land-dispatcher-auto

Land dispatcher-auto-respawns work onto current main

Metadata

Statusdone
Assignedagent-879
Agent identityf51439356729d112a6c404803d88015d5b44832c6c584c62b96732b63c2b0c7e
Created2026-04-27T21:50:19.097971191+00:00
Started2026-04-27T21:50:50.466196852+00:00
Completed2026-04-27T22:17:58.878261031+00:00
Tagseval-scheduled

Description

Description

Agent-777's first attempt produced commit e0aff8dbb on branch wg/agent-777/dispatcher-auto-respawns (worktree: /home/erik/workgraph/.wg-worktrees/agent-777). The retry failed unrelated to the work itself (native handler dispatched with no ANTHROPIC_API_KEY). The actual feature is implemented and committed — it just hasn't landed on main, and main has moved forward.

What's already done in e0aff8dbb (DO NOT redo)

  • New wg service purge-chats command + IpcRequest::PurgeChats (idempotent, falls back to direct graph mutation when daemon offline)
  • Supervisor mid-loop archive-check — exits cleanly when chat task is tagged archived / Done / Abandoned
  • Supervisor orphan exit removes coordinator-state-N.json so restart doesn't resurrect dead chats
  • 4 new tests:
    • test_handle_purge_chats_archives_all_chats_idempotent
    • test_handle_purge_chats_empty_graph_is_noop
    • test_purge_chats_excludes_from_boot_enumeration
    • test_direct_purge_chats_archives_and_removes_state_files

Files touched: src/cli.rs, src/commands/service/coordinator_agent.rs, src/commands/service/ipc.rs, src/commands/service/mod.rs, src/main.rs (+477 / -4)

What's left

  1. Rebase wg/agent-777/dispatcher-auto-respawns onto current main. The branch's diff against current main shows spurious reverts of:

    • CLAUDE.md "Agency tasks run on claude CLI" section (recently added to main — KEEP main's version)
    • README.md install/setup section reorganization (KEEP main's version)
    • docs/AGENT-GUIDE.md tweaks These are stale-base artifacts, not intentional reverts. Resolve by taking main's versions.
  2. Verify the original parts 1+2 of the parent task are actually addressed by inspecting the committed code. The original task asked for two things:

    • (a) idle-respawn rule — chat doesn't respawn when no consumer is connected and inbox is empty
    • (b) bulk-purge command — wg service purge-chats The commit message describes (b) clearly and a 'supervisor self-exit on archive' but it's not obvious from the message alone whether the idle-respawn rule (last-consumer timestamp + N-second idle threshold) is implemented or whether only the archived-respawn rule is. Read the diff and confirm — if (a) is missing, add it as part of this task.
  3. Auto-migrate stale .coordinator-N ids — the original task also called this out as a latent bug (Coordinator-1 spawning against deprecated .coordinator-1 id, never migrated). Confirm whether e0aff8dbb addresses this; if not, either auto-run wg migrate chat-rename on dispatcher boot or have the supervisor self-archive when it sees a non-existent task id.

  4. Test the full scenario from the parent task's Validation list — the four bullets there (purge survives restart, idle-respawn rule, stale-id self-archive, manual smoke) are still the acceptance bar.

Validation

  • Branch rebased cleanly onto current main; git diff main...HEAD shows only feature-related changes (no CLAUDE.md/README reverts)
  • Idle-respawn rule confirmed implemented (read coordinator_agent.rs diff) OR added if missing — failing test first
  • Stale .coordinator-N self-archive confirmed implemented OR added if missing — failing test first
  • All 4 new tests from e0aff8dbb still pass post-rebase
  • cargo build + cargo test pass with no regressions
  • Manual smoke from parent task: spawn 3 chats, wg service purge-chats, restart dispatcher, verify (a) zero handler processes alive, (b) zero respawn attempts in 30s, (c) chat tasks remain in graph as archived, (d) chat history dirs intact
  • Manual smoke: spawn chat with no consumer + empty inbox → supervisor does NOT respawn within idle threshold
  • No deprecated config warnings introduced (don't reintroduce agent.executor / dispatcher.executor)

Depends on

Required by

Log