Skip to content

impl(fleet-hosted): service skeleton — Worker route modules, RP-token auth, tenancy mapping, health/capabilities (#12583) - #12822

Merged
dezren39 merged 1 commit into
mainfrom
felix/12583-service-skeleton
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
felix/12583-service-skeleton

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

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 stubs 501 not_implemented naming the issue that fills it. Package shape mirrors pkgs/id/hosted-worker (plain TS ESM, node --test, wrangler config, local-only posture).

How the pieces map to the design

  • §3.1 one Worker, route modules, shared plumbing — 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).
  • §4.1 who may call — src/jwt.ts validates 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.ts resolves 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.
  • §4.1 / E keying — tenancy mapping — src/tenancy.ts: a validated (issuer, subject) maps to a tenancy account keyed by its minted binding_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 shape pkgs/id/hosted-worker validates). 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.
  • §3.3 rule 3 — data-plane refusal — a per-user Turso DB credential presented as service auth is refused with 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.
  • Cross-tenant fail-closed — the credential is the only source of tenancy; a client-sent x-binding-id / x-tenancy-binding header that disagrees with the resolved binding is refused (cross_tenant_refused), the pkgs/id hosted-worker posture.
  • Health + capabilities — public GET /health (door identity, config presence as booleans) and GET /capabilities, which mirrors the native fleet capabilities JSON shape (build / capabilities / compiled_capabilities / domains with 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 a doors[] 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)

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

  • Fail-before: the test suite copied onto a pristine origin/main worktree (implementation absent) — 4 test files, 0 pass / 4 fail.
  • Pass-after: 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 → 401 data_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.
  • Typecheck: tsc --noEmit (typescript 5.6.3) clean.
  • Local run: npm run smoke boots the real router in-process with the fixture provider/tenancy and answers: GET /health 200 with the fleet-hosted identity, GET /capabilities 200, POST /v1/stamps without a token 401, with a valid RP token 501 — all checks pass. A wrangler dev boot 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.
  • Dependencies: no runtime dependencies (WebCrypto only). devDependencies mirror pkgs/id/hosted-worker: typescript ^5.6.0, wrangler ^4.0.0.

Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

… auth validation, tenancy mapping, health/capabilities (#12583)
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • 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

@dezren39
dezren39 merged commit f127893 into main Nov 23, 2026
1 of 2 checks passed
@dezren39
dezren39 deleted the felix/12583-service-skeleton branch November 23, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant