Skip to content

test: isolate shared /tmp session-store paths in runner and health suites - #133568

Merged
steipete merged 1 commit into
mainfrom
steipete/gracious-franklin-9b0f09
Aug 30, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/gracious-franklin-9b0f09

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where OpenClaw's own test suite writes a shared, machine-wide
SQLite database at /tmp/openclaw-agent.sqlite, outside any per-test temporary
directory.

The agent-runner execution fixtures hand storePath: "/tmp/sessions.json" to the
real executeAgentTurn. Production resolution derives the agent database from the
store's directory (resolveSqliteTargetFromSessionStorePath -> dirname /tmp), so
those turns create and migrate /tmp/openclaw-agent.sqlite through
openOpenClawAgentDatabase.

That file is harmless while it matches the current schema version. It stops being
harmless the next time OPENCLAW_AGENT_SCHEMA_VERSION
(src/state/openclaw-agent-db-contract.ts) is bumped: a stale copy left on a
developer or runner machine then fails every unrelated suite that reaches the real
session accessor, with a migration error from
src/state/openclaw-agent-db-schema-helpers.ts. That is exactly the failure
#132960 had to repair across 14 suites, and a remaining producer brings it back.

Why This Change Was Made

Route the leaking store paths through the existing test/helpers/temp-dir tracker,
matching the pattern established in #132960, rather than deleting the shared path
(a cleanup hook would race other suites on the same machine).

The auto-reply harness already owns tracked agentDir, sessionFile, and
workspaceDir for these fixtures, so it gains one makeTestSessionStorePath()
helper beside them and the five leaking literals call it.

The same investigation found src/gateway/health/collector.deadline.test.ts and
collector.legacy-owner.test.ts mocking resolveSessionStorePathCore to the same
shared /tmp/sessions.json. Those suites never create the database — they mock the
accessor — but real target resolution still opens /tmp/openclaw-agent.sqlite
read-only to read its owner, so the store.path they assert on depends on whether
a machine-wide database happens to exist and who owns it. Same invariant, fixed in
the same change.

User Impact

No user-visible or runtime behavior change: test-only, production LOC unchanged.
Developers and CI runners no longer accumulate a shared /tmp/openclaw-agent.sqlite
from these suites, so the next agent-schema bump cannot resurrect the cross-suite
failure mode that #132960 cleaned up.

Evidence

Producer located by instrumenting openNodeSqliteDatabase with a stack-trace probe
(file-append, because vitest swallows process.stderr.write from production
modules) and running lane groups with the shared file removed:

@@@PRODUCER@@@ /tmp/openclaw-agent.sqlite
    at openNodeSqliteDatabase (src/infra/node-sqlite.ts)
    at openOpenClawAgentDatabase (src/state/openclaw-agent-db.ts:326)
    at resolveSessionEntry (src/config/sessions/session-accessor.sqlite-entry.ts:135)
    at loadSessionEntry (src/config/sessions/session-accessor.sqlite-entry.ts:140)
    at createAgentPatchedSessionModelRunGuard (src/agents/session-model-auto-revert.ts:146)
    at executeAgentTurnInternalWithRetryState (src/auto-reply/reply/agent-runner-execution.ts:301)
    ...
    at src/auto-reply/reply/agent-runner-execution.test-support.ts:335
    at src/auto-reply/reply/agent-runner-execution-cli-sessions.test.ts:532

Regression proof, shared file deleted before each run:

  • Before: full src/auto-reply lane created /tmp/openclaw-agent.sqlite at schema 19.
  • After: full src/auto-reply lane (6160 tests) leaves it absent.
  • src/auto-reply/reply/agent-runner-execution-{cli-sessions,context-failures}.test.ts: 22/22 pass, file stays absent.
  • src/gateway/health: passes, file stays absent.
  • node scripts/check-changed.mjs: clean.
  • Codex autoreview (--mode branch --base origin/main): scoped-clean, no accepted findings.

Note for reviewers: this host runs several OpenClaw checkouts concurrently, and any
of them recreates the same machine-wide path. File-existence timing is therefore not
attribution here; the stack-trace probe above is.

