Skip to content

Session: reuse one driver macro instead of a new file per call - #36

Merged
tproffen merged 1 commit into
claude-python-appfrom
claude/inspiring-brahmagupta-ne81m7
Nov 16, 2026
Merged

tproffen merged 1 commit into
claude-python-appfrom
claude/inspiring-brahmagupta-ne81m7

Conversation

@tproffen

Copy link
Copy Markdown
Owner

Merges into claude-python-app (not master).

This commit was pushed to claude/fourier-pdf just after #35 was merged, so it did not make it in. Same change, now on top of the merged claude-python-app.

What it fixes

Every diffuse call wrote a new driver macro (_driver_0.mac, _driver_1.mac, …), so a long session left thousands of small files in its scratch folder. Now each session reuses one _driver.mac, overwritten on every call.

Why reusing one file name is safe

DISCUS keeps the macros it runs in memory, keyed by file name (lib_f90/macro.f90, class_macro_internal), so a reused name could in principle run stale text. But macro_close empties that store whenever a top-level macro ends, including after an error. Checked directly with suite_python: three different texts through the same file name, one of them failing, each ran its new content.

Tests

  • New test_scratch_folder_does_not_grow: 20 calls with different text, a failing call, a call after the error, and powder calculations before and after; the folder contents are unchanged and each call sees its own text.
  • pytest tests/python: 40 passed (33 legacy macro tests skipped without DISCUS_SUITE).
  • After 200 calls plus powder, PDF and Fourier, the scratch folder holds 5 entries: _driver.mac, fourier.inte, input/, pdf.gr, powder.dat.

Generated by Claude Code

Each call wrote a new _driver_<n>.mac, so long sessions left thousands
of small files in the scratch folder. DISCUS keeps macros in memory by
file name, but empties that store whenever a top-level macro ends (also
after an error), so overwriting one file is safe: checked by running
different text through the same name, including right after a failed
macro. The scratch folder now stays at a handful of files (driver, data
outputs, input copy). New test: test_scratch_folder_does_not_grow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yw8KkfPLawp8Po4f5Bc9v
@tproffen
tproffen merged commit 81ad356 into claude-python-app Nov 16, 2026
4 checks passed
@tproffen
tproffen deleted the claude/inspiring-brahmagupta-ne81m7 branch November 16, 2026 18:26
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.

2 participants