Repository navigation
docs(adr): ADR-0154 amendments — bounded checkpoints (D4) and the DB session seal lock (D3) - #33489
Conversation
…session seal lock (D3) Records two seat rulings on the build card as a dated amendment to ADR-0154. D4: a chain's window seals into consecutive checkpoints of at most N = 10,000 leaves (a fixed constant), late checkpoints capped the same way, a part index and final flag in the signed body, S1 relaxed for parts of one window, and a row id listed by two checkpoints is a verify fault; the cost line is restated per checkpoint. D3: a second, database session lock beside audit.sealer, following acquireSchemaMigrationLock; each sealer pass try-locks it and skips, os migrate audit-* --apply holds it for the run, and where no such lock exists --apply on a sealed object needs the explicit sealer-stopped flag. Ruling records 6884540128 and 6885005594. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM
|
Contract-review-claim: session_016WV4d1PGptBW3QRQNmy5e6 · head 96b5a04 · 2026-11-14T22:32:04Z review#3. |
Review — PASSHead-sha: The diff touches one file, D4 (S7): every element of the ruling is present and none is widened.
D3 (E + B): every element of the ruling is present.
Two sentences go beyond the ruling's words. Neither adds a rule. The seat should confirm the first.
The form is right for a dated amendment: the original text is kept, there are dated pointers at the status line, D3 (two places), D4, D9 and the Consequences cost line, a Tier H: this PR lands only by an approver's approval, which this review is not. Reviewed-by: |
… window checkpoint reads as sealed Seat ruling 6885452378 on the S4 verify gap: a window is also sealed when it starts at or before the highest window_start among the object's trusted window checkpoints, so a chain a fault left behind reads unsealed in D9. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM
|
Contract-review-claim: session_016WV4d1PGptBW3QRQNmy5e6 · head 7ec8511 · 2026-11-14T22:52:57Z review#3 (delta). |
Review — PASS (delta)Head-sha: This reviews the delta
My PASS at Reviewed-by: |
… cites ruling 6885452378 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cyNkH7W7e89m6j4aQq
|
domain:server#5 · os-elon-musk · session_016WV4cyNkH7W7e89m6j4aQq review#3: delta review request, new line(s) only. Old head
Seat ruling 3 check: the amendment never said "chain links expose a removed part", so no reword was needed in the ADR. Gates at |
|
Contract-review-claim: session_016WV4czb1FQB8j27FVgnMye · head 20fdf0c · 2026-11-15T04:01:15Z review#3. |
Contract reviewServed-tier: Review — PASS (delta). This reviews the delta ① Derived judgments
② Semver levelNone. This is a ③ Boundary flagsNone. No code, schema or gate changes in the delta. ④ Design judgmentThe bullet records a ruled design choice next to the part-index text it qualifies, with the grounds that make it safe, and does not widen it. review#3's PASS at Implemented-by: VERDICT: PASS |
|
domain:server#5 · os-elon-musk · session_016WV4cztR1A2CZoxSZyuoGP ACCEPT · area A2 · Tier H · 2026-11-15T05:08Z
|
…ve hands its crypto provider to an app-supplied AuditPlugin (objectstack-ai#33503) <!-- 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 objectstack-ai#31908 (slice P4b1; seat ruling 6884540128 items 2 and 3) Clause-②: yes (widening) Metadata-protocol: none ## Maintainer quick read - What changes: the audit sealer isolates faults per chain. When a canonical rule refuses one of a chain's rows, or one of a chain's checkpoints (its head included) is malformed, only that chain is skipped, and the other chains seal as usual. Each chain has its own cursor and resumes from its own oldest unsealed window. Past a window that holds a skipped chain, `sealed_through` stops advancing. A lock lapse or a signer, crypto or storage fault still aborts the object's whole pass. Also: when an app puts its own `AuditPlugin` in `plugins` without a `cryptoProvider`, `os serve` now hands it the host's crypto provider. It does this only for the real `AuditPlugin` class, and it never overrides an explicit provider. - Why: before, one bad row stopped sealing for every chain of the object. And an app's own `AuditPlugin` (one added to turn on `readAudit`, for example) replaced the CLI's instance, got no crypto provider, and sealed nothing. - Risk and rollback: verdicts and refusal reasons are unchanged, and every existing seal and verify pin passes as is. The PR adds one public method, `AuditPlugin.adoptHostCryptoProvider` (widening). The sealer pass is window-major, and `late` never sweeps a lagging chain. Both are pinned per seat ruling 6885452378, the precondition for the verifier's sealed-window rule, which lands in P4c. Rollback is a revert. - Read first: in `sealer.ts`, `run`, `cursorOf`, `skip`, `writeChains` and the catch in `readWindow`. In `serve.ts`, the `handHostCryptoToAppAuditPlugin` line inside the stack plugins loop. In `audit-plugin.ts`, `adoptHostCryptoProvider`. - Two-minute check: `pnpm --filter @objectstack/plugin-audit exec vitest run src/audit-seal/audit-seal-sealer.test.ts src/audit-plugin.test.ts`. Expect 2 files and 65 tests, all green. - Needed from you: nothing. The seat lands it. ## What changes 1. **S4, per-chain isolation (seat ruling 6884540128 item 2).** `sealer.ts`: - Only a chain-local fault skips a chain: a row a canonical rule refuses (`CanonicalFormError` while reading the row), or a malformed checkpoint of that chain (`SignedBodyError`/`CanonicalFormError` while reading it back: its head in `headOf`, a lister in the late re-count, a lister in `listedIn`, or its `window_start` while the cursors are read). The skipped chain stays out for the rest of the pass; every other chain is sealed. Lock lapse, signer, crypto-provider and storage faults (and the Q6 coordinate bound) still throw out of the object's pass, as before. - Each chain has its own cursor: the window after its last `window` checkpoint at or past the object's floor (the stored `sealed_through`, before which every chain is complete). A row is `late` only before its own chain's cursor; at or past it the window pass seals it as `window`. So a skipped chain (or one a stopped pass left) resumes from its own oldest unsealed window as `window` checkpoints. This replaces the object-wide `lastWindow` / `resumed` pair. - `sealed_through` on every `window` checkpoint is `min(window start, earliest window a skipped chain leaves unsealed)`, never below the stored floor. So it never passes a window that has a skipped chain. - The window walk starts at the floor. A window that only re-reads chains already sealed (or skipped) past it does not count toward `MAX_WINDOWS_PER_PASS`, so a stuck chain cannot stall the others behind the cap. - Each skipped chain is reported once at `error` per cause per hour, naming the object, the chain, the fault (code and reason, never a statement) and the window it is unsealed from. A chain sealed again is forgotten. 2. **App-supplied AuditPlugin (seat ruling 6884540128 item 3).** - `audit-plugin.ts`: new `adoptHostCryptoProvider(provider, { armSealer })`. It takes the provider only when the instance was composed with no `cryptoProvider`, so an explicit one is never overridden. `armSealer: false` (a one-shot boot) keeps the sealer off. `true` leaves the instance's own `armSealer` standing, so an app's `armSealer: false` is never turned on. Kept in private fields; the app's options object is not mutated. - `packages/cli/src/utils/app-audit-plugin-host-crypto.ts`: `handHostCryptoToAppAuditPlugin` hands over only to `instanceof` the real class, as this host loads it. A same-named lookalike is never touched. It never throws. - `serve.ts`: the class is loaded once, best-effort, ahead of the stack `plugins` loop. Each entry is handed `() => hostCrypto?.provider` and `!migrateAndExit` (the same provider function and one-shot posture as the 5d instance and the `requires: ['audit']` resolver) right before `kernel.use`. Boot is never refused. An instance left with no provider keeps D3's once-at-`error` report from its sealer. Out of scope, untouched: S7, the item-5 DB session lock, verify's bootStack crypto (item 4, P4c), any `lifecycle.seal` default, expiry amendments, objectql lifecycle, `docs/adr/**`, `.claude/**`, `skills/**`, `.github/workflows/**`. ## Tests Tests first. Each new pin was run red before its fix. - `audit-seal-sealer.test.ts`, new describe `per-chain isolation …`: - A refused row in org_b's 08:00 window. The deployment chain and org_a are sealed at 08:00, 09:00 and 10:00. org_b is not. Every `sealed_through` stays at 08:00. One `error` line names the object, `org:org_b`, `b1.payload` and "NOT being sealed". - Once the row is fixed, org_b resumes: `window` checkpoints at 08:00 (seq 0) and 09:00 (seq 1), not `late`. A third pass writes nothing. - A malformed head (org_b's checkpoint `root`). org_a is sealed at 09:00 and 10:00, both with `sealed_through` 09:00. org_b is skipped with one `error` line naming `root`. - A storage fault (`connection reset` on org_a's insert) still stops the whole object: nothing is stored, and one object-level `error` line. This one is green before and after; it preserves the abort. - Verify stays loud: `verifyAuditLedger` over the first scenario answers `ok: false`, with totals `unmodified: 2, late: 2, unsealed: 2`. This is the verdict `os audit verify` exits 1 on. - Window-major (seat ruling 6885452378): org_a writes every hour for 30 hours, which is more windows than one pass seals, and org_b writes only at hours 0, 11, 23 and 29. After pass 1, both chains' newest `window` checkpoint is at 23:00. After pass 2, both are at 29:00, and there is no `late` checkpoint. It was green at first run, so no code change was needed: the pass is one loop over windows that seals every due chain under one shared budget. Giving org_b its own budget turns it red (Verification). - No late sweep (seat ruling 6885452378): org_x is skipped at 08:00 while org_a seals 08:00 and 09:00. In pass 2, org_x recovers into `window` checkpoints at 08:00 (seq 0) and 09:00 (seq 1), and the only `late` checkpoint is org_a's own late row at 08:00. It was green at first run, so no code change was needed. Restoring the old every-chain late rule turns it red (Verification). - `audit-plugin.test.ts`, new describe: takes the host provider when none was composed, and the sealer seals under it. Never overrides an explicit one. A one-shot host keeps the sealer off, and an app's `armSealer: false` stands. A host with no provider composes none, so the sealer is built without crypto and reports at `error`. - `cli/src/utils/app-audit-plugin-host-crypto.test.ts`: the real class with no provider is fed. An explicit provider is not replaced. A same-named lookalike with an `adoptHostCryptoProvider` of its own is never called. The class missing or no plugin feeds nothing. A one-shot host disarms the sealer. - `serve-audit-registration.contract.test.ts`: every existing assertion is kept. New: the hand-over call (exact spelling, with `() => hostCrypto?.provider` and `!migrateAndExit`) sits inside the stack `plugins` loop before `await kernel.use(pluginToLoad);`, and the real class is loaded ahead of the loop. ## Acceptance notes - **Ruled: verify for a window where the skipped chain is the only chain.** The verifier today reads a window as sealed when a trusted `window` checkpoint names it, or when the window ends at or before the highest `sealed_through`. Ruling item 2 holds `sealed_through` at the skipped window. So if no other chain sealed that window, the skipped chain's rows there get no verdict. Seat ruling 6885452378 (option A) closes this in P4c: a window is also sealed when it starts at or before the highest `window_start` among trusted `window` checkpoints. The ADR-0154 D3 line is in objectstack-ai#33489. Its two preconditions, a window-major pass and `late` never sweeping a lagging chain, are pinned in this PR (Tests). - **A row whose `created_at` will not parse, when it is the oldest row of a span**, is met by the window walk's `firstRowAt` before any chain is read. That still stops the object's pass, as before. In `readWindow` the same fault skips only its chain. - **Cost while a chain is stuck.** Each pass walks from the floor, so it re-reads the windows other chains already sealed past it until the stuck chain is fixed. This is bounded by how long the chain stays stuck. The cursor read fetches the `window` checkpoints at or past the floor. review#3 S1: bounding this re-walk is carried to P4b2. - **A separately installed copy of `@objectstack/plugin-audit`** in the app is a different class from the one the host loads, so an instance of it is treated as a lookalike and is not fed. Its sealer reports the missing provider at `error`. - **`OS_MIGRATE_AND_EXIT=1` with an app AuditPlugin that composed its own provider** arms its sealer, as before. The ruling feeds only instances with no provider, so this PR does not touch them. - **Stacked on P4a (objectstack-ai#33476).** Base is `claude/area-A2-31908-p4a`; the area thread retargets it to `main` once objectstack-ai#33476 merges. ## Verification All readings were taken at head `4cbd2fca9` unless they name another commit; the follow-up block was taken at `22d4da3f6`. <details><summary>Red before the fixes</summary> ``` # 5ada48f (sealer pins only) × skips the chain of a row a canonical rule refuses, seals every other chain, and holds sealed_through at the skipped window × resumes a skipped chain from its own oldest unsealed window, as window checkpoints and not late ones × skips the chain whose head checkpoint is malformed, and seals the others past it × keeps verify loud: the skipped chain's rows read unsealed and the verdict is not ok Tests 4 failed | 30 passed (34) os-verify-lock: VERDICT command-exit 1 # 03a059d (plugin pins only) TypeError: plugin.adoptHostCryptoProvider is not a function Tests 4 failed | 25 passed (29) os-verify-lock: VERDICT command-exit 1 # cli pins before the helper and the serve wiring Error: Cannot find module './app-audit-plugin-host-crypto.js' × hands the host crypto provider to an app-supplied AuditPlugin in the stack `plugins` loop, before the kernel takes it (seat ruling 6884540128 item 3) Tests 1 failed | 7 passed (8) os-verify-lock: VERDICT command-exit 1 ``` </details> <details><summary>Green: the full plugin-audit suite, and the CLI tests that read serve.ts</summary> ``` # pnpm --filter @objectstack/plugin-audit exec vitest run --maxWorkers=2 Test Files 93 passed (93) Tests 1511 passed (1511) os-verify-lock: VERDICT command-exit 0 # pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2 (every test file that reads serve.ts, plus the helper's) Test Files 40 passed (40) Tests 600 passed (600) os-verify-lock: VERDICT command-exit 0 ``` 48 files were named, and the `unit` project ran the 40 that are unit-tier. The rest are integration-tier, which CI's `Test Core` runs. </details> <details><summary>Follow-up pins (seat ruling 6885452378): green at first run, and each bites under ablation</summary> ``` # 22d4da3, sealer file: Tests 36 passed (36), VERDICT command-exit 0 # ablation: the sealLate accept against the chain's own cursor replaced by the every-chain rule (start before the pass end) # no-late-sweep pin red, expected 5 to be 3; Tests 3 failed | 33 passed (36); restored blob == HEAD (5e40b51) # ablation: a separate per-pass budget for org_b in the window pass # window-major pin red, expected 25 to be 27; Tests 1 failed | 35 passed (36); restored blob == HEAD (5e40b51) # full plugin-audit suite at 22d4da3: Test Files 93 passed (93), Tests 1513 passed (1513), VERDICT command-exit 0 ``` </details> <details><summary>Type-check, lint and gates</summary> ``` pnpm --filter '@objectstack/cli^...' build -> VERDICT command-exit 0 pnpm --filter @objectstack/plugin-audit typecheck -> VERDICT command-exit 0 (check:test-typecheck OK, 0 pinned) pnpm --filter @objectstack/cli typecheck -> VERDICT command-exit 0 (check:test-typecheck OK, debt unchanged) eslint --no-inline-config (the eight changed source files) -> exit 0 node scripts/check-test-source-alias.mjs (pnpm check:test-source-alias) -> exit 0 dispatch-gates --ran: 99 derived, 22 run (each exit 0), 0 NOT-MEASURED, 77 left to CI ``` The 22 run locally: `check-adr-0087-registration`, `check-changeset-no-major`, `check-empty-changeset`, `check-closing-keyword-parity`, `check-issue-citations` (both), `check-plugin-teardown-shape`, `check-tenant-audit-census`, `check-comment-mask-adoption`, `check:durability-log-level`, `check:startup-registry-verdict`, `check:nul-bytes`, `check:doc-authoring`, `check:engine-double-contract`, `check:test-source-alias`, `check:cross-package-test-inputs`, `check:optional-error-sink`, `check:system-context-census`, `check:keyed-text-bounds`, `check:undeclared-dep-imports`, `check:logger-receiver-detach` and `check:tier-file-adoption`. The derivation is taken against `main`, so it includes P4a's files, and the spec families are mostly P4a's. CI's `Lint & Repo Gates` runs the rest. </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (No spec change here.) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes (eslint on the changed files; the repo-wide run is CI's). - [x] 4. One issue, one branch, one pull request. (By the seat's slicing, this branch carries slice P4b1 of objectstack-ai#31908, stacked on P4a's branch until objectstack-ai#33476 merges.) - [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` untouched: nothing to regenerate. - [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. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM --------- Co-authored-by: Claude <noreply@anthropic.com>
…rows, and bound the idle re-walk (P4b2) (objectstack-ai#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 objectstack-ai#31908 (slice P4b2) Blocked-by: objectstack-ai#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 objectstack-ai#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 objectstack-ai#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: objectstack-ai#33489 has merged, and the seat lands this once review passes. ## What changes **S7: bounded checkpoints (ADR-0154 D4 as amended in objectstack-ai#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 objectstack-ai#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 objectstack-ai#33503 merged; `origin/main` is merged in (faadaaa, then 60960cd, which brings in objectstack-ai#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, objectstack-ai#33773, in place of `follow-up owed` and `none`. ## Why Seat ruling 6884540128 item 1 (S7), with the ADR-0154 amendment in objectstack-ai#33489. review#3's should-fix S1 on objectstack-ai#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 objectstack-ai#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 objectstack-ai#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>
…ows by whole checkpoints (ADR-0154 D8, D10) (objectstack-ai#37605) <!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuWkuYc3V797qxZSYHo5QzBw)_ Part of objectstack-ai#31908 Clause-②: yes (narrowing) — narrowed: `sys_audit_log` now declares `lifecycle.seal` on every deployment, so `os migrate audit-key-material`, `audit-mail-bodies`, `audit-metadata-bodies` and `audit-side-copies` with `--apply` refuse on SQLite or Turso without `--sealer-stopped`, and on Postgres or MySQL take the audit seal lock and refuse after ten minutes, where 18.6.0 ran them unlocked on a deployment that sealed nothing; `os audit verify` exits 1 on a row it reads `late` and unsealed (the S4 arm); `os audit verify` refuses with `archive_not_connected` and exits 2 where the `archive` datasource is declared and not connected on its own boot (fix: `autoConnect: true`, or make it reachable), where 18.6.0 printed that nothing is sealed and exited 0; `verifyAuditLedger` throws for `sys_audit_log` when its `archive` datasource is not connected and no `archive` is passed; on a sealed object with no `archive` whose lifecycle is declared in packaged metadata, a retention override below the declared window, global or for one organization, is rejected (reported at `error`, the declared window applies), where 18.6.0 applied it. An object created at runtime is outside the override arm and outside signed expiry: it keeps the 18.6.0 row-cutoff retention sweep, and a settings override applies to it; the `os audit verify` arms hold for it as for any sealed object. This breaks the bound changeset `35c9a30` (objectstack-ai#33675) set ("a deployment that did not opt in sees no change"). Widened: `LifecycleService.registerExpiryPrefix` and the `LifecycleExpiryPrefix*` types (the request with `tenants` and `tenantColumn`), `takesSignedExpiry` and `SignedExpiryRegistryLike`, three optional owner reads on `LifecycleEngineLike.registry`, `policy: 'expiry'`, the skip reasons `seal-expiry-pending` and `seal-delete-unsupported`. Metadata-protocol: semantic — beside `lifecycle.seal`, the authored `retention.maxAge`, `ttl.expireAfter` and `archive.keep` no longer delete a row at its row cutoff: rows leave by whole checkpoints under a signed expiry amendment (seat ruling on review 7198128323 S2; the changeset moves all four packages `minor`) Skills-docs: objectstack-ai#37881 — this claim's second PR (amendment 7193137455) rewrites `skills/objectstack-data/rules/lifecycle.md`, which says the sweeper deletes sealed rows until it lands (hence `Part of`, not `Fixes`) ## 维护者速读 - 每个部署的审计日志从此默认带防篡改封印:管理员跑审计校验时,被改、被删、被脱敏、按策略到期的记录都能分辨出来,热库和归档库都算。 - **这是对运维可见的破坏性变化**:SQLite 和 Turso 部署下次跑 `os migrate audit-*`(包括升级流程里的 `audit-side-copies --apply`)会被拒,要先停掉服务再带 `--sealer-stopped`;Postgres 和 MySQL 会先等封存锁,最多等 10 分钟。 - **过期删除不可撤回**:过了保留期的审计记录按整段检查点删除,删之前先签一份到期说明,校验时读作“到期”而不是“丢失”,但删掉的行找不回来。 - **宿主没有传加密服务时**,`sys_audit_log` 过了 `archive.keep` 也会一直留着,封存器每小时报一次 error。出错时只会多留、不会多删:链条有缺口、签名不可信、检查点或到期说明不属于这条链、前后接不上,都一律保留并告警一次。 - **没有 archive 的封存对象上,保留期覆盖不能把窗口缩短到声明值以下**:运维在设置里把这类对象的保留期改短(全局或某个组织)会被拒绝并报 error,按对象声明的窗口执行;改长照常生效。想留得更短,只能改对象自己的声明。带 archive 的对象(比如 `sys_audit_log`)上,覆盖仍然决定什么时候转入归档。 - **签名到期只覆盖打包元数据里声明的对象**:运行时创建的封存对象(在 Studio 等处建的、存在数据库里的)照旧按保留期清扫(被清掉的行在校验里读作“丢失”)、覆盖照样生效,和现在一样,不受“覆盖下限”和“签名到期”这两条收窄影响;但 `os audit verify` 的两条收窄对它一样适用,比如有 late 未封存的行时同样 exit 1。让运行时对象也支持签名到期另开卡。 - **按租户设的保留期**设在对象的 `organization_id` 列上,所以只有链列也是 `organization_id`(`seal.chainField: 'organization_id'`)的对象,才按这个组织自己的保留期过期;其他链(不属于任何组织的链,以及保留期设在另一列上的对象的所有链)一律按所有保留期里最长的那个保留。代价是:保留期设在非链列上的对象,租户设的更短保留期对它的封存记录不起作用,记录会留到最长的保留期。 **Tier:** Tier H (declared narrowing: the Clause-② line above; seat ruling on review 7202871622). About 2,996 changed lines (under 3,000). No governed path: `packages/spec/src/data/object.zod.ts` changes one `.describe()` sentence only, and the `skills/**` wording fix is split into this claim's second PR (amendment 7193137455), Tier H on its own. The release page `content/docs/releases/v18/18-6.mdx` is release-owned and is not edited here (AGENTS.md "Documentation Guardrails"). ## What changes ADR-0154 D8 + D10, slice P4c, the last slice of objectstack-ai#31908. - **`sys_audit_log` is sealed by default.** Its lifecycle now declares `seal: { valueFields: ['old_value', 'new_value', 'metadata'] }` (`packages/plugins/plugin-audit/src/objects/sys-audit-log.object.ts`). The chain column is the default `tenant_id` (a lookup, one text value on every store). - **LifecycleService: sealed objects expire only through a registered seam** (`packages/objectql/src/lifecycle/lifecycle-service.ts`). Signed expiry covers objects whose lifecycle is declared in packaged metadata; an object created at runtime keeps the row-cutoff retention sweep. Extending signed expiry to runtime-created objects is a separate card. The test is one predicate, `takesSignedExpiry` (new, `lifecycle/signed-expiry-scope.ts`, exported), which the routing, the audit floors and the sealer's expiry all ask; it answers yes only for an object the registry places in packaged metadata. Any other sealed object keeps the row-cutoff path, and the sealer's expiry answers no run for it (seat ruling 7209154881). New public `registerExpiryPrefix(expiry)` (the name slice plan 6759503769 ruled) (one slot; a later registration replaces it; the disposer clears only its own) and the types `LifecycleExpiryPrefix`, `LifecycleExpiryPrefixRequest`, `LifecycleExpiryPrefixRun`. For an object with `lifecycle.seal`: - the `retention.maxAge` / `ttl.expireAfter` legs and the archive's `keep` prune never delete by a row cutoff; each asks the seam to `plan({ object, policy, policyValue, cutoff, tenants?, tenantColumn? })`; - each run's `rowIds` are deleted by id (hot and archive for an archiving object; through the engine, reap guards asked, for the rest), and `run.complete()` is called only when every one is gone; - with no seam registered, rows are kept, the archive copy still runs, the sweep reports `seal-expiry-pending`, and one `warn` says so; - a tenant-scoped window (on the partition `reap()` uses, through the same floors) travels as `tenants`, with the column it is set on (`tenantColumn`), which need not be the chain column (review 7202871622 S4); - an archive store with no `bulkDelete` is never planned (`seal-delete-unsupported`), so no amendment is signed over rows it could not delete. - **plugin-audit: the expiry writer** (new `audit-seal/expiry.ts`, `AuditSealer.expire`, registration in `audit-plugin.ts`): - per chain, from the first remaining checkpoint (which must follow and link to the last admitted expiry, or be sequence 0), take consecutive checkpoints whose window ended at or before the chain's cutoff aligned down to a UTC day, each the chain's own, linked to the one before and admitted by a trusted signature, at most 10,000 rows a sweep; a chain holding a checkpoint or stored expiry that is not its own, or one that does not link, is not expired at all and is said once (review 7202871622 M3); - each chain's window: where `tenantColumn` is the object's chain column, an organization's chain takes its own tenant window (else the global one); every other chain, the chain of rows about no organization and every chain of an object whose windows sit on another column, takes the longest window configured; its amendment signs it (seat rulings on S1 and on review 7202871622 S4). No row is read to pick a window; - sign and store the chain's `expiry` amendment (the S1 key-id loop, then the sink, best-effort), then answer the run; `complete()` removes each checkpoint's seed, then the checkpoint, oldest first (review n5), and removes a seed only when it is the secret sealed under that checkpoint's own coordinate; - a stored, admitted amendment that still covers the first remaining checkpoint is resumed (no second amendment); the resume branch admits each checkpoint as the fresh branch does (the chain's own, linked to the one before, a trusted signature), requires them consecutive from the amendment's first sequence to its last sequence and digest, reads them a page at a time, and removes them oldest first; otherwise nothing in the range is deleted; an unadmitted amendment deletes nothing; - a gap or an untrusted checkpoint stops the chain there and is said once; - planning holds the `audit.sealer` lock and the DB seal-pass lock, so two replicas never sign two amendments over one range; a fully drained plan is memoised for the day; - registered only when the plugin has a crypto provider (otherwise nothing could be signed); - on a sealed object with no `archive`, a retention override cannot shorten the declared window (review 7207510869): beside the expiry, the plugin registers a retention floor (`LifecycleService.registerRetentionFloor`, the mechanism the job queue uses) for every object whose packaged metadata declares `lifecycle.seal` and no `archive`, at its declared `retention.maxAge` and `ttl.expireAfter` (new `audit-seal/retention-floor.ts`), and registers it again before every sealer pass (new `AuditSealerOptions.beforePass`) so it follows the registry; a lifecycle service with no retention floors is given no expiry, so its sealed rows are kept, and the plugin says so at `error`. An archiving sealed object expires only past `archive.keep`, which takes no override; - the sealer's head falls back to the last admitted expiry (the chain's own, its signature verified) when a chain has no checkpoint left (`last_sequence`, `last_removed_digest`), and the object floor to the newest admitted `covered_to`; both, like the expiry, read stored amendments page by page until an admitted one answers. - **Verifier: the S4 arm** (seat ruling 6885452378, ADR-0154 D3 as amended in objectstack-ai#33489): a window that starts at or before the newest window a trusted `window` checkpoint names is sealed, so a lagging chain's rows read `late` and unsealed. It also holds an honoured expiry to what it signed: an amendment stored under another chain than its signed organization is a `chain_key` fault, as a checkpoint is, and a checkpoint in an honoured range reads `expired` only within the window the range covers (review 7202871622 M3). - **verify harness** (`packages/verify/src/harness.ts`, ruling 6884540128 item 4): an `AuditPlugin` that `bootStack` mounts (extra, stack `plugins`, or `requires: ['audit']` provider) adopts `harnessCryptoProvider()`, the instance settings and the engine get; an instance with its own provider keeps it. - **Docs:** the `lifecycle.seal` describe sentence (and the regenerated `content/docs/references/data/object.mdx`), `content/docs/data-modeling/objects.mdx` (the sentence at :277, the day alignment, the row budget and tenant windows, plus one line that `sys_audit_log` declares the block), `content/docs/deployment/cli.mdx` (the audit seal lock and `--sealer-stopped` for every run covering the audit log), `content/docs/upgrading.mdx` (the 18.5.0 line now holds on every deployment), `content/docs/deployment/production-readiness.mdx`. ## Tests - `packages/objectql/src/lifecycle/lifecycle-service.sealed-expiry.test.ts` (new, 13): a sealed object created at runtime keeps the row-cutoff sweep, retained and archiving, and never asks the expiry (seat ruling 7209154881); against a real `SchemaRegistry`, a sealed object the registry does not place in an installed package's metadata keeps the row-cutoff sweep, while one it does takes the signed expiry; pending skip and the once-only warning; `archive.keep` plan on both stores and complete-after-delete; `retention.maxAge` per-id engine deletes; `ttl.expireAfter`; a partial guard veto leaves its run uncompleted; a failing plan deletes nothing; slot replacement and disposer; a malformed registration; an unsealed object keeps the row-cutoff path; an archive store with no `bulkDelete` is never planned; a tenant-scoped window travels to the expiry with the column it is set on (review S1, S4, n3). - `packages/objectql/src/lifecycle/signed-expiry-scope.test.ts` (new, 3): `takesSignedExpiry` answers yes only when the registry places the object in packaged metadata: a registry that cannot be asked answers no; an installed `code` or `marketplace` source answers yes, an `authored` or unknown one no; a plain registration from code answers yes, an owner under no installed package or a tenant-authored one no. - `packages/plugins/plugin-audit/src/audit-seal/audit-seal-expiry-live.integration.test.ts` (new, 10): the real-kernel end-to-end over SQLite with an `archive` datasource. `sys_audit_log` sealed by its own declaration; the plugin's sealer seals; an interrupted expiry (amendment stored, rows still there) reads `expired`; the kernel's own LifecycleService sweep archives, resumes, deletes exactly the expired rows from both stores and then their checkpoints and seeds; a second same-day sweep signs nothing; verify then reads no gap and the untouched windows `unmodified` in hot and in archive; a fully expired chain's next checkpoint links to `last_removed_digest`; `modified`, `missing` and `redacted` are still told apart. A second boot: a sound chain expires whole, a chain stops at a checkpoint no trusted key signed, a chain with a gap is kept, each said once; a stored expiry is never resumed over a checkpoint no trusted key signed (no row and no seed it lists is deleted); a chain head never follows an expiry amendment no trusted key signed (review M1). - `audit-seal-expiry-window.test.ts` (new, 7): each chain's window — its organization's own where the windows are set on the chain column, the global one, the longest for a chain of no one organization (review S1) and for every chain where the windows are set on another column (S4); and the `policy_change_log` shape over the sealer itself (declared `tenant_id`, injected `organization_id`, the two values differing): windows on `tenant_id` expire each organization's chain under its own window, windows on `organization_id` keep every row to the longest (S4). - `audit-seal-expiry-admission.test.ts` (new, 14, review 7202871622 M3 and n6, review 7205485052): one pin per check an expiry or the sealer's head makes before it acts — a fresh run's checkpoints bound to the chain and linked, the first linked to the last expiry; a resumed range's checkpoints bound, consecutive, linked, each signature trusted, ending at the amendment's digest, none before its first sequence; a stored expiry bound to the chain; the newest admitted expiry found past more stored ones than one page; and the sealer's head under the same two rules; and a checkpoint whose seed handle names another secret drops nothing but its own row. - `audit-seal-verifier.test.ts` (+2): an amendment stored under another chain is a `chain_key` fault; a checkpoint whose window ends past its honoured range's `covered_to` is judged, not read `expired` (M3). - `audit-seal-sealer.test.ts` (+1): the S4 sole-chain window reads `late` unsealed and `ok` false. - `audit-seal-retention-floor.test.ts` (new, 10, review 7207510869, S7 of 7209130288 and seat rulings 7209154881, 7210805783): over a real `LifecycleService` and the plugin's own registration, an object created at runtime, and one owned under a package id no installed code or marketplace package answers, take no floor and no expiry while a packaged one takes both, and the sealer's expiry answers no run for a runtime object before it resolves a seam; a global and a tenant override below the declared window are rejected and the expiry is asked for the declared window, with both rejections on the sweep report; an override above it still applies and is what the expiry signs; a lengthened declaration is the floor from the next sealer pass on; a lifecycle service without floors gets no expiry; and which windows a sealed object is floored at. - `audit-plugin.test.ts` (+3): the expiry is registered with a crypto provider, unregistered on destroy, not registered without one, and boot survives a lifecycle service without the seam. - Existing pins adjusted for the seal default (not loosened): `packages/cli/src/commands/audit/verify.integration.test.ts` and `verify.ownership-queue.integration.test.ts` now expect `sys_audit_log` beside the fixture ledger in `objects` and in the unreachable-archive message, and case 4 reads that a project with no seal of its own still checks the platform's sealed audit log (exit 0); the four `os migrate audit-*` archive and preview integration files (`audit-mail-bodies.archive`, `audit-key-material.archive`, `audit-side-copies.archive`, `preview-read-only`) pass `--sealer-stopped` on their SQLite `--apply` runs (and `preview-read-only`, now judged by the test-source alias gate's source reach, pays its twelve dynamic imports at module top); the two `os migrate audit-*` dogfood files (`packages/qa/dogfood/test/audit-key-material.dogfood.test.ts`, `audit-mail-bodies.dogfood.test.ts`) pass the same flag on their `--apply` runs; and in plugin-audit, `audit-seal-chain-field-34164.test.ts` passes `archive: () => 'none'` (its boot connects no archive datasource, as `os audit verify` establishes), and `audit-seal-host-seam-resolve-34280.integration.test.ts` forgets what the loop's own first pass reported before each pin counts its own passes. <details><summary>Ablations (each restored, blob == HEAD)</summary> - Verifier S4 arm `|| start <= this.newestSealedWindow()` → `|| false`: the new sole-chain pin goes red (`expected [] to deeply equal [ Array(1) ]`), 1 failed | 57 passed. - Lifecycle routing `if (lc.seal) return this.reapSealed(…)` disabled: 5 of the 9 new lifecycle pins go red. - Archive keep branch `if (lc.seal) {` disabled: the two archive pins go red. - Resume admission (signature check and the last-sequence/digest match) disabled, and the sealer's expiry signature check disabled: the two M1 pins go red, 2 failed | 8 passed. - Reviews 7202871622 and 7205485052, one check at a time (each its own pin red, 1 failed, every other selected pin skipped): the fresh run's binding, link and first link; the resumed range's binding, sequence continuity, link, signature, last digest and first-sequence floor; the stored expiry's binding and paging; the sealer head's binding and paging; the verifier's `chain_key` fault on an amendment and its window bound on an honoured range (15); S4's own-window branch and its longest-elsewhere branch (2); the seed coordinate check (1); review 7207510869: the floor registration, its refresh before each sealer pass, and the no-floors refusal (3); seat ruling 7209154881: the lifecycle routing, the floor and the sealer's expiry each scoped to packaged objects (3); the packaged-metadata predicate's installed-source answer and its default when the registry cannot answer (2). 26 of 26 red. </details> ## Acceptance notes - **Rows are kept, never over-deleted, whenever something is off.** No crypto provider, a one-shot boot, a gap, an untrusted checkpoint, a reap guard veto, or a failing plan all keep the rows. A deployment whose `AuditPlugin` has no crypto provider now keeps `sys_audit_log` rows past `archive.keep` instead of pruning them, says so once per process at `warn`, and its sealer reports the missing provider hourly at `error`. An expiry, once run, deletes for good. - **`os migrate audit-* --apply` on SQLite or Turso now needs `--sealer-stopped`** whenever it rewrites `sys_audit_log`: the 18.6.0 rule for a sealed object (ADR-0154 D3 amended, B, seat ruling 6885005594) now meets every deployment. On Postgres and MySQL every such run now takes the audit seal lock and waits up to ten minutes; dry runs are unchanged. Declared as the narrowing arm with a BREAKING banner and an ADR-0087 marker (review M2). - **The day-aligned cutoff** keeps a row up to one day past its policy, on top of D8's bound, so a drained chain gains at most one expiry amendment a day; amendments are never removed. **10,000 rows a sweep per sealed object**, across its chains; a backlog keeps rows longer, and a cut run continues in the next amendment. Both exceed D8's stated bound in the safe direction; the seat kept them and the add-only ADR-0154 note follows in its own governed PR, beside the skills PR. - **On a sealed object with no `archive`, a retention override cannot shorten the declared window** (review 7207510869, S7 of 7209130288): an override may lengthen it, one below it is rejected at every sweep (`floorViolations`, `error`), and the declared window applies. On an object that archives (`sys_audit_log` among them), an override still sets when rows move to the archive, and `archive.keep` takes no override. - **Signed expiry covers objects whose lifecycle is declared in packaged metadata** (seat ruling 7209154881): an object created at runtime keeps the 18.6.0 row-cutoff retention sweep (its expired rows read as missing), its overrides apply, and it takes no floor. Extending signed expiry to runtime-created objects is a separate card. - **Tenant-scoped retention windows** are set on the object's `organization_id` column, and apply as the seat ruled on S1 and S4: where the windows are set on the chain column an organization's chain expires under its own window; every other chain under the longest of all, never shorter than a window set for a row in it; each amendment signs the value its chain expired under. The cost: on an object whose windows sit on another column than its chain column, a shorter tenant window has no effect on its sealed rows, which are kept to the longest. `sys_audit_log` itself archives, and `keep` has no override. - `os audit verify` on a deployment with no `archive` datasource anywhere already reads the hot store alone (`'none'`); a library caller of `verifyAuditLedger` that composes no archive must now pass `archive` for `sys_audit_log`, as the adjusted test does. - **File surface past the claim:** the two CLI `os audit verify` integration pins, the four CLI `os migrate audit-*` integration files and the two dogfood files above (expectations, the flag and module-top imports only), `content/docs/deployment/production-readiness.mdx`, `content/docs/upgrading.mdx`, the new `audit-seal-expiry-window.test.ts` and `audit-seal-expiry-admission.test.ts`, `seal-store.testkit.ts` (the in-memory store double judges `$lte`), `packages/verify/vitest.config.ts` (one anchored alias the source-alias gate asks for), `scripts/engine-double-contract.pinned.json` and the plugin-audit tenant-audit census page (both regenerated by their own `--write`). Named here for the seat's claim amendment. - The CLI `os serve` composition is unchanged (it already hands its host provider to `AuditPlugin`, P4b). - The `skills/objectstack-data/rules/lifecycle.md` "not built yet" wording follows in this claim's second PR (Tier H, amendment 7193137455); until then this PR is `Part of objectstack-ai#31908`. - **Small decisions:** the seam is `registerExpiryPrefix` as ruled, and its three types now share that stem (`LifecycleExpiryPrefix`, `LifecycleExpiryPrefixRequest`, `LifecycleExpiryPrefixRun`), so a reader finds them beside the method. A chain of no one organization takes the longest window rather than the global one, the safe reading of the S1 ruling. Under S4 no row is read to pick a window (seat ruling on review 7205485052). Stored expiry amendments are read 50 a page until an admitted one answers, in place of the 10-row scans (review minor). The in-memory store double now judges `$lte`, which the expiry's queries use. A resumed range is read 20 checkpoints a page, as a fresh run is; the chain walk never takes a row with no `chain_key` as its key. These last two have no pin of their own: neither changes a result on a store the platform writes. - **Owed before queueing:** the delta contract-review-tier L2 over this head (round 7, after review 7210787318 PASS with S8, S9, n17, n19 and n20 to close), done by the seat. ## Verification Two-minute check: `cd packages/plugins/plugin-audit && pnpm exec vitest run src/audit-seal/audit-seal-expiry-live.integration.test.ts` — expect `Tests 10 passed (10)`. Read first (risk order): `packages/plugins/plugin-audit/src/audit-seal/expiry.ts` (`chainRun`: resume, gap, admission, budget), `packages/objectql/src/lifecycle/lifecycle-service.ts` (`sweepSealed` / `deleteSealedRows`: complete only after every row is gone), `packages/plugins/plugin-audit/src/audit-seal/sealer.ts` (`expire`: locks around planning; the head fallback). <details><summary>Local runs at ff14eb2 (each under os-verify-lock, exit captured before any pipe)</summary> - `pnpm turbo run build` over spec, objectql, plugin-audit and verify: exit 0. - plugin-audit full: Tests 1879 passed (1879), exit 0. - objectql full: Tests 14449 passed (14449), exit 0. - verify full: Tests 503 passed (503), exit 0. - cli `src/commands/audit/`, `serve-audit-registration.contract`, `app-audit-plugin-host-crypto`, `schema-migrate.one-shot-family.integration`: Tests 221 passed (221), exit 0. - `tsc --noEmit` of plugin-audit (with its test-typecheck layer) and objectql, and `eslint` on the changed sources: exit 0. - `gen:schema && gen:docs` regenerated `content/docs/references/data/object.mdx`. - `dispatch-gates --commands`: 142 derived, 141 exit 0. One NOT MEASURED: `check-plugin-teardown-shape --self-test` exits 3, PREREQUISITE NOT MET (needs an unshallow clone). - dogfood_battery at ff14eb2: `turbo run build --filter='@objectstack/dogfood^...'` 73 of 73 tasks, then `pnpm --filter @objectstack/dogfood test`: Test Files 488 passed | 3 skipped (491), Tests 4135 passed | 68 skipped (4203), exit 0. - Ablations at ff14eb2: 26 single-check ablations, each its own pin red, each file restored byte for byte. - `overlap-check` at ff14eb2: merges cleanly with origin/main c826e8a and the PR heads sharing `content/docs/deployment/cli.mdx` (objectstack-ai#37807, objectstack-ai#37366). - Earlier heads: 51ba1c1, 5860216, 4deab94, 46e272e (review 7198128323), 48e81f3 and c05884d (review 7202871622; CI green), 65a5d7d (reviews 7205485052 and 7207510869; CI green), 71bb12a (review 7209130288; CI green), 05e6a57 (review 7210787318; CI green). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01L6bhgUd6hon2o34LQSLbZt)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgUd6hon2o34LQSLbZt <!-- signed: repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Elon · project thread
Part of #31908 (governed ADR amendment; seat lands)
Clause-②: no
Metadata-protocol: none
维护者速读 (Maintainer quick read)
docs/adr/0154-audit-ledger-tamper-evidence-sealer-signed-checkpoints-amendments-verify.md末尾的 Amendment 节(两个小节各对应一条裁决),其次是 Consequences 的成本行标注。pnpm check:adr-links && pnpm check:adr-index,预期两者都通过、README 索引无变化。What changes
One file:
docs/adr/0154-audit-ledger-tamper-evidence-sealer-signed-checkpoints-amendments-verify.md. A new section, Amendment (2026-11-14, #31908): bounded checkpoints (D4) and the database session seal lock (D3), is appended at the end, in the style other records use for a dated amendment (ADR-0119, ADR-0125, ADR-0131): a status line segment, aStatus of this amendmentparagraph naming the ruling records, and the original text kept with a dated pointer in each place the amendment changes (the status line, D3's "one sealer at a time" and late-rows bullets, D4's heading, D9, and the Consequences cost line).latecheckpoints are capped the same way. The signed body carries a part index and a final flag, so a crash mid-window resumes aswindowand the rest is never mislabelledlate. The sealer's S1 ("not sealed twice") relaxes for parts of the same window. The verifier faults any row id two checkpoints list. This replaces D4's "one root per chain per window".sys_secretrow per checkpoint, which is now per part: one per active chain per window (the existing "at most 24 per organization per day") while no window holds more than N rows, and one more per further block of up to N rows. The work of one checkpoint is bounded by N; what grows with a window's volume is the number of checkpoints. No new figure is introduced.audit.sealer, a second named database session lock (the ruling's example name,objectstack:audit-seal), followingacquireSchemaMigrationLockinpackages/objectql/src/schema-migration-lock.ts: Postgres advisory lock or MySQLGET_LOCKon a dedicated out-of-pool connection, taken on the datasource that holds the audit rows (the hot store, where it differs from the primary). Each sealer pass try-locks it and skips while it is held;os migrate audit-* --applyholds it for the whole run, waiting up to a timeout longer than a normal sealer pass, then refusing. Where the lock is unavailable (it answers null on SQLite, Turso and other dialects),--applyon an object declaringlifecycle.sealis refused unless the operator passes the explicit sealer-stopped flag. Red line: never take a lock that excludes nothing and then proceed silently. The cluster lock, the unique(chain, sequence)index and D7's amendment-before-rewrite order stay. Options A, C and D are recorded as not taken, with the ruling's reasons.The amendment records the two rulings and adds no design of its own: names the rulings leave open (the session lock's exact key, the sealer-stopped flag's spelling, the part-index and final-flag column names) stay the build card's.
Tests
Docs only: no code, no test. The ADR gates are the verification below.
Acceptance notes
docs/adr/**, which publishes nothing from any package (fast-track path), so it takes theskip-changesetroute; the area thread applies that label.node scripts/adr-index.mjsregeneratesdocs/adr/README.mdbyte-identical: the index row's status excerpt is truncated before the appendedAmendedsegment, and the record's keyword (Proposed) is unchanged.origin/mainat0e9ff949c; one commit behindorigin/mainat open, which touches nodocs/adr/path.Verification
All readings at head
96b5a0412, a clean tree, repositoryobjectstack-ai/objectstack.Derived gate families (dispatch-gates --commands, 21) — all exit 0
Every other family CI runs (the wide-population and roster families, the type-check lanes) is CI's; read it from this PR's check-runs.
Human Minimum
packages/specholds no runtime logic. (No code in this PR.)pnpm lintpasses (eslint on the changed files; the repo-wide run is CI's). (No lintable file changed.)main, one pull request. (Cut frommainat0e9ff949c; Part of plugin-audit + objectql lifecycle: build the audit tamper-evidence ADR — sealer, signed checkpoints, redaction and expiry amendments,os audit verify#31908 by the seat's slicing.)docs/adr/**only, the skip-changeset route; both declaration lines are above.)packages/spectouched: its generated artifacts are regenerated and committed. (Not touched.)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cz2MxDkQYCC4U8indM