Skip to content

spec-review skills are structurally blind to hallucinations in file paths, math, and CLI flags #973

Closed

Description

@Akagilnc

Problem

/office-hours and /plan-* spec-review skills score design docs 8/10 on documents that contain CRITICAL fact errors — wrong file paths, wrong math, fabricated CLI flags, "reuse X module" claims that contradict hardcoded implementation. Spec-review subagents see only document text. They can't grep source, compute math, or shell out <tool> --help.

Evidence from one session

2026-04-11, ai-blogger-lab project. A design doc passed two spec-review rounds at 8.0/10, reached Status: APPROVED. A manually-triggered post-approval audit against real code / npm / math found 10 hallucinations, including:

  • CRITICAL: Beta(1,21) upper CI = 0.143 — fabricated. Actual scipy.stats.beta.ppf(0.975, 1, 21) = 0.1611. The pivot rule (fire when upper CI < 0.15) would not trigger until Beta(1,23) = 22 silences, not Beta(1,21) = 20 silences. Two errors compounded: wrong number and wrong trigger threshold. Would have made the L3 test suite red on first implementation.
  • High: Claimed post-decider was a "thin persona-neutral passthrough". Actual: hardcoded Chinese prompts + ["screenshot","text_card"] enum.
  • High: Claimed piece-critique was persona-neutral. Actual: every heuristic is CJK-specific (character-count thresholds, [\u4e00-\u9fa5] regex).
  • Medium: refactor run-tick.ts — wrong target. run-tick.ts is already DI'd; the wiring is in cli.ts:runSingleTick.
  • Low: --panels=1 CLI flag on comic-compositor.py — the script has no CLI flags, panel count comes from stdin JSON.

Post-approval audit is the canonical recovery pattern (Status: downgraded to APPROVED_WITH_KNOWN_CORRECTIONS, ## Post-Approval Hallucination Audit section appended). But catching these errors before implementation starts would save an entire day of wrong-code-on-wrong-doc.

Meta note — this very issue is evidence for itself. The first draft of this report contained scipy.stats.beta.ppf(0.975, 1, 22) = 0.1482 as the "actual" value. Wrong in both args and result: Beta(1,22) = 0.1544, and 0.1482 is Beta(1,23). I caught it by spawning a disposable scipy venv and computing the values before publishing, at my user's explicit instruction. A gstack-grounded-review skill would do this automatically for every numerical claim in a design doc — which is exactly the thing spec-review skills cannot.

Why I can't just add a rule to CLAUDE.md

I tried for an afternoon. A prose rule in CLAUDE.md requiring "grounded review before APPROVED" does not work:

  • v1 (~30 lines) adversarial review → 2 P0 + 6 P1 structural findings
  • v2 (~102 lines, addressed every v1 finding) → 3 P0 + 5 P1 new structural findings
  • v3 (~20 lines, intent-only) → Codex + Gemini external review found 4 more P0s (lost pre-approval gate, scope bypass via repo-local paths, no legacy-doc downgrade, vaporware pointer)

Not iteration fatigue. Prose has a structural ceiling for any rule requiring machine-verifiable artifacts. Each round opens new classes of holes. Logged as operational learning prose-rules-have-ceilings (confidence 10).

Sub-observation from the same session: reviewer subagents hallucinate too. A dispatched Claude subagent invented two CLI flag errors (codex -C and gemini --approval-mode plan), both refuted by actual --help output. Subagents can't substitute for real CLI calls in a grounding-check.

What would actually work: a gstack-grounded-review skill

Rough shape:

  1. Parse a markdown doc, extract concrete factual claims (file paths, function/module names, math, CLI flags, npm packages, API signatures)
  2. Route each claim to the right verifier: grep source, spawn python3 for math, <tool> --help for CLI, registry/official-docs lookup for npm. First-party sources only.
  3. Run Claude main + Codex + Gemini in parallel on the same claim set, no subagent fallback, no cross-contamination
  4. Deterministic severity merge (2-reviewer → high, 3-reviewer → critical, upgrade-only)
  5. Exit non-zero on unresolved critical/high findings — blocks Status: APPROVED in calling workflow
  6. Write findings to ## Grounded Review or ## Post-Approval Hallucination Audit section, re-run merges into existing section

Complements /plan-* (narrative/taste/architecture). Would be invoked by /office-hours, /plan-*, /ship before Status: APPROVED.

Offer

Happy to prototype if this scope is welcome. Can share the audit doc, the two failed prose iterations, and the Codex/Gemini review logs from the v3 attempt.

Activity

  1. time-attack commented on Jul 15, 2026

    @time-attack
    Contributor

    Thanks for this. Executing tool names extracted from untrusted documents lacks a safe verification contract; please define an allowlisted, argv-only, isolated, credential-free verifier with clear scope before implementation.

  2. Akagilnc commented on Jul 18, 2026

    @Akagilnc
    ContributorAuthor

    Thanks for the thoughtful reply, and sorry for the long silence on my end.

    In the time since I filed this, I ended up building it rather than waiting — a local, pre-PR, review-only cross-model gate that does grounded verification, and I've been running it daily across my own projects. It's now open source, in case the approach is useful for gstack: https://github.com/Akagilnc/ak-cross-m-review

    I think the design also addresses the safe-verifier concern you raised, so I'll walk through the logic rather than only drop a link.

    The core move: the claim is never its own evidence. A reviewer cannot accept "reuse module X" or "Beta(1,21) CI = 0.143" just because the document says so. It must verify directly — read the actual source, run the actual computation, execute the narrowest useful probe — and if it can't, it must mark the row unverifiable and say why. Findings carry an evidence field that records exactly what was read and what commands/probes were run. Agreement between models can raise confidence but never severity — grounding decides.

    Isolation is structural, not a bolted-on sandbox. Each model family reviews from its own fresh clone (a per-leg root). Inside that clone a reviewer may install dependencies, run tests, and create probes or local artifacts — but must not commit, push, or mutate remote state. Checkout mutations are evidence only, and the review is always judged against the pinned target, not the reviewer's scratch state.

    Why this avoids the injection risk you flagged. The concern was executing a tool name taken from an untrusted document. This design never does that: the untrusted doc is never a source of executable input. The reviewer formulates its own probes against a pinned target and authority list — the doc is the thing being checked, not a thing that gets run. So the "allowlisted / argv-only / isolated / credential-free" constraints are satisfied by construction, because the only things that execute are reviewer-formulated operations against a known repo in a throwaway clone.

    The rest is scaffolding around that: pin one base-to-HEAD range (or a design doc) as the target, pin the authority sources, dispatch a cross-model panel with a family floor of at least two successful reviewers from distinct model families, then a separate judge adjudicates the candidate findings and returns one verdict. SKILL.md and the prompts/ files are the full active spec if you want to see the exact contract.

    None of this is to say gstack should adopt my approach — it would need to fit the skill harness natively. But if a built-in grounded-review step is still of interest, the repo is a working reference for one way the safety contract can be met without a doc-driven execution path. Happy to share the original audit doc, the failed prose-rule iterations, and the cross-model review logs from this issue's evidence if any of that would be useful.

  3. capy-ai commented on Oct 11, 2026

    @capy-ai
    Contributor

    Thanks @Akagilnc for the idea. In the Oct 11 triage we grouped the open feature requests by theme so related asks get built together instead of one at a time. This one is part of the Planning reviews theme in TODOS.md (https://github.com/garrytan/gstack/blob/50d020ad9/TODOS.md#L54-L69). Closing it here so the open list stays actionable; it isn't rejected, and the theme credits every linked reporter when it's picked up.

  4. added
    parked
    on Oct 25, 2026
  5. capy-ai commented on Oct 25, 2026

    @capy-ai
    Contributor

    Reopened under the parked label: this is tracked in the Planning reviews theme in TODOS.md (https://github.com/garrytan/gstack/blob/main/TODOS.md#p3-feature-themes-from-the-wave-9-triage-filed-2026-10-11), and what fixes it is the grounded-verification step for spec reviews (paths, math and CLI flags checked against the repo), which also carries #1644's fixes and fixtures. Closed-but-tracked read as closed, so parked issues now stay open until they ship, are duplicates, or are declined (https://github.com/garrytan/gstack/blob/main/docs/triage.md).

  6. added
    S3
    enhancement
    on Oct 31, 2026
  7. capy-ai commented on Nov 1, 2026

    @capy-ai
    Contributor

    Fixed in #3775 (merged as 8695938, v1.92.15.0).

    gstack-plan-reality check now opens every file:line receipt and fails the review on a missing file or a line past the end (REALITY_RECEIPT_UNRESOLVED). The /office-hours spec reviewer reads the repository, checks CLI flags with gstack-office-hours-review probe --help <command> (an allowlisted, keyless --help run), and writes out the arithmetic behind any number it questions. The three-model severity merge and registry lookups were not taken.

    Thanks @Akagilnc for the clear report; it shaped the fix.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    S3enhancementparked

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions