Skip to content

emrg: test: harden stop_all hermeticity guard to all five killers (rant 2026-08-25T10:42:47) - #971

Merged
argszero merged 2 commits into
masterfrom
feature/test-stop-all-hermeticity
Aug 25, 2026
Merged

emrg: test: harden stop_all hermeticity guard to all five killers (rant 2026-08-25T10:42:47)#971
argszero merged 2 commits into
masterfrom
feature/test-stop-all-hermeticity

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Closes the ⛔ red-line test hole reported in rant 2026-08-25T10:42:47: on a Windows pytest run, tests/test_stop_all.py::test_stop_all_process_residual_still_aborts mocked is_win → True but only isolated stop_daemon — so stop_gui, stop_tui, stop_bundled_git and stop_lock_owners executed for real, killing the live EMRG GUI/TUI (and their process scans) on the host.

Changes

  1. tests/conftest.py — the autouse red-line guard _guard_stop_all_hermeticity (renamed from _guard_stop_daemon_hermeticity) now replaces all five stop killers (stop_daemon, stop_gui, stop_tui, stop_bundled_git, stop_lock_owners) with raisers, so any test that reaches a real stop path fails loudly with AssertionError instead of killing processes. Existing isolation pattern (monkeypatch.setattr(_stop_all, "stop_x", lambda: None)) still overrides it as before.

  2. Escape hatch — a new @pytest.mark.allow_real_stop("stop_lock_owners") marker opts a test out per function when it deliberately calls a stop function with its internal kill machinery already isolated. Applied to the two verified-hermetic direct-call sites:

    • test_posix_noop (is_win=False → early noop; _lock_owner_ps mocked)
    • test_stop_lock_owners_logs_diag (find_install_module_holders → [] + _lock_owner_ps mocked)
      Marker registered in pyproject.toml ([tool.pytest.ini_options]).
  3. tests/test_stop_all.py::test_stop_all_process_residual_still_aborts — the flawed test now isolates all five killers (mirroring test_stop_all_retries_lock_kill), so the Windows branch can never perform a real kill.

  4. CanaryTestStopAllHermeticityGuard is now parametrized over all five functions, verifying each guard raiser is installed (function-identity check only, never calls a stop path).

  5. Agent.md — documented pytest count 1052 → 1056 (net +4: 5 parametrized canaries − 1 old canary), satisfying the emrg: sync test counts to 484 + guard test against doc drift (recurs #426/#430/#510) #511 doc-count guard.

Verification

  • uv run pytest tests/ -v1055 passed, 1 skipped (1056 collected, doc-synced)
  • uv run python -c "from emrg.client.app import run_client" → OK
  • uv run python -m emrg --help → OK

No production code touched — emrg/_stop_all.py is unchanged (the Windows stop path is legitimate emrg stop behavior; the hole was purely test-side).

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle

Fresh review of the stop_all hermeticity fix (rant 2026-08-25T10:42:47):

  • tests/conftest.py: autouse guard now replaces ALL FIVE stop killers (stop_daemon/stop_gui/stop_tui/stop_bundled_git/stop_lock_owners) with raisers — matches the Windows 5-step _step_plan; any un-isolated real stop path fails loudly with AssertionError. The allow_real_stop marker opts out per function only for verified-hermetic direct calls.
  • tests/test_stop_all.py:770: the flawed Windows-branch test now isolates all 5 killers (mirrors test_stop_all_retries_lock_kill), closing the hole where stop_gui/stop_tui/stop_bundled_git/stop_lock_owners ran for real.
  • Escape hatch applied only to the 2 safe direct-call sites (test_posix_noop with is_win=False + _lock_owner_ps mocked; test_stop_lock_owners_logs_diag with both killers mocked).
  • Canary TestStopAllHermeticityGuard parametrized over all 5 functions (identity check only, never calls a stop path).
  • Marker registered in [tool.pytest.ini_options]; Agent.md count 1052→1056 syncs the #511 doc guard.

CI double-green (run 32803059504: test + test-windows both pass). Local verification: 1055 passed / 1 skipped, import + CLI OK. Production code untouched — the fix is purely test-side. No issues found.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle (2/3)

Head unchanged (06e79a0), CI double-green (run 32803059504: test + test-windows both pass), MERGEABLE. Re-verified the diff from cycle 105902: conftest guard replaces all five stop killers with raisers (matches Windows 5-step _step_plan), allow_real_stop escape hatch applied only to the two verified-hermetic direct-call sites, test_stop_all.py:770 now isolates all five (mirrors retries_lock_kill), 5-way parametrized canary, marker registered in pyproject, Agent.md count 1052→1056 syncs the #511 doc guard. No issues found.

…re/test-stop-all-hermeticity — resolve Agent.md pytest count 1056+2 → 1058

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

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

✅ LGTM — cycle (3/3)

Head unchanged since the last review (6cebd41, includes the master-merge conflict resolution — Agent.md pytest count merged to 1058), CI double-green (run 32804511105: test + test-windows both pass), MERGEABLE/CLEAN. Full diff reviewed across cycles 105902/111222: conftest guard on all five stop killers, allow_real_stop escape hatch, test_stop_all.py:770 full isolation, 5-way canary, doc-count synced. No issues found — merging.

@argszero
argszero merged commit 7d230d4 into masterAug 25, 2026
2 checks passed
Sign up for freeto 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

@argszero