Skip to content

test(infra): clean exec approval temp roots - #113342

Merged
steipete merged 1 commit into
mainfrom
steipete/test-exec-approval-fixtures
Aug 9, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/test-exec-approval-fixtures

Conversation

@steipete

@steipete steipete commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The shared exec-approval fixture helper creates canonical real temporary directories for twelve consumer suites but did not own their lifecycle. Repeated tests therefore left openclaw-exec-approvals-* roots behind, while two consumers attempted narrower one-off deletion loops.

Why This Change Was Made

The shared producer now tracks only the canonical real paths it creates in a module-local Set, registers one Vitest afterEach, and delegates deletion exclusively to cleanupTempDirs. That repository helper owns recursive force removal, bounded retry/backoff, and collection clearing. The two consumer-local rmSync loops were removed so this fixture class has one cleanup spelling.

This directly addresses ClawSweeper's retry-policy finding and keeps lifecycle ownership at the producer rather than relying on every importer.

ClawSweeper's rank-up moves are addressed: deletion now uses cleanupTempDirs, every current importer passed, the clean-box no-roots assertion passed, and normal maintainer handling continues through the repository-native landing flow.

User Impact

Developers and CI workers no longer accumulate exec-approval fixture directories across tests. Production behavior is unchanged.

Windows cleanup is the main risk. The canonical helper uses Node recursive fs.rmSync with force: true, maxRetries: 5, and retryDelay: 20; Node 24 documents linear-backoff retries for EBUSY, EMFILE, ENFILE, ENOTEMPTY, and EPERM. A native Azure Windows proof was attempted, but the broker rejected the Windows image selector before creating a lease with HTTP 403 admin_required. No Windows runtime pass is claimed.

Evidence

  • Regression before producer cleanup (node scripts/run-vitest.mjs src/infra/exec-approvals-config.test.ts -- -t 'exec approval temp fixture cleanup'):
    • Tests 1 failed | 1 passed | 24 skipped
    • the next test observed the prior fixture root still present
    • [vitest] FAILED (exit 1)
  • Regression after cleanup (same command):
    • Tests 2 passed | 24 skipped
    • [test] passed 1 Vitest shard in 4.05s
  • All twelve current importer suites on the rebased head:
    • unit-fast: 3 files, 42 tests passed
    • infra: 9 files, 431 tests passed
    • total: 12 files, 473 tests passed
    • [test] passed 2 Vitest shards in 9.91s
  • Clean-box importer + external no-roots proof:
  • Changed-file gate (node scripts/check-changed.mjs):
  • git diff --check: passed.
  • Fresh Codex autoreview on rebased head 656979297c5456ac57117599a4fd8a08b1102820: clean after one round; no accepted/actionable findings, confidence 0.99.
  • Exact-head CI (node scripts/watch-pr-ci.mjs 113342 656979297c5456ac57117599a4fd8a08b1102820): GREEN, pending=0.

AI-assisted: yes.

@steipete
steipete marked this pull request as ready for review July 24, 2026 14:17
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Jul 24, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Jul 24, 2026
@clawsweeper

clawsweeper Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 2, 2026, 10:51 PM ET / August 3, 2026, 02:51 UTC.

ClawSweeper review

What this changes

The PR tracks temporary directories made by the shared exec-approval test fixture and removes them after each Vitest test.

Merge readiness

⚠️ Needs maintainer review before merge - 3 items remain

Keep this PR open: it solves real test-fixture leakage and includes credible after-fix proof, but its direct cleanup loop bypasses OpenClaw’s canonical retrying temporary-directory cleanup policy. The protected maintainer label requires an explicit landing decision after that narrow repair.

Priority: P3
Reviewed head: b22c1859874c3ee18db737751ac2140b881f052a

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The cleanup goal has credible real-behavior proof, but the implementation needs the established retrying cleanup semantics before it is merge-ready.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body reports focused Blacksmith Testbox results and a post-run assertion that no matching temporary roots remained, directly demonstrating the intended cleanup outcome.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body reports focused Blacksmith Testbox results and a post-run assertion that no matching temporary roots remained, directly demonstrating the intended cleanup outcome.
Evidence reviewed 7 items Branch cleanup bypasses the canonical policy: The PR adds a fixture-local set and direct recursive rmSync loop, but does not include the retry parameters used for temporary-directory cleanup elsewhere in the repository.
Canonical cleanup contract: cleanupTempDirs removes tracked roots with maxRetries: 5 and retryDelay: 20, then clears the tracking collection; its auto-cleaning tracker registers that behavior through the caller-provided Vitest cleanup hook.
Canonical helper has direct regression coverage: The shared helper’s own tests prove cleanup of populated directories, caller-owned collections, and an afterEach-registered auto-cleaning tracker.
Findings 1 actionable finding [P2] Reuse the retrying temporary-directory cleanup
Security None None.

How this fits together

Exec-approval tests create real executable directories in the operating-system temporary root, then pass those paths into command-resolution and approval-policy code. The shared fixture serves multiple test suites, so it should own cleanup of the roots it creates without making every consumer implement teardown.

flowchart LR
  A[Exec-approval tests] --> B[Shared fixture helper]
  B --> C[Temporary executable directory]
  C --> D[Command-resolution tests]
  D --> E[After-each cleanup]
  E --> F[Operating-system temp root]
Loading

Before merge

  • Reuse the retrying temporary-directory cleanup (P2) - The direct rmSync loop omits the maxRetries and retryDelay policy in test/helpers/temp-dir.ts. A transient handle can make afterEach fail—especially on Windows—and convert a passing suite into a CI failure; call the shared cleanup helper instead.
  • Resolve merge risk (P1) - Without the canonical retry budget, a transient filesystem handle can make the new afterEach hook fail and turn otherwise successful exec-approval tests into cross-platform CI failures.
  • Complete next step (P2) - The lone blocker is a narrow mechanical repair, while the protected maintainer label still reserves the final landing decision for a maintainer.

Findings

  • [P2] Reuse the retrying temporary-directory cleanup — src/infra/exec-approvals-test-helpers.ts:10-12
Agent review details

Security

None.

PR surface

Source +14. Total +14 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 15 1 +14
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 15 1 +14

Review metrics

Metric Value Why it matters
Test-only LOC delta production 0, test infrastructure +14/-1 The branch affects only fixture hygiene, making cleanup-hook reliability rather than production behavior the relevant merge concern.

Merge-risk options

Maintainer options:

  1. Delegate to shared cleanup (recommended)
    Replace the direct deletion loop with cleanupTempDirs while retaining the fixture-owned set and real-path tracking, then re-run the focused suites.
  2. Pause the hygiene change
    Defer the PR if maintainers do not want the fixture to take a dependency on the shared test cleanup helper.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Replace the direct fixture cleanup loop with the canonical retrying `cleanupTempDirs` helper, preserve realpath tracking, and validate focused exec-approval tests plus the no-roots assertion.

Technical review

Best possible solution:

Keep lifecycle ownership in the shared fixture, but have its hook call cleanupTempDirs so every tracked root receives the repository’s retrying removal and collection-clearing behavior.

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

Yes, from source: current main’s shared fixture creates openclaw-exec-approvals- roots for twelve consumer suites without tracking them, while the branch supplies the missing tracking hook. This read-only review did not execute the suite, but the PR body also reports a focused post-run no-roots assertion.

Is this the best way to solve the issue?

No: centralizing cleanup in the fixture is the right owner boundary, but directly calling rmSync duplicates and weakens the current retrying cleanup policy. Reusing cleanupTempDirs is the narrower maintainable repair.

Full review comments:

  • [P2] Reuse the retrying temporary-directory cleanup — src/infra/exec-approvals-test-helpers.ts:10-12
    The direct rmSync loop omits the maxRetries and retryDelay policy in test/helpers/temp-dir.ts. A transient handle can make afterEach fail—especially on Windows—and convert a passing suite into a CI failure; call the shared cleanup helper instead.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 443821f49b63.

