Repository navigation
feat(reporting): canonical JSONL row encoding for revision row storage - #3145
Conversation
Add contract-fixed canonical JSONL encoding for reporting revision rows (shared SDK persistence spec, adcontextprotocol/adcp#7996 §3.1): 500-row segments, 10,000-row / 8 MiB chunks, segment/chunk/manifest digests, ranged verified segment decoding, and streaming hashers that reproduce revision_content_sha256 and the rows_v1 profile from stored bytes without parsing rows. Includes golden vectors shared with the Python SDK. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
There was a problem hiding this comment.
Ladon verdict: Approve
Approve.
Clean, additive PR adding canonical JSONL row encoding for reporting revisions (row-encoding.ts), a golden-vector fixture, and a comprehensive node:test suite. Pure computation — no I/O, no wire reshaping, no mock/fallback data; witness-not-translator holds. Verified load-bearing paths: the streaming envelope hasher reconstructs JCS(full envelope) byte-for-byte in correct key order; lone-surrogate regex is real work since jcs.serializeString passes surrogates through verbatim; oversized-row isolation and segment/chunk verification fail closed. Changeset is minor, correct for a new additive export surface.
No Critical/High/Medium findings. No escalation triggers: high_risk false, gated_paths false, no team gate, no deletions, first review. Falls through to row 9.
First SDK PR for the shared persistence spec (adcontextprotocol/adcp#7996, §3.1 and Stage 1, PR 1 of 16).
It adds the canonical JSONL row encoding that every row-storage backend will build on. It has no database or provider code, and existing store behaviour is unchanged.
New exports from
@adcp/sdk/reporting/ledgerencodeReportingRowsV1(rows): splits rows into contract-fixed 500-row segments and 10,000-row / 8 MiB chunks ofJCS(row) + "\n". Returns:rowManifestSha256, the value the revision header will bind immutably.verifyReportingRowManifestsV1: checks that the manifest matches the header digest, ordinals run contiguously from 0, segments follow the contract limits, and segments exactly cover their chunk. Dropping, reordering or truncating chunks fails.verifyReportingRowChunkV1anddecodeVerifiedReportingRowSegmentsV1: whole-chunk and ranged-segment verification. Rows are returned only after every touched segment verifies, which lets paged delivery reads verify only the segments a page needs.createReportingRevisionEnvelopeHasherV1/reportingRevisionEnvelopeDigestV1/assertReportingRevisionEnvelopeV1: rebuild the protocolrevision_content_sha256(andbinding.byteCount) by streaming stored chunk bytes, without parsing rows.createReportingRowsOnlyHasherV1: therows_v1profile (sha256(JCS(rows))) used by the JS-retained adjustment rows.canonicalReportingRowV1: refuses rows whose canonical bytes are not portable across RFC 8785 implementations: non-plain objects, non-finite numbers, integers beyond ±(2^53 − 1), and lone surrogates.Tests (
test/lib/reporting-row-encoding.test.js, 11 cases)sha256(canonicalize({...}))for empty revisions, Unicode, nested values, numeric edge cases and 1,234 rows.test/fixtures/reporting-row-storage-v1.json, which the Python SDK will consume.Validation run locally: the new suite plus
reporting-ledger.test.js(43/43 pass),npm run typecheck, eslint and prettier.🤖 Generated with Claude Code
Open workspace in Conductor