mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-16 19:59:26 +00:00
Off every active line (PATHFINDER-2026-10-13/03-unified-proposal.md, cuts). Deleted: the four hunter tools no caller enables (read_definition, entry_points, flows, obligations) with their schemas and dispatch, the dead mapping branch of find_refs; 20 functions whose only caller was one test (mapping task records, compute_ranking_metrics, build_quick_hunter_prompt, validate_evidence_transition, should_fuse, harness processors, rank_targets_with_model, model/report slice rendering, taxonomy hierarchical/related, config_value.verdict, taint.verdict, roles.load_roles, features.language_of and build_for_scan, folds.leave_one_*, features.recorded_case, search BatchExecutor and the three __main__ shims, delivery.put_input); the receiver delivery mode of the plane. push_inputs.py moved to benchmarks/push. memory.purge stays: the live-S3 test cleanup uses it. Net: 2,730 lines deleted, 207 added. 473 targeted tests passed; 3,282 tests collect. breadth.toml records the removals. Co-Authored-By: Claude Fable 5.1 <[email protected]>
52 lines
2.3 KiB
Python
52 lines
2.3 KiB
Python
"""Folds by repository group (learned-decision-engine design 4.3-4.4, task 6.3)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
from learn_fixtures import corpus
|
|
|
|
from openultrasast.learn.folds import Fold, FoldError, assert_disjoint, compile_split, folds_digest, outer_folds
|
|
|
|
|
|
def test_compile_split_is_a_quarter_of_groups_and_disjoint_from_every_evaluation_fold() -> None:
|
|
examples = corpus(groups=20)
|
|
split = compile_split(examples, seed=1)
|
|
groups = {e.group for e in examples}
|
|
assert len(split.groups) == 6 and split.groups <= groups # 25% of each family's 10 groups, rounded: 3 + 3
|
|
assert split.boot | split.val == split.groups and not split.boot & split.val and len(split.boot) == 4
|
|
folds = [
|
|
*outer_folds(examples, seed=1, exclude=split.groups),
|
|
]
|
|
assert_disjoint(split, folds)
|
|
for fold in folds:
|
|
assert not fold.eval_groups & split.groups
|
|
|
|
|
|
def test_outer_folds_partition_the_remaining_groups_stratified() -> None:
|
|
examples = corpus(groups=20)
|
|
split = compile_split(examples, seed=1)
|
|
folds = outer_folds(examples, seed=1, exclude=split.groups)
|
|
assert len(folds) == 5
|
|
union = set().union(*(f.eval_groups for f in folds))
|
|
assert union == {e.group for e in examples} - split.groups and sum(len(f.eval_groups) for f in folds) == len(union)
|
|
assert max(len(f.eval_groups) for f in folds) - min(len(f.eval_groups) for f in folds) <= 1
|
|
|
|
|
|
def test_folds_are_deterministic_by_seed() -> None:
|
|
examples = corpus(groups=20)
|
|
a, b = compile_split(examples, seed=7), compile_split(examples, seed=7)
|
|
assert a == b and outer_folds(examples, seed=7) == outer_folds(examples, seed=7)
|
|
assert folds_digest(a, outer_folds(examples, seed=7)) == folds_digest(b, outer_folds(examples, seed=7))
|
|
assert any(compile_split(examples, seed=s).groups != a.groups for s in range(1, 6))
|
|
|
|
|
|
def test_a_shared_group_is_refused() -> None:
|
|
examples = corpus(groups=8)
|
|
split = compile_split(examples, seed=0)
|
|
leaked = Fold("outer", "outer-x", frozenset({next(iter(split.groups))}))
|
|
with pytest.raises(FoldError, match="compile split"):
|
|
assert_disjoint(split, [leaked])
|
|
twice = [Fold("outer", "a", frozenset({"g"})), Fold("outer", "b", frozenset({"g"}))]
|
|
with pytest.raises(FoldError, match="in a and b"):
|
|
assert_disjoint(split, twice)
|