Follow-up recorded, not in this PR: test/scripts/docs-sync-publish.test.ts pins the
release-notes page list, so each release breaks it on main from a lane that
release PRs do not select (#133557 -> #133581). It should read the versions from the
navigation instead.

@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 30, 2026 21:43
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 30, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 30, 2026
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 6:29 PM ET / 22:29 UTC.

ClawSweeper review

What this changes

The PR replaces shared /tmp session-store paths with tracked per-test temporary paths in agent-runner and Gateway health tests.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking introduced defect was found. This focused maintainer-authored test-isolation patch should remain open for normal human landing review after exact-head CI completes.

Priority: P3
Reviewed head: 0d316a99a2b7dbd4ee21ba6799dcbd0c481aa053
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-consistent test-only repair with no blocking review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This is a MEMBER-authored, test-only PR, so the external-contributor real-behavior-proof gate does not apply; the supplied before/after test evidence is supplementary.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This is a MEMBER-authored, test-only PR, so the external-contributor real-behavior-proof gate does not apply; the supplied before/after test evidence is supplementary.
Evidence reviewed 6 items Isolated test-path producer: The new helper creates a unique tracked directory and returns its sessions path; each calling test receives cleanup through Vitest's test-finished hook.
Runtime ownership path: Session scope resolution passes a supplied store path to SQLite target resolution, and the resolver derives openclaw-agent.sqlite beside a conventional sessions file.
Gateway health caller: Gateway health creates a status session-store reader; that reader resolves the SQLite target before invoking the supplied session-entry reader, so the mocked store paths remain relevant to target resolution.
Findings None None.
Security None None.

How this fits together

Test fixtures supply session-store paths to session resolution, which derives the adjacent agent SQLite target before runner execution or Gateway health projection proceeds. The patch keeps those derived targets within test-owned temporary directories.

flowchart LR
  A[Test fixtures] --> B[Session-store path]
  B --> C[Session target resolution]
  C --> D[Adjacent agent SQLite target]
  D --> E[Runner and health assertions]
Loading

Decision needed

Question Recommendation
Should this maintainer-authored test-isolation patch land once exact-head CI is complete and green? Land after exact-head CI: Accept the focused producer-boundary test isolation after required checks finish green.

Why: The patch is clean and test-only, but the maintainer label and MEMBER authorship require explicit human handling rather than automated cleanup.

Before merge

  • Complete next step (P2) - No repair lane is needed: no introduced defect was found, and protected maintainer handling plus exact-head CI govern landing.
Agent review details

Security

None.

PR surface

Source +12, Tests +26. Total +38 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 12 0 +12
Tests 4 36 10 +26
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 48 10 +38

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests and test support +48/-10 All introduced lines are test fixtures or test-support cleanup; no runtime product code changes.

Technical review

Best possible solution:

Land the isolated-path approach once a maintainer accepts the test evidence and the required checks are green on this exact head.

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

Yes, source-reproducible: supplied /tmp/sessions.json reaches SQLite target resolution, which derives an adjacent agent database. This read-only review did not execute the test suite.

Is this the best way to solve the issue?

Yes. Reusing the established tracked temporary-directory helper repairs the path producer before real session-target resolution, rather than masking the resulting database access downstream.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is low-risk test-suite maintenance with no runtime or user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This is a MEMBER-authored, test-only PR, so the external-contributor real-behavior-proof gate does not apply; the supplied before/after test evidence is supplementary.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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-08-30T21:49:19.675Z sha d52aa391f3cce8f661b9d6b90401a49c443c3d7a :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/gracious-franklin-9b0f09 branch from d52aa39 to 6f8c4fd Compare August 30, 2026 22:16
…ites

The agent-runner execution fixtures handed storePath "/tmp/sessions.json" to the
real executeAgentTurn. Production resolution derives the agent database from the
store's directory, so those turns created and migrated the machine-wide
/tmp/openclaw-agent.sqlite. A stale copy of that file makes unrelated suites fail
through the real session accessor the next time OPENCLAW_AGENT_SCHEMA_VERSION is
bumped, which is the failure #132960 had to repair across 14 suites.

Route the store paths through the existing test/helpers/temp-dir tracker: the
auto-reply harness gains makeTestSessionStorePath() beside the tracked agentDir
and workspace it already owns, and the two gateway health collector suites, whose
resolveSessionStorePathCore mock made real target resolution inspect the same
shared database read-only, get their own tracked directories.

Production LOC unchanged.
@steipete
steipete force-pushed the steipete/gracious-franklin-9b0f09 branch from 6f8c4fd to 0d316a9 Compare August 30, 2026 22:22
@steipete
steipete merged commit ee6106c into main Aug 30, 2026
173 checks passed
@steipete
steipete deleted the steipete/gracious-franklin-9b0f09 branch August 30, 2026 22:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to shojikumaru/openclaw that referenced this pull request Aug 30, 2026
…cked-delivery

* origin/main:
  fix(ui): wait for restored draft before clearing (openclaw#133575)
  fix(deps): update fast-uri security patches (openclaw#133572)
  test: reduce workflow sanity fixture cleanup time (openclaw#133588)
  fix(media): normalize detected Matroska MIME (openclaw#133383)
  refactor(docker): retire ClawDock shell helpers (openclaw#133594)
  perf(browser): reuse snapshot refs and screenshot metadata (openclaw#133598)
  perf: load web chat history in larger, faster batches (openclaw#133565)
  fix(plugins): keep bundled plugins bundled when selected by plugins.load.paths (openclaw#133584)
  test: isolate shared /tmp session-store paths in runner and health suites (openclaw#133568)
  fix(cron): avoid no-op schedule repair writes (openclaw#133552)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
…ites (openclaw#133568)

The agent-runner execution fixtures handed storePath "/tmp/sessions.json" to the
real executeAgentTurn. Production resolution derives the agent database from the
store's directory, so those turns created and migrated the machine-wide
/tmp/openclaw-agent.sqlite. A stale copy of that file makes unrelated suites fail
through the real session accessor the next time OPENCLAW_AGENT_SCHEMA_VERSION is
bumped, which is the failure openclaw#132960 had to repair across 14 suites.

Route the store paths through the existing test/helpers/temp-dir tracker: the
auto-reply harness gains makeTestSessionStorePath() beside the tracked agentDir
and workspace it already owns, and the two gateway health collector suites, whose
resolveSessionStorePathCore mock made real target resolution inspect the same
shared database read-only, get their own tracked directories.

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

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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.

1 participant