DeepSeek-Reasonix icon indicating copy to clipboard operation
DeepSeek-Reasonix copied to clipboard

Ordinary-mode shell guard should report exit-status coverage instead of matching a verifier allowlist / 普通模式应改为标注退出码覆盖范围,而非匹配 verifier 白名单

Open SivanCola opened this issue 3 months ago • 0 comments

Problem

The ordinary-mode shell guard decides whether to block a command by asking "is one of these segments a host-recognized verifier?" — evidence.bashSegmentIsVerification, a hand-maintained allowlist keyed on argument position.

That question is the wrong one, and the allowlist is unbounded.

Wrong question. Ordinary mode is not protecting a verification receipt (that is Delivery's job). It is protecting against one thing: a later segment's exit status hiding an earlier segment's failure. Whether the later segment happens to be a verifier is irrelevant — rm -rf build; make hides the rm failure exactly as much as go generate; go test does. The verifier concept is inherited from Delivery and is vestigial here.

Unbounded allowlist. Recognition depends on argument position, so semantically identical commands classify differently:

pnpm install ; pnpm test                       -> recognized  (args[0] == "test")
pnpm -C desktop/frontend install ; pnpm -C desktop/frontend test
                                               -> not recognized (args[0] == "-C")

Every new tool, every flag form, every wrapper (npx, bunx, uv run, poetry run, monorepo -C/--filter/--cwd) needs another entry. Chasing that is not a fixed cost, and each miss is silent.

Proposed direction

Replace block with annotate, using the machinery #7757 just built.

tool.ShellExecution already carries structured per-call facts that never reach provider request bytes. Add one more fact — whether the shell's exit status covers the whole command — and let the model see it instead of refusing the call:

  • shellparse.CanMaskEarlierFailure (added in #7757) already answers the separator half deterministically: && chains are exempt, ; / newline / || / | / |& / & are not, and unparseable input reports ok=false rather than guessing.
  • On a call where the status does not cover every segment, set the new field and surface it on the tool card and in the model-visible result: exit 0, but this status does not cover the earlier segments.
  • Drop the verifier allowlist from the ordinary-mode path entirely. Delivery keeps it, because there a mutation invalidates the verification receipt regardless of exit status.

This is strictly more honest than a blocklist: no false positives, nothing for the model to route around by rearranging flags, and the information lands where the rest of the execution contract already lives.

Why not now

#7757 already narrowed the ordinary-mode blast radius so go build ./... && go test ./... and friends run again. With that in place a missed verifier only means "we did not block something we also did not need to block" — a cheap false negative in a guardrail. The remaining inconsistency in Delivery predates #7757.

Acceptance

  • Ordinary mode no longer consults bashSegmentIsVerification.
  • ShellExecution reports status coverage; Desktop / CLI / Serve show it.
  • The pnpm -C ... pair above classifies identically to its unflagged form.
  • Delivery-mode behavior is unchanged, with its existing guards still green.

SivanCola avatar Aug 06 '26 13:08 SivanCola