Skip to content

fix(qapi): disable Claude tools before report execution - #441

Merged
barbatdev merged 1 commit into
mainfrom
fix/claude-qa-tool-isolation
Nov 16, 2026
Merged

barbatdev merged 1 commit into
mainfrom
fix/claude-qa-tool-isolation

Conversation

@barbatdev

Copy link
Copy Markdown
Contributor

Fixes #440

Summary

  • Claude QA invocation now passes --tools "" (separate empty argument) so built-in tools are disabled before launch, not only rejected in the output stream.
  • Invocation validation accepts an empty argument only for the exact fixed Claude vector; every other vector still rejects empty arguments.
  • docs/operating.md documents the pre-launch tool control; stream tool-call rejection stays as defense in depth.

Verification

  • RED/GREEN tests for the argv and the validation boundary (internal/qapi, internal/cli).
  • Differential check: Pi/OpenCode invocations unchanged.
  • go vet ./... and go test ./... pass after rebasing on current main.
  • Six-role live QA smoke on Mac/Claude: all PASS, no tool calls.

@barbatdev

Copy link
Copy Markdown
Contributor Author

Fleet review (glm)

Lens: requirements + adversarial. Reviewed PR #441 (head d62b893) against issue #440. All four acceptance criteria are satisfied by the diff: (1) claudeArgv() now includes "--tools", "" as a separate empty argument (internal/qapi/claude.go:128) and BuildInvocation launches exactly that argv, so tools are disabled before execution, not just rejected in the stream; (2) validInvocation (internal/qapi/runner.go:72-75) carves out the empty token only for an argv that exactly equals claudeArgv() — every other vector still rejects any empty or NUL argument, including near-misses (claudeArgv()+"extra", claudeArgv()[1:], per-index mutations), pinned by TestRunRejectsEmptyAndNULArgvBeforeStart which also proves rejected argv never launches a child; (3) tests pin both the argv contract (TestClaudeArgvContract, extended to all roles' BuildInvocation) and the validation boundary, and no Pi/OpenCode source changed; (4) docs/operating.md documents the pre-launch tool control with stream rejection kept as defense in depth. The end-to-end test TestQARunClaudeDisablesToolsBeforeLaunch pins the child argv, the env allowlist, and the bounded stdin frame. Adversarial checks found no way to carry an empty argument outside the fixed vector, no prompt/role content leaking into argv, and no NUL/empty bypass. No blocking findings.

Suggestion (1)

  • Record the minimum Claude Code version that supports the empty --tools value (internal/qapi/claude.go:128): The pre-launch tool control depends on Claude Code accepting --tools "" (empty value) as 'disable all built-in tools'. The repo records live verification on claude 2.1.278 and the fake pins 2.1.316, but claudeVersionOutput (internal/qapi/claude.go:40) accepts any semver with no documented floor. An older CLI that treats an empty --tools value differently (e.g. rejecting the flag or ignoring it) would at worst fail the run loudly rather than silently re-enabling tools, so this is not blocking; documenting the verified minimum version next to the flag would make the dependency explicit for anyone bumping or probing the runtime matrix.

Verdict: ready to merge

@barbatdev

Copy link
Copy Markdown
Contributor Author

Fleet review (glmflash)

Lens: adversarial. Reviewed PR #441 (fix(qapi): disable Claude tools before report execution) against issue #440's acceptance criteria, attacking the validation boundary, the argv construction, and the relaxation's blast radius. The fixed Claude vector is the only argv permitted to carry an empty argument, and the authorization is a strict full-vector equality (slices.Equal against claudeArgv()), so no near-match — a prefixed flag alone, claudeArgv()[1:], appended tokens, or per-index mutations — can smuggle an empty or NUL argument. NUL bytes remain rejected in all positions including the fixed vector. Tests pin the argv contract, the validation boundary (including a bare {"--tools",""} vector and per-index empty/NUL mutations), and an end-to-end run with a hostile task string that never leaks into child argv or environment. Pi/OpenCode invocations are untouched. If a deployed Claude Code version lacks --tools, the run fails closed at launch rather than executing with tools. All four acceptance criteria are met; no blocking findings.

Suggestion (1)

  • fixedClaude authorization keys on argv only, not on the binary (internal/qapi/runner.go:70): validInvocation() grants the empty-argument exemption when invocation.argv equals claudeArgv() regardless of invocation.binary. Within the current code paths only the Claude backend builds that argv against the Claude runtime, so this is not exploitable today, but tying the exemption to (binary, argv) — or asserting the binary is the resolved Claude runtime — would make the boundary hold even if a future backend reuses the same vector against a binary that interprets an empty argument differently.

Question (1)

  • Is --tools "" supported by the pinned Claude Code runtime version? (internal/qapi/claude.go:125): The pre-launch control depends on the target Claude Code binary accepting --tools with an empty value. The PR evidence cites a live smoke on version 2.1.316, but the runtime binary is resolved at run time (qaPiResolver / installed runtime), so a different installed version that drops or changes the flag would surface as a launch failure (fail closed), not as a silent tool enablement. Worth confirming the flag exists in the minimum supported Claude Code version documented for the qa backend.

Verdict: ready to merge

@barbatdev

Copy link
Copy Markdown
Contributor Author

Fleet review (deepseek)

Lens: evidence + test design. The diff is faithful to issue #440: claudeArgv() gains --tools, "" before --strict-mcp-config, and validInvocation relaxes the empty-argument rule only when slices.Equal(invocation.argv, claudeArgv()), so the intentional empty token is exactly as narrow as the criterion demands (and cannot drift, because the comparison key is the same fixed vector the builder uses). The validation boundary is well evidenced from the negative side: near-miss vectors (extra flag, appended empty token, dropped -p, a substituted value at every index, empty and NUL values at every index) all stay pre-launch invalid, and TestQARunClaudeDisablesToolsBeforeLaunch reads the argv back at the real process boundary, not from the builder. What is not evidenced from the diff is the effect the issue actually wants: that the pinned Claude build interprets an empty --tools value as "no tools" rather than accepting and ignoring it. No blocking finding: I found no input, path, or sequence in the diff that produces wrong behavior, and every acceptance criterion as written is met.

Suggestion (2)

  • Fake backend selection reads mutable cwd state instead of an explicit signal (internal/cli/qa_test.go:184): fakePi() now switches to fakeClaudeQA() by reading a file named qa-report-scenario from the child's working directory. The backend the fixture emulates is therefore decided by filesystem contents rather than by argv or an explicit variable, so the choice is invisible at the call site and any future test whose cwd happens to contain that file silently gets the Claude fake instead of the Pi fake. Test condition: select the fake from an explicit signal (an env var the test already sets, or inspection of the argv that TestMain sees) and keep the cwd files purely as recorded output. Not required for merge.
  • Pre-launch tool control is documented without the supported-version boundary (docs/operating.md:355): The new paragraph states the argv contract as an unconditional guarantee. Because the guarantee depends on Claude Code honoring an empty --tools value, the doc should name the version boundary at which it was verified (and, if the backend already probes --version, what happens on an unlisted build). Test condition, if a version guard exists: an invocation whose --version reports an unlisted build is rejected pre-launch rather than launched with a flag whose semantics are unknown. Not required for merge.

Question (1)

  • Which evidence shows --tools "" disables tools instead of being accepted and ignored? (internal/qapi/claude.go:128): Acceptance criterion 1 only requires the empty token in argv, and the tests pin exactly that. But the outcome the issue states ("a QA report run cannot execute tools") depends on Claude Code's interpretation of an empty --tools value, which the diff never evidences: it is version-dependent, and an unrecognized or defaulted empty value would produce the same argv and the same "no tool calls" observation as a prompt that simply never needed a tool. The PR body's six-role live smoke on Mac/Claude is the only supporting evidence and it is not reproducible from the diff (no Claude version recorded, no negative control). Suggested test conditions, none of which I am writing: (1) a prompt that explicitly requests a built-in tool, asserting no tool_use block appears in the stream — that is the only case that separates "disabled" from "ignored"; (2) the Claude version string the smoke ran against, asserted or recorded next to the argv contract, so an operator on an older or newer build sees which pin the claim holds for. Can you state the version and whether a tool-requiring negative control was run?

Verdict: ready to merge

@barbatdev

Copy link
Copy Markdown
Contributor Author

Fleet review (qwen38)

Lens: evidence. Audited against issue #440's four acceptance criteria: all are met and grounded in real tests. The --tools "" token is added to the fixed Claude vector and pinned at the actual process boundary (fakeClaudeQA records the child's os.Args and the test compares the full argv). The validation relaxation in runner.go gates the empty-token allowance on exact slices.Equal against claudeArgv(), and TestRunRejectsEmptyAndNULArgvBeforeStart covers near-miss vectors (extended, truncated, per-position changed, empty/NUL at each index) plus a launch-marker proving rejection is pre-launch. Pi/OpenCode paths are untouched and cannot produce the fixed vector. docs/operating.md documents the pre-launch control as required. Evidence gaps noted below are not blockers: the six-role live smoke and the semantic interpretation of --tools "" by Claude Code are only attested by the author's live run, not reproducible from the PR; the deterministic tests pin the token reaching the child process. No blocking findings.

Suggestion (1)

  • Env-leak containment check is weak for multi-line task strings (internal/cli/qa_test.go:100): In TestQARunClaudeDisablesToolsBeforeLaunch the loop checks strings.Contains(entry, task) per environment entry, but task contains a newline, so no single env entry can ever contain it and that assertion is always true. The name-based allowlist check already covers the leak risk effectively, so this is only about the assertion actually asserting something: checking the first line (or each line) of task would make the containment claim real.

Question (1)

  • Semantic effect of --tools "" rests on the live smoke, not the pinned tests (internal/qapi/claude.go:128): The tests prove the exact empty --tools token reaches the child process and that validation gates it correctly, but the claim that Claude Code CLI interprets --tools "" as disabling built-in tools before launch is only evidenced by the reported six-role live QA smoke on Mac/Claude, which is not reproducible from the PR. If a future Claude Code version changes the flag's parsing (e.g. treats empty as 'no override'), the pre-launch control would silently degrade to stream-level rejection only. Worth recording the Claude Code version tested (the fixture claims 2.1.316) in the evidence record so a parser change can be correlated.

Verdict: ready to merge

@barbatdev

Copy link
Copy Markdown
Contributor Author

Fleet review (mimo)

Lens: requirements. Checked the diff against all four acceptance criteria of issue #440; none is contradicted, partially satisfied, or untestable as written. AC1 (Claude argv includes --tools "" as a separate empty argument before execution): satisfied — claudeArgv() in internal/qapi/claude.go inserts the pair "--tools", "", pinned exactly by TestClaudeArgvContract and observed across the real process boundary by TestQARunClaudeDisablesToolsBeforeLaunch (the recorded child argv must equal the fixed vector including the empty token). AC2 (validation still rejects empty arguments in any other vector; only the exact fixed Claude vector may carry the empty --tools value): satisfied — validInvocation in internal/qapi/runner.go permits an empty token only when the whole argv equals claudeArgv(); TestRunRejectsEmptyAndNULArgvBeforeStart rejects nil, {""}, {"--tools", ""}, generic/Pi-style vectors with empties, every mutated or extended/trimmed near-match of the Claude vector (each near-match retains the empty token and is therefore caught), all NUL cases, and invalid binary/cwd, each verified pre-launch via an unchanged launch marker. AC3 (tests pin argv and the validation boundary; Pi/OpenCode keep previous behavior): satisfied — no Pi/OpenCode argv builder is touched, and non-Claude vectors keep the previous empty-argument rejection (fixedClaude is false for them); the CLI test additionally pins that hostile task text travels only in the bounded stdin frame, never in argv or the child environment. AC4 (docs/operating.md documents the pre-launch tool control): satisfied — the new paragraph around docs/operating.md:354 documents --tools "" before launch and explicitly demotes stream tool-call rejection to defense in depth. No concrete failure scenario was found in the diff; the runtime effect of --tools "" on Claude Code itself is supported by the PR's stated six-role live smoke rather than re-verifiable from the diff alone (tests may not be executed during review).

No findings.

Verdict: ready to merge

@barbatdev barbatdev added the type:bug Bug fix label Nov 16, 2026
@barbatdev
barbatdev merged commit fa71280 into main Nov 16, 2026
2 of 4 checks passed
@barbatdev

Copy link
Copy Markdown
Contributor Author

Post-merge QA (glm)

Lens: requirements + adversarial. The merge does what #440 asked: claudeArgv() now carries --tools "" as a separate empty argument before execution, and validInvocation() in runner.go admits an empty argument only when the argv is exactly the fixed Claude vector (slices.Equal against claudeArgv()), so any near-miss, appended empty, NUL byte, or other backend vector stays pre-launch invalid. Tests pin the argv contract, the end-to-end child argv/env/stdin frame (hostile task never reaches argv or env), and the rejection matrix including every single-position mutation of the Claude vector; Pi/OpenCode invocations are differentially unchanged. docs/operating.md documents the pre-launch tool control with stream rejection as defense in depth. Adversarial check on the exact-match allowlist: a hostile caller cannot widen it because argv is built internally, and an exact match contains exactly one intentional empty token. No defects found.

No findings.

Verdict: clean

@barbatdev

Copy link
Copy Markdown
Contributor Author

Post-merge QA (deepseek)

Lens: evidence + test design. The merge closes the pre-launch isolation gap of #440: claudeArgv() now carries --tools followed by a separate empty token, and validInvocation relaxes the empty-argument rejection only when the whole argv equals the fixed Claude vector, so every near-miss vector still fails before launch. Evidence for the argv is solid: TestClaudeArgvContract pins the vector, TestQARunClaudeDisablesToolsBeforeLaunch records the real child argv and environment through a fixture process (and asserts the hostile task text never reaches argv), and TestRunRejectsEmptyAndNULArgvBeforeStart enumerates near-matches, single-position mutations, appended empty/NUL tokens, and invalid binary/cwd values while proving no child was launched. Existing Pi/OpenCode invocations are untouched by the change. One residual question remains about the real CLI's semantics for an empty --tools list, recorded below as non-blocking.

Question (1)

  • Pre-launch control rests on an unpinned CLI semantic for an empty --tools list (internal/qapi/claude.go:119): The merged guard depends on the Claude Code CLI reading an empty --tools value as 'no built-in tools'. Everything the repo can check is the argv shape; the behaviour of the pinned runtime is claimed only by the PR's live smoke ('six-role live QA smoke on Mac/Claude: all PASS, no tool calls'), which is not reproducible from the repository and is not recorded as evidence anywhere in it. If a CLI revision treated an empty list as 'unset' and fell back to the default tool set, the argv tests would still pass while QA runs regained tool execution.

Verdict: clean

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

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Claude QA backend does not disable built-in tools before launch

1 participant