From 9910c89b4cb3e51fbf7e8e4e46e4a635cd2761ee Mon Sep 17 00:00:00 2001 From: fas89 <50082482+fas89@users.noreply.github.com> Date: Sat, 3 Oct 2026 02:18:18 +0200 Subject: [PATCH] fix(tests): the composition perf test scans its own tree, not pytest's shared temp root test_for_contract_perf_bound_shallow_path put the workspace directly in tmp_path. Its marker-less ancestor walk then took tmp_path's parents as scan roots: pytest's per-worker and per-session temp roots, which hold every contract written by every test that ran before it. The scan time therefore grew with the suite and failed the 10 s bound on main's Coverage & Audit run (10.50 s) after the 0.18.0 PRs added many contract-writing tests; locally the old placement takes 19 s. The workspace now sits _MAX_ANCESTOR_LEVELS below tmp_path, so the capped walk still crosses marker-less ancestors but ends at tmp_path, and the test asserts that. It runs in about 1 s; reverting the placement fails the new assertion. --- tests/test_composition_workspace_scan.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/test_composition_workspace_scan.py b/tests/test_composition_workspace_scan.py index 7704bbd4..349183d7 100644 --- a/tests/test_composition_workspace_scan.py +++ b/tests/test_composition_workspace_scan.py @@ -400,9 +400,13 @@ def test_for_contract_perf_bound_shallow_path(tmp_path, monkeypatch): ancestor walk runs; the hard cap + dot-dir pruning keep it bounded. """ # A workspace dir holding the contract + its upstreams, with no - # boundary marker — the ancestor walk will run from here. - ws = tmp_path / "shallow_ws" - ws.mkdir() + # boundary marker — the ancestor walk will run from here. It sits + # _MAX_ANCESTOR_LEVELS below tmp_path, so the capped walk ends at + # tmp_path: the scan still crosses marker-less ancestors up to the cap, + # but never reaches pytest's shared per-worker temp root, whose size + # depends on how many contract-writing tests ran before this one. + ws = tmp_path / "l1" / "l2" / "shallow_ws" + ws.mkdir(parents=True) consumes = [] for i in range(9): pid = f"raw.upstream_{i}" @@ -418,6 +422,12 @@ def test_for_contract_perf_bound_shallow_path(tmp_path, monkeypatch): elapsed = time.perf_counter() - start assert out == [] + # The walk stopped at the cap, inside this test's own tree. + from fluid_build.forge.product_types import _MAX_ANCESTOR_LEVELS, _resolve_scan_roots + + roots = _resolve_scan_roots(None, target) + assert len(roots) == _MAX_ANCESTOR_LEVELS + 1 + assert roots[-1] == tmp_path # Deliberately generous bound — cf. tests/perf/test_ux_performance_budgets.py # ("catch regressions, not police absolute speed"). The historical # BUG-VALIDATE-SLOW took *tens of seconds* because the ancestor walk