Skip to content

Redirect temporary root-level scratch files to .villani_code scratch storage#316

Open
mmprotest wants to merge 1 commit into
mainfrom
mmprotest/implement-scratch-file-redirection
Open

Redirect temporary root-level scratch files to .villani_code scratch storage#316
mmprotest wants to merge 1 commit into
mainfrom
mmprotest/implement-scratch-file-redirection

Conversation

@mmprotest

Copy link
Copy Markdown
Owner

Motivation

  • Prevent transient model-created verification scripts from polluting the repo root and final diffs by redirecting obvious scratch filenames to session-local scratch storage.

Description

  • Added a conservative allowlist SCRATCH_FILENAMES and a small write-boundary redirect so newly created root-level files matching the list are written under .villani_code/.../scratch/ via _resolve_write_target and _scratch_root instead of the repo root.
  • Preserved normal behavior for edits to existing files and for files created under existing directories (e.g. tests/, src/) by only redirecting when the target does not already exist and is a root-level plain name.
  • Implemented _resolve_scratch_alias and _rewrite_bash_scratch_aliases so Read and shell commands referencing the original filename resolve to the redirected path when appropriate, and updated _run_read, _run_write, and _run_bash accordingly.
  • Ensured runtime imports continue to work when executing redirected scratch scripts by prepending the repo root to PYTHONPATH for subprocesses, and made redirection visible in tool output with an explanatory message.

Testing

  • Ran pytest -q tests/test_scratch_redirection.py and all tests passed (6 passed).

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