Skip to content

feat(mcp): sequant_run result carries each issue's QA summary and findings #1200

Closed

Description

@admarble

Epic: field-2026-09-28 (downstream non-Node adoption) Blocked by: #1194 Tier: mechanical Graph: tracker #1203

Problem. The per-issue result (src/mcp/tools/run.ts:38-44, built at :234-250) has status, phase names/statuses/durations and verdict, but never gaps or findings, whatever the verdict. #391 set that shape; #434 added summary to sequant_logs only. An MCP caller that gets NEEDS_VERIFICATION or AC_NOT_MET needs a second tool call to learn why, and gets nothing at all when D2 fires.

Not previously filed (checked #391, #434, #937, #964, #972, #1070).

AC

  • AC-1: Each issue in sequant_run's result includes the qa phase's summary (acMet, acTotal, gaps, findings) when one exists, for every verdict. Evidence: npx vitest run src/mcp/tools/run.test.ts
  • AC-2: Findings are capped (count and length) so the result stays under the MCP response size limit, with a truncated flag. Evidence: npx vitest run src/mcp/tools/run.test.ts

Graph metadata

May touch

  • src/mcp/tools/run.ts

Activity

  1. added
    enhancement
    graph-2026-09-field
    on Sep 28, 2026
  2. admarble commented on Sep 29, 2026

    @admarble
    ContributorAuthor

    Context before wave 3 (main @ 1b0fa9a). The blocker #1194 has merged (PR #1214). parseQaSummary now handles bold and emoji-less status cells, and keeps the SEQUANT_QA_GAPS marker even when the AC table is unparseable. The run log's qa PhaseLog.summary is the source this issue reads. Line refs: RunToolIssueSummary is at src/mcp/tools/run.ts:38-45, and the per-issue map is at :234.

    Run rules for the phase agents (spec, exec and qa):

    • exec and qa: do not run the full npm test. Run the targeted npx vitest run <files> named in the ACs, in the foreground with a timeout. Every MCP-dispatched phase has a hard 30-minute wall, and in wave 2 an exec ran up to 27 minutes. This applies to the qa phase too, not only exec.
    • Commit WIP early, and commit again before any mutation test. Work that is committed survives a phase timeout.
    • For a mutation record, failedTest must start with the test file path (src/…test.ts > <describe> > <case>). If it starts with a describe name, §6i floors the verdict to AC_NOT_MET.
    • In the PR body, put Closes #<this issue> for this issue and Refs #1203 for the tracker. Never Closes #1203.
    • A skill snippet that reads .sequant/settings.json must handle JSONC (comments and trailing commas), not bare JSON.parse/jq.
  3. admarble commented on Sep 29, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (2 ACs, 1 directory)

    AC Quality Check

    Both ACs declare Evidence: npx vitest run src/mcp/tools/run.test.ts — measurable, non-vacuous (verified: that file's 85 tests pass on main today; AC-1/AC-2 only go green once new assertions land in the same file).

    ⚠️ Format gap: AC lines use - AC-1: … (no checkbox). extractAcceptanceCriteria requires - [ ] AC-1: … and parses 0 ACs from this body as-written — confirmed by running the parser. Human-readable, but /testgen stub generation and /qa's AC-table/mutation-gate parsing won't see these ACs unless fixed first. See Open Question 2.


    Scope Assessment

    Non-Goals: ⚠️ Not found in issue body.

    Metric Value Status
    Feature count 1 ✅
    AC items 2 ✅
    Directory spread 1 (src/mcp/tools/) ✅

    Verdict: ✅ SCOPE_OK (manual — performScopeAssessment auto-skips as "trivial" here because the checkbox gap above makes it see 0 ACs)


    Acceptance Criteria

    AC-1: Each issue's result includes the qa summary for every verdict

    Verification: Unit Test
    Scenario: Given a RunLog whose qa PhaseLog.summary has acMet/acTotal/gaps/findings → When buildStructuredResponse runs, for each of READY_FOR_MERGE / AC_MET_BUT_NOT_A_PLUS / AC_NOT_MET / NEEDS_VERIFICATION → Then the per-issue response includes those four fields only (not suggestions/pendingAcIds — AC names exactly four).
    Assumptions: PhaseLog.summary is already populated for qa today (run-log-schema.ts:211-233); this is a read-through previously dropped in buildStructuredResponse.

    AC-2: Findings capped (count + length), with a truncated flag

    Verification: Unit Test
    Scenario: Given >N findings or long description/evidence strings → When response is built → Then findings is sliced, oversized fields truncated, truncated: true set; given a normal-sized summary → no truncation.
    Assumptions: Existing 64KB enforceResponseSizeLimit (run.ts:279-310) stays as outer backstop; this adds a narrower per-issue cap.


    Implementation Plan

    Phase 1: Extend the response shape

    1. Add an optional field to RunToolIssueSummary (run.ts:38-44) with acMet/acTotal/gaps/findings (reuse GapFinding/QaSummary types from run-log-schema.js — no schema change) plus optional truncated.
    2. In buildStructuredResponse (run.ts:234-250), read qaPhase?.summary alongside the existing verdict lookup, unconditional on verdict.

    Phase 2: Cap findings (AC-2)

    1. Add a helper beside enforceResponseSizeLimit capping findings by count and per-field length, following run-reflect.ts's existing truncate-with-flag pattern (MAX_OUTPUT_LINES/truncated). Suggest: 10 findings, 300 chars/field; set truncated: true if either fires.
    2. Leave enforceResponseSizeLimit's rawOutput/error trimming as the aggregate backstop (Open Question 1).

    Phase 3: Tests

    1. Extend run.test.ts fixtures: one qa summary per verdict, asserting the four fields surface.
    2. Add an oversized-findings fixture (count/length capping + truncated: true) and a normal-sized case (no truncation).

    Design Review

    1. Where does this belong? src/mcp/tools/run.ts, next to enforceResponseSizeLimit.
    2. Simplest correct approach? Read-through of the existing QaSummary/GapFinding types already on PhaseLog.summary — no new schema. Rejected: exposing full QaSummary (adds suggestions/pendingAcIds the AC doesn't ask for).
    3. Existing pattern? run-reflect.ts's truncate+flag pattern for the cap; enforceResponseSizeLimit's post-hoc trim for the outer guard — this adds a second, narrower layer.
    4. Reviewer pushback? "Why cap findings not gaps?" — gaps is already a short deduped union (feat(qa/loop/ready): structured gap findings — finite taxonomy with required evidence, replacing the lossy prose-scrape gap channel #937); findings is the unbounded structured array. "Many issues, each capped but present?" — could still approach 64KB in aggregate; not solved here (Open Question 1) since this issue targets the single-issue NEEDS_VERIFICATION/AC_NOT_MET case.

    No ADR needed — additive field from an existing schema, not a design choice.


    Feature Quality Planning

    All standard checks pass. Notable: additive/optional field, no backcompat break; aggregate multi-issue size risk noted but out of this issue's scope.


    Open Questions

    1. Are cap constants (10 findings / 300 chars) right for a hard 64KB MCP ceiling? Recommendation: start conservative. Impact if wrong: too loose risks the aggregate response exceeding 64KB on many-issue runs; too tight loses debugging signal on exactly the verdicts this issue targets.
    2. AC-1/AC-2 aren't checkbox-formatted, so extractAcceptanceCriteria parses 0 ACs. Recommendation: edit to - [ ] AC-1: … / - [ ] AC-2: … before /exec//qa. Impact if left as-is: /qa §6i's AC-table parser and mutation-record classification have nothing to anchor to.

    Recommended Workflow

    Phases: exec → qa
    Quality Loop: disabled
    Reasoning: Mechanical, single-file, two-AC additive change to an already-well-tested function (85 existing tests, established describe("buildStructuredResponse") pattern from #391/#434 the exec agent extends directly). Testgen's declared-evidence rule would normally trigger (both ACs' evidence is a vitest command → Unit Test), but overriding: a separate testgen phase would only restate stubs the exec agent writes directly from the existing pattern. No complexity/scope-warning signal for the quality loop.


    Label Review

    Current: enhancement, graph-2026-09-field
    Recommended: no change
    Reason: Small, single-file, non-complex; manual scope read is SCOPE_OK.
    Quality Loop: Won't auto-enable.


    --- DRAFT GITHUB ISSUE COMMENT (PLAN) ---

    Plan: #1200 — sequant_run result carries each issue's QA summary and findings

    AC-1 (Unit Test): Add acMet/acTotal/gaps/findings to each issue's response in buildStructuredResponse (run.ts:234-250), sourced from the existing qa PhaseLog.summary (no schema change), for every verdict.

    AC-2 (Unit Test): Cap findings by count and per-field length with a truncated flag, following run-reflect.ts's truncate-with-flag pattern; keep the current 64KB enforceResponseSizeLimit as the outer backstop.

    Plan:

    1. Extend RunToolIssueSummary (run.ts:38-44) with the four fields + optional truncated.
    2. Wire the read-through in buildStructuredResponse, unconditional on verdict.
    3. Add a capping helper (count + length caps) beside enforceResponseSizeLimit.
    4. Extend run.test.ts: one summary per verdict, plus oversized and normal-sized cases.

    Open questions:

    • Cap constants (proposing 10 findings / 300 chars/field) — flag if you want different limits.
    • ⚠️ AC-1/AC-2 aren't checkbox-formatted, so the AC parser reads 0 ACs from this body. Recommend editing to - [ ] AC-1: … / - [ ] AC-2: … before /exec//qa so AC-table parsing and the mutation-gate can anchor to them.

    Workflow: exec → qa, quality loop disabled (mechanical, well-precedented single-file change).

  4. added
    planned
    on Sep 29, 2026
  5. admarble commented on Sep 29, 2026

    @admarble
    ContributorAuthor

    QA Verdict: AC_NOT_MET

    AC coverage: 1/2 met

    Gaps:

    • AC-2 cap is bypassed: gaps duplicates every finding description uncapped, so the result can exceed the 64KB MCP limit and truncated:true misreports
    • No test asserts the response stays under the MCP size limit with realistic gaps derived from findings
    • CI test check still pending at review time
    • gaps gets around the cap. It is built from the full descriptions of all findings, so the 300-character and 10-entry limits apply to findings but not to the text that repeats it. truncated: true then tells the caller something was cut when all of it is still in gaps.

    Suggestions:

    • Cap gaps with the same count and length limits, and let that set truncated too.
    • Add one test that asserts Buffer.byteLength(JSON.stringify(response)) <= 64*1024 for an issue with many long findings. That checks what AC-2 promises, not just how the cap works.
  6. added 2 commits that reference this issue on Sep 29, 2026
  7. admarble commented on Sep 29, 2026

    @admarble
    ContributorAuthor

    Runner fix for QA's AC_NOT_MET (PR #1218, now at e3136c7)

    QA's gap was real. gaps is built from each finding's full description, so capping only findings let the full text through in gaps, and truncated: true misreported. The fix, in src/mcp/tools/run.ts:

    • capGaps gives gaps the same caps as findings: 10 entries, 300 characters each. Either cap sets truncated.
    • enforceResponseSizeLimit now handles a response that is still over 64KB after the rawOutput/error trims. It drops findings, then gaps, from the last issue backward until the response fits, and sets truncated. acMet/acTotal/verdict always stay. Without this, per-issue caps bound one issue but not a many-issue run.

    Verification (runner):

    • npx tsc --noEmit: clean. npx vitest run src/mcp/tools/run.test.ts: 95 passed, with 2 new tests.
    • New test: a 12-issue run with 15 long findings and 15 long gaps per issue, plus 5 KB of raw output, asserts Buffer.byteLength(JSON.stringify(response)) <= 64*1024, as QA suggested.
    • Mutations: making capGaps a passthrough failed only the gaps-cap test, and emptying the drop loop failed only the 64KB test. Each was restored. The records are in the PR body.
    • CI on e3136c7 is green. closingIssuesReferences is [1200].

    QA is being re-dispatched on the new head.

  8. admarble commented on Sep 29, 2026

    @admarble
    ContributorAuthor

    QA Verdict: READY_FOR_MERGE

    AC coverage: 2/2 met

  9. added a commit that references this issue on Sep 29, 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

    enhancementgraph-2026-09-fieldplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions