Repository navigation
impl(fleet-hosted): session registry — server-minted session ids, resolution-order parity with #9075 (#12584) - #12838
Merged
Merged
Conversation
…olution-order parity with #9075 (#12584) The hosted session registry (component C design §4.2): the service mints the session id (ses_ + 128 bits of crypto randomness as hex — the native #9075 id format), records it against the caller's credential-resolved binding_id with lane, declared model, open/close times and the lane-start issue set, and resolves ids on the stamp path. Open / resume / resolve / close routes over the skeleton's auth plumbing; unknown ids refuse session_unknown (another tenancy's session answers identically — no existence oracle), closed ids session_closed, malformed ids invalid_session_id. CLI-side resolution (design §3.2) transcribes the native resolver (pkgs/fleet/crates/fleet/src/session_state.rs) step for step: explicit argument > FLEET_SESSION_ID > OPENCODE_SESSION_ID > per-workspace stored state, with its failure modes (malformed nonempty values fail closed; an ended stored id is a named stale error; supplied identities persist for a later bare invocation). test/session-parity.test.ts runs the case table transcribed from the native resolver's own tests against it. Storage follows the skeleton's seam idiom: SessionRegistry is an interface (its production home is the #9074 metadata DB session table) with a fixture in-memory implementation. No new dependencies; no deployment.
|
Warning Review limit reachedYou'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 55 minutes. View limit details
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 #12584 (component C of #9081; design
doc/2026-11-22T14-28-45Z_design_fleet-tool-workers-edition§4.2). Builds on the #12583 skeleton (PR #12822,pkgs/fleet/hosted-worker). Left unmerged for Felix's review.What landed
Session registry (
src/sessions.ts,src/routes/sessions.ts) — the server-side replacement for #9075's env + worktree pwd-file:POST /v1/sessions(open),POST /v1/sessions/resume,POST /v1/sessions/resolve(the stamp path's question),POST /v1/sessions/close. All carry door idsessionsfor service-token scoping.ses_+ 32 lowercase hex from 16crypto.getRandomValuesbytes (128-bit entropy). The format is the native impl(fleet): session state — session id in env + worktree pwd-file #9075 format (session_state.rsvalid_session_id:ses_+ ASCII alphanumerics), so an id means the same thing in both editions. A client-sentsession_id/binding_idon open is ignored — the client never chooses its id and never asserts tenancy; the record is keyed by the caller's credential-resolvedbinding_idonly.404 session_unknown; another tenancy's session → alsosession_unknown(deliberately indistinguishable, no cross-tenant existence oracle); closed id →409 session_closed; malformed id →400 invalid_session_id(format checked before the registry is consulted, as native checks before trusting a source); agent caller declaring a lane other than its credential's →403 lane_beyond_credential(design §4.1 ceiling; an omitted lane inherits the credential's).SessionRegistryinterface +FixtureSessionRegistry(in-memory, theTenancyDirectoryidiom). The production home is the impl(fleet): metadata database + fleet Metadata query surface #9074 metadata DB session table behind the same interface;src/worker.tsholds one fixture instance at module scope. No live Cloudflare/Turso anything.CLI-side resolution (
src/session-resolution.ts) — design §3.2's carriage, a step-for-step transcription of the native resolver (pkgs/fleet/crates/fleet/src/session_state.rs): explicit argument > env (FLEET_SESSION_ID, thenOPENCODE_SESSION_ID— the native env level, perpkgs/fleet/README) > per-workspace stored state, with the native failure modes preserved (trim/nonempty at every level; malformed nonempty values fail closed rather than falling through; a stored id is used only when live — hosted liveness is the registry's word — and an ended/unverifiable stored id is a namedstale_session_stateerror; supplied identities persist to the stored state for a later bare invocation, and the stored state is not read when a higher level supplies one).Parity evidence
test/session-parity.test.tsruns one case table against the hosted resolver — 13 cases, each named for thesession_state.rstest it transcribes (explicit_argument_wins_over_both_environments_and_pwd_file,fleet_env_precedes_opencode_env_and_pwd_file,opencode_env_precedes_pwd_file,marker_is_used_only_when_live_and_stale_marker_is_explicit×2,whitespace_values_are_absent×2,invalid_environment_and_marker_ids_fail_closed×2, plus the malformed-env-before-stored, malformed-explicit, whitespace-explicit and empty cases) — plus the two native persistence tests (supplied_identity_is_persisted_for_a_later_bare_invocation,explicit_and_environment_values_do_not_read_an_invalid_marker) as full bind/recover flows. #9075's order is recorded in its acceptance, in the pm-board design note §14, and in component-C design §3.2; the native path is executable Rust, so the table is transcribed from its tests rather than run cross-language.Suite evidence
npm test: 56/56 pass — the 28 baseline skeleton tests untouched and green, plus 13 registry/route tests and 15 parity tests (incl. the end-to-end acceptance flow: open via the router → bare recovery of the same id from stored state → close → bare resolution refuses stale).npm run typecheck: clean.npm run smoke: all checks pass, including the new sequence through the real router — open (201, mintedses_…) → resolve (200) → close (200) → resolve refused (409session_closed).Deliberate calls
doorslist is unchanged: the registry is a §4.2 service surface, not one of the five §3.1 front doors (auth/tenancy aren't doors either), and the baseline capabilities/health tests pin that list.Closeskeyword: the acceptance's CLI surface is delivered as the resolution library the thin TS CLI consumes (this package ships no CLI binary, as with the skeleton); Felix's merge/done-check decides the close.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.