Repository navigation
Description
Problem
After a machine reboot or crash, all builder processes die — shellper daemons (detached, in-memory) and Tower together. Disk-persistent state survives: worktrees in .builders/<id>/, porch status.yaml, SQLite terminal_sessions, spec/plan/review files. But there is no command to walk that state and respawn the builders that should still be running.
The user typically discovers a half-dozen "dead" builders the morning after a reboot and has to afx spawn <id> --resume each one by hand. Most builders are sitting idle at approval gates when this happens, so a fresh respawn (which lands them right back at the gate via status.yaml) is functionally equivalent to true session resume.
Proposal
Add an explicit afx workspace recover command (no auto-trigger on Tower startup) that:
- Enumerates
codev/projects/*/status.yaml(usingfindStatusPath()to handle spec-653 multi-PR layouts under.builders/<id>/codev/projects/). - Filters to eligible projects via the predicate below.
- By default, runs in dry-run mode: lists what it would revive and exits. Pass
--applyto actually respawn. - For each eligible project, respawns the builder via the existing
afx spawn <id> --resumecodepath.
Revival predicate
A project is eligible when ALL of:
phase ∉ {verified, complete}— not in a terminal porch state.- A
terminal_sessionsrow exists for this project (it had a builder previously). - The shellper PID is dead OR the Unix socket is unreachable (actually needs recovery, not already alive).
- The worktree at
.builders/<id>/still exists on disk. status.yaml.updated_atis within the last 7 days (configurable via--max-age <days>; bypass entirely with--include-stale).
Notes:
- Builders idle at the
prgate are revived (consistent with all other gate-idle builders; the resource cost is negligible and the human may want to dispatch the builder to address review feedback without manual respawn). - Projects whose
status.yamlwas never written (builder crashed before first phase transition) won't show up; this is the conversation-resume gap and is out of scope.
CLI
afx workspace recover # dry-run, prints eligible projects
afx workspace recover --apply # actually respawn
afx workspace recover --max-age 14
afx workspace recover --include-stale --apply
Out of scope (separate issue)
- Conversation resume — restoring the builder's prior Claude session content (the
~/.claude/projects/<encoded-cwd>/<uuid>.jsonlfile). Requires capturing the Claude session UUID at spawn time, storing it interminal_sessions, and passing--resume <uuid>to the relaunchedclaudeprocess. Worth it for mid-phase recovery but materially larger scope; file separately if/when mid-phase crashes become a real pain point. - Auto-trigger on Tower startup — explicitly rejected here to avoid reviving abandoned-but-uncleaned projects. Revisit if explicit-trigger friction proves high.
Implementation notes
- Reuse
findStatusPath()(state.ts:285–303) for status.yaml lookup. - Liveness check: SQLite
terminal_sessionsrow → PID alive + socket connectable. Reconciliation logic intower-terminals.ts:485–711already detects dead sockets; recovery extends that path with respawn instead of just cleanup. - Respawn path: invoke the same flow as
afx spawn <id> --resumerather than building a parallel codepath.
Activity
amrmelsayed commentedon May 23, 2026
Status update — implementation landed on
feat/829-workspace-recover, draft PR #833.What this PR ships (closes #829):
afx workspace recovercommand — enumerates porch projects, identifies dead builders, respawns viaafx spawn --resume. Dry-run by default.spir,aspir,air,pir,bugfix);experiment/maintain/task/legacyspiderskipped withunsupported_protocolreason.Three rounds of cmap-3 review:
69d65d37.c14fd0d1,c6c0dc98,386353d4,b96dcacc.discoverResumeSessionhelper extraction so PIR/bugfix recovery also picks up prior conversations, and a defensive guard so main architect resume can't steal a sibling's session in multi-architect workspaces.Live-tested against shannon (345-project workspace) — 9 in-flight PIR/SPIR builders correctly surfaced as
revive; rest classified across terminal/unsupported/missing/stale.Related issues:
[Issue #829] fix: address cmap-3 round-2 review findings
[Issue #829] fix: cmap-3 round-3 nits
[Issue #829] fix: pass workspace path to getArchitects (post-merge)
Merge pull request #833 from cluesmith/feat/829-workspace-recover
[Issue cluesmith#829] feat(porch): add listAllProjects helper
[Issue cluesmith#829] feat(afx): add 'workspace recover' to revive bu…
[Issue cluesmith#829] fix: address cmap-3 review findings
[Issue cluesmith#829] fix: invert session-row predicate — absence mea…
[Issue cluesmith#829] feat(recover): hide stale items from dry-run by…
[Issue cluesmith#829] feat(recover): conversation resume via on-disk …
[Issue cluesmith#829] fix(recover): round age display UP so labels ma…