Skip to content

Add finalization-only cleanup gate for provisional scratch artifacts#314

Open
mmprotest wants to merge 1 commit into
mainfrom
mmprotest/add-cleanup-for-provisional-scratch-artifacts
Open

Add finalization-only cleanup gate for provisional scratch artifacts#314
mmprotest wants to merge 1 commit into
mainfrom
mmprotest/add-cleanup-for-provisional-scratch-artifacts

Conversation

@mmprotest

Copy link
Copy Markdown
Owner

Motivation

  • Prevent temporary files created by model-driven shell probing from lingering in the repo while avoiding changes to model behavior or verification flow.
  • Ensure cleanup is conservative, reversible, and executed only once after a successful verification pass.

Description

  • Add runner-owned provenance state: _provisional_scratch_candidates, _explicit_mutation_created_paths, and _cleanup_summary on the Runner to track Bash-created files and explicit Write/Patch-created files.
  • Capture provenance at the normal tool boundary by snapshotting repo files before/after Bash in execute_tool_with_lifecycle and adding newly-created files to the provisional set while recording Write/Patch created paths separately in state_tooling.py.
  • Implement cleanup_provisional_scratch_artifacts in state_runtime.py that conservatively filters eligible candidates (must be provenance-backed, regular file, inside repo, not explicit edits, not under source/test/pkg roots, root detection confident), backs them up, removes them, reruns existing run_validation, and restores files on any failure/error.
  • Invoke the cleanup exactly once in the finalization path (in _finish_bounded after run_post_execution_validation and before final summary write) and propagate cleanup telemetry into final_summary.json via DebugRecorder.write_final_summary without adding a new telemetry system.
  • Add focused tests in tests/test_scratch_cleanup_gate.py covering keep/restore, git untracked handling, exclusion of Write-created files, and source/tests exclusions.

Testing

  • Ran pytest -q tests/test_scratch_cleanup_gate.py and all tests passed (4 passed).
  • Verified the cleanup call site is singular with rg -n "cleanup_provisional_scratch_artifacts\(" villani_code, confirming the helper is invoked from exactly one final post-success location.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant