Skip to content

Commit 66dbe47

Browse files
authored
refactor(benchmarks): extract planner ownership and isolate verifier imports (#1288)
* refactor(benchmarks): extract planner ownership with bounded validation Rebuild the benchmark planner extraction directly on main 1a30359. Keep CI scripts as import-safe adapters, move compiler and validator semantics into tools.benchmark_plan, preserve the full historical regression corpus against the package owner, restore fail-closed matrix invariants, and retain the latest focused benchmark-contract host mapping. * style(benchmarks): normalize validation imports Use collections.abc for Iterator and align the validation regression import block with the repository Ruff policy. * test(benchmarks): bind planner corpus to package owners Return the complete planner corpus to the approved CLI-integration path, bind its semantic globals and validation helper to tools.benchmark_plan after collection, move extraction-specific assertions into a focused package test, patch process classification against the compiler owner, and align the current Make help contract. * style(benchmarks): avoid constant setattr in collection binding Bind the legacy planner corpus through the collected module dictionary so the extraction hook remains explicit and Ruff-safe. * restore benchmark planner host ownership * fix(benchmarks): isolate conjecture verifier imports
1 parent 289def1 commit 66dbe47

14 files changed

Lines changed: 1621 additions & 1130 deletions

.github/scripts/_ci_paths.py

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,14 @@
1-
"""Shared path-decoding policy for Harbor ``PATHS`` inputs.
2-
3-
These helpers turn a ``PATHS`` input (JSON array, newline list, or
4-
shell-quoted tokens) into repository-relative paths. Harbor planning is the
5-
only remaining consumer.
6-
"""
1+
"""Compatibility adapter for package-owned benchmark path decoding."""
72

83
from __future__ import annotations
94

10-
import json
11-
import shlex
5+
import sys
126
from pathlib import Path
137

14-
__all__ = ["normalize_paths", "path_values"]
15-
16-
17-
def path_values(raw: str) -> list[str]:
18-
"""Decode a PATHS input without making callers manufacture a Git diff."""
8+
ROOT = Path(__file__).resolve().parents[2]
9+
if str(ROOT) not in sys.path:
10+
sys.path.insert(0, str(ROOT))
1911

20-
raw = raw.strip()
21-
if not raw:
22-
return []
23-
try:
24-
value = json.loads(raw)
25-
except json.JSONDecodeError:
26-
value = None
27-
if isinstance(value, list):
28-
if not all(isinstance(path, str) for path in value):
29-
raise ValueError("PATHS JSON must be an array of strings")
30-
return list(value)
31-
if value is not None:
32-
raise ValueError("PATHS JSON must be an array of strings")
33-
return raw.splitlines() if "\n" in raw else shlex.split(raw)
12+
from tools.benchmark_plan.paths import normalize_paths, path_values # noqa: E402
3413

35-
36-
def normalize_paths(paths: list[str]) -> list[str]:
37-
"""Reject non-repository-relative paths and strip leading ``./``."""
38-
39-
normalized: list[str] = []
40-
seen: set[str] = set()
41-
for path in paths:
42-
path = path.replace("\\", "/")
43-
if not path or path.startswith("/") or ".." in Path(path).parts:
44-
raise ValueError(f"changed path must be repository-relative: {path!r}")
45-
path = path.removeprefix("./")
46-
if path not in seen:
47-
normalized.append(path)
48-
seen.add(path)
49-
return normalized
14+
__all__ = ["normalize_paths", "path_values"]

0 commit comments

Comments
 (0)