Skip to content

Workspace recover: revive Tower-managed architects after machine reboot #830

Description

@amrmelsayed

Context

Follow-up to #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: 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

  • afx workspace recover: revive builders after machine reboot/crash #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

Activity

self-assigned this
on May 23, 2026
added
area/towerArea: Tower server / agent farm CLI
and removed on May 23, 2026

waleedkadous commented on May 23, 2026

@waleedkadous
Contributor

amrmelsayed commented on May 23, 2026

@amrmelsayed
CollaboratorAuthor

Status update — partially addressed by PR #833.

Shipped in #833:

Deferred to #832 (assigned to @waleedkadous):

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
added 3 commits that reference this issue on Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/towerArea: Tower server / agent farm CLI

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions