Repository navigation
Workspace recover: revive Tower-managed architects after machine reboot #830
Copy link
Copy link
Open
Labels
area/towerArea: Tower server / agent farm CLIArea: Tower server / agent farm CLI
Description
Activity
added on May 23, 2026
type:featureNet-new capabilityNet-new capability
area/towerArea: Tower server / agent farm CLIArea: Tower server / agent farm CLI
and removed type:featureNet-new capabilityNet-new capability
Is this maybe going too far? what happens when there are multiple
architects? What if we just manually resumed the session based on the
/resume that is built in to codev?
…On Sat, May 23, 2026 at 4:12 PM Amr Elsayed ***@***.***> wrote:
*amrmelsayed* created an issue (cluesmith/codev#830)
<#830>
Context
Follow-up to #829 <#829>, which
built afx workspace recover for builders. The recovery flow (process
revival + conversation-context restoration via claude --resume <uuid>) is
now in place but only covers builders. Tower-managed architects die in the
same machine-reboot scenario and have no equivalent recovery path.
Problem
Two architect spawn surfaces exist today:
- *afx architect* — runs Claude directly in the user's current
terminal. No Tower dependency. If the machine reboots, the user just opens
a new terminal and runs afx architect again. *Not in scope* for
recovery.
- *afx workspace add-architect* (Spec 755) and the *main architect*
spawned implicitly by afx workspace start — Tower-managed PTYs,
persisted in terminal_sessions, killed by reboot. *In scope.*
After a reboot of a workspace with several Tower-managed architects (main
+ named siblings per Spec 755), the user has to manually re-spawn each one.
There's no equivalent of afx workspace recover for them, and the existing
recovery command excludes architects by predicate (type === 'builder'
filter on session rows, and porch state is the entry point — architects
don't have porch projects).
Proposed mechanism
Reuse the on-disk Claude conversation discovery from #829
<#829>: each architect's prior
conversation lives at
~/.claude/projects/<encoded-workspace-cwd>/<uuid>.jsonl. After reboot,
findLatestSessionId(workspacePath) returns the most recent UUID; we
relaunch the architect via claude --resume <uuid> to restore the
conversation in addition to the process.
Two architect kinds, both Tower-managed:
1. *Main architect* — one per active workspace, spawned by afx
workspace start. Its cwd is the workspace root.
2. *Named sibling architects* (Spec 755) — additional architects added
via afx workspace add-architect [--name <name>]. Each is tracked by a
name; the spec docs in codev/specs/755-multi-architect.md (or
wherever) detail naming rules. Their cwd may also be the workspace root, or
may be a per-architect subdirectory — needs verification.
Sketch of a new command (or extension of the existing one):
afx workspace recover-architects [--apply] [-y]
Or, more unified:
afx workspace recover [--builders] [--architects] [--apply] [-y]
Either reuses findLatestSessionId() from
agent-farm/utils/claude-session-discovery.ts.
Open design questions
1. *Unified command or separate?* Extend afx workspace recover to
handle both (with optional filters), or ship a sibling
recover-architects? Unified is fewer commands; separate keeps each
predicate simple.
2. *Predicate for architects.* Builders use porch state for
eligibility (non-terminal phase, etc.). Architects have no porch project.
Likely the predicate is just: terminal_sessions row exists with type =
'architect' AND shellper PID is dead. Simpler than the builder
predicate, but worth thinking through stale-architect cases.
3. *Main architect's cwd resolution.* Confirm that the main
architect's working dir on respawn is the workspace root (so the jsonl
lookup at ~/.claude/projects/<encoded-workspace-root>/ works). If the
architect runs in a per-name subdirectory, the encoding changes.
4. *Spec-755 naming on revival.* When re-spawning a named architect (
architect-2, reviewer-bob, etc.), need to preserve the name so the
user's references still resolve. The name comes from the
terminal_sessions.label or a related field — verify the column.
5. *Architect spawn API.* Tower-managed architects are spawned
server-side (workspace-add-architect calls client.addArchitect()
rather than going through spawn.ts). The revival path needs an
equivalent server call, or a flag like --resume-session <uuid> on the
existing addArchitect endpoint.
6. *Concurrent revival with builder recovery.* If both are running,
ensure neither steps on the other (separate terminal_sessions rows, no
shared mutations).
Acceptance criteria
- After reboot, running the chosen command revives every Tower-managed
architect that was previously alive, with conversation context restored
(each lands in the same Claude session it was in before).
- Standalone afx architect (local, non-Tower) remains unchanged.
- Named architects keep their names on revival.
- Dry-run by default; --apply actually respawns; -y skips confirmation
— same UX as builder recovery.
- Tests cover: main architect alive vs dead, named sibling alive vs
dead, missing jsonl (fallback to fresh session), Tower not running, no
architects to recover.
References
- #829 <#829> — builder
recovery + the findLatestSessionId helper at
packages/codev/src/agent-farm/utils/claude-session-discovery.ts
- Spec 755 — multi-architect support (named siblings)
- packages/codev/src/agent-farm/commands/workspace-add-architect.ts —
current architect spawn surface
- packages/codev/src/agent-farm/commands/architect.ts — local
(non-Tower) architect, out of scope
—
Reply to this email directly, view it on GitHub
<#830>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAUXGUF3G4DSUKW6E2RQOUD44IV6VAVCNFSM6AAAAACZKWLNIKVHI2DSMVQWIX3LMV43ASLTON2WKOZUGUYDSOBWGUYDAMA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
Status update — partially addressed by PR #833.
Shipped in #833:
- Main architect resume after machine reboot, via the same on-disk jsonl discovery mechanism used for builder conversation resume (Builder conversation resume: restore Claude session on recovery via jsonl discovery #831). When Tower's
launchInstancere-spawns main after a reboot, it now reads~/.claude/projects/<encoded-workspacePath>/for the newest jsonl and invokesclaude --resume <uuid>, skipping role injection (the saved conversation already contains it). - Conservative collision guard: if more than one architect is persisted in
state.db(i.e., named siblings have been added), main skips the resume path and spawns fresh with role injection. A WARN log surfaces this with a reference to Multi-architect conversation resume: disambiguate via per-architect session UUID #832. Prevents main from "stealing" a sibling's conversation in multi-architect workspaces.
Deferred to #832 (assigned to @waleedkadous):
- Named sibling architects added via
afx workspace add-architect(Spec 755) sharecwd = workspacePathwith main, so jsonl-discovery can't disambiguate them. Per-architect session UUID storage in thearchitecttable is the proper fix, designed in Multi-architect conversation resume: disambiguate via per-architect session UUID #832.
Scope of this issue going forward: can stay open as the umbrella architect-revival issue; close once #832 also lands and full multi-architect coverage is in place.
added a commit that references this issue on May 28, 2026
Metadata
Metadata
Assignees
Labels
area/towerArea: Tower server / agent farm CLIArea: Tower server / agent farm CLI
Context
Follow-up to #829, which built
afx workspace recoverfor builders. The recovery flow (process revival + conversation-context restoration viaclaude --resume <uuid>) is now in place but only covers builders. Tower-managed architects die in the same machine-reboot scenario and have no equivalent recovery path.Problem
Two architect spawn surfaces exist today:
afx architect— runs Claude directly in the user's current terminal. No Tower dependency. If the machine reboots, the user just opens a new terminal and runsafx architectagain. Not in scope for recovery.afx workspace add-architect(Spec 755) and the main architect spawned implicitly byafx workspace start— Tower-managed PTYs, persisted interminal_sessions, killed by reboot. In scope.After a reboot of a workspace with several Tower-managed architects (main + named siblings per Spec 755), the user has to manually re-spawn each one. There's no equivalent of
afx workspace recoverfor them, and the existing recovery command excludes architects by predicate (type === 'builder'filter on session rows, and porch state is the entry point — architects don't have porch projects).Proposed mechanism
Reuse the on-disk Claude conversation discovery from #829: each architect's prior conversation lives at
~/.claude/projects/<encoded-workspace-cwd>/<uuid>.jsonl. After reboot,findLatestSessionId(workspacePath)returns the most recent UUID; we relaunch the architect viaclaude --resume <uuid>to restore the conversation in addition to the process.Two architect kinds, both Tower-managed:
afx workspace start. Its cwd is the workspace root.afx workspace add-architect [--name <name>]. Each is tracked by a name; the spec docs incodev/specs/755-multi-architect.md(or wherever) detail naming rules. Their cwd may also be the workspace root, or may be a per-architect subdirectory — needs verification.Sketch of a new command (or extension of the existing one):
Or, more unified:
Either reuses
findLatestSessionId()fromagent-farm/utils/claude-session-discovery.ts.Open design questions
afx workspace recoverto handle both (with optional filters), or ship a siblingrecover-architects? Unified is fewer commands; separate keeps each predicate simple.terminal_sessionsrow exists withtype = 'architect'AND shellper PID is dead. Simpler than the builder predicate, but worth thinking through stale-architect cases.~/.claude/projects/<encoded-workspace-root>/works). If the architect runs in a per-name subdirectory, the encoding changes.architect-2,reviewer-bob, etc.), need to preserve the name so the user's references still resolve. The name comes from theterminal_sessions.labelor a related field — verify the column.workspace-add-architectcallsclient.addArchitect()rather than going throughspawn.ts). The revival path needs an equivalent server call, or a flag like--resume-session <uuid>on the existingaddArchitectendpoint.terminal_sessionsrows, no shared mutations).Acceptance criteria
afx architect(local, non-Tower) remains unchanged.--applyactually respawns;-yskips confirmation — same UX as builder recovery.References
findLatestSessionIdhelper atpackages/codev/src/agent-farm/utils/claude-session-discovery.tspackages/codev/src/agent-farm/commands/workspace-add-architect.ts— current architect spawn surfacepackages/codev/src/agent-farm/commands/architect.ts— local (non-Tower) architect, out of scope