0
Fork 0
mirror of https://github.com/zeronsh/comet.git synced 2026-11-16 18:57:19 +00:00

engine: a shut-down engine is freed (two holds kept its whole graph alive)

local_first's online_runtime_shutdown_stops_edge_workers_and_retires_the_graph
failed every time ("engine graph still reachable after shutdown + drop").
CI never ran it (scripts/ci/test-core.sh lists the engine tests it runs).
After shutdown + drop the doc host stayed at 2 strong references for good;
tracking every DocHost clone named both:

- The version-change hook (zeron_update::set_before_restart, c004d547c)
  is process-wide and captured the doc host and workspace strongly, so
  every engine ever assembled in the process stayed alive. It now holds
  them weakly and upgrades when it runs: only this process's live engine
  restarts it (the CLI never sets a hook), and with its graph gone there
  is nothing left to prepare.
- A cycle: the engine holds its plugins (sessions.set_plugins), the
  plugins' agents hold their host (EngineAgentHost, 564da4414), and the
  host holds the doc host, sessions and workspace. Plugins::shutdown now
  lets go of that host, as shutdown already breaks the sessions <-> doc
  host cycle. (The agents' sink holds the plugins weakly; left alone.)

Each alone still leaks (the test fails with either fix undone); with
both it passes, 5/5. A new restart_hook test (its own binary: the hook
is process-wide) shows the hook still prepares the running engine's
store and holds nothing after shutdown; with the old strong hook it fails.

The test's next check then failed on this Mac only: one `HEAD /` after
shutdown. lsof named the sender: the Zeron Engine already running on
the Mac, whose preview discovery probes this process's listeners (a
listener bound after shutdown got probed too). Not the engine under
test, so the counting edge leaves `HEAD /` out, as the client tests'
mock edge already does; the engine sends the edge no `HEAD /`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: zeronsh[bot] <346184242+zeronsh[bot]@users.noreply.github.com>
This commit is contained in:
Wing 2026-11-11 13:38:55 -07:00
commit 1a7dc2e49c
9 changed files with 117 additions and 4 deletions