Labels

Label justifications:

  • P3: This is a contained test-infrastructure cleanup with no production runtime behavior change.
  • merge-risk: 🚨 automation: A teardown exception can fail otherwise passing test suites and CI jobs, particularly on platforms with transient file handles.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The PR body reports focused Blacksmith Testbox results and a post-run assertion that no matching temporary roots remained, directly demonstrating the intended cleanup outcome.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports focused Blacksmith Testbox results and a post-run assertion that no matching temporary roots remained, directly demonstrating the intended cleanup outcome.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs .
  • [P1] git diff --check.
  • [P1] Run the existing post-run assertion for openclaw-exec-approvals-* roots.

What I checked:

  • Branch cleanup bypasses the canonical policy: The PR adds a fixture-local set and direct recursive rmSync loop, but does not include the retry parameters used for temporary-directory cleanup elsewhere in the repository. (src/infra/exec-approvals-test-helpers.ts:10, b22c1859874c)
  • Canonical cleanup contract: cleanupTempDirs removes tracked roots with maxRetries: 5 and retryDelay: 20, then clears the tracking collection; its auto-cleaning tracker registers that behavior through the caller-provided Vitest cleanup hook. (test/helpers/temp-dir.ts:38, b521e0a6dce9)
  • Canonical helper has direct regression coverage: The shared helper’s own tests prove cleanup of populated directories, caller-owned collections, and an afterEach-registered auto-cleaning tracker. (test/helpers/temp-dir.test.ts:25, 443821f49b63)
  • Shared fixture has broad consumer reach: Twelve exec-approval test files import the fixture helper and create temporary directories through makeTempDir, so a cleanup-hook failure can affect many focused test suites. (src/infra/exec-approvals-test-helpers.ts:16, 443821f49b63)
  • Feature and cleanup provenance: The current shared fixture and canonical cleanup helper are attributed to Peter Steinberger on current main; prior fixture history includes Jesse Merhi’s command-authorization refactor. (src/infra/exec-approvals-test-helpers.ts:1, b521e0a6dce9)
  • Current-main comparison: Current main does not contain this PR’s cleanup loop, so the central cleanup behavior is not already implemented or superseded on main. (src/infra/exec-approvals-test-helpers.ts:16, 443821f49b63)

Likely related people:

  • Peter Steinberger: Current-main blame attributes both the shared exec-approval fixture and the canonical temporary-directory cleanup helper to this contributor; they also authored the PR branch. (role: recent area contributor; confidence: high; commits: b521e0a6dce9, b22c1859874c; files: src/infra/exec-approvals-test-helpers.ts, test/helpers/temp-dir.ts)
  • Jesse Merhi: The PR branch’s file history traces the earlier shared exec-approval fixture lineage through this contributor’s command-authorization refactor. (role: feature-history contributor; confidence: medium; commits: c9707ab635b9; files: src/infra/exec-approvals-test-helpers.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Route fixture-root deletion through cleanupTempDirs.
  • Re-run the affected exec-approval suites and the redacted no-roots assertion after the repair.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-07-24T14:21:46.191Z sha b22c185 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T14:36:30.857Z sha b22c185 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T15:09:50.850Z sha b22c185 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-03T02:46:04.086Z sha b22c185 :: found issues before merge. :: [P2] Reuse the canonical retrying temporary-directory cleanup

@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. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. 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 Aug 3, 2026
@steipete
steipete force-pushed the steipete/test-exec-approval-fixtures branch from b22c185 to 6569792 Compare August 9, 2026 12:27
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 9, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit d5809b4 into main Aug 9, 2026
103 checks passed
@steipete
steipete deleted the steipete/test-exec-approval-fixtures branch August 9, 2026 12:43
@steipete

steipete commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant