GeezerVison is showing github.com — id: hosted export production — DO enumeration and R2 blobs into build_export (slice 4b of #2852) by dezren39 · Pull Request #13212 · developing-today/code
Conversation
dezren39
commented
Nov 23, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Slice 4b (production half) of #2852: produce a real §6 export from a live hosted per-user store. Design + mapping record: the design comment on #13157; the mapping is also recorded in the spec as §6.3.
Data plane (hosted-worker)
- New
src/export.ts: produceExportSets enumerates the DO's applied events (BridgeStore.appliedEvents()) and fetches the R2 blobs they cite, producing the §6 object/blob sets in canonical (hash) order with counts and the concatenated-hash digest. A referenced blob R2 cannot produce — or a citation no referenced blob satisfies — fails production loudly, naming the hash.
- New route
GET /v1/bridge/export, ID-key proof like the other bridge HTTPS legs (new "export" auth context). Pure read: available from a read-only, at-cap store.
SignedEvent now exposes the envelope signature it already parsed.
Object-model mapping (§6.3)
- Export bytes are the stored envelope verbatim — never re-encoded, never re-signed. Export hash = SHA-256 of the envelope bytes; signer = envelope author; signature = the envelope's own.
hosted_export.rs: ExportObject::from_envelope + cited_content_hashes replace the synthetic sign-over-hash constructor; verify_import step 3 verifies an object by decoding its envelope exactly as chain.rs does. Document citations (BLAKE3, native) resolve to the export's SHA-256 blob names by content.
Defect found by the rebind-history acceptance case, fixed at the root
HostedBindingService::verify_key_signature required the ceremony transcript's key to be the record's current key, so no post-rebind record could ever verify — a rebind-history export was impossible. The transcript's key must now be the current key or a history key; the record's current shape stays covered by the service attestation (checked alongside in §6.2 step 2).
Verification (reference laptop; the dispatch container cannot run this suite — no Node.js and the #13159 nix gaps — so per the dispatch-first fallback the verifying route is local, recorded here)
cargo test -p id --lib — 531 passed, 0 failed (includes 13 hosted_export tests: the reworked 4a set on real envelopes, the fixture contract, the rebind-history export; and all hosted_binding tests).
- hosted-worker
npm test — 121 passed, 0 failed, including 5 new export tests (seeded DO → sets; at-cap availability; both loud-failure legs; proof fail-closed).
- Cross-language contract: the worker suite pins the produced sets to
test/fixtures/hosted-export-sets.json (seed key [7;32]); the Rust suite feeds the same fixture through build_export + verify_import — counts 4/2 and the digest match.
cargo fmt clean on the touched Rust files (three test files carry pre-existing fmt drift on main, left untouched). Clippy: no findings in the touched files beyond warn-level pedantic notes; the workspace's clippy run stops earlier on pre-existing expect() errors in crates/id-store/src/admission.rs test code (untouched here, the id phase-8: P8.8 clippy/lint sweep deferred — ~150 clippy warnings remain with no tracking issue #803-family debt).
Acceptance mapping: export from a seeded DO passes verify_import with matching counts/digest (fixture contract test); producible at cap (worker test); missing blob fails loudly naming the hash (both legs, worker tests); enumeration mapping covered incl. multiple objects citing multiple blobs, one blob cited twice, and a rebind-history store (Rust test).
Closes #13157
Update — reconciled with #13158 (ingest half, landed on main while this PR was open): merged main in (e042850). Doc conflict in hosted_export.rs resolved by keeping the production section and pointing ingest at hosted_ingest. Semantic conflict: hosted_ingest's tests built objects with the removed ExportObject::new — migrated to ExportObject::from_envelope; its not-an-event test's premise (a wrapper-valid non-event object) is exactly what §6.3 overturns, so it now asserts the refusal at verify_import (ObjectSignatureInvalid). Merged tree re-verified: cargo test -p id --lib — 535 passed, 0 failed.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…_export (slice 4b of #2852, #13157)
Production half of the §6 export: the hosted data plane now
produces the object/blob sets build_export assembles.
- hosted-worker/src/export.ts: produceExportSets maps a per-user
DO's applied events (BridgeStore.appliedEvents) and the R2 blobs
they cite into the §6 sets, in canonical order, with counts and
the concatenated-hash digest. A referenced blob R2 cannot
produce, or a citation no referenced blob satisfies, fails the
export loudly naming the hash.
- GET /v1/bridge/export on the DO, ID-key proof like the other
bridge HTTPS legs (new "export" auth context). Pure read:
available from a read-only, at-cap store.
- SignedEvent exposes the envelope signature (parsed already,
never surfaced before).
Object-model mapping (§6.3 in the spec doc): export bytes are the
stored envelope verbatim — never re-encoded, never re-signed;
the export hash is SHA-256 of the envelope bytes; signer and
signature are the envelope's author and its own signature.
hosted_export.rs follows: ExportObject::from_envelope +
cited_content_hashes replace the synthetic sign-over-hash
constructor, and verify_import step 3 verifies an object by
decoding its envelope as chain.rs does. Document citations
(BLAKE3, native) resolve to the export's SHA-256 blob names by
content.
Defect found by the rebind-history acceptance case and fixed at
the root: HostedBindingService::verify_key_signature required
the ceremony transcript's key to be the record's current key, so
no post-rebind record could ever verify. The transcript's key is
now required to be the current key or a history key; the current
shape stays covered by the service attestation.
Cross-language contract: the worker suite seeds a DO from a
fixed seed key and pins the produced sets to
test/fixtures/hosted-export-sets.json; the Rust suite feeds the
same fixture through build_export + verify_import.
coderabbitai
Bot
commented
Nov 23, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Warning
Review limit reached
You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.
Next included review available in 57 minutes.
Check out review usage here.
View limit details
-
Limit details: You’ve used the included review currently available.
Learn how review limits work.
Review configuration:
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
bbbe961a-ca8d-4694-8dd7-399c6ff7524c
Commits
-
Reviewing files that changed from the base of the PR and between 52d0d4d and e042850.
Files selected for processing: 13
-
doc/2026-10-30T22-45-00Z_design_hosted_provisioning_sso_binding.md
pkgs/id/hosted-worker/README.md
pkgs/id/hosted-worker/package.json
pkgs/id/hosted-worker/src/bridge-auth.ts
pkgs/id/hosted-worker/src/bridge-store.ts
pkgs/id/hosted-worker/src/event.ts
pkgs/id/hosted-worker/src/export.ts
pkgs/id/hosted-worker/src/user-do.ts
pkgs/id/hosted-worker/test/export.test.ts
pkgs/id/hosted-worker/test/fixtures/hosted-export-sets.json
pkgs/id/src/hosted_binding.rs
pkgs/id/src/hosted_export.rs
pkgs/id/src/hosted_ingest.rs
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-11-23T11:26:50.508450Z |
e042850 |
New commits |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b7cdcf8e1c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+591
to
+593
|
|
if hex_encode(event.header.verifying_key.as_bytes()) != object.signer
|
|
|
|| !chain_keys.contains(&object.signer.as_str())
|
|
|
|| hex_encode(&event.header.signature.to_bytes()) != object.signature
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make multi-author bridge exports importable
When a bridge store contains events authored by other users, the new producer exports those events verbatim, but this check rejects the resulting archive with ObjectSignatureInvalid because their authors are not in the exporting user's binding history. This is a supported bridge scenario: hosted-worker/test/bridge-session.test.ts:151–172 authenticates with one bound key while synchronizing Alice's and Bob's separately authored chains. Reconcile the import authorization policy with the producer's complete applied-event set so normal collaborative stores can be exported and restored without discarding other authors' objects.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
blob_refs: o.blob_refs,
|
|
|
bytes: [...o.bytes],
|
|
|
})),
|
|
|
blobs: sets.blobs.map((b) => ({ hash: b.hash, bytes: [...b.bytes] })),
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stream blob bytes instead of expanding the whole export in memory
For stores containing moderately large blobs, this expands every buffered blob into a JavaScript number array before user-do.ts additionally stringifies the entire response. The Worker/DO has a 128 MB isolate memory budget, while blob uploads permit up to 100 MiB and aggregate storage is uncapped by default; even a single blob well below the upload limit can exhaust memory during this conversion. Consequently, valid populated stores cannot export their data, including capped stores for which export is explicitly intended to remain available. Use bounded streaming or chunked export rather than retaining the complete binary, numeric-array, and JSON representations simultaneously.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+521
to
+522
|
|
const irohHex = this.requireIroh(req);
|
|
|
const store = await this.bridgeProof(req, bindingId, irohHex, "export", new Uint8Array(0));
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide an export production path for users who lost their key
During a lost-key rebind wait, an authenticated account holder cannot satisfy this proof because it requires the unavailable current Iroh private key. However, §6.1 of doc/2026-10-30T22-45-00Z_design_hosted_provisioning_sso_binding.md explicitly promises export in that situation using a service-signed unkeyed_export manifest, which build_export(..., None, ...) already supports. Searching for produceExportSets, appliedEvents, and export routes shows this is the only production path that enumerates the signed objects; the existing /v1/export returns only KV data and blob metadata. Add a separately service-authenticated production path so the binding service can obtain the complete sets without requiring the lost key.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+111
to
+112
|
|
const document = mapGet(ext, "document");
|
|
|
if (document === undefined) return [];
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include blob citations from notes and chat messages
When content is referenced only by a note or a chat attachment, this early return silently treats it as unreferenced and excludes its bytes from the export. The existing native model also carries blob citations in NoteOp::Create and NoteOp::Revise through their content: DocumentRef fields (crates/id-store/src/notes.rs:41–55), and in chat links with ChatLinkKind::Blob (crates/id-store/src/chat.rs:68–95). A read-only reproduction with a signed note.create and its uploaded content produces one object but zero blobs and empty blob_refs, so restoring the archive loses the note's content despite a successful export. Enumerate all supported blob-carrying payload variants in both this helper and the Rust counterpart.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
* of it, so neither is enumerated here. */
|
|
|
appliedEvents(): HeldEvent[] {
|
|
|
return this.sql
|
|
|
.exec("SELECT author, seq, id, bytes FROM bridge_events ORDER BY author, seq")
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restrict exported events to the applied chain prefix
When a fork is discovered after one branch has already been stored, refreshAuthor() reduces the applied frontier to the fork sequence but retains the branch's rows in bridge_events. This unfiltered query therefore exports events that are no longer applied, while the exporter deliberately omits the competing fork-proof header. In an in-memory reproduction, ingesting e0,a1 followed by conflicting b1 leaves the chain frozen with next_seq: 1, but appliedEvents() returns sequences [0,1]. Restoring that export can reactivate the known-forked branch and its suffix. Filter the enumeration against each author's applied frontier rather than exporting every retained row.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Conflicts: hosted_export.rs module doc (both slices rewrote the
not-here note) — kept the production section, pointing ingest at
hosted_ingest. Semantic: #13158's hosted_ingest tests built
objects with the synthetic ExportObject::new, which the section
6.3 mapping removes — migrated to ExportObject::from_envelope.
Its not-an-event test's premise (a wrapper-valid non-event
object) is exactly what 6.3 overturns, so the test now asserts
the refusal at verify_import (ObjectSignatureInvalid) instead of
at ingest.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 23, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|