Repository navigation
fix(baseline): Retry the removal of the tests' scratch directories - #306
Conversation
A test removes its scratch git repository while git may still be writing into it,
which failed a bare recursive rmSync with ENOTEMPTY ('.git/objects/pack') and
turned a green Template tests run red. Every recursive rmSync in the Owned lib/
modules now passes maxRetries and retryDelay, and a check fails on a bare one.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Claude Review
Overview
This PR adds maxRetries: 5, retryDelay: 100 to every recursive rmSync that removes a scratch directory in the Owned Sandcastle test files and in git-sandbox-fake.mts. It makes the same change in dotfiles' root copies and in the Template's copies, so test.sh's cmp drift check stays green. It also adds a guard test in template.test.mts that scans the Owned lib/*.mts files for any recursive rmSync without maxRetries. I found nothing that should block the merge.
I read the diff and the changed files at the PR's head. The pairs of copies hold identical hunks, and I saw no site where only one copy changed. I did not run the tests. The Advisory items below are the leftovers I'd consider.
Changes
| File | What changed |
|---|---|
.sandcastle/lib/git-sandbox-fake.mts and its Template Owned copy |
cleanup() removes its scratch root with maxRetries: 5, retryDelay: 100. |
.sandcastle/lib/{checkpoint,host-safety,review-ledger,scan,shell}.test.mts and their Template Owned copies |
Every recursive rmSync in a finally or afterEach now passes maxRetries: 5, retryDelay: 100. The edits are mechanical and the copies match. |
.sandcastle/lib/template.test.mts (dotfiles-only) |
New test that reads each Owned lib/**/*.mts file, matches rmSync(... recursive: true ...) calls, and fails if any lacks maxRetries. It asserts at least one call was found, so it can't pass by checking nothing. |
Advisory (not blocking)
- Guard scope gap: the scan only covers
owned/.sandcastle/lib. dotfiles' owntemplate.test.mtsstill has a barermSync(scratch, { recursive: true, force: true })in itsafterhook. That directory holds only copied sources and a symlink, and no git runs in it, so the ENOTEMPTY risk is low. The same applies to any other dotfiles-only test file. - Async removal not covered: the scan doesn't see
fs.rmorfs/promisesrmwithrecursive: true. - Regex edge case:
/rmSync\([^;]*?recursive: true[^;]*?\)/stops at the first)afterrecursive: true. An option written asretryDelay: delay(), maxRetries: 5would be reported as a false positive. A barermSync(x)with no semicolon before a laterrecursive: truecould also match across the two. This is unlikely in this code. - Retry behaviour assumed: I'm relying on Node's
rmSyncretrying ENOTEMPTY whenmaxRetriesis set. That is documented forfs.rmSync. I haven't confirmed it for the Node version CI uses, in case a newer nativermSyncpath handles retries differently. - Masked test failures:
rmSyncstill runs infinallyblocks. If it throws after the retries, that error replaces the test's own assertion failure. This was already the case before the PR.
No findings.
## Why Re-Apply the repo-ci-baseline Template so this repo carries the Template changes from mpaulosky/dotfiles#303, mpaulosky/dotfiles#304, mpaulosky/dotfiles#305 and mpaulosky/dotfiles#306. ## What changed - `6af2035` Apply commit, `apply.sh` output alone: brings mpaulosky/dotfiles#303, mpaulosky/dotfiles#304, mpaulosky/dotfiles#305 and mpaulosky/dotfiles#306. - `.github/scripts/post_claude_review.py` - `.github/scripts/tests/test_post_claude_review.py` - `.github/workflows/claude-review.yml` - `.sandcastle/lib/agents.test.mts` - `.sandcastle/lib/build.test.mts` - `.sandcastle/lib/checkpoint.test.mts` - `.sandcastle/lib/git-sandbox-fake.mts` - `.sandcastle/lib/host-safety.test.mts` - `.sandcastle/lib/plan.test.mts` - `.sandcastle/lib/review-ledger.test.mts` - `.sandcastle/lib/scan.test.mts` - `.sandcastle/lib/shell.test.mts` - `.sandcastle/lib/ui-role-fixture.mts` (added) - `.sandcastle/lib/ui-role-fixture.test.mts` (added) ## Verification - The Apply commit is exactly `apply.sh`'s output on a branch up to date with `main`. - The pre-push gate (`scripts/gate.sh`) passed on `6af2035`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Why
dotfiles#304's
Template testsrun failed once withENOTEMPTY: directory not empty, rmdir '.git/objects/pack'incheckpoint.test.mts("lets a branch that leaves the gate script alone through"), and passed on a rerun. The test removes its scratch git repository with a barermSync(dir, { recursive: true, force: true })while git may still be writing into it (background maintenance after a commit). Every assertion in the test had passed; the failure was in the cleanup.What changed
rmSynccalls in the Ownedlib/modules (checkpoint.test.mts,host-safety.test.mts,scan.test.mts,shell.test.mts,review-ledger.test.mts,git-sandbox-fake.mts) now passmaxRetries: 5, retryDelay: 100, whichrmSyncuses to retryENOTEMPTY. dotfiles' root copies match.template.test.mtsfails when a recursivermSyncin those modules lacksmaxRetries, and when its scan finds no call at all.rmSyncuses (review-ledger.mts, one test) delete single files with{ force: true }and need no retries.Verification
test.shpasses;check:sandcastlepasses (2029 tests, no failures)./pre-push-review: 2 rounds, one Advisory finding (the guard passing without checking anything), fixed; nothing open.🤖 Generated with Claude Code