Skip to content

Unload finished scopes and prevent PID reuse collisions - #1910

Merged
JacobStephens2 merged 14 commits into
mainfrom
issue-1895
Nov 10, 2026
Merged

JacobStephens2 merged 14 commits into
mainfrom
issue-1895

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

Closes #1895.

 scope command ends
   sweep surviving processes
   inspect OOM evidence
+  release owner → stop its empty systemd unit

-thirdshift-<kind>-<pid>-<counter>-<detail>.scope
+thirdshift-<kind>-<pid>-<counter>-<random128>-<detail>.scope

Session, Trial and Grader owners unload retained empty units without relying on manager notifications. Already-collected units are silent, including collection racing with stop. Borrowed Trial membership retains its owner; survivor handling, memory caps and --collect are preserved.

Evidence

Execution evidence

Reproduced at the supplied merge base, 02c96545737cbd35efb69dd1ef93594f218ba9f2, in a detached worktree. Only the branch's unchanged regression file and its test-module declaration were added there; production code stayed at the merge base. The fake manager successfully runs the command, requires --collect, reports no processes, and retains the empty unit until explicitly stopped. No host systemd state was changed.

Commands used CARGO_BUILD_JOBS=2 and CARGO_TARGET_DIR=/tmp/thirdshift-1895-repro.ZTQmtu/target. The baseline package was cleaned before rebuilding the Issue branch to prevent reuse of baseline build artifacts. After results are from branch head f12ba6fba17bbdc11fe8bb0efbd364455b7a3e45.

  • Before: cargo test --manifest-path /tmp/thirdshift-1895-repro.ZTQmtu/baseline/Cargo.toml --bin thirdshift scope::lifecycle_tests::finished_scopes_are_unloaded -- --exact --nocapture
    failed with finished Session scope remains loaded: thirdshift-session-1078883-0-harness.scope and 0 passed; 1 failed.
    After: the same test, cargo test --bin thirdshift scope::lifecycle_tests::finished_scopes_are_unloaded -- --exact --nocapture, passed: 1 passed; 0 failed, checking Session, Trial and Grader disposal.
  • Before: cargo test --bin thirdshift scope::lifecycle_tests::reused_pid_and_counter_do_not_reuse_unit_names -- --exact --nocapture in the baseline worktree failed with PID reuse must not collide with a retained unit; both names were thirdshift-session-1079746-0-harness.scope (0 passed; 1 failed).
    After: the identical command on the Issue branch passed: 1 passed; 0 failed.
  • cargo test --bin thirdshift scope:: -- --nocapture: 9 passed; 0 failed, including already-gone units, collection racing stop, cap arguments and OOM evidence retained until owner disposal.
  • cargo test --bin thirdshift evals::experiment::execution::tests::scope_cap_evidence_preserves_explicit_voids_and_unexplained_kills_fail -- --exact --nocapture: 1 passed; 0 failed. Scope cap-kill evidence still produces a Void Trial with memory_cap; explicit Void causes and unexplained-kill failures remain intact.

Confirmed cause: scope owners left disposal entirely to manager collection; PID plus a restarting counter could then collide with a retained unit. The regressions exercise session_command, trial_command and grader_command through shared process supervision against isolated fake systemd commands.

The exact head's Rust, Console and site CI passed. This Continuation needed no source changes; successful exact-head full-suite CI was reused per docs/testing.md rather than repeated locally.

Review coverage

Independent thirdshift-code-review against refs/remotes/origin/main, pinned at 84c5856e6846f5c1f6cd8c1c80722341e2e267bf: Standards 0 findings, Spec 0 findings. Both reviewers fully read both changed files, src/scope.rs and src/scope/lifecycle_tests.rs. Unread changed files: none. Generated-output exclusions: none. Reports, each axis's final files-read list, finding counts and reproduction notes are retained in this Session's .thirdshift-review-vXiIWx/ directory.

Unaddressed findings

Standards

None.

Spec

None.

Security review outcome

No unaddressed introduced findings.

Merge Danger

Door: two-way

Reverting restores the earlier behavior. Existing leftover host units require separate operator cleanup.

Blast Radius: Execution

Scope disposal affects Session, Trial and Grader completion. It stops empty owned scopes after existing survivor handling and OOM inspection. Disposal errors produce warnings without changing command outcomes.

Built with codex codex-cli 0.164.0 · gpt-6.1-sol · xhigh

…/actions/runs?head_sha=362c2018c07cdafb1d941ad48f3a80e4c922d2eb&per_page=100 failed: gh: API rate limit exceeded for user ID 53905376. If you reach out to GitHub Support for help, please include the request ID D810:105010:1393FFE:3E7768B:6AF260DB and timestamp 2026-11-10 00:10:03 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) (HTTP 403))

2026-11-10T00:10:04Z, host dev.etadventures.com. Uncommitted work at the time of failure is included in this commit.
@JacobStephens2
JacobStephens2 marked this pull request as draft November 10, 2026 00:10
@JacobStephens2
JacobStephens2 marked this pull request as ready for review November 10, 2026 18:15
…/actions/runs?head_sha=07c8c5a201bba001c14c84ac0ea490c62ffdc162&per_page=100 failed: gh: API rate limit exceeded for user ID 53905376. If you reach out to GitHub Support for help, please include the request ID AAAC:2BCE1:DCEF4E:2AF6BD0:6AF37848 and timestamp 2026-11-10 20:02:16 UTC. For more on scraping GitHub and how it may affect your rights, please review our Terms of Service (https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) (HTTP 403))

2026-11-10T20:02:16Z, host stephens. Uncommitted work at the time of failure is included in this commit.
@JacobStephens2
JacobStephens2 marked this pull request as draft November 10, 2026 20:02
@JacobStephens2
JacobStephens2 marked this pull request as ready for review November 10, 2026 20:59
@JacobStephens2 JacobStephens2 added the in-progress A Claim: thirdshift has taken this issue label Nov 10, 2026
@JacobStephens2 JacobStephens2 removed the in-progress A Claim: thirdshift has taken this issue label Nov 10, 2026
@JacobStephens2
JacobStephens2 merged commit d6bee52 into main Nov 10, 2026
16 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-1895 branch November 10, 2026 23:02
This was referenced Nov 11, 2026
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.

Scopes systemd fails to unload stay loaded and block later scopes of the same name

1 participant