Skip to content

test(scripts): model AI declarations in bounded E2E preparation fixture - #160532

Merged
VACInc merged 1 commit into
mainfrom
fix/vitest-bounded-declarations-stub
Sep 28, 2026
Merged

VACInc merged 1 commit into
mainfrom
fix/vitest-bounded-declarations-stub

Conversation

@VACInc

@VACInc VACInc commented Sep 28, 2026

Copy link
Copy Markdown
Member

Summary

High Level TLDR

Fixes red main. test/scripts/run-vitest-bounded.test.ts › "prepares the direct E2E reader generation once" fails on clean checkouts in two cases: success and prebuilt. Commit 9c69495 added a check that runs the typed AI build again when packages/ai declarations are missing. That check is correct. The test's stub AI build never wrote declarations, and the test read the real checkout's packages/ai/dist. On a clean CI checkout, the check therefore fired and started an extra ai build. This PR changes only the test fixture so it models the declarations the real build writes.

Root Cause

  • Before: on clean origin/main (no packages/ai/dist), node scripts/run-vitest.mjs test/scripts/run-vitest-bounded.test.ts --maxWorkers=1 gives 2 failed | 37 passed:
    • success: expected [ 'runtime', 'ai', 'ai' ] to deeply equal [ 'runtime', 'ai' ]
    • prebuilt: expected [ 'ai' ] to deeply equal []
  • CI evidence: PR fix: deliver final replies after unrelated plugin reloads #160009, run 36438955843, job checks-node-compact-small-17.
  • Mechanism: 9c69495 (fix(ci): prepare packed AI declarations before prebuilt tests) added preparePrebuiltAiPackage in scripts/lib/vitest-build-prerequisites.mts. It runs when OPENCLAW_E2E_USE_PREBUILT_DIST=1 and the e2e config selects the packed AI consumer. It checks every types entry in packages/ai/package.json with fs.existsSync. If any entry is missing, it runs tsdown.ai.config.ts.
    • success: prepareE2eVitestRuntime runs the stubbed runtime and AI builds, then sets OPENCLAW_E2E_USE_PREBUILT_DIST=1. The stub writes no .d.mts, so prepareVitestRuntime sees missing declarations and starts a second ai build.
    • prebuilt: the test says a prebuilt generation exists, but the checkout has no declarations, so the check runs one ai build.
  • The product check is correct. The real E2E setup AI build emits declarations (tsdown.ai.config.ts sets dts unless OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1, and the test strips OPENCLAW_*). A real run therefore finds complete declarations and does not rebuild. Only the fixture was wrong. The test also depended on local packages/ai/dist state, which is why it passed on hosts that had built the AI package.

Exact change

Test-only change in test/scripts/run-vitest-bounded.test.ts:

  • When the stub ai build succeeds, it writes a declarations receipt file in the test temp dir.
  • The existing I/O preload now also wraps fs.existsSync. For <repo>/packages/ai/dist/*.d.mts it returns whether that receipt exists. All other paths go to the real existsSync. The test is now independent of the checkout's dist.
  • The prebuilt case pre-writes the receipt, because a complete prebuilt generation includes the typed AI package.

Expectations are unchanged: still exactly ["runtime", "ai"] for success and [] for prebuilt. No product code changed. The missing-declarations path stays covered by test/scripts/vitest-prebuilt-ai.test.ts from 9c69495.

Verification

Real behavior proof

On a clean worktree at origin/main 917e1b8 plus this commit (no packages/ai/dist), Node from ~/.local/share/openclaw-node/current:

node scripts/run-vitest.mjs test/scripts/run-vitest-bounded.test.ts --maxWorkers=1
  • Before (same worktree, without the change): Tests 2 failed | 37 passed (39) (failures shown above).
  • After: 5 consecutive runs, each Tests 39 passed (39), exit 0. Wall is about 51s for the file, the same as before. No new tests were added and no subprocesses were added.
  • The test left no packages/ai/dist behind.
  • node scripts/check-changed.mjs: exit 0.

What was not tested

  • Full CI shard checks-node-compact-small-17 was not rerun. This PR's own CI will run it.
  • The product path with a real (non-stubbed) typed AI build was not run. It was already covered by 9c69495's proof, and this PR does not change it.

Fixes red main.

@clawsweeper

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

@VACInc
VACInc force-pushed the fix/vitest-bounded-declarations-stub branch from 3d6fc7e to fa078c4 Compare September 28, 2026 15:44
@clawsweeper

clawsweeper Bot commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 28, 2026, 11:52 AM ET / 15:52 UTC.

ClawSweeper review

What this changes

The branch makes the bounded E2E runner test simulate typed AI declarations produced by its stubbed build and by a complete prebuilt setup.

Merge readiness

✅ Ready for maintainer review

Current main still has the clean-checkout fixture failure. The branch addresses that failure without changing the production declaration check, so this PR remains useful.

Priority: P2
Reviewed head: fa078c40e53d4bd870cd706b52afc238251001b5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused fixture repair has a credible clean-checkout explanation and reported before-and-after validation, with no concrete patch defect found.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The contributor proof gate does not apply to this MEMBER-authored PR. Its body reports before-and-after runs of the changed bounded-runner test on a clean checkout; no product runtime or stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The contributor proof gate does not apply to this MEMBER-authored PR. Its body reports before-and-after runs of the changed bounded-runner test on a clean checkout; no product runtime or stored-data contract changes.
Evidence reviewed 6 items Introduced fixture change: The stub records successful AI preparation in a temporary receipt; the preload uses that receipt only for AI declaration existence checks.
Current main still needs the fixture correction: The relevant test and prerequisite files are identical at the pinned PR base and fetched main; the introduced fixture change is absent from current main.
Production prerequisite boundary: The runner checks declared AI type files and starts a typed build when any is absent; the PR does not change this behavior.
Findings None None.
Security None None.

How this fits together

OpenClaw’s Vitest runner prepares shared runtime and AI package artifacts before starting E2E test readers. This fixture substitutes inexpensive build processes while exercising the runner’s real preparation decisions.

flowchart LR
  A[Vitest E2E command] --> B[Runtime preparation]
  B --> C[AI declaration check]
  G[Test fixture receipt] --> C
  C --> D{Declarations available?}
  D -->|No| E[Typed AI build]
  D -->|Yes| F[Vitest readers]
  E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +18. Total +18 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 19 1 +18
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 19 1 +18

Review metrics

Metric Value Why it matters
Focused suite cost 39 tests; about 51 seconds reported per run The changed fixture adds no test cases or subprocesses to this existing suite.

Technical review

Best possible solution:

Keep the fixture tied to successful stub output while retaining the production missing-declarations repair and its separate regression coverage.

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

Yes. On a clean checkout without AI declarations, the existing stub produces no declaration files while the real prerequisite check looks for them; the PR body reports the resulting two test failures. This review did not run the test.

Is this the best way to solve the issue?

Yes. A temporary receipt makes the fixture model successful AI preparation without weakening the production declaration guard or changing its separate missing-file tests.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: A clean-checkout test fixture failure affects validation, with no demonstrated user-facing runtime regression.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: A clean-checkout test fixture failure affects validation, with no demonstrated user-facing runtime regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: 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.

@VACInc

VACInc commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

Follow-up: #160392 is now merged. Its final main integration preserved this canonical AI-declaration fixture fix and dropped the duplicate repair. Relative to the integrated main version, test/scripts/run-vitest-bounded.test.ts retained only two executable-matcher substitutions from scripts/run-node.mjs to scripts/prepare-vitest-runtime.mjs. The AI-declaration contract fixed here remains intact.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant