Repository navigation
fix(disk-hygiene): release the clean session belt when no run is open - #11295
Conversation
Lane-Activity: work-resolve-issue/resolve-issue
Lane-Activity: pr-unblock/fix-ci
…-hygiene-clean-belt-run-scoped
…uard The owner-registry scan allows deletion only in the engine's lanes, and the belt's marker.unlink() in destructive_guard.py broke it (check-skills, test-bash, test-python). An ended marker now stays on disk and reads as no run; the next step that opens a run overwrites it. A scan refreshes the idle clock only of an open run, so a timed-out or corrupt marker is not revived. clean-runs/ joins ENGINE_OWNED_DIRS, so no engine --output or --report can land on a marker. The safety model records the residual that a file write the belt does not see can end a run early. SKILL.md, README.md and the denial text restore the preview-to-apply span. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-review reviewed Incremental review of d28dbd6, which changes What changed. What I checked, by reading the code. I did not run the tests.
The guard comment block above No trusted-path files are in this incremental change. No cost or critical-security hold applies. |
|
claude-security-review reviewed No security issues found in the incremental change (since 0f03ee0). I read
Manifest fields: not touched. No spend beyond prepaid or subscription usage. No hold. critical-findings: 0 |
|
The pr-verify verifier failed head What it wrote (37 lines)This pull request leaves the merge queue, and ci-status holds it out while it carries |
…he run ends The guard left an ended marker on disk, which the #6377 criteria rule out: the run-end paths delete clean-runs/<session>.json, and a marker past the idle timeout is deleted. The engine now does both in close_clean_runs: after apply or handoff-apply writes the report the marker names, after a preview of the marker's plan ends in manual-handoff-lane or blocked, and on every engine call for any marker past the idle timeout. It removes only regular *.json files in clean-runs/; the guard still deletes nothing. close_clean_runs joins the owner-registry DELETERS set beside the temporary file writers, with a pin that it removes only clean-runs markers. The preview's <plan>.run-end.json end file is gone, and the belt reads only the marker's age. Refs: #6377 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n-belt-run-scoped-d13
…en run With disk_hygiene_enabled false and no open run, the belt release ran before the audit-only verdict was used, so a PowerShell deletion spelling the kill switch denies, and a Bash rm, fell through to the session's own permission rules. _belt_released now takes the kill switch and never releases while it is off, on both lanes. The safety model, SKILL.md, README and changelog fragment say so. Refs: #6377 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…no run "Audit-only" names the disk_hygiene_enabled=false mode, but the changelog fragment's headline, the README belt paragraph, the safety model and a guard comment also used it for a scan with no preview. The fragment now says the fix covers a scan-only /disk-hygiene:clean with execution enabled, and states plainly that with the kill switch off the belt keeps denying gh, git and test commands for the rest of the session. Refs: #6377 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A handoff-verify opens the manual lane with no end file, so only the idle timeout ends it. An allowed preview admitted afterwards rewrote the marker with its --plan as the end file, and when that preview ended in manual-handoff-lane or blocked the engine deleted the marker. The belt then stood down and a PowerShell Remove-Item ran with no ask, with no backdating involved. An apply or handoff-apply report closed it the same way. While a verify-opened run is open, the guard now only restarts its idle clock for a preview, apply or handoff-apply and never records an end file, so only the timeout ends the lane. An unreadable open marker counts as a verify's. New tests cover a terminal preview and a handoff-apply after a verify; both fail on the old guard. The safety model's run and residual paragraphs say so. Refs: #6377 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KeBVgcHpe4YpFuL5b24Ft2
Closes #6377
Replaces #11250
Hold: a human merges this
#6377 makes this line a done-when item: the change alters when a guard on destructive deletes restricts agents, which protects the host (standing direction §2 counts a host-protecting limit as safety, not friction).
Summary
Carries #11250's change: the
/disk-hygiene:cleanbelt denies only while a clean run is open, tracked by a per-session marker, instead of for the rest of the session. The engine deletes the session's markerclean-runs/<session>.jsonwhen the run ends, and deletes any marker past the idle timeout. The guard deletes nothing.Design notes:
preview, not atscan: the owner decided this on fix(disk-hygiene): release the clean session belt when no run is open #6377 (D13, option a, "go with a"). D13's wording hadscanwrite the marker, which cannot coexist with the criterion thatgh issue listis allowed after an audit-only run reaches its report: nothing the guard or engine sees at scan time tells an audit-only run from one that will execute (plugins/disk-hygiene/skills/clean/SKILL.md:346; the scan subcommand has no execution flag,plugins/disk-hygiene/lib/engine_grammar.py:208-244), and the audit-only end, the step-3 report, makes no engine call. A scan only restarts an open run's idle clock; the belt holds from the preview through apply.manual-handoff-lanepreview ends the run. Eachhandoff-verifyopens it again until the idle timeout, which keeps the belt'saskon the manual lane's PowerShell deletes.Fix
Ended markers stayed on disk (pr-verify): fix(disk-hygiene): release the clean session belt when no run is open #6377 requires that the run-end paths delete the marker and that a marker read past the idle timeout is deleted. The new engine function
close_clean_runsdoes both:applyorhandoff-applywrites the report the marker names;previewof the plan the marker names ends inmanual-handoff-laneorblocked;It removes only regular
*.jsonfiles inclean-runs/, and leaves other sessions' markers that name a different file. The guard still deletes nothing. The preview's<plan>.run-end.jsonend file is gone, and the belt now reads only the marker's age.Kill switch vs. belt release (security thread): with
disk_hygiene_enabledfalse and no open run, the release ran before the audit-only verdict, so a PowerShell deletion spelling and a Bashrmfell to the session's own rules._belt_releasednow takes the kill switch and never releases while it is off, on both lanes;test_kill_switch_off_denies_deletions_with_no_open_runfailed on both lanes before the fix. The safety model, SKILL.md, README and fragment say so.Owner-registry deletion check:
close_clean_runsjoins theDELETERSset intest_owner_registry.py, next to the temporary-file writers. The test's docstring sanctions that kind of edit: "Widening what a file may do is an edit to the constants above, in review." A new pin,test_the_run_closer_removes_only_clean_run_markers, checks that its only removal ismarker.unlinkoverclean-runs/*.json. A behavior test checks that an aged file elsewhere under the data root, and an aged non-.jsonfile inclean-runs/, both survive.test_no_shipped_file_deletes_names_the_registry_or_reaches_a_lanepasses.Security threads (model-writable run end):
clean-runs/is engine-owned state (engine_grammar.ENGINE_OWNED_DIRS), so an engine--outputor--reportcannot land on a marker. The belt matches only Bash and PowerShell, so a PowerShell command it does not read as a delete could still backdate the marker and end a run early.safety-model.mdrecords this as an accepted residual. A forged end reaches the same state a natural run end gives: the engine gate and the approval token still gate every engine mutation. If the owner wants this closed, the option is aWrite|Edit|NotebookEditmatcher that denies writes underclean-runs/.SKILL.md wording thread: the Gotchas bullet, the README and the belt's denial text cover the span from preview to apply.
The changelog fragment was generated by
scripts/new-changelog-fragment.shand now names engine-side deletion.Verification
Run locally on head f22bda0 through
scripts/run-test-file.sh:test_owner_registry.py: 25 passed.owner_registry.test.sh: 25 tests OK.test_hygiene.py: 757 passed, 3 skipped, 1065 subtests passed.hygiene.test.sh: 760 tests OK, 3 skipped.Red before the fix: the new and changed tests failed on the pre-fix engine (7 failed, 5 passed), as did the new owner-registry pin (1 failed, 24 passed). The failures were:
test_belt_holds_between_scan_and_apply_until_the_report_landstest_handoff_apply_completion_ends_the_runtest_terminal_preview_outcome_ends_the_run(manual-handoff-laneandblocked)test_engine_call_after_the_report_does_not_reopen_the_runtest_run_end_deletes_only_the_marker_of_the_run_it_endstest_engine_deletes_a_marker_past_the_idle_timeoutEach asserted that the marker file is gone after the engine step. All pass after the fix.
check-skill.sh plugins/disk-hygiene/skills: 4 passed, 0 failed.scripts/check-changelog-fragments.sh --check: all fragments valid.run-ruff.sh checkon the changed Python files: all checks passed.Related
do-not-merge)🤖 Generated with Claude Code