wg-service-purge

wg service purge-chats: skip active chats by default; require --include-active to nuke them

Metadata

Statusdone
Assignedagent-951
Agent identityf51439356729d112a6c404803d88015d5b44832c6c584c62b96732b63c2b0c7e
Created2026-04-28T21:49:09.755490041+00:00
Started2026-04-28T21:51:39.427928513+00:00
Completed2026-04-28T22:20:46.356974839+00:00
Tagseval-scheduled
Tokens20286885 in / 59787 out
Eval score0.88
└ blocking impact0.85
└ completeness0.95
└ constraint fidelity0.85
└ coordination overhead0.90
└ correctness0.87
└ downstream usability0.85
└ efficiency0.80
└ intent fidelity0.84
└ style adherence0.90

Description

Description

Today (2026-04-28) the user ran wg service purge-chats to clean up 22 test chats spawned by a runaway worker agent. The command obediently archived ALL chats — including .chat-5 which was the user's actual active chat session.

User quote: 'lol you archived this chat too lol lol'

The current behavior is correct in the literal sense (purge-chats does what it says), but unsafe by default — you should not be able to silently nuke the chat you are currently sitting in.

What to change

  1. wg service purge-chats detects which chats are 'active' and skips them by default. Definitions of active, in priority order:
    • The chat session whose handler is the parent process of the calling wg invocation (if reachable via env var like WG_CHAT_REF or process tree walk)
    • Chats whose handler subprocess is alive AND whose last consumer ping was within N seconds (e.g. 60s)
    • Chats that have a TUI attached (the tui-cannot-retire work added a TUI-attach signal — reuse that)
  2. New flag --include-active (or --all / --force — pick whatever fits existing wg verb conventions) that opts back in to the current full-nuke behavior. Without it, active chats are skipped.
  3. The output should be explicit: Purged 22 chat(s), skipped 1 active chat (.chat-5). Pass --include-active to override. so the user knows what happened.

Behavior matrix

Invocationactive chat .chat-5inactive chats .chat-6..27
wg service purge-chatsskipped + reportedarchived
wg service purge-chats --include-activearchivedarchived

Out of scope

  • Renaming the command (keep purge-chats)
  • Changing the chat archival format / history preservation (already correct)
  • Fancy interactive confirmation — single line of stderr output is enough

Validation

  • Failing test first: with one chat marked as 'active' (live handler + recent consumer ping), purge-chats archives the others but leaves the active one open
  • Failing test: purge-chats --include-active archives ALL chats including active (current behavior preserved under explicit flag)
  • Failing test: purge-chats on a graph with zero active chats works the same as today (no false positives blocking cleanup)
  • Output line clearly reports skipped count and how to override
  • Manual smoke: open a TUI, attach to a chat, run wg service purge-chats from a different terminal — the attached chat survives, others die
  • cargo build + cargo test pass

Depends on

Required by

Log