Skip to content

fix(test): drain canonical state fixture directories - #159281

Merged
steipete merged 1 commit into
mainfrom
fix/canonical-state-dir-fixture-0926
Sep 27, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/canonical-state-dir-fixture-0926

Conversation

@steipete

@steipete steipete commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes test fixture cleanup missing database workers when the temporary state directory has a symlinked parent, such as /var versus /private/var on macOS.

User Impact

No user-visible change. This is a test-helper repair; installed state, configuration, ports, SDK, schemas, durability, retention, and permissions are unchanged. No migration is required.

Why This Change Was Made

The fixture supplied a lexical state path, while database owners and some callers used its canonical path. Root-scoped drainage could therefore miss the database resources before the fixture directory was removed. Resolve the new state directory once and use that same canonical root for the environment, callback, and existing ordered cleanup.

The existing helper scenario now covers both ordinary and symlinked temporary parents with real filesystem operations. The symlink case fails on the original helper and passes after this change. It adds no production seam, sleep, retry, timeout increase, or broader cleanup mock.

The related session-group teardown-order repair already landed in #159163 as d9fd43d6cf4286e1734e4a6ff91b962cb3e35e82; this PR preserves that fixture unchanged and publishes only the remaining helper defect. It is a separate prerequisite discovered while landing the system-job scheduler slice.

Evidence

Remote provider: blacksmith-testbox, lease tbx_01m3fz4ar9ygxxkxh5y2qjc40x, run 36278033418. The job used the original CI class, blacksmith-32vcpu-ubuntu-2404, with 8 actual logical CPUs and 33,229,729,792 bytes RAM. Runtime versions matched the original failure: Node 24.19.0 and the repository's checksum-pinned Bun build. Frozen dependency installs preceded proof.

Proof Result Command wall
Original full shard order, historical merge 0b0cc375ade9a9e9d6e096b49757a07625599e47 Reproduced the session-group teardown failure 286.692 s
Original session-group file alone Passed; recorded as non-reproduction 20.935 s
Strengthened helper test against original helper Failed exactly at the aliased-root assertion 14.115 s
Candidate helper file, pnpm test src/test-helpers/state-dir-env.test.ts --maxWorkers=1 4 cases passed 14.470 s
Candidate session-group file, pnpm test src/gateway/session-group-mutation-targets.test.ts --maxWorkers=1 20 consecutive runs / 60 cases passed 365.925 s total; first file cost 21.551 s
Original complete shard command and group order, candidate pass 1 128 files / 2,784 cases passed 423.469 s
Same complete original shard, candidate pass 2 128 files / 2,784 cases passed 410.143 s
Same complete original shard, candidate pass 3 128 files / 2,784 cases passed 414.928 s

The shard commands used node --import tsx scripts/ci-run-node-test-shard.mts with the original five-group manifest, worker intersections, Node/Bun routing, and plan concurrency. These broader results belong to the earlier three-file candidate at tree ec2fe5ee7c106dffd66866460765e833215fb603, based on 547bb312f4098cd0f28f71cc45a7e351e944b1ff. The two helper files here are byte-identical to that proved candidate. Fresh main independently supplied the Gateway fixture repair, so the final PR does not duplicate it. Exact-head hosted CI owns the refreshed composition.

Deslop and formatting/diff checks passed. The initial Codex review identified the canonical-path mismatch; it was corrected, and review was clean through P2. The final two-file follow-up received a fresh scoped Codex review before publication. Exact-head CI run 36282647720 passed on 17e0aaba7266d815374307518a32a316c4a44fd5 in 797 s workflow elapsed, including the enforced openclaw/ci-gate. Auto-merge landed 5e0d86f46d83a0bf81dd4242ccb7ce86d23d0a40, verified on origin/main.

LOC: production +0/−0/net 0; tests/support +41/−15/net +26; docs +0/−0/net 0. The temporary resource-class workflow used for proof is excluded from this PR.

@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete enabled auto-merge (squash) September 27, 2026 00:31
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 8:34 PM ET / September 27, 2026, 00:34 UTC.

ClawSweeper review

What this changes

The branch canonicalizes temporary test state paths before passing them to tests and adds a real-filesystem regression case with a symlinked temporary parent.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main still gives scoped cleanup a lexical state path that can differ from canonical database paths. This focused PR addresses that gap; the merged teardown-order repair addressed a separate race.

