Repository navigation
Commit 23a07c8
fix(plugin-audit): a registered audit seam that fails to resolve stops the sealer instead of falling back (#34495)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi96xkbCcbB1nF3xM9vBtrWwE)_
Fixes #34280
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么:**
审计封存器每轮取宿主的签名服务、导出服务和集群服务时,分清三种情况:没注册就用本机兜底(和以前一样);注册了能取到就用;注册了却取不到(比如
KMS 客户端起不来)就这一轮不封存,并报一条 error 点名哪个服务。
- **为什么改:** 以前「取不到」被当成「没注册」,于是悄悄改用本机密钥签名、悄悄不导出、悄悄不加集群锁,没有任何日志;客户以为是 KMS
签的,其实不是。另外用工厂方式注册的签名服务以前根本取不到,也被悄悄忽略。
- **风险与回滚:** 只影响注册了这三个服务的宿主;配置坏掉的宿主从「悄悄降级」变成「停止封存并报错」,配置正常的宿主无变化。回滚即还原本
PR。
- **先看:** `packages/plugins/plugin-audit/src/audit-seal/sealer.ts` 的
`resolveSeams`;`packages/plugins/plugin-audit/src/audit-plugin.ts` 末尾的
`hostSeamResolver`。
- **两分钟验证:** `cd packages/plugins/plugin-audit && npx vitest run
src/audit-seal/audit-seal-host-seam-resolve-34280.integration.test.ts`,预期
5 条全绿。
- **需要你做的:** 无,席位落地。
## What changes
- `audit-seal/sealer.ts`: a pass resolves its three host seams
(`audit.checkpointSigner`, `audit.checkpointSink`, `cluster`) once, at
its start, in `resolveSeams()`. A getter that answers `undefined` means
"not registered" and keeps its stand-in (local signer, no export,
in-process lock). A getter that throws means "registered and not
resolvable": the pass seals nothing and reports at `error`, naming the
slot and the fallback it refused, once per `REPORT_REPEAT_MS` while it
lasts (the sealer's existing `report()` discipline). The resolved sink
and cluster are handed to the lock and the object passes; the lock no
longer absorbs a throwing cluster getter, and delivery no longer
re-resolves the sink per checkpoint. A sink whose `deliver()` fails is
still only a warning, unchanged. The getters may now return a promise;
`AuditSealer` is not exported from the package root.
- `audit-plugin.ts`: `startSealer` resolves each seam with
`hostSeamResolver`, which uses the kernel's async accessor and absorbs
only the branded "never registered" rejection
(`isServiceNotRegisteredError`, `@objectstack/core`), the pattern
`service-automation` already uses for `tenancy`. Every other rejection
propagates. The async accessor also builds a factory-registered seam,
which the sync accessor refused with "is async" and the old helper read
as absent. A host with no async accessor (`LiteKernel`, no factories)
keeps the sync accessor, where "not registered" is the only fault.
## Tests
New
`src/audit-seal/audit-seal-host-seam-resolve-34280.integration.test.ts`,
on a real `ObjectKernel` with ObjectQL over SQLite (wasm):
1. No host signer: one checkpoint, signed under the local key (its
fingerprint is the only `sys_audit_signing_key` row); no error.
2. Host signer registered as a factory that throws: `runPass()` → 0, no
checkpoint, no local key created, exactly one error naming
`audit.checkpointSigner` and "does not sign with the local key"; a
second pass adds no second line.
3. Host signer that resolves, as an instance and as a factory: the
checkpoint carries the host key id and verifies under the host public
key; no local key created.
4. Sink factory that throws: nothing sealed, one error naming
`audit.checkpointSink`; a resolving sink factory is handed the
checkpoint.
5. Cluster factory that throws: nothing sealed, one error naming
`cluster`.
Ablation (fix reverted, test kept): cases 2–5 red (`expected 1 to be +0`
for 2/4/5; case 3's factory leg signs under the local key), case 1
green.
No existing test changed. `plugin-audit`: 100 files / 1659 tests green;
`pnpm typecheck` (incl. `check:test-typecheck`) green.
## Acceptance notes
- **Narrowing declaration (the card asks the dev to measure it):**
`Clause-②: no`. No key, config value or service shape a host writes is
refused; what changes is the reaction to a registration that already
fails. A host whose signer, sink or cluster registration threw used to
seal silently with the local key or without its lock and now seals
nothing until it is fixed, which is the card's rule. A working host sees
no change. The changeset says this in its last paragraph.
- **Same-family site, not changed here (out of the claimed file
surface):** `packages/cli/src/utils/audit-redaction-seal.ts` resolves
`audit.checkpointSigner` / `audit.checkpointSink` with the same
catch-all helper, so a CLI redaction run with a failing host signer
falls back to the local signer in `amendment-writer.ts`. Handed to the
seat for a follow-up card.
- "Logged once": the line repeats at most once per `REPORT_REPEAT_MS`
while the fault lasts, as every other sealer fault does; the test pins
that a second pass inside the window adds no line.
## Verification
Gates per `node scripts/pm/dispatch-gates.mjs --commands` after the last
commit: see the `os-dev-report` comment on #34280.
Co-authored-by: Claude <noreply@anthropic.com>1 parent 047f37b commit 23a07c8
4 files changed
Lines changed: 326 additions & 30 deletions
File tree
- .changeset
- packages/plugins/plugin-audit/src
- audit-seal
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
835 | 835 | | |
836 | 836 | | |
837 | 837 | | |
838 | | - | |
839 | | - | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
840 | 841 | | |
841 | 842 | | |
842 | 843 | | |
| |||
848 | 849 | | |
849 | 850 | | |
850 | 851 | | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
| 852 | + | |
858 | 853 | | |
859 | 854 | | |
860 | 855 | | |
861 | | - | |
862 | | - | |
863 | | - | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
864 | 859 | | |
865 | 860 | | |
866 | 861 | | |
| |||
1103 | 1098 | | |
1104 | 1099 | | |
1105 | 1100 | | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
0 commit comments