Skip to content

test: prefer auto-cleaning temp dir helper#93209

Merged
clawsweeper[bot] merged 5 commits into
mainfrom
codex/use-temp-dir-helper-tests
Jul 2, 2026
Merged

test: prefer auto-cleaning temp dir helper#93209
clawsweeper[bot] merged 5 commits into
mainfrom
codex/use-temp-dir-helper-tests

Conversation

@hxy91819

@hxy91819 hxy91819 commented Jun 15, 2026

Copy link
Copy Markdown
Member

Summary

  • add useTempDirTracker() to test/helpers/temp-dir.ts, with Vitest-owned automatic cleanup after each test and no exposed cleanup() method
  • keep the existing lower-level temp-dir helpers for historical unmigrated tests, while warning on new diff lines that import or call makeTempDir, cleanupTempDirs, or createTempDirTracker
  • keep the positive migration sample small by moving two script tests to useTempDirTracker()
  • update the testing guide and reporter tests for the new negative/positive CI warning behavior

Verification

  • env PATH=/root/.nvm/versions/node/v24.15.0/bin:$PATH node scripts/run-vitest.mjs run test/scripts/report-test-temp-creations.test.ts test/helpers/temp-dir.test.ts src/scripts/test-projects.test.ts test/scripts/parallels-package-log-progress-extract.test.ts test/scripts/runtime-postbuild-stamp.test.ts
  • env PATH=/root/.nvm/versions/node/v24.15.0/bin:$PATH pnpm tsgo:test
  • env PATH=/root/.nvm/versions/node/v24.15.0/bin:$PATH node scripts/report-test-temp-creations.mjs --base origin/main --head HEAD --json -> []
  • env PATH=/root/.nvm/versions/node/v24.15.0/bin:$PATH pnpm exec oxfmt --check scripts/report-test-temp-creations.mjs test/scripts/report-test-temp-creations.test.ts test/helpers/temp-dir.ts test/helpers/temp-dir.test.ts src/scripts/test-projects.test.ts test/scripts/parallels-package-log-progress-extract.test.ts test/scripts/runtime-postbuild-stamp.test.ts docs/help/testing.md
  • git diff --check origin/main...HEAD
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main -> clean, no accepted/actionable findings
  • CI on 91b78eb6b8154a2840e2b0f5fb0a8bd9878ddea1: check-guards, check-test-types, check-lint, check-docs, checks-node-core-tooling, and checks-node-core-tooling-docker passed; check-guards annotations are []

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: passed. Reviewed July 1, 2026, 10:45 PM ET / 02:45 UTC.

Summary
The branch adds useAutoCleanupTempDirTracker(), broadens the temp-dir warning reporter to flag new manual helper imports/usages, updates docs, and migrates two script tests to the new helper.

PR surface: Tests +301, Docs +1, Other +248. Total +550 across 8 files.

Reproducibility: not applicable. this is test/tooling cleanup, and the changed behavior is exercised through helper/reporter tests and CI evidence rather than a user reproduction path.

Review metrics: 1 noteworthy metric.

  • Temp-dir reporter warning scope: 1 warning-only reporter broadened. The diff changes changed-gate annotations for test temp-dir migration, which matters to maintainer noise and automation behavior even though it does not fail CI by default.

Stored data model
Persistent data-model change detected: migration/backfill/repair: scripts/report-test-temp-creations.mjs, serialized state: test/scripts/runtime-postbuild-stamp.test.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Risk before merge

  • [P1] The PR broadens warning-only changed-gate behavior from bare temp creation to manual helper imports/calls, so maintainers should accept that new annotations may appear for tests that intentionally keep using lower-level helpers unless they add or preserve the documented exception paths.

Maintainer options:

  1. Land with warning-only automation (recommended)
    Accept the broadened reporter scope because it only changes migration guidance annotations and the branch includes focused coverage for staged diffs, imports, calls, and exclusions.
  2. Narrow the reporter before merge
    If maintainers want less CI annotation noise, restrict manual-helper warnings to a smaller helper set or require explicit opt-in before landing.
  3. Pause the helper policy change
    If the project is not ready to discourage manual helper usage, keep the helper migration work out of the changed gate and land only the test helper separately.

Next step before merge

  • No ClawSweeper repair is needed; review found no actionable patch defect and the remaining automation concern is a maintainer acceptance choice.

Security
Cleared: The diff touches test helpers, docs, and an existing local warning reporter without adding dependencies, workflows, permissions, package scripts, downloads, or secret-handling changes.

Review details

Best possible solution:

Merge after exact-head CI/automerge gates remain green, keeping the reporter warning-only while the helper migration policy settles.

Do we have a high-confidence way to reproduce the issue?

Not applicable; this is test/tooling cleanup, and the changed behavior is exercised through helper/reporter tests and CI evidence rather than a user reproduction path.

Is this the best way to solve the issue?

Yes; centralizing Vitest-owned cleanup in the shared top-level test helper and limiting reporter checks to added lines is the cleanest migration path without breaking existing callers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7fa26e088d28.