Priority: P2
Reviewed head: 17e0aaba7266d815374307518a32a316c4a44fd5

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrow owner-level fix has a targeted before-and-after regression case and detailed original-order validation.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR reports a real-filesystem symlink case failing against the original test-state helper and passing after canonicalization, plus original-order shard passes on Testbox. The broader shard proof predates this exact head, whose helper files are reported as identical; no stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports a real-filesystem symlink case failing against the original test-state helper and passing after canonicalization, plus original-order shard passes on Testbox. The broader shard proof predates this exact head, whose helper files are reported as identical; no stored-data contract changes.
Evidence reviewed 7 items Current main retains lexical path: The fetched main helper constructs stateDir from tempRoot and passes that path into scoped cleanup without resolving it.
Introduced helper change: The pinned PR delta resolves the newly created state directory before setting the environment and invoking the callback; cleanup receives that same canonical path.
Scoped cleanup boundary: Cleanup uses the supplied state root to wait for reconciles and close pooled readers and agent databases, so path identity matters before temporary files are removed.
Findings None None.
Security None None.

How this fits together

A shared test helper gives OpenClaw tests an isolated state directory. Its teardown drains session and database resources for that directory, restores the environment, and removes the temporary files.

flowchart LR
  A[Test requests isolated state] --> B[Create temporary directory]
  B --> C[Resolve canonical state path]
  C --> D[Test uses state directory]
  D --> E[Drain scoped resources]
  E --> F[Restore environment and remove files]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +26. Total +26 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 41 15 +26
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 41 15 +26

Review metrics

None.

Technical review

Best possible solution:

Keep one canonical state-directory identity throughout fixture use and scoped teardown, with the symlinked-parent case guarding the cleanup contract.

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

Yes, as a source-backed path: run the symlinked temporary-parent case against current main's lexical-path helper. The PR reports a pre-fix failure and after-fix pass; this read-only review did not execute the test.

Is this the best way to solve the issue?

Yes. Resolving the state path where the shared fixture creates it makes the callback, environment, and scoped cleanup agree without adding a second cleanup rule.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: The path mismatch is a bounded shared-fixture reliability bug with no reported user-facing behavior change.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR reports a real-filesystem symlink case failing against the original test-state helper and passing after canonicalization, plus original-order shard passes on Testbox. The broader shard proof predates this exact head, whose helper files are reported as identical; no stored-data contract changes.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports a real-filesystem symlink case failing against the original test-state helper and passing after canonicalization, plus original-order shard passes on Testbox. The broader shard proof predates this exact head, whose helper files are reported as identical; no stored-data contract changes.

Label justifications:

  • P2: The path mismatch is a bounded shared-fixture reliability bug with no reported user-facing behavior change.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports a real-filesystem symlink case failing against the original test-state helper and passing after canonicalization, plus original-order shard passes on Testbox. The broader shard proof predates this exact head, whose helper files are reported as identical; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports a real-filesystem symlink case failing against the original test-state helper and passing after canonicalization, plus original-order shard passes on Testbox. The broader shard proof predates this exact head, whose helper files are reported as identical; no stored-data contract changes.

Evidence

What I checked:

  • Current main retains lexical path: The fetched main helper constructs stateDir from tempRoot and passes that path into scoped cleanup without resolving it. (src/test-helpers/state-dir-env.ts:28, 389cee4cb104)
  • Introduced helper change: The pinned PR delta resolves the newly created state directory before setting the environment and invoking the callback; cleanup receives that same canonical path. (src/test-helpers/state-dir-env.ts:30, 17e0aaba7266)
  • Scoped cleanup boundary: Cleanup uses the supplied state root to wait for reconciles and close pooled readers and agent databases, so path identity matters before temporary files are removed. (src/test-utils/session-state-cleanup.ts:33, 17e0aaba7266)
  • Regression case: The changed test creates a real directory and optional symlink, checks that the callback receives a canonical state path, and verifies cleanup. (src/test-helpers/state-dir-env.test.ts:61, 17e0aaba7266)
  • Reported before-and-after proof: The PR body reports that the aliased-root assertion failed with the original helper and passed with the candidate, followed by three passes of the original-order shard. Those results belong to an earlier candidate whose helper files the author reports as byte-identical; the linked Testbox workflow was still in progress when checked. (17e0aaba7266)
  • Related repair is distinct: GitHub records fix(chat): recover history reads across resets and rebuilds #159163 as merged. Its documented fixture repair settles agent cleanup before shared-state teardown; it does not canonicalize this helper's state path. (d9fd43d6cf42)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Shakker: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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
steipete merged commit 5e0d86f into main Sep 27, 2026
174 checks passed
@steipete
steipete deleted the fix/canonical-state-dir-fixture-0926 branch September 27, 2026 00:43
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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