feat(recovery): durable per-project agent-session ledger in plan.db (#2405) - #2406
Merged
Conversation
) The authoritative, per-project record of the agents a project has LAUNCHED, so recovery reads a fact instead of inferring from a pid-only JSON file + worktrees. - plandb `fleet_sessions` table (pane_id PK · stream_id · role · cwd · pid · status · launched_at · last_seen) + the `sessions` module owning its DDL + `Store` methods (upsert/heartbeat/set_status/list/remove). Wired into schema.migrate + ALL_TABLES. Persists across a clean quit (unlike pty-ledger.json). - `bsc plan fleet session {set|list|heartbeat|status|remove}` — the runtime records each spawned agent here (per the bsc-reachable golden rule). - Tests: upsert-then-refresh preserves launched_at; set-status + remove; empty pane_id rejected. cargo check + clippy --all-targets clean. Slices next: discover_sessions reads the ledger · frontend write-hooks on the fleet lifecycle · recovery/Glance restart from it. Refs #2405.
…#2405) publishFleetRoster now also records each launched agent in the durable per-project session ledger (`bsc plan fleet session set`), from the same roster rows — so the ledger reflects every fleet launch (primary launch + recovery restart, the two publishFleetRoster callers). Best-effort + fire-and-forget per agent; a failed write never blocks the launch. cwd is re-derived from the plan on restart, so it's left blank here. - recordFleetSessions(projectKey, rosterRows) in fleetRoster.ts. - Test: records director (empty streamId) + worker (real streamId) as running; skips a keyless row. Next: discover_sessions reads the ledger (app crate) · recovery/Glance restart + status transitions. Refs #2405.
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.
Fool-proof fleet recovery: an authoritative, DB-backed record of the agents a project has launched, so recovery reads a fact instead of inferring from a pid-only JSON file + worktrees + the fleet plan.
Landed here (slices 1 + 3)
fleet_sessionstable (pane_idPK ·stream_id·role·cwd·pid·status·launched_at·last_seen) + thesessionsmodule (DDL +Storeupsert/heartbeat/set_status/list/remove). Wired intoschema.migrate+ALL_TABLES. Persists across a clean quit (unlikepty-ledger.json).bsc plan fleet session {set|list|heartbeat|status|remove}— the runtime records each spawned agent (bsc-reachable golden rule).publishFleetRosterrecords every launched agent (recordFleetSessions) from the roster rows — covering both the primary launch and the recovery restart.cargo check/clippy --all-targetsclean · frontendtypecheck/lintclean.Still to come (follow-up slices, need the app build + GUI check)
discover_sessionsreads the ledger (+ pid liveness) as the authoritative source.Design (approved): per-project plan.db · persists across clean quit · augments (doesn't replace)
pty-ledger.json(the pre-boot orphan-reaper). Refs #2405.🤖 Generated with Claude Code