Skip to content

fix(test): prevent SQLite pathname failures in shared Gateway shards - #160838

Merged
jalehman merged 2 commits into
mainfrom
openclaw/fix-main-gateway-ci-lifetimes
Sep 29, 2026
Merged

jalehman merged 2 commits into
mainfrom
openclaw/fix-main-gateway-ci-lifetimes

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #153340

What Problem This Solves

Fixes intermittent SQLite pathname-changed failures in shared Gateway test shards when a preceding file imports the shared-state worker owner without its operation adapter.

User Impact

No product runtime behavior changes. Gateway CI fixtures now retire their worker resources before later tests reuse temporary database paths. SQLite admission guards, permissions, assertions, and deadlines are unchanged; no migration or operator action is required.

Why This Change Was Made

The worker owner moved into openclaw-state-worker-owner.ts, but the non-isolated runner still associated its singleton with the old adapter module. The surviving owner kept cleanup callbacks attached to a retired database lifecycle, so even an awaited canonical close could miss a live worker.

Track the actual owner module and extend the existing cross-file lifecycle proof to verify that canonical close reaches the next file's resource. No new process boot or serial test configuration was added.

Evidence

Verified against pinned main 3da238d5e385, with Node 24.19.0 and pnpm 12.5.1 on secretless AWS m7a.large runners (2 vCPU, approximately 8 GB RAM):

  • Fail before: the original physical plan reproduced the same SQLite guard error in three deletion-lifecycle cases: 602 passed / 3 failed across 59 Gateway files. The nine title cases passed on this newer main snapshot; they are not presented as fail-before evidence. A cold-order diagnostic replay reproduced the same three failures.
  • Pass after: the unchanged original Gateway group passed 605/605 tests in all 59 files, plus its preceding 294 dispatch tests. The original-plan wall time was 1000.21 s. Vitest result caches were moved aside to preserve cold file ordering rather than rerunning with failure/duration-based ordering.
  • Causal real-worker probe: two ordered files reproduced a worker still holding one reference, with no retirement underway, after canonical close and fixture replacement. It failed before and passed after (12.58 s / 12.57 s wall).
  • Regression: the expanded existing lifecycle test failed before because the second generation's resource was not closed, then passed after. One-worker command cost: 6.92 s before / 6.06 s after; it reuses the existing child-process fixture and preserves the existing failure-custody and skip assertions.
  • Selected checks: the complete staged check-changed plan passed, including all four root TypeScript partitions, formatting, lint, dead-export scans, and applicable guards (678.82 s wall). No check was skipped or waived.
  • Independent autoreview through P2: no actionable findings. The verified tree 1ddd228f8f43 exactly matches signed commit 16b08d69020d4.

Separate catalog limitation: the public catalog-startup case passed in 71.502 s on untouched main, but a peer worker was OOM-killed, leaving that wider replay incomplete. That does not establish a clean comparison or attribute the original 90-second timeout. No startup-performance repair is included here. Hosted CI for this new PR is not claimed complete.

Worked on by

Work sessions


View the OpenClaw team session

roboclaw-bot and others added 2 commits September 29, 2026 00:02
Track the shared-state singleton at its creator module rather than the
operation adapter. A direct owner import otherwise survives the database
lifecycle reset and leaves later worker resources outside canonical close.

Extend the existing non-isolated runner proof with two file generations
that verify current-generation resource retirement. The regression fails
on the old mapping; a real worker probe reproduces the pathname conflict
before the change and reopens successfully afterward. Native admission
guards and test deadlines are unchanged.

Co-authored-by: jalehman <[email protected]>
Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 966bf246-cd75-46a2-86de-ca62772a236b
@clawsweeper

clawsweeper Bot commented Sep 29, 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 9:50 PM ET / September 29, 2026, 01:50 UTC (Revision 2).

ClawSweeper review

What this changes

The branch updates Gateway test cleanup to retire the shared SQLite worker between files and adds ordered fixtures that check retirement across two file generations.

Merge readiness

✅ Ready for maintainer review

Current main retains the test-isolation defect. The focused repair has relevant before-and-after evidence, and the previous completed review recorded no actionable finding.

Priority: P2
Reviewed head: 1950d114606de0e0678f302713930cf87266e849

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-mapping repair has a failing-before regression and reported real-worker recovery, with no discrete defect found in this review.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The changed owner is shared Gateway test cleanup. The PR reports an original 59-file Gateway run with three pathname failures before and 605/605 passing after, plus an ordered real-worker probe that observed retirement after the fix; the committed mock-transport regression is supplemental. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed owner is shared Gateway test cleanup. The PR reports an original 59-file Gateway run with three pathname failures before and 605/605 passing after, plus an ordered real-worker probe that observed retirement after the fix; the committed mock-transport regression is supplemental. No stored-data contract changes.
Evidence reviewed 7 items Current-main gap: The fetched main revision still associates the shared worker singleton with the operation adapter rather than the module that creates it.
Worker ownership: The state worker owner creates the global singleton and registers its close operation with the database lifecycle.
Proposed lifecycle mapping: The introduced change points the test runner's singleton publication map at the worker owner module.
Findings None None.
Security None None.

