← Back to Pull requests

End processes a mutant's tests fork #1066

Closed
unknown closed this pull request without merging on Nov 12, 2026 19:04 UTC
View on GitHub
unknown unknown commented on Nov 11, 2026 21:59 UTC
Author

Part of #872

A test that starts Workers through LoadGenerator.mp_run leaves them behind once per mutant. mutmut ends a mutant's run with os._exit or a kill, which skips the exit hook that stops daemon processes. Each stranded Worker is small, so the per-mutant memory cap from #1035 never trips. They pile up until the runner dies with "The hosted runner lost communication with the server" and no summary. #946 hits this on every run because it changes test_runtime_metrics_wiring.py, which has an mp_run test.

Now a process a mutant's test forks, and a Python process it starts along with what that one forks, is killed when its parent exits. That reaches Workers, which the multiprocessing forkserver forks. The stats run and the clean run are left alone.

Changes:
A mutation_orphan_guard module in the harness directory sets PR_SET_PDEATHSIG to SIGKILL when MUTANT_UNDER_TEST names a mutant. A before-fork hook notes the parent's pid, so a child whose parent already left exits on its own.
The mutation_child_hits plugin's at-fork hook calls the guard, which covers what a test forks itself.
The harness directory's sitecustomize.py runs the guard in every interpreter started under a mutant. The forkserver starts by exec and runs no fork hook, so this is what arms it and each Worker it forks.
A test that starts a sleeping process through fork and through forkserver and leaves through os._exit(1). The process is gone within 5 s under a mutant and still alive under the stats run.

  • One paragraph under Wall time in docs/mutation_testing.md.
  • Linux only. Elsewhere prctl is missing and the guard does nothing. A program that is not Python is not covered.

    Failing on main:

    E       AssertionError: assert False
    E        +  where False = process_ended(622973, 5)
    

    A local ratchet run for #946 on main left 266 of these processes holding 18.6 GB. The same run on this branch left none.

    pdm run validate and pytest tests/required/scripts/test_check_mutation_regression.py ran clean.

    Diff: 255 lines (+191 / -64) across 3 files Reviewer: rishabhsinha17 Review duration: 1264m
    All Vouch review confidence checks passed
    Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 255 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.332
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1066"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.1% (MEDIUM) · Higher = larger blast radius
    39.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.4% · Safe to merge
    15.4%