Skip to content

feat(spec): measure-first grounding gate for explorer findings — deterministically verify cited paths/symbols before they enter the plan #922

Closed

Description

@admarble

⚠️ Re-aimed 2026-08-09 after /spec measurement — read this first.

The original framing below is preserved for the reasoning trail, but its central premise is measurably false: sequant-explorer has 0 recorded spawns across 1,332 local transcripts (169 of which ran /spec; 78% of those spawned no subagent at all). The explorer fan-out never executes — filed as #927.

Consequences: AC-2 as originally written is unsatisfiable (the explorer-transcript corpus is empty, so no rate is computable), and Phase B would have gated a code path that never runs. This is the denominator trap @zeweihan predicted, in its limit case — the gate would have measured 0% and read as a clean bill of health when the true reading is "no data".

The method survives; only the corpus was wrong. Measure-first, deterministic-script-not-LLM-pass, and the #608/#834 reasoning all still hold. The target moves from explorer report text to the posted SEQUANT_PHASE: spec plan comment — durable, timestamped (so the contemporaneous-commit caveat becomes resolvable rather than a caveat), and the artifact /exec actually consumes. Acceptance Criteria below are updated accordingly; everything above them is the original text.

Full measurement: spec planning comment.

Problem

/spec's research fan-out is the one agent output in the pipeline that is consumed with zero verification.

The spec skill spawns 1–3 sequant-explorer subagents (spec/SKILL.md:133-148) whose entire output contract is one prose line in the agent definition: "Report findings in structured format: file paths, patterns discovered, recommendations" (.claude/agents/sequant-explorer.md). Their free-form findings feed directly into the Implementation Plan. No existence check on cited files, no symbol resolution, no validation of any kind — not in the skill, not in the agent definition, not in TypeScript.

The codebase already documents this exact failure mode — but only for QA: qa/SKILL.md:165 — "Ad-hoc background agents for code review are unreliable — they hallucinate about file existence, misattribute API patterns…". /spec has no equivalent caveat or mitigation, yet its explorers are the same kind of background agent, and their claims have a longer blast radius: a plan built on a phantom path or misattributed API misdirects /exec, then burns /qa and quality-loop iterations on rework, in a worktree run that costs 20–30 minutes.

