You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ed45eb9
Browse filesBrowse the repository at this point in the historyBrowse files
fix(cli): an os migrate audit-* run stops when a registered host signer or sink fails to resolve (#34569)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi96xkbCcbB1nF3xM9vBtrWwE)_Fixes#34519
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么:** `os migrate audit-*`
四个改写命令在改写已封存的行之前要先签一份修订;签名时取宿主的签名服务和导出服务。现在和封存器(#34280)一样分三种情况:没注册就用本机钥(不变);注册了能取到就用;注册了却取不到就整次运行报错退出,不改任何行。
- **为什么改:** 以前「取不到」被当成「没注册」,修订会悄悄改用本机钥签名,导出也悄悄丢掉;工厂方式注册的签名器也取不到。这和
#34280 修掉的封存器问题同一形状。
- **风险与回滚:** 只影响注册了签名器或导出服务、且注册已经坏掉的宿主:从悄悄降级变成报错退出(exit
1)。配置正常的宿主无变化。回滚即还原本 PR。
- **先看:** `packages/cli/src/utils/audit-redaction-seal.ts` 末尾的
`hostSeam`;四个命令里 `await redaction.seal(...)` 一行。
- **两分钟验证:** `cd packages/cli && npx vitest run
src/utils/audit-redaction-seal.host-seam-34519.test.ts`,预期 4 条全绿。
- **需要你做的:** 无,席位落地。
## What changes
- `packages/cli/src/utils/audit-redaction-seal.ts`:
`RedactionSealRun.seal()` is now async and resolves
`audit.checkpointSigner` and `audit.checkpointSink` through
`hostSeam()`: the kernel's `getServiceAsync`, absorbing only the branded
"never registered" rejection (`isServiceNotRegisteredError`,
`@objectstack/core`); every other rejection becomes `Audit redaction
seal: the '<slot>' service is registered but could not be resolved
(<cause>) — no sealed row is amended or rewritten; the run does not
<fallback> in place of a service the host registered. …`, with the cause
attached. A kernel with no async accessor keeps the sync read, where
"not registered" is the only fault. This is the rule and the wording of
PR #34495 (the sealer, #34280).
- The four commands (`audit-key-material`, `audit-mail-bodies`,
`audit-metadata-bodies`, `audit-side-copies`): `const seal = await
redaction.seal(stack.kernel, engine);`. The call already sat inside the
try whose catch prints the error (or the `--json` error object) and
exits 1, before `underAuditSealLock`, so a rejection stops the run
before any row is amended or rewritten.
- `content/docs/deployment/cli.mdx` (Sealed audit rows): one paragraph
says who signs the amendments (the host signer when registered, the
local key when none) and that a signer or sink registered but not
resolvable stops the run with exit 1, never falling back to the local
key.
## Tests
- New `src/utils/audit-redaction-seal.host-seam-34519.test.ts` (real
`ObjectKernel` service registry; the crypto composition is stubbed to
"no provider", which a run survives):
1. nothing registered: `signer` and `sink` are `undefined`, so the
amendment writer signs with the local key, as before;
2. a signer factory that throws: `seal()` rejects with the slot name,
the cause and "does not sign with the local key";
3. a sink factory that throws: `seal()` rejects naming
`audit.checkpointSink`;
4. a signer that resolves, as an instance and as a factory, is handed
over.
- `audit-redaction-seal.contract.test.ts`: one new pin per command:
`seal()` is awaited exactly once, before the `underAuditSealLock(` hold.
- Ablation (fix reverted, tests kept): 7 red (cases 2–4 and the four
await pins), case 1 green.
- The new test imports `@objectstack/service-settings` at module top, as
`check:test-source-alias` asks (the util's static reach names it through
the mocked `one-shot-settings.js`).
- No existing assertion changed. `packages/cli`: `pnpm typecheck` (incl.
`check:test-typecheck`) green; `src/commands/migrate/` + the new file:
75 files, 606 passed / 8 skipped.
## Acceptance notes
- The card names the signer; the sink rides the same helper and the same
rule, as in PR #34495, so it is covered here too.
- `Clause-②: no`: no key, flag or config value an operator writes is
refused; a run on a host whose signer or sink registration already fails
now exits 1 instead of amending under the local key.
## Verification
Gates per `node scripts/pm/dispatch-gates.mjs --commands` after the last
commit: see the `os-dev-report` comment on #34519.
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmRPxhTmqbUbMrqygh4 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(cli): an `os migrate audit-*` run stops when the host's checkpoint signer or sink is registered but fails to resolve, instead of amending under the local key
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
The four `os migrate audit-*` ledger-copy rewrites amend a sealed row before they rewrite it (ADR-0154 D7), signing the amendment with the host's `audit.checkpointSigner` when one is registered and the local key otherwise. The CLI read that slot, and `audit.checkpointSink`, through a helper that turned every resolution error into "not registered". A host signer whose factory threw (a KMS client that cannot start, a missing credential) was therefore replaced by the local key, and a failing sink dropped the export, with nothing said. A signer registered as a factory was never built at all.
11
+
12
+
The run now follows the rule the sealer follows since #34280. No host signer registered still amends under the local key, and no sink exports nothing, as before. A registered signer or sink that resolves is used, including one registered as a factory. One that is registered and fails to resolve stops the run before any row is amended or rewritten: it prints `Audit redaction seal: the '<slot>' service is registered but could not be resolved (<cause>)` and exits 1. A working host sees no change.
0 commit comments