Skip to content

emrg: isolate stop_daemon in test_stop_all_process_residual_still_aborts (⛔ host red line) - #889

Merged
argszero merged 1 commit into
masterfrom
feature/stop-all-test-isolation
Aug 20, 2026
Merged

argszero merged 1 commit into
masterfrom
feature/stop-all-test-isolation

Conversation

@argszero

Copy link
Copy Markdown
Owner

Fix a ⛔ host-red-line violation (host directive 2026-08-18T22:58): running the full pytest suite killed the real local emrgd twice (2026-08-20 16:18/16:25) because test_stop_all_process_residual_still_aborts called _stop_all.stop_all() without isolating stop_daemon — stop_daemon() really connects to ws://127.0.0.1:56031 and sends shutdown to the running daemon.

Fix

tests/test_stop_all.py line 677 test: add

monkeypatch.setattr(_stop_all, stop_daemon, lambda: None)

with a ⛔ red-line comment explaining why (matches the file's existing isolation convention — the other two stop_all() tests already do this).

Audit (rant acceptance item 2)

  • All 3 _stop_all.stop_all() test call sites (lines 656 / 681 / 968) now isolate stop_daemon
  • test_scheduler.py sched.stop_all() = TaskScheduler method (stops handler coroutines, NOT the daemon process) — safe
  • test_installer_stop.py = static source analysis, never executes stop paths — safe

Verification

  • pytest tests/test_stop_all.py::TestIndependentLockProbe → 10 passed, 0.28s, no shutdown triggered
  • Full uv run pytest tests/ → 980 passed + 1 skipped, daemon stays alive after the suite
  • import + CLI OK

…rts (⛔ host red line)

The test called _stop_all.stop_all() without monkeypatching stop_daemon,
which REALLY connects to ws://127.0.0.1:56031 and shuts down the running
emrgd — observed twice on 2026-08-20 16:18/16:25 (emrgd.log 'shutdown
requested by client (source=stop_all)') while running the full pytest
suite. The other two stop_all() tests in the file already isolate
stop_daemon; this one was the missed spot.

Fix: add monkeypatch.setattr(_stop_all, 'stop_daemon', lambda: None) with
a ⛔ red-line comment, matching the file's convention. Full-suite audit
confirms no other un-isolated stop_all()/stop_daemon() real-execution
tests remain (test_installer_stop.py is static source analysis; scheduler
stop_all() stops handler coroutines, not the daemon).

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 1 (single-file ⛔ red-line fix: stop_daemon isolated in the missed test, matching file convention; full-suite audit confirms no other un-isolated stop paths; pytest 980 green with daemon alive; test + test-windows CI PASS)

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 2 (independent re-review: single-file change adds stop_daemon monkeypatch isolation to the missed test, matching the same-file convention; ⛔ red-line comment documents the 2026-08-20 16:18/16:25 real-daemon kill evidence; test + test-windows CI PASS)

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 3 (re-review: head 4b4201c unchanged, single-file ⛔ red-line isolation fix consistent with file convention; test + test-windows CI PASS, mergeable CLEAN)

@argszero
argszero merged commit d9df81d into master Aug 20, 2026
2 checks passed
argszero added a commit that referenced this pull request Aug 20, 2026
…ails loudly (⛔ red line backstop) (#890)

The 2026-08-20 16:18/16:25 incidents killed the live emrgd twice because
tests/test_stop_all.py:677 lacked stop_daemon isolation. PR #889 fixed the
specific leak; this adds the definitive anti-regression layer: an autouse
conftest fixture replaces emrg._stop_all.stop_daemon with a raiser so any
future test that triggers a real stop path fails with AssertionError instead
of killing the daemon. A canary test verifies the guard stays installed.
Agent.md pytest count synced 981 -> 982.

Co-authored-by: EMRG Evolution <emrg@argszero.dev>
argszero added a commit that referenced this pull request Aug 20, 2026
Co-authored-by: EMRG Evolution <emrg@argszero.dev>
@argszero
argszero deleted the feature/stop-all-test-isolation branch August 23, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant