chore(test): add temp cleanup guard scan#78416
Conversation
|
Codex review: needs maintainer review before merge. Reviewed May 27, 2026, 5:51 AM ET / 09:51 UTC. Summary PR surface: Tests +156, Config +1, Other +187. Total +344 across 3 files. Reproducibility: not applicable. this is internal test-tooling cleanup rather than a bug report. Source inspection and exact-head CI/check-run evidence are the relevant validation path. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Keep the guard as a standalone lint script first, accept the heuristic only if the current signal is useful, and wire it into broader checks later after the current findings and noise profile are reviewed. Do we have a high-confidence way to reproduce the issue? Not applicable: this is internal test-tooling cleanup rather than a bug report. Source inspection and exact-head CI/check-run evidence are the relevant validation path. Is this the best way to solve the issue? Yes, with maintainer acceptance of the rollout: adding the scan as a standalone script is a narrow way to review the heuristic before wiring it into broader gates. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 8c6da93fdf7c. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Tests +156, Config +1, Other +187. Total +344 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: defd24a732
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Adjusted the scanner to reduce the false-negative case the bot pointed out, without moving to an AST-heavy approach. What changed:
Why this shape:
Re-ran validation:
Current scan after the adjustment:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8b4a309800
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed the new bot review points. Changes:
Re-ran:
Current scan after this update is unchanged in shape:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4453d40602
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Handled the last review point. What changed:
Also retained the earlier sparse-checkout fix:
Re-ran:
Current scan remains:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b58754af5c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Review follow-up: here is the full path from the initial guard to the current heuristic, including what the bot surfaced and why the implementation changed the way it did. GoalThis guard exists for one practical reason:
So the guard is trying to answer a narrow question: Not a full correctness proof. Just a lightweight repo-local detector that is cheap enough to run regularly. Review path1. Initial versionThe first pass was intentionally simple: That gave us a usable first signal, but the bot correctly pointed out that the suppression rule was too broad. 2. False negative: file-level suppression was too coarseThe first real issue was: That can hide a real leak when the cleanup is for some unrelated path. ASCII shape of the bug: That was the main behavioral flaw in the original rule. 3. Sparse checkout failureThe bot also found that The fix there was straightforward: skip tracked-but-missing files on 4. JSON test was coupled to live repo stateThe earlier JSON-output test called the CLI path against the current repository and asserted that findings existed. That meant the test would eventually fail for the wrong reason: So the test was changed to run against a hermetic temporary git fixture instead of the live repository. 5. Remaining false negative: cleanup must match the same mkdtemp bindingThe last bot point was the important one and is what the latest commit addresses. The scanner now looks for variable bindings created from ASCII view: That keeps the implementation lightweight, but removes the most obvious source of false negatives. Important decisionsDecision 1: stay heuristic, do not jump to AST parsing yetWe explicitly kept this as a regex/string-based guard instead of moving straight to AST/dataflow analysis. Reason:
So the design target is: Decision 2: bias against noisy suppressionThe review path made it clear that broad suppression is more dangerous than broad reporting. So the current heuristic prefers this tradeoff: That may still leave some warnings/errors that a smarter analyzer could dismiss, but it avoids silently hiding obvious leaks. Decision 3: keep fixture-backed tests for scanner behaviorThe scanner tests now validate behavior through tiny temporary git repos. That gives us deterministic coverage for:
Current boundary / limitationThis is still not full semantic analysis. The scanner can miss or over-report more complex patterns. Examples of remaining boundaries:
So the rule should be read as: That is deliberate for this rollout. Why this matters beyond the scriptThe underlying operational issue is not just test neatness. Residual temp directories can:
So this guard is part of keeping test residue from becoming a security and operations distraction. Validation rerunRe-ran after the binding-aware fix:
In short: That is a materially better floor without over-engineering the rule. |
Dependency Changes DetectedThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
0b29216 to
9188331
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Mossy Proofling Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Closing this PR in favor of a lower-noise helper-first design. The cleanup scanner proved too strong for a CI gate: it has to infer whether arbitrary temp-dir cleanup patterns are sufficient, which turns into heuristic data-flow analysis and can force contributors to rewrite existing reasonable cleanup code just to match the scanner's recognized shape. We'll replace this with a repo-local approach:
Thanks for iterating on this. The problem is real; the enforcement shape needs to be more conservative. |
Summary
scripts/check-test-temp-cleanup.mjsto scan tracked test files formkdtempusage without obvious scoped cleanuptest/scripts/check-test-temp-cleanup.test.tscoverage for the scanner and its JSON modepnpm lint:tmp:test-temp-cleanupWhy this matters
/tmpare easy to forget, but they accumulate across repeated local and CI runsCurrent scan snapshot
errorlevel (no obvious cleanup signal)warninglevel (rmpresent but noafterEach/afterAll/finallyscope)Current limitations
mkdtempcallValidation
OPENCLAW_VITEST_MAX_WORKERS=1 pnpm test test/scripts/check-test-temp-cleanup.test.tsnode scripts/check-test-temp-cleanup.mjs --jsonNotes
This PR intentionally adds the guard as a standalone scan first. It does not fix the existing findings yet, so maintainers can review the heuristic and rollout strategy before wiring it into broader gates.