Skip to content

Commit a2cd0a1

Browse files
authored
Merge branch 'main' into ownership-probe-expectations
2 parents 2f7c1a3 + 375795a commit a2cd0a1

7 files changed

Lines changed: 142 additions & 5 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ version number follows semantic versioning over the surfaces the
77

88
## Unreleased
99

10+
- **Ownership manifest controls run in four CTest shards (CR-196).** The same
11+
loader-discovered cases keep every assertion and the 180-second timeout per
12+
row; a cheap guard checks complete, disjoint assignment for shard counts
13+
1 through 8. Preflight continues to run the complete unsharded suite.
1014
- **EN-115 selected-window completeness proof completed.** From 1.6.2 the image
1115
declares selected-window contract revision `1.3` again: the section-4
1216
producers and manifest are present, `value_ownership` is `complete`, and a

‎docs/ci.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ TAIL-I's one, XAU-CAL's four and FIX-E1E2's two). The full-run release and
192192
kernel floors are the table's own numbers above (603 and 306 rows absent, 910
193193
and 337 with the overlay present); full runs do not exclude a label.
194194

195+
CR-196 splits the ownership manifest controls into four CTest shards,
196+
`test_selected_window_ownership_manifest_controls_shard_1of4` through
197+
`test_selected_window_ownership_manifest_controls_shard_4of4`, each with the
198+
existing 180-second timeout. This adds three public registered/run rows to
199+
every engine profile in both fixture worlds; it only raises the counts above
200+
the pinned minimum floors listed above. The private-fixture and receipt row
201+
populations stay the same. Preflight still runs the complete unsharded driver;
202+
see [the controls commands](../tests/ownership/README.md#manifest-checker-controls)
203+
for parallel CTest and individual shard invocations.
204+
195205
Preflight also runs the detached-comment census of the kernel compile closure
196206
(`detached-comments`: `scripts/measure_detached_comments.py --check-ceiling`)
197207
against the checked-in `DETACHED_LINE_CEILING`, which is 0: R5 lane B-DOCS

‎scripts/ci_verify.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,11 @@
790790
'release': (RELEASE_MIN_TESTS, 307),
791791
'kernel': (KERNEL_MIN_TESTS, 31),
792792
}
793+
# CR-196 replaces one public ownership-controls row with four shards (+3
794+
# registered/run rows in every engine profile, in either fixture world).
795+
# These pinned minimum floors (absent: release 603, kernel 306) and the PR
796+
# registration minima remain lower bounds; more rows only raise the count.
797+
# The receipt/private-fixture populations and runner-only floors are unchanged.
793798

794799

795800
def private_fixtures_overlay() -> bool:

‎scripts/test_private_fixture_reads.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ def __init__(self, directory: Path):
252252
shutil.copy(REPO / 'tests' / name, self.root / 'tests')
253253
for driver in sorted((REPO / 'tests').glob('*.py')):
254254
shutil.copy(driver, self.root / 'tests')
255-
# Both ownership registrations name this nested driver.
255+
# The four ownership control shards and the D4 row share this nested
256+
# driver; one copy lets the sweep inspect every registration.
256257
(self.root / 'tests' / 'ownership').mkdir()
257258
shutil.copy(REPO / 'tests' / 'ownership' / 'test_manifest_checker.py',
258259
self.root / 'tests' / 'ownership')

