Skip to content

Keep Command scratch under the user home and recover orphaned files - #2279

Merged
JacobStephens2 merged 9 commits into
mainfrom
issue-2278
Nov 18, 2026
Merged

JacobStephens2 merged 9 commits into
mainfrom
issue-2278

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

Give each Command private scratch under ~/.thirdshift/scratch/, shared by child Ticket runs. Sessions use TMPDIR there; Factory skills are extracted there too. Sandbox Sessions receive separate temporary subdirectories, mounted at /sandbox/tmp in sealed sandboxes.

Command starts → record owner + hold directory lease
  ├─ sessions and child Runs → Command scratch
  ├─ completed → remove scratch
  └─ paused / Recovery → retain until successful continuation or Dismissal
Next Command → remove proven dead local owners + verified legacy skills >2 days

Closes #2278.

Evidence

Execution evidence

  • Before: cargo test --test scratch sessions_and_factory_skills_use_command_scratch_and_success_removes_it -- --nocapture failed at the scratch-location assertion: "/tmp/.tmpnbqE4p/tmp".
    After: the same command passed for Claude and Codex; the complete scratch integration file passes 10 tests (2 fixture entry points ignored).
  • Before: cargo test --test scratch startup_reaps_a_killed_commands_scratch_but_never_a_live_commands -- --nocapture failed: orphan survived.
    After: the same test passes, including its live-owner preservation assertion and removal log.
  • Before: cargo test --test scratch recovery_keeps_scratch_until_a_successful_continuation_or_dismissal -- --nocapture failed: Recovery lost its scratch.
    After: the same test passes for successful continuation and Dismissal.
  • Before: cargo test --test scratch sandboxed_triage_uses_writable_command_scratch -- --nocapture failed with wrong TMPDIR and Harness exit 42.
    After: the same test passes using writable Command scratch.
  • cargo test --test experiments custom_runner::custom_runner_uses_command_scratch_without_the_sandbox -- --nocapture: passed.
  • cargo test --bin thirdshift prompts_page: 14 passed; npm run docs:check --prefix site: passed.
  • Spec review regression — Before: cargo test --test scratch_review_spec recommending_triage_does_not_discard_a_failed_runs_retained_scratch -- --exact --nocapture failed: recommendation-only Triage deleted the failed run's retained scratch, with the removal log.
    After: the exact command passes; retained scratch survives recommendation-only Triage. The regression is kept.
  • Startup interruption — Before: cargo test --test scratch sigterm_during_startup_removes_scratch_before_any_session_starts -- --exact --nocapture failed: SIGTERM during startup left scratch (left: 1, right: 0).
    After: the same command passes, before any Harness starts. The handler is installed before allocation.
  • RUST_TEST_THREADS=3 cargo test --test ci --test fresh_run --test mergeable: 72 passed, 6 fixture entry points ignored.
  • CLI ending — Before: cargo test --test pickup_run a_waiting_spec_is_passed_over_until_its_ticket_can_start_then_continued -- --exact --nocapture failed because cleanup displaced the final PR outcome. After: the exact command passes; retained cleanup is recorded only in the Activity log.
  • Cross-host fixture — Before: cargo test --test pickup_run delayed_selector_after_failed_winner_still_starts_only_one_run -- --exact --nocapture failed after 120 seconds: the agent never started. After: the exact command passes in 2.49 seconds with explicit fixture coordination; the full RUST_TEST_THREADS=3 cargo test --test pickup_run passes 154 cases (2 fixture entry points ignored).
  • cargo test --locked --test pickup_model -- --nocapture: 4 passed, 1 known-finding assertion ignored. Bounded claimed-dispatch safety passes; the existing documented pre-Claim counterexample remains. Reservation/Claim requests and ordering are unchanged.
  • Sealed summary privacy — Before: cargo test --test release summaries::every_configured_harness_gets_complete_release_evidence_in_a_toolless_sandbox -- --exact --nocapture failed with Broken pipe and no summary: mounting scratch at its host path exposed the host-home ancestor that the fake Harness checks is absent. After: the exact command passes for all seven Harnesses with the original privacy assertions intact; the sandbox sees /sandbox/tmp backed by Command scratch. cargo test --bin thirdshift sandbox::tests passes 30 tests, and cargo test --test experiments sandbox:: passes six.
  • Release fixture ordering — Before: cargo test --test release summary_calls_in_the_same_second_follow_execution_order_not_opaque_log_tokens -- --exact --nocapture failed with calls [second, first] instead of [first, second]. After: the exact command passes; the helper orders sequential summary Sessions by completed writes, keeping the Release recovery assertions intact. The original CI failure, cargo test --test release recovery::an_old_merged_bump_can_be_recut_with_a_new_bump_pr -- --exact --nocapture, also passed locally.
  • RUST_TEST_THREADS=3 /usr/bin/time -p target/debug/deps/release-ea016fa707ae5020: 150 passed, 3 fixture entry points ignored, 324.65 seconds; compilation excluded. This clean run replaces an invalidated Cargo run whose test executable was rebuilt concurrently.
  • Final CI succeeded at 9a41cc05: all four Linux x86 Rust partitions, exact test-coverage gate, formatting, clippy, Python tooling, site and Console browser tests. ARM follows the repository's main/nightly policy and was skipped on this PR.
  • Required local selection: CARGO_BUILD_JOBS=3 RUST_TEST_THREADS=3 /usr/bin/time -p scripts/affected-tests refs/remotes/origin/main. Site: 72 passed in 74.22 seconds. Cargo fallback: 1,974 unit tests passed (3 ignored), followed by passing integration cases; stopped the duplicate local suite after equivalent Rust and site CI passed for this exact head, as docs/testing.md permits. This is CI reuse, not a claim that the local full-suite run completed.

Test seams: real CLI Command/Session lifecycle with Scenario's fake Harnesses; the sandboxed Triage launch; the Custom runner Experiment CLI; native scratch allocation and guard lifetime in an isolated subprocess.

Visual evidence

The thirdshift PR skill requires: “Host PR-evidence media in a secret git-pushed Gist.” gh gist create failed with HTTP 404 because the configured GitHub token lacks gist scope. No media was uploaded; paired captures remain at these exact local paths and are copied beside the Session reports under .thirdshift-review-laVrhm/captures/.

Flow Viewport Before After
Manual 1440×900 /tmp/before-desktop.Rc3GpK.png /tmp/after-desktop.jzOdXy.png
Manual 390×844 /tmp/before-mobile.dVlgbZ.png /tmp/after-mobile.wXEgIN.png
Architecture 1440×900 /tmp/before-desktop.nbH0gT.png /tmp/after-desktop.Sbmpov.png
Architecture 390×844 /tmp/before-mobile.qmlSzd.png /tmp/after-mobile.6LAOD6.png
Home 1440×900 /tmp/before-desktop.o2KNqy.png /tmp/after-desktop.BWU0wm.png
Workflow 1440×900 /tmp/before-desktop.KOq2QX.png /tmp/after-desktop.CF0Yp1.png

Unaddressed findings

Standards

None. No findings skipped or declined.

Spec

None. No findings skipped or declined.

Security

None. No introduced findings.

Security review outcome

No unaddressed introduced findings.

Review coverage

Standards: 0 actionable findings. Spec: 1, fixed and verified with the reviewer’s exact reproducer. Both reviewers completed an initial pass and one coverage follow-up at 35e5004b (31 changed files read, 37 generated exclusions).

