Repository navigation
Description
Field incident (full report available; summarized with evidence)
On a second workspace, four of five architects died individually over ~two days. Tower — whose daemon ran CONTINUOUSLY the whole window (uptime 150,352s → 316,489s, so this was not a Tower crash) — kept serving all of them as registered. afx status listed an architect with a pid that ps -p showed dead; workspace terminal count dropped 14 → 10 with no deregistration. Worst part: afx send architect:<name> to a dead architect reported [ok] Message delivered. A gate approval relayed to a dead architect is lost with a positive confirmation and no error anywhere — the held-mailbox path exists precisely for this and never engaged because the target was believed live.
Why the gap exists (architecture)
Liveness reconciliation runs at Tower BOOT only. A long-lived Tower never re-checks; rows can only go stale. Compounding detail from the reporter's DB inspection: the architect table stores pid = 0 for every row (unusable for liveness; started_at also stale across restarts), while terminal_sessions carries real pid, shellper_pid, shellper_start_time — correct and sufficient, but nothing validates or prunes those rows during Tower's life. The data needed for liveness is already persisted; it just is not checked after boot.
Fix shape (hypothesis, for the builder to validate)
- Validate before presenting.
afx status/ overview:kill(pid, 0)each terminal_sessions row withshellper_start_timecompared against the live process's start time (PID-reuse guard — same discipline as tower reconcile: failed reconnect triggers delete + SIGTERM without verifying the shellper is dead (destroyed 53 live sessions in the #1629 incident) #1686's proof-of-death), and present dead rows as STALE, never as live. Presentation-only: this must not delete or signal anything (tower reconcile: failed reconnect triggers delete + SIGTERM without verifying the shellper is dead (destroyed 53 live sessions in the #1629 incident) #1686's invariant stands — destruction requires proof of death AND stays reconcile's job). afx sendmust not report success to a dead target. Route to the durable mailbox with adead-target(or similar) hold reason, consistent with existing hold semantics — the sender getsheld+reason and the owner escalation path engages, instead of[ok] deliveredinto a void. Also investigate HOW delivery verification passed against a dead session: if the echo check can pass on a stale ring buffer, that is its own sub-defect of the tower: delivery write edge — verify-or-retry 'delivered', settle-before-write, loud size limit (silent-loss residuals of #1564/#1521) #1573 contract.- Periodic or on-read revalidation. Boot-only reconcile is structurally insufficient for a daemon designed to run for weeks. Options for the builder to weigh: lazy revalidation on read (status/overview/send resolve), a slow background sweep with the tower startup can hang unbounded and unlogged in killOrphanedShellpers, tripping the 30s launcher timeout (field report on 3.3.3) #1685 bounding discipline, or both. Any sweep must stay presentation/hold-only per (1).
afx workspace recoverequivalent for architects. Today it revives only builders. The field recovery that worked, worth building toward and documenting:afx workspace add-architect --name <same-name>then re-init — builder→architect affinity survives (builders keep their Owner), so same-name re-add restores routing with no builder disruption.
Docs note
The afx skill had no entry for recreating/restarting an architect (reporter had to discover workspace add-architect / remove-architect from --help). Being fixed directly in the skill docs alongside this filing; noted here for completeness.
Related: #1714 (registry-vs-substrate consistency check) is the audit-side complement; this issue is the runtime-liveness side.
Activity
docs(afx skill): architect lifecycle — add-architect/remove-architect…
amrmelsayed commentedon Sep 21, 2026
Correction from the reporting workspace, plus a codev-side model correction. This reshapes the issue - read before working it.
Retracted by the reporter (inference had been written up as observation):
Codev-side correction (mine): the body's 'reconcile runs at Tower boot only' was incomplete. The on-read reconnect path in getTerminalsForWorkspace() deletes a row whose reconnect fails AND whose pid is provably dead - the pid-dead delete that PR #1693 deliberately preserved while forbidding live-pid destruction. That is almost certainly the pruning the reporter observed, and it means dead rows are cleaned lazily on the next read that touches them, not only at boot.
What still stands, re-verified by the reporter:
Revised scope for this issue:
Title updated to match.
[-]Dead agents look alive: boot-only reconcile serves stale registrations for days and afx send reports '[ok] delivered' to a dead architect[/-][+]architect liveness: characterize dead-architect visibility and send behavior (prior claims partly retracted); architect table pid=0; no architect recover command[/+]amrmelsayed commentedon Sep 21, 2026
Specimen from the reporting workspace: the four deaths were ONE simultaneous event at a sleep/wake boundary — this re-corrects the premise (including their own earlier 'died individually over two days', which was a sampling artifact).
Their observations, verbatim in substance:
pmset -g logrecordsDarkWake from Deep Idle [CDNP] ... Using BATT, going FullWake at 05:07:25. The surviving architect logs on.Codev-side annotations:
ps -o pid,ppid,tty,lstartfor BOTH the shellper and the child, plus shellper socket paths; sleep on battery into Deep Idle; wake; then check shellper liveness and child liveness SEPARATELY. That distinguishes 'shellpers die at wake' from 'children die at wake' and tests the PPID discriminator with the measurement the field specimen lacked.The characterization experiment in the revised scope should absorb this repro — it is now the highest-value run on the issue.
amrmelsayed commentedon Sep 21, 2026
Cross-workspace evidence from the same machine and the same event (one Tower serves every workspace here), plus source verification of the reporter's two facts.
Reporter's new hard facts, accepted: the 05:07:22 event killed 4 of 5 architects and ZERO of 8 builders in their workspace; Tower (the shared parent, up 3d16h spanning the event) survived; orphan-vs-parented does not predict outcome (PPID=1 processes both died and survived). Parent-death cascade and blunt-sweep models are dead.
New facts from this side, same machine, same instant:
Tower was passive. tower.log at the wake instant (UTC 2026-09-19T19:07:22) shows exactly: two SSE clients removed (dead), the cloud tunnel websocket closing (code 1006) and reconnecting 5 s later - and NOTHING else. No terminal closes, no kills, no errors. The terminal partial monitor reports the same session count (42) immediately after the instant and for the following minutes. Whatever killed those four processes, it was not a Tower-initiated closure.
Another workspace's architects all survived the same event: five architects (created 08-18 and 09-02, i.e. long-lived), every one of them PPID=1 / orphaned to launchd - the same shape as the reporter's survivor. Across both workspaces, every long-orphaned architect survived and only the reporter's recent, current-Tower-era architects died. The characterization run should treat AGE/orphanhood-at-event-time as a candidate axis alongside host.
Schema conflation CONFIRMED in source - tower-instances.ts:659-660 passes shellperInfo.pid as BOTH the pid and shellper_pid arguments to saveTerminalSession, so the CHILD pid is never persisted anywhere. The reporter is right that 'record shellper and child separately' cannot be satisfied from the DB; the run needs ps snapshots walking children of the Tower pid at capture time.
The hosting-path axis is real in source: architect spawn tries shellper first and falls back to a NON-PERSISTENT bare PTY (a direct Tower child) with only a tower.log WARN - tower-instances.ts:712/765 (main architect) and 1123/1279 (add-architect). The reporter's freshly recreated architect showing PPID=Tower matches the fallback shape. No 'non-persistent' WARN appears in the current tower.log window, which is its own puzzle - the run must record, per architect, WHICH path actually fired (shellper socket present + start_time populated vs bare PTY), not assume from role.
The UI-host hypothesis is consistent with (1): the SSE drops at the instant ARE clients (editor windows / dashboards) going away at wake. No close-on-client-disconnect logic was found in the terminal server on first inspection, but absence-of-finding is not absence - if the run shows dead architects were exactly the UI-pane-hosted ones, that code path gets a targeted hunt.
Instrument list for the characterization run, consolidated: per architect and builder BEFORE sleep - ps -o pid,ppid,tty,lstart for shellper AND child (walk Tower's children), shellper socket path presence, spawn path (WARN present or not), terminal HOST (UI pane / dashboard / headless), age and orphan status. Sleep on battery to Deep Idle; wake; re-snapshot; correlate. One run with those columns should separate the surviving hypotheses (host-death, hosting-path, age/orphanhood) in a single pass.
amrmelsayed commentedon Sep 21, 2026
Weighting correction from the reporter (their fourth, self-caught): the claim 'PPID=1 processes both died and survived, so orphanhood does not predict outcome' is WITHDRAWN in its died-half - the six surviving builders' PPID=1 was observed, but the dead architects' PPID=1 was inferred from their cohort timestamp (one 09-17 09:02:45 batch), never measured, and is now unrecoverable (processes gone, rows pruned; no shellper artifacts under ~/.codev/run were touched in the 05:06-05:09 window - which also independently corroborates the passive-Tower reading above).
Revised hypothesis ranking for the characterization run, per the reporter and concurred with here:
The instrument list in the previous comment already separates all three in one run; nothing about the experiment changes - only what we expect it to find.