You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
id: hosted export production — enumerate a per-user DO's objects and R2 blobs into build_export (slice 4b of #2852, from #3810) #13157
Slice 4b (production half) of #2852, remainder of #3810. The §6 core — export format + import verification — landed in PR #9396 as slice 4a (pkgs/id/src/hosted_export.rs: build_export / verify_import, 9 tests green at main 3a941eff430e, verified 2026-11-23). What 4a deliberately left, in its own module doc: "The enumeration of a live per-user store (the slice-3 DO scaffold) and R2 blob fetching: build_export takes the object/blob sets as inputs, so the DO/R2 wiring is a follow-on that feeds it."
Scope
Produce a real §6 export from a live hosted per-user store:
Enumerate the per-user Durable Object's signed graph objects (slice-3 scaffold: pkgs/id/hosted-worker/src/user-do.ts, event.ts) in canonical (hash) order.
Feed both sets to build_export with the binding record and its rebind records.
Settle and document the object-model mapping this wiring forces: DO envelope bytes ↔ §6 ExportObject.bytes, and how the envelope's signer/signature relate to the §6 rule (signer is a binding-chain key; signature over the SHA-256 hash bytes of the object). If the DO's stored form cannot satisfy the §6 rule as-is, the mapping (or a format note in the spec doc) is part of this slice — do not silently re-sign with a key the producer should not hold.
Acceptance
An export produced from a seeded per-user DO passes verify_import unchanged; manifest counts and the concatenated-hash digest match the DO's contents exactly.
Export remains producible from a read-only, at-cap store.
A blob the DO references but R2 cannot produce fails the export loudly (named hash), never as a silently incomplete export.
Tests cover the enumeration mapping, including an object citing multiple blobs and a store with a rebind history.
Lane QN pickup (archer): taking slice 4b of #2852 — the DO/R2 enumeration wiring that feeds build_export. Premise verified: issue open, no live claim (only the Kaneo bot link), slice 4a (pkgs/id/src/hosted_export.rs) is on main. Working in a laptop worktree off main; one PR per the feature-slice rule.
Lane QN — design + object-model mapping for slice 4b (settling scope item 4 before code).
Premise reverified at main ebd4bde81ca: slice 4a (src/hosted_export.rs) takes object/blob sets as inputs; the DO scaffold (hosted-worker/src/user-do.ts, bridge-store.ts, event.ts) stores signed events in bridge_events (applied chains) and blob references in a blobs table (SHA-256 → R2, slice A). The existing GET /v1/export is a KV/metadata dump, not the §6 export.
The mapping the wiring forces (to be recorded in the spec doc as §6.3 and in both modules' docs):
ExportObject.bytes := the stored envelope bytes verbatim — the bridge never re-encodes or re-signs a stored event, so the export doesn't either.
ExportObject.hash := SHA-256 of the envelope bytes — the export-layer digest (canonical order + manifest objects_digest). The envelope's own BLAKE3 id remains its identity at the object layer; the two hashes coexist, neither replaces the other.
ExportObject.signer := the envelope's author key; ExportObject.signature := the envelope's own signature. The stored form cannot satisfy 4a's signature-over-the-SHA-256-hash-bytes rule — the envelope signature covers the canonical header encoding (chain.rs decode's scheme) — and the producer must not re-sign with a key it should not hold. So §6's object-signature rule is settled as: the signature verifies in the object's own scheme — verify_import step 3 decodes the envelope exactly as chain.rs does (which verifies the signature), and checks the decoded author equals signer, the decoded signature equals signature, and signer is a binding-chain key (4a's chain rule, unchanged). 4a's synthetic ExportObject::new (sign-over-hash) is removed; its tests are reworked onto real envelopes via chain::sign.
Blob citations: a document.put envelope cites content by BLAKE3 (DocumentRef.content, native blob identity), while hosted R2 blobs are SHA-256-addressed (slice A table). The producer resolves citations by content: it fetches each referenced blob's bytes from R2, checks SHA-256(bytes) equals the table hash, computes BLAKE3(bytes), and records the blob in the export under its SHA-256 hash with the citing object's blob_refs naming that SHA-256 hash (§6 form). A cited content no referenced blob satisfies, or a referenced blob R2 cannot produce, fails the export loudly, naming the hash (acceptance 3). Blobs no applied object cites are not exported (§6.1 item 2: blobs referenced by those objects; §6.2 refuses unreferenced blobs).
Object set: the store's applied events (bridge_events) — the graph. Waiting-pool events (dependencies unmet, not yet graph objects) and fork-proof headers (evidence, not objects) are excluded. "An object citing multiple blobs" (acceptance 4) is covered as: multiple objects citing multiple blobs, two objects citing the same blob (carried once), since one envelope cites at most one document content in the current ChainExt form.
BridgeStore.appliedEvents() enumeration (author/seq order; the producer applies canonical hash order).
SignedEvent gains its envelope signature (already parsed, not yet exposed).
New DO route GET /v1/bridge/export, authenticated like the other bridge HTTPS legs (new "export" proof context), returning the sets in the exact serde wire shape of HostedExport's object/blob fields. It is a pure read — available from a read-only, at-cap store (acceptance 2).
Rust: ExportObject::from_envelope(bytes, blob_refs) (decodes + maps, never re-signs), ExportObject::cited_content_hashes() (BLAKE3 citations from the decoded extension), verify_import step 3 per mapping (3).
Cross-language contract: the TS suite seeds a DO from a fixed seed key and pins the produced sets to a committed fixture (hosted-worker/test/fixtures/hosted-export-sets.json); the Rust suite loads the same fixture, feeds it through build_export with a binding whose root key is that seed key, and asserts verify_import passes with matching counts/digest (acceptance 1). A separate Rust test covers a rebind-history binding with objects authored by the old and current keys (acceptance 4's rebind leg).
One PR, then merge on green; #13157 closes on its acceptance evidence.
Lane QN — PR open:#13212 (head b7cdcf8e1c8fba25cf280f7695c8283aa8e4cc9d).
Landed in the PR: hosted-worker/src/export.ts production module + GET /v1/bridge/export route (proof-authenticated, pure read, at-cap safe); BridgeStore.appliedEvents(); the §6.3 object-model mapping in the spec doc and both modules; ExportObject::from_envelope / cited_content_hashes; verify_import step 3 verifying envelopes as chain.rs decodes them; the cross-language fixture contract (hosted-worker/test/fixtures/hosted-export-sets.json).
One root-cause fix rides along, found by this slice's rebind-history acceptance case: verify_key_signature could never verify a post-rebind record (transcript key ≠ current key after any rebind) — now the transcript key must be the current or a history key, with the current shape still covered by the service attestation.
Verification (laptop; dispatch container can't run this suite — no Node, #13159 nix gaps): cargo test -p id --lib 531/0; hosted-worker npm test 121/0 (5 new export tests); fmt clean on touched files; no clippy findings in touched files (workspace clippy stops on pre-existing id-store admission.rs test-code errors, untouched).
Activity
developing-today commentedon Nov 23, 2026
CODE-4798
dezren39 commentedon Nov 23, 2026
Lane QN pickup (archer): taking slice 4b of #2852 — the DO/R2 enumeration wiring that feeds
build_export. Premise verified: issue open, no live claim (only the Kaneo bot link), slice 4a (pkgs/id/src/hosted_export.rs) is on main. Working in a laptop worktree off main; one PR per the feature-slice rule.dezren39 commentedon Nov 23, 2026
Lane QN — design + object-model mapping for slice 4b (settling scope item 4 before code).
Premise reverified at main
ebd4bde81ca: slice 4a (src/hosted_export.rs) takes object/blob sets as inputs; the DO scaffold (hosted-worker/src/user-do.ts,bridge-store.ts,event.ts) stores signed events inbridge_events(applied chains) and blob references in ablobstable (SHA-256 → R2, slice A). The existingGET /v1/exportis a KV/metadata dump, not the §6 export.The mapping the wiring forces (to be recorded in the spec doc as §6.3 and in both modules' docs):
ExportObject.bytes:= the stored envelope bytes verbatim — the bridge never re-encodes or re-signs a stored event, so the export doesn't either.ExportObject.hash:= SHA-256 of the envelope bytes — the export-layer digest (canonical order + manifestobjects_digest). The envelope's own BLAKE3 id remains its identity at the object layer; the two hashes coexist, neither replaces the other.ExportObject.signer:= the envelope's author key;ExportObject.signature:= the envelope's own signature. The stored form cannot satisfy 4a's signature-over-the-SHA-256-hash-bytes rule — the envelope signature covers the canonical header encoding (chain.rsdecode's scheme) — and the producer must not re-sign with a key it should not hold. So §6's object-signature rule is settled as: the signature verifies in the object's own scheme —verify_importstep 3 decodes the envelope exactly as chain.rs does (which verifies the signature), and checks the decoded author equalssigner, the decoded signature equalssignature, andsigneris a binding-chain key (4a's chain rule, unchanged). 4a's syntheticExportObject::new(sign-over-hash) is removed; its tests are reworked onto real envelopes viachain::sign.document.putenvelope cites content by BLAKE3 (DocumentRef.content, native blob identity), while hosted R2 blobs are SHA-256-addressed (slice A table). The producer resolves citations by content: it fetches each referenced blob's bytes from R2, checks SHA-256(bytes) equals the table hash, computes BLAKE3(bytes), and records the blob in the export under its SHA-256 hash with the citing object'sblob_refsnaming that SHA-256 hash (§6 form). A cited content no referenced blob satisfies, or a referenced blob R2 cannot produce, fails the export loudly, naming the hash (acceptance 3). Blobs no applied object cites are not exported (§6.1 item 2: blobs referenced by those objects; §6.2 refuses unreferenced blobs).bridge_events) — the graph. Waiting-pool events (dependencies unmet, not yet graph objects) and fork-proof headers (evidence, not objects) are excluded. "An object citing multiple blobs" (acceptance 4) is covered as: multiple objects citing multiple blobs, two objects citing the same blob (carried once), since one envelope cites at most one document content in the currentChainExtform.Production shape:
hosted-worker/src/export.ts:produceExportSets(events, blobRefs, fetchBlob)→ §6 object/blob sets + counts +objects_digest; typedExportProductionErrornaming the offending hash.BridgeStore.appliedEvents()enumeration (author/seq order; the producer applies canonical hash order).SignedEventgains its envelopesignature(already parsed, not yet exposed).GET /v1/bridge/export, authenticated like the other bridge HTTPS legs (new"export"proof context), returning the sets in the exact serde wire shape ofHostedExport's object/blob fields. It is a pure read — available from a read-only, at-cap store (acceptance 2).ExportObject::from_envelope(bytes, blob_refs)(decodes + maps, never re-signs),ExportObject::cited_content_hashes()(BLAKE3 citations from the decoded extension),verify_importstep 3 per mapping (3).hosted-worker/test/fixtures/hosted-export-sets.json); the Rust suite loads the same fixture, feeds it throughbuild_exportwith a binding whose root key is that seed key, and assertsverify_importpasses with matching counts/digest (acceptance 1). A separate Rust test covers a rebind-history binding with objects authored by the old and current keys (acceptance 4's rebind leg).One PR, then merge on green; #13157 closes on its acceptance evidence.
dezren39 commentedon Nov 23, 2026
Lane QN — PR open: #13212 (head
b7cdcf8e1c8fba25cf280f7695c8283aa8e4cc9d).Landed in the PR:
hosted-worker/src/export.tsproduction module +GET /v1/bridge/exportroute (proof-authenticated, pure read, at-cap safe);BridgeStore.appliedEvents(); the §6.3 object-model mapping in the spec doc and both modules;ExportObject::from_envelope/cited_content_hashes;verify_importstep 3 verifying envelopes as chain.rs decodes them; the cross-language fixture contract (hosted-worker/test/fixtures/hosted-export-sets.json).One root-cause fix rides along, found by this slice's rebind-history acceptance case:
verify_key_signaturecould never verify a post-rebind record (transcript key ≠ current key after any rebind) — now the transcript key must be the current or a history key, with the current shape still covered by the service attestation.Verification (laptop; dispatch container can't run this suite — no Node, #13159 nix gaps):
cargo test -p id --lib531/0; hosted-workernpm test121/0 (5 new export tests); fmt clean on touched files; no clippy findings in touched files (workspace clippy stops on pre-existing id-store admission.rs test-code errors, untouched).