Label changes

Label changes:

  • add status: 🚀 automerge armed: This PR is in ClawSweeper's automerge lane. Not applicable: The external contributor proof gate does not apply because this maintainer-member PR is internal test/tooling/docs cleanup, and the PR body plus CI provide supplemental verification.
  • remove status: 🔁 re-review loop: Current PR status label is status: 🚀 automerge armed.

Label justifications:

  • P3: This is low-risk test tooling, docs, and migration cleanup with no product runtime behavior change.
  • merge-risk: 🚨 automation: The PR changes the warning-only temp-dir reporter used by check-changed/check-guards, so incorrect matching could create misleading CI annotations.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 🚀 automerge armed: This PR is in ClawSweeper's automerge lane. Not applicable: The external contributor proof gate does not apply because this maintainer-member PR is internal test/tooling/docs cleanup, and the PR body plus CI provide supplemental verification.
Evidence reviewed

PR surface:

Tests +301, Docs +1, Other +248. Total +550 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 6 341 40 +301
Docs 1 17 16 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 1 256 8 +248
Total 8 614 64 +550

Acceptance criteria:

  • [P1] Exact-head CI/automerge gates remain green.
  • [P1] Warning reporter output remains empty or expected on the PR diff.
  • [P1] Focused helper and reporter tests continue to pass.

What I checked:

  • Target policy read and applied: Root and scoped repository policy for docs, scripts, and tests was considered; the touched surfaces are test tooling/docs cleanup and warning-only changed-gate automation. (AGENTS.md:1, 7fa26e088d28)
  • PR adds a distinct helper not already on main: Current main has the lower-level temp-dir helpers, while the PR adds useAutoCleanupTempDirTracker() that registers Vitest afterEach cleanup and intentionally returns no manual cleanup method. (test/helpers/temp-dir.ts:53, 1fdd7d2a9aed)
  • Reporter scans added manual-helper usage without whole-file churn: The PR extends the reporter with TypeScript AST-based manual helper import/call detection, added-line mapping, and staged-source reads while keeping the scan warning-only. (scripts/report-test-temp-creations.mjs:69, 1fdd7d2a9aed)
  • Focused tests cover the new helper and reporter edge cases: The PR adds helper cleanup/no-cleanup-property coverage and reporter tests for observed mkdtemp forms, manual helper imports/calls, multiline imports, helper-test exclusions, --staged index reads, and fail-on-findings behavior. (test/scripts/report-test-temp-creations.test.ts:114, 1fdd7d2a9aed)
  • Automation integration is warning-only on main: The changed reporter is invoked by check-changed and the guards workflow as a warning-only test temp creation report, so merge risk is annotation/noise correctness rather than runtime breakage. (scripts/check-changed.mjs:283, 7fa26e088d28)
  • Vitest hook ordering contract supports the helper test shape: The pinned Vitest version is 4.1.8; upstream source documents afterEach reverse registration order under the default sequence.hooks: stack, and OpenClaw's scoped Vitest config does not override that hook ordering for this lane. (package.json:307, 7fa26e088d28)

Likely related people:

What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jun 15, 2026
@hxy91819
hxy91819 force-pushed the codex/use-temp-dir-helper-tests branch from bfd66dc to 6d20b83 Compare June 15, 2026 07:50
@hxy91819

Copy link
Copy Markdown
Member Author

Positive temp-dir helper validation result:

  • check-guards passed on the updated head 6d20b839e8299596c66ccc8f3c7faa0629bd7c23.
  • The check-guards check-run annotation API returned 0 annotations, so the helper-backed migration does not emit the temp-dir warning.
  • checks-node-core-tooling passed after updating the helper import routing expectation in src/scripts/test-projects.test.ts.

Known unrelated CI state:

  • check-test-types is failing in this run, but I reproduced the same pnpm tsgo:test failure on current main with the same packages/gateway-protocol/src/native-protocol-levels.guard.test.ts errors, so it is a baseline failure rather than this PR's temp-dir helper migration.

@hxy91819 hxy91819 changed the title test: use temp dir helper in script tests test: use auto-cleaning temp dir helper Jun 15, 2026
@hxy91819
hxy91819 force-pushed the codex/use-temp-dir-helper-tests branch from 6d20b83 to 83a0dcb Compare June 15, 2026 08:07
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: S and removed size: XS labels Jun 15, 2026
@hxy91819

Copy link
Copy Markdown
Member Author

Follow-up update after tightening the helper shape:

  • Replaced the manual-cleanup usage with useTempDirTracker(), which registers Vitest afterEach cleanup inside the helper.
  • Updated the testing guide so new callers use the auto-cleaning pattern instead of copying manual cleanup() wiring.
  • Fixed the previous check-test-types noise by narrowing the TypeBox union schema access in native-protocol-levels.guard.test.ts.
  • Reran the flaky checks-node-core-tooling job after confirming test/scripts/ui.test.ts passed locally; the rerun is now green.

Current validation on head 83a0dcb3b1783bbbc70696d786fe4fb34bf365bb:

  • check-guards: pass, 0 annotations
  • check-test-types: pass
  • checks-node-core-tooling: pass
  • all currently reported PR checks: pass

@hxy91819
hxy91819 force-pushed the codex/use-temp-dir-helper-tests branch from 83a0dcb to 2ed18af Compare June 15, 2026 08:39
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M and removed size: S labels Jun 15, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 15, 2026
@hxy91819
hxy91819 force-pushed the codex/use-temp-dir-helper-tests branch from 2ed18af to c84e510 Compare June 15, 2026 08:55
@openclaw-barnacle openclaw-barnacle Bot removed app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling labels Jun 15, 2026
@hxy91819
hxy91819 force-pushed the codex/use-temp-dir-helper-tests branch from 9699b92 to 1fdd7d2 Compare July 1, 2026 13:34
@hxy91819

hxy91819 commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Rebased after #96711 landed and resolved the shared src/scripts/test-projects.test.ts routing expectation conflict.

Fixed the staged-mode ClawSweeper finding: --staged manual-helper scans now parse the staged index blob instead of worktree source, with a partially staged regression test covering both missed staged additions and unstaged false positives.

Local proof on head 1fdd7d2a9ae:

  • node scripts/run-vitest.mjs run test/scripts/report-test-temp-creations.test.ts -> 13 passed
  • node scripts/run-vitest.mjs run --config test/vitest/vitest.tooling.config.ts src/scripts/test-projects.test.ts -> 83 passed
  • node_modules/.bin/oxfmt --check scripts/report-test-temp-creations.mjs test/scripts/report-test-temp-creations.test.ts src/scripts/test-projects.test.ts -> passed
  • git diff --check -> passed
  • node scripts/report-test-temp-creations.mjs --base origin/main --head HEAD --json -> []

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@hxy91819

hxy91819 commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@hxy91819

hxy91819 commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper approve

@clawsweeper

clawsweeper Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper clawsweeper Bot added status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 1, 2026
@hxy91819

hxy91819 commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper approve

@clawsweeper

clawsweeper Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@hxy91819

hxy91819 commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper automerge

@clawsweeper

clawsweeper Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@hxy91819 hxy91819 removed the clawsweeper:human-review Needs maintainer review before ClawSweeper can continue label Jul 2, 2026
@hxy91819

hxy91819 commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper automerge

@clawsweeper clawsweeper Bot added clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane. and removed status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. labels Jul 2, 2026
@clawsweeper
clawsweeper Bot merged commit 5ff247b into main Jul 2, 2026
128 of 132 checks passed
@clawsweeper
clawsweeper Bot deleted the codex/use-temp-dir-helper-tests branch July 2, 2026 02:46
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 2, 2026
Summary:
- The branch adds `useAutoCleanupTempDirTracker()`, broadens the temp-dir warning reporter to flag new manual helper imports/usages, updates docs, and migrates two script tests to the new helper.
- PR surface: Tests +301, Docs +1, Other +248. Total +550 across 8 files.
- Reproducibility: not applicable. this is test/tooling cleanup, and the changed behavior is exercised through helper/reporter tests and CI evidence rather than a user reproduction path.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test: harden temp dir helper guard
- PR branch already contained follow-up commit before automerge: test: clarify auto cleanup temp dir helper name
- PR branch already contained follow-up commit before automerge: test: cover existing mkdtemp temp dir forms
- PR branch already contained follow-up commit before automerge: test: read staged temp helper source from index

Validation:
- ClawSweeper review passed for head 1fdd7d2.
- Required merge gates passed before the squash merge.

Prepared head SHA: 1fdd7d2
Review: openclaw#93209 (comment)

Co-authored-by: Mason Huang <[email protected]>
Approved-by: hxy91819
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 3, 2026
Summary:
- The branch adds `useAutoCleanupTempDirTracker()`, broadens the temp-dir warning reporter to flag new manual helper imports/usages, updates docs, and migrates two script tests to the new helper.
- PR surface: Tests +301, Docs +1, Other +248. Total +550 across 8 files.
- Reproducibility: not applicable. this is test/tooling cleanup, and the changed behavior is exercised through helper/reporter tests and CI evidence rather than a user reproduction path.

Automerge notes:
- PR branch already contained follow-up commit before automerge: test: harden temp dir helper guard
- PR branch already contained follow-up commit before automerge: test: clarify auto cleanup temp dir helper name
- PR branch already contained follow-up commit before automerge: test: cover existing mkdtemp temp dir forms
- PR branch already contained follow-up commit before automerge: test: read staged temp helper source from index

Validation:
- ClawSweeper review passed for head 1fdd7d2.
- Required merge gates passed before the squash merge.

Prepared head SHA: 1fdd7d2
Review: openclaw#93209 (comment)

Co-authored-by: Mason Huang <[email protected]>
Approved-by: hxy91819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:automerge Maintainer opted this PR into bounded ClawSweeper-reviewed automerge docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: L status: 🚀 automerge armed This PR is in ClawSweeper's automerge lane.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants