Skip to content

fix(phase-complete): keep internal phase diagnostics out of chat-visible output#876

Merged
zaxbysauce merged 1 commit into
mainfrom
copilot/fix-logs-leak-into-chat-bar
May 16, 2026
Merged

fix(phase-complete): keep internal phase diagnostics out of chat-visible output#876
zaxbysauce merged 1 commit into
mainfrom
copilot/fix-logs-leak-into-chat-bar

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 16, 2026

Summary

  • Removes console.warn/console.info/console.error from non-fatal diagnostic paths in executePhaseComplete — fixes issue fix(guardrails): recover from provider outages #875 where internal phase-boundary messages leaked into the OpenCode chat bar
  • Routes gate-skip notifications to the tool result warnings array (operator-visible, structured) and lock-release failures to the debug-gated logger (OPENCODE_SWARM_DEBUG=1)
  • Adds two regression tests asserting no console writes occur on turbo-mode and non-code drift-skip paths

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; all 52 phase-complete tests pass
  • 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 'console\.(warn|info|error)' returns zero matches; fix removes the invariant violation
  • 11 (tool registration): not touched — no tool registration changes
  • 12 (release/cache): touched — docs/releases/v7.20.2.md created (v7.20.1 was already claimed by release-please for chore(main): release 7.20.1 #877); package.json/CHANGELOG/.release-please-manifest.json untouched

Test plan

  • bun --smol test tests/unit/tools/phase-complete.test.ts — 52 pass, 0 fail
  • All tests/unit/tools/*.test.ts per-file — phase-complete suite fully green; other failures confirmed pre-existing on clean main
  • bunx biome ci . — 0 errors, 2 pre-existing warnings (unrelated file)
  • bun run typecheck — clean
  • bun test tests/security — 139/139 pass
  • bun test tests/smoke — 10/10 pass
  • node scripts/repro-704.mjs — 3/3 OK (plugin init deadline)
  • node --input-type=module -e "await import('./dist/index.js')"dist import OK
  • dist/ rebuilt from source and committed; no drift

Pre-existing failures

Tiers 2–4 contain pre-existing failures confirmed on clean main checkout (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_complete was 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

    • Removed chat-visible console.warn / console.info / console.error usage from src/tools/phase-complete.ts for non-fatal internal diagnostics.
    • Routed non-blocking diagnostic paths through the existing debug-gated logger.
    • Kept operator-relevant information in the tool response warnings array where it belongs.
  • Behavior changes

    • Turbo-mode gate skips are now reported as structured warnings on the phase_complete result instead of console output.
    • Non-code / disabled drift-check skip messages stay visible to the caller via warnings, without writing to the chat-visible console path.
    • Lock-release cleanup failures are downgraded to non-fatal debug logging instead of raw console error output.
  • Regression coverage

    • Added focused tests to assert that:
      • turbo-mode phase completion returns warnings without writing to console.warn / console.error
      • non-code drift-skip paths return warnings without writing to console.info

Copilot AI linked an issue May 16, 2026 that may be closed by this pull request
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
Copilot AI requested a review from zaxbysauce May 16, 2026 16:20
@zaxbysauce zaxbysauce marked this pull request as ready for review May 16, 2026 19:19
…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
@zaxbysauce zaxbysauce force-pushed the copilot/fix-logs-leak-into-chat-bar branch from 8714387 to 17e1f38 Compare May 16, 2026 19:35
@zaxbysauce zaxbysauce merged commit 9ab7664 into main May 16, 2026
13 checks passed
@zaxbysauce zaxbysauce deleted the copilot/fix-logs-leak-into-chat-bar branch May 16, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] logs leak into chat bar

3 participants