Skip to content

test: isolate shared /tmp state in reply, channel, and boot suites - #132960

Merged
steipete merged 1 commit into
mainfrom
steipete/test-tmp-isolation
Aug 30, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/test-tmp-isolation

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Several test fixtures handed real session-store, agent, transcript, and workspace
paths under the shared, machine-wide /tmp — /tmp/agent, /tmp/session.jsonl,
/tmp/sessions.json, and /tmp itself as a workspace directory. Mocking recording
or model execution did not intercept every filesystem consumer: channel execution
calls deliverPendingDeliveryNotice, which reads the session through the real
SQLite accessor and validates its schema.

The result is that unrelated state left on a developer or CI machine silently
changes test outcomes. A stale /tmp/openclaw-agent.sqlite at an older schema
version made suites fail with a migration error that has nothing to do with the
code under test, and passing runs only proved that nobody had left such a file
behind yet.

Why This Change Was Made

Route those fixtures through the existing test/helpers/temp-dir.ts tracker,
which creates unique directories under the canonical system temp root (including
macOS /var symlink handling). Shared fixture factories register cleanup on the
current test via onTestFinished on each invocation, rather than import-time
hooks that could attach only to the first suite under isolate: false.

No new helper, production seam, schema, configuration, or dependency was added,
and no repository-wide /tmp replacement was performed — inert literals that
terminate in mocked readers were deliberately left alone.

Fresh isolated fixtures then exposed two CLI progress tests whose one-second
vi.waitFor polling deadline was racing real startup. They now wait on the actual
callback through the existing deferred helper, keep their exact ordering
assertions, and release/drain the run on failure. No timeout was raised, assertion
weakened, mock broadened, retry added, or test skipped.

User Impact

None at runtime. Production LOC is unchanged (+0/-0); every changed line is test
or test-support code. The change removes a class of false failures that cost
maintainers time to diagnose.

Evidence

Failing-first, in the original execution order: with a synthetic
/tmp/openclaw-agent.sqlite at user_version=17 present, run-channel-turn.finalize
failed 5/19 on unmodified source with the schema-17 migration error raised at
src/state/openclaw-agent-db-schema-helpers.ts:265, through the read-only session
accessor and pending-delivery notice. With the same stale database present, the
repaired suite passed 19/19. The operator's real database was preserved by
rename and restored with SHA-256 and inode verification.

Blast radius: all 29 call sites of the three changed fixture factories were
enumerated, including two integration suites in src/agents that the original
lane runs did not cover. Re-validated on the rebased head:

node scripts/run-vitest.mjs <14 changed files + uncovered callers>
Test Files  2 failed | 26 passed (28)
Tests  2 failed | 583 passed (585)

The two failures were the first-case tests in
agent-runner-execution-cli-commentary.test.ts and
agent-runner-execution-cli-progress.test.ts. Subsequent review reproduced them
in a fresh two-suite process and traced them to missing model-input metadata in
the execution fixture, which triggered real provider catalog discovery. The
progress case uses mocked CLI events; the commentary case invokes a real local
scripted JSONL subprocess. Warm reruns and the earlier clean A/B did not establish
host load as the root cause.

The fixture correction is tracked separately in #132988 because this PR merged
while the extended verification was running. With that correction, a new empty
Vitest module cache passed 18/18 CLI tests; all 40 affected files passed 723 tests.
See the corrected review evidence.

Per-suite validation with the stale database deliberately present passed 310 tests
across all 14 changed suites plus test/helpers/temp-dir.test.ts. Fresh
$autoreview on the final edit reported no accepted or actionable findings.

Fixtures handed real session-store, agent, transcript, and workspace paths
under shared /tmp, so a stale machine-wide openclaw-agent.sqlite made
unrelated suites fail through the real SQLite accessor. Route them through
the existing test/helpers/temp-dir tracker instead, and wait on the actual
CLI progress callbacks rather than a one-second polling deadline.

Production LOC unchanged.
@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.

@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete
steipete force-pushed the steipete/test-tmp-isolation branch from b071738 to 940f716 Compare August 30, 2026 01:00
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 29, 2026, 9:13 PM ET / August 30, 2026, 01:13 UTC.

ClawSweeper review

What this changes

The PR replaces shared /tmp paths in reply, channel, gateway-boot, and plugin-SDK test fixtures with tracked per-test temporary directories, and synchronizes two CLI-progress tests on real callbacks.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review. The branch remains necessary on current main and uses the existing temp-directory lifecycle boundary, but its submitted aggregate validation still reports cold-start timeouts in a changed CLI-progress suite.

Priority: P3
Reviewed head: 940f7168e28d9a121b1c369c5c1c7900519ff967
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-consistent, but the reported cold-first-run timeouts leave merge confidence incomplete.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository state identifies this as a maintainer-authored, test-only PR, so the external contributor real-behavior gate does not apply; the PR body instead supplies focused stale-state validation evidence.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository state identifies this as a maintainer-authored, test-only PR, so the external contributor real-behavior gate does not apply; the PR body instead supplies focused stale-state validation evidence.
Evidence reviewed 6 items Introduced fixture isolation: The shared follow-up-run fixture now creates one tracked root per invocation and derives its agent, session, and workspace paths from it.
Cleanup owner: The existing helper tracks created directories and registers its cleanup callback with the supplied test lifecycle hook.
Real channel path: Prepared channel execution calls the pending-delivery notice after recording, so isolating the fixture store path protects a real session-accessor boundary rather than only a mock.
Findings None None.
Security None None.

How this fits together

Reply and channel tests construct workspace and session paths that reach real session and SQLite accessors before mocked dispatch boundaries. The shared temporary-directory helper creates unique directories and registers their cleanup with the test lifecycle.

flowchart LR
  A[Test fixture] --> B[Tracked temporary directory]
  B --> C[Agent workspace and session paths]
  C --> D[Reply and channel execution]
  D --> E[Session and SQLite accessors]
  E --> F[Test assertions and cleanup]
Loading

Decision needed

Question Recommendation
Should this maintainer-owned test-reliability PR land after exact-head cold-start validation resolves the reported CLI-suite timeouts? Require stable cold-start validation: Run the affected suites from a fresh process on the exact head and repair any reproducible timeout before merge.

Why: The implementation is focused and uses an established helper, but the PR's own aggregate evidence still contains two relevant initial-run timeouts and the item carries the protected maintainer label.

Before merge

  • Resolve merge risk (P1) - The submitted aggregate exact-head run reports two cold-first-run 120-second timeouts, including one in a changed CLI-progress suite; stable cold-start validation is still needed before landing.
  • Resolve merge risk (P1) - The patch directly relies on Vitest's onTestFinished API, but this checkout lacks a locally inspectable Vitest package and dependency-source inspection was blocked by unavailable network access; existing target tests show established use of that API.
Agent review details

Security

None.

PR surface

Source +10, Tests +42. Total +52 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 3 21 11 +10
Tests 11 139 97 +42
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 160 108 +52

Review metrics

Metric Value Why it matters
Production versus test delta production +0/-0; tests and test-support +160/-108 All introduced lines are test infrastructure or tests; the change does not alter shipped runtime behavior.

Merge-risk options

Maintainer options:

  1. Verify cold-start stability (recommended)
    Require a clean exact-head run of the affected CLI suites before merge, and fix the timeout if it reproduces.
  2. Pause if initial-run failures persist
    Hold this test-only PR until the cold-start failure is isolated from host contention or repaired at its owner boundary.

Technical review

Best possible solution:

Retain the existing tracked temporary-directory helper and land only after an exact-head cold-process run shows the affected CLI suites are stable or the remaining timeout cause is repaired.

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

Not applicable as a product-bug reproduction: this is a test-infrastructure PR. The supplied evidence gives a concrete stale-state test scenario, but read-only review did not execute it.

Is this the best way to solve the issue?

Yes, conditionally: reusing the canonical tracked temporary-directory helper repairs the shared-state boundary without adding runtime surface. The remaining question is whether the reported cold-start timeouts are environmental or a test defect.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is low-risk test reliability cleanup with no claimed user-visible runtime change.
  • merge-risk: 🚨 automation: The submitted exact-head aggregate validation still reports two initial-run test timeouts, including a changed suite.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository state identifies this as a maintainer-authored, test-only PR, so the external contributor real-behavior gate does not apply; the PR body instead supplies focused stale-state validation evidence.

Evidence

What I checked:

  • Introduced fixture isolation: The shared follow-up-run fixture now creates one tracked root per invocation and derives its agent, session, and workspace paths from it. (src/auto-reply/reply/agent-runner-execution.test-support.ts:477, 940f7168e28d)
  • Cleanup owner: The existing helper tracks created directories and registers its cleanup callback with the supplied test lifecycle hook. (test/helpers/temp-dir.ts:85, 940f7168e28d)
  • Real channel path: Prepared channel execution calls the pending-delivery notice after recording, so isolating the fixture store path protects a real session-accessor boundary rather than only a mock. (src/channels/turn/execution.ts:302, 940f7168e28d)
  • Current-main check: The fetched main revision changes only get-reply-run files under the relevant directories; it does not contain this PR's temporary-directory changes, so the PR is not obsolete. (a6bae8f5c63d)
  • Feature-history routing: Prior main history includes temporary-directory helper work in commit d9cbb7d. Its raw-parent patch could not be read because the partial clone attempted an unavailable network fetch, so this is routing context rather than introduction attribution. (test/helpers/temp-dir.ts:35, d9cbb7d23691)
  • Submitted validation: The PR body reports 310 passing focused tests with deliberate stale-state input, but also reports two 120-second cold-first-run timeouts in the aggregate exact-head run, including agent-runner-execution-cli-progress.test.ts. (src/auto-reply/reply/agent-runner-execution-cli-progress.test.ts:319, 940f7168e28d)

Likely related people:

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

Rank-up moves

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

  • Show a clean exact-head cold-process run for the affected CLI suites, with private data redacted if any output is posted.

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-30T01:06:32.228Z sha 940f716 :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review August 30, 2026 01:07
@steipete

steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated review result: the cold-start failures had a fixture-level cause beyond host contention.

A fresh process at the original PR head reproduced both first-case 120-second timeouts in the CLI progress/commentary suites (16 passed, 2 failed). The progress case uses mocked CLI events; only the commentary case forwards to a real local scripted JSONL subprocess.

The execution fixture lacked modality metadata for selected models. resolveRunModelHasVision therefore loaded the real provider catalog instead of using prepared fixture facts. Completing that catalog at the fixture producer removed the unintended discovery. With a new empty Vitest module-cache directory, both suites passed 18/18 in 51.57 seconds; their first cases completed in 32.59 and 34.66 seconds. No deadlines, assertions, mocks, or loader lifecycle were changed.

The completed fixture then passed all 40 affected files, 723 tests, including every shared-factory consumer and the module-reset integration paths. Changed-file checks passed; fresh Codex autoreview and independent source review found no remaining actionable issue within their reviewed scope. Production delta remains zero.

This PR merged while that verification was running, so the six-line improvement is tracked separately in #132988. Its exact-head hosted CI gates the follow-up landing. The earlier clean A/B runs remain observations, but they were insufficient to explain the cold failures.

Named follow-up: audit explicit cached SQLite-handle closure before temporary-directory cleanup in the existing miscellaneous runReplyAgent suite on Windows. No failure was reproduced in this review; the concern is separate from the fixture metadata correction.

@steipete steipete self-assigned this Aug 30, 2026
@steipete
steipete merged commit 5117f20 into main Aug 30, 2026
308 checks passed
@steipete
steipete deleted the steipete/test-tmp-isolation branch August 30, 2026 01:23
@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 30, 2026
…penclaw#132960)

Fixtures handed real session-store, agent, transcript, and workspace paths
under shared /tmp, so a stale machine-wide openclaw-agent.sqlite made
unrelated suites fail through the real SQLite accessor. Route them through
the existing test/helpers/temp-dir tracker instead, and wait on the actual
CLI progress callbacks rather than a one-second polling deadline.

Production LOC unchanged.
steipete added a commit that referenced this pull request Aug 30, 2026
…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 added a commit that referenced this pull request Aug 30, 2026
…ites (#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 #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.
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

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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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