Skip to content

fix(task-graph): stamp saturating depth on over-cap bridge + dedupe warn per parent#603

Open
sroussey wants to merge 1 commit into
claude/beautiful-mayer-j1anwifrom
claude/beautiful-mayer-j1anwi-cap-fix
Open

fix(task-graph): stamp saturating depth on over-cap bridge + dedupe warn per parent#603
sroussey wants to merge 1 commit into
claude/beautiful-mayer-j1anwifrom
claude/beautiful-mayer-j1anwi-cap-fix

Conversation

@sroussey

Copy link
Copy Markdown
Collaborator

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's BRIDGE_DEPTH marker. When the cap fires, the code returns early without stamping the subgraph — so the next bridge call (whose parentGraph is this just-skipped subgraph) reads BRIDGE_DEPTH as undefined, falls back to 0, and reinstalls listeners. The cap leaks downstream.

Fix: stamp subGraph[BRIDGE_DEPTH] = maxDepth before 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-level WeakSet<TaskGraph> keyed by parentGraph so 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:types clean.


Generated by Claude Code

…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.
@github-actions

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 62.51% 25336 / 40528
🔵 Statements 62.35% 26219 / 42050
🔵 Functions 63.75% 4815 / 7552
🔵 Branches 51.09% 12373 / 24216
File CoverageNo changed files found.
Generated in workflow #2627 for commit 50a969a by the Vitest Coverage Report Action

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.

2 participants