T-UU2N-live-session-states-and-status-hooks-sessionnote-session
State: closed/done · Impact: high · Complexity: large
Neither the Router (M-27ZR) nor session list/session attach (P6’s
T-QMGC) has anywhere to record which host, harness and session id serve a
given lease, or whether that session is running, waiting for input, or gone.
simple-dispatch-interfaces.html’s Session note and registry / Status signals
sections design this as SessionNote, a SessionRegistry, and hook-driven
status — the single biggest new capability this fold-in brings in.
Approach
Section titled “Approach”- Define
SessionState = 'running' | 'waiting_for_input' | 'gone'and theSessionNoteshape (lease,host,target,harness,sessionId,startedAt,state) per simple-dispatch-interfaces.html’s SessionNote section. - Implement a
SessionRegistry(get/put/drop/list/reconcile) storing one JSON note per lease. - Add status hooks per harness (Claude Code hook events; Codex/Cursor equivalents
where available) that update a note’s state on turn-start/turn-end/needs-input,
per the Status signals section; fall back to host-level polling (e.g. Orca’s
tui-idle) when no hook fires. - Wire the registry into
session list/session attach(T-QMGC) so they read live state from it instead of querying each host directly. - Implement the reconciliation-on-startup steps (re-find handles by worktree/tag,
adopt unambiguous matches, prefer latest
lastOutputAton ambiguity, mark gone otherwise).
| Area | Note |
|---|---|
solutions/ontological/lib/services/host/session-note.ts | New: SessionState, SessionNote, AgentStatus/StatusEvent, the status→state reducer, the hook-reporter entry point |
solutions/ontological/lib/services/host/session-registry.ts | New: SessionRegistry (get/put/drop/list/reconcile), storage under .sdlc/dispatch/sessions/ |
solutions/ontological/lib/services/host/contract.ts | New optional find part (FindQuery/FoundSession), for reconciliation |
solutions/ontological/lib/services/host/hosts/{orca,tmux}.ts | find implementation |
solutions/ontological/lib/services/lease/ | Read-only: notes key off taskLeaseRef(taskId), the existing lease-ref builder (@lib/services/lease) — no new lease-package code |
solutions/ontological/lib/services/session/ops/launch.ts | Writes a note on interactive launch (AC-1) |
solutions/ontological/lib/services/session/ops/list.ts | Reads live state from the registry for display |
docs/planning/notes/N-UJFF-hosts-agent-status.md | Source for hook-vs-poll status detection |
Acceptance criteria
Section titled “Acceptance criteria”- AC-1 (refined — scoped to interactive launches, which is the only case
with a
HostNameto note; a headless run has no open host session forHost.sendto ever reach, so it gets no note): opening an INTERACTIVE session on atask/<id>-branched worktree writes a SessionNote with the correctlease/host/harness/state (running). A launch off atask/*branch (no lease to serve) writes no note — not a failure, nothing to key it on. Verified:session/launch.test.ts’s “SessionNote on interactive launch” describe block. - AC-2 (refined — “live smoke test” replaced per this campaign’s no-real-process
testing rule): the reporter entry point a real hook would invoke, called with
a fake hook payload for at least one harness, transitions a note between
runningandwaiting_for_input— no real claude/codex/pi process is started. Verified:host/tests/session-note.test.ts’sreportStatusEventrunning→waiting_for_input→running cycle viaclaudeHookStatus/parseClaudeHookPayload. - AC-3 (refined for objective verification, and to match this codebase’s
HostRegistry/Hostshape rather than interfaces.html’s aspirationalHarnessRegistry, which does not exist here): given a reconcile pass whose injectedhosts.findfakes report the noted target gone and, on a second call, a single unambiguous live replacement match, the registry adopts the replacement and the note’s state updates fromgoneback torunning— simulating “restarted host process” via the fake rather than an actual restart. Verified:host/tests/session-registry.test.ts’s gone→running restart-recovery cycle.
Out of scope
Section titled “Out of scope”- the Router’s use of session state to decide delivery (
T-BT9H) - PR-subject leases (
T-KMPU)
Dependencies
Section titled “Dependencies”T-GG0NT-CPJI
Depends on
Section titled “Depends on”T-GG0N, T-CPJI