How this fits together

Gateway tests can share a Vitest worker. After each file, the shared runner drains SQLite resources and resets module singletons before another file uses temporary database paths.

flowchart LR
  A[Gateway test file] --> B[Shared test runner]
  B --> C[File finishes]
  C --> D[SQLite lifecycle drain]
  D --> E[Worker owner retired]
  E --> F[Next test file]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +64. Total +64 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 67 3 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 67 3 +64

Review metrics

Metric Value Why it matters
Single-worker regression cost 6.92 s before; 6.06 s after The PR reports that the expanded ordered lifecycle check reuses its existing child-process fixture.

Technical review

Best possible solution:

Keep worker retirement with the shared runner's existing lifecycle owner and retain the ordered regression to catch future owner-module moves.

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

Yes. The old mapping and ordered cross-file path are clear in source, and the PR reports before-and-after real-worker and original-shard results; this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. Correcting the existing runner's owner mapping and checking cross-file retirement is a narrow repair for the reported fixture leak.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded Gateway CI isolation defect with no reported product runtime change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed owner is shared Gateway test cleanup. The PR reports an original 59-file Gateway run with three pathname failures before and 605/605 passing after, plus an ordered real-worker probe that observed retirement after the fix; the committed mock-transport regression is supplemental. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed owner is shared Gateway test cleanup. The PR reports an original 59-file Gateway run with three pathname failures before and 605/605 passing after, plus an ordered real-worker probe that observed retirement after the fix; the committed mock-transport regression is supplemental. No stored-data contract changes.

Evidence

What I checked:

  • Current-main gap: The fetched main revision still associates the shared worker singleton with the operation adapter rather than the module that creates it. (test/sqlite-test-lifecycle.ts:16, fbc0d118683c)
  • Worker ownership: The state worker owner creates the global singleton and registers its close operation with the database lifecycle. (src/state/openclaw-state-worker-owner.ts:660, 1950d114606d)
  • Proposed lifecycle mapping: The introduced change points the test runner's singleton publication map at the worker owner module. (test/sqlite-test-lifecycle.ts:16, 1950d114606d)
  • Cross-file regression: The second ordered fixture checks that the preceding file's worker closed and that canonical database close reaches the current worker. Its transport is mocked; the PR body separately reports a real-worker probe. (test/non-isolated-runner.sqlite-fixtures.ts:505, 1950d114606d)
  • Reported behavior proof: The captured PR body reports three SQLite pathname failures in the original 59-file Gateway plan before the repair, 605/605 passing afterward, and a separate two-file real-worker probe that failed before and passed after. These are contributor-reported observations; this read-only review did not rerun them. (1950d114606d)
  • Area history: Prior merged SQLite teardown and runner work includes commit c07906d. Local partial history did not support exact source-line introduction attribution. (test/sqlite-test-lifecycle.ts, c07906d5fa37)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • jalehman: 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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-29T00:51:24.926Z sha 1950d11 :: needs maintainer review before merge. :: none

@jalehman
jalehman marked this pull request as ready for review September 29, 2026 01:43
@jalehman
jalehman enabled auto-merge (squash) September 29, 2026 01:48
@jalehman
jalehman merged commit 34b811b into main Sep 29, 2026
207 checks passed
@jalehman
jalehman deleted the openclaw/fix-main-gateway-ci-lifetimes branch September 29, 2026 01:53
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…penclaw#160838)

* fix(test): retire shared-state workers between test files

Track the shared-state singleton at its creator module rather than the
operation adapter. A direct owner import otherwise survives the database
lifecycle reset and leaves later worker resources outside canonical close.

Extend the existing non-isolated runner proof with two file generations
that verify current-generation resource retirement. The regression fails
on the old mapping; a real worker probe reproduces the pathname conflict
before the change and reopens successfully afterward. Native admission
guards and test deadlines are unchanged.

Co-authored-by: jalehman <[email protected]>

* fix(test): prevent SQLite pathname failures in shared Gateway shards

Worked on by:
- @jalehman

Co-authored-by: jalehman <[email protected]>
OpenClaw-Publication: 966bf246-cd75-46a2-86de-ca62772a236b

---------

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: jalehman <[email protected]>
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: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

2 participants