Skip to content

feat(reporting): canonical JSONL row encoding for revision row storage - #3145

Merged
bokelley merged 1 commit into
mainfrom
bokelley/postgres-vs-bigquery-reporting
Oct 8, 2026
Merged

bokelley merged 1 commit into
mainfrom
bokelley/postgres-vs-bigquery-reporting

Conversation

@bokelley

@bokelley bokelley commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

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/ledger

  • encodeReportingRowsV1(rows): splits rows into contract-fixed 500-row segments and 10,000-row / 8 MiB chunks of JCS(row) + "\n". Returns:
    • segment and chunk SHA-256 digests;
    • per-segment byte offsets;
    • 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.
  • verifyReportingRowChunkV1 and decodeVerifiedReportingRowSegmentsV1: 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 protocol revision_content_sha256 (and binding.byteCount) by streaming stored chunk bytes, without parsing rows.
  • createReportingRowsOnlyHasherV1: the rows_v1 profile (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)

  • The streamed digest equals sha256(canonicalize({...})) for empty revisions, Unicode, nested values, numeric edge cases and 1,234 rows.
  • Segment and chunk boundaries at 500 / 10,000 rows and at 8 MiB; an oversized row forms its own chunk.
  • Refusals of non-portable rows.
  • Manifest, chunk and segment tampering are detected.
  • Row-count drift and partial rows fail closed.
  • Golden vectors in 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

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]>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bokelley
bokelley merged commit c4c2a5f into main Oct 8, 2026
44 checks passed
@bokelley
bokelley deleted the bokelley/postgres-vs-bigquery-reporting branch October 8, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant