Skip to content

test(cli): prove the catalog-budget escape hatch round-trips - #2595

Merged
cliffhall merged 2 commits into
v2/mainfrom
v2/chore/2428-skills-get-escape-hatch-test
Oct 5, 2026
Merged

cliffhall merged 2 commits into
v2/mainfrom
v2/chore/2428-skills-get-escape-hatch-test

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #2428

What the test turned up

The budget-exceeded message told users to run --method skills/get --uri to get a verdict for a skipped skill. Run as given, that command fetches the skill and checks nothing: verification only happens under --verify (clients/cli/src/handlers/run-method.ts, the skills/get branch). So the escape hatch the issue asked us to prove did not round-trip. It also left the URI blank, so the user had to look it up.

Changes

  • core/mcp/skillsVerification.ts: the message now names the whole runnable command, with the skipped entry's own URI and --verify:
    `--method skills/get --uri skill://<path>/SKILL.md --verify`
  • clients/cli/__tests__/skills-verify-cli.test.ts: a new end-to-end round-trip test against the in-process skills test server, with a catalog that sets skillCatalogMaxSkills: 1:
    1. skills/list --verify skips every skill after the first for budget reasons.
    2. The test pulls the backticked command out of a skipped report's incomplete text.
    3. It runs that command back through the real CLI (runCli, so the real argument parser) under the same budget.
    4. It asserts one --verify report for exactly that URI, built from files actually read (files.length > 0) and without the budget message.
  • clients/web/src/test/core/mcp/skillsVerification.test.ts: the existing core budget test now also asserts that each skipped report names its own URI plus --verify.

Verified that the test catches the defect

I ran the new test against two mutated versions of the message:

  • the original text (--uri with no value): fails
  • a URI without --verify: fails, naming what the run printed instead (not a --verify report (exit 0): …)

With the fix it passes.

Gate

  • Passed: local:validate (guards, format, lint, typecheck, every client build), verify:skills:cli, coverage:cli (447 tests), coverage:tui, coverage:launcher, verify:build-gate, verify:bundle-externals.
  • coverage:web failed on one test: inspectorClient-timeout-diagnostics.test.ts › "emits connectionDiagnosticsChange…", already tracked as Flaky integration test: inspectorClient-timeout-diagnostics 'emits connectionDiagnosticsChange' reads an undefined GET log entry #2580. It's a pre-existing flake and unrelated to this diff: in isolation it fails 5 of 6 runs with this PR's source change reverted, and 5 of 8 with it applied. Everything else in coverage:web passed (8782 tests).
  • Not run locally: the smokes and Storybook. The machine-wide gate lease timed out three times behind other worktrees' gates, so I ran the stages above directly, but not these, because they bind fixed ports and must not overlap another gate. This diff has no UI surface. CI runs both.
  • Sandbox note: the sandbox's outbound proxy (NODE_USE_ENV_PROXY=1) breaks two proxy/transport integration suites locally (18 tests, same result with or without this change). The gate results above were run with the proxy variables unset, which matches CI.

No UI change, so no screenshots.

🤖 Generated with Claude Code

A skill past the run's catalog budget is reported `incomplete` with a
message naming the command that verifies it on its own. That command was
`--method skills/get --uri` — which, run as given, fetches the skill and
checks nothing, so the advertised escape hatch produced no verdict.

The message now names the whole runnable command, the skipped entry's
own URI and `--verify` included. A CLI test hits the budget against the
skills test server, lifts the command out of the report, runs it back
through the real argument parser under the same budget, and asserts a
verdict for that skill from files actually read. It fails against both
the original text and a URI-without-`--verify` variant.

Closes #2428

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

The suggested command embeds a server-controlled URI without shell escaping, enabling command injection when pasted.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Fixes the CLI escape hatch for skills skipped by verification budgets.

Changes:

  • Includes the skipped skill URI and --verify in guidance.
  • Adds CLI round-trip and core message assertions.
File Description
core/​mcp/​skillsVerification.ts Builds the suggested verification command.
clients/​cli/​__tests__/​skills-verify-cli.test.ts Tests the command through the real CLI parser.
clients/​web/​src/​test/​core/​mcp/​skillsVerification.test.ts Verifies per-skill command text.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread core/mcp/skillsVerification.ts Resolved
The budget message spliced `entry.uri` into a command users are meant
to paste. The URI is server-controlled and shell metacharacters are
legal in one, so a server could author a command that runs something
else when pasted. Name a `<uri>` placeholder instead and point at the
report's own `uri`; the round-trip test fills it in as one argv
element, and the core test asserts the URI is never embedded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 1: one finding, fixed.

  • Shell injection via unquoted server-controlled URI (core/mcp/skillsVerification.ts): valid, introduced by this PR. Fixed in aa42f66 by using a <uri> placeholder instead of splicing entry.uri into the command. Tests assert the URI is never embedded, and the round-trip test fills the placeholder as one argv element.

Re-checked after the fix: validate:guards, validate:core, CLI check, coverage:cli, web format:check and the core unit test all pass.

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The corrected guidance is safe and the focused tests cover both message construction and real CLI behavior.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot review loop closed. Round 2 was clean ("Approval recommended", no findings, nothing suppressed), and it marked round 1's shell-injection finding resolved. Stopping on the first clean round.

@cliffhall
cliffhall merged commit 3f7f7da into v2/main Oct 5, 2026
6 checks passed
@cliffhall
cliffhall deleted the v2/chore/2428-skills-get-escape-hatch-test branch October 5, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Skills-verification budget-exceeded message names a --method skills/get --uri escape hatch with no test asserting it round-trips

2 participants