#177c: observe claude liveness server-side, instead of announcing it from the launch line #195
No reviewers
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lz/agent-nexus!195
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/session-exit-reporter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fourth of the #177 stack. Stacked on
feat/fleet-sse(#193) — merge #188, #192, #193 first or this will not compile.What this fixes
checkSessionHealthhas exactly one caller,GET /api/workers/:id/sessions/:sid/health, and only a browser polls it. So with no browser open, Nexus never learned that a session's claude had died. #177 closed that hole for workspace state; it was still open for sessions, and it is the same hole MCP exists to be on the other side of.The plan changed, and why
#177c was specified as
nexus-report-exit: a reporter on the launch line posting to a new/api/agent/session-exit. Two measurements against the installed claude 2.1.278 (not the docs) took its justification away, and a third showed it was the wrong instrument:SessionEndis not graceful-exit-only.shutdown(e = 0, n = "other", r)awaitsexecuteSessionEndHooksbeforeforceExit, and SIGTERM (143), SIGHUP (129) anduncaughtException(1) all route into it. Driven end to end: a realclaude --printSIGTERM'd mid-run exits 143 and emits{"hook_event_name":"SessionEnd","reason":"other"}, which the plugin's existing matcher already accepts. SIGKILL is the negative control — nothing fires. The uncovered set is SIGKILL/SIGSEGV/OOM, not "a crash".waitForClaude's poll; two of its four call sites wait for claude to be present, which a reporter cannot answer, and the other two go throughrespawn-window -k, which the spec itself says kills the wrapper. Net saving: zero.; exec bash. Convergence is keyed on the window. Measured, the report also never fires forrestartSession(both actions),closeWorkspaceSession,openWorkspaceSessiononto an existing window,deleteSession, container stop, or tmux server death.The wrapper is still a defensible latency optimisation for the SIGKILL set. It is filed as #194 with every measurement attached, including the three things it must get right.
What shipped instead
Liveness as an observation, taken in the exec pass
convergeSessionsalready makes:probeLiveClaudeCwdsisprobeClaudeCwd's walk with the cwd filter removed and the directory echoed — one exec answers every session of a workspace instead of one each. Session cwds are unique by construction, so the set maps straight onto rows. The self-match immunity is unchanged and never depended on the filter that went: the probe's own cmdline begins/bin/sh, which theclaude|test rejects.sessions.claude_alive(migration 0023, unclaimed on every branch in the stack) is NULL until observed. A failed exec writes nothing — uncertainty must not assert absence, the rule the worktree listing already follows.sessionMarkfolds the two sources inliveness(), probe first: the probe is fetched on demand and is seconds old, the observation can be a resync interval behind. The observation is consulted when there is no probe, and when the probe says'unknown'— that it could not look.mcpSessioncarries it deliberately.mcpSessionis a field-by-field allowlist, so a new column reaches MCP only on purpose — and a caller with no browser open is exactly the caller for whom nothing else answers this.statusis intent;attention_stateis a report a crashed agent cannot send.No worker script, no new route, no
AGENT_CALLBACKSentry, no worker image release — so it works on every existing workspace the day it merges, which the wrapper by construction could not. It also covers a hung claude and the container-stop case. The cost is latency: bounded by the resync interval rather than immediate.Docs corrected in place
The false premise was written down in four places and would have been re-derived. Fact #26 now records what
SessionEndactually covers, with the signal-handler evidence; fact #15 loses its claim that a dying claude "closes a tmux window" (it does not —; exec bashis there so the pane survives, and that sentence is what made a reporter look like the missing edge); fact #5 gains the second/procwalk and why both keep theclaude|test; the fleet-status spec's Worker changes section is marked superseded rather than deleted, because the goal was right and the instrument was not.A note for whoever edits the parity suite
attention.test.ts's generated suite now has the observation as a dimension. The byte-for-byte promise holds only while BOTH inputs are unobserved, and a second generated block pins the probe-first precedence in both directions — the null-only suite could not see that, because it only ever passed null.Not done
Sessions are still not on the SSE stream. That is an explicit non-goal of #193, one commit below this, and needs a server-side session store plus a notify in the attention writer. This changes whether the answer exists with no browser open, not how fast it arrives; the SSE spec now says so where a reader would otherwise assume this closed it.