Skip to content

feat(guard): Windows lifecycle partial parity — Job Object + CTRL events (#10)#75

Merged
ernestprovo23 merged 1 commit into
mainfrom
feat/issue-10-windows-guard-parity
Jun 29, 2026
Merged

feat(guard): Windows lifecycle partial parity — Job Object + CTRL events (#10)#75
ernestprovo23 merged 1 commit into
mainfrom
feat/issue-10-windows-guard-parity

Conversation

@ernestprovo23

Copy link
Copy Markdown
Member

Summary

  • Spawns child with CREATE_NEW_PROCESS_GROUP on Windows so CTRL_BREAK_EVENT targets only the child's console group
  • Job Object with JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE: child tree is reaped when guard exits (even unexpectedly); best-effort — logs degradation if unavailable
  • _teardown_windows upgraded to async: CTRL_BREAK_EVENTTERM_GRACE_S wait → proc.terminate() fallback (replaces terminate-only)
  • Updated DEGRADED_GUARANTEES: reflects partial parity — signal forwarding is now approximate, orphan-freedom not asserted only when Job Object is unavailable

Test plan

  • tests/test_guard_windows.py: 22 new tests cover _win32_send_ctrl, _win32_create_and_assign_job, win32_register_child, win32_release_child, _teardown_windows (all async paths), teardown_child routing
  • All tests run on macOS via mock ctypes injection (create=True patch)
  • Full suite: 524 passed, 4 skipped — zero regressions
  • Closes Windows guard parity — process groups + signal model #10

Closes #10

🤖 Generated with Claude Code

…nts (mcp-warden#10)

Upgrades Windows guard teardown from terminate-only to a proper best-effort model
aligned with GUARD_PROXY_V3.md §3.2:

- Child spawned with CREATE_NEW_PROCESS_GROUP so CTRL_BREAK_EVENT targets only
  the child's console group, not guard itself.
- win32_register_child(): assigns child to a Job Object with JOB_OBJECT_LIMIT_
  KILL_ON_JOB_CLOSE immediately after spawn so the child tree is reaped when
  guard exits (even on unexpected exit). Best-effort — logs debug note if unavailable.
- win32_release_child(): closes the job handle explicitly on normal exit; still
  fires KILL_ON_JOB_CLOSE passively on guard crash.
- _teardown_windows() upgraded to async: sends CTRL_BREAK_EVENT (approximate
  SIGTERM), waits TERM_GRACE_S, falls back to proc.terminate() if child persists.
- DEGRADED_GUARANTEES updated to reflect partial parity; orphan-freedom still
  not asserted when Job Object is unavailable.
- 22 new unit tests in tests/test_guard_windows.py cover all helpers + teardown
  paths; run on any platform via mock ctypes injection.
- Full suite: 524 passed, 4 skipped (no regressions).
@ernestprovo23 ernestprovo23 merged commit 8009937 into main Jun 29, 2026
9 checks passed
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.

Windows guard parity — process groups + signal model

1 participant