Skip to content

id: hosted export production — enumerate a per-user DO's objects and R2 blobs into build_export (slice 4b of #2852, from #3810) #13157

Closed

Description

@dezren39

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:

  1. 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.
  2. Fetch every R2 blob those objects cite, by hash (slice A indirection, feat(id): hosted Worker slice A — R2 content-addressed blobs + SQLite reference indirection #10129), including from a read-only, at-cap store (§5.4; slice B feat(id): hosted Worker slice B — per-user metering, ceilings, read-only + export-at-cap #10132 already provides export-at-cap metering/ceilings).
  3. Feed both sets to build_export with the binding record and its rebind records.
  4. 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.
{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-23T09:26:15Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": null,
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": null,
    "auth_subject": "archer",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Activity

  1. added
    kind/featureNew feature or capability request
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Nov 23, 2026
  2. developing-today commented on Nov 23, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    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.

  4. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    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):

    1. ExportObject.bytes := the stored envelope bytes verbatim — the bridge never re-encodes or re-signs a stored event, so the export doesn't either.
    2. 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.
    3. 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.
    4. 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).
    5. 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.

    Production shape:

    • hosted-worker/src/export.ts: produceExportSets(events, blobRefs, fetchBlob) → §6 object/blob sets + counts + objects_digest; typed ExportProductionError naming the offending hash.
    • 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.

  5. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)kind/featureNew feature or capability requeststatus:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions