Repository navigation
Bound MCP compile failure diagnostics without losing actionable errors - #67424
Conversation
Preserve actionable dependency errors and scanner results while limiting fallback diagnostics to 4 KiB and fallback JSON to 48 KiB. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
✅ PR Code Quality Reviewer completed the code quality review. Testing safeoutputs availability after bash write denial.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.
|
|
✅ Ponytail Reviewer completed successfully! Lean already. Ship.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
🏗️ Design Decision Gate — ADR RequiredThis PR makes significant changes to core business logic (507 new lines in 📄 Draft ADR committed:
🔎 Evidence used
📋 What to do next
Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision. ❓ Why ADRs MatterADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you. 📋 Michael Nygard ADR Format ReferenceAn ADR must contain these four sections to be considered complete:
All ADRs are stored in
|
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Request changes
The new stderr collector is on the right track, but it still drops remediation text when debug output is interleaved between the error line and its follow-up details. That leaves the fallback JSON with the least actionable part of the failure in exactly the noisy-debug scenario this patch is meant to harden.
The blocking theme
- Skipping a
workflow:/cli:debug line currently clears the active multiline error block, so later remediation lines are discarded instead of being preserved.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 39.8 AIC · ⌖ 5.57 AIC · ⊞ 20K
Comment /review to run again
There was a problem hiding this comment.
🟡 Changes recommended
Diagnostic classification misses valid logger namespaces and console prefixes, allowing non-actionable output into failure responses.
1 open finding
What changed in this PR
Bounds MCP compile-failure diagnostics while preserving actionable and structured scanner output.
Changes:
- Adds streaming stderr collection and bounded fallback JSON.
- Adds regression coverage for large, malformed, and concurrent diagnostics.
- Documents the fallback contract and release impact.
| File | Description |
|---|---|
pkg/cli/mcp_tools_readonly.go |
Integrates bounded compile diagnostics. |
pkg/cli/mcp_compile_diagnostics.go |
Implements streaming collection and limits. |
pkg/cli/mcp_compile_diagnostics_test.go |
Tests bounds, cancellation, Unicode, and isolation. |
docs/src/content/docs/reference/gh-aw-as-mcp-server.md |
Documents fallback behavior. |
.changeset/bound-mcp-compile-errors.md |
Records the patch change. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs — requesting changes on three correctness gaps in the new mcpCompileDiagnostics line classifier found through direct reproduction (pkg/cli/mcp_compile_diagnostics.go).
📋 Key Themes & Highlights
Key Themes
- Shellcheck lines leak into the reported failure message when no
✗/error:line follows them — theswitchthat capturesshellcheck findings in .../script:lines doesn't short-circuit before the laterisError/messageaccumulation logic. - Hardcoded debug-namespace allowlist (
cli:,workflow:,parser:,mcp:,agentdrain:,repoutil:,logger:,stringutil:) misses ~20 other registeredlogger.New(...)namespaces in the repo (e.g.console:*,gitutil:,jsonutil:,typeutil:*). Debug output from any of those leaks straight into the bounded diagnostic, reintroducing the noise this PR is meant to eliminate. - Warning capture is last-write-wins on any
⚠-prefixed line, so a⚠ shellcheck findings in ...header can overwrite a genuine dependency-unavailable warning, discarding the actionable one.
All three were confirmed with isolated unit reproductions against the actual mcpCompileDiagnostics.Write/finishLine/failureMessage code paths (not just read from the diff).
Positive Highlights
- ✅ Strong test suite already covers byte-boundary truncation, UTF-8 validity, cancellation, and concurrent request isolation — excellent
/tdddiscipline for the happy paths. - ✅ The head/tail retention strategy in
compileDiagnosticTextis a clean, allocation-bounded way to avoid buffering debug floods. - ✅ Separating shellcheck findings from the execution-failure message (so structured scanner output survives truncation) is a good design call.
Note on scope
Given the PR's stated 20-tool-call investigation budget and the diff size (~500 lines across 2 new/modified Go files), I bounded exploration to the new diagnostics module and its direct dependencies (console.FormatWarningMessage, logger.New call sites) rather than tracing every compile code path that could emit these namespaces at runtime.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 173.6 AIC · ⌖ 16.1 AIC · ⊞ 10.3K
Comment /matt to run again
Recognize logger output generically, keep remediation blocks open across debug lines, and isolate shellcheck findings from failure summaries. Complete the diagnostic bounding ADR. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Closes #66823. Corroborating reports: #66455, #66792, #67119, #67350.
ADR: ADR-67424: Bound MCP Compile Diagnostics With a Streaming Head/Tail Collector. Completed for maintainer review; status remains Proposed until review and merge.
Changes
max_tokenscontract are unchanged.DEBUGenabled and 12 MiB stderr; cover huge single lines, whitespace stdout, multiline/ANSI diagnostics, Unicode and byte boundaries, escape-heavy JSON, 334-workflow discovery, spawn failures, cancellation, concurrent request isolation, interleaved remediation, unlisted logger namespaces, and scanner/warning separation. No diagnostic-file persistence is needed.Validation
Validated the code committed as
63248a5ea648fa7ab7dac048f4052db0451e2fd0:npm_config_package=prettier@3.9.9 PATH="/opt/homebrew/bin:$(go env GOPATH)/bin:$PATH" make fmt— passed.npm_config_package=prettier@3.9.9 PATH="/opt/homebrew/bin:$(go env GOPATH)/bin:$PATH" make lint— passed, including full-repository Go lint, JavaScript lint, shellcheck and schema checks. Existing JavaScript warnings remain warnings; no rules were disabled.npm_config_package=prettier@3.9.9 PATH="/opt/homebrew/bin:$(go env GOPATH)/bin:$PATH" make agent-report-progress— passed, including build, changed-file standard/custom Go lint, impacted unit tests and workflow drift (all 334 workflow lock files in sync). Existing custom analyzer findings in unchanged files are handled by the repository's change-scoped gate.go test ./pkg/cli -run 'Test(CompileTool|MCPCompile|BuildCompileErrorResults|InjectShellcheckDiagnostics|InjectDockerUnavailableWarning|ExtractLastConsoleMessage|DevelopmentCompileFailsWithoutShellcheckOrDocker|MCPSubprocessGuardrail)' -count=1— passed.go test -race ./pkg/cli -run 'Test(MCPCompile|CompileToolBounds|CompileToolPreservesStructuredFailureAfterDebugFlood|CompileToolDevelopmentPreservesBatchDiagnosticsOnFailure|CompileTool_UsesOnlyStdoutOnSuccess)' -count=1— passed.git diff --check— passed.The new review regressions reproduced the defects before the fixes and pass afterward. All five in-scope review threads were replied to and resolved.
Earlier publication encountered a shared golangci-lint lock and baseline custom-linter findings; the finishing pass's required local gates now pass. The default unpinned
npxselected Prettier 4.0.0-alpha.13 and crashed on unrelated JSON; the declared dependencies and pinned Prettier 3.9.9 are used for validation without unrelated formatting changes.CI hand-off: the two last-known CI checks were successful at triage. CI on the latest agent-pushed HEAD remains unverified until a maintainer re-triggers it. No Actions runs were triggered and the PR was not merged.