Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions tests/unit/backend/test_scenario_hierarchy_parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,15 @@ def test_hierarchy_repeated_attempt_diagnostic_retries_consistency() -> None:


def test_hierarchy_traversal_halts_immediately_on_budget_exhaustion() -> None:
"""Test that with 1,000 root results and max_nodes=1, traversal stops immediately without quadratic loop."""
"""Test that with 1,000 root results and max_nodes=1, traversal stops immediately.

The halt is asserted structurally: exactly one node is projected, truncation
is flagged, and the aggregate total stays exact. A wall clock bound was
removed because a 0.05 second budget failed on contended CI runners by a few
milliseconds while the identical code passed in between runs, and the node
count already proves the traversal did not walk the remaining roots. See
issue #3671 for the failing run evidence.
"""
deltas = [
_make_test_delta(
attack_result_id=f"root-{i}",
Expand All @@ -1214,9 +1222,6 @@ def test_hierarchy_traversal_halts_immediately_on_budget_exhaustion() -> None:

snapshot = _make_test_snapshot(deltas=deltas)

import time

start_time = time.perf_counter()
projection = ScenarioProgressReadModel.build_scenario_hierarchy(
scenario_result_id="scenario-run-1",
scenario_name="TestScenario",
Expand All @@ -1225,9 +1230,7 @@ def test_hierarchy_traversal_halts_immediately_on_budget_exhaustion() -> None:
snapshot=snapshot,
max_nodes=1,
)
elapsed = time.perf_counter() - start_time

assert elapsed < 0.05, f"Expected <0.05s, got {elapsed:.4f}s"
assert projection.truncated is True
# Count total nodes in projection
node_count = sum(len(g.roots) for g in projection.groups)
Expand Down
Loading