Skip to content

Commit f539b76

Browse files
luisleo526claude
andcommitted
tests: run the ownership manifest controls in four CTest shards (CR-196)
test_selected_window_ownership_manifest_controls took 126-132 s on the loaded pool box (180 s budget) and hit the timeout in Debug and sanitizers (run 39172376128). The module is pure Python and ~39 checker subprocess runs; the same loader-discovered cases now run as four CTest entries test_selected_window_ownership_manifest_controls_shard_{1..4}of4, each with the same 180 s TIMEOUT, so no timeout is raised and no assertion, fixture or the checker changes. tests/ownership/test_manifest_checker.py gains --shard I/N (sorted ManifestCheckerTests ids at positions [I-1::N], plus a cheap partition guard case run in every shard that proves, for N=1..8, the shards are disjoint and cover every case); without --shard the module behaves as before (preflight and scripts/test_private_fixture_reads.py run it unsharded). CMake, docs/ci.md, tests/ownership/README.md, the ci_verify floor note and the CHANGELOG say so. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 39d6fa1 commit f539b76

7 files changed

Lines changed: 125 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: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,13 +3772,25 @@ 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+
# 126/4 = 31.5 s, or 132.3/4 = 33.1 s using the slowest passing measurement.
3779+
# 180/33.1 = 5.4x estimated headroom before overhead (60 s/shard allows 3x).
3780+
# Cases have unequal costs; the supervisor verifies each shard's loaded time.
3781+
set(_pf_ownership_control_shards)
3782+
foreach(_pf_ownership_shard 1 2 3 4)
3783+
add_test(NAME test_selected_window_ownership_manifest_controls_shard_${_pf_ownership_shard}of4
3784+
COMMAND ${Python3_EXECUTABLE} -I -B ${PROJECT_SOURCE_DIR}/tests/ownership/test_manifest_checker.py
3785+
--shard ${_pf_ownership_shard}/4)
3786+
list(APPEND _pf_ownership_control_shards
3787+
test_selected_window_ownership_manifest_controls_shard_${_pf_ownership_shard}of4)
3788+
endforeach()
37773789
add_test(NAME test_selected_window_ownership_d4
37783790
COMMAND ${Python3_EXECUTABLE} -I -B ${PROJECT_SOURCE_DIR}/tests/ownership/test_manifest_checker.py
37793791
ManifestCheckerTests.test_d4_independent_reconstruction_matches_manifest)
37803792
set_tests_properties(test_selected_window_ownership_manifest
3781-
test_selected_window_ownership_manifest_controls test_selected_window_ownership_d4
3793+
${_pf_ownership_control_shards} test_selected_window_ownership_d4
37823794
PROPERTIES WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} TIMEOUT 180)
37833795

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

‎tests/ownership/README.md‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,33 @@ 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]`. The separate cheap
293+
`test_shards_partition_every_case_exactly_once` guard runs in every shard:
294+
for each shard count from 1 through 8 it independently discovers at least 30
295+
cases and checks the exact assignments, disjointness and full coverage.
296+
Preflight continues to run the complete unsharded suite. The positive
297+
`test_selected_window_ownership_manifest` and independent
298+
`test_selected_window_ownership_d4` CTest rows keep their existing commands.

‎tests/ownership/test_manifest_checker.py‎

Lines changed: 59 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,58 @@ 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+
unittest.main(module=None, defaultTest=shard_case_ids(index, count) + guards,
526+
argv=[sys.argv[0]])
527+
else:
528+
unittest.main()

0 commit comments

Comments
 (0)