Skip to content

fix: keep prepared-model tests inside owned state - #133131

Merged
steipete merged 1 commit into
mainfrom
steipete/test-prepared-model-fixture-isolation-20260830
Aug 30, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/test-prepared-model-fixture-isolation-20260830

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where prepared-model runtime tests could read shared temporary files even though model discovery was mocked. Native models.json capture and the read-only SQLite catalog reader still consumed fabricated agent-directory paths, allowing unrelated filesystem contents to influence tests. Fixture teardown could also run before a timed-out build actually finished.

This is a maintainer-requested test-isolation repair discovered during broader QA, not a production behavior change or an attempt to hide a failing assertion.

Why This Change Was Made

The shared harness now takes the existing OpenClawTestState owner, and all eleven consuming suites use its canonical agent paths. This preserves the intentional default agent identity, explicit shared-directory cases, exact model-file bytes, and OAuth hook-generation identities. Deferred tests release and join their actual work before cleanup; timeout coverage waits for build completion rather than treating the public timeout rejection as a drain. Failed tests retain their fixture namespace conservatively.

The regression guards real native file capture and the read-only database entry point before delegation. Broader filesystem mocks and production guards would conceal the fixture producer defect, so neither was added. Existing lifetime cases were moved into the catalog-owner suite rather than adding line-limit suppressions.

User Impact

No production, configuration, schema, protocol, dependency, or user-visible behavior changes. Developers can run the prepared-model test family without its agent-directory fixtures pointing at shared temporary locations.

Production LOC: +0/-0. Tests: +1605/-1190; test support: +35/-9. Much of the test churn is existing cases moved between suites and try/finally settlement around existing assertions. No test-only production API was introduced.

Evidence

  • RED: restoring the original fixture producer caused three intended containment failures, before any outside-path read or database-handle lookup. Static and live model capture attempted the unowned models.json path; the catalog case reached the unowned agent database path. The non-ENOENT PREPARED_FIXTURE_ESCAPE guard caused each failure.
  • GREEN: all 171 tests across the eleven affected files passed, with zero skipped, failed, or todo cases. This includes the eight-file shared-worker agent sequence, the configured isolated refresh lane, Gateway metadata lifecycle, and TUI integration.
  • The existing real-SQLite case reads only named catalog rows without running migration or repair also passed (one selected case, 31 intentionally unselected), preserving actual catalog-content coverage without duplicating it.
  • Complete classified changed checks passed: formatting, core and core-test typechecking, lint, dead exports, import cycles, and applicable repository guards. An initially incomplete worktree dependency installation caused formatter lookup and UI pako type-resolution failures. A normal frozen-lockfile install of the repository-pinned pnpm 12.1.0 resolved both; the aggregate and all 171 affected tests then passed again with the patch byte-identical.
  • Independent isolated Codex autoreview completed with no P0 findings. This is scoped review evidence, not a claim that hosted CI or live-provider testing has completed.
  • Tested base: cfddfc2f700ea456c66b887d70716b83d3ac0ea2. Changed files and relevant runtime owners were also compared with fetched main 136eab023035dd5943818f791d3c3db7d92e4491; those source blobs were unchanged.

Commands below use the native repository wrappers. Local report-output arguments are omitted. Each invocation used Node 24.15.0, one worker, private fixture roots outside Git, and no live credentials or channel calls.

node scripts/run-vitest.mjs src/agents/prepared-model-runtime.inbound-registry.test.ts src/agents/prepared-model-runtime-config-stamp.test.ts src/agents/prepared-model-runtime.test.ts src/agents/prepared-model-runtime.lifecycle.test.ts src/agents/prepared-model-runtime.catalog-owner.test.ts src/agents/prepared-model-runtime.owner-selection.test.ts src/agents/prepared-model-runtime.reload-auth.test.ts src/agents/prepared-model-runtime.reply-fallback.test.ts
node scripts/run-vitest.mjs src/agents/prepared-model-runtime.scoped-refresh.test.ts
node scripts/run-vitest.mjs src/gateway/server-chat-metadata-lifecycle.integration.test.ts
node scripts/run-vitest.mjs src/tui/embedded-prepared-runtime.test.ts
node scripts/run-vitest.mjs src/agents/plugin-model-catalog.test.ts -t 'reads only named catalog rows without running migration or repair'
node scripts/check-changed.mjs -- src/agents/prepared-model-runtime-config-stamp.test.ts src/agents/prepared-model-runtime.catalog-owner.test.ts src/agents/prepared-model-runtime.inbound-registry.test.ts src/agents/prepared-model-runtime.lifecycle.test.ts src/agents/prepared-model-runtime.owner-selection.test.ts src/agents/prepared-model-runtime.reload-auth.test.ts src/agents/prepared-model-runtime.reply-fallback.test.ts src/agents/prepared-model-runtime.scoped-refresh.test.ts src/agents/prepared-model-runtime.test-harness.ts src/agents/prepared-model-runtime.test.ts src/gateway/server-chat-metadata-lifecycle.integration.test.ts src/tui/embedded-prepared-runtime.test.ts

Hosted exact-head CI remains a landing prerequisite. This test-only change does not claim a live runtime, provider, channel, or deployment verification.

@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 gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 30, 2026 06:54
@steipete
steipete requested a review from a team as a code owner August 30, 2026 06:54
@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, 3:01 AM ET / 07:01 UTC.

ClawSweeper review

What this changes

The PR routes prepared-model tests through owned fixture state, drains deferred test work before cleanup, and adds native file/SQLite containment checks.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep this PR open. It is a focused, maintainer-authored test-isolation repair with no blocking introduced defect found; current main has not absorbed the branch, and exact-head CI is still completing.

Priority: P3
Reviewed head: 162fd4f181fa73e1123cde2811342ba6b1aaa278

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A well-scoped test-only repair with source-aligned containment coverage and no blocking review finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR changes tests and test support only, so the external contributor real-behavior-proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR changes tests and test support only, so the external contributor real-behavior-proof gate does not apply.
Evidence reviewed 6 items Native read boundary: Prepared runtime facts synchronously capture <agentDir>/models.json and read the persisted plugin catalog from the same agent directory; arbitrary fixture paths could therefore observe shared temporary state.
Fixture producer repair: The shared harness now resolves unspecified agent directories from the supplied OpenClawTestState and resets the runtime before state cleanup, keeping fixture ownership at the producer boundary.
Boundary regression coverage: The introduced containment tests guard both the actual synchronous model-file read and the read-only database delegation, while existing suites retain model catalog, lifecycle, Gateway, and TUI coverage.
Findings None None.
Security None None.

How this fits together

Prepared-model runtime preparation builds agent model snapshots used by agent runs, Gateway metadata, and the embedded TUI. Test inputs reach native models.json capture and read-only SQLite catalog access before mocked discovery consumes their results.

flowchart LR
  A[Test suites] --> B[Owned test state]
  B --> C[Shared prepared-model harness]
  C --> D[Native model file capture]
  C --> E[Read-only catalog database]
  D --> F[Prepared runtime snapshot]
  E --> F
  F --> G[Gateway and TUI tests]
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed: the patch has no actionable review finding and remains in the normal maintainer CI flow.
Agent review details

Security

None.

PR surface

Source +26, Tests +415. Total +441 across 12 files.

View PR surface stats
Area Files Added Removed Net
Source 1 35 9 +26
Tests 11 1605 1190 +415
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 1640 1199 +441

Review metrics

Metric Value Why it matters
Production versus test delta production +0/-0; tests +1605/-1190; test support +35/-9 The large diff moves and strengthens test isolation without altering production runtime behavior.

Technical review

Best possible solution:

Retain the state-owned fixture approach and land it after the exact-head CI gate completes successfully.

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

Yes—source establishes that the former harness supplied arbitrary temporary paths to native file and catalog readers; this read-only review did not execute the reported RED case.

Is this the best way to solve the issue?

Yes. Supplying the existing owned test state to the shared fixture producer repairs the source of the leak, rather than masking native reads or changing production behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a contained test-fixture isolation repair with no user-facing runtime or configuration change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored PR changes tests and test support only, so the external contributor real-behavior-proof gate does not apply.

Label justifications:

  • P3: This is a contained test-fixture isolation repair with no user-facing runtime or configuration 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 maintainer-authored PR changes tests and test support only, so the external contributor real-behavior-proof gate does not apply.

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)

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

Maintainer verification is complete for head 162fd4f181fa73e1123cde2811342ba6b1aaa278.

The root cause is the shared test producer supplying fabricated agent paths to real native model-file capture and read-only catalog readers. The repair keeps directory allocation and lifetime in the existing test-state owner across all eleven consumers, with no production changes or broader filesystem mocks. Timeout coverage joins actual build completion before fixture cleanup.

The three guarded pre-fix failures and fixed containment proof are retained; final native proof passed 171/171 affected tests, zero skips, plus the existing real-SQLite catalog-content case. The complete classified changed checks passed after normal pinned dependency provisioning, with the reviewed patch unchanged. Exact native test/check selections and the initial dependency-topology failures are documented in the PR Evidence section. Independent isolated Codex P0 review had no findings.

Exact-head CI run 33297995323, attempt 1 is completed and successful. Native review artifacts validated, and this command completed with hosted gates passing and the same prepared/remote head:

OPENCLAW_TESTBOX=1 scripts/pr prepare-run 133131

The latest ClawSweeper review has no actionable findings; its remaining next step was exact-head CI completion, now satisfied. No additional re-review is needed for an unchanged head.

Production +0/-0; tests +1605/-1190; test support +35/-9. This is test isolation and cleanup proof, not live provider, channel, or deployment verification. Proceeding through the native pinned-head merge gate.

@steipete
steipete merged commit 6e2a179 into main Aug 30, 2026
183 checks passed
@steipete
steipete deleted the steipete/test-prepared-model-fixture-isolation-20260830 branch August 30, 2026 07:08
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

agents Agent runtime and tooling 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: XL 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