mirror of
https://github.com/l0ng-ai/tty7.git
synced 2026-09-22 00:02:23 +00:00
Three holes in the wait primitive, all of which make a delegation loop answer with something other than what it asked for. The agent status the server keeps is a level, not an event: `done` stands until the next turn begins, `waiting` until the agent moves again. A wait issued right after a `send` therefore returned last turn's state before the worker had even read the input, and a second task in the same pane matched `--until done` instantly. `--changed` snapshots the position the wait arrived at — status plus the activity counter, which ticks even when the status letter does not — and refuses to match it; the JSON carries `stale` so a plain wait can tell whether the answer might be a leftover. `exit` was unreachable for any pane that had ever had an agent: the snapshot has no liveness in it, and the daemon keeps a dead pane registered until it is closed. A worker that crashed mid-turn reported `working` until the timeout. Liveness is now re-checked from the tree every few polls; the fast path where the first poll already answers still costs exactly one request. The "pane exited before reaching the awaited state" branch built its JSON and then threw it away on an anyhow error, leaving `--json` with nothing to read and the exit indistinguishable from an unreachable daemon. It now exits 1 with its report. Also: the wire spelling of a state is written out instead of derived from the variant name, the sleep no longer overshoots a near deadline, an absurd `--timeout` cannot overflow, and `--interval` is range-checked at parse time rather than silently clamped.