feat(build/wrap-console): classify console.warn/error into halt events (PR 3 of 7)#54
Merged
Conversation
…RROR Wraps console.warn / console.error and emits halt-events for each line based on pattern classification. Patterns: - "Re-processing the feature" → SILENT_STATE_MUTATION (HIGH) - "worktree cleanup failed" → SOFT_HALT_WARN (LOW) - "PR check unsettled" / "PR not yet mergeable" → SOFT_HALT_WARN (LOW) - "branch deletion failed" → SOFT_HALT_WARN (LOW) - "✗ " error sigil → SOFT_HALT_ERROR (MEDIUM) - Unmatched → SOFT_HALT_WARN/ERROR at level-appropriate severity Original console behavior preserved (wrapper calls original first). Env-gated by GSTACK_HALT_EVENTS_OFF=1 and a NODE_ENV=test guard so test runs don't spam the user's real queue.
Captures soft-halt class (console.warn / console.error lines) into the halt-events queue. Installed only for the build run loop (not for drain-faults, mark-shipped, doctor, monitor — those have separate flows). Uninstall in finally so the shim is always removed on exit.
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
Third PR in the 7-PR halt-events rollout. Adds the wrapConsole shim that classifies every
console.warn/console.errorline in the orchestrator into a SOFT_HALT_WARN / SOFT_HALT_ERROR / SILENT_STATE_MUTATION halt event.The orchestrator emits 281 console.warn/error calls today, only ~7 of which are caught by the explicit helpers in PRs 1+2. This PR catches the rest — the "soft halt" class invisible to structured detection.
What's new
New module:
build/orchestrator/wrap-console.ts(147 lines)classifyConsoleLine(level, msg)— pure function, maps a message to{ kind, severity }.installWrapConsole(ctx)— wrapsconsole.warn/console.errorglobally. Returns an uninstall function.Pattern table (matched in order):
/Re-processing the feature/i→ SILENT_STATE_MUTATION (HIGH) — catches the polis hand-merged-feature class from any code path that prints it (also explicitly emitted atcli.ts:9548in PR 2; matches dedupe via faultId)./worktree cleanup failed/i→ SOFT_HALT_WARN (LOW)/PR check unsettled|PR not yet mergeable/i→ SOFT_HALT_WARN (LOW)/branch deletion failed/i→ SOFT_HALT_WARN (LOW)^✗(orchestrator's error sigil) → SOFT_HALT_ERROR (MEDIUM)Safety knobs:
GSTACK_HALT_EVENTS_OFF=1short-circuits installation (debug escape hatch).NODE_ENV=test+ no explicitqueueDiris a no-op (tests don't pollute the user's real queue).console.warn/console.errorFIRST, then attempts the emit. emit failures are swallowed silently — the shim never crashes the orchestrator.cli.ts wiring (one site, in
main()around line 9442):helperCtxFor(state)is valid).process.exitbefore this block — they don't get the shim, matching the "build mode only" intent).finally(cleanup warnings hit the realconsole.warn, not the wrapped one).Bisectable commits
a0571513— wrap-console module + 14 tests + MODULE_TEST_OWNERS registration.e3031fa6— wireinstallWrapConsole(helperCtxFor(state))into the orchestrator's main entry with try/finally uninstall.Test plan
bun test build/orchestrator/__tests__/wrap-console.test.ts— 14 pass / 0 failbun test build/orchestrator/__tests__/coverage-matrix.test.ts— 4 pass / 0 failbun test build/orchestrator/__tests__/— 1402 pass / 16 fail. Same 16 pre-existing failures as PR 2's baseline; zero new failures.rg -n 'installWrapConsole\\(' build/orchestrator/cli.ts— 1 match (single install site).Versioning
Fork-local skill work per CLAUDE.md
## Fork versioning rule. No top-level VERSION/CHANGELOG bump. No*.tmplchanged — no skill-frontmatter bump either.Plan reference
~/.claude/plans/i-want-the-idempotent-dream.mddocs/superpowers/plans/2026-05-19-idempotent-dream-halt-events.mdPRs 4-7 remaining:
🤖 Generated with Claude Code