Skip to content

Commit ac0b9a5

Browse files
fix(plugin-audit)!: seal a window into checkpoints of at most 10,000 rows, and bound the idle re-walk (P4b2) (#33637)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DXuamRUC67fx2TTYrFfyuSH)_ Part of #31908 (slice P4b2) Blocked-by: #33489 (governed ADR-0154 amendment; merged to `main` as 8f915f2, which this branch now contains) Clause-②: yes (narrowing) — narrowed: `os audit verify` reports a row id that two checkpoints list as the new chain fault `listed_twice` and fails the run, where the 18.4.0 verifier accepted it, and the 18.4.0 sealer could write such a chain when two of its late sealings overlapped. Widened: two optional signed-body fields (`part_index`, `final_part`), two nullable `sys_audit_checkpoint` columns for them, and the `AuditChainFaultKind` member `listed_twice`. Metadata-protocol: none Skills-docs: follow-up #33773 — skills/objectstack-data/evals/objects-fields-relationships.json, skills/objectstack-data/rules/lifecycle.md — both still teach that the sealer signs each `created_at` hour into one checkpoint per organization, where this change cuts a window into checkpoints of at most 10,000 rows each (the eval's graded `expected_output`, and `lifecycle.md` § Sealing); the card also carries their older stale claim that no verifier exists, which `os audit verify` already contradicts. `skills/**` is changed only on a `domain:skills` PR, so this one does not edit them; `content/docs/data-modeling/objects.mdx` and `content/docs/deployment/cli.mdx` gain the parts, the new fault and what a removed checkpoint shows in this change. **BREAKING** for `os audit verify` on a chain that an 18.4.0 sealer wrote while two of its late sealings overlapped (two replicas with no cluster service, whose lock is in-process only, or a lease that lapsed). Such a chain lists one late row in two checkpoints. Verify now reports it as `listed_twice` and fails, where it passed. No tolerance and no repair ships for it (seat ruling 6888674846 item 1). A chain one sealer wrote at a time is not affected. ADR-0087 disposition, in the changeset: `not-required (no-migration-prescription)`. `@objectstack/plugin-audit` stays `patch`, because `Metadata-protocol: none`. ## Maintainer quick read - **What changed:** the audit sealer now seals each organization's hour of audit rows into checkpoints of at most 10,000 rows each, instead of one checkpoint of any size. `os audit verify` now fails when two checkpoints list the same row. While one organization's chain is stuck, a pass stops re-reading old windows after 168 windows that seal nothing, and once no chain is stuck the walk is not cut, so sealing catches up. - **Why:** one busy hour made one huge checkpoint, so the work and memory of a single seal grew without limit. And while one chain stayed stuck on a bad row, every hourly pass re-read every row since that window. Seat ruling 6884540128 item 1 (S7) and review#3 S1 on #33503 ask for both bounds. - **Risk and rollback:** this changes how new checkpoints are cut, not the insert path. Checkpoints written before this release still verify, as one final part. Upgrading is one way once this release writes a checkpoint: an 18.4.0 verifier fails the signature of every checkpoint that carries the two new fields, and an 18.4.0 sealer's next checkpoint is a `link` fault. No object opts into sealing by default, so this only matters for an app that declared `lifecycle.seal`. - **Look first:** `packages/plugins/plugin-audit/src/audit-seal/sealer.ts` (the walk in `run` and what counts toward the idle cap, the S1 re-check in `writeCheckpoint`, `writeChain`, `leavesOf`), then `signed-body.ts` (`checkpointPartOf` and the part docblocks), then `verifier.ts` (`listed_twice` in `judgeCheckpoint`). - **Two-minute check:** `pnpm --filter @objectstack/plugin-audit exec vitest run --maxWorkers=2 src/audit-seal/audit-seal-sealer.test.ts`: expect 52 passed, including the "bounded checkpoints" and "uncounted re-walk" groups. - **What you need to do:** nothing: #33489 has merged, and the seat lands this once review passes. ## What changes **S7: bounded checkpoints (ADR-0154 D4 as amended in #33489).** - A chain's window seals into consecutive checkpoints of at most `AUDIT_SEAL_MAX_LEAVES = 10_000` leaves. N is a fixed exported constant, not a knob. The internal `AuditSealerOptions.maxLeaves` is a test seam beside `now`. `AuditPlugin` never passes it, and the sealer is not exported from the package. - Parts are cut in D1 order, `(created_at, id)`, and each part's leaves are in that order. Each part draws its own seed (D2), so one seed still covers one checkpoint. - A window is read twice: once for each row's id and canonical `created_at`, then each part's rows by id, in `$in` batches of 500, hashed under that part's seed. So one checkpoint's hashing, ids, body and memory are bounded by N. A row deleted or moved between the two reads is left out of its part. - The signed body gains `part_index` (from 0) and `final_part`. `sys_audit_checkpoint` stores them in two new nullable columns. - Resume: a chain whose newest `window` checkpoint is not final resumes that window as further `window` parts. They continue its part count and seal only rows no checkpoint lists yet. They are never sealed as `late`. - `late` sealings split the same way. A late part's index counts within that one late sealing (the prose line for this is on #33489, seat ruling 6888674846 item 2). - The sealer's S1 check ("not sealed twice") is relaxed for parts. A `window` part is refused when the chain already holds a later window, a part of this window at this index or past it, or a checkpoint of this window written before the amendment (NULL part index). - `os audit verify` faults a row id that two checkpoints list, as the new fault kind `listed_twice`. The second listing holds nothing for that row. - Compatibility: a checkpoint with neither field (written before this release, NULL columns) reads back without them. Its signed bytes are unchanged, so it verifies and reads as one final part. A body with one field and not the other is refused. **What verify does and does not see of a removed part (seat ruling 6888674846 item 3).** Verify adds no continuity check and no final-part check. The chain links expose a removed *interior* part, as a `gap` or a `link` fault. They do not see a removed *newest* part; its rows are reported as late and unsealed instead, because a surviving part of the same window still names that window as sealed. A final part cannot be required, because `writeChain` skips a part whose rows all went between the two reads: `part_index` can then skip a number, and a window whose last part emptied has no final part. **review#3 S1: bounded idle re-walk.** The separate cap `AUDIT_SEAL_MAX_IDLE_WINDOWS_PER_PASS` (168, one late horizon of windows) counts windows that seal nothing, and only while a chain is skipped in the pass. A pass that has walked that many stops walking, and the sealer reports it at `error`, naming the skipped chains. With no chain skipped the walk is not cut, so it reaches the next window that seals something and the floor moves past the rest. Why the cap and not the seek. Seeking from the minimum per-chain cursor is only correct if the sealer knows every chain that still has rows. Per-chain cursors exist only for chains with a `window` checkpoint at or past the floor. Two kinds of chain are missing from that set: - a chain skipped at a later window than the one holding the floor; - a chain with no checkpoint since the floor. Neither is recorded anywhere durable. A seek would pass over their windows, and once the floor moved their on-time rows would seal as `late`. That breaks S4's rule that a skipped chain resumes "from its own oldest unsealed window" as `window` checkpoints. The cap never changes how a row seals, only when. Its cost: after about a week of a chain that stays skipped, chains past the cap wait for it, and that is loud. The window-major pin and the no-late-sweep pin from P4b1 are unchanged and green. **Docs.** `content/docs/data-modeling/objects.mdx` said each hour seals into one checkpoint per organization; it now says one checkpoint, or consecutive checkpoints of at most 10,000 rows. `content/docs/deployment/cli.mdx` gains what verify shows of a removed checkpoint, and its exit code 1 entry now names a row that two checkpoints list. **Spec.** The signed body is declared in `plugin-audit` (`audit-seal/signed-body.ts`), not in `packages/spec`. There is no Zod schema, generated JSON schema or reference doc for it, so nothing in spec is regenerated. ## Round 2: what each item of review#3 got - **M1** (ff13294): the changeset and this body declare `Clause-②: yes (narrowing)`, carry the BREAKING banner, and the changeset holds one ADR-0087 marker, `not-required (no-migration-prescription)`, stating that a chain sealed by 18.4.0 with overlapping late sealers now reports `listed_twice`. `Metadata-protocol: none`, so `patch`. No tolerance or heal code. - **M2** (6bb7f49, ff13294, this body): the wording above, in the `part_index` / `final_part` docblocks and in the changeset. Pinned: a removed interior part is a `gap`, and a removed newest part reads unsealed with no chain fault. - **N1** (ff13294): the one-way upgrade note is in the changeset. - **N2** (6bb7f49): the S1 re-check's `$or` gains `{ window_start in this window, part_index: { $null: true } }`. The seal-store testkit now judges a `where` as SQL does (a comparison with a NULL column is never true, and `$null` is `IS NULL`), so the pin is red without the arm. - **N3** (b189644, e930216): the five pins asked for, plus an emptied middle part. See Tests. - **N4** (6bb7f49): the `part_index` docblock says the count may skip an emptied part. - **Found while pinning N3's last item, fixed here** (6bb7f49): the idle cap never let go. It counted every window that sealed nothing, skipped chain or not. Once the stuck chain was fixed, the windows the cap had left behind still counted, so the walk stopped short of the next window that seals something again. No checkpoint was written, the floor never moved, and the object never sealed past the cap. That held whether the stuck row was corrected in place or deleted. The cap now counts only while a chain is skipped in the pass. - **Docs** (f08afca): the two pages above, which this PR had made false or incomplete, and the changeset's `Skills-docs:` line that the `(narrowing)` arm owes. - The base moved to `main` after #33503 merged; `origin/main` is merged in (faadaaa, then 60960cd, which brings in #33489), and this PR's diff against `main` is P4b2 alone. - b234eee (another agent, test-only): a 30 s budget on the three stalled-chain re-walk tests, after a Test Core timeout. The local runs below predate it. - 5ef334e merges `main` again (412fbf7); the full dogfood battery at 5ef334e ran green, 467 test files and 3958 tests. 55dfebc (review#3 record 6891899947, M1): the changeset's `Skills-docs:` line and this body's now name the filed follow-up card, #33773, in place of `follow-up owed` and `none`. ## Why Seat ruling 6884540128 item 1 (S7), with the ADR-0154 amendment in #33489. review#3's should-fix S1 on #33503 (comment 6885454935). review#3 on this PR (comment 6888713592) and seat rulings 6888674846. ## Tests Each new pin that covers new behaviour was run red before its fix. Round 1: the pins were committed first (4827322), the implementation files were set back to the base, and the pins were run. 10 failed: the seven S7 sealer pins, the duplicate-id verifier pin, two signed-body pins, and the idle re-walk pin, which read **200** windows in one pass before the cap. The pin "a checkpoint written before the amendment still verifies" was run red against the first implementation, before the compatibility fix in 0dd58a8. Round 2: the pins were committed first (b189644, then e930216 for one precondition) and run against the round-1 implementation, on the tree merged with `main`: - red: the pre-amendment S1 pin (`expected 1 to be +0`: a second `window` checkpoint listing `r1` was written); - red: both re-seal pins after the idle cap, once the stuck row was fixed in place and once it was deleted (`expected [ 'a0', … (182) ] to deeply equal [ 'a0', … (197) ]`, and the same with 181 and 196: 15 of org_a's rows never sealed); - green, as they pin behaviour round 1 already had: the tie across a part boundary, a row deleted or moved between the reads, an emptied middle part, an emptied last part and its resume, and the removed interior and newest parts. New pins this round, in `audit-seal-sealer.test.ts`: - A window part is refused beside a pre-amendment checkpoint of that window that another sealer wrote after this pass read the window (NULL part columns, re-signed without the keys); the error names the part, and the ledger verifies. - A `created_at` tie that straddles a part boundary cuts the same way whichever order the rows were written in: the id decides the side. - A row deleted, or moved to the next window, between the two reads is left out of its part; the moved row seals in its new window. - A middle part that empties between the reads is skipped without taking its index: parts 0 and 2. - A last part that empties leaves the window with no final part; the next pass writes nothing, and a row that arrives in that window afterwards is `window` part 1, final, never `late`. - A removed interior part is a `gap` fault and its rows read unsealed; a removed newest part raises no chain fault and its rows read unsealed. - After the idle cap was hit, the whole object seals again once the stuck chain's row is fixed in place, and once it is deleted: every row is listed exactly once, none as `late`, and the second case verifies ok. <details><summary>plugin-audit suite at f08afca, merged with main at 8f915f2 (under os-verify-lock)</summary> ``` pnpm --filter @objectstack/plugin-audit test && pnpm --filter @objectstack/plugin-audit typecheck Test Files 94 passed (94) Tests 1541 passed (1541) check:test-typecheck: OK — @objectstack/plugin-audit's test layer compiles under packages/plugins/plugin-audit/tsconfig.test.json os-verify-lock: VERDICT command-exit 0 · held the lock 146s (2m26s) ``` </details> <details><summary>The round-2 red runs, before 6bb7f49 (under os-verify-lock)</summary> ``` vitest run src/audit-seal/audit-seal-sealer.test.ts (at faadaaa, tests of b189644) × refuses a window part when the chain, re-read under the lease, holds a checkpoint of that window written before the amendment ... (S1, N2) AssertionError: expected 1 to be +0 × seals the whole object again once the skipped chain is fixed ... (failed on its precondition, corrected in e930216) × seals the whole object again once the skipped chain has nothing left to seal ... Tests 3 failed | 49 passed (52) vitest run src/audit-seal/audit-seal-sealer.test.ts -t "uncounted re-walk" (at e930216) × seals the whole object again once the skipped chain is fixed ... AssertionError: expected [ 'a0', 'a1', 'a10', 'a100', …(182) ] to deeply equal [ 'a0', 'a1', 'a10', 'a100', …(197) ] × seals the whole object again once the skipped chain has nothing left to seal ... AssertionError: expected [ 'a0', 'a1', 'a10', 'a100', …(181) ] to deeply equal [ 'a0', 'a1', 'a10', 'a100', …(196) ] Tests 2 failed | 1 passed | 49 skipped (52) ``` </details> ## Acceptance notes - **Part index of a `late` part** counts within the one late sealing that wrote it. A second late sealing of the same window starts at 0 again. Seat ruling 6888674846 item 2 accepts this; its prose line is on #33489. - **A part whose rows all went** between the two reads is not written and takes no index, so `part_index` can skip a number. If that was the last part, the window has no final part; the next pass resumes it, and a row that arrives in it later seals as the next `window` part. Verify checks neither part continuity nor a final part. The chain links show a removed interior part as a `gap` or `link` fault; they do not show a removed newest part, whose rows read unsealed instead. When the removed checkpoint was the only one naming the object's newest window, that is ADR-0154's head truncation, which this check alone cannot see. - **Rows moved between the two reads** (a changed `created_at` or `tenant_id`) are left out of the part. They are sealed later in their new window (as `late` if that window is already sealed), or the verifier reports them. - **The S1 re-check against a pre-amendment checkpoint** matters only when a sealer of an earlier release runs beside this one during a rolling upgrade with no cluster lock; the unique `(sealed_object, chain_key, sequence)` index does not cover it, because the later pass reads the chain head after the other sealer's insert. ## Verification All local runs below were at head f08afca, the tree merged with `main` at 8f915f2, except the direct dependents: I ran them at ff13294 (merged with `main` at d95ddeb), and the A2 landing step that merged `main` in ran them again at 60960cd, which differs from f08afca only in two docs pages and the changeset (cli unit 421 files / 5979 tests, verify 51 / 437, service-storage 86 / 1651 passed and 1 skipped, plugin-security 267 / 6681 passed and 45 skipped, service-automation 282 / 3976; all exit 0). - `pnpm --filter @objectstack/plugin-audit typecheck`: exit 0. Tests are included through `check:test-typecheck`. - eslint `--no-inline-config` on the 8 changed source and test files: exit 0. - `node scripts/check-test-source-alias.mjs`, `node scripts/check-nul-bytes.mjs`: exit 0. - `check-adr-0087-registration --base origin/main`: exit 0, one declared-breaking changeset, `not-required (no-migration-prescription)`. - `check-changeset-no-major --base origin/main` with this body as the `pull_request` payload: exit 0, "declares clause-② `yes (narrowing)` and metadata-protocol `none` ... a non-protocol change at `patch`". - Direct dependents of `@objectstack/plugin-audit`, after building their closure: `typecheck` exit 0 for `cli`, `verify`, `service-storage`, `service-automation` and `plugin-security`. Tests: `cli` unit layer 421 files / 5972 tests passed (its integration layer is CI's); `verify` 51 / 437; `service-storage` 86 / 1641 passed, 1 skipped; `plugin-security` 267 / 6679 passed, 45 skipped; `service-automation` 282 / 3959. All exit 0. - `dispatch-gates --commands`: 97 derived on this tree (the docs pages add 31 doc families), all run. 96 exit 0, including `check:doc-authoring`, the `docs-audit` checks, `check:i18n`, `check:dts-closure` and `check:dual-build-cjs-loads`. 1 exits 3, PREREQUISITE NOT MET, so NOT MEASURED: `check-plugin-teardown-shape --self-test` (needs an unshallow clone; its scan is green). `dispatch-gates --ran` with the exit codes: 97 derived, 96 run, 1 NOT-MEASURED, 0 UNRUN. - Full dogfood battery (owed by the `(narrowing)` arm): at ff13294, `pnpm --filter @objectstack/dogfood test` under os-verify-lock gave `Test Files 467 passed | 3 skipped (470)`, `Tests 3953 passed | 42 skipped`, `VERDICT command-exit 0` (28m49s). NOT MEASURED at f08afca: the re-run was stopped during its closure build when the area thread asked for the report. Since ff13294 this branch gained the `main` merge, two docs pages, the changeset line and the test-only b234eee, and no change to this PR's code. - CI at ff13294: `TypeScript Type Check`, `Lint & Repo Gates`, `Check Changeset`, `Build Core`, `Governed Surface Queue Guard` and the eight `Test Core` shards concluded success. The reds on b189644, faadaaa and 6bb7f49 were lanes concluded `cancelled` by my next push (no `error TS` in those logs), not failures. CI at f08afca is in the round-2 report on #31908. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (spec not touched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; eslint is green on the changed files (`pnpm lint` is CI's). - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: n/a. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cyNkH7W7e89m6j4aQq <!-- signed: domain:server#5 · os-elon-musk · session_016WV4cyNkH7W7e89m6j4aQq --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1e65a38 commit ac0b9a5

32 files changed

Lines changed: 800 additions & 51 deletions
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
'@objectstack/plugin-audit': patch
3+
---
4+
5+
fix(plugin-audit)!: the audit sealer seals a window into checkpoints of at most 10,000 rows each, `os audit verify` fails on a row two checkpoints list, and a pass bounds what it re-reads while a chain stays skipped
6+
7+
Clause-②: yes (narrowing) — narrowed: `os audit verify` reports a row id that two checkpoints list as the new chain fault `listed_twice` and fails the run, where the 18.4.0 verifier accepted it, and the 18.4.0 sealer could write such a chain when two of its late sealings overlapped. Widened: the checkpoint's signed body gains two optional fields, `part_index` and `final_part`; `sys_audit_checkpoint` gains two nullable columns for them; and the exported `AuditChainFaultKind` union gains `listed_twice`.
8+
Metadata-protocol: none
9+
Skills-docs: follow-up #33773 — skills/objectstack-data/evals/objects-fields-relationships.json, skills/objectstack-data/rules/lifecycle.md — both still teach that the sealer signs each `created_at` hour into one checkpoint per organization, where this change cuts a window into checkpoints of at most 10,000 rows each (the eval's graded `expected_output`, and `lifecycle.md` § Sealing); the card also carries their older stale claim that no verifier exists, which `os audit verify` already contradicts. `skills/**` is changed only on a `domain:skills` PR, so this one does not edit them; `content/docs/data-modeling/objects.mdx` and `content/docs/deployment/cli.mdx` gain the parts, the new fault and what a removed checkpoint shows in this change.
10+
11+
<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value or metadata type is added, removed or renamed: the moved answer is a verify verdict over stored audit checkpoints, which no metadata author writes. Nothing stored is rewritten and no tolerance or repair is shipped, so a chain sealed by 18.4.0 with overlapping late sealers now reports listed_twice. -->
12+
13+
**BREAKING** for `os audit verify` on a chain that an 18.4.0 sealer wrote while two of its late sealings overlapped (two replicas with no cluster service, whose lock is in-process only, or a lease that lapsed). Such a chain lists one late row in two checkpoints. Verify now reports it as a `listed_twice` fault and fails, where it passed. No tolerance and no repair ships for it. A chain one sealer wrote at a time is not affected.
14+
15+
**Bounded checkpoints (ADR-0154 D4, as amended 2026-11-14).** A chain's rows of one window now seal into consecutive checkpoints of at most 10,000 rows each, cut in `(created_at, id)` order, instead of one checkpoint however many rows the window holds. Each checkpoint has its own seed. Its signed body carries two new fields, `part_index` (from 0) and `final_part`, and `sys_audit_checkpoint` stores them in two new nullable columns. A pass that stops in the middle of a window resumes it on the next pass as further `window` checkpoints, never as `late` ones. Late rows split into checkpoints of at most 10,000 rows the same way. The work and memory of one checkpoint no longer grow with the window. A checkpoint written before this release has neither field. It still verifies, reads as one final part, and its chain goes on. `part_index` can skip a number, and a window can end with no final part: a part whose rows were all deleted or moved between the sealer's two reads of the window is not written.
16+
17+
**`os audit verify`.** A row id that two checkpoints list is now a fault of the new kind `listed_twice`, and the run fails. The second listing holds nothing for that row. Verify does not check that a window's parts are continuous or that it ends in a final part. The chain links show a removed interior part, as a `gap` or a `link` fault. They do not show a removed newest part; that part's rows read as late and unsealed instead.
18+
19+
**Skipped chains.** While a chain stays skipped by a chain-local fault, it holds back the sealed-through watermark, so each pass walked every window from there and re-read all of them. Now, while a chain is skipped, a pass walks at most 168 windows that seal nothing (one late horizon) and then stops. When it stops, the sealer says so at `error`, naming the skipped chains. Once no chain is skipped, the walk is not cut, so sealing catches up whether the chain's fault was fixed or the chain has nothing left to seal.
20+
21+
**Upgrading is one way once this release writes a checkpoint.** An 18.4.0 reader does not know `part_index` and `final_part`. The 18.4.0 verifier drops them and then fails the signature of every checkpoint that carries them. An 18.4.0 sealer computes the chain head's digest without them, so the checkpoint it writes next is a `link` fault. Roll back to 18.4.0 only before this release seals its first checkpoint. A host's checkpoint sink receives the two fields in each body.

‎content/docs/data-modeling/objects.mdx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,11 @@ lifecycle: {
222222
}
223223
```
224224

225-
- Each hour of `created_at` is sealed ten minutes after it ends: one
226-
checkpoint per organization (and one for rows about no organization),
227-
holding a Merkle root over the rows, signed with the deployment's Ed25519
225+
- Each hour of `created_at` is sealed ten minutes after it ends, per
226+
organization (and once for rows about no organization): into one
227+
checkpoint, or, when the hour holds more than 10,000 such rows, into
228+
consecutive checkpoints of at most 10,000 rows each. Each checkpoint holds a
229+
Merkle root over its rows and is signed with the deployment's Ed25519
228230
key. A row that arrives later in a sealed hour is sealed as a `late`
229231
checkpoint; rows that already exist when sealing starts are sealed oldest
230232
first, archived rows included.

‎content/docs/deployment/cli.mdx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,12 @@ Each row a checkpoint lists reads as one of:
800800
A row in a sealed window that no checkpoint lists is reported `late` and **unsealed**: on
801801
the host alone it cannot be told from a forged insert.
802802
803+
A checkpoint removed from a chain shows as a gap in the chain's links, unless it was the
804+
chain's newest: the links cannot see that one. Its rows then read `late` and unsealed
805+
while their window still counts as sealed (another checkpoint of the object names that
806+
window, or one's sealed-through passes it); otherwise the removal does not show. A row
807+
that two checkpoints list is a fault of its own.
808+
803809
Trust comes only from the deployment's own signing key. A key is trusted only when its
804810
wrapped private half opens with the crypto provider `os serve` seals with (the declaring
805811
plugin's, or the existing data key from `OS_SECRET_KEY` or the persisted key file; this
@@ -811,8 +817,9 @@ Exit codes:
811817
812818
- **0**: every chain, link and signature verifies under a trusted key, and every row is
813819
`unmodified`, `late` (sealed), `redacted` or `expired`. Also 0 when nothing is sealed.
814-
- **1**: a row is `modified`, `missing` or `late` and unsealed, or a link or signature
815-
fails. The report names every row that is not `unmodified` and every fault.
820+
- **1**: a row is `modified`, `missing` or `late` and unsealed, a link or signature
821+
fails, or two checkpoints list the same row. The report names every row that is not
822+
`unmodified` and every fault.
816823
- **2**: no verdict is given. The cause is one of these: a usage error, a stack that would
817824
not boot, a crypto provider that cannot open what is sealed, an archive datasource a
818825
sealed object declares that this run did not connect (every archived row would read

‎packages/plugins/plugin-audit/src/audit-seal/audit-seal-core.test.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ describe('signed bodies (D4, D7, D8)', () => {
253253
tenant_id: 'org_1',
254254
sequence: 3,
255255
kind: 'window',
256+
part_index: 0,
257+
final_part: true,
256258
window_start: '2026-11-10T04:00:00.000Z',
257259
window_end: '2026-11-10T05:00:00.000Z',
258260
sealed_through: '2026-11-10T05:00:00.000Z',
@@ -279,6 +281,8 @@ describe('signed bodies (D4, D7, D8)', () => {
279281
window_end: '2026-11-10 05:00:00',
280282
sealed_at: Date.parse(body.sealed_at),
281283
fencing_token: 17,
284+
part_index: '0',
285+
final_part: 1, // a driver with no boolean column hands back 1 / 0
282286
};
283287
const back = checkpointBodyFromRow(driverRow);
284288
expect(back).toEqual(body);
@@ -304,6 +308,8 @@ describe('signed bodies (D4, D7, D8)', () => {
304308
{ ...body, tenant_id: 'org_2' },
305309
{ ...body, sealed_through: '2026-11-10T06:00:00.000Z' },
306310
{ ...body, seed_handle: 'sec_other' },
311+
{ ...body, part_index: 1 },
312+
{ ...body, final_part: false },
307313
]) {
308314
expect(checkpointDigest(checkpointBodyFromRow(changed))).not.toBe(digest);
309315
}
@@ -323,6 +329,10 @@ describe('signed bodies (D4, D7, D8)', () => {
323329
{ ...body, columns: { clear: ['id', 'created_at'], committed: [] } },
324330
{ ...body, columns: { clear: ['id'], committed: ['id'] } },
325331
{ ...body, fencing_token: '-1' },
332+
{ ...body, part_index: -1 },
333+
{ ...body, part_index: undefined },
334+
{ ...body, final_part: undefined },
335+
{ ...body, final_part: 'yes' },
326336
]) {
327337
expect(() => checkpointBodyFromRow(bad as unknown as Record<string, unknown>), JSON.stringify(bad).slice(0, 80)).toThrow(SignedBodyError);
328338
}
@@ -400,6 +410,8 @@ describe('the deployment chain signs a NULL organization (D5)', () => {
400410
tenant_id: null,
401411
sequence: 0,
402412
kind: 'window',
413+
part_index: 0,
414+
final_part: true,
403415
window_start: '2026-11-10T04:00:00.000Z',
404416
window_end: '2026-11-10T05:00:00.000Z',
405417
sealed_through: '2026-11-10T05:00:00.000Z',
@@ -467,7 +479,7 @@ describe('a redaction names its checkpoint by the signed sequence (D7)', () => {
467479

468480
it('declares one checkpoint column per stored field, the sequence a redaction refers to among them', () => {
469481
const body: CheckpointSignedBody = {
470-
sealed_object: 'sys_audit_log', tenant_id: null, sequence: 0, kind: 'window',
482+
sealed_object: 'sys_audit_log', tenant_id: null, sequence: 0, kind: 'window', part_index: 0, final_part: true,
471483
window_start: '2026-11-10T04:00:00.000Z', window_end: '2026-11-10T05:00:00.000Z',
472484
sealed_through: '2026-11-10T05:00:00.000Z', leaf_count: 1, row_ids: ['r1'], root: 'a'.repeat(64),
473485
previous_digest: null, columns: { clear: ['created_at', 'id'], committed: [] },
@@ -482,7 +494,7 @@ describe('a redaction names its checkpoint by the signed sequence (D7)', () => {
482494

483495
describe('NULL names the deployment chain only when it is stated (D5)', () => {
484496
const checkpoint: CheckpointSignedBody = {
485-
sealed_object: 'sys_audit_log', tenant_id: null, sequence: 0, kind: 'window',
497+
sealed_object: 'sys_audit_log', tenant_id: null, sequence: 0, kind: 'window', part_index: 0, final_part: true,
486498
window_start: '2026-11-10T04:00:00.000Z', window_end: '2026-11-10T05:00:00.000Z',
487499
sealed_through: '2026-11-10T05:00:00.000Z', leaf_count: 1, row_ids: ['r1'], root: 'a'.repeat(64),
488500
previous_digest: null, columns: { clear: ['created_at', 'id'], committed: [] },
@@ -530,6 +542,8 @@ describe('the leaf hashes beside a checkpoint are trusted only through its signe
530542
tenant_id: 'org_1',
531543
sequence: 0,
532544
kind: 'window',
545+
part_index: 0,
546+
final_part: true,
533547
window_start: '2026-11-10T04:00:00.000Z',
534548
window_end: '2026-11-10T05:00:00.000Z',
535549
sealed_through: '2026-11-10T05:00:00.000Z',

0 commit comments

Comments
 (0)