‎tests/CMakeLists.txt‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,13 +3772,28 @@ endif()
37723772
# EN-132 M: source-only ownership proof, controls, and an independent D4 route.
37733773
add_test(NAME test_selected_window_ownership_manifest
37743774
COMMAND ${Python3_EXECUTABLE} -I -B ${PROJECT_SOURCE_DIR}/scripts/check_selected_window_ownership.py)
3775-
add_test(NAME test_selected_window_ownership_manifest_controls
3776-
COMMAND ${Python3_EXECUTABLE} -I -B ${PROJECT_SOURCE_DIR}/tests/ownership/test_manifest_checker.py)
3775+
# CR-196: lab release/debug/sanitizers/kernel took 57.0/65.9/85.5/56.9 s.
3776+
# Loaded pool release/kernel/native-live took 125.7/126.8/132.3 s; debug and
3777+
# sanitizers timed out at 180.02 s. Four shards keep the same 180 s budget.
3778+
# The cases are unequal: the heaviest shard (3) holds 15 of the 39 checker
3779+
# runs. ESTIMATE, not measured: 132.3 s x 15/39 = 50.9 s on the loaded pool in
3780+
# Release; scaling by the lab sanitizers/release ratio (85.5/57.0 = 1.5) gives
3781+
# about 76 s for sanitizers, i.e. 2.4x headroom against 180 s. The lab run of
3782+
# the four shard rows is the measurement; each shard also fails closed when it
3783+
# runs a number of tests different from the number it selected.
3784+
set(_pf_ownership_control_shards)
3785+
foreach(_pf_ownership_shard 1 2 3 4)
3786+
add_test(NAME test_selected_window_ownership_manifest_controls_shard_${_pf_ownership_shard}of4
3787+
COMMAND ${Python3_EXECUTABLE} -I -B ${PROJECT_SOURCE_DIR}/tests/ownership/test_manifest_checker.py
3788+
--shard ${_pf_ownership_shard}/4)
3789+
list(APPEND _pf_ownership_control_shards
3790+
test_selected_window_ownership_manifest_controls_shard_${_pf_ownership_shard}of4)
3791+
endforeach()
37773792
add_test(NAME test_selected_window_ownership_d4
37783793
COMMAND ${Python3_EXECUTABLE} -I -B ${PROJECT_SOURCE_DIR}/tests/ownership/test_manifest_checker.py
37793794
ManifestCheckerTests.test_d4_independent_reconstruction_matches_manifest)
37803795
set_tests_properties(test_selected_window_ownership_manifest
3781-
test_selected_window_ownership_manifest_controls test_selected_window_ownership_d4
3796+
${_pf_ownership_control_shards} test_selected_window_ownership_d4
37823797
PROPERTIES WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} TIMEOUT 180)
37833798

37843799
# The C bridge test also links the shared window-plan helper, whose bridge

‎tests/ownership/README.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,36 @@ a watchdog, native observer acceptance test, deadline/billing classification
266266
or a full canonical phase-schema audit. Stage timeouts remain driver errors.
267267
The broader corpus, manifest, parity sweep, ABI gates and exact-tree maintainer
268268
verification remain separate acceptance work.
269+
270+
## Manifest checker controls
271+
272+
Run the complete source-only manifest controls with Python 3.10+:
273+
274+
```bash
275+
python3 -I -B tests/ownership/test_manifest_checker.py
276+
```
277+
278+
CTest distributes the same `ManifestCheckerTests` cases across four rows,
279+
`test_selected_window_ownership_manifest_controls_shard_1of4`,
280+
`test_selected_window_ownership_manifest_controls_shard_2of4`,
281+
`test_selected_window_ownership_manifest_controls_shard_3of4`, and
282+
`test_selected_window_ownership_manifest_controls_shard_4of4`. Each keeps its
283+
180-second timeout. Run all four in parallel, or one shard directly:
284+
285+
```bash
286+
ctest --test-dir build --output-on-failure --parallel 4 \
287+
-R '^test_selected_window_ownership_manifest_controls_shard_[1-4]of4$'
288+
python3 -I -B tests/ownership/test_manifest_checker.py --shard 1/4
289+
```
290+
291+
`--shard I/N` requires integers with `1 <= I <= N` and selects
292+
`sorted(loader case ids)[I-1::N]`, passes those ids to unittest by name and
293+
exits non-zero unless it ran exactly the number of tests it selected (9, 9, 9
294+
and 8 for shards 1 to 4 of 4: 8, 8, 8 and 7 cases plus the guard). The separate cheap `test_shards_partition_every_case_exactly_once`
295+
guard runs in every shard: for each shard count from 1 through 8 it rebuilds
296+
the assignment from the loader's ids with index residues (the same loader
297+
expression, a different assignment rule) and checks the exact assignments,
298+
disjointness and full coverage, with at least 30 cases discovered.
299+
Preflight continues to run the complete unsharded suite. The positive
300+
`test_selected_window_ownership_manifest` and independent
301+
`test_selected_window_ownership_d4` CTest rows keep their existing commands.

‎tests/ownership/test_manifest_checker.py‎

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55
The positive tree check deliberately requires the integrated producers, rather
66
than accepting a recorded count or treating existing integration findings as a
77
successful check. The supervisor runs this suite on the completed tree.
8+
9+
Use --shard I/N (1-based) to run sorted loader-discovered ManifestCheckerTests
10+
ids at positions [I-1::N], plus the cheap partition guard in every shard.
11+
Without --shard, the usual unittest discovery and CLI selectors apply.
812
"""
913
from __future__ import annotations
1014

15+
import argparse
1116
import ast
1217
import copy
1318
import ctypes
@@ -466,5 +471,69 @@ def test_duplicate_json_key_is_rejected(self):
466471
self.assertIn("ownership[input]: duplicate JSON key format", result.stdout.splitlines())
467472

468473

474+
def shard_case_ids(index: int, count: int) -> list[str]:
475+
ids = sorted(test.id() for test in
476+
unittest.TestLoader().loadTestsFromTestCase(ManifestCheckerTests))
477+
return ids[index - 1::count]
478+
479+
480+
class ManifestCheckerShardingTests(unittest.TestCase):
481+
def test_shards_partition_every_case_exactly_once(self):
482+
# Discover the expectation independently of shard_case_ids, and use
483+
# index residues rather than reproducing its slicing implementation.
484+
ids = sorted(test.id() for test in
485+
unittest.TestLoader().loadTestsFromTestCase(ManifestCheckerTests))
486+
self.assertGreaterEqual(len(ids), 30)
487+
for count in range(1, 9):
488+
with self.subTest(shards=count):
489+
seen = set()
490+
total = 0
491+
for index in range(1, count + 1):
492+
shard = shard_case_ids(index, count)
493+
expected = [test_id for position, test_id in enumerate(ids)
494+
if position % count == index - 1]
495+
self.assertEqual(shard, expected)
496+
self.assertEqual(len(shard), len(set(shard)))
497+
self.assertTrue(seen.isdisjoint(shard))
498+
seen.update(shard)
499+
total += len(shard)
500+
self.assertEqual(seen, set(ids))
501+
self.assertEqual(total, len(ids))
502+
503+
504+
def parse_shard(value: str) -> tuple[int, int]:
505+
message = "--shard must be I/N with integers satisfying 1 <= I <= N"
506+
if re.fullmatch(r"[1-9][0-9]*/[1-9][0-9]*", value) is None:
507+
raise argparse.ArgumentTypeError(message)
508+
index, count = map(int, value.split("/"))
509+
if index > count:
510+
raise argparse.ArgumentTypeError(message)
511+
return index, count
512+
513+
469514
if __name__ == "__main__":
470-
unittest.main()
515+
if any(arg == "--shard" or arg.startswith("--shard=") for arg in sys.argv[1:]):
516+
parser = argparse.ArgumentParser(allow_abbrev=False)
517+
parser.add_argument("--shard", type=parse_shard, metavar="I/N",
518+
required=True, action="append")
519+
args = parser.parse_args()
520+
if len(args.shard) != 1:
521+
parser.error("specify --shard exactly once")
522+
index, count = args.shard[0]
523+
guards = [test.id() for test in unittest.TestLoader().loadTestsFromTestCase(
524+
ManifestCheckerShardingTests)]
525+
selected = shard_case_ids(index, count) + guards
526+
if len(selected) == len(guards):
527+
parser.error("shard %d/%d selects no case" % (index, count))
528+
# The ids go in argv: with module=None unittest ignores defaultTest and
529+
# would fall back to discovery (zero tests, exit 0 before Python 3.12).
530+
program = unittest.main(module=None, argv=[sys.argv[0], *selected], exit=False)
531+
# A shard that ran a different number of tests than it selected fails,
532+
# whatever unittest's own exit status says.
533+
if program.result.testsRun != len(selected) or not program.result.wasSuccessful():
534+
print("shard %d/%d: ran %d tests, selected %d" % (
535+
index, count, program.result.testsRun, len(selected)), file=sys.stderr)
536+
sys.exit(1)
537+
print("shard %d/%d: ran %d tests as selected" % (index, count, len(selected)))
538+
else:
539+
unittest.main()

0 commit comments

Comments
 (0)