Repository navigation
feat(id): TenantOpsDO provisioning state machine (E2 of #9083) - #14392
Merged
developing-today-fleet[bot] merged 2 commits intoNov 24, 2026
Merged
Conversation
added 2 commits
November 24, 2026 13:08
Implements design §4 on the E1 baseline: one TenantOpsDO per tenant keyed by binding_id, driving the tenant_db row through requested → db_creating → db_ready → active, with suspension, export-only and two-phase deletion (revoke credentials, cooling-off window, drop, tombstone). Creation is intent-first: the deterministic request id is a pure function of the tenant id, the row records the intent before the provider call, and retries adopt the database the intent already made — concurrent sign-ups create exactly one database (test proves it against the real E1 schema). Every transition checks the §4 actor (owner = the bound binding, operator, platform, abuse/ceiling triggers) on internal headers and fails closed. The Turso management API is a provider seam (idempotent create / find / drop); no provider configured fails closed. Credential issuance stays E4; this slice only revokes on deletion, as §4 step 10 requires.
Book live update (book-live-update rule): the slice adds src/tenant-ops.ts and the TENANT_OPS binding, which moves statements in the id book — reference/hosted-worker.md gains the binding row, a TenantOpsDO routes section and the unrouted-surface row; concepts/hosted.md's package enumeration gains tenant-ops.ts. design/hosted-editions.md checked: its tenancy statements are about a running service, which this scaffold slice is not, so nothing there moves. Package READMEs updated for the same facts.
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
3 tasks
developing-today-fleet
Bot
deleted the
felix/12797-tenantops-provisioning
branch
November 24, 2026 13:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #12797 (E2 of #9083; Felix: done-check on merge is yours — acceptance mapping below).
What this is
TenantOpsDO— the §4 provisioning state machine of the hosted-tenancy design record (doc/2026-11-17T16-55-00Z_design_hosted-tenancy-architecture), implemented inpkgs/id/hosted-worker/src/tenant-ops.tson the E1 baseline (PR #13042). One object per tenant, keyed bybinding_id(§3), driving thetenant_dbrow:requested → db_creating → db_ready → active, withsuspended⇄active,export_only, two-phasedeleting → deleted, andfailedfromrequested(validation) anddb_creating(permanent provider refusal).How the §4 rules are kept
provisioningRequestId); the row records the intent before any provider call. Retries adopt the database the intent already made (checked before creating, and again after any create error — a lost response adopts, never duplicates).db_creating— neverfailedon a transient fault — for the next drive. Permanent refusal fails the tenant with nothing left at the provider.export_onlyonly) revokes all credential metadata first and opens the cooling-off window (TENANT_DELETION_COOLING_OFF_MS, default 24h); completion drops the database and writes the tombstone. A stuckdeletingtenant has no working credentials — the safe half-state.503 provider_unavailable). The tenancy SQL handle is the object's storage with the tenancy migrations applied — the E6 adapter is where a Turso-over-HTTP handle plugs in. Credential issuance stays E4; this slice only revokes, as §4 step 10 requires. E2 needed no migration: the baseline row carries every field the machine writes.Verification (remote only)
Run 45405972563 on head
71356ecd2(the run shows cancelled only because I cancelled it during the known fleet-command Post Execute hang, after the execute step completed; full log read):npm: command not found), so the command put the runner toolcache's Node on PATH: node v24.22.3, npm 11.19.1,npm install(78 packages).npm run typecheck(tsc --noEmit, strict): clean.npm test(full package suite, 22 files): 171 tests, 171 pass, 0 fail. The 14 new tests intest/tenant-ops.test.ts, by name: the §4 lifecycle end to end with two-phase deletion; concurrent sign-ups create exactly one database (§11 item 2) — duplicate racing requests + provisions against a slow provider,createCalls == 1, plus a restarted second instance still creating nothing; crash-after-creation adoption; lost-response adoption; same-request-id retry; retryable exhaustion stayingdb_creating; permanent refusal →failedwith no database left; no-binding validation →failed; activation gated on observed bootstrap; the full §4 actor matrix (every step tried by every unnamed actor, state unmoved); trigger scope (abuse suspends, ceiling forces export-only, neither does the other's step); cooling-off refusal with revocation already applied; wrong-state refusals and idempotent repeats; no-provider fail-closed.tenancy/migrations/, astenancy-schema.test.tsdoes), never a schema copy.Book live update (in-slice)
The slice adds
src/tenant-ops.tsand theTENANT_OPSbinding, moving id-book statements:pkgs/id/book/reference/hosted-worker.mdgains theTENANT_OPSbinding row, a TenantOpsDO routes section (routes, §4 actors, failure shapes), the unrouted-surfaces row, and the source line;pkgs/id/book/concepts/hosted.md's package enumeration gainstenant-ops.ts.design/hosted-editions.mdwas checked: its tenancy statements concern a running service, which this scaffold slice is not — nothing there moves. Package READMEs (hosted-worker/README.md,tenancy/README.md) updated for the same facts, including the correction that E2 landed with no new migration. Book not rebuilt in this pass (no SUMMARY/H1/link structure changed); the post-merge Pages check owns the render verification.New dependencies: none. No secrets in code or logs — the platform Turso credential is referenced by name only and never leaves the Worker; tests use a fake provider.
{ "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-24T13:52:24Z", "session_id": null, "lane": null, "host": "htch-runtime", "worktree": "/home/hatch", "model": null, "lane_start_issues": [], "workspace_ref": { "kind": "worktree", "id": "/home/hatch", "repo": "developing-today/code", "branch": "main", "sha": "c11f41086f57d626be7eb582763b721f8f557408" }, "auth_subject": "felix", "stamped_by": "fleet 0.1.0 (native)" } }Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.