12 Commits

Author SHA1 Message Date
roboomp 74e73debaf fix(launch): scope daemon prune to the daemons container
smokeTestDaemonBroker mkdtemp'd its runtime dir directly under
os.tmpdir(), and the broker's startup sweep pruneDeadDaemonRuntimeDirs
reclaims path.dirname(runtimeDir). On a default session that is /tmp, so
--smoke-test recursively deleted every aged sibling with no live
broker/clients (tmux/ssh sockets, editor state, build trees) while still
exiting 0.

- client.ts: keep the smoke broker's project and runtime dirs under a
  single private mkdtemp parent the process owns.
- presence.ts: refuse any prune root that is not the daemons container
  and only prune entries named like a 16-hex daemon scope key, so a
  relocated runtime dir can never rm -rf unrelated neighbours.

Fixes #8721
2026-08-16 11:50:00 +00:00
can1357 2dba883e08 fix(launch): preserved global daemon service runtimes 2026-08-16 02:43:31 +02:00
roboomp 0fc2b0f42c fix(launch): prune dead daemon runtime dirs on broker startup
~/.omp/run/daemons/<hash> scopes accumulated forever: broker shutdown
removed only the socket and PID lease, and nothing swept dead scopes, so
inert broker state and the persistent shared Chromium profiles grew
without bound (reporter: 1.3GB / 198 dirs in ~4 weeks).

Each broker now sweeps its sibling daemon roots on startup and removes a
scope only when its broker.pid is absent/dead, no live client presence
remains, and it has been untouched past a stale grace. The caller's own
runtime dir and the machine-global daemon container are skipped. The
sweep is detached and non-throwing so it never delays client connects.

Fixes #8674
2026-08-15 19:33:25 +00:00
can1357 b279db1790 test: refactored test suites to eliminate time-based sleeps and polling loops
- Replaced time-based sleeps and polling loops with event-driven promise resolvers and fake timers across agent and tool tests.
- Migrated test suites to share in-memory auth storage and fixtures using lifecycle hooks.
- Updated catalog model definitions, metadata, and configurations.
2026-08-13 19:32:22 +02:00
roboomp 39920d73a1 test(launch): move broker idle-shutdown regression into collected test tree
The coding-agent CI runner collects test files only from packages/coding-agent/test (scripts/ci-test-ts.ts), so the regression at src/launch/broker.test.ts was skipped by bun run test and CI.

Relocated to test/launch/broker-idle-shutdown.test.ts and rewrote it to the in-process broker pattern used by the sibling broker tests: it awaits the broker's own run() promise (resolves on idle shutdown) instead of watching the PID file, so shutdown is an awaited signal rather than a poll.

Fixes #8110
2026-08-09 23:55:51 +00:00
roboomp 5b3bed18b5 fix(launch): accepted empty daemon regex matches
Preserved zero-width readiness and wait matches across the daemon wire protocol, and isolated malformed completion events from unrelated pending RPCs.

Fixes #7908
2026-08-07 23:38:25 +02:00
Christian Stewart 302148523f fix(hub): wake owners when supervised processes exit
Publish terminal daemon completions to the session that started the
process so idle agents can resume without polling hub status.

Persist every unacknowledged generation with a stable completion ID and
immutable snapshot. Replay the collection after reconnect or broker
recovery, and clear each event only after the owning client acknowledges
it.

Signed-off-by: Christian Stewart <christian@aperture.us>
2026-08-03 01:31:39 -07:00
can1357 04fad069aa Merge PR #6853: fix(launch): treat restarting daemon as settled in broker #settle (@roboomp) 2026-07-28 10:59:35 +02:00
can1357 30512418c1 test(launch): restore kernel comm after in-process broker test
startDaemonBrokerFromEnvironment now sets the kernel-visible name via
prctl, so restoring only process.title left the test runner's
/proc/self/comm as "omp daemon brok" for the rest of the Linux run.
2026-07-28 10:58:59 +02:00
roboomp a0f353c561 fix(launch): rechecked daemon state after output read
A recovered detached daemon has no in-memory process handle, so two
concurrent refreshes can both enter settle for the same dead pid. The
initial guard runs before detached output is read; both continuations
could therefore pass it and then double-settle the generation.

Recheck generation and settled states after the awaited output read,
and cover concurrent refreshes against a recovered daemon. Without the
post-read guard the regression test observes restartCount 2 instead of
1.

Fixes #6852
2026-07-28 04:16:24 +00:00
roboomp 9d6eac0cb8 fix(launch): treat restarting daemon as settled in broker #settle
A detached restart:"always" daemon that exits quickly parks in the
`restarting` state with process/pid cleared and a restartTimer armed.
Every subsequent op ran #refreshDetached, which only skips terminal
states, so it fell through to a re-entrant #settle. #settle's guard
only checked generation and terminalState, so re-entry proceeded:
restartCount++ and record.restartTimer was overwritten without clearing
the previously armed timer, orphaning it.

Consequences: stop cleared only the last timer, so an orphaned timer
later fired #launch (resetting stopRequested) and resurrected the
daemon; and restartCount phantom-inflated on every list/logs poll.

Add `restarting` to #settle's entry guard: it is a settled state
(child exited, relaunch timer pending) and no legitimate caller settles
while in it. Closes both the timer leak and the count inflation.

Fixes #6852
2026-07-28 04:04:52 +00:00
can1357 d16a251777 chore: reorg tests 2026-07-27 16:43:53 +02:00