Evidence honesty: there is no captured sequant incident of an explorer hallucination corrupting a plan. The failure mode is documented in-repo for the same agent class, and was observed directly on background QA agents in a downstream project (Apr 2026: claims that existing test files "don't exist in the repository", misattributed fetch wrappers). Because direct evidence here is thin, this issue is deliberately structured measure-first (the #608 pattern): Phase A establishes the phantom-citation rate before any gate ships, and "rate ≈ 0 → close as acceptable-as-is" is an explicit, valid outcome.

Design

Not another LLM review pass. #608 measured the last two always-on LLM gap sections (§6c, §6d) at a 0% action rate; #834's finding is that automated checks reliably catch exactly what is a deterministic gate and miss what requires judgment. Verifying "does src/lib/foo.ts exist" is deterministic — it should be a script, not a prompt.

Phase A — measure (blocks Phase B): a standalone script (idiom: scripts/qa/precheck.ts → .sequant/gap-precheck.json) that extracts path-like and symbol-like citations from explorer report text and checks them against the repo (git ls-files for paths, grep for symbols). Run it over ≥10 recent spec-run transcripts (~/.claude/projects/*/*.jsonl) and report the phantom-citation rate per run. Extraction reuses the PATH_REGEX genus from assess-collision-detect.ts with the #769 lesson applied: extraction over prose produces false positives, so the checker only verifies existence (side-effect-free, cheap) and never treats a miss as more than a flag; deleted-file citations from historical transcripts are excluded by checking against the commit contemporaneous with the run where feasible, else noted as a caveat.

Phase B — gate (only if Phase A shows signal): wire the same script into /spec as a post-explorer step. The spec agent runs it over the explorer reports before writing the plan; findings citing nonexistent paths/symbols are quarantined — the agent either re-grounds them with a direct Read/Glob (cheap, in-session) or excludes them from the plan with a one-line note. Deterministic script output, agent judgment only on the surfaced candidates — the same division of labor as qa's Phase 0c precheck (qa/SKILL.md:808).

Rejected alternatives: a fresh-context LLM verifier per finding (token cost with no evidence of need — see #608); tightening the explorer prompt alone (prompt-only contracts are the failure mode #814 just demonstrated); verifying explorer recommendations (judgment calls, not checkable facts — only existence claims are in scope).

Effect on process and code quality

  • Plans grounded in real code paths before /exec commits 20–30 minutes of worktree work to them — the highest-leverage point to catch confabulation because everything downstream compounds it.
  • Near-zero marginal cost: the gate is a deterministic script (~ms, no tokens); the only LLM cost is re-grounding actually-flagged citations, proportional to the error rate.
  • Data before ceremony: if Phase A measures ~0, we close with a number instead of shipping a gate that pattern-matches to methodology. Either outcome improves on today's unknown.
  • Symmetry: closes the documented QA-agent reliability caveat's blind spot in /spec, with the mitigation style (deterministic precheck + agent adjudication) the codebase already uses.

Acceptance Criteria

Re-aimed per the banner above. AC-1/AC-3 are near-verbatim; AC-2 changes corpus and adds a second rate; AC-4–AC-7 are Phase B and must be re-derived, not merely unblocked. Note the (Phase B) marker is now inside the description — a leading (Phase B) parenthetical defeats the AC parser's ID match and forces re-synthesized IDs.

Phase A — measure (blocks Phase B)

  • AC-1: A citation-grounding script exists at scripts/spec/ground-check.ts that takes plan/report text and emits JSON {citations: [{raw, kind: path|symbol, exists, matchedAt?}]} using git ls-files/grep only — no writes, no network. Follows the scripts/qa/precheck.ts idiom: always exit 0, findings live in the JSON, consumers decide gating.
  • AC-2: Phase A report posted as a comment on this issue, over ≥10 recent SEQUANT_PHASE: spec plan comments (not explorer transcripts), each checked against the commit contemporaneous with its timestamp. The report states two rates, not one: the phantom rate (phantom citations ÷ path-typed citations) and the coverage rate (findings carrying any mechanically-extractable citation ÷ all findings). It states plainly that this is an existence score, not a grounding-quality score — it catches the loud failure (invented path) and leaves the quiet one (real path, wrong description of it) untouched. It also records the explorer-corpus null result as the finding it is.
  • AC-3: Decision gate recorded on this issue. Low coverage → do not wire the gate regardless of phantom rate. High coverage + phantom rate ≈ 0 → close as acceptable-as-is, citing the number. High coverage + real phantom rate → proceed to Phase B.
  • AC-4: Extractor validated against a real captured spec plan comment, not a synthetic fixture (feat(qa): require detection-pattern verification for skill regex/grep/awk changes #551/feat(#529): enforce manual-test AC gate in QA skill #547), with Windows/POSIX handled via path.posix against git ls-files output — no hand-rolled separator regexes. Unit + CLI integration tests mirroring scripts/qa/precheck.test.ts and precheck-cli.integration.test.ts; note that without an .integration. infix the 5s unit-project timeout applies to subprocess tests (fix(test): tsx-spawning integration tests blow vitest's 5s default — phase-registry should use the prebuilt dist like its five siblings #842).

Phase B — gate: NOT BUILT. AC-3 resolved against it on the data (0.31% adjudicated hallucination rate, ~4.7:1 false-flag ratio). Left unchecked deliberately — these are declined, not outstanding.

  • AC-5: (Phase B) The spec skill, all 3 mirrors sync-verified, runs the grounding script before plan writing; quarantined citations are either re-grounded in-session or excluded from the plan with a one-line note. Must merge with the SEQUANT_SPEC marker block fix(run): spec recommendation handoff parses ephemeral chat text — recommended phases silently dropped; move the contract to a structured comment marker #921 added to the Output Template, not rewrite around it.
  • [~] AC-6: (Phase B, half-landed — resolvedSha ships in the checker output; the per-finding flag has no plan artifact to live in without a gate) Each cited finding carries a provenance flag (ground-checked / re-grounded / unverified) and the commit SHA the check ran against, surviving into the posted plan artifact — so /exec and /qa can see the cost of trusting an unverified citation, and can detect drift on the specific cited files rather than trusting a spec-time confirmation whose shelf life is shorter than the 20–30 min /exec takes to consume it. (Both points from @zeweihan's review.)
  • AC-7: (Phase B) Gate test scoped to the skill section that invokes the script, mutation-verified per CLAUDE.md — delete the invocation, confirm exactly that test fails, record in the PR body.
  • AC-8: CHANGELOG entry if Phase B ships; Phase A alone needs only the issue-comment report.

Non-Goals

References

Complexity

Phase A: simple — one read-only script + a measurement report. Phase B: simple-to-medium — skill wiring across 3 mirrors + one gate test.

Self-assessed workflow

spec → exec → qa for Phase A (script + report); Phase B re-assessed after the data lands.

Activity

  1. admarble commented on Aug 9, 2026

    @admarble
    ContributorAuthor

    #922 — feat(spec): measure-first grounding gate for explorer findings — deterministically verify cited paths/symbols before they enter the plan
    OPEN
    ────────────────────────────────────────────────────────────────

    → PROCEED — Measure-first Phase A is a narrow, mechanical deliverable (script + report)

    Commands:
    sequant run 922

    spec → exec → qa · 7 ACs
    ────────────────────────────────────────────────────────────────
    Cleanup:
    gh issue edit 922 --add-label enhancement # unlabeled; net-new measurement feature
    ────────────────────────────────────────────────────────────────
    ⚠ Phase B (spec/SKILL.md wiring) overlaps #921 and is contingent on Phase A's measured phantom-citation rate — scope exec to Phase A pending the decision gate
    ────────────────────────────────────────────────────────────────

  2. zeweihan commented on Aug 9, 2026

    @zeweihan

    Strong writeup, and the "deterministic existence-check, not another LLM review pass" instinct is exactly right — git ls-files/grep is the correct tool class for existence. A few things the measure-first framing should account for from the audit-trail side, because they shape what Phase A's number will and won't tell you:

    Existence phantoms are the easy class; misattribution is the unmeasured dangerous one. A finding citing src/lib/auth.ts that exists but is described as "uses a deprecated callback pattern" when it doesn't, passes the existence gate and is strictly harder to catch than a phantom path. The acceptance criteria (AC-1/AC-2) measure existence-class phantoms, which is fair for a deterministic script — but the "blast radius" framing in the problem statement should be honest that the gate catches the loud failure (invented path) and leaves the quiet one (real path, wrong description of it) untouched. That's still worth shipping; just don't let Phase A's number read as a grounding-quality score. It's an existence score.

    The rate ≈ 0 → close gate has a denominator trap. If Phase A measures ~0 phantom citations, the first thing to check is whether the extractor is too narrow rather than whether the problem is absent. Prose-typed findings ("the auth module handles retries") carry no path syntax and won't enter the denominator at all — so the measured rate is (phantom path citations) / (path-typed citations), not (unsupported findings) / (all findings). Recommend AC-2 also report the coverage rate: what fraction of explorer findings carry any mechanically-extractable citation. A phantom rate of 0% over a coverage of 30% means 70% of findings were never checkable in the first place — which is the more decision-relevant number for whether Phase B is worth wiring in.

    The downstream plan needs to know which citations were confirmed, not just that some were quarantined. When an explorer finding is re-grounded in-session via Read/Glob, the Implementation Plan should record the verification on the finding itself — otherwise a plan is byte-identical whether its citations were checked against the tree or merely asserted. The property /exec and /qa care about is "confirmed-against-tree" vs "asserted-only," and that distinction has to survive into the plan artifact, not live only in the gate's stdout. Cheapest form: a provenance flag per cited finding (ground-checked / re-grounded / unverified), so the cost of trusting an unverified finding is visible downstream instead of absorbed.

    Grounding has a shelf life. The gate checks citations against the tree at spec-time; /exec may run later against a tree that moved (concurrent work, rebase). A path verified at spec-time can be gone or semantically changed by the time /exec commits 20–30 min to it. Near-free mitigation: record the commit SHA the ground-check ran against alongside the finding, so /exec can detect drift on the specific cited files and re-trigger cheaply rather than trusting a stale confirmation. Provenance should include when it was grounded, not just that it was.

  3. admarble commented on Aug 9, 2026

    @admarble
    ContributorAuthor

    /spec — Planning Review

    Complexity: Standard (7 ACs, 3 directories)

    Headline: the issue's premise is measurably false, and the measurement is already done. sequant-explorer has 0 recorded spawns. Phase A as written cannot run (empty corpus); the concern behind it is real but sits on a different artifact. Recommendation below re-aims Phase A rather than closing the issue.


    Premise Check — the explorer fan-out is a dead prompt

    The issue's first design claim is "The spec skill spawns 1–3 sequant-explorer subagents … whose free-form findings feed directly into the Implementation Plan." Measured against the local transcript corpus (~/.claude/projects/**/*.jsonl, 1,332 transcripts, 2026-07-07 → 2026-08-09):

    Measurement Result
    "subagent_type":"sequant-explorer" across all 1,332 transcripts 0
    Transcripts that loaded the /spec skill body 169
    …of those, spawning no subagent at all 131 (78%)
    …spawning Explore / general-purpose instead 38 (22%)
    Headless dogfood /spec runs (matcha-maps + ad-motion) 98 → 0 explorer spawns
    Explorer report text in .sequant/logs/** (this repo + both testbeds) 0 (2 hits are changed-file lists)

    Availability is not the cause — .claude/agents/sequant-explorer.md is installed in this repo and in both consumer testbeds. The corpus is representative of headless runs: 160 transcripts live in worktree project dirs and 108 contain the exec-skill body, so the driver does record phase agents; /spec simply runs pre-worktree, which is why its 169 transcripts sit in the main-checkout dirs.

    The agent is choosing targeted inline Read/Grep over the fan-out — which is the behavior the repo's own guidance prefers. This planning run did exactly that, and never considered spawning an explorer.

    What this does to each AC

    AC Status under the measurement
    AC-1 (script exists) Buildable, but its declared input — explorer report text — is an artifact nothing produces
    AC-2 (rate over ≥10 explorer transcripts) ❌ Unsatisfiable as written. n = 0. No rate is computable
    AC-3 (decision gate) Satisfiable — but the answer is "denominator is zero", not "phantom rate ≈ 0"
    AC-4 / AC-5 / AC-6 (Phase B) Would gate a code path that never executes → zero value as specified
    AC-7 (CHANGELOG if Phase B ships) N/A under the recommendation

    This is @zeweihan's denominator trap in its limit case. Their review predicted the measured rate would be phantom path citations / path-typed citations rather than unsupported findings / all findings; the actual coverage denominator turns out to be 0 findings, so the gate would have measured 0% and read as "no problem" when the real reading is "no data".


    Recommendation — re-aim Phase A, keep the method

    The measure-first structure, the deterministic-script design (git ls-files/grep, no LLM pass), and the #608/#834 reasoning are all sound and worth keeping. Only the corpus is wrong.

    Primary (recommended): measure the posted spec plan comment, not explorer transcripts. The ## Implementation Plan + AC sections of <!-- SEQUANT_PHASE: spec --> issue comments are the artifact /exec actually consumes, they are durable and timestamped (so the contemporaneous-commit caveat in the issue becomes resolvable rather than a caveat), and they exist in volume. This keeps AC-1 and AC-3 nearly verbatim and changes only AC-2's corpus definition.

    Secondary (same script, second corpus, near-free): the 38 spec runs that did spawn Explore/general-purpose researchers. Their results are tool_result blobs in the transcripts — extractable, and closest to the original "verify the researcher" framing. Small-n, so report it as a side panel, not the headline number.

    Rejected: make explorers actually fire, then measure. That ships a behavior change in order to manufacture the problem you then measure, and it runs against the repo's own preference for targeted reads. Also out of bounds — the issue's own Non-Goals forbid changing explorer count/model/maxTurns.


    Scope Assessment

    Non-Goals: present and well-formed (3 items) ✅

    Metric Value Status
    Feature count 2 ⚠️
    AC items 7 ⚠️
    Directory spread 3 ⚠️

    Verdict: ⚠️ SCOPE_WARNING — driven entirely by the Phase A + Phase B bundle. Scoping this run to Phase A only (per the /assess note) drops it to 3 ACs / 1–2 directories → SCOPE_OK. Plan below assumes Phase-A-only.

    AC Quality Check

    lintAcceptanceCriteria: ✅ all 7 clear and testable — no vague/unmeasurable/open-ended patterns.

    One hygiene note the linter doesn't cover: the (Phase B) parenthetical in AC-4/5/6 defeats parseACLine, so those three fall through to the bare-checkbox path and get re-synthesized IDs. They happen to land on AC-4/5/6 here by ordering luck. Prefer - [ ] **AC-4:** (Phase B) … so the ID is parsed, not inferred.

    Behavior-rule detector: no AC triggered → Rule Touchpoints section omitted (correctly — this is a new script, not a rule edit).


    Acceptance Criteria (as re-aimed)

    AC-1: Citation-grounding script exists — unchanged

    scripts/spec/ground-check.ts, JSON out {citations:[{raw, kind: path|symbol, exists, matchedAt?}]}, git ls-files/grep only, no writes, no network.

    Verification: Unit Test + Integration Test
    Scenario: Given a captured report containing a real path, a deleted path, a prose-only sentence, and a backticked non-path → When npx tsx scripts/spec/ground-check.ts --in <file> → Then JSON classifies each correctly and exit code is 0 regardless of findings.
    Assumptions: follows the scripts/qa/precheck.ts idiom (always exit 0; findings live in JSON; consumers decide gating). Test layout copies precheck.test.ts + precheck-cli.integration.test.ts.

    AC-2 (re-aimed): Phase A report over spec plan comments

    Verification: Manual Test (measurement report posted as an issue comment)
    Scenario: Given ≥10 recent SEQUANT_PHASE: spec plan comments → When ground-check runs against each comment's contemporaneous commit → Then the comment reports both numbers.

    Per @zeweihan, AC-2 must report two rates, not one:

    • Phantom rate = phantom citations / path-typed citations — an existence score
    • Coverage rate = findings carrying any mechanically-extractable citation / all findings

    and must state plainly that the gate catches the loud failure (invented path) and leaves the quiet one (real path, wrong description) untouched. Also report the explorer-corpus result above as the null finding it is.

    AC-3: Decision gate — unchanged in form

    Verification: Manual Test. Low coverage → the gate is not worth wiring regardless of phantom rate. High coverage + ~0 phantom → close as acceptable-as-is with the number. High coverage + real phantom rate → Phase B.

    AC-4 – AC-7 (Phase B): deferred behind AC-3, and to be re-derived, not merely unblocked

    If Phase B proceeds it targets the plan comment, not explorer reports, so AC-4's wording needs rewriting. Two @zeweihan design inputs to carry forward: a per-finding provenance flag (ground-checked / re-grounded / unverified) that survives into the plan artifact so /exec and /qa can see the cost of trusting an unverified citation, and the commit SHA the check ran against, since a spec-time confirmation has a shelf life shorter than the 20–30 min /exec takes to consume it.


    Implementation Plan (Phase A only)

    Phase 1 — script

    1. scripts/spec/ground-check.ts, modeled on scripts/qa/precheck.ts:1-30 (shebang, exported types, schemaVersion, always-exit-0).
    2. Path extraction: reuse the PATH_REGEX genus from src/lib/assess-collision-detect.ts:84 (backtick-quoted, tracked-root-anchored, known-extension). Reuse normalizeSkillMirrorPath (:175) — otherwise every skill citation triples. Apply the fix(assess): path extraction counts cited paths as modification targets, producing phantom collisions #769 lesson: verify existence only, never escalate a miss beyond a flag.
    3. Symbol extraction: backticked identifiers only; resolve via git grep -n. Report unresolved as exists:false, not as an error.
    4. Windows/POSIX: path.posix against git ls-files output (always /-separated) — no hand-rolled separator regexes (AC-5's requirement, worth honoring in Phase A since the extractor is written here).

    Phase 2 — corpus + report
    5. Harvest ≥10 SEQUANT_PHASE: spec comments via gh issue list/gh api; for each, resolve the contemporaneous commit from the comment timestamp so deleted-file citations don't inflate the phantom rate.
    6. Run, tabulate phantom rate + coverage rate per run, post as an issue comment.
    7. Record the AC-3 decision in the same comment.

    Phase 3 — tests
    8. Unit tests on the extractor against a real captured spec plan comment, not a synthetic fixture (#551/#547; the synthetic-fixture trap is exactly how a multi-marker extractor hides false negatives).
    9. CLI integration test mirroring precheck-cli.integration.test.ts. Note: no .integration. infix → the unit project's 5s timeout applies, which subprocess tests will flake against.


    Design Review

    1. Where does this logic belong? scripts/spec/, sibling to scripts/qa/. It is a standalone measurement CLI, not library code — nothing in src/lib/ should import it. Path-extraction primitives stay in src/lib/assess-collision-detect.ts and get imported, not copied.
    2. Simplest correct approach? One read-only script + one issue comment. No skill edits, no state writes, no new config in Phase A. Rejected: putting the checker in src/lib/ behind a CLI wrapper (premature — one consumer), and extending precheck.ts (different phase, different lifecycle).
    3. Existing pattern? scripts/qa/precheck.ts — deterministic precheck emitting JSON, agent adjudicates surfaced candidates, missing/malformed JSON falls back rather than blocking. Fits exactly.
    4. What would a senior reviewer challenge? "You measured the premise false — why build the script at all?" Because the concern survives the premise: 78% of spec runs cite files with no verification of any kind, and the plan comment is a better measurement target than the explorer transcript ever was. The script is the cheap part; the number is the deliverable.

    Feature Quality Planning

    • Extractor false positives are the main risk. fix(assess): path extraction counts cited paths as modification targets, producing phantom collisions #769 is the precedent. Mitigation is structural: existence-only checking, backtick-anchored extraction, and a real captured corpus for tests.
    • Don't let the Phase A number read as a grounding-quality score. It measures existence, not accuracy. AC-2's report must say so in the comment, not just in this plan.
    • Two-rate reporting is load-bearing, not a nicety — a phantom rate without a coverage rate is what would have made today's null result look like a clean bill of health.

    Conflict Risk

    None. In-flight worktrees are #915 (loop), #916 (bench), #919 (locks) — no overlap with scripts/spec/. #921 merged (9ae2e1b4) and touched spec/SKILL.md's Output Template; Phase A touches no SKILL.md, so no contention. Phase B would, and must merge that marker block rather than rewrite around it.


    Open Questions

    1. Re-aim, or split? — Recommendation: re-aim feat(spec): measure-first grounding gate for explorer findings — deterministically verify cited paths/symbols before they enter the plan #922 in place (edit AC-2's corpus, add the coverage rate, mark AC-4–7 as to-be-re-derived). Impact if wrong: a split leaves feat(spec): measure-first grounding gate for explorer findings — deterministically verify cited paths/symbols before they enter the plan #922 as a closed null result and needs a fresh issue to carry the method; recoverable but loses the reasoning trail.
    2. Should the dead explorer prompt be fixed here? — Recommendation: no — separate issue. The spec skill's "Agent Spawn Rules" table (spec/SKILL.md:133-148) prescribes 1–3 explorers with a 0% execution rate over 169 runs. Either delete it in favor of the observed behavior (targeted inline reads, escalate to Explore for open-ended discovery) or make it real. That is a genuine finding, it is not what feat(spec): measure-first grounding gate for explorer findings — deterministically verify cited paths/symbols before they enter the plan #922 asked for, and feat(spec): measure-first grounding gate for explorer findings — deterministically verify cited paths/symbols before they enter the plan #922's Non-Goals explicitly fence off explorer configuration. Not silently widening scope — your call.
    3. Is 10 plan comments enough? — Recommendation: take all available (≈169 spec runs exist locally; GitHub-side is the binding limit). Impact: too small an n and AC-3's decision is noise.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: Matches the /assess recommendation (spec,exec,qa, quality-loop off). Phase-A-only scoping keeps this at 3 ACs / 1–2 directories, so the SCOPE_WARNING that would auto-enable the loop no longer applies. testgen considered and declined: one script, with a directly copyable two-file test precedent in scripts/qa/, against /testgen's known untracked-stub pitfall. If Phase B is later bundled into the same run, re-enable the quality loop.

    Blocking on AC-2's re-aim: /exec should not start against AC-2 as currently written — the corpus is empty and the phase would either stall or fabricate a rate.


    Label Review

    Current: none
    Recommended: enhancement
    Reason: net-new measurement tooling; matches the /assess cleanup suggestion. No ui (no component files), so no browser testing.

    → gh issue edit 922 --add-label enhancement


    Planning only — no implementation performed.

  4. added
    planned
    enhancement
    on Aug 9, 2026
  5. admarble commented on Aug 9, 2026

    @admarble
    ContributorAuthor

    Phase A report + AC-3 decision

    Instrument: scripts/spec/measure-corpus.ts (PR #928). Reproduce with npx tsx scripts/spec/measure-corpus.ts --limit 45.

    Verdict up front: recommend closing as acceptable-as-is per AC-3. The adjudicated hallucination rate is 0.31% (3 of 972 citations across 39 merged plans), and a shipped gate would run an 8:1 false-to-true flag ratio. Detail below.


    Headline — closed issues (the discriminable corpus)

    Metric Value
    Plan comments 39
    Citations extracted 972
    Grounded (existed at spec time) 870
    Planned-new (created afterwards) 69
    Untracked-but-real (build output, runtime state) 4
    Missing at both refs 29
    — of those, proposed (dropped/renamed) 2
    — of those, asserted as existing code 27
    Phantom rate (all missing) 3.0%
    Asserted-phantom rate (the decision-relevant one) 2.8%
    Coverage rate 51.6% (497/963 claim lines)

    Open issues — reported separately, not discriminable

    6 comments, 182 citations, 12 unresolved at both refs (6.6%). Their work has not merged, so planned-new and phantom are indistinguishable by construction — this number is an upper bound, not a rate.

    Per-run detail (closed issues)

    Issue Citations Grounded Planned-new Missing Asserted-phantom Coverage
    #921 24 21 3 0 0 52.6%
    #920 29 28 1 0 0 65.0%
    #914 36 35 1 0 0 57.1%
    #909 6 6 0 0 0 62.5%
    #911 21 20 1 0 0 26.5%
    #910 12 11 0 1 1 33.3%
    #908 16 16 0 0 0 58.3%
    #906 50 50 0 0 0 47.5%
    #901 42 35 7 0 0 42.9%
    #899 29 19 7 3 3 66.7%
    #892 14 11 3 0 0 68.8%
    #890 20 19 1 0 0 47.4%
    #860 32 29 3 0 0 68.4%
    #878 18 18 0 0 0 80.0%
    #885 34 29 0 3 3 60.9%
    #881 18 17 1 0 0 45.5%
    #879 37 30 4 3 2 70.0%
    #871 31 26 3 2 2 61.8%
    #870 25 22 2 1 1 61.1%
    #866 16 15 1 0 0 52.9%
    #867 31 29 1 1 1 63.6%
    #844 8 7 0 1 0 16.7%
    #850 15 13 2 0 0 34.5%
    #853 17 16 1 0 0 46.4%
    #847 20 18 1 1 1 56.0%
    #845 13 13 0 0 0 17.4%
    #846 12 10 1 1 1 46.7%
    #848 34 34 0 0 0 75.7%
    #842 23 20 1 0 0 38.2%
    #834 18 13 3 2 2 15.8%
    #837 26 21 2 3 3 30.0%
    #833 31 30 0 1 1 48.5%
    #817 28 26 1 1 1 61.5%
    #817 27 26 0 1 1 65.0%
    #818 31 26 3 2 2 43.5%
    #819 10 6 4 0 0 50.0%
    #822 31 28 2 1 1 56.5%
    #820 20 16 4 0 0 37.5%
    #804 67 61 5 1 1 73.7%

    Phantom candidates (closed issues) — for manual adjudication

    Caveats

    • This is an existence score, not a grounding-quality score. It catches the loud failure (a cited path that does not exist) and is blind to the quiet one (a real path described incorrectly). Do not read the phantom rate as a measure of whether plans understood the code they cite.
    • The coverage rate is the decision-relevant denominator: a low phantom rate over low coverage means most claims were never checkable, not that most claims were right.
    • Contemporaneous refs resolve against origin/main by comment timestamp. A plan written against an unmerged branch will show its branch-only files as missing-then.
    • Missing is not phantom, and phantom is not hallucinated. Plan text is full of proposals, so a citation missing at both refs is usually a name that was dropped or renamed during implementation — fix(run): phase-restricted runs without an implementing phase must skip PR creation — spec-only batches always report failed #920's plan offered hasDeliverableCommits as an alias and shipped hasExecChanges. The intent split separates proposals from claims about existing code; the latter is the only bucket a grounding gate would have caught, and it still warrants reading before it is believed.

    Manual adjudication of the 27 raw asserted-phantoms

    The script cannot tell a confabulation from a hypothetical, so I read all 27.

    Genuine hallucinations — 3

    All three are symbols. Zero path citations were genuine phantoms.

    Not hallucinations — 24

    Class Count Examples
    Hypothetical alternatives discussed in prose 5 pnpm-lock.yaml ×2, .yarnrc.yml, build/, out/
    Real but gitignored / absent in a fresh worktree 8 .sequant/state.json ×4, scripts/dev/ ×2, ../worktrees/ ×2
    Proposed names later renamed or dropped 8 computeResumePlan, ALGORITHM_UNPARSEABLE, mapRollupToTerminal, isTerminal
    Explicitly rejected proposals 1 ReadyGateStatus ("Rejected: a ReadyGateStatus helper")
    Not a path at all 2 .integration.test.ts (a filename suffix being discussed)

    AC-3 decision

    AC-3 says: high coverage + phantom rate ≈ 0 → close as acceptable-as-is, citing the data.

    Coverage is 51.6% — moderate, comfortably above the "nothing was checkable" failure mode @zeweihan warned about. Adjudicated phantom rate is 0.31%.

    Recommendation: close as acceptable-as-is; do not proceed to Phase B. Three reasons, in order of weight:

    1. The signal is real but tiny. 3 confabulations across 39 merged plans. Both executeIssue cases would surface within seconds of an implementer opening batch-executor.ts.
    2. The noise ratio would kill it. A gate shipped today flags 27 citations to catch 3 — 8 false flags per true one. That is how investigate(metrics): gap-check signal-to-noise — does flagged → action rate justify cumulative QA prompt cost? #608's always-on gap sections reached a 0% action rate: not because they never fired, but because what they fired was not worth reading. Shipping a gate at this ratio recreates the exact failure feat(spec): measure-first grounding gate for explorer findings — deterministically verify cited paths/symbols before they enter the plan #922 cites as its own cautionary precedent.
    3. A path gate would catch nothing. All three hallucinations are symbols; 0 of ~700 path citations were phantoms. The cheap, reliable half of the checker has nothing to do, and the half that would earn its keep — symbols — is where extraction is least precise.

    What survives

    The checker itself is worth keeping as an on-demand tool even with no gate wired in: npx tsx scripts/spec/ground-check.ts --in plan.md is a few milliseconds and no tokens, and re-running measure-corpus.ts in six months costs one command. If the rate moves, the decision can be revisited against a comparable number instead of an intuition.

    Two honest limits on this number

    • It is an existence score, not a grounding-quality score. It catches the loud failure and is blind to the quiet one — a real path described incorrectly. @zeweihan's first review point stands untouched by this data, and nothing here says plans understood the code they cited.
    • Coverage is 51.6%, so roughly half of all claim lines carry no mechanically-checkable citation. Those claims were never in the denominator. A 0.31% phantom rate is a statement about checkable claims only.

    If you'd rather not close

    The one variant worth considering is a symbol-only, advisory check — no gate, no quarantine, just a line in the plan output listing unresolved symbols. It targets the only class with a positive hit rate. I'd still want a second measurement before wiring even that, because the 8:1 ratio above is driven mostly by symbol extraction, not path extraction.


    Phase A complete: AC-1, AC-2, AC-3, AC-4 satisfied in PR #928. AC-5–AC-8 (Phase B) remain deferred pending your call on the above.

  6. admarble commented on Aug 9, 2026

    @admarble
    ContributorAuthor

    /exec complete — Phase A

    PR #928 · branch feature/922-feat-spec-measure-first-grounding-gate-for-exp

    AC Status
    AC-1 grounding script ✅ scripts/spec/ground-check.ts
    AC-2 two-rate report over ≥10 plan comments ✅ 45 comments, report above
    AC-3 decision gate ✅ recommend close as acceptable-as-is
    AC-4 real fixtures, path.posix, unit + CLI integration ✅ 48 tests
    AC-5–AC-8 (Phase B) 🔄 deferred pending AC-3

    Checks: build ✅ · lint ✅ · npm test 259/259 files, 5353 passed (Node 22.23.0) · 3 mutations verified, one of which exposed a tautology in my own test — detail in the PR body.

  7. added
    ai-in-progress
    on Aug 9, 2026
  8. added 3 commits that reference this issue on Aug 9, 2026
  9. admarble commented on Aug 10, 2026

    @admarble
    ContributorAuthor

    @zeweihan Thanks for this — all four points ended up shaping the work, one of them more literally than either of us expected. Where each landed:

    1. Existence vs. misattribution — adopted verbatim. AC-2 now requires the report to state it, the Phase A report carries it as its first caveat, and the checker's own file header opens with it. And the data made your point sharper than the framing did: of the 3 genuine confabulations found in 972 citations, all three are symbols, zero are paths — and the standout (finalizePhaseLog, invented next to the real finalizeRunLog with a fabricated line number attached) is exactly the "real sibling lending credibility to an invented one" shape. The loud failure class (invented path) turns out to be nearly empty; even within existence-checkable claims, the quieter and more symbol-shaped the claim, the more it fails.

    2. The denominator trap — this one fired in its limit case before the measurement even ran. The original corpus (explorer transcripts) turned out to be empty: sequant-explorer has 0 recorded spawns across 1,332 transcripts (#927). A gate over that corpus would have measured 0% and read as a clean bill of health when the true reading was "no data" — the issue was re-aimed at posted plan comments because of it. The coverage rate you asked for is in the report: 51.6% of claim lines carry a mechanically-extractable citation, stated alongside the phantom rate rather than hidden under it. Adjudicated hallucination rate over the checkable half: 0.31% (3/972 across 39 merged plans).

    3 & 4. Provenance flags and shelf life — both were written into AC-6, but the AC-3 decision went the other way: with 3 true positives against 14 false flags (~4.7:1 after instrument fixes), wiring a gate would recreate the 0%-action-rate failure (#608) this issue cites as its own cautionary precedent, so Phase B stays unwired and the recommendation is to close on the number. The part of your feedback that survives that verdict is now implemented anyway: the checker (kept as an on-demand tool, PR #928) pins resolvedSha — the full SHA of --ref resolved, or HEAD in working-tree mode — alongside generatedAt, with an unresolvable ref pinning null rather than silently reporting HEAD (08040c7). So if the rate ever moves and a gate does get wired, drift detection is already in the JSON schema rather than a retrofit. The full provenance-flag-per-finding design stays parked in AC-6 with the Phase B ACs, to be re-derived from data rather than shipped on spec.

  10. added a commit that references this issue on Aug 10, 2026
  11. admarble commented on Aug 10, 2026

    @admarble
    ContributorAuthor

    AC-3 decision: close as acceptable-as-is

    Per the gate AC-3 defines — coverage is adequate (51.6%, well clear of the nothing-was-checkable failure mode) and the adjudicated phantom rate is ≈ 0 (0.31%, 3 of 972 citations across 39 merged plans) — this closes acceptable-as-is, with the number.

    Why no Phase B:

    1. The signal is real but tiny, and self-correcting. All 3 confabulations are symbols that die the moment an implementer opens the cited file — seconds into /exec, not the 20–30-minute blast radius the problem statement feared. Zero of ~700 path citations were phantoms; the cheap, reliable half of a gate would have nothing to catch.
    2. The noise ratio would kill it. Even after instrument fixes, 14 false flags per 3 true ones (~4.7:1). investigate(metrics): gap-check signal-to-noise — does flagged → action rate justify cumulative QA prompt cost? #608 already measured where always-on checks at that signal-to-noise end up: a 0% action rate. The symbol-only advisory variant was considered and skipped for the same reason — symbol extraction is precisely the noise source.

    What ships and what's parked:

    • Merged in feat(#922): Phase A — citation grounding checker and measured verdict on the gate #928 (e9a1a8a4): scripts/spec/ground-check.ts as an on-demand tool (now pinning resolvedSha per @zeweihan's shelf-life point, so drift detection is in the schema if a gate is ever wired) and scripts/spec/measure-corpus.ts as the re-measurement instrument. AC-1, AC-2, AC-3, AC-4 done; AC-8 satisfied by this report (Phase A needs no CHANGELOG entry).
    • AC-5–AC-7 (Phase B): not pursued. AC-6's commit-SHA half is absorbed into the checker's output; the provenance-flag-per-finding design remains unbuilt by decision, not oversight.

    Reopen trigger: if spec prompts, models, or plan style change materially, npx tsx scripts/spec/measure-corpus.ts --limit 45 reproduces this measurement in one command — compare against 0.31% / 51.6% and revisit with numbers, not intuition.

    Known limits, restated so the close doesn't overclaim: this is an existence score over the checkable half of plan claims. Misattribution (real path, wrong description) is unmeasured and out of deterministic reach; 48.4% of claim lines carry no extractable citation.

    The dead explorer fan-out that re-aimed this issue remains tracked separately in #927.

  12. admarble commented on Aug 10, 2026

    @admarble
    ContributorAuthor

    Revised Phase A numbers after the gap-closing pass

    Three instrument defects were making the measurement report its own errors as plan defects. Fixed in PR #928; re-measured over the same 39 merged plan comments / 972 citations.

    first run after instrument fixes now
    Asserted phantoms 34 27 17
    Rate 3.5% 2.8% 1.7%
    Instrument noise 24 24 14
    False-flag ratio 8:1 8:1 ~4.7:1
    Coverage 51.6% 51.6% 51.6%

    Adjudicated hallucinations stayed at 3 throughout. The fixes removed noise, not signal — which is the reassuring outcome: the headline finding was not an artifact of a sloppy extractor.

    What changed in the instrument:

    • git check-ignore replaces a bare fs.existsSync as the untracked-path signal. The filesystem check made the number checkout-dependent — a fresh worktree has no dist/ or .sequant/state.json, so it scored as phantoms what a built checkout resolves. A gitignore match is checkout- and history-independent. This alone moved 11 citations.
    • Repo-external paths (../worktrees/) are out of scope rather than phantom, compared on the resolved path rather than by looking for ".." in the string.
    • Git/shell idioms (origin/, fix/, ./) no longer parse as directory citations.

    The recommendation is unchanged

    Close as acceptable-as-is per AC-3. At ~4.7:1 the ratio is better than the 8:1 I first reported, but still four-plus false flags per true one — and the three true positives remain low-cost to catch downstream (executeIssue is contradicted the moment anyone opens batch-executor.ts). Coverage is unchanged at 51.6%, so the caveat that half of all claim lines were never checkable still stands.

    Also closed in this pass

    Repo-level gaps found while measuring, none of them #922's doing but all in its blast radius:

    • scripts/ was neither typechecked nor linted. tsconfig.json covers src/+bin/; lint ran eslint src/ bin/. Every CLI /qa and /spec shell out to was unguarded. Now covered by tsconfig.scripts.json + typecheck:scripts (wired into CI) and an extended lint scope — which immediately surfaced 11 real problems, all fixed.
    • vitest run --project <name> never worked. Vitest 4 reads a project name only from inside its test block; as a sibling it is silently ignored and the filter fails with "No projects matched" — which reads like a typo, not a config defect. The fix(test): tsx-spawning integration tests blow vitest's 5s default — phase-registry should use the prebuilt dist like its five siblings #842 unit/integration split had been unverifiable from the CLI since it landed. Now verified: 42 unit, 6 integration for these scripts.

    resolvedSha (the shelf-life half of @zeweihan's provenance point) landed separately as the Phase-A-safe slice — the checker now emits which commit it ran against, so a stale confirmation is detectable without any gate being wired.

    Phase B remains not started, per AC-3. Say the word if you'd rather I build the symbol-only advisory variant anyway.

  13. admarble commented on Aug 10, 2026

    @admarble
    ContributorAuthor

    Closing — AC-3 resolved against the gate, on the data

    Phase A shipped in #928 (e9a1a8a4), with a follow-up in #930 (93a7483c). Closing per AC-3's own terms.

    The number

    Over 39 merged plan comments / 972 citations, each checked at the commit contemporaneous with the comment and again at HEAD:

    Metric Value
    Grounded at spec time 870
    Planned-new · untracked-but-real 69 · 15
    Asserted phantoms (raw) 17 — 1.7%
    Adjudicated hallucinations 3 — 0.31%
    Coverage 51.6% (497/963 claim lines)

    Three real confabulations, all symbols, none paths:

    Why close rather than build Phase B

    Not "no signal" — signal too dilute to survive being read. 3 true positives against 14 residual false flags is ~4.7:1. #608 measured the last two always-on LLM gap sections at a 0% action rate; a gate that cries wolf four times per real catch is how that outcome is reached. All three hallucinations are also cheap to catch downstream: executeIssue is contradicted the moment anyone opens batch-executor.ts.

    And a path-only gate — the cheap, reliable half — would have caught nothing: 0 phantoms across ~700 path citations.

    Two limits on this number, stated plainly

    • It is an existence score, not a grounding-quality score. It catches the loud failure and is blind to the quiet one: a real path described incorrectly. @zeweihan's first review point is untouched by this data. Nothing here says plans understood what they cited.
    • Coverage is 51.6%, so about half of all claim lines carry no mechanically-checkable citation and were never in the denominator.

    What survives

    • scripts/spec/ground-check.ts — on-demand, offline, read-only, always exits 0. Now also pins resolvedSha, the shelf-life half of @zeweihan's provenance point, so a stale confirmation is detectable without any gate wired.
    • scripts/spec/measure-corpus.ts — re-run with npx tsx scripts/spec/measure-corpus.ts --limit 45 to revisit this decision against a comparable number rather than an intuition.

    Also closed along the way

    If the decision should be revisited

    The one variant still worth considering is a symbol-only, advisory check — no gate, no quarantine, just a line listing unresolved symbols. Symbols are where all 3 true positives were and where the path half contributed nothing. I'd want a second measurement first, since the residual noise is concentrated in symbol extraction.

  14. removed
    planned
    ai-in-progress
    on Aug 10, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions