Skip to content

test: use per-run temp roots in update-cli and migrate suites - #125171

Merged
steipete merged 1 commit into
mainfrom
steipete/charming-wu-c81cfb
Aug 17, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/charming-wu-c81cfb

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

src/cli/update-cli.test.ts anchored all its fixture paths to a fixed shared root (/tmp/openclaw-update-tests) with deterministic per-case names (openclaw-updated-root-6, ...). The suite's comment claimed all I/O was mocked, but setupUpdatedRootRefresh really writes entrypoint files and package.json under those paths and registers them for recursive fs.rm cleanup. Two concurrent runs on one machine (CI shards, sibling checkouts) generate byte-identical paths, so one run's cleanup deletes the other run's live fixtures mid-test — observed as 34 spurious failures on PR #124997 run 31992421445 while the same head was green locally.

A sibling sweep found one more instance of the same destructive class: src/commands/migrate.test.ts mocks resolveStateDir to a fixed /tmp/openclaw-migrate-command-test, the apply flow really mkdirs report dirs under it, and both beforeEach and afterEach recursively rm the shared root.

Why This Change Was Made

Repo test rules require per-run mkdtemp + fs.realpath'd roots. Both suites now derive their root from mkdtemp under os.tmpdir(), realpath'd for the macOS /var -> /private/var symlink, and remove it on suite exit. The eleven inline /tmp/openclaw-update-tests/... profile literals in update-cli were rebased onto the per-run root so the whole suite shares one unique namespace. In migrate.test.ts the unique root is computed in an async vi.hoisted block because the vi.mock factory runs during static imports.

User Impact

None at runtime — test-only change. CI shards and sibling checkouts sharing one machine no longer produce spurious cross-run failures in these suites.

Evidence

  • Forced reproduction: running the pre-fix update-cli suite while a background loop performed a sibling run's cleanup (rm -rf /tmp/openclaw-update-tests every 50ms) fails 3 tests; the fixed suite under identical interference passes 240/240.
  • Two plain concurrent runs of each fixed suite pass: update-cli 240/240 + 240/240, migrate 40/40 + 40/40.
  • node scripts/check-changed.mjs -- <both files> exit 0 (core-test typecheck shards, lint, deadcode, temp-dir report: no new warnings); oxfmt/oxlint clean.
  • Fresh autoreview (Codex, gpt-5.6-sol, high): clean, no accepted/actionable findings.
  • Survey of other suites: fixed /tmp literals elsewhere are mock-only strings; two additive-only (non-destructive) fixed-mkdir cases in extensions/browser are flagged as a follow-up rather than expanding this diff.

Production LOC: +0/-0 | Tests: +34/-16

update-cli.test.ts used a fixed /tmp/openclaw-update-tests root with
deterministic case-dir names; some cases write real fixture files there
and cleanup rm -rf's them, so concurrent runs on one machine (CI shards,
sibling checkouts) deleted each other's live fixtures — observed as 34
spurious failures on PR #124997 run 31992421445. migrate.test.ts had the
same shape via a fixed mocked resolveStateDir root rm -rf'd in
beforeEach/afterEach.

Both suites now use per-run mkdtemp roots, realpath'd for the macOS
/var -> /private/var symlink, removed on suite exit.
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: S maintainer Maintainer-authored PR labels Aug 17, 2026
@steipete
steipete marked this pull request as ready for review August 17, 2026 08:29
@steipete steipete self-assigned this Aug 17, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 17, 2026
@clawsweeper

clawsweeper Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 5:06 AM ET / 09:06 UTC.

ClawSweeper review

What this changes

The branch gives the update CLI and migration command test suites unique per-run temporary roots so concurrent runs cannot recursively delete each other’s real fixture files.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: this maintainer-owned, test-only PR addresses a current shared-temp-root defect with a focused owner-boundary repair. Likely related: steipete (recent contributor to both affected test surfaces).

Priority: P3
Reviewed head: 20c9c977e45e7e06949b04db63b9f9c5502d359a
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, root-cause-aligned test-isolation repair with strong supplied concurrent-run evidence.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-owned test-only PR is outside the external-contributor proof gate; its body nevertheless supplies concurrent after-fix suite evidence.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-owned test-only PR is outside the external-contributor proof gate; its body nevertheless supplies concurrent after-fix suite evidence.
Evidence reviewed 4 items Shared update fixture root on current main: Current main uses one deterministic fixture root; setupUpdatedRootRefresh writes real entrypoint and package files below case paths, then registers their directories for recursive cleanup.
Shared migration state root reaches real writes: The migration test mocks resolveStateDir to a fixed path and recursively removes it before and after each case; the production apply path resolves that state directory and creates its report directory.
Current-main history ownership: Recent file history identifies Peter Steinberger as the current contributor on both affected test surfaces; the current repository head still predates the submitted per-run-root change.
Findings None None.
Security None None.

How this fits together

The update CLI suite creates temporary package entrypoints for post-update handoff tests, while the migrate command suite creates report directories under its mocked state root. Both clean up those paths, so a per-run namespace prevents cross-process cleanup from affecting another suite instance.

flowchart LR
A[Concurrent test process] --> B[Unique temporary root]
B --> C[Fixture or migration report files]
C --> D[Suite cleanup]
D --> E[Only this process's files removed]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned test-isolation repair land after its current-main refresh confirms the two-suite change remains clean? Refresh and land: Rebase or refresh the merge result and accept the focused per-run-root repair if exact-head checks remain green.

Why: The PR has a protected maintainer signal, so automated cleanup must not close or land it without an explicit maintainer decision.

Before merge

  • Resolve merge risk (P1) - GitHub reports the branch as behind main; refresh the merge result and exact-head checks before landing.
  • Complete next step (P2) - This active maintainer-owned PR needs normal exact-head merge handling, not an automated repair lane.
Agent review details

Security

None.

PR surface

Tests +18. Total +18 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 34 16 +18
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 34 16 +18

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0, tests +34/-16 The change is confined to test fixture lifecycle and adds no runtime product code.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/migrate.test.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the per-run realpath-resolved roots, rebase or refresh against current main, and land once the exact merged head remains green.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the per-run realpath-resolved roots, rebase or refresh against current main, and land once the exact merged head remains green.

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

Yes — current main has deterministic roots that feed real file writes and recursive cleanup, and the PR body records concurrent-run failure before the change. This review did not execute the suite because the checkout is read-only.

Is this the best way to solve the issue?

Yes — allocating unique roots where the suites own fixture setup prevents the destructive cross-run interaction without changing production behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a bounded test-reliability repair with no user-facing runtime behavior change.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-owned test-only PR is outside the external-contributor proof gate; its body nevertheless supplies concurrent after-fix suite evidence.

Label justifications:

  • P3: This is a bounded test-reliability repair with no user-facing runtime behavior change.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-owned test-only PR is outside the external-contributor proof gate; its body nevertheless supplies concurrent after-fix suite evidence.

Evidence

What I checked:

  • Shared update fixture root on current main: Current main uses one deterministic fixture root; setupUpdatedRootRefresh writes real entrypoint and package files below case paths, then registers their directories for recursive cleanup. (src/cli/update-cli.test.ts:533, e3d553b73419)
  • Shared migration state root reaches real writes: The migration test mocks resolveStateDir to a fixed path and recursively removes it before and after each case; the production apply path resolves that state directory and creates its report directory. (src/commands/migrate.test.ts:41, e3d553b73419)
  • Current-main history ownership: Recent file history identifies Peter Steinberger as the current contributor on both affected test surfaces; the current repository head still predates the submitted per-run-root change. (src/cli/update-cli.test.ts:533, 42a46250d442)
  • After-fix concurrency evidence: The PR body reports forced pre-fix interference failures and passing concurrent after-fix runs for both suites; the branch changes only the two implicated test files. (src/cli/update-cli.test.ts:533, 20c9c977e45e)

Likely related people:

  • steipete: Current-main history shows Peter Steinberger maintaining both affected test files, including recent update CLI work. (role: recent area contributor; confidence: high; commits: 42a46250d442, 76b26c31dce0; files: src/cli/update-cli.test.ts, src/commands/migrate.test.ts)

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.

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready verification for source head 20c9c977e45e7e06949b04db63b9f9c5502d359a:

  • Root cause: both suites used deterministic shared temporary roots for fixture trees that they really write and recursively delete, so concurrent processes could remove each other's live fixtures. The fix restores per-run ownership with mkdtemp and canonicalizes paths with realpath.
  • Focused proof: node scripts/run-vitest.mjs src/cli/update-cli.test.ts src/commands/migrate.test.ts passed 240 update-cli tests and 40 migrate tests.
  • Exact-head CI: run 32010644301 is green, including openclaw/ci-gate.
  • Fresh Codex autoreview completed cleanly with no accepted/actionable findings; native review artifacts and prepare-run both passed.
  • Production LOC: +0/-0. Tests: +34/-16. No docs or changelog change is needed for this test-only reliability repair.

Best-fix verdict: this belongs in fixture ownership at the two test harnesses; serializing CI, weakening cleanup, or changing production code would only mask the race.

@steipete
steipete merged commit 1df264d into main Aug 17, 2026
179 checks passed
@steipete
steipete deleted the steipete/charming-wu-c81cfb branch August 17, 2026 09:22
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
…aw#125171)

update-cli.test.ts used a fixed /tmp/openclaw-update-tests root with
deterministic case-dir names; some cases write real fixture files there
and cleanup rm -rf's them, so concurrent runs on one machine (CI shards,
sibling checkouts) deleted each other's live fixtures — observed as 34
spurious failures on PR openclaw#124997 run 31992421445. migrate.test.ts had the
same shape via a fixed mocked resolveStateDir root rm -rf'd in
beforeEach/afterEach.

Both suites now use per-run mkdtemp roots, realpath'd for the macOS
/var -> /private/var symlink, removed on suite exit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant