One function

StateWatcher in androsovm/clorch

The author described this change as Fix watcher fingerprint and shell hook subagent inconsistencies. It counts as a record because the check below fails on the code as it stood at 659ce87d1 and passes on b3e75ff4c, with nothing else changed between the two runs.

Fix saved2026-03-17
Sharing licenceMIT · LICENSE
Change size+1 1

What the code was meant to do, written into the code itself as a docstring

Polls *STATE_DIR* for agent state changes and invokes a callback. The watcher runs in a daemon thread so it is automatically cleaned up when the main process exits. Parameters ---------- on_change: Called whenever the set of agents or any individual state changes. Receives the full agent list and an up-to-date :class:`StatusSummary`. poll_interval_ms: Milliseconds between scans. Defaults to :data:`STATE_POLL_INTERVAL_MS` from config. state_dir: Override the directory to watch (useful for tests).

The change

126126 a.session_id: (
127127 f"{a.status.value}|{a.last_event_time}|{a.tool_count}"
128128 f"|{a.error_count}|{a.notification_message}"
129- f"|{len(a.subagents)}|{a.compact_count}|{a.task_completed_count}"
129+ f"|{len(a.running_subagents)}:{len(a.subagents)}|{a.compact_count}|{a.task_completed_count}"
130130 )
131131 for a in agents
132132 }

The check that tells the two apart

failpass·tests/test_event_handler_subagent.py::TestSubagentStart::test_empty_agent_id_does_not_increment_count

Check file tests/test_event_handler_subagent.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it659ce87d12baba19d466bae37d94418d37efbbe0
Broken version dated2026-03-16
Moduleclorch.state.watcher
Units changedStateWatcher
Fingerprint58a6e0b1d906ccb9
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in androsovm/clorch