GeezerVison is showing github.com — feat(id): tenancy schema + migration baseline (E1 of #9083) by dezren39 · Pull Request #13042 · 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.
Closes #12796
E1 of #9083 (component E, hosted tenancy): the central tenancy DB schema from design §2.1 (doc/2026-11-17T16-55-00Z_design_hosted-tenancy-architecture) lands as a migration baseline in the new control-plane schema home, pkgs/id/hosted-worker/tenancy/.
What
tenancy/migrations/0001_tenancy_baseline.sql — the §2.1 schema as a Turso/SQLite migration: account (identity registry), binding (account→identity/tenant pointer), tenant_db (database registry), role_grant (design(pm-stack): one identity across the stack — SSO propagation from the public entry into every layer, roles replace asserted authorship #1253 vocabulary), peer_policy (epic: ID/Atlas extensible primitives, federation, namespaces — major design iteration (2026-11-12 directive) #9106/B31 classes as configuration, not a parallel trust model), publish_record, credential (metadata only), plus a meta table carrying schema_version (the user-do.ts bootstrap pattern).
tenancy/README.md — the plane rules, the invariant, and the migration discipline (numbered, append-only; E2/E4/E5 add files here).
test/tenancy-schema.test.ts — guard suite (below), wired into npm test and the id.hosted-worker.routing suite-registry entry.
README.md — a pointer section for the control plane.
Acceptance mapping
- Tenancy schema lands as a migration implementing §2.1 — the suite applies the migration to in-memory SQLite and pins the result table-for-table, column-for-column against §2.1.
- A test fails if a content/key/token column appears — the never-central guard (§2.3) scans every column of every table against token/key/secret/content-bytes name patterns; a companion test plants violations (
token_value, private_key, note_body, blob_bytes, api_secret) and proves the guard bites. Sanctioned references stay legal: content_hash (a content address), iroh_id (the public key), jti (the revocation handle — never the token).
- Peer principle honoured —
tenant_db.participant_kind is one vocabulary (user_hosted | user_native | self_hosted_node | public) on the shared registry row; a test asserts all four kinds insert identically and no schema object is named for one kind.
Documented statements of the design's rules (migration header)
The design calls its DDL "a sketch for the implementation issues, not a migration"; two spots state the rule rather than the sketch verbatim:
binding: the sketch's UNIQUE (account_id, status) would cap an account at one superseded binding ever, breaking the rebind chain its own superseded_by defines. The stated rule — at most one active row per account — is a partial unique index; the suite walks the full rebind flow (pending → supersede → activate).
- Vocabularies the record names as closed carry CHECK constraints:
participant_kind, jurisdiction, peer_policy.class, credential.scope. (meta uses name/value columns so the never-central guard needs no exception for it.)
Evidence
Coordination
Sibling #12825 (PM tenant store schema) is a different database (the tenant plane) with disjoint tables; this PR touches no PM-store files — footprint is pkgs/id/hosted-worker/tenancy/**, one test file, the package manifest/README, and the registry entry.
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.
Implements design section 2.1 as 0001_tenancy_baseline.sql in the new
pkgs/id/hosted-worker/tenancy/ control-plane schema home: account,
binding, tenant_db, role_grant, peer_policy, publish_record and
credential (metadata only), plus a meta table carrying schema_version.
Guard suite test/tenancy-schema.test.ts applies the migrations to
in-memory SQLite and pins the baseline column for column, fails if
any content/key/token column appears (design section 2.3, never
central), and pins the peer principle: one participant_kind
vocabulary (user_hosted | user_native | self_hosted_node | public),
no hosted-only schema objects.
Two statements of the design's rules over its sketch DDL, documented
in the migration header: the at-most-one-active-binding rule is a
partial unique index (the sketch's UNIQUE (account_id, status) would
break the rebind chain), and the vocabularies the record names as
closed carry CHECK constraints.
Wiring: package.json test list and the id.hosted-worker.routing
suite-registry entry gain the new test file.
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 16 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:
c63a1681-a306-48ca-b28d-384a8cfa9a16
Commits
-
Reviewing files that changed from the base of the PR and between c11fa9b and 597f0a5.
Files selected for processing: 6
-
.github/test-suite-registry.json
pkgs/id/hosted-worker/README.md
pkgs/id/hosted-worker/package.json
pkgs/id/hosted-worker/tenancy/README.md
pkgs/id/hosted-worker/tenancy/migrations/0001_tenancy_baseline.sql
pkgs/id/hosted-worker/test/tenancy-schema.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:37:35.300762Z |
511c3a2 |
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.
…schema
# Conflicts:
# pkgs/id/hosted-worker/package.json
|
Main advanced under this PR (bridge suites from #3818 and the provisioning gate from #3403 both edited the hosted-worker test line), which made this PR conflict in package.json only. Resolved by merging origin/main (d0d599ed3): the test line now carries every suite from main plus test/tenancy-schema.test.ts. Full merged suite re-run locally: 102/102 pass, tsc --noEmit clean.
Registry observation for the #3818 / #3403 lanes (not fixed here, out of this PR's scope): test/provisioning.test.ts and the five test/bridge-*.test.ts files are in npm test but appear in no .github/test-suite-registry.json entry, so the registry check will flag them as unwired until their entries are trued up. The id.hosted-worker.routing entry covers the pre-existing files plus this PR's tenancy-schema.test.ts.
|
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: 511c3a2df6
ℹ️ 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
+137
to
+138
|
|
content_hash TEXT NOT NULL, -- content address; the row is the only grant
|
|
|
signed_artifact TEXT NOT NULL, -- the signed bytes live in the public DB; this is the digest + envelope id
|
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.
Preserve the publish-record kind in the baseline schema
The §2.1 design schema includes a required publish_record.kind column (document | note | tag | artifact), but this migration drops it without documenting a deviation. Consequently, the baseline cannot record the published object's kind as specified. The new EXPECTED_SCHEMA also omits this field, so the claimed column-for-column conformance test incorrectly passes. Add the discriminator to the migration and its expected schema.
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.
|
Merged via merge commit 32d964d7e1253169a2f35734f8cf75df5db30831. The PR head contains merge-main-in commit 597f0a5fde6a9756de343b5f80361dd28a3e277a (parents: original PR head d0d599ed30e42fd20b3ffaa1da1fbfc62804adc6 and origin/main c11fa9b8c571527260780e57de718f7074b473b3). Preserved main and PR hosted-worker suites and added publish_record.kind to the migration and EXPECTED_SCHEMA. Verification on the merged PR head: npm test 151/151; npm run typecheck clean. The suite-registry checker reports 19 violations on current main and 17 on this merged tree (no new violations; two main-side suites are covered by this merge).
|
Sorry, something went wrong.
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.
|