Later validation corrections are outside that completed pass. Final unread changes:

  • .agents/skills/pr/SKILL.md: new evidence recipe change.
  • skills/thirdshift-pr/SKILL.md: last evidence recipe adjustment; earlier hunks were read.
  • site/prompts/index.html: last regenerated evidence recipe adjustment.
  • tests/ci.rs: exact expected prompt strings updated for scratch guidance.
  • tests/fresh_run.rs: exact expected prompt string updated for scratch guidance.
  • tests/mergeable.rs: exact expected prompt string updated for scratch guidance.
  • src/scratch.rs: early interruption handling and Activity-log-only retained cleanup; earlier implementation was read.
  • tests/scratch.rs: new SIGTERM-during-startup regression; earlier tests were read.
  • tests/pickup_run.rs: fixture coordination separated from Session TMPDIR.
  • src/sandbox.rs: neutral sandbox TMPDIR alias backed by Command scratch.
  • src/sandbox/code_grader.rs: shared temporary-directory sandbox mount.
  • docs/guide.md: namespace alias clarification.
  • site/docs/index.html: regenerated namespace alias clarification.
  • tests/release.rs: same-second call-order regression and fixture ordering correction.

The code-review skill allows one coverage follow-up per axis and says remaining gaps are reported rather than retried. Coverage of all 74 final changed paths at 9a41cc05: 25 fully read, 35 unchanged confirmed generated exclusions, and the 14 paths above. Reports and each axis's actual final files-read list are retained with this Session in .thirdshift-review-laVrhm/standards.md, spec.md and summary.json.

The generated files below were intentionally not read. For the reviewed head, both axes reviewed their sources and generators: src/prompt.rs, src/prompts_page.rs, the affected embedded Factory skills, Harness arguments, docs/guide.md and site/generate-docs.mjs. Prompt parity/fence/escaping checks, manual regeneration checks and documentation browser captures passed; the prompt page's surrounding hand-written HTML is unchanged.

Every generated changed file intentionally left unread
  • prompts/architecture-review.md
  • prompts/bug-continuation-pr.md
  • prompts/bug-continuation.md
  • prompts/bug-fresh.md
  • prompts/ci-fix-repair-inherited.md
  • prompts/ci-fix-repair.md
  • prompts/code-review.md
  • prompts/conflict-repair.md
  • prompts/continuation-pr.md
  • prompts/continuation.md
  • prompts/fix-ci-repair.md
  • prompts/fix-conflict-repair.md
  • prompts/fix-review-repair.md
  • prompts/foreign-conflict-repair.md
  • prompts/fresh.md
  • prompts/grader.md
  • prompts/panel-grader.md
  • prompts/process-step-issue.md
  • prompts/process-step-later.md
  • prompts/process-step.md
  • prompts/pull-request-address.md
  • prompts/pull-request-ci-fix-repair.md
  • prompts/pull-request-review.md
  • prompts/pull-request-security-review.md
  • prompts/pull-request-validation.md
  • prompts/resume.md
  • prompts/review-repair.md
  • prompts/security-audit.md
  • prompts/security-fix.md
  • prompts/security-reproduction.md
  • prompts/security-review.md
  • prompts/spec-review.md
  • prompts/triage-correction.md
  • prompts/triage-issue.md
  • prompts/triage.md
  • site/prompts/index.html
  • site/docs/index.html

Merge Danger

Door: one-way

Cleanup deletes disposable files and verified old Factory extractions. Undoing a Dismissal cannot restore deleted scratch. Age, ownership, recursive layout checks, host/process identity and directory leases guard deletion.

Blast Radius: host

Commands on the same OS account share the scratch inventory. Repository skills and files outside Command scratch stay outside cleanup.

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

@JacobStephens2
JacobStephens2 marked this pull request as ready for review November 18, 2026 22:56
@JacobStephens2
JacobStephens2 merged commit 0f84bc7 into main Nov 18, 2026
25 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-2278 branch November 18, 2026 23:21
@JacobStephens2 JacobStephens2 mentioned this pull request Nov 19, 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.

Runs leave Factory skills and session scratch files in /tmp: 17 GB on stephens.page

1 participant