Skip to content

test: complete current-plugin-metadata-snapshot mock factories - #129791

Merged
steipete merged 1 commit into
mainfrom
steipete/wonderful-snyder-102e95
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/wonderful-snyder-102e95

Conversation

@steipete

@steipete steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

~27 test files mocked src/plugins/current-plugin-metadata-snapshot.ts with explicit vi.mock factories exporting only getCurrentPluginMetadataSnapshot, violating the AGENTS.md rule that explicit factories must export every binding prod touches. Under isolate: false shard composition these incomplete mocks can leak into sibling test files. Live incident: src/agents/embedded-agent-runner/model-resolution-consistency.test.ts failed on CI with No withPluginMetadataSnapshotScope export is defined on the mock; PR #129526 added a file-local self-defense identity mock as a stopgap.

Why This Change Was Made

Repair the invariant at the producers instead of defending at one consumer: every incomplete factory now uses the importOriginal-spread form, overriding only the binding the test actually stubs, so leaked mocks still carry the full real module surface. With the sweep exhaustive, the stopgap identity mock in model-resolution-consistency.test.ts is removed.

src/agents/embedded-agent-runner/model.static-catalog.test.ts sat at exactly the 1000-counted-line max-lines cap; completing its factory added a line, so per repo file-split guidance (never suppress max-lines) its canonicalizeManifestModelCatalogProviderAlias describe block moved to a new sibling model.static-catalog.provider-alias.test.ts (632 + 390 counted lines afterwards). The new file is picked up by the agents-embedded lane glob (src/agents/embedded-agent-runner/*.test.ts) — no vitest config change.

User Impact

None at runtime — test-only change. Production LOC delta: 0. Removes a whole class of cross-file mock-leak flakes from the agents shards.

Evidence

  • Sweep exhaustiveness: rg -ln 'vi\.mock\([^)]*current-plugin-metadata-snapshot' src extensions test → all 36 mocking factories now spread importOriginal; none export a partial surface.
  • Incident composition rerun: node scripts/run-vitest.mjs src/agents/embedded-agent-runner/model.static-catalog.test.ts src/agents/embedded-agent-runner/model.static-catalog.provider-alias.test.ts src/agents/embedded-agent-runner/model-resolution-consistency.test.ts → 3 files, 36 tests passed (stopgap removed).
  • Composed lane: node scripts/run-vitest.mjs src/agents/embedded-agent-runner → 249 files, 3,376 tests passed.
  • All 29 touched suites in one composed run → 668 tests passed.
  • node scripts/check-changed.mjs → formatting, policy guards, max-lines ratchet, core-test typecheck, oxlint batches all green.

CI heal note

checks-node-compact-small-18 failed on an earlier rebased head with startup JS gzip: 340903 B vs 340900 B — main-side Control UI growth had consumed the 512 B rolling tolerance; this PR's diff is test-only and adds no UI bytes. A baseline refresh was briefly carried here, then dropped: main independently landed its own refresh in #129824 (22d3c550fca, baseline 340901 B), which covers the current bundle. This PR is now purely test-only again.

ClawSweeper before-merge items applied: rebased onto current main and re-validated with exact-head CI; its live-verification "FAIL" was the harness's own 30 s timeout — the visible test lines all passed, and the same composition passes locally (36/36).

@clawsweeper

clawsweeper Bot commented Aug 26, 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 commands Command implementations agents Agent runtime and tooling size: L maintainer Maintainer-authored PR labels Aug 26, 2026
@steipete
steipete marked this pull request as ready for review August 26, 2026 02:40
@steipete
steipete requested a review from a team as a code owner August 26, 2026 02:40
@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 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 11:36 PM ET / August 26, 2026, 03:36 UTC.

ClawSweeper review

What this changes

This PR completes Vitest mock factories for plugin metadata, removes a local leak workaround, splits an oversized agent test file, and refreshes the Control UI startup-size baseline.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for maintainer merge handling: the factory sweep repairs the producer-side mock invariant and removes the consumer workaround, but the branch is behind current main, checks are incomplete, and its CI baseline update needs exact-head confirmation.

Priority: P3
Reviewed head: 9791abfb9740738fc59a51b655483f1526ac6ada

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The source-level repair is coherent and supported by composed test evidence, with remaining confidence work limited to rebase and exact-head CI completion.
Proof confidence 🌊 off-meta tidepool Not applicable: Maintainer-authored test and CI maintenance is exempt from the external-contributor real-behavior-proof gate; the PR body supplies composed-suite evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Maintainer-authored test and CI maintenance is exempt from the external-contributor real-behavior-proof gate; the PR body supplies composed-suite evidence.
Evidence reviewed 6 items Current export surface: Current main exports withPluginMetadataSnapshotScope, so a factory exposing only the snapshot getter can omit a binding used by importing test paths.
Current-main manifestation: Before this branch, the static-catalog test factory on current main exported only getCurrentPluginMetadataSnapshot; the model-resolution test carried an import-original self-defense mock for the same module.
Producer-side repair: The new factory spreads the original module before overriding the intended getter, preserving the complete module surface for leaked mocks.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

$ node scripts/run-node.mjs --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 108.82 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 14.6s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4425ms (slowest: built plugin control-plane loads 3646ms)

OpenClaw 2026.8.1 (9791abf) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console (silent|fatal|error|warn|info|debug|trace)
  --no-color           Disable ANSI colors
  --profile ‹name›     Use a named profile (iso
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

Agent and command tests mock the plugin metadata snapshot used by model and plugin discovery. Vitest factories must retain exports that sibling tests may import under shared-process test composition, while the Control UI baseline controls a CI performance gate.

flowchart LR
  A[Test suites] --> B[Vitest mock factory]
  B --> C[Plugin metadata module]
  C --> D[Scoped metadata reader]
  D --> E[Agent and model tests]
  F[Control UI build] --> G[Startup-size baseline]
  G --> H[CI performance gate]
Loading

Before merge

  • Resolve merge risk (P1) - The baseline change increases the rolling UI gzip allowance by 541 B; rebase and exact-head performance validation must confirm it reflects main-side growth only and retains the hard cap.
  • Complete next step (P2) - This maintainer-owned, protected-label PR needs rebase and exact-head CI confirmation rather than an automated repair branch.
Agent review details

Security

None.

PR surface

Tests +47, Other 0. Total +47 across 30 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 29 476 429 +47
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 3 0
Total 30 479 432 +47

Review metrics

Metric Value Why it matters
Production versus test LOC production 0; tests +47 net; CI baseline 3 changed lines The behavioral repair is test-only; the separate baseline edit is the merge-sensitive non-test surface.
Control UI gate rolling baseline +541 B; hard cap unchanged at 358400 B This quantifies the CI allowance change that needs exact-head verification.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/agents/agent-project-settings.bundle.test.ts, vector/embedding metadata: src/agents/auth-profile-runtime-contract.test.ts, vector/embedding metadata: src/agents/embedded-agent-runner/model-resolution-consistency.test.ts, vector/embedding metadata: src/agents/embedded-agent-runner/model.static-catalog.provider-alias.test.ts, vector/embedding metadata: src/agents/embedded-agent-runner/model.static-catalog.test.ts, vector/embedding metadata: src/agents/model-auth-env.provider-aliases.test.ts, and 23 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Rebase and revalidate the CI baseline (recommended)
    Rebase onto current main, rerun the affected composed suites and Control UI performance check, and merge only if the refreshed baseline remains justified with its hard cap unchanged.

Technical review

Best possible solution:

Retain the producer-side mock repair and test split, then rebase and validate the composed agent suites and Control UI performance gate against current main before merging.

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

Yes, at source level: current main has a partial metadata-module factory while the consumer test imports the omitted module surface; the shared-process leak path is clear, though it was not executed in this dependency-less read-only checkout.

Is this the best way to solve the issue?

Yes for the test flake: repairing factories at their producers is preferable to retaining a consumer-side identity mock; the accompanying CI baseline still needs current-main validation.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 automation: The PR changes the Control UI performance-baseline input used by CI to decide whether startup-size checks pass.

Label justifications:

  • P3: This is test and CI-maintenance work with no claimed runtime user-impact change.
  • merge-risk: 🚨 automation: The PR changes the Control UI performance-baseline input used by CI to decide whether startup-size checks pass.
  • 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: Maintainer-authored test and CI maintenance is exempt from the external-contributor real-behavior-proof gate; the PR body supplies composed-suite evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame assigns the scoped metadata export to 4c4152e, and the related snapshot and baseline history is authored by Peter Steinberger. (role: introduced current metadata-snapshot behavior and recent area contributor; confidence: high; commits: 4c4152e71d2a, 9791abfb9740; files: src/plugins/current-plugin-metadata-snapshot.ts, config/control-ui-startup-budget-baseline.json)

Rank-up moves

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

  • Rebase onto current main and let the exact-head CI suite complete, including the Control UI performance gate.

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-26T02:46:21.131Z sha 5460b6cc976f17b3fee50ed24ddfb0169a5dbbe1 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the steipete/wonderful-snyder-102e95 branch 2 times, most recently from 76bb857 to 9791abf Compare August 26, 2026 03:30
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. label Aug 26, 2026
Explicit vi.mock factories for src/plugins/current-plugin-metadata-snapshot.ts
exported only getCurrentPluginMetadataSnapshot; under isolate:false shard
composition the incomplete mocks leaked into sibling files (CI incident:
model-resolution-consistency.test.ts lost withPluginMetadataSnapshotScope,
stopgapped in #129526). Convert all 27 incomplete factories to the
importOriginal-spread form, overriding only the stubbed binding, and remove
the now-unneeded self-defense identity mock.

model.static-catalog.test.ts sat at the 1000-counted-line max-lines cap, so
its canonicalizeManifestModelCatalogProviderAlias block moved to a new
model.static-catalog.provider-alias.test.ts sibling (picked up by the
agents-embedded lane glob) instead of adding a suppression.
@steipete
steipete force-pushed the steipete/wonderful-snyder-102e95 branch from 9791abf to b2472cd Compare August 26, 2026 03:52
@steipete
steipete merged commit f63a6b5 into main Aug 26, 2026
137 checks passed
@steipete
steipete deleted the steipete/wonderful-snyder-102e95 branch August 26, 2026 04:11
@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 26, 2026
…law#129791)

Explicit vi.mock factories for src/plugins/current-plugin-metadata-snapshot.ts
exported only getCurrentPluginMetadataSnapshot; under isolate:false shard
composition the incomplete mocks leaked into sibling files (CI incident:
model-resolution-consistency.test.ts lost withPluginMetadataSnapshotScope,
stopgapped in openclaw#129526). Convert all 27 incomplete factories to the
importOriginal-spread form, overriding only the stubbed binding, and remove
the now-unneeded self-defense identity mock.

model.static-catalog.test.ts sat at the 1000-counted-line max-lines cap, so
its canonicalizeManifestModelCatalogProviderAlias block moved to a new
model.static-catalog.provider-alias.test.ts sibling (picked up by the
agents-embedded lane glob) instead of adding a suppression.
vincentkoc added a commit that referenced this pull request Aug 26, 2026
* origin/main: (24 commits)
  fix(gateway): reject rootless session permission modes (#128149)
  docs(memory): document shipped turn-taint propagation for network tool output (#129837)
  fix(ui): pool reply-less wake activity into one chat rollup (#128442)
  fix(package): prevent installs from deleting validated runtime assets (#129724)
  fix(nodes): approve silent initial node surfaces and name the pending surface approval (#129795)
  fix(backup): preserve configured agent state roots (#129773)
  fix(ui): own chat history issuance with a closed state machine (#129776)
  fix(cron): preserve cancellation reason after late finalization (#129331)
  fix(cron): prevent run waits from failing after clock changes (#129805)
  fix(telegram): route commentary through one frozen progress owner (#128259)
  fix(release): start approved VCR mirror recovery jobs (#129829)
  test: complete current-plugin-metadata-snapshot mock factories (#129791)
  test(telegram): remove duplicate reaction case (#129848)
  fix(channels): honor supported account reply-threading policies (#129679)
  refactor(cli): deduplicate lazy subcommand registration (#129351)
  fix(ai): report interrupted local-model streams instead of empty success (#129794)
  refactor(cli): consolidate Gateway fallback and hook ownership (#129802)
  fix(qa): reject token confidence lanes without executed evidence (#129830)
  fix(tui): fence session state and delayed actions (#129810)
  fix(control-ui): keep task progress full width on hover (#129832)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations gateway Gateway runtime 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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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