Skip to content

fix(test): mock the real skills/loading/workspace.js exports, not a hand-picked subset - #111

Closed
william-antoline-boon wants to merge 3 commits into
boonfrom
williamantoline/fix-embedded-workspace-mock
Closed

william-antoline-boon wants to merge 3 commits into
boonfrom
williamantoline/fix-embedded-workspace-mock

Conversation

@william-antoline-boon

@william-antoline-boon william-antoline-boon commented Aug 9, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

attempt.spawn-workspace.context-engine.test.ts (and its sibling spawn-workspace test) fail on current boon HEAD with:

[vitest] No "resolveExplicitSkillForRun" export is defined on the "../../../skills/loading/workspace.js" mock.

Found while cutting the boon.15 release PR (#110) — CI on that PR surfaced this as a pre-existing failure on boon, unrelated to the version-bump diff.

Why This Change Was Made

#107 added resolveExplicitSkillForRun to src/skills/loading/workspace.ts and attempt.ts now calls it directly, but the test-support mock for that module (attempt.spawn-workspace.test-support.ts) was a hand-written full replacement exporting only resolveSkillsPromptForRun — any other real export throws when called under test.

Switches the mock to vi.importActual + spread (matching the existing pattern used one mock up in the same file, for ../../workspace.js) so it tracks the module's real export surface and only overrides what the test actually needs to control (resolveSkillsPromptForRun).

Evidence

  • npx vitest run src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts — 2 test files, 124/124 passed (was failing before this change).

🤖 Generated with Claude Code


Summary by cubic

Fixes failing spawn‑workspace tests by mocking the real ../../../skills/loading/workspace.js, pins nanoid to patched versions, and fixes npm shrinkwrap generation for pnpm-scoped overrides. No runtime impact.

  • Bug Fixes

    • Use vi.importActual + spread to mirror real exports (so resolveExplicitSkillForRun is available).
    • Keep resolveSkillsPromptForRun mocked; other exports pass through.
  • Dependencies

    • Pin postcss>nanoid to 3.3.17 and node-llama-cpp>nanoid to 5.1.16 (HIGH advisories); add minimumReleaseAgeExclude and update the lockfile.
    • Update scripts/generate-npm-shrinkwrap.mjs to drop chained override selectors when building npm overrides to avoid npm EINVALIDTAGNAME; regenerate shrinkwraps for extensions/llama-cpp and extensions/zalouser.

Written for commit c5b4124. Summary will update on new commits.

Review in cubic

…and-picked subset

attempt.spawn-workspace.context-engine.test.ts (and its sibling spawn-workspace
test) fail with:

  [vitest] No "resolveExplicitSkillForRun" export is defined on the
  "../../../skills/loading/workspace.js" mock.

#107 added resolveExplicitSkillForRun to src/skills/loading/workspace.ts and
attempt.ts now calls it directly, but the test-support mock for that module
was a hand-written full replacement exporting only resolveSkillsPromptForRun
-- any other real export throws when called under test.

Switch the mock to vi.importActual + spread (matching the existing pattern
used one mock up, for ../../workspace.js) so it tracks the module's real
export surface and only overrides what the test actually needs to control.

Verified: both spawn-workspace test files pass (124/124).
@claude

claude Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@claude

claude Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Verified end-to-end on both base and PR branch:

  • Premise confirmed: resolveExplicitSkillForRun is a real export of src/skills/loading/workspace.ts (line 1513) and attempt.ts imports + calls it directly (lines 77, 1129). The hand-picked mock omitting it was correctly the cause.
  • Base (5293015^): reproduces the exact failure — [vitest] No "resolveExplicitSkillForRun" export is defined on the "../../../skills/loading/workspace.js" mock. Because the mock module aborts, 116 tests get skipped and 8 fail.
  • This PR: that error is gone; 110/124 tests run and pass. The pattern (vi.importActual + spread, overriding only resolveSkillsPromptForRun) matches the file's own established convention for sibling mocks (../../workspace.js, bootstrap-files.js, etc.).

Note: on my local box 14 of the now-unblocked tests hit ENOENT ... session.trajectory.jsonl under ~/.openclaw/tmp — a local filesystem/env artifact, unrelated to this diff (they only surface because the module no longer aborts). Not a blocker for this change.

Correct, minimal, test-only fix that tracks the real export surface. Ship it.

…28wg-ghj8-5hjv)

pnpm-audit-prod flags 2 HIGH advisories in the production dependency graph:
- [email protected] (postcss>vite>vitest chain, reached via
  @openclaw/qa-lab's @copilotkit/aimock dependency) — GHSA-2v37-7h3g-55p8,
  non-secure generator can loop indefinitely when size is zero, fixed <3.3.17.
- [email protected] (node-llama-cpp, an optionalDependency of
  @openclaw/llama-cpp-provider) — GHSA-28wg-ghj8-5hjv, same generator-loop
  class, fixed >=5.1.16.

Path-scoped pnpm overrides (postcss>nanoid, node-llama-cpp>nanoid) rather than
a single global nanoid override, since postcss's toolchain needs nanoid's
CJS-era ^3 API while node-llama-cpp resolves the ESM-only 5.x line — a global
override would force one chain onto an incompatible major.

Both patched versions were published 2026-08-07T16:41:06Z, inside the repo's
2880-min minimumReleaseAge window as of this fix, so they need an explicit
minimumReleaseAgeExclude entry (same pattern as the other pinned CVE-fix
versions already in that list).

nanoid does not appear in npm-shrinkwrap.json (not part of the packed release
tarball's runtime graph) — this is a dev/build-tooling + optional-provider-only
fix, zero impact on the shipped gateway artifact.

Verified: node scripts/pre-commit/pnpm-audit-prod.mjs --audit-level=high
-> "No high or higher advisories found for production dependencies."
@github-actions

github-actions Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • extensions/llama-cpp/npm-shrinkwrap.json
  • extensions/zalouser/npm-shrinkwrap.json
  • pnpm-lock.yaml
  • pnpm-workspace.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile, shrinkwrap, or workspace dependency policy changes are present.
  • Treat package-lock.json and npm-shrinkwrap.json diffs as security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions

github-actions Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

Dependency graph changes are blocked

OpenClaw does not accept dependency graph changes through PRs unless a repository admin or security explicitly authorizes the current head SHA. Dependency updates are generated internally by maintainers so external PRs cannot change the resolved graph.

Detected dependency graph changes:

  • extensions/llama-cpp/npm-shrinkwrap.json changed.
  • extensions/zalouser/npm-shrinkwrap.json changed.
  • pnpm-lock.yaml changed.

Auto-scrub was not attempted because this PR also changes dependency-related files that are not package lockfiles:

  • pnpm-workspace.yaml

Please remove lockfile changes manually if they are not needed.

To remove lockfile changes, restore them from the target branch:

git fetch origin
git checkout 'origin/boon' -- 'extensions/llama-cpp/npm-shrinkwrap.json' 'extensions/zalouser/npm-shrinkwrap.json' 'pnpm-lock.yaml'
git commit -m 'chore: remove dependency lockfile change'
git push

If this PR intentionally needs a dependency graph change, ask a repository admin or member of @openclaw/openclaw-secops to comment:

/allow-dependencies-change

The action will approve the current head SHA (c5b4124bbd9117c9be99d79dbf3fb73dc921e63c) when it reruns. A later push requires a fresh approval.

william-antoline-boon added a commit that referenced this pull request Aug 9, 2026
…on.15

Pulls in both fixes so this release PR's CI is clean too:
- fix(test): mock the real skills/loading/workspace.js exports
- fix(deps): pin nanoid off GHSA-2v37-7h3g-55p8 / GHSA-28wg-ghj8-5hjv

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread pnpm-workspace.yaml Resolved
pnpm-workspace.yaml's "postcss>nanoid" / "node-llama-cpp>nanoid" scoped
overrides are valid pnpm syntax but not valid npm override syntax, so
`generate-npm-shrinkwrap.mjs` was passing them straight through into the
temp package.json handed to `npm install --package-lock-only`, which
crashed with EINVALIDTAGNAME. Drop chained selectors before building the
npm overrides object — the equivalent npm-nested scoping for shrinkwrap
purposes is already derived from pnpm-lock.yaml by
readPnpmLockScopedVersionOverrides(). Regenerate the two shrinkwraps that
actually differ (llama-cpp's nanoid pin; zalouser's incidental registry
metadata refresh).

Also correct the nanoid exclude-entry comment in pnpm-workspace.yaml: the
stated publish date matched neither pinned version (cubic-dev-ai review).

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="scripts/generate-npm-shrinkwrap.mjs">

<violation number="1" location="scripts/generate-npm-shrinkwrap.mjs:61">
P3: Add a regression test for `readShrinkwrapOverrides()` that verifies pnpm `parent>child` entries are omitted from npm overrides while equivalent nested overrides are reconstructed; this security-pin translation currently has no coverage.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

// EINVALIDTAGNAME. These selectors exist so *pnpm* resolves the pinned version;
// the equivalent npm-nested scoping for shrinkwrap purposes is already derived
// from the regenerated pnpm-lock.yaml by readPnpmLockScopedVersionOverrides().
return Object.fromEntries(Object.entries(overrides).filter(([key]) => !key.includes(">")));

@cubic-dev-ai cubic-dev-ai Bot Aug 9, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Add a regression test for readShrinkwrapOverrides() that verifies pnpm parent>child entries are omitted from npm overrides while equivalent nested overrides are reconstructed; this security-pin translation currently has no coverage.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At scripts/generate-npm-shrinkwrap.mjs, line 61:

<comment>Add a regression test for `readShrinkwrapOverrides()` that verifies pnpm `parent>child` entries are omitted from npm overrides while equivalent nested overrides are reconstructed; this security-pin translation currently has no coverage.</comment>

<file context>
@@ -51,7 +51,14 @@ function isPlainObject(value) {
+  // EINVALIDTAGNAME. These selectors exist so *pnpm* resolves the pinned version;
+  // the equivalent npm-nested scoping for shrinkwrap purposes is already derived
+  // from the regenerated pnpm-lock.yaml by readPnpmLockScopedVersionOverrides().
+  return Object.fromEntries(Object.entries(overrides).filter(([key]) => !key.includes(">")));
 }
 
</file context>
Fix with cubic

@william-antoline-boon

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #112 — folded the (dependency-free) test-mock fix directly into the release PR since both were blocking the same boon.15 cut. The nanoid dependency bump that landed on this branch has been reverted (unrelated to ENG-17282, not required — security-fast isn't an enforced/required check on this branch — and it's better handled as its own dedicated security PR later).

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant