GeezerVison is showing github.com — feat(fleet-hosted): create-path stamping endpoint — Metadata parse/stamp/DB insert, fleet App rotation server-side (#12585) by dezren39 · Pull Request #12856 · 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.
Implements #12585 — the create-path stamping endpoint, filling the stamping door stub from the #12583 skeleton. Design: doc/2026-11-22T14-28-45Z_design_fleet-tool-workers-edition §§3.1, 5 (component C of #9081). Left unmerged for review.
What lands
POST /v1/stamps — through the skeleton's pipeline (authenticate → tenancy assertion → service-token door scope):
- Parse any pm-metadata block in the caller's body (
src/metadata.ts, pm stack: multi-board hierarchy + full task genealogy #9060 §12 format). A malformed block refuses the create (400 invalid_metadata_block) rather than silently dropping caller-owned fields.
- Stamp every fleet-owned provenance field from service sources only (§5 table):
created_at from the service clock; session_id/lane/model/lane_start_issues from the session registry (a cited session is resolved with requireOpenSession — unknown → 404 session_unknown, closed → 409 session_closed, another tenancy's → 404, no existence oracle; an agent credential's session claim is the ceiling, 403 session_beyond_credential); queue_id/scheduled_start/picked_up_at/work_started_at from the queue record; auth_subject = the credential-resolved binding_id; stamped_by = the service deployment identity; host/worktree/workspace_ref from request claims (design §3.2), never from the body's block. Caller-owned fields (direct_parent, links, lineage) are preserved exactly, with required-field defaults injected when absent; caller-supplied provenance — forged or honest — is replaced in full.
- Sign the provenance via impl(fleet): stamp signature — sign/verify canonical provenance (stamp_sig, stamped_by, auth_subject), both editions #12586's
signStamp. Unconfigured signing fails closed (503 stamp_signing_not_configured) before any GitHub write — this door never creates an unstamped item.
- Create the GitHub item through the hosted rotation point (
src/github.ts): fleet App installation tokens held as Worker secrets (configuration by name only: GITHUB_APP_ID, GITHUB_APP_PRIVATE_KEY_PKCS8, GITHUB_APP_INSTALLATION_IDS), minted from an App JWT (RS256/WebCrypto) and cached until near expiry; rate-limit and permission refusals fail over to the next installation (the native fleet gh: one passthrough that rotates personal + App tokens for every fleet gh call #8887 rule); other failures surface as 502 github_create_failed.
- Insert the full record (full Metadata JSON + extracted keys, §15) into the metadata store in the same request. A failed insert leaves the GitHub item intact and is reported in the response (
metadata_inserted: false, insert_error) — the ingestion slice (impl(fleet-hosted): ingestion receiver — GitHub webhook route + scheduled-Worker sweeper (#9076 hosted) #12590) heals the miss, per design §7.3.
Capabilities now truthfully report the gh domain available and the stamping door live.
What #9073 looks like on main (asked to check)
#9073 is still open and unimplemented natively — no pm_meta handling exists anywhere in pkgs/fleet Rust; fleet gh remains the step-1 rotation passthrough, exactly as design §1 records. So there is no native rotation/stamping machinery to reuse or conform to yet: this is the first edition of the §12/§13 semantics, and its fixtures are the ones the native side conforms to when #9073 lands (design §6 discipline). The hosted rotation point is new code here, mirroring the native rotation's rule (failover on rate-limit/permission), not its code.
Seams (interface + fixture, the #12584 idiom) — stated plainly
- MetadataStore (
src/stamping.ts): the production home is impl(fleet): metadata database + fleet Metadata query surface #9074's metadata DB, which doesn't exist yet. Fixture in-memory implementation ships; a Turso-backed store replaces it behind the interface. The Worker wires the fixture at module scope, same posture as the session registry.
- QueueRecordSource (
src/stamping.ts): the queue front door (impl(fleet-hosted): queue front door — broker protocol over hosted transports on the existing fleet-queue Turso DB #12589) owns claim records and wires the real source. The Worker wires none, so queue fields stamp null — the §5 rule for work that is not queue-originated. Tests inject a fixture source to prove the sourcing path.
- GitHubWriter (
src/github.ts): the rotation writer is real code, hermetically tested against a fake fetch. The Worker wires it when App configuration parses, and the fixture writer otherwise (local/dev semantics; this package is not deployed — see wrangler.toml). GitHub issues the App key as a PKCS#1 PEM; provisioning converts it to PKCS#8 (the only RSA form WebCrypto imports) — noted in config.ts.
Judgment calls (also recorded in the route header)
scheduled_start is stamped as a provenance key: §5 lists it in the stamp set and §12's format allows arbitrary keys; the native §12 example doesn't name the key, so the hosted edition fixes it here.
- A create citing no session stamps
session_id: null rather than refusing: §4.2 refuses unknown/closed cited ids; an uncited create (a person at the CLI) is a shape the §12 stamp set already carries as nulls.
- Unknown keys inside a caller's provenance are dropped, not signed sight-unseen; unknown top-level block keys are preserved (§12 allows arbitrary keys; only provenance is service-authoritative).
Evidence
npm test: 90/90 — the 70 baseline tests stay green (three auth.test.ts probes that used /v1/stamps as a generic stub door were repointed to still-stubbed doors; doors.test.ts drops stamps from the stub table; capabilities.test.ts skeleton-truth assertions updated to the landed truth) + 13 new stamping tests (no/partial/complete block, forged-provenance overwrite, session+queue sourcing, unconfigured-signer 503 with zero writes, cross-tenant session refusal, closed/unknown session refusals, forced insert failure leaving the item intact, caller-owned edit still verifies / provenance edit diverges, service-token scope, PR head/base, agent session ceiling) + 7 rotation tests (App JWT shape + signature, first-installation success, rate-limit and permission failover, non-failover surfacing, all-installations-refused, token caching).
tsc --noEmit clean. npm run smoke all-pass, extended with a real stamped create (forged picked_up_at overwritten, caller-owned parent preserved).
- No new dependencies. The locally generated
package-lock.json was kept out of the PR, same as impl(fleet-hosted): session registry — server-minted session ids, resolution-order parity with #9075 #12584/impl(fleet): stamp signature — sign/verify canonical provenance (stamp_sig, stamped_by, auth_subject), both editions #12586.

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.
…amp/DB insert, fleet App rotation server-side (#12585)
POST /v1/stamps is now the hosted stamping authority (design
doc/2026-11-22T14-28-45Z §§3.1, 5):
- Parse any pm-metadata block in the caller's body (#9060 §12);
malformed blocks refuse the create rather than dropping
caller-owned fields. Caller-owned fields (direct_parent, links,
lineage) are preserved exactly, with required-field defaults
injected when absent; provenance is replaced in full from service
sources (service clock, queue record, session registry, validated
token) — forged caller values are overwritten wholesale.
- The assembled provenance is signed via #12586's signStamp;
unconfigured signing fails closed (503) before any GitHub write.
- The GitHub write goes through the hosted rotation point
(src/github.ts): fleet App installation tokens held as Worker
secrets (config by name only), minted from an App JWT and cached,
failing over across installations on rate-limit/permission
refusals (the native #8887 rule). A GitHubWriter seam + fixture
stand behind it.
- The full record (full Metadata JSON + extracted keys) is inserted
into the metadata store in the same request; a failed insert
leaves the GitHub item intact and is reported in the response
(metadata_inserted: false) for the ingestion slice to heal.
Seams, all interface + fixture per the #12584 idiom: MetadataStore
(production home is #9074's metadata DB) and QueueRecordSource
(the queue door #12589 wires the real claim records; until then
queue fields stamp null — not queue-originated). #9073's native
create path is still unimplemented, so this is the first edition
of the §12/§13 semantics, not a port.
Capabilities now truthfully report the gh domain available via the
stamping door. Tests: 90/90 (70 baseline kept green — three auth
probes repointed from the now-live stamps door to stub doors, the
doors/capabilities skeleton-truth assertions updated to the landed
truth — plus 13 stamping endpoint tests and 7 rotation tests);
tsc clean; smoke extended with a real stamped create.
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 33 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:
d02b9a0e-c376-4181-b0aa-4e4c4e0b6d89
Commits
-
Reviewing files that changed from the base of the PR and between a3ab4c5 and 57f7cb7.
Files selected for processing: 16
-
pkgs/fleet/hosted-worker/README.md
pkgs/fleet/hosted-worker/package.json
pkgs/fleet/hosted-worker/smoke/smoke.mjs
pkgs/fleet/hosted-worker/src/auth.ts
pkgs/fleet/hosted-worker/src/capabilities.ts
pkgs/fleet/hosted-worker/src/config.ts
pkgs/fleet/hosted-worker/src/github.ts
pkgs/fleet/hosted-worker/src/metadata.ts
pkgs/fleet/hosted-worker/src/routes/stamping.ts
pkgs/fleet/hosted-worker/src/stamping.ts
pkgs/fleet/hosted-worker/src/worker.ts
pkgs/fleet/hosted-worker/test/auth.test.ts
pkgs/fleet/hosted-worker/test/capabilities.test.ts
pkgs/fleet/hosted-worker/test/doors.test.ts
pkgs/fleet/hosted-worker/test/github.test.ts
pkgs/fleet/hosted-worker/test/stamping.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.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 27, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|