Skip to content

feat(qa/loop/ready): structured gap findings — finite taxonomy with required evidence, replacing the lossy prose-scrape gap channel #937

Closed

Description

@admarble

Motivation

The gap channel between /qa, /loop, and sequant ready is prose scraped by a single regex, and it is measurably lossy:

  • parseQaSummary (src/lib/workflow/phase-executor.ts:581-625) extracts gaps via parseListSection(output, /\*\*(?:Issues|Gaps)/). That matches exactly one place in the QA output templates — the **Issues:** bullet list under ### Code Review. It does not capture AC-table NOT_MET rows, §6d Adversarial Re-Read findings, §5 Risk Assessment, or §2d Test Quality Review's differently-named **Issues Found:** list. A QA pass that fails on a §6d Severe Gap can hand /loop an empty findings list.
  • /loop's own extraction (loop/SKILL.md:114-122) greps for a ### Required Fixes section that no QA output template emits — the only occurrences of that heading in the qa skill are a prohibition and loop's own worked example. The surviving channel is a raw NOT_MET|PARTIALLY_MET line grep.
  • ReadyGapItem (src/lib/workflow/ready-gate.ts:85-93) is {description: string, nonGoal: boolean} — no category, severity, evidence, or recommended action.
  • Under ac policy, sequant ready's "document remaining gaps without fixing" output goes to terminal scrollback only: no GitHub comment (orchestrated QA skips posting per qa/SKILL.md §9), no state payload beyond a single status enum. The documented gaps are unrecoverable after the terminal closes.

Meanwhile the repo has four unrelated finding shapes (ReadyGapItem, QaSummary.gaps: string[], merge-check's severity-typed CheckFinding in src/lib/merge-check/types.ts:44-57, precheck's CheckStatus), none wired to the QA verdict path.

Transcript evidence for why structure matters: a 28-episode audit of end-of-session gap prompts (2026-07-14 → 08-10) measured 57% real would-ship defects, 29% cosmetic tail, and one shipped regression (#930) — caused by acting on a gaps-list with no severity/action classification ("fix all gaps" applied to findings the QA itself had framed as non-blocking). #608 measured the inverse failure: open-ended "what might we be missing" sections invent plausible concerns with a 0% action rate. A finite taxonomy with required evidence is the middle path.

Proposal

One shared gap-finding schema, emitted as a structured marker and consumed by every existing gap consumer.

Schema (new, in run-log-schema.ts or sibling; consolidates — does not add a fifth shape alongside the four):

interface GapFinding {
  category: "requirement_gap" | "dependency_gap" | "test_gap"
          | "repository_gap" | "risk_gap" | "execution_gap";
  evidence: string;              // REQUIRED — concrete observation, not speculation
  description: string;
  recommendedAction: "fix_now" | "document" | "pause_for_human";
  affectedAcs?: string[];        // e.g. ["AC-3"]
  nonGoal?: boolean;             // existing ready-gate semantics
}

Emission: /qa output templates end with <!-- SEQUANT_QA_GAPS: {json} --> — the same durable-marker idiom as SEQUANT_SPEC (#921/#925) and SEQUANT_PHASE. The prose sections stay for humans; the marker is the machine contract.

Consumers (all wired in this issue — an emitted marker nothing reads is dead weight, per #608):

  1. parseQaSummary parses the marker first, falls back to the current regex scrape for older output.
  2. /loop consumes recommendedAction: "fix_now" findings instead of the dead ### Required Fixes grep; document findings are excluded from fix iterations (this is the structural fix for the fix(lint): exclude gitignored scripts/dev from the widened lint/typecheck scope #930 class).
  3. ReadyGapItem gains the schema fields; formatReadyReport renders category/action.
  4. sequant ready persists the final gap report to the issue as a comment carrying the marker (closing the terminal-scrollback hole). Feeds feat(ready): sequant ready never records run metrics — no visibility into escalation, iteration counts, or gate outcomes #929's metric record shape (remaining counts by category).

Fallback rule: a gap the model cannot fit into the six categories is emitted as prose exactly as today — the taxonomy narrows the structured channel; it must never silently drop an unclassifiable finding.

Non-Goals

Tailored caveats

Acceptance Criteria

  • AC-1: A GapFinding schema with the six categories, required evidence, and recommendedAction exists in src/lib/workflow/ and is exported. Evidence: unit test constructs and validates all six categories plus rejects a missing-evidence finding.
  • AC-2: QA output templates (standard and simple-fix, all three skill dirs) emit <!-- SEQUANT_QA_GAPS: {json} --> and parseQaSummary prefers the marker over the regex scrape. Evidence: unit test feeds a QA output containing a §6d finding absent from **Issues:** and asserts it survives into QaSummary.gaps via the marker; mutation-verified by deleting the marker from the fixture and confirming the fallback path returns the old (lossy) result.
  • AC-3: /loop consumes fix_now findings from the marker and excludes document findings from fix iterations; the dead ### Required Fixes grep is removed. Evidence: integration test drives loop with a marker containing one fix_now and one document finding and asserts only the former reaches the fix prompt.
  • AC-4: sequant ready posts its final gap report (with marker) as an issue comment when terminal, and ReadyGapItem carries the schema fields. Evidence: unit test asserts the comment body contains the marker with remaining findings; manual verification on one live dogfood issue.
  • AC-5: An unclassifiable gap falls back to today's prose behavior with no finding dropped. Evidence: unit test with a marker-less QA output asserts parseQaSummary output is unchanged from current behavior.
  • AC-6: Existing consumers are regression-covered — run --ready-gate, standalone ready, and loop paths pass the current suite unchanged. Evidence: full targeted suite for phase-executor, ready-gate, and loop-related tests green.

Human decisions required

  • Should the ready gap-report comment post under ac policy only, or for a-plus terminal states too?

Context

Designed from the 2026-08-13 strategy review: 28-episode transcript audit of gap-prompt outcomes, flow-map of the qa/ready gap channel, and the taxonomy proposal (finite categories + required evidence). Related: #929 (ready metrics — this issue's persisted report feeds its record shape), #921/#925 (marker idiom), #608 (advisory-section action-rate data), #930 (the shipped regression this schema's document class prevents).

Activity

  1. admarble commented on Aug 21, 2026

    @admarble
    ContributorAuthor

    Spec: Structured gap findings (#937)

    Complexity: Standard (6 ACs, 4 consumers across src/lib/workflow/, src/commands/, skills/{qa,loop} ×3 mirrors)

    AC Quality Check

    Linter: 0 issues. All six ACs carry explicit evidence clauses. One semantic tension to resolve up front: AC-2 says parseQaSummary "prefers the marker over the regex scrape", AC-5 says an unclassifiable gap "falls back to today's prose behavior with no finding dropped". If a marker is present and a prose-only gap exists, strict "prefer marker" drops the prose gap. Plan resolves this as union with dedupe (see Decisions).

    Scope Assessment

    Non-Goals: present (4 items). Feature count 2 ⚠️ · AC items 6 ⚠️ · Directory spread 1 ✅ → ⚠️ SCOPE_WARNING (quality loop auto-enabled). In-flight worktrees (#916, #919) touch none of the affected files.

    Acceptance Criteria

    • AC-1 — GapFinding zod schema in src/lib/workflow/run-log-schema.ts (GapFindingSchema, GapCategorySchema, GapActionSchema), exported. Unit test: Given each of the 6 categories → safeParse succeeds; given evidence missing/empty → fails.
    • AC-2 — Both QA templates (skills/qa/SKILL.md §Output Template, simple-fix + standard, after ### Next Steps) end with <!-- SEQUANT_QA_GAPS: {"findings":[...]} -->; parseQaSummary parses the marker first. Unit test: fixture with a §6d Adversarial Re-Read finding absent from **Issues:** → present in QaSummary.gaps and QaSummary.findings. Mutation-verified: delete the marker from the fixture → test fails, fallback returns the lossy list (record as SEQUANT_MUTATION marker in the PR body per CLAUDE.md).
    • AC-3 — Orchestrated loop inputs (ready-gate.ts fixableGaps, batch-executor.ts:1610 failedAcs) filter to recommendedAction === "fix_now" when findings exist; loop/SKILL.md reads the marker and drops the dead ### Required Fixes sed. Integration test: ready-gate.test.ts fake runner returns QA output with one fix_now + one document finding → loop-phase config failedAcs/promptContext contain only the former. Plus a gate test scoped to loop/SKILL.md asserting ### Required Fixes is gone and SEQUANT_QA_GAPS is referenced (mutation-verified).
    • AC-4 — ReadyGapItem gains optional category, evidence, recommendedAction, affectedAcs; formatReadyReport renders [category · action] per item and appends the marker; sequant ready posts the report via GitHubProvider.postComment when finalVerdict !== null. Unit test: injected postComment spy receives a body containing the marker whose findings equal remaining. Manual: one live dogfood issue.
    • AC-5 — Marker-less QA output → parseQaSummary result deep-equals current behavior. Unit test: reuse existing fixtures in phase-executor.test.ts, snapshot before/after.
    • AC-6 — phase-executor*, ready-gate*, ready*, batch-executor test files green, full suite before push (signature change on QaSummary/ReadyGapItem).

    Implementation Plan

    Phase 1 — Schema + parser (AC-1, AC-2, AC-5)

    1. run-log-schema.ts: add GapFindingSchema; extend QaSummarySchema with findings: GapFindingSchema.array().optional(). Keep gaps: string[] — batch-executor.ts:200/1610, run-display.ts:128, ready-gate.ts:565 all read it.
    2. New src/lib/workflow/qa-gaps-marker.ts mirroring mutation-marker.ts (stripMarkdownCode, zod validate, invalid → [] + warning). Regex must NOT be the {[^}]+} family — the payload is nested (array of objects, affectedAcs array). Use /<!-- SEQUANT_QA_GAPS: (\{[\s\S]*?\}) -->/ (lazy to the closing -->); template contract: single line, no --> inside strings.
    3. parseQaSummary: gaps = dedupe([...markerFindings.map(f => f.description), ...parseListSection(...)]); findings set only when the marker parsed.

    Phase 2 — QA template emission (AC-2)
    4. skills/qa/SKILL.md: add the marker line to both templates + an "Output Verification" bullet requiring it; classification guidance: NOT_MET rows → requirement_gap/fix_now; §2d/§6d findings → test_gap/risk_gap; non-blocking polish → document; "cannot classify → prose only, omit from marker". Sync templates/skills/ and .claude/skills/ byte-identically (cmp gate, #742).

    Phase 3 — Loop + ready consumers (AC-3, AC-4)
    5. ready-gate.ts: classifyGaps consumes summary.findings when present (nonGoal = finding.nonGoal || gapTouchesNonGoals), fixableGaps filters !nonGoal && action === "fix_now"; batch-executor.ts:1610 same filter. New opt postReport?: (body) => Promise<void> on the gate options; src/commands/ready.ts and the run --ready-gate path (batch-executor.ts:771) wire new GitHubProvider().postComment. Best-effort (never fails the gate).
    6. formatReadyReport: per-item category · action tag, marker appended; ready.ts --json remaining already serializes the extended item.
    7. skills/loop/SKILL.md: replace the ### Required Fixes sed with: prefer SEQUANT_FAILED_ACS env when set (orchestrated, already filtered); else shell presence-grep for the marker, then filter recommendedAction=="fix_now" with a tiny inline node -e JSON filter (no regex schema duplication — #871 drift guard). Add a document row to "Excluded Finding Classes".

    Phase 4 — Regression + docs (AC-6) — targeted suites, full suite, CHANGELOG, docs/ reference for the marker.

    Decisions

    • Marker payload is {"findings":[...]}, not a bare array — extensible (e.g. unclassified count for feat(ready): sequant ready never records run metrics — no visibility into escalation, iteration counts, or gate outcomes #929) and the opening { keeps the existing marker-grep idiom shape.
    • Union, not replace, in parseQaSummary — reconciles AC-2 with AC-5's no-drop rule. Dedupe on trimmed/case-folded description.
    • Post the ready comment for every terminal state with a verdict (both policies), skip NO_IMPLEMENTATION/UNCOMMITTED_ONLY/NO_VERDICT — MAX_ITERATIONS/TOKEN_BUDGET are exactly the states whose gap list must survive the terminal. (Resolves the issue's human-decision question; override if you want ac-only.)
    • No new CLI subcommand for loop's shell parsing — node -e on an extracted single-line JSON is a 3-line filter; a subcommand would be a fifth parser to keep in sync.

    Open Questions

    1. Post-comment opt-out? Recommendation: none in this issue; --json mode still posts. Impact if wrong: noisy dogfood issues — trivial follow-up flag.
    2. Should batch-executor.ts:200 ("QA Gaps:" error text) render category/action? Recommendation: yes, cheap, same formatter as the ready report.

    Recommended Workflow

    Phases: spec → testgen → exec → qa
    Quality Loop: enabled (SCOPE_WARNING)
    Reasoning: 5 of 6 ACs are unit/integration-verified (testgen stubs); two-skill × three-dir template sync and a parser contract change warrant the loop.

    Labels: current none → add enhancement, planned.

  2. added
    planned
    enhancement
    on Aug 21, 2026
  3. admarble commented on Aug 21, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #937
    Status: NEEDS_VERIFICATION

    Summary

    • AC: 5/6 MET, 1 PENDING (AC-4's declared "manual verification on one live dogfood issue" — cannot happen before merge; the unit-test half of AC-4's evidence is done and passing)
    • Tests: full suite green — 269 files, 5549 passed, 1 expected fail, 2 skipped, 0 failures
    • Build/lint/skill-sync/skill-gates/skill-calls: all clean
    • CI on PR feat(#937): structured gap findings — finite taxonomy replacing the lossy prose-scrape gap channel #954: 8/8 checks green (build (22.x), typecheck, validate-skills, validate-plugin, node-floor-guard, Hooks Validation, Plugin Structure Validation, Setup Directory Creation)

    Progress Table

    Phase Iterations Status
    Spec 1/1 Complete
    Exec 1/1 Complete — PR #954 created
    Test 0 (skipped — no ui/frontend/admin label) N/A
    QA 1/2 Complete — NEEDS_VERIFICATION

    AC Coverage

    AC Status Notes
    AC-1 ✅ MET GapFindingSchema — six categories, required evidence, exported. Matches the issue's own verbatim GapFinding TS-interface fixture field-for-field.
    AC-2 ✅ MET QA templates (3 skill dirs, byte-synced) emit SEQUANT_QA_GAPS; parseQaSummary unions marker + prose.
    AC-3 ✅ MET selectFixableGaps wired into ready-gate.ts/batch-executor.ts; /loop's dead ### Required Fixes grep replaced with marker parsing — verified against 5 realistic samples.
    AC-4 ⏳ PENDING Comment-posting + schema fields implemented and unit-tested (4+1 tests, all green). "Manual verification on one live dogfood issue" — its own declared evidence — cannot execute pre-merge; deferred, as already flagged in the PR body's Test Plan.
    AC-5 ✅ MET Union-not-replace dedup; all marker-less fixtures unchanged.
    AC-6 ✅ MET Full suite green, 0 regressions.

    Risk Assessment

    • Likely failure mode: none identified — all mechanical paths (schema validation, marker parse/format, fix-loop filtering, comment posting) are unit- and integration-tested.
    • Not tested: the live-dogfood round trip (AC-4's manual clause) — genuinely can't be, pre-merge.
    • Adversarial re-read finding (non-blocking): /loop's shell-side marker extraction (grep/sed) has no fenced-code-block awareness, unlike the TypeScript-side stripMarkdownCode the other markers use. Low real-world risk (QA never wraps its own emitted marker in a fence), but worth a follow-up hardening pass if it proves to matter in practice.

    Quality checks: type safety ✅ (0 issues), scope/size ✅ (moderate, cohesive, test-proportionate), security ✅ (0 critical/warning).

    PR: #954


    Merge is a human decision. The one open item (AC-4's manual dogfood check) is exactly the kind of post-merge verification this project's ready/QA framework treats as report-only, not auto-mergeable — /fullsolve is stopping here rather than merging on your behalf. Suggested next step: merge #954, then exercise sequant ready (or a /qa→/loop cycle) on a live issue to close out AC-4, or run /qa 937 again once you're satisfied.

  4. added 2 commits that reference this issue on Aug 25, 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

    enhancementplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions