Skip to content

feat(plugin-audit): export the signed-body readers so a checkpoint sink can re-deliver what it missed - #35895

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-34170-export-signed-body-readers
Nov 20, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-34170-export-signed-body-readers

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread
Fixes #34170
Clause-②: yes
Metadata-protocol: none

维护者速读

  • 用户无感:审计插件对外多导出两个读取函数,外部的检查点接收方可以把已存储的检查点和修订记录还原成当初签名的原文。
  • 为企业版检查点外部锚定解决补发问题:接收方漏收的检查点以后可以重新读出并补发,审计链不再留缺口。
  • 出错时只影响拿这两个函数补发的外部接收方,补发内容会对不上签名;本改动只加导出、不改现有行为,可以直接撤回。
  • 无。

What changes

@objectstack/plugin-audit exports checkpointBodyFromRow and amendmentBodyFromRow from its package entry (the ADR-0154 export block), with the two body types they return, CheckpointSignedBody and AmendmentSignedBody. Only those two return types are exported, not the types they pull in (area ruling, option A). The readSignedCheckpoints helper the card also offered is not added (seat ruling).

A checkpoint sink (audit.checkpointSink, ADR-0154 D11) is handed each signed checkpoint and amendment once. Its contract says it re-delivers what a failed call missed by re-reading the stored records. Until now the readers that turn a stored sys_audit_checkpoint or sys_audit_amendment row back into the exact signed body were reachable only by path inside the package. A sink outside it would have had to copy the body shape and its parsing.

  • packages/plugins/plugin-audit/src/index.ts: four names added to the ADR-0154 export block, and one comment sentence on why.
  • packages/plugins/plugin-audit/src/audit-seal/signed-body.ts: comments only, no code. Each of the two readers gets a TSDoc @public and three paragraphs:
    • the D11 use, read from an unaltered row;
    • the reader validates and normalizes but never verifies the signature, so a sink verifies it under a key it trusts before it treats the row as delivered;
    • how a sink assembles the entry it re-delivers: kind from the table, keyId from body.signing_key_id, signature from the row, and its own RFC 8785 (JCS) serializer for the signed bytes.
  • packages/plugins/plugin-audit/src/audit-seal/audit-seal-signed-body-readers-34170.integration.test.ts: new pin, on a real kernel.
  • .changeset/34170-export-signed-body-readers.md: patch, with both declaration lines, and the same two paragraphs on verification and assembly.

Read first, by risk:

  1. audit-seal-signed-body-readers-34170.integration.test.ts: the whole acceptance claim. It imports the readers through ../index.js, the package entry, and compares the result with what the sink was actually handed.
  2. src/index.ts, the export hunk: the new public surface.
  3. The two reader TSDocs in signed-body.ts: the public guidance on what the reader does not check.

Two-minute check: pnpm --filter @objectstack/plugin-audit exec vitest run --maxWorkers=2 src/audit-seal/audit-seal-signed-body-readers-34170.integration.test.ts should report Tests 2 passed (2).

Tests

The new pin boots an ObjectKernel with ObjectQL, the audit plugin, a registered checkpoint sink and SQLite (wasm). It seals one settled window, which delivers a checkpoint, then runs the mail-log body migration, which delivers a redaction amendment. For each kind, the test reads the stored row and checks four things:

  • the reader's body equals the delivered entry.body;
  • signedBodyBytes(body) is byte-equal to the RFC 8785 bytes of the delivered body;
  • the row's signature and the body's signing_key_id match the delivered entry;
  • the signature verifies (Ed25519) over those bytes under the stored, trusted signing key.
Round 1 (d6a679c): comments and changeset only, proved; typecheck and pin re-run
git diff -U0 af6dff1d84 d6a679c374 -- '*.ts', added or removed lines that are not comment lines: count=0
  .changeset/34170-export-signed-body-readers.md  |  6 +++-
  packages/plugins/plugin-audit/src/audit-seal/signed-body.ts  | 34 +++++++++++++++++++---

pnpm --filter @objectstack/plugin-audit typecheck
  check:test-typecheck: OK, 0 file(s) / 0 error(s) / 0 pinned signature(s)
pnpm --filter @objectstack/plugin-audit exec vitest run ... audit-seal-signed-body-readers-34170.integration.test.ts
  Test Files  1 passed (1)
       Tests  2 passed (2)
  os-verify-lock: VERDICT command-exit 0

node scripts/check-changeset-no-major.mjs --base origin/main --event (this body's declaration lines)
  LEVEL AXIS: clause-② yes, metadata-protocol none, no entry graded minor or above. exit 0
node scripts/pm/overlap-check.mjs
  origin/main (f44758b21e): merges cleanly, 0 PR heads. VERDICT clean exit 0
Round 0: plugin-audit typecheck and tests (code at 6e06a45)
pnpm --filter @objectstack/plugin-audit typecheck
  check:test-typecheck: OK, the test layer compiles under tsconfig.test.json; 0 file(s) / 0 error(s) / 0 pinned signature(s)
  os-verify-lock: VERDICT command-exit 0

pnpm --filter @objectstack/plugin-audit exec vitest run --maxWorkers=2
  Test Files  104 passed (104)
       Tests  1731 passed (1731)
  os-verify-lock: VERDICT command-exit 0
Ablation: delete the checkpointBodyFromRow export, and the pin goes red

Committed first (6e06a45), mutated through scripts/ablation-replace.mjs, and restored to the HEAD blob. The subject resolves through src/ (a relative import of the package entry), so no build sits between the mutation and the run.

ablation-replace: anchor   x1 -> x0
ablation-replace: blob     51f6525fbc98 -> 060554f73253
 × ... a checkpoint: the stored row rebuilds the delivered body byte for byte ...
 ✓ ... an amendment: the stored row rebuilds the delivered body byte for byte ...
TypeError: checkpointBodyFromRow is not a function
      Tests  1 failed | 1 passed (2)
ablation-replace: ok restored: blob == HEAD (51f6525fbc98) and `git diff HEAD` is empty

Restored run: Tests 2 passed (2), VERDICT command-exit 0. The amendment leg stays green under the checkpoint ablation, so the red is specific to the deleted export. Round 1 changes no code, so no new ablation is owed.

Acceptance notes

  • Changeset level: patch. Under maintainer ruling A, Metadata-protocol: none takes patch (AGENTS.md, Post-Task Checklist step 3; scripts/check-changeset-no-major.mjs). The claim's minor was corrected in af6dff1. The contract review agreed (patch is right) and so did the seat's level amendment on the card.
  • Contract review S1 and S2, taken in round 1. S1: both TSDocs and the changeset now say the reader checks shape, never authenticity, and that a sink verifies the signature over the rebuilt body under its own trusted key before it treats the row as delivered. S2: they say how a sink assembles the entry, and that it needs its own RFC 8785 serializer.
  • Accepted deviations, contract review nits N1 to N4, not taken:
    • N1: @public sits on the two readers only, not on the two exported types or any other entry export. Nothing reads the tag.
    • N2: SignedBodyError, AUDIT_CHECKPOINT_OBJECT and AUDIT_AMENDMENT_OBJECT stay internal. The error's name string and the two literal table names are the contract a sink reads.
    • N3: the reader accepts only the installed AUDIT_SEAL_CANON_VERSION (1). A later canonical form must keep version 1 rows readable; that is worth a line where the constant is next bumped.
    • N4: the pin compares with toEqual and JCS bytes, so member order is not pinned. The contract is the RFC 8785 form.
  • No API-surface baseline exists for @objectstack/plugin-audit: the api-surface snapshot covers packages/spec only.
  • Carry: a later card may export signedBodyBytes (the package's RFC 8785 serialization) if the cloud#4128 sink needs it, so the consumer does not copy the serialization. It is not exported in this PR.

Verification

Based on origin/main 8c18a36. overlap-check at d6a679c against origin/main f44758b: VERDICT clean, exit 0, 0 open PR heads share a file. CI runs the full gate set: see this PR's check runs.


Generated by Claude Code

Export checkpointBodyFromRow and amendmentBodyFromRow, with the two body
types they answer, from the ADR-0154 export block of the package entry, so
a checkpoint sink outside the package can rebuild a stored checkpoint or
amendment row into the exact body it was handed and re-deliver it.

Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7
Co-authored-by: Claude <noreply@anthropic.com>
Metadata-protocol: none takes patch on the level axis; exporting two
readers changes nothing a metadata author can write.

Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

⚠️ 2 changed file(s) yielded no anchor (packages/plugins/plugin-audit/src/audit-seal/signed-body.ts, packages/plugins/plugin-audit/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files. Nothing else in this diff resolved to a documentable surface (no symbol, route or SDK anchor derived from 1 changed package(s)).

What this run could not see
  • 2 changed file(s) yielded no anchor (packages/plugins/plugin-audit/src/audit-seal/signed-body.ts, packages/plugins/plugin-audit/src/index.ts) — pages documenting those are invisible to this run
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 12 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json cd55df8f3ce5beb41f4db51ef3b7eb7ac317dd73 → packageMentionDocs.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7

Contract-review-claim: session_01L9qibwJEh7hMPPvagWM1g7 · head af6dff1 · 2026-11-20T17:58Z

The L2 is owed on the Clause-②: yes face, a new public export of @objectstack/plugin-audit. It runs at CONTRACT_REVIEW_TIER, per the seat ruling on this card, as an isolated reviewer on this head.

@objectstack-fleet objectstack-fleet Bot added the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Nov 20, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

L1: ACCEPT at af6dff1d84a58b6bf78e0d36661503717e8bb3aa (2026-11-20T17:59Z)

Scope. I reviewed the 4 files against merge base 8c18a362a2 (+164 / −2). The dev reports are 7045478481 and 7046786325.

What I checked

  • The exports.

    • checkpointBodyFromRow and amendmentBodyFromRow join the ADR-0154 export block of @objectstack/plugin-audit's entry.
    • CheckpointSignedBody and AmendmentSignedBody join the type block.
    • Everything else in ./audit-seal/ stays reachable by path inside the package only, as the block's comment says. Both readers get a @public TSDoc that states the D11 use. ✔
  • The pin, through the package entry.

    • It imports from ../index.js, which is what a sink outside the package imports, on a real kernel.
    • For a checkpoint and for an amendment, it reads the stored row back. It asserts that:
      • the reader answers the body the sink was handed (toEqual(entry.body));
      • signedBodyBytes(body) equals the RFC 8785 bytes of that body;
      • the row's signature is the delivered one;
      • the signature verifies over those bytes under the stored, trusted key.
    • It also asserts that the stored row is not itself the body.

    This is exactly the changeset's claim that the RFC 8785 serialization of the reader's answer is the bytes the row's signature covers. ✔

  • The ablation is a positive control. Deleting the checkpointBodyFromRow export line turns the checkpoint leg red (… is not a function). The amendment leg stays green as the control, and the restore is clean back to the HEAD blob. ✔

  • The changeset, sentence by sentence.

    • The exports and types are named. ✔
    • The sink is handed each record once and re-delivers by re-reading stored records (D11), which matches the pin. ✔
    • "A malformed row is refused with an error whose name is SignedBodyError and whose message names the field" is the existing class (signed-body.ts:38, this.name = 'SignedBodyError'). The class is not exported, so stating it by name is the honest form. ✔
  • The level. Clause-②: yes covers new exports, which widen the package. Patch is right: under ruling A, Metadata-protocol: none takes patch, as on feat(lint): warn when a text field named like a currency, country or time zone code declares no valueDomain #35378 (a new lint code, Clause-②: yes, patch), and the seat's level amendment on A sink cannot re-read a stored checkpoint into the body it was signed over, so a checkpoint missed once is never re-sent #34170 records it. ✔

  • Not a narrowing, not governed, no !. So no dogfood battery and no Skills-docs: line is owed. ✔

  • CI at af6dff1d84. When I read it: 37 success, 20 skipped, 1 in progress (Check Changeset), 0 red.

Before landing

  • CI fully green on this head.
  • A CONTRACT_REVIEW_TIER L2 PASS on this head (claim 7046817453), because Clause-②: yes is declared.
  • The PR leaves draft.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: af6dff1d84a58b6bf78e0d36661503717e8bb3aa
Local-runs: none
Scope: packages/plugins/plugin-audit/src/index.ts, packages/plugins/plugin-audit/src/audit-seal/signed-body.ts, .changeset/34170-export-signed-body-readers.md + packages/plugins/plugin-audit/src/audit-seal/audit-seal-signed-body-readers-34170.integration.test.ts
Security-touching: yes

Read for this record: card #34170 with all 8 comments, PR #35895 (body, 4 files, net diff against main, merge base 8c18a362a2), and the 58 check-runs on this head. Read but not reviewed, at this head: packages/plugins/plugin-audit/package.json, src/audit-seal/index.ts, sealer.ts, amendment-writer.ts, packages/spec/src/contracts/audit-checkpoint.ts, ADR-0154 (D11 and the residual-risk note), AGENTS.md Post-Task Checklist step 3.

Check-runs on this head: 58 runs, 38 success, 20 skipped, none failed or pending. Check Changeset ran twice (17:25Z and 17:58Z), both success. Build Core, TypeScript Type Check (workspace, source gates, consumer gates), Test Core 10/10, Lint & Repo Gates, Governed Surface Queue Guard and the PR-body guards are success.

① Derived judgments

  • What the entry now adds: exactly four names. Right. src/index.ts adds the values checkpointBodyFromRow and amendmentBodyFromRow and the types CheckpointSignedBody and AmendmentSignedBody to the existing ADR-0154 export block. Nothing else in the block moved. The two-dot diff against main shows no other plugin-audit file differs.
  • The exports map: only . is addressable. Right. package.json has one entry, ., with import and require conditions, and files ships dist only. No subpath exists, so ./audit-seal/* stays unreachable from outside, and the entry is the only door. The four names are the whole widening.
  • Nothing else became reachable. Right. Still inside the package: signedBodyBytes, checkpointDigest, checkpointRow, amendmentRow, checkpointLeafHashesFromRow, checkpointPartOf, chainKeyOf, SignedBodyError, canonicalJson / canonicalJsonBytes, AUDIT_CHECKPOINT_OBJECT, AUDIT_AMENDMENT_OBJECT, the sealer and the signer.
  • Transitive types: unnamed from the entry, and that is sound. CheckpointSignedBody refers to AuditCheckpointKind and SealedColumnSet. AmendmentSignedBody is the union of RedactionAmendmentBody and ExpiryAmendmentBody, which extend the module-private AmendmentCommon. None of the five is exported from the entry. The declaration bundle carries them as unexported declarations, which TypeScript accepts; Build Core and the consumer type gates are green on this head. A consumer reads every member and narrows the union on kind, but cannot name a union arm. That matches what the PR body calls the area ruling, option A. The ruling itself is not on the card thread (see ③).
  • One consequence the diff implies and nobody names: the member shapes of those five types are now public by structure. Renaming or retyping a member of RedactionAmendmentBody is a change to the entry's surface, even though the name is not exported. No finding; it follows from option A.
  • @public TSDoc: consistent with the claim, uneven against the tree (N1). Both readers carry @public, as the claim's file surface says ("on the two readers only"). The two exported types carry none, and no other entry export of this package carries the tag: these are its only two uses in plugin-audit. Nothing reads the tag: there is no API-extractor config, and the api-surface snapshot covers packages/spec only, so the dev's "no baseline exists for this package" is right.
  • No runtime behaviour changed. Right. The signed-body.ts hunks are comment-only: no code line moved in either reader.

② Semver level

patch with Clause-②: yes and Metadata-protocol: none is right.

  • AGENTS.md, Post-Task Checklist step 3: "The level follows the kind alone: a kind takes at least minor on a package the diff moves, none takes patch; a non-protocol change, widening or breaking, ships patch."
  • none is the correct kind. Metadata-protocol is the change to what a metadata author can write. Two exported functions and two types add no key, value or metadata type.
  • Clause-②: yes is the correct clause. The package's public surface widens. No arm is required ("at most one arm").
  • Both declaration lines are line-initial in the changeset body and in the PR body, and they agree.
  • Check Changeset is success on this head, twice. The claim's minor was the error, and the seat's level amendment (the latest card comment) corrects it. The changeset names one package, the one whose source moved.
  • The changeset's title keeps feat(...). Under the rule above the level follows the kind, not the commit type, and the gate agrees.

③ Boundary flags

Dev report 7045478481 (blocked):

  • Open question, how to commit after the refused git commit: closed by events. The re-claim 7045416162 records the maintainer's choice on the decision card, and report 7046786325 shows the commit made after it. It is a permission matter, not a contract one, and nothing in the tree depends on it.
  • Out-of-scope note, the release comment says "never pushed" while origin held the branch at the base sha: accepted as stated. An empty marker push carries no work.
  • Deviation, overlap-check after the commit: accepted. It has no effect on the contract.

Dev report 7046786325 (done):

  • Open question, keep patch: A, keep patch. See ②.
  • NOT MEASURED locally, check:dual-build-cjs-loads and check:i18n: answered by CI on this head (Build Core and Lint & Repo Gates are success).
  • The note that main moved to f44758b21e after the local runs: answered by the check-runs, which ran on this head. The PR reads mergeable_state: clean.
  • Deviations 1 to 5 (overlap-check order, push before verification, trailers, attribution lines, worktree removal): process only, the lane seat's to accept. None touches the exported surface.
  • security_findings: none: I agree that the diff opens no hole (④). The record still reads Security-touching: yes, because the changed hunks export readers of the tamper-evidence mechanism and teach what a signature covers.

Escalated to the seat:

  • E1, the tier. The committed tree touches no published schema and no governed path, so by the template's own rule the face is the declaration one, which maps to TIER_DEFAULT. The release comment 7044194641 says the same ("a TIER_DEFAULT L2 is owed"). This record is served at CONTRACT_REVIEW_TIER because the claim cites a seat ruling asking for it. The seat should confirm that the record reader accepts a record served above the face's tier before it posts.
  • E2, two rulings I could not read. The seat ruling of 05:26Z (shape, @public, tier) and the area ruling "option A" (two return types only) are quoted in the claim, the release comment and the PR body, but neither is a comment on the card. I judged both points on the tree, and both hold on their merits.
  • E3, the PR is still a draft.

SQL push-down: no finding. The diff adds no production query, no id materialisation and no in-app join. The only reads are the test's two engine.find calls on one-row tables.

④ Design judgment

Against the card's acceptance scenario: holds. The sealer hands the sink the object it signed (sealer.ts, signBody then deliver), and stores checkpointRow(body, ...), which itself passes the body through checkpointBodyFromRow. The amendment writer does the same with amendmentRow. So the stored row is the reader's own normal form plus the unsigned columns, and reading it back gives the delivered members. The live verifier reads stored rows through the same two functions, so a sink's re-read and the verifier's read cannot drift apart. That is the property the card asks for. The pin proves it on a real kernel for a window checkpoint and a redaction amendment, with the readers imported through ../index.js.

Against ADR-0154: holds. D2: a body carries commitments, roots, digests and handle ids, never a value, salt or seed, so exporting the body types publishes nothing that AuditCheckpointSinkEntry.body did not already describe member by member in packages/spec. D11: the sink seam is unchanged; the export serves the contract's own sentence, "it can re-read the stored records".

Attempts to break it:

  • Forge or build a signed body. Not possible through the new surface. The readers are pure: a row in, a validated body out. No signer, no key, no engine. checkpointRow, amendmentRow and the signer stay internal. A caller able to write sys_audit_checkpoint rows could do so before this PR.
  • Weaken verification. No. verifier.ts and bundle.ts are untouched, and the readers are the functions the verifier already trusts.
  • A body that verifies for a row it should not. I found none. The signature covers sealed_object, tenant_id and sequence, so a body cannot be moved to another chain or position. The reader ignores id, chain_key, leaf_hashes and, on an amendment, the other kind's columns. Changing those leaves the signed bytes unchanged, which is correct: they are not signed. Driver spellings ("7" for a count, 1 for a flag, a Date for an instant) fold to one body by design. An absent tenant_id is refused, never read as the deployment chain. previous_digest absent on a sequence above 0 is refused.
  • Hidden state. One coupling: the reader refuses any canon_version other than the installed AUDIT_SEAL_CANON_VERSION (N3).
  • Stability as a contract. Output members are fixed by the spec's sink contract and by the signature itself, so they cannot move without breaking stored signatures. Pre-amendment checkpoints (no part_index, final_part) read back without the two keys, so their bytes stand.

Findings:

S1 (should-fix) — The public TSDoc and the changeset say the reader "answers the body the sink was handed". That holds only for a row nobody changed. The reader checks shape, never authenticity, and a missed checkpoint waiting for re-delivery is exactly the row a host operator can still rewrite (ADR-0154: "Whoever holds the database and either key can re-sign"). The readers' own neighbour says it for its case (checkpointLeafHashesFromRow: "and its signature checked"); the two @public readers do not. Add one sentence to each TSDoc and to the changeset: the reader validates and normalizes, it does not verify the signature, and a rewritten row yields a body that fails verification (or, re-signed by a key holder, one that only the off-host trust anchor catches). Not blocking: the export weakens nothing, and the residual risk is the ADR's own, stated there.

S2 (should-fix) — The acceptance speaks of the entry and its signed bytes; the export gives the body only. A sink outside the package must assemble the entry itself (kind from the table, keyId from body.signing_key_id, signature from the row's signature column) and bring its own RFC 8785 serializer, because signedBodyBytes and canonicalJson stay internal. The pin shows this: its reader comes through the entry, but its bytes and its key check come from ./signed-body.js, ./jcs.js and ./signer.js by path. The contract still holds, since first delivery leaves the sink in the same position and the pin asserts row.signature and signing_key_id against the delivered entry. Fix in this PR by stating the assembly in the TSDoc or changeset, and carry to cloud#4128 whether signedBodyBytes should follow, so the consumer does not copy the serialization the card set out not to copy.

N1 (nit) — @public sits on the two readers only: not on the two exported types, and on no other entry export of the package. Nothing reads the tag.

N2 (nit) — SignedBodyError is not exported, so the changeset makes the error's name string the contract. That is workable and it is stated. AUDIT_CHECKPOINT_OBJECT and AUDIT_AMENDMENT_OBJECT are likewise internal, so the changeset's two literal table names are what a sink queries by.

N3 (nit) — The reader accepts only the installed AUDIT_SEAL_CANON_VERSION (1). Now that it is public, a later canonical form must keep version 1 rows readable, or a sink cannot backfill older checkpoints. Worth a line where the constant is next bumped.

N4 (nit) — The pin compares with toEqual and JCS bytes, so member order is not pinned. It need not be: the contract is the RFC 8785 form. Today's order happens to match the sealer's.

No must-fix.

Implemented-by: claude/issue-34170-export-signed-body-readers
Reviewed-by: session_01L9qibwJEh7hMPPvagWM1g7

VERDICT: PASS

…ow a sink assembles the entry

The two public readers validate and normalize a stored row; they never
check its signature, so a sink verifies it under a key it trusts before
treating the row as delivered. State how an outside sink assembles the
re-delivered entry (kind from the table, keyId from body.signing_key_id,
signature from the row) and that it brings its own RFC 8785 serializer.
Comment and changeset prose only.

Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

L1 delta: ACCEPT at d6a679c374e6e29a7765d6f81fca7276ae80261e (2026-11-20T18:45Z)

This follows my ACCEPT 7046859393 at af6dff1d84. This round answers CONTRACT_REVIEW_TIER L2 7046919186 (PASS with S1 and S2). The dev report is 7047779338.

What I checked

  • The diff from af6dff1d84 is prose only. It is one commit touching two files: the changeset (+5 / −1) and audit-seal/signed-body.ts (+30 / −4). Every changed line in signed-body.ts sits inside the TSDoc of checkpointBodyFromRow or amendmentBodyFromRow, so no code line moved. The code findings in 7046859393 carry over unchanged.

  • S1: met. Both TSDocs and the changeset now say:

    • the body equals the one the sink was handed only for an unaltered stored row;
    • the readers validate and normalize, and never verify the signature;
    • a rewritten row fails verification, and a row re-signed by a key holder is caught only by the off-host trust anchor;
    • so a sink verifies the row's signature under a key it trusts itself before it treats the row as delivered.

    This matches the code: neither reader calls the verifier or trustedSigningKey. ✔

  • S2: met, and I checked each assembly claim against the delivery path.

    • kind. The sealer delivers kind: 'checkpoint' (sealer.ts#deliver) and the amendment writer delivers kind: 'amendment', so the kind follows from the table. ✔
    • keyId. The value delivered is the keyId the signer answered. Both signBody loops deliver only when that equals expected, the id the body was built with. So body.signing_key_id is the delivered keyId. ✔
    • signature. The value delivered is the stored row's signature column. ✔
    • The bytes. signedBodyBytes stays unexported: it is not in src/index.ts. The prose says "this package does not export one", which is true. ✔
    • The Carry line. The PR body's Carry line names cloud#4128 for whether signedBodyBytes should follow. ✔
  • CI at d6a679c374: 39 success, 18 skipped, 0 failed. ✔

Before landing

  • The same-head CONTRACT_REVIEW_TIER delta L2 PASS on d6a679c374. It is running.
  • Undraft.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: d6a679c374e6e29a7765d6f81fca7276ae80261e
Local-runs: none
Scope: packages/plugins/plugin-audit/src/index.ts, packages/plugins/plugin-audit/src/audit-seal/signed-body.ts, .changeset/34170-export-signed-body-readers.md + packages/plugins/plugin-audit/src/audit-seal/audit-seal-signed-body-readers-34170.integration.test.ts
Security-touching: yes

Delta review of record 7046919186 (head af6dff1d84) against this head. Read: the one new commit d6a679c374 (its parent is af6dff1d84), the net diff against main, dev report 7047779338, the PR body as it now stands, and the 57 check-runs on this head. Read but not reviewed, at this head: verifier.ts, packages/spec/src/contracts/audit-checkpoint.ts and ADR-0154, for the meaning of "trust anchor".

Check-runs on this head: 57 runs, 39 success, 18 skipped, none failed or pending. Build Core, TypeScript Type Check, Test Core, Lint & Repo Gates, Governed Surface Queue Guard, the PR-body guards and Check Changeset (twice) are success.

① Derived judgments

  • The round is comment and changeset prose only. Confirmed on the tree. The commit touches two files: signed-body.ts (+30 / −4) and the changeset (+5 / −1). Every changed .ts line is a TSDoc line: the count of changed non-comment lines is 0. src/index.ts, the test file and package.json are unchanged from af6dff1d84.
  • The public surface is what it was. The entry still exports the same four names; signedBodyBytes stays internal, as the dev reports. Every ① judgment of record 7046919186 stands.
  • The net diff against main is the same four files.

② Semver level

Unchanged: patch, Clause-②: yes, Metadata-protocol: none. Both declaration lines are still line-initial in the changeset. Check Changeset is success on this head. The judgment of record 7046919186 stands.

③ Boundary flags

Dev report 7047779338:

  • open_questions: none.
  • Deviation 1, the dev wrote the PR body in a patch round: process only, the seat's to accept; the coordinator's order named it.
  • Deviation 2, the worktree was recreated and removed: no effect on the contract.
  • NOT MEASURED locally (check:dual-build-cjs-loads, check:i18n, check:type-check-debt): answered by CI on this head, where Build Core, Lint & Repo Gates and TypeScript Type Check are success.
  • security_findings: none: not agreed for this round. See M1.

Still open from record 7046919186, for the seat: E1 (the committed tree maps to the declaration face, so confirm the reader accepts this above-tier record), E2 (the two quoted rulings are not on the card) and E3 (the PR is still a draft).

SQL push-down: no finding. No query was added.

④ Design judgment

Each new sentence, against the code:

  • "read from an unaltered stored row, it answers the body the sink was handed": right.
  • "It validates and normalizes; it never verifies the signature": right. Neither reader takes a key or reads signature.
  • "A rewritten row reads back into a body that fails verification": right for a signed column. Two cases are left out (N5).
  • "or, re-signed by whoever holds the signing key, into one that only the off-host trust anchor catches": wrong. See M1.
  • "So a sink verifies the row's signature over the rebuilt body, under a key it trusts itself, before it treats the row as delivered": sound as an instruction. It catches a changed signed column and a key the sink does not trust.
  • The entry assembly: right. kind is 'checkpoint' or 'amendment', as AuditCheckpointSinkEntry.kind declares. keyId is body.signing_key_id: the sealer and the amendment writer never store a signature whose key id differs from the one in the bytes. signature is the row's signature column, which checkpointRow and amendmentRow write.
  • "this package does not export one": right. Neither signedBodyBytes nor canonicalJson is in the entry.

Findings:

M1 (must-fix) — The sentence says a row re-signed by the signing-key holder is caught by "the off-host trust anchor". In this tree a trust anchor is the party that vouches for a public key (IAuditCheckpointSigner.trustedPublicKey: "This is the trust anchor os audit verify's live check reads"; verifier.ts: "A signature is ok only under a key the trust anchor vouches for"). A row rewritten and re-signed with the genuine signing key verifies under exactly that key, so the trust anchor does not catch it, and neither does the check the next sentence prescribes. What catches it is the copies already off the host: a later checkpoint's signed previous_digest no longer matches the rewritten one (ADR-0154: such a holder "can rewrite rows, recompute roots and re-sign the chain", and only "taking checkpoints off the host as they are signed" closes that). The trust anchor catches the other case, a row signed under a key planted on the host. The sentence appears three times: both reader TSDocs and the changeset, which ships as CHANGELOG.md and is not amendable in place after release. It teaches a sink author that a signature check under a trusted key covers a key-holder rewrite, on the one path, re-delivery, where the row has no off-host copy yet.

The wording came from this reviewer's own S1 in record 7046919186, which was loose in the same way; the dev took it faithfully. The fault is the record's first, and it is corrected here.

A fix that matches the code, in all three places: "A rewritten row reads back into a body that fails verification. A row rewritten and re-signed under a key planted on the host fails under a key the sink trusts itself. A row rewritten and re-signed by whoever holds the genuine signing key verifies; only the copies already off the host catch it, because a later checkpoint's signed previous_digest no longer matches. So a sink verifies ..." The last sentence can stay as it is.

N5 (nit) — "A rewritten row reads back into a body that fails verification" leaves out two cases: a rewrite of an unsigned column (id, chain_key, leaf_hashes) reads back into the same body, and a malformed rewrite is refused with SignedBodyError. The M1 rewrite can take "a row whose signed columns were rewritten" in passing.

Closures against record 7046919186:

  • S1: not closed. The three points asked for are present (unaltered row, no signature check, the sink verifies under its own trusted key), but the added clause is wrong. It is reopened as M1.
  • S2: closed. The assembly is stated in both TSDocs and the changeset, and the PR body carries the signedBodyBytes question as a Carry line.
  • N1 to N4: closed as accepted deviations, listed in the PR body's Acceptance notes. The text there matches the record.

Implemented-by: claude/issue-34170-export-signed-body-readers
Reviewed-by: session_01L9qibwJEh7hMPPvagWM1g7

VERDICT: FAIL

… checkpoint or amendment

A row re-signed with the genuine signing key verifies under that key, so
the trust anchor does not catch it; only the copies already off the host
do (a later checkpoint's signed previous_digest). A key planted on the
host fails under a key the sink trusts itself. Note the unsigned columns
and the SignedBodyError refusal in passing. Comment and changeset prose
only.

Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH

L1 delta-2: ACCEPT at 588872ba8fd9e0ab4bdae950df3abae387668c89 (2026-11-20T19:25Z)

This follows my delta ACCEPT 7047822201 at d6a679c374. This round answers delta L2 FAIL 7047833971 (M1 and N5). The dev report is #34170 comment 7048592847.

A correction to my own delta. At d6a679c374 I accepted "re-signed by whoever holds the signing key, into one that only the off-host trust anchor catches" as meeting S1. It did not. The trust anchor vouches for a public key, so it catches a key planted on the host, not the genuine key-holder. M1 is right, and I should have caught it.

What I checked

  • The diff from d6a679c374 is prose only. It is one commit touching signed-body.ts, in the two reader TSDocs (+20 / −10), and the changeset (+1 / −1). No code line moved. Each claim below is checked against signed-body.ts at this head.
  • M1: met, in all three places. Each now tells three cases apart:
    • A rewrite of the signed columns fails verification.
    • A re-sign under a key planted on the host fails under a key the sink trusts itself.
    • A re-sign by the genuine key-holder verifies. Only copies already off the host catch it:
      • For a checkpoint, a later checkpoint's signed previous_digest no longer matches. CheckpointSignedBody.previous_digest is the SHA-256 of the chain's previous signed body. ✔
      • For an amendment, no later record carries its digest. Neither AmendmentCommon nor any checkpoint body field references an amendment. ✔
  • N5: absorbed correctly.
    • Checkpoint. The unsigned columns named are id, chain_key and leaf_hashes. checkpointBodyFromRow ignores id, chain_key and signature, the body carries root and not the hashes, and chain_key is derived from tenant_id. ✔
    • Amendment. The unsigned columns named are id and chain_key. ✔
    • A malformed rewrite is refused with a SignedBodyError. ✔
    • The changeset says "a checkpoint's leaf_hashes", so the list is right for both tables. ✔
  • The sink's instruction is unchanged and still right. It verifies under its own trusted key before treating a row as delivered. The prose no longer implies that this covers a key-holder rewrite. ✔
  • CI at 588872ba8f: 37 success, 16 skipped, 0 failed. ✔

Before landing

  • The same-head CONTRACT_REVIEW_TIER delta L2 PASS on 588872ba8f. It is running.
  • Undraft.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 588872ba8fd9e0ab4bdae950df3abae387668c89
Local-runs: none
Scope: packages/plugins/plugin-audit/src/index.ts, packages/plugins/plugin-audit/src/audit-seal/signed-body.ts, .changeset/34170-export-signed-body-readers.md + packages/plugins/plugin-audit/src/audit-seal/audit-seal-signed-body-readers-34170.integration.test.ts
Security-touching: yes

Second delta review: the delta record 7047833971 (head d6a679c374, FAIL on M1) against this head. Read: the one new commit 588872ba8f (its parent is d6a679c374), the net diff against main, dev report 7048592847, and the 53 check-runs on this head. Read but not reviewed, at this head: the rest of signed-body.ts (checkpointRow, amendmentRow, checkpointDigest) and the other audit-seal sources, for the digest claims.

Check-runs on this head: 53 runs, 37 success, 16 skipped, none failed or pending. Build Core, TypeScript Type Check, Test Core, Lint & Repo Gates, Governed Surface Queue Guard and Check Changeset are success.

① Derived judgments

  • The round is comment and changeset prose only. Confirmed on the tree. The commit touches two files: signed-body.ts (+20 / −10) and the changeset (+1 / −1). Every changed .ts line is a TSDoc line: the count of changed non-comment lines is 0.
  • The public surface is what it was. src/index.ts, the test file and package.json are unchanged since af6dff1d84. The entry exports the same four names. Every ① judgment of record 7046919186 stands.
  • The net diff against main is the same four files.

② Semver level

Unchanged: patch, Clause-②: yes, Metadata-protocol: none. Both declaration lines are still line-initial in the changeset. Check Changeset is success on this head. The judgment of record 7046919186 stands.

③ Boundary flags

Dev report 7048592847:

  • It adapts the key-holder sentence per reader instead of taking the M1 wording verbatim, because the previous_digest clause would be false for an amendment. That is right, and it is the better fix: the wording this reviewer offered in M1 was written for a checkpoint and was offered for all three places.
  • NOT MEASURED locally (check:dual-build-cjs-loads, check:i18n) and the three scripts stale against a moving main: answered by CI on this head, where Build Core and Lint & Repo Gates are success.
  • The PR body was not changed this round: accepted. It never carried the trust-anchor sentence.

Still open from record 7046919186, for the seat: E1 (the committed tree maps to the declaration face, so confirm the reader accepts this above-tier record), E2 (the two quoted rulings are not on the card) and E3 (the PR is still a draft).

SQL push-down: no finding. No query was added.

④ Design judgment

Each new sentence, against the code:

  • "A row whose signed columns were rewritten reads back into a body that fails verification": right.
  • The unsigned columns. Checkpoint TSDoc names id, chain_key and leaf_hashes; amendment TSDoc names id and chain_key. Right: checkpointRow writes id, chain_key, leaf_hashes and signature beside the body, amendmentRow writes id, chain_key and signature, and neither reader reads any of them. signature is correctly left out of the list, since changing it fails verification.
  • "a malformed one is refused with a SignedBodyError": right. Every field reader throws that class, and instant rewraps a datetime fault into it.
  • "A row rewritten and re-signed under a key planted on the host fails under a key the sink trusts itself": right.
  • Checkpoint: "re-signed by whoever holds the genuine signing key verifies; only the copies already off the host catch it, because a later checkpoint's signed previous_digest no longer matches". Right. checkpointDigest is the SHA-256 of the signed body's bytes, previous_digest is a signed member of the next body, and the verifier reports a link whose digest does not match.
  • Amendment: "no later record carries an amendment's digest, so only checks against the copies already off the host can catch it". Right. No amendment digest exists in audit-seal: the only digests a body carries are a checkpoint's (previous_digest, and an expiry's last_removed_digest).
  • The changeset carries both halves in one sentence, with "can catch it". Right.

Findings:

No must-fix, no should-fix.

N6 (nit) — The checkpoint TSDoc says the off-host copies "catch it"; the changeset says they "can catch it". The second is the exact one: a rewritten checkpoint that is the newest of its chain has no later link off the host yet. The same holds for a missed amendment, where the TSDoc already says "can".

Closures:

  • M1: closed. The trust-anchor clause is gone from all three places, and what replaces it matches the code.
  • N5: closed. Absorbed as the parenthetical on unsigned columns and malformed rows.
  • S1: closed, with M1.
  • S2 and N1 to N4: closed in delta record 7047833971; nothing here reopens them.

Implemented-by: claude/issue-34170-export-signed-body-readers
Reviewed-by: session_01L9qibwJEh7hMPPvagWM1g7

VERDICT: PASS

@objectstack-fleet objectstack-fleet Bot removed the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Nov 20, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7

Landing — PR #35895 (#34170) at 588872ba8fd9e0ab4bdae950df3abae387668c89, 2026-11-20T19:27Z

  • L1: delta-2 ACCEPT 7048622698 (same head).
  • L2: CONTRACT_REVIEW_TIER delta PASS 7048628871 (same head; M1 closed, N5 absorbed, nit N6 left as is). needs:contract-review removed.
  • CI on this head: 53 runs, 37 success, 16 skipped, 0 red.
  • check-governed-merges --pr 35895: NOT governed (0 of 4 paths on the register), 207 lines. Not narrowing (Clause-②: yes, patch).
  • overlap-check --pr=35895: clean, merges cleanly. K = 7 first-parent commits on main since the merge base 8c18a362a2 (< 15, no main merge needed).
  • E1–E3 of record 7046919186: E3 (draft) is resolved by this landing; E1/E2 are reported to the seat.

Landing under the standing go-ahead for pm-dispatch-reviewed PRs: ready for review + auto-merge (queue).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 20, 2026 19:27
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 2a0cd20 Nov 20, 2026
57 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34170-export-signed-body-readers branch November 20, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A sink cannot re-read a stored checkpoint into the body it was signed over, so a checkpoint missed once is never re-sent

2 participants