fix(task-graph): stamp saturating depth on over-cap bridge + dedupe warn per parent#603
Open
sroussey wants to merge 1 commit into
Open
Conversation
…arn per parent Without the saturating stamp, when bridgeSubGraphTaskEvents short-circuits at the depth cap, the subgraph is left without a BRIDGE_DEPTH marker — so the next bridge level reads depth as undefined (0) and the cap leaks downstream. Stamp the subgraph at maxDepth before the early return so every nested bridge also short-circuits. Also gate the warn through a module-level WeakSet keyed by parent graph: an iterator with 1k iterations at over-cap was previously emitting 1k warns per run.
Coverage Report
File CoverageNo changed files found. |
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.
Stacks on #601. Two follow-up fixes to
SubGraphEventBridge.1. Saturating depth stamp on over-cap
The existing depth cap (
DEFAULT_MAX_BRIDGE_DEPTH = 16) is derived from the parent graph'sBRIDGE_DEPTHmarker. When the cap fires, the code returns early without stamping the subgraph — so the next bridge call (whoseparentGraphis this just-skipped subgraph) readsBRIDGE_DEPTHasundefined, falls back to0, and reinstalls listeners. The cap leaks downstream.Fix: stamp
subGraph[BRIDGE_DEPTH] = maxDepthbefore returning the no-op teardown. Every nested bridge whose parent is an over-cap subgraph now also short-circuits.2. Warn deduplication per parent graph
Without dedupe, an iterator with N iterations at over-cap emits N warns per run (1k iterations = 1k warns). Gate the
getLogger().warn(...)through a module-levelWeakSet<TaskGraph>keyed byparentGraphso each unique parent warns at most once. Held weakly so an evicted parent is still GC-able.Tests
stamped over-cap subgraph prevents downstream bridges from restarting depth— maxDepth=2, 5-level chain; verifies no event escapes past the cap (without the stamp, depth resets and the event leaks 3 levels outward).warn fires exactly once per parentGraph at over-cap— 50 over-cap calls with the same parent; expects exactly 1 warn.distinct parents at over-cap each warn once— two parents → two warns.All 731 graph-section vitest tests pass;
build:typesclean.Generated by Claude Code