Skip to content

docs: specify shared reporting persistence layout and pluggable row storage - #7996

Merged
bokelley merged 11 commits into
mainfrom
bokelley/reporting-ledger-table-names
Nov 2, 2026
Merged

bokelley merged 11 commits into
mainfrom
bokelley/reporting-ledger-table-names

Conversation

@bokelley

@bokelley bokelley commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Turns the shared-persistence proposal into a concrete spec for (1) one PostgreSQL layout for Reliable Reporting shared by the JS and Python SDKs and (2) storing revision rows outside PostgreSQL, with a derived BigQuery warehouse copy for analytics.

What it specifies

  • Shared layout. adcp_reporting_* tables, COLLATE "C" identifiers, transaction-level account locks with one shared key (and a dual-key transition for rolling upgrades), a sequence-based change feed, startup catalog fingerprints, and a decision table resolving every JS/Python Core divergence.
  • Row storage. Revision headers stay in PostgreSQL. Rows are canonical JSONL in 500-row segments and 10,000-row / 8 MiB chunks. Segment, chunk and manifest digests are committed on the header and checked on every read. Backends: postgres (default) and object storage (GCS, S3, Azure Blob, filesystem), written create-only, with a host allowlist for bindings, hashed key templates, and fenced write intents so a sweep can never delete adopted or committed bytes.
  • Warehouse sink. Committed revisions are loaded into adopter-defined BigQuery tables once per tick with idempotent load jobs, plus a current_rows view. The sink is never read for serving or verification. Recommended GCP shape: GCS row store plus BigQuery sink.
  • Retention. Aligned with the protocol: superseded snapshots stay readable for status_retention_days. Unchanged pulses may skip minting a revision. Includes a wire mapping for expired, unavailable and corrupt rows.
  • Adoption. JS row storage ships first, as a 14-PR sequence; then Python; then the full Core layout; then idempotency.

Considered and deferred: BigQuery as the ledger database or as the authoritative row store, and pointing at rows already sitting in an adopter's warehouse. Reasons are in §9.

Upstream protocol follow-ups listed in §10:

  • whether the superseded-snapshot readability text is normative, and what instant anchors the retention window;
  • no issue code means "a retained revision is unreadable";
  • REPORTING_REVISION_NOT_FOUND is used by get_media_buy_delivery but missing from the error-code enum.

Review. Protocol, JS SDK, Python SDK, data-platform and security reviews have been folded in. The canonical JSONL envelope reconstruction was checked against the JS canonicalizer: Unicode, numeric edge cases, and 20 chunk/row-set combinations all match.

Validation: links resolve, fenced blocks balance, git diff --check is clean, and the local pre-commit suite passed (unit tests, dynamic-import/identity guards, typecheck).

🤖 Generated with Claude Code

aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Oct 7, 2026

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ladon verdict: Approve

Approve — adds one non-normative proposal document with no blocking findings.

This PR adds a single file, specs/shared-sdk-persistence-proposal.md (268 additions, 0 deletions). It touches no published protocol surface — no static/schemas/source/**, no docs/reference/**, no release scripts, no dist/** — so no changeset is required and no schema↔docs coherence, oneOf discriminator, or artifact-immutability rules apply. The doc self-classifies as a non-normative proposal, cites DR-0021 accurately as status: proposed without ratifying it, links an existing security.mdx, and respects naming/character conventions.

Gate checks:

  • No no-auto-approve team match.
  • gated_paths: false, so row 2 does not apply despite review_decision: REVIEW_REQUIRED.
  • high_risk: false; no deleted/modified high-risk files.
  • No breaking-class protocol change — this is a proposal doc, not a wire/schema edit.
  • Reviewer surfaced zero Critical/High/Medium findings.

With no blocking findings, no escalation trigger, and no team gate, this falls through to row 9 of the decision table.

bokelley and others added 2 commits October 7, 2026 19:11
Rework the shared SDK persistence proposal into a concrete spec:
canonical PostgreSQL layout decisions for both SDKs, canonical JSONL
row chunks with segment and manifest digests verified against
PostgreSQL, object-storage row bindings (GCS, S3, Azure Blob,
filesystem), a derived BigQuery warehouse sink, protocol-aligned
retention, safe intent sweeps, and a staged adoption plan starting
with JS row storage.

Incorporates protocol, JS, Python, data-platform and security reviews.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@bokelley bokelley changed the title docs: propose shared SDK persistence contracts docs: specify shared reporting persistence layout and pluggable row storage Oct 7, 2026
aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Oct 7, 2026

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

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 pass on a single new design proposal.

This PR adds one 895-line file, specs/shared-sdk-persistence-proposal.md, a reference-SDK persistence layout design doc. No protocol/wire change, so changeset, schema↔docs coherence, oneOf discriminator, and dist-immutability rules do not engage. Reviewer verified load-bearing claims: DR-0021 and security.mdx links resolve, DR-0021 is cited accurately as proposed-not-ratified, and the §3.1 canonical envelope key ordering is consistent with the §2.4 binding preimage under JCS lexical sort. No real-brand misnaming or invented characters in the fictional scenarios.

No critical/high/medium findings. high_risk is false; gated_paths is false (so the REVIEW_REQUIRED status does not trigger row 2). No no-auto-approve team match. Prior decision was approve. No decision-table trigger fires → row 9 approve.

- **Configuring a shorter window.** A deployment that needs less pulse history
advertises a shorter `status_retention_days`. A row retention shorter than the
advertised window is non-conformant, and the SDK refuses it.
- **Unchanged pulses.** When a pulse's canonical rows are byte-identical to the current

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Skipping an unchanged pulse keeps observed_at and data_through at the leaf's values. A buy that has stopped delivering produces identical rows every pulse, so its freshness freezes, and a consumer can't tell "stopped delivering" from "nobody checked". Pacing and delivery-health consumers need exactly that distinction.

Suggest minting a header-only revision instead: new observed_at/data_through, pointing at the leaf's existing chunks, within the same feed only and never across consumers. The wire stays accurate and no rows are stored again.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Skipping would freeze freshness, and the protocol has no other way to advance observed_at/data_through. Done in 3f0ab49 (§4.2): an unchanged pulse now mints a normal snapshot revision with a new ID, revision_number, observed_at, data_through and revision_content_sha256. It shares the previous revision's chunks instead of storing them again.

  • "Unchanged" means row_manifest_sha256 matches. The producer still has the rows it just pulled, so it computes the new envelope digest normally and only skips the upload.
  • Sharing is limited to one obligation (one account and configuration generation), so never across consumers. The header records rows_shared_from_reporting_revision_id.
  • Postgres bodies are now content-addressed per obligation, and pruning only deletes bytes that no non-pruned chunk row still references (§3.2, §4.3).
  • I dropped the separate "observations" concept. The repeated header-only revisions are themselves the evidence stabilized finality needs.

for exact bytes, and `row JSON` for cheap field access.
- The sink also writes commit metadata: revision ID, obligation, finality, supersession
and period.
- The sink ships a reference **`current_rows` view** that keeps only each obligation's

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could the store expose a cheap "current leaf per obligation for period P" read and a stable host-facing changesAfter cursor? In-process consumers (pacing, alerts) need both, and the warehouse sink's current_rows can't be used for serving.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, added §3.7 (host reads, not buyer surfaces):

  • Current revision. The obligation row carries current_reporting_revision_id, updated in the revision's commit transaction. getCurrentRevision({account_id, reporting_obligation_id}) is one index lookup, and listCurrentRevisions({account_id, delivery_config_id?, period range, cursor}) pages through a period range. Both return headers; rows come from the verified paged reader.
  • changesAfter({cursor, account_id?, kinds?, limit}) reads the shared change table, so cursors are opaque, versioned and stable across restarts and SDKs.
    • Account-scoped feeds order by seq. They are gap-free because nextval is taken under the account lock.
    • Deployment-wide feeds order by (xid, seq) and return only rows below the reading snapshot's pg_snapshot_xmin, so a slow lower-seq commit can't be skipped. A long-running transaction delays that feed but never makes it lose a record.
  • An expired cursor gets CURSOR_EXPIRED, and the consumer resyncs from listCurrentRevisions. Named consumers (the warehouse sink among them) can register to hold back change-table pruning, up to max_feed_hold_days.

receipt, consumer status, adjustment or live materialization still names the
revision.
- **After expiry.** The period's records leave the protocol projection together, and
`ledger_retained_from` advances. Headers may persist longer for internal audit, but

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a retention bound for headers, the change table and unchanged-pulse observations, or are they kept forever by design?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not by design; it was a gap. §4.2 now gives every record a bound:

  • Row bytes: the protocol window plus holds, then pruned.
  • Period records (headers, manifests, statuses, receipts, issues, transitions, lifecycle state): ledger_record_retention_days after the period expires (default and minimum status_retention_days). They are deleted together in one period-aligned transaction under the account lock.
  • Per-obligation tombstone (about 200 bytes: final revision ID, digests, revision count): kept indefinitely, so replays can't resurrect pruned IDs and the audit conclusion survives.
  • Change table: change_retention_days (default 30, never below the protocol checkpoint TTL), extended by registered consumers up to a cap. Older cursors get CURSOR_EXPIRED.
  • Idempotency replay rows: their 30-day window. JS's current lifetime per-consumer caps become active-window caps.
  • Unchanged-pulse observations no longer exist; header-only revisions follow normal revision retention.

- Define the contract format: contract.json, JSON Schema 2020-12
  payload schemas, normative CONTRACT.md, fixtures and declarative
  conformance cases.
- Replace skipped unchanged pulses with header-only revisions that
  share the previous revision's chunks within one obligation, so
  freshness keeps advancing; content-address PostgreSQL bodies and
  reference-check deletion.
- Add host reads: current-revision pointer, listCurrentRevisions,
  and a durable changesAfter cursor (account feeds by seq,
  deployment-wide feeds by (xid, seq) under the snapshot xmin), with
  registered feed consumers.
- Bound retention for headers, change-table rows and replay rows,
  with period-aligned deletion and per-obligation tombstones.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

bokelley commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @rachitm022. On the shape of persistence/contracts/: yes, JSON Schema. New §1.1 spells it out. Each component has:

  • contract.json, validated by a meta-schema. It declares constants, owned tables, the lock-key registry with acquisition order, state machines with allowed transitions, error codes, and retention parameters with defaults and minimums.
  • schemas/*.schema.json (draft 2020-12, closed by default) for every JSONB payload and value that crosses a store port. SDK types are generated from these, and CI fails on drift.
  • CONTRACT.md for normative operation semantics.

Fixtures are validated against the schemas. Conformance cases are declarative YAML (setup, operation, expected state or error) run by a thin harness in each SDK, with concurrency and crash cases named in the contract and implemented per SDK. It's the protocol's existing toolchain, so no new IDL.

aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Oct 8, 2026

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

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 pass.

This PR adds a single new proposal document, specs/shared-sdk-persistence-proposal.md (+1034, 0 deletions). It is reference-SDK persistence design carrying no new protocol requirements. It touches no static/schemas/source/**, docs/reference/**, dist/**, or changeset surface, and is based on main (not 3.1.x), so the schema-drift, changeset, oneOf-discriminator, immutability, and 3.1.x-patch gates do not fire.

Reviewer verified: all references resolve (DR-0021, L1 security docs); protocol claims in the open questions are accurate (REPORTING_REVISION_NOT_FOUND / REFERENCE_NOT_FOUND status matches the enums; superseded-snapshot readability matches reporting-revision.json); and the JCS envelope key order at L372 is correct by codepoint, so the cross-SDK byte-identical digest claim holds.

No Critical/High/Medium findings. high_risk is false, gated_paths is false, no no-auto-approve team match, and this is a new file only. Prior decision was also approve. Decision table rows 1–8 do not fire → row 9 approve.

bokelley added a commit to adcontextprotocol/adcp-client that referenced this pull request Oct 8, 2026
#3145)

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]>
bokelley added a commit to adcontextprotocol/adcp-client that referenced this pull request Oct 8, 2026
Add optional listRevisionMetadata/listAdjustmentMetadata to
ReportingLedgerStore, implemented in PostgreSQL with `data - 'rows'`.
The producer, lifecycle reconciler and status ingest prefer them and
fall back to the full listings with rows dropped, so custom stores keep
working. Managed Delivery planning selects revision ids instead of whole
revision documents. Stage 1 PR 2 of the shared persistence spec
(adcontextprotocol/adcp#7996).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
rachitm022
rachitm022 previously approved these changes Oct 8, 2026
bokelley added a commit to adcontextprotocol/adcp-client that referenced this pull request Oct 8, 2026
Add optional getRevisionMetadata/readRevisionRows to
ReportingLedgerStore; PostgreSQL slices rows with jsonb_path_query_array.
The delivery handler reads only the requested page and the status
revision view inlines rows only up to 10,000 rows. Stage 1 PR 3 of the
shared persistence spec (adcontextprotocol/adcp#7996).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
bokelley added a commit to adcontextprotocol/adcp-client that referenced this pull request Oct 8, 2026
Add REPORTING_ROW_STORAGE_MIGRATION (installation identity, row
bindings, row sets, chunk manifests, content-addressed PostgreSQL
bodies, write intents) with immutability triggers and a schema probe.
Stage 1 PR 4 of the shared persistence spec (adcontextprotocol/adcp#7996).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
bokelley added a commit to adcontextprotocol/adcp-client that referenced this pull request Oct 8, 2026
Opt-in `rowStorage` on PostgresReportingLedgerStore (and the production
service) writes revision and adjustment rows as canonical JSONL chunks
with committed segment/chunk/manifest digests instead of inline ledger
JSON. Reads verify before release, delivery pages read only the needed
segments, bodies are content-addressed per obligation, legacy inline
revisions keep working, and Managed Delivery claims hydrate chunked rows.
Every PostgreSQL reporting suite now also runs with REPORTING_ROW_STORAGE=chunked.
Stage 1 PR 5 (and 6) of the shared persistence spec (adcontextprotocol/adcp#7996).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>

@KonstantinMirin KonstantinMirin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry for the delay on this review.

Summary

I recommend not merging this document in its current form, and not building Stage 3 on it.

The document specifies a custom storage engine: a row format with three digest levels, a fencing protocol with write intents and sweeps, a change feed, and a warehouse loader. Established standards and maintained libraries already solve each of these. Every custom primitive is code that both SDKs must build, keep identical, and secure, in two languages. The code shipped for Stages 1 and 2 already shows that cost. The two SDKs take different account locks, and the cross-SDK acceptance test has never run in CI. The stored values also drift from the AdCP fields they correspond to.

AdCP needs far less than this. The protocol already defines what a seller owes: immutable revisions, exact reads by revision ID with paging, the RFC 8785 digest, retention, and the error codes. The compliance vector in reporting-reconciliation/ already pins the digest, typed control totals included. Everything else is storage, which existing tools already handle.

What I suggest instead

Make the following changes before Stage 3:

  • Replace each custom component with the standard or library that already provides it. The table in the next section maps each one.
  • Reduce the shared SDK surface to three things: the digest computation and verification, exact-read paging, and a narrow storage interface. The interface writes the rows of a revision, reads rows by revision ID and page, and retires a period. Ship one reference implementation, a PostgreSQL table with UPDATE and DELETE revoked. Adopters plug their own storage, usually their warehouse, behind the interface.
  • Store every value in the format AdCP already defines for it. The format section lists the mismatches.
  • Don't publish an adcontextprotocol.org/schemas/persistence/ namespace. A storage contract between two SDKs isn't protocol, and the values that do have AdCP schemas are referenced, not re-declared.
  • Keep this document as a short design record for the storage interface and the digest code the SDKs share, not as a storage-engine specification.

Replace the custom components

Each component in the document has an existing counterpart:

Component in #7996 Existing standard or library What it removes
§3.1 canonical JSONL in 500-row segments and 10,000-row / 8 MiB chunks, with segment, chunk, and manifest digests A PostgreSQL table with UPDATE and DELETE revoked. At scale, an open table format with immutable snapshots: Apache Iceberg (pyiceberg) or Delta Lake (deltalake). The protocol digest is computed from JCS rows at write time and stored in the revision header, as it is today. The custom row format, its three digest levels, and its byte-pinned cross-SDK fixtures
§3.4 three object-store providers plus filesystem obstore (Python bindings for the Rust object_store crate): create-only put(..., mode="create") and version-pinned reads across S3, GCS, Azure, local, and memory Three provider modules with one skeleton
§3.2 and §4.3 write intents, owner tokens, lease expiry, sweeps, and the listing backstop Native create-only writes, which the document already relies on, plus a lifecycle rule for abandoned uploads. Where retention must be enforced: S3 Object Lock, a locked GCS retention policy, or Azure immutable blob storage. The fencing protocol and the class of bug where a sweep deletes live rows
§2.1 object lifetime lock and the re-verification inside the commit Unique object keys. The JS SDK already refuses templates without {revision_key} when compaction is on (row-storage.ts:273-289); require it always. The lock, the re-download inside the commit transaction, and the scoped delete
§2.1 and §3.7 change table with seq, xid8, registered consumers, and CURSOR_EXPIRED The transactional outbox pattern, or PostgreSQL logical replication A custom change feed shared between SDKs
§3.6 BigQuery load-job sink and current_rows view BigQuery reads Iceberg and Delta Lake tables in Cloud Storage as external tables A custom loader

Buyers may need proof of authorship or of history beyond the digest. Standards cover that too: a JWS or COSE signature over the same JCS digest, and a transparency-log profile by reference (C2SP tlog, or SCITT with COSE Receipts). That belongs in a protocol profile, not in SDK storage.

Why change direction now

Stages 1 and 2 have shipped, and Stage 3 puts the shared Core layout, the migration runners, the dual-key locks, and the idempotency store on top of this layer. Every stage added makes the custom layer harder to replace. The shipped code shows the problems a hand-built layer brings:

  • The SDKs disagree on the account lock. §2.1 defines one lock. JS locks hashtextextended('adcp-reporting-account:' || account_id, 0) (postgres.ts:5196). Python locks hashtext('adcp.reporting:' || account_id) (pg.py:721-725). §5 still says the layout "is qualified for concurrent mixed-SDK writers".
  • The cross-SDK acceptance gate has never run. §7's gate is "JS-written chunks verify in Python and vice versa, against one database and one bucket". test_one_database_and_one_bucket_in_both_directions skips unless ADCP_JS_SDK_DIR is set, and no workflow sets it.
  • The Python half needs sixteen follow-up fixes. They include an error code chosen by substring match on a message, and a FOR SHARE lock that one of two paths doesn't hold. Another is a 17 MiB re-download inside the commit transaction, under the account lock. Most of them disappear with the custom layer.
  • The stored formats drift from AdCP, as the next section shows.

Store values in their AdCP format

Every stored value that has an AdCP counterpart must use that counterpart's name, type, pattern, and bound, defined once in the protocol schema and referenced. The document and the shipped tables differ from AdCP in these places:

Value AdCP definition #7996 and the SDK tables
Object key object_ref: decoded, destination-relative, 1 to 1024 characters (reporting-file-object-ref.json) object_key TEXT, no bound
Native version native_version_ref: decoded, 1 to 1024 characters (reporting-native-version-ref.json) native_version TEXT, no bound
Object size and list size_bytes, and files[]: {object_ref, native_version_ref, size_bytes, sha256, row_count} (reporting-file-manifest.json) byte_count, physical_byte_count, canonical_byte_count, and a separate chunk manifest shape
Period date YYYY-MM-DD in the period's source_timezone {period_date:yyyy/MM/dd}, rendered in UTC by both SDKs (row_storage_object.py:226, row-storage-object.ts:179)
Platform and destination ReportingCloud (aws, gcp, azure) and {provider, location, access_mode} (reporting-write-destination.json) gcs, s3, azure_blob, filesystem, and per-provider identity_config schemas
Page size max_results from 1 to 100 (pagination-request.json) Segments sized for "a 500-row delivery page" (§3.1)
Format token format: jsonl, with algorithm: adcp_jcs_rows_v1 encoding = 'adcp_canonical_jsonl_v1'

The reporting_revision_id pattern, the hex digests, the control-total shape, the currency check, RFC 3339 timestamps, and the wire error codes already match. Keep them exactly as they are.

What carries over

The work has parts worth keeping in any design:

  • The protocol goal: immutable revisions that a buyer can read exactly and verify.
  • RFC 8785 as the single encoding primitive, and the digest code in row-encoding.ts and row_encoding.py, which the golden fixtures pin to each other.
  • The correct use of native create-only writes on all three providers.
  • The typed-control-totals fix, which the compliance vector confirms.
  • Exact-read paging, the wire mapping in §3.5, and the protocol error codes in §10.
  • The one-database interop test from #1470, retargeted at the storage interface.

I can open the Stage 2 follow-ups as separate issues, with file and line evidence, and I'm happy to help define the storage interface and the replacement plan.

Copy link
Copy Markdown
Contributor Author

Thanks, @KonstantinMirin. This is the review the document needed, and most of it lands. Here's where we're taking it.

What we're changing

  • Stage 3 is dropped. No shared Core layout, no dual-key locks, no shared idempotency store, and no adcontextprotocol.org/schemas/persistence/ namespace. The document becomes a short design record around a narrow storage interface: write a revision's rows, read rows by revision ID and page, retire a period. It also covers the digest code both SDKs share.

  • One writer per database, stated outright. §5 will say a ledger database has exactly one SDK writing it, not just drop the mixed-writer claim. You're right that the account locks differ (postgres.ts:5196 vs pg.py:721-725). Under one writer per database that difference is harmless, but adopters need to see the constraint.

  • The interop gate will actually run. A gate that skips without ADCP_JS_SDK_DIR isn't a gate. Python CI will build JS main and run test_one_database_and_one_bucket_in_both_directions, failing rather than skipping when the JS side is missing.

  • Stored values move to their AdCP formats, as one breaking migration, now.

    • object_key → object_ref and native_version → native_version_ref, with AdCP's 1–1024 bounds.
    • byte_count → size_bytes.
    • The encoding token aligns with format: jsonl / algorithm: adcp_jcs_rows_v1.

    The only adopter has the tables installed but switched off and plans a clean re-sync, so this is the cheapest moment to rename. After the first activation, every rename becomes a data migration every seller has to run. We'll ship it before that activation. The protocol revision_content_sha256 doesn't change.

  • period_date is a real bug, and it blocks the next release. Both SDKs render it in UTC. AdCP defines it as the calendar date in the period's source_timezone. An adopter partitions dashboards on it, so a non-UTC account would land rows on the wrong day. The fix covers object keys and the BigQuery sink's period_date column.

  • The re-download inside the commit transaction. JS has the same pattern: assertObjectsPresent re-reads adopted objects under the lock. Native versions are write-unique, so a version-pinned metadata check (exists at the recorded version, with the recorded size) proves the object is unchanged without downloading it. Both SDKs will switch.

  • Please file the sixteen Python follow-ups. File and line evidence is exactly what we want, and we'll work through them.

What stays supported as the JS implementation

Narrowing the cross-language contract is right. That doesn't demote the JS implementation to example code. The adopter's managed delivery, notifications and dashboard copy are built on these pieces, so they stay supported SDK code behind the storage interface:

  • the PostgreSQL ledger store;
  • GCS row storage;
  • the change feed;
  • the BigQuery warehouse sink.

Demoting them would push every adopter into owning a fork. That's the outcome a reference SDK exists to prevent.

Where we see it differently

  • The change feed is the transactional outbox pattern. It's a change row written in the same transaction as each record, read by registered consumers. We agree on the pattern; what's in the SDK is that pattern implemented once, with retention-aware consumer horizons. Logical replication would add replication slots and decoding plugins for every adopter to operate.
  • Write intents and sweeps can't be replaced by a lifecycle rule. A lifecycle rule can't tell an abandoned upload from a committed object under the same prefix, and object stores have no rename to separate staging from committed. Deleting by age would remove live rows. The GCS probe already refuses lifecycle Delete rules that can match live objects, for that reason. The only alternative is tolerating orphaned objects as a cost leak, and the sweep is what prevents it. With unique object keys required everywhere, though, the cross-row-set object lock can go. We'll take that simplification.
  • obstore is a good fit for Python, but it's Python-only, so it doesn't remove the JS providers. Python can adopt it behind the interface if its maintainers prefer.
  • Iceberg or Delta Lake suit adopters who want table-format storage, and they can plug in behind the interface. As the default, they'd be heavy dependencies for sellers who just want rows in Postgres or a bucket.

What carries over

Agreed on your list: immutable, exactly readable revisions; RFC 8785 as the single encoding primitive, with the shared digest code and its golden fixtures; native create-only writes; typed control totals; exact-read paging and the §3.5 wire mapping; the protocol error codes; and the one-database interop test, retargeted at the interface.

We'll revise the document along these lines. We'd welcome your help defining the storage interface.

🤖 Generated with Claude Code

…esign record

Rewrite specs/shared-sdk-persistence-proposal.md after the review on this
PR. The document now leads with the narrow storage interface (write a
revision's rows, read rows by revision ID and page, retire a period) and
the shared RFC 8785 digest code with its golden fixtures.

Dropped: Stage 3, the shared Core layout, dual-key locks, the shared
idempotency store, the persistence/ contract namespace and catalog-manifest
runners, and the adcontextprotocol.org/schemas/persistence/ namespace.

Added: one writer SDK per ledger database as an explicit constraint, with
the reproduced seq skip as the reason; the supported JS implementation
behind the interface; the change feed as the transactional outbox; stored
values under their AdCP names; and an adoption table that records what
shipped in adcp-client and adcp-client-python.

Co-Authored-By: Claude Sonnet <[email protected]>

Copy link
Copy Markdown
Contributor Author

Pushed b21051a: the proposal is rewritten to match the direction in our reply, @KonstantinMirin and @rachitm022. It goes from 1110 lines to 381.

Now a short design record. It leads with the narrow storage interface (write a revision's rows, read rows by revision ID and page, retire a period) and the shared RFC 8785 digest code with its golden fixtures.

Dropped, with the reason in the document and a link to the review: Stage 3, the shared Core layout, dual-key locks, the shared idempotency store, the persistence/ contract namespace, catalog-manifest runners, and the adcontextprotocol.org/schemas/persistence/ namespace. The Core decisions table, header DDL and cross-SDK qualification matrix went with them.

Added or changed:

Two things I would like checked. §8 extends the one-writer constraint to any idempotency store both SDKs would write, which is my inference. §6 keeps a paragraph on Python's protected periods because it is still true without Stage 3.

🤖 Generated with Claude Code

aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Oct 14, 2026

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

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 design-record addition, no blocking or medium findings.

This PR adds one new file, specs/shared-sdk-persistence-proposal.md (381 lines), an explicitly non-protocol reference-SDK persistence design record ("no new protocol requirements"). It touches no static/schemas/source/**, no docs/reference/**, and no dist/** artifacts, so no changeset is required and none is missing.

Checks performed by the reviewer: all five cited AdCP schema names in §2 resolve; §1.2's control_totals shape matches reporting-control-total.json exactly (no spec drift); cited DR-0021 and the L1 security doc exist with resolving links; naming is clean (AdCP, fictional examples only). Substantially revised since the prior approve in response to KonstantinMirin's review.

Decision-table walk: no critical/high findings (row 1 n/a); gated_paths is false (row 2 n/a); not high-risk and no deletions (rows 3/5 n/a); no medium data-loss/schema/infra findings (row 4 n/a); prior decision was approve, not escalate (row 6 n/a); no no-auto-approve team match (row 7 n/a); fewer than three medium findings — zero in fact (row 8 n/a). Falls through to row 9: approve.

Note: review_decision is CHANGES_REQUESTED, but that only forces escalate under row 2 when gated_paths is true; here it is false, so the gate does not apply. No breaking-class protocol change is present (design record only), so the breaking-change hard gate does not apply either.

@KonstantinMirin

Copy link
Copy Markdown
Collaborator

b21051a settles the parts of my review that concerned what the document commits both SDKs to. Stage 3 and the shared layout are gone, §5 states one writer SDK per ledger database and cites Rachit's reproduction, §2 uses the AdCP names and the period_date rule, and both SDKs' DDL on main matches it (row-storage-migration.ts:48-52, 78-79; reporting_row_storage.sql:23-26; row_storage_object.py:286-335). The interop test runs in CI (#1481). Your two questions first.

§8: one writer and the idempotency store

No shared idempotency store exists, and Stage 4 keeps it that way. The sentence is still true, for a reason the lock argument does not give: both SDKs create a table named adcp_idempotency by default, with incompatible layouts. JS has scoped_key TEXT PRIMARY KEY (backends/pg.ts:92-99); Python has PRIMARY KEY (scope_key, key) (backends.py:369-376). Both use CREATE TABLE IF NOT EXISTS, so the second SDK on a database runs against the first SDK's shape without an error. Python's docstring warns about exactly this (backends.py:343-351). Replace "The same constraint applies to any store both SDKs would write" with that fact: two SDKs cannot share a database at all, and the ledger is one instance of it.

§6: Python's protected periods

The paragraph needs a correction. On Python main (3961d1c, period_retirement.py):

  • A reconciliation record holds its period. retire_expired_periods excludes it from the candidate query (lines 115-120), so the period is never tombstoned and retirement frees none of its bytes.
  • RECORDS_PROTECTED comes from provisional observations and notification events. The period passes phases 1 and 2, its bytes are deleted, then phase 3 raises and the tombstone stays retiring with that cause and a backoff (lines 425-432).
  • protected is a field of the pass result (line 61), not a stored state.

So "such as reconciliation records" names the wrong kind, and "marked protected and is not retired" describes neither path. The generic rule belongs in §6, in one sentence: an SDK's own append-only records can stop phase 3, and the period then stays retiring with a cause after its bytes are freed. The Python specifics belong in the Python module docstring, where they already are, and in the 9.0.0 release notes.

What remains from my review

The four concessions are reflected in §1.1, §4.1, §4.2 and §9. Of the five recommendations, one is partly addressed and four are as they were. The smallest change that settles each:

  1. Separate packages. §3 answers a different question. The choice is supported code in @adcp/sdk against supported code in a separately published package from the same maintainers, which is how Auth.js, LangGraph and OpenTelemetry ship storage; "supported, not example code" and "demoting them to examples would push every adopter into owning a fork" leaves that choice unrecorded. Record it in §9 as an alternative considered, with the reason. I'll open the Python side as an issue before 9.0.0 GA; chore: remove unused vite and plugin-react deps #1490 already asks which ledger names are public there.

  2. Chunks or plain rows. §1.2 keeps the 500-row segment and §7 maps delivery pages to segments, while pagination-request.json caps max_results at 100 and the only 500 in either SDK's production code is REPORTING_ROW_SEGMENT_MAX_ROWS (row-encoding.ts:47, row_encoding.py:74). The rewrite dropped the volume motivation without replacing it, so the record now gives no reason for a chunk format over a partitioned append-only table. Both SDKs page BYTEA with substring(body FROM … FOR …) (row-storage.ts:963, row_storage.py:1419) and neither sets STORAGE EXTERNAL, so my question stands: has a paged read been measured? One §9 entry, "plain partitioned rows, rejected because …", with the measurement if one exists, settles it. The shipped format stays.

  3. (xid, seq) for the account feed. Partly addressed. The truncation guard (Brand-claim panel: surface from not-linked state for cross-org claims #3228, Docs intro: early audience fork (buy vs build) #1483) is what §5 calls it: defense in depth that "cannot close it for every interleaving". Ordering the account feed by (xid, seq) behind xid < pg_snapshot_xmin(...), as the deployment-wide feed already does in both SDKs (postgres.ts:1620; change_feed.py:157-162), removes the feed's dependence on the lock; Rachit proposed the same guard in feat: add shows and episodes as a content dimension for products #1457. The two Python differences I named are unchanged: the checkpoint upsert is unconditional (change_feed.py:264-271) and nothing re-reads the horizon after the page (:197, :217), where JS does (postgres.ts:1629-1631). I file both this week. Follow-up.

  4. Listing collector. §4.2 keeps the intent and sweep rationale, and the old §4.3 listing backstop is gone, so the record now names no mechanism for the three cases the sweep cannot see: an object whose PUT succeeds before the intent records it (row-storage.ts:499-516; row_storage.py:796, then row_write.py:209), intents for a binding no running host configures, and intents lost to a database restore. Follow-up, one issue per SDK, linked from §4.2.

  5. BigQuery sink. §3.2 is unchanged and the per-revision metadata object is not mentioned. Follow-up.

Two small things while you are in the file: §4.2's "Removing the lock is a follow-up" is #1492 on the Python side, and the header-only sharing reason is new there; §2's "pattern and bound" claim does not yet hold for row_binding_id, which both DDLs cap at 128 (#1498).

What clears my review

One more push: the §6 correction, the §8 sentence grounded in the table collision, a §9 entry for plain partitioned rows with the reason, and links from the document to tracked issues for items 1, 3, 4 and 5. With those I approve. The packaging and row-format positions stay mine, and I argue them in the issues, not in the review.

Section 6: replace the Python-specific protected paragraph with the generic
rule that an SDK's own append-only records can stop phase 3 and leave the
period retiring with a cause after its bytes are freed.

Section 8: ground the one-database fact in the adcp_idempotency table that
both SDKs create by default with incompatible layouts.

Section 9: record plain partitioned rows (rejected, with a local
measurement of exact paged reads and of STORAGE EXTERNAL) and a separately
published storage package (alternative considered).

Section 1.2 and 7: describe the 500-row segment as the verification and
range unit, with pages of at most 100 rows served from within segments.

Section 2: qualify the pattern-and-bound claim for row_binding_id.
Sections 3.2, 4.2 and 5: link the tracking issues for the BigQuery
revision metadata load, the listing collector, removing the object lock and
the (xid, seq) account feed.

Co-Authored-By: Claude Sonnet <[email protected]>

Copy link
Copy Markdown
Contributor Author

Thanks. d18aab7 makes the changes you asked for. I checked each claim against Python main and JavaScript main (dfc9c4be) first. Where it landed:

Item Where Tracking
§6 correction §6 now has the generic sentence: an SDK's own append-only records can stop phase 3, and the period stays retiring with a cause after its bytes are freed. Your reading of period_retirement.py holds (hold at 115-120, RECORDS_PROTECTED at 425-432, protected a result field at 61). Python specifics are out of the spec.
§8 sentence Replaced with the adcp_idempotency fact: scoped_key TEXT PRIMARY KEY (pg.ts:92-99) against PRIMARY KEY (scope_key, key) (backends.py), both CREATE TABLE IF NOT EXISTS, so the ledger is one instance. I cite backends.py:507-516, the executed DDL. Your 369-376 is its docstring copy.
§9 plain partitioned rows New entry, with the measurement below
§1.2, §7 The 500-row segment is the verification and range unit. The protocol caps a page at 100, so pages are served from within segments. adcp-client#3213 (the JS handlers still accept 500)
1. Separate packages §9 alternative considered, with the reason for staying in @adcp/sdk (one install, optional cloud-SDK peers, experimental policy) and a revisit at 16.0 GA adcp-client#3286, adcp-client-python#1510
3. (xid, seq) account feed §5 adcp-client#3283
4. Listing collector §4.2 adcp-client#3284
5. BigQuery sink §3.2 now states the two-table load (rows, then per-revision metadata) and that current_rows reads through it adcp-client#3285
§4.2 lock Links both, keeps the header-only chunk-sharing reason adcp-client#3281, adcp-client-python#1492
§2 row_binding_id bound Qualified: adopter-chosen, no AdCP field, 128 against AdCP's 255 adcp-client#3282, adcp-client-python#1498

Measurement (§9). JavaScript SDK dfc9c4be, local PostgreSQL 16.14, 8 vCPU, shared_buffers 128 MB, one sequential client. One revision of 100,000 rows (about 320 bytes each, ten chunks) in postgres-kind storage, readRevisionRows with limit 100. The baseline is a (revision_id, ordinal) primary-key table paged by ordinal, with no verification. Median / p95 in ms:

Chunked Chunked, STORAGE EXTERNAL Plain rows
Warm, first / middle / last 9.2 / 10.2 / 12.8 (p95 10.4 / 14.9 / 16.1) 8.8 / 8.3 / 8.9 0.57 / 0.55 / 0.57
Cold, first / middle / last 15.0 / 18.3 / 22.7 (p95 19.5 / 20.3 / 31.8) 14.7 / 15.2 / 15.2 2.6 / 2.5 / 2.6

The chunk format is 15 to 20 times a plain read when warm and 6 to 9 times when cold, so it is not justified on PostgreSQL speed. §9 says that, and keeps the format for object-store verification and one shared shape. A plain table can also reproduce the revision digest by a full ordered scan (0.26 s against 1.65 s for the verified chunked read), so the entry does not claim that as a reason. On STORAGE EXTERNAL: default TOAST compresses the bodies 4.6 times, and a slice decompresses everything before its offset. EXTERNAL takes the last-page read from 12.8 to 8.9 ms warm and 22.7 to 15.2 ms cold, and leaves first-page reads unchanged. It costs 4.6 times the storage. It matters modestly for late pages, and I did not measure chunks near the 8 MiB bound. §9 records it as a column choice for adopters, not a new default. It is a local single-node measurement. The throwaway script is not committed.

Where your description did not match what I found:

The packaging and row-format positions are argued in the issues, as you proposed (#3286 and #1510 for packaging). I have not resolved your review.

🤖 Generated with Claude Code

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

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 pass on a documentation-only addition.

This PR adds one new 482-line design record, specs/shared-sdk-persistence-proposal.md, covering reference-SDK persistence only. It does not touch the published protocol surface (static/schemas/source/**, docs/reference/**, task definitions, release scripts, or dist/**), so changeset, oneOf, dist-immutability, and breaking-class concerns do not apply.

The reviewer verified the doc's load-bearing protocol claims against the actual schemas: L87 revision_content_sha256 matches reporting-revision.json digest_requirement; L90 control_totals shape matches reporting-control-total.json; L130 adcp_jcs_rows_v1 matches reporting-canonicalization-contract.json; all referenced schema files exist; storage JSONL form kept distinct from the protocol array-digest form. L409 correctly notes DR-0021 is still proposed and not ratified here — proper governance hygiene.

No critical/high/medium findings. Not gated (gated_paths: false), high_risk false, no author-team gate. Despite review_decision: CHANGES_REQUESTED, row 2 only fires when gated_paths is true — it is false here, so no escalation trigger applies. Falls through to row 9: approve. Consistent with the prior clean approve.

Copy link
Copy Markdown
Contributor Author

@KonstantinMirin, could you take another look? d18aab7 makes each of the changes you listed as clearing your review:

Since then, the storage split you proposed has shipped on both sides: @adcp/reporting-storage (0.1.0, alongside @adcp/sdk 16) and adcp-client-python#1557.

🤖 Generated with Claude Code

@bokelley
bokelley dismissed KonstantinMirin’s stale review November 2, 2026 10:51

Dismissed by the PR owner after the conditions in KonstantinMirin's 2026-10-15 comment were met in d18aab7: the §6 correction, §8 grounded in the adcp_idempotency collision, the §9 plain-partitioned-rows entry with a measurement, and tracking issues adcp-client#3281-#3286 linked from the document. The packaging proposal he raised has since shipped on both SDKs (@adcp/reporting-storage; adcp-client-python#1557). No reply after a follow-up on 2026-10-24.

@bokelley
bokelley merged commit 3501b49 into main Nov 2, 2026
31 checks passed
@bokelley
bokelley deleted the bokelley/reporting-ledger-table-names branch November 2, 2026 10:51
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.

3 participants