GeezerVison is showing github.com — impl(fleet): session state — session id in env + worktree pwd-file · Issue #9075 · developing-today/code
impl(fleet): session state — session id in env + worktree pwd-file #9075DescriptionDesign: doc/2026-11-12T22-50-00Z_design_pm-board-hierarchy-genealogy/note.md section 14. Each fleet start assigns a session id, stored in the environment of everything fleet launches AND in a pwd-file at the repo root of every worktree it operates in.
Acceptance:
- fleet start writes the session id to env + pwd-file; a later bare fleet invocation in the worktree recovers it without being told.
- Resolution order demonstrated: explicit argument > env > pwd-file.
- The create-path stamp (fleet gh superset slice) records the recovered session id into provenance.session_id on a real created item.
- Pwd-file location/name documented in the fleet docs; stale pwd-files (session ended) are detectable and do not silently misattribute new work.
Activitydeveloping-today commented on Nov 12, 2026 dezren39 commented on Nov 13, 2026 Cross-link: #9178 §1 builds on this session-state work — a new resume_session_id column on the queue tasks table names the session a claim should continue, using the env / pwd-file session identity specified here. Companion decision record seed: FDR-0001 in #9180. dezren39 commented on Nov 17, 2026
Agent note — triaged (lane any-m, task 18825)
State: triaged
Work kind: task/small-fix (implementation in the fleet multicall binary)
Priority: priority/normal — fleet/PM-stack infrastructure (priorities brief line 4, PM stack as a real hub); not fleet-stalling, so not band 10. It is however a named dependency: #9178 builds on it, and MOB-07 / DSP-05 slices are dep-blocked in part on #9075.
Effort: effort/m
Fresh verification (2026-11-17):
- Issue impl(fleet): session state — session id in env + worktree pwd-file #9075 is OPEN, labels kind/feature + app/pm-stack only; no held / user/owned / do-not-merge / do-not-auto-edit labels.
- No implementation on current main (22e7682): no fleet session-id env assignment, no worktree pwd-file, no resolution-order code in pkgs/fleet or pm-stack (the MCPX_SESSION_ID hits are the unrelated mcpx session mechanism).
- Design source is doc/2026-11-12T22-50-00Z_design_pm-board-hierarchy-genealogy/note.md section 14.
- Consumer gate: acceptance item 3 (create-path stamp writes provenance.session_id) depends on impl(fleet): fleet gh Metadata superset — create-path stamping + DB insert (extends #9016) #9073, which is still OPEN — that integration point is sequenced in the follow-on, not a blocker for the core session-state work (env + pwd-file + resolution order + stale detection + docs are independent).
First concrete step for the follow-on: in the fleet binary, assign a session id at fleet start, export it to launched children, write the pwd-file at each operated worktree root, and implement recovery with resolution order explicit argument > env > pwd-file, with stale pwd-file detection.
Acceptance check for the fix: all four acceptance items on this issue demonstrated, including the #9073 create-path stamp recording the recovered session id once that slice is available (or the follow-on is dep-blocked on #9073 for that item only).
Follow-on: a scoped small_fix queue packet for this issue is enqueued by this triage (dedupe-checked); this triage task completes as triaged naming it. dezren39 commented on Nov 22, 2026 Verification follow-up for task 20275: retried bun test .opencode/plugin/mcpx/session-created.test.ts after the Rust suite finished; Bun 1.4.4 again timed out at 120s and reported out-of-memory (8.52 GB peak RSS). The test remains unverified. Queue task 20275 is recorded complete with canonical PR #12326 as the deliverable; issue #9075 remains OPEN with status/in-review, and #9073-dependent create provenance is still outstanding. dezren39 commented on Nov 23, 2026 Lane felix starting on #9075 (session state: session id in env + worktree pwd-file). Done check first against current origin/main; then the bounded slice if anything is missing. dezren39 commented on Nov 23, 2026
Picked up by felix — working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live while felix posts progress markers; after 30 minutes of silence any other worker may pick this up.) dezren39 commented on Nov 23, 2026 Verification record — lane felix, 2026-11-23: #9075 is already implemented on main; nothing to land.
Done check against origin/main 3721eefa2, item by item:
- Env + pwd-file write and bare-invocation recovery — landed.
pkgs/fleet/crates/fleet/src/session_state.rs: the pwd-file is .fleet-session-id at the Git worktree root (per-worktree, not the common Git dir; root .gitignore line 116 ignores it). fleet init and supported domain invocations resolve identity once via session_state::initialize (main.rs run_domain_with_initializer; also the fleet gh closure path), set FLEET_SESSION_ID for everything fleet launches, and persist a supplied identity to the pwd-file, so a later bare invocation in the worktree recovers it (resolve_marker + tests supplied_identity_is_persisted_for_a_later_bare_invocation). One deliberate shape note: the id is assigned at session start by the OpenCode session plugin (exported as FLEET_SESSION_ID) or bound explicitly via fleet session bind [--session-id ID] — fleet binds and propagates that identity rather than minting a competing one, which is what keeps it joinable with the queue's claim_session_id and the OpenCode session record. Landed via commits 22bf6e1 / d260bb5 / 471847b / fabbdb7.
- Resolution order demonstrated — landed.
resolve(): explicit argument > FLEET_SESSION_ID > OPENCODE_SESSION_ID > pwd-file, with unit tests naming each step (explicit_argument_wins_over_both_environments_and_pwd_file, fleet_env_precedes_opencode_env_and_pwd_file, opencode_env_precedes_pwd_file) plus a proptest over the ses_ id format.
- Create-path stamp — landed. The native create path (impl(fleet): fleet gh Metadata superset — create-path stamping + DB insert (extends #9016) #9073 slice 9, commit 31d0905) calls
gather_facts in prepare_create (gh_metadata.rs): session_id comes from FLEET_SESSION_ID, else the recovered session via session_state::initialize(None) (env → pwd-file), and assemble_provenance stamps it as provenance.session_id in the full provenance set; the §8.2 golden vectors reproduce byte-exact with session_id populated. (Evidence shape: code path + golden vectors + the impl(fleet): fleet gh Metadata superset — create-path stamping + DB insert (extends #9016) #9073 fake-gh e2e on its record; I did not mint a throwaway live item for this check.)
- Docs + stale detection — landed.
pkgs/fleet/README.md section "Session identity in worktrees (impl(fleet): session state — session id in env + worktree pwd-file #9075)" documents the file name/location, the resolution order, and the liveness rule. A marker is accepted only when the local OpenCode server returns a matching, non-archived session record (opencode-probe feature, in the full/connect feature sets); an ended or unverifiable marker fails closed with a named stale error instead of silently misattributing — and gather_facts degrades to a null stamp rather than failing creates.
Fresh test evidence (remote only): fleet queue dispatch fp_1d4438448a437c80d43019afd60b4ed2, run https://github.com/developing-today-forks/fleet/actions/runs/45196304833 at 3721eefa2 — cargo test -p fleet --features full from pkgs/fleet: succeeded (cargo exit status is the oracle; the tail shows the closing suites green). Two earlier dispatches failed before running any test — a bare-SHA checkout failure and a wrong-workspace command on my side — neither touched the code under test.
Close recommendation: Felix can close #9075 on this record; the downstream consumers (#9178's resume_session_id, MOB-07 / DSP-05) build on this landed state. dezren39 commented on Nov 23, 2026
Released by felix (outcome: done). Verified already implemented on main 3721eef: session_state.rs (env + .fleet-session-id pwd-file, resolution order, stale fail-closed), README docs, and the #9073 create-path stamp of provenance.session_id via gather_facts recovery. Fresh remote suite green (run 45196304833). No PR; close rests with Felix. dezren39 commented on Nov 23, 2026 Closed — Felix, 2026-11-23. Verified already done on main: session_state.rs implements the env + pwd-file identity with the named resolution order, the #9073 create path stamps provenance.session_id from it, and the README documents the stale-marker rule. Fresh evidence from my lane: cargo test -p fleet --features full passed remotely at current main (run 45196304833). Verification record above (7104420744). Downstream #9178/MOB-07/DSP-05 build on this landed state.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|