Skip to content

Recover managed child services - #27

Merged
kiroro123 merged 1 commit into
mainfrom
codex/managed-service-recovery
Jul 8, 2026
Merged

Recover managed child services#27
kiroro123 merged 1 commit into
mainfrom
codex/managed-service-recovery

Conversation

@kiroro123

Copy link
Copy Markdown
Owner

Summary

  • Persist NetShaper-owned child services under managed_services in the recovery manifest.
  • Record portal and mitmproxy process identity metadata immediately after launch, including PID, process create time, executable, argv, and ownership details.
  • Teach stale recovery to verify and terminate only matching NetShaper-owned portal/mitmproxy children before restoring firewall, shaper, plugins, and sysctl state.
  • Keep externally managed/verified portal listeners out of NetShaper-owned recovery state.

Why

If the NetShaper parent is killed with SIGKILL after starting the portal or mitmproxy, normal finally cleanup cannot run. Previous stale recovery restored firewall and shaping state but had no persisted child-process ownership data, so a managed service could survive the parent. This PR makes those child services recoverable while failing closed on owner or command identity mismatch.

Validation

  • .venv/bin/python -m coverage run -m pytest -q -> 372 passed, 5 skipped, 16 subtests passed
  • .venv/bin/python -m coverage report --fail-under=60 -> total 69.41%
  • .venv/bin/python -m coverage report --include='src/netshaper/core/session_plan.py' --fail-under=95 -> 98.63%
  • .venv/bin/python -m coverage report --include='src/netshaper/core/session_runner.py' --fail-under=95 -> 97.37%
  • .venv/bin/python -m coverage report --include='src/netshaper/core/portal_manager.py' --fail-under=85 -> 94.33%
  • .venv/bin/python -m coverage report --include='src/netshaper/core/elevated.py,src/netshaper/core/session_plan.py,src/netshaper/core/session_runner.py' --fail-under=80 -> 97.86%
  • .venv/bin/python -m ruff check .
  • .venv/bin/python -m mypy
  • .venv/bin/python -m bandit -c pyproject.toml -r src/netshaper

@kiroro123
kiroro123 marked this pull request as ready for review July 8, 2026 07:41
@kiroro123
kiroro123 merged commit dda4861 into main Jul 8, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant