fix(phase-complete): keep internal phase diagnostics out of chat-visible output#876
Merged
Merged
Conversation
Copilot
AI
changed the title
[WIP] Fix logs leak into chat bar
fix(phase-complete): keep internal phase diagnostics out of chat-visible output
May 16, 2026
…ble output Removes console.warn/console.info/console.error from the non-fatal diagnostic paths in executePhaseComplete and routes them to either the tool result warnings array (operator-visible, structured) or the debug-gated logger (OPENCODE_SWARM_DEBUG=1 only). Fixes issue #875. Changes: - safeWarn: console.warn → logger.warn (debug-gated) - Turbo-mode gate bypass: console.warn → warnings.push - drift_check disabled skip: console.info removed (warnings.push kept) - non-code phase skip: console.info removed (warnings.push kept) - Lock release failure: console.error → logger.warn (non-blocking, post-decision) Regression tests added for turbo-mode and non-code drift-skip paths asserting no console writes occur. ## Invariant audit - 1 (plugin init): not touched — no init path changes; phase-complete runs post-init - 2 (runtime portability): touched — dist/ rebuilt; node --input-type=module -e "await import('./dist/index.js')" → dist import OK - 3 (subprocesses): not touched — grep of changed source files shows no new spawn call sites - 4 (.swarm containment): not touched — no .swarm/ path changes - 5 (plan durability): not touched — no plan schema changes - 6 (test_runner safety): not touched — no test_runner changes - 7 (test writing): touched — two new bun:test regression tests with finally-block console restore; no mock.module usage - 8 (session state): not touched — no session state changes - 9 (guardrails/retry): not touched — no retry logic changes - 10 (chat/system msg): touched — grep src/tools/phase-complete.ts for console.warn/info/error returns zero matches; fix removes the violation - 11 (tool registration): not touched — no tool registration changes - 12 (release/cache): touched — docs/releases/v7.20.2.md created; package.json/CHANGELOG/.release-please-manifest.json untouched ## Pre-existing failures Tiers 2–4 contain pre-existing failures confirmed on clean main checkout: diagnostic-gating (3), phase-complete-lean-turbo-critic (9), phase-complete-lean-turbo-reviewer (7), sast-and-cochanger-tools (18), tool-registration-conformance (1), update-task-status.gate-fix (4), integration/phase-completion-e2e (subset), adversarial (10). None are in files touched by this PR. https://claude.ai/code/session_013N8A2pNYg7vwLtnjvP68cW
8714387 to
17e1f38
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
console.warn/console.info/console.errorfrom non-fatal diagnostic paths inexecutePhaseComplete— fixes issue fix(guardrails): recover from provider outages #875 where internal phase-boundary messages leaked into the OpenCode chat barwarningsarray (operator-visible, structured) and lock-release failures to the debug-gated logger (OPENCODE_SWARM_DEBUG=1)Invariant audit
node --input-type=module -e "await import('./dist/index.js')"→dist import OKfinally-block console restore; nomock.moduleusage; all 52 phase-complete tests passgrep src/tools/phase-complete.ts 'console\.(warn|info|error)'returns zero matches; fix removes the invariant violationdocs/releases/v7.20.2.mdcreated (v7.20.1 was already claimed by release-please for chore(main): release 7.20.1 #877);package.json/CHANGELOG/.release-please-manifest.jsonuntouchedTest plan
bun --smol test tests/unit/tools/phase-complete.test.ts— 52 pass, 0 failtests/unit/tools/*.test.tsper-file — phase-complete suite fully green; other failures confirmed pre-existing on clean mainbunx biome ci .— 0 errors, 2 pre-existing warnings (unrelated file)bun run typecheck— cleanbun test tests/security— 139/139 passbun test tests/smoke— 10/10 passnode scripts/repro-704.mjs— 3/3 OK (plugin init deadline)node --input-type=module -e "await import('./dist/index.js')"→dist import OKPre-existing failures
Tiers 2–4 contain pre-existing failures confirmed on clean
maincheckout (worktree verify):diagnostic-gating(3),phase-complete-lean-turbo-critic(9),phase-complete-lean-turbo-reviewer(7),sast-and-cochanger-tools(18),tool-registration-conformance(1),update-task-status.gate-fix(4), integration/phase-completion-e2e (subset), adversarial (10). None in files touched by this PR.Original Copilot description
phase_completewas emitting internal phase-boundary diagnostics through raw console output, which can surface in the OpenCode chat bar. This change keeps those messages in structured tool output or debug-only logging instead of leaking workflow internals into the user conversation.What changed
console.warn/console.info/console.errorusage fromsrc/tools/phase-complete.tsfor non-fatal internal diagnostics.warningsarray where it belongs.Behavior changes
warningson thephase_completeresult instead of console output.warnings, without writing to the chat-visible console path.Regression coverage
console.warn/console.errorconsole.info