Repository navigation
impl(fleet-hosted): service skeleton — Worker route modules, RP-token auth, tenancy mapping, health/capabilities (#12583) - #12822
Merged
Conversation
… auth validation, tenancy mapping, health/capabilities (#12583)
|
Caution Review failedThe pull request is closed.
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. |
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.
Refs #12583 (component C of #9081; design
doc/2026-11-22T14-28-45Z_design_fleet-tool-workers-edition, PR #12593). Unmerged for review — this PR does not close the issue: the acceptance's live-deploy leg belongs to a later slice (see "Not in this slice").Summary
Stands up
pkgs/fleet/hosted-worker— the fleet-hosted service skeleton: one Cloudflare Worker, route modules for the five component-C front doors (stamping, query, queue door, ingestion, sync), over one shared auth/tenancy plumbing layer. The plumbing is real; every door authenticates and then stubs501 not_implementednaming the issue that fills it. Package shape mirrorspkgs/id/hosted-worker(plain TS ESM,node --test, wrangler config, local-only posture).How the pieces map to the design
src/worker.ts+src/router.ts+src/routes/{stamping,query,queue,ingestion,sync}.ts. Every non-public route runs the same pipeline: authenticate → caller-tenancy assertion → service-token route scope → handler. No Durable Objects (design: none of C's routes need one at V2).src/jwt.tsvalidates SSO for fleet services: GitHub/Google/Microsoft login gated to Drew + devtoday OIDC provider with roles + account linking #9077 relying-party tokens the standard RP way (JWS signature against the provider JWKS via WebCrypto, RS256/ES256; iss/aud/exp/nbf checks; no callback to the caller).src/auth.tsresolves the three caller kinds: RP callers; design(pm-stack): one identity across the stack — SSO propagation from the public entry into every layer, roles replace asserted authorship #1253 agent-role credentials (lane + session claims required — they are the ceiling of what the caller may assert); per-caller service tokens recorded in the tenancy plane, looked up by SHA-256 and scoped to named doors.src/tenancy.ts: a validated (issuer, subject) maps to a tenancy account keyed by its mintedbinding_id(32 lowercase hex, the E/id: design: hosted provisioning + SSO→ID binding spec — account/binding records, challenge ceremony, delayed rebind, metering, export (from #2045) #2258 contract, same shapepkgs/id/hosted-workervalidates). Stamps/contexts record the binding_id, never an email or provider subject. Unmapped subjects and inactive accounts fail closed; the service accepts exactly the accounts the tenancy plane marks active.data_plane_credential_refused: libsql tokens carry data-plane access claims (a/p) in place of an RP iss/aud pair, and that shape is detected and refused as a stated rule, not an incidental signature failure.x-binding-id/x-tenancy-bindingheader that disagrees with the resolved binding is refused (cross_tenant_refused), the pkgs/id hosted-worker posture.GET /health(door identity, config presence as booleans) andGET /capabilities, which mirrors the nativefleet capabilitiesJSON shape (build/capabilities/compiled_capabilities/domainswith the native registry's names, summaries, aliases, capability ids and state vocabulary), plus additive hosted fields:domains[].hosted(the §2 disposition),domains[].filling_issue, and adoors[]list. Skeleton truth: no business domain reports available yet — the doors are stubs and the document says so; each filling issue flips its own domain.Seams (named, not hidden)
TenancyDirectoryis an interface with a fixture implementation (TENANCY_FIXTURE_JSON, tests/local dev). A DB-backed implementation replaces it behind the same interface./v1/route paths are the skeleton's; each filling issue owns its door's final verb shapes (the queue door's broker transport is impl(fleet-hosted): queue front door — broker protocol over hosted transports on the existing fleet-queue Turso DB #12589's surface).Not in this slice
Session registry (#12584), create-path stamping (#12585), stamp signing (#12586), and any production Cloudflare deployment — the acceptance's "Worker deploys" is verified locally here; deployment is a later slice's, per the skeleton's scope.
Evidence
origin/mainworktree (implementation absent) — 4 test files, 0 pass / 4 fail.npm test— 28/28 tests pass, including: valid RP token → binding_id; invalid signature → 401; expired → 401; absent token → 401 on every door; unknown subject → 403; inactive account → 403; agent credential with/without lane+session claims; service token in-scope 501 vs out-of-scope 403; cross-tenant header attempts fail closed for both RP and service callers; Turso-shaped credential → 401data_plane_credential_refused(signed with the fixture provider's own key, so only the §3.3 shape rule can refuse it); capabilities shape + skeleton truth values; every door 501s naming its filling issue.tsc --noEmit(typescript 5.6.3) clean.npm run smokeboots the real router in-process with the fixture provider/tenancy and answers:GET /health200 with the fleet-hosted identity,GET /capabilities200,POST /v1/stampswithout a token 401, with a valid RP token 501 — all checks pass. Awrangler devboot was also attempted; the sandbox's npx install of wrangler did not finish inside the attempt window, so the smoke harness (the repo's node test-harness idiom) is the local-run evidence of record.pkgs/id/hosted-worker: typescript ^5.6.0, wrangler ^4.0.0.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.