Skip to content

Commit 5c179ea

Browse files
authored
Modularize Make targets and retire C901 backlog (#780)
* Modularize Make targets and enforce complexity limits * Fix SMT checker type narrowing
1 parent 228e494 commit 5c179ea

155 files changed

Lines changed: 11683 additions & 8210 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ci-impact.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@
415415
{
416416
"name": "makefile",
417417
"patterns": [
418-
"Makefile"
418+
"Makefile",
419+
"make/**"
419420
],
420421
"suites": [
421422
"static",

.github/scripts/plan-benchmarks

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ BENCHMARK_CONTROL_PATHS = frozenset(
6666
".github/workflows/benchmarks.yml",
6767
".github/workflows/heldout-benchmarks.yml",
6868
"Makefile",
69+
"make/harbor.mk",
6970
"tools/check_benchmark_adapters.py",
7071
"tools/benchmark_pr_status.py",
7172
"tools/check_benchmark_contracts.py",

.github/scripts/validate-ci-plan

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import tomllib
1111
from pathlib import Path
1212

1313
ROOT = Path(__file__).resolve().parents[2]
14+
if str(ROOT) not in sys.path:
15+
sys.path.insert(0, str(ROOT))
16+
17+
from tools.makefile_catalog import MakefileCatalogError, discover_makefiles
1418

1519
BOOLEAN_KEYS = (
1620
"run-python",
@@ -117,7 +121,7 @@ def _validate_catalog() -> None:
117121
targets = set(
118122
re.findall(
119123
r"(?m)^([A-Za-z0-9_.-]+):(?:[^=]|$)",
120-
(ROOT / "Makefile").read_text(encoding="utf-8"),
124+
discover_makefiles(ROOT).text(),
121125
)
122126
)
123127
for name, entry in catalog.items():
@@ -177,7 +181,14 @@ def _validate_catalog() -> None:
177181
"CI catalog must keep a local-only deploy gate "
178182
"with command 'make deploy-check'"
179183
)
180-
except (OSError, KeyError, TypeError, ValueError, tomllib.TOMLDecodeError) as exc:
184+
except (
185+
MakefileCatalogError,
186+
OSError,
187+
KeyError,
188+
TypeError,
189+
ValueError,
190+
tomllib.TOMLDecodeError,
191+
) as exc:
181192
fail(f"invalid CI validation catalog: {exc}")
182193

183194

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ jobs:
119119
--config benchmarks/environment-profiles.toml \
120120
--config .github/workflows/benchmarks.yml \
121121
--config Makefile \
122+
--config make/harbor.mk \
122123
--config tools/check_benchmark_adapters.py \
123124
--config tools/check_benchmark_contracts.py \
124125
--config tools/check_benchmark_static.py \

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ jobs:
118118
--config .github/scripts/validate-ci-plan \
119119
--config .github/workflows/ci.yml \
120120
--config Makefile \
121+
--config make/development.mk \
122+
--config make/harbor.mk \
123+
--config make/evaluations.mk \
121124
--plan-file "$plan_dir/plan.txt" \
122125
--paths-file "$plan_dir/changed-paths.txt" \
123126
--output "$plan_dir/plan-receipt.json"

Makefile

Lines changed: 7 additions & 407 deletions
Large diffs are not rendered by default.

benchmarks/datasets/conjecture-probes-v1/reconstruction-deck-certificate/tests/verifier_support.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,21 @@ def resolve_evidence(
267267
_JSON_WHITESPACE_CHARS = " \t\n\r"
268268

269269

270+
def _drain_stream_tail(stream, decoder) -> None:
271+
"""Reject any non-whitespace content after the parsed JSON value."""
272+
273+
while True:
274+
block = stream.read(65_536)
275+
if not block:
276+
break
277+
tail = decoder.decode(block)
278+
if tail and not all(character in _JSON_WHITESPACE for character in tail):
279+
raise ValueError("non-whitespace after evidence JSON value")
280+
tail = decoder.decode(b"", final=True)
281+
if tail and not all(character in _JSON_WHITESPACE for character in tail):
282+
raise ValueError("non-whitespace after evidence JSON value")
283+
284+
270285
def _read_streaming_json_value(stream) -> Any:
271286
"""Parse the first JSON value from a binary stream without a byte cap.
272287
@@ -301,16 +316,7 @@ def _read_streaming_json_value(stream) -> Any:
301316
continue
302317
if not all(character in _JSON_WHITESPACE for character in buffer[end:]):
303318
raise ValueError("non-whitespace after evidence JSON value")
304-
while True:
305-
block = stream.read(65_536)
306-
if not block:
307-
break
308-
tail = decoder.decode(block)
309-
if tail and not all(character in _JSON_WHITESPACE for character in tail):
310-
raise ValueError("non-whitespace after evidence JSON value")
311-
tail = decoder.decode(b"", final=True)
312-
if tail and not all(character in _JSON_WHITESPACE for character in tail):
313-
raise ValueError("non-whitespace after evidence JSON value")
319+
_drain_stream_tail(stream, decoder)
314320
return value
315321

316322

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM python:3.12-slim@sha256:57cd7c3a7a273101a6485ba99423ee568157882804b1124b4dd04266317710de
22
RUN python -m pip install --no-cache-dir attrs==26.1.0 jsonschema==4.26.0 jsonschema-specifications==2025.9.1 referencing==0.37.0 rpds-py==2026.6.3 typing-extensions==4.16.0
33
LABEL jacobian.task="jacobian/vizing-bounded-cartesian-products" \
4-
jacobian.checksum="0eba7b4cb29a47aae2d613ea04941d599c32998dda49aa089653441a50db6945"
4+
jacobian.checksum="838147c45b1c21c5b7d1e54d2b0d1d5995c448b2bb649669dbefda6def151b59"
55
COPY expected.json input.json public_contract.json test.sh verifier.py verifier_support.py /tests/
66
COPY input.json /app/input.json
77
RUN chmod +x /tests/test.sh && python -c 'import json; assert json.load(open("/tests/input.json"))["task_id"] == "jacobian/vizing-bounded-cartesian-products"'

benchmarks/datasets/conjecture-probes-v1/vizing-bounded-cartesian-products/tests/verifier.py

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,25 @@ def _product(left: list[list[int]], right: list[list[int]]) -> list[list[int]]:
8484
return [sorted(neighbors) for neighbors in result]
8585

8686

87+
def _frozen_graphs(graphs: list[object]) -> dict[str, list[list[int]]] | None:
88+
by_id: dict[str, list[list[int]]] = {}
89+
for graph in graphs:
90+
if (
91+
not isinstance(graph, dict)
92+
or set(graph) != {"id", "adjacency"}
93+
or graph.get("id") not in GRAPH_IDS
94+
or graph["id"] in by_id
95+
):
96+
return None
97+
adjacency = _adjacency(graph["adjacency"])
98+
if adjacency is None:
99+
return None
100+
by_id[graph["id"]] = adjacency
101+
if tuple(by_id) != GRAPH_IDS:
102+
return None
103+
return by_id
104+
105+
87106
def _frozen() -> dict[str, Any] | None:
88107
try:
89108
value = json.loads((TESTS / "input.json").read_text())
@@ -106,20 +125,8 @@ def _frozen() -> dict[str, Any] | None:
106125
or len(pairs) != 13
107126
):
108127
return None
109-
by_id: dict[str, list[list[int]]] = {}
110-
for graph in graphs:
111-
if (
112-
not isinstance(graph, dict)
113-
or set(graph) != {"id", "adjacency"}
114-
or graph.get("id") not in GRAPH_IDS
115-
or graph["id"] in by_id
116-
):
117-
return None
118-
adjacency = _adjacency(graph["adjacency"])
119-
if adjacency is None:
120-
return None
121-
by_id[graph["id"]] = adjacency
122-
if tuple(by_id) != GRAPH_IDS:
128+
by_id = _frozen_graphs(graphs)
129+
if by_id is None:
123130
return None
124131
actual = []
125132
for pair in pairs:
@@ -167,17 +174,11 @@ def _product_witness(
167174
)
168175

169176

170-
def _math(result: object, frozen: dict[str, Any]) -> bool:
171-
if (
172-
not isinstance(result, dict)
173-
or set(result) != {"graphs", "pairs", "derived_conclusion", "scope_identity"}
174-
or result.get("scope_identity") != SCOPE
175-
):
176-
return False
177-
graphs = frozen["graphs"]
178-
expected = {name: _domination(graphs[name]) for name in GRAPH_IDS}
179-
if any(value is None for value in expected.values()):
180-
return False
177+
def _math_graphs(
178+
result: dict[str, Any],
179+
graphs: dict[str, list[list[int]]],
180+
expected: dict[str, Any],
181+
) -> bool:
181182
rows = result.get("graphs")
182183
if not isinstance(rows, list) or len(rows) != 8:
183184
return False
@@ -204,11 +205,17 @@ def _math(result: object, frozen: dict[str, Any]) -> bool:
204205
or not _dominates(row["minimum_dominating_set"], gamma, adjacency)
205206
):
206207
return False
207-
if seen != set(GRAPH_IDS):
208-
return False
208+
return seen == set(GRAPH_IDS)
209+
210+
211+
def _math_pairs(
212+
result: dict[str, Any],
213+
graphs: dict[str, list[list[int]]],
214+
expected: dict[str, Any],
215+
) -> bool | None:
209216
rows = result.get("pairs")
210217
if not isinstance(rows, list) or len(rows) != 13:
211-
return False
218+
return None
212219
seen_pairs: set[tuple[str, str]] = set()
213220
all_hold = True
214221
for row in rows:
@@ -226,10 +233,10 @@ def _math(result: object, frozen: dict[str, Any]) -> bool:
226233
"bound_holds",
227234
}
228235
if not isinstance(row, dict) or set(row) != required:
229-
return False
236+
return None
230237
pair = (row.get("left"), row.get("right"))
231238
if pair not in PAIR_IDS or pair in seen_pairs:
232-
return False
239+
return None
233240
seen_pairs.add(pair)
234241
left, right = pair
235242
left_adj, right_adj = graphs[left], graphs[right]
@@ -238,7 +245,7 @@ def _math(result: object, frozen: dict[str, Any]) -> bool:
238245
product_adj = _product(left_adj, right_adj)
239246
product_value = _domination(product_adj)
240247
if product_value is None:
241-
return False
248+
return None
242249
product_gamma = product_value[0]
243250
if (
244251
row["gamma_left"] != left_gamma
@@ -257,12 +264,31 @@ def _math(result: object, frozen: dict[str, Any]) -> bool:
257264
len(right_adj),
258265
)
259266
):
260-
return False
267+
return None
261268
holds = product_gamma >= left_gamma * right_gamma
262269
if row["bound_holds"] is not holds:
263-
return False
270+
return None
264271
all_hold = all_hold and holds
265272
if seen_pairs != set(PAIR_IDS):
273+
return None
274+
return all_hold
275+
276+
277+
def _math(result: object, frozen: dict[str, Any]) -> bool:
278+
if (
279+
not isinstance(result, dict)
280+
or set(result) != {"graphs", "pairs", "derived_conclusion", "scope_identity"}
281+
or result.get("scope_identity") != SCOPE
282+
):
283+
return False
284+
graphs = frozen["graphs"]
285+
expected = {name: _domination(graphs[name]) for name in GRAPH_IDS}
286+
if any(value is None for value in expected.values()):
287+
return False
288+
if not _math_graphs(result, graphs, expected):
289+
return False
290+
all_hold = _math_pairs(result, graphs, expected)
291+
if all_hold is None:
266292
return False
267293
return result.get("derived_conclusion") == (
268294
"HOLDS_ON_FROZEN_PAIR_SET" if all_hold else "VIOLATION_IN_FROZEN_PAIR_SET"

benchmarks/datasets/mathematical-benchmarks-v1/cubic-image-classification/tests/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM python:3.12-slim@sha256:57cd7c3a7a273101a6485ba99423ee568157882804b1124b4dd04266317710de
22
RUN python -m pip install --no-cache-dir attrs==26.1.0 jsonschema==4.26.0 jsonschema-specifications==2025.9.1 referencing==0.37.0 rpds-py==2026.6.3 typing-extensions==4.16.0
3-
LABEL jacobian.checksum="188d51930c7bafebb659afa2d9d75c9388616f39636c18216114d9823fef83f6"
3+
LABEL jacobian.checksum="51e3e8145415187b5ef60562608ae5f7b2cfd38fa0ff169cf86b09437988cc59"
44
LABEL jacobian.task="jacobian/cubic-image-classification"
55
COPY expected.json input.json test.sh verifier.py verifier_support.py public_contract.json /tests/
66
COPY input.json /app/input.json

0 commit comments

Comments
 (0)