GeezerVison is showing github.com — feat(id-hosted-worker): reference record schema + access check (component F, #12803) by dezren39 · Pull Request #13050 · developing-today/code
Conversation
dezren39
commented
Nov 23, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Slice 1 of #9084 (component F design, doc/2026-11-23T03-04-00Z_design_content-addressed-media-data-plane): the reference record in component E's tenancy schema plane, the design §5 access check, and the create/remove outbox events.
Closes #12803
What lands
pkgs/id/hosted-worker/references/migrations/0001_reference_record.sql — the reference record schema, applied per tenant DB and in the public DB (E design §2.2: references are tenant-plane rows; there is no separate registry, GC reads these rows). content_reference carries exactly the design's fields: content ID (epic: ID/Atlas extensible primitives, federation, namespaces — major design iteration (2026-11-12 directive) #9106 Part A, the sha256 shape the landed blobs table uses), partition (jurisdiction + sensitivity tier per id: isolate hosted blobs by jurisdiction and minimize shared directory #3401, both stored on the row and CHECK-constrained), class (standard / restricted / publication), created-by (binding_id), and tombstone state (tombstoned_at — removal tombstones, never hard-deletes, so the sweep's re-verify has authoritative state). A partial unique index makes referencing idempotent (one live reference per content/partition/class/writer). reference_outbox is the append-only event contract for the derived index (impl(pm-stack F): derived reference/location index builder (#9084 slice 3) #12805) and GC (impl(pm-stack F): GC mark-and-sweep worker — epochs, grace, fenced delete (#9084 slice 4) #12806): reference.created / reference.removed, pageable by seq, dedupe by event_id.
pkgs/id/hosted-worker/src/references.ts — ReferenceStore over the same minimal SqlStorage interface as user-do.ts (runs on DO SQLite or any SQLite/Turso behind it), bound to its database's own partition so a reference cannot be forged across partitions; plus checkAccess, the §5 rule evaluated against authoritative rows: live reference in an authorized DB in the object's own partition whose class permits the operation, or a live publication reference in the public DB (tier public only). Minting guards: restricted class requires an authorized writer of the source content; publication class only in the public DB at tier public; staged content is not referenceable. The embedded DDL and the migration file are pinned together by a drift test.
pkgs/id/hosted-worker/test/references.test.ts — 15 tests (node:test + node:sqlite, the package's harness shape).
Acceptance coverage
Live vs tombstoned references (removal = revocation), cross-partition refusal (jurisdiction and tier), unauthorized-DB refusal, hash-alone-grants-nothing, restricted-class minting (refused without source-writer authorization; standard class insufficient for tenant-restricted access), publication grant + unpublish revocation, idempotent create, outbox ordering/cursor paging, fail-closed validation.
Verification (sandbox)
node --experimental-transform-types --test test/references.test.ts — 15 passed, 0 failed.
- Package suite
npm test — 36 passed, 0 failed (no regression).
tsc --noEmit (TypeScript 5.9.3, package tsconfig) — clean.
Boundaries
Not the central tenancy schema (#12796, tenancy/ — untouched), not the PM tenant store (#12825 — untouched), no changes to user-do.ts/worker.ts. package.json is deliberately unchanged so the in-flight E1 lane's test wiring cannot conflict; until a follow-up wires it in, run the new test directly as above. Capability minting itself is #12807 — this PR is the check that slice must call.

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…nent F, #12803)
Slice 1 of #9084: the reference record in component E's tenant/public
DB plane -- rows carrying content ID (#9106 Part A), partition
(jurisdiction + sensitivity tier, #3401), class, created-by and
tombstone state -- plus the design section 5 access check (live
reference in an authorized DB, or publication reference in the
public DB) and reference create/remove outbox events for the index
(#12805) and GC (#12806) consumers.
Lands in references/migrations/ + src/references.ts +
test/references.test.ts; the central tenancy schema (#12796) and
the PM tenant store (#12825) are untouched, and package.json is
deliberately unchanged so the in-flight E1 lane's test wiring
cannot conflict (the new test runs standalone).
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 17 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:
bcaae852-5fc0-44d4-8b1f-0c5680320fc5
Commits
-
Reviewing files that changed from the base of the PR and between 38f9052 and 1f56742.
Files selected for processing: 3
-
pkgs/id/hosted-worker/references/migrations/0001_reference_record.sql
pkgs/id/hosted-worker/src/references.ts
pkgs/id/hosted-worker/test/references.test.ts
- 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-23T07:39:41.290196Z |
1f56742 |
PR opened |
ℹ️ 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: 1f567422e3
ℹ️ 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.
|
|
row.created_by,
|
|
|
row.created_at,
|
|
|
);
|
|
|
this.appendEvent("reference.created", row, createdBy, now);
|
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.
Commit reference mutations and outbox events atomically
With an autocommitting SQLite adapter, such as the one used by the new tests, the reference insert commits before the outbox insert. If appendEvent fails or the process stops between them, the reference survives without its creation event; retrying cannot repair this because the existing-reference branch returns without emitting an event. Removal has the same failure mode: the tombstone survives, and subsequent calls return false without emitting the missing removal event. Wrap each reference mutation and its outbox append in one transaction so consumers cannot permanently miss changes.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+75
to
+79
|
|
test("a live reference grants read in its own partition via an authorized database", () => {
|
|
|
const tenant = makeStore("tenant-a", US_PRIVATE);
|
|
|
const { row, created } = tenant.createReference({
|
|
|
contentId: CONTENT,
|
|
|
refClass: "standard",
|
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.
Add generated coverage for the reference access state machine
The new suite contains only hand-written acceptance examples, although the implementation has explicit invariants for partition isolation, tombstone revocation, and idempotency, plus a documented access-rule model. The repository requires property-based coverage for invariants and model-based coverage where a specification exists; acceptance examples do not replace those checks. Add generated create/remove/access sequences checked against an independent reference model across partitions, classes, and authorization sets.
AGENTS.md reference: AGENTS.md:L37-L39
Useful? React with 👍 / 👎.
Sorry, something went wrong.
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.
This was referenced Nov 24, 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.
|