Skip to content

Do not draw the mean-precision rule beyond 100x the acquired objects (fixes #646) - #654

Merged
guijacquemet merged 2 commits into
mainfrom
claude/rule-draw-limit
Nov 28, 2026
Merged

guijacquemet merged 2 commits into
mainfrom
claude/rule-draw-limit

Conversation

@guijacquemet

Copy link
Copy Markdown
Contributor

Fixes #646. Refs #501. Follows #653 (the chunked draws, identical outputs, merged), which this builds on.

What

When the mean-precision rule asks for more than RULE_DRAW_LIMIT (100, set by the owner on 2026-11-28) times the objects a group acquired, that group and target's row of object_rule_check is not assessable and no whole fields are drawn:

not assessable: the rule asks for 11349387 cells, 1134938.7 times the 10 acquired (more than 100 times), so whole fields were not drawn

The ratio is rounded up to one decimal, so it never reads as the limit itself. The row goes through the existing "not assessable" path: a ⚠️ line in the summary, like the zero-reference and too-few-fields rows. At the limit itself the draws still run. Every other row, and every row of other groups and targets, is drawn exactly as before (each group and target has its own seeded generator).

The draws move from object_rules.py, which was at 584 lines out of the 600 allowed, into a new private module sampling_unit/_whole_field_draws.py (fovs_until, beyond_draw_limit, RULE_DRAW_LIMIT), listed in AGENTS.md section 7.

Why

The v27 export with a DrugA field raised by 100: the control mean of repeat rep1 is 0.25, so the rule asks for 11 and 45 million cells (targets 5% and 2.5%), drawn 4,000 times each. That took more than 15 minutes, linear in n, with no message. The same object_rule_check now returns in well under a second.

Tests (tests/test_object_rules.py)

  • test_the_rule_is_drawn_up_to_the_limit_and_not_beyond[-1, 0, 1]: the limit, just below it and just above it; the exact message above it.
  • test_an_outlier_field_over_a_small_control_mean_is_not_drawn_for_minutes: the v27 outlier case. Both DrugA rep1 targets are skipped with numbers above the limit, every drawn row is within it, and the call finishes under a 30 s bound (it took more than 15 minutes before).
  • The bit-identical test of A still passes on the moved fovs_until.

Local gate (on 81f574b)

pytest -n 0 tests/test_guards.py tests/test_function_guards.py tests/test_function_tools.py tests/test_object_rules.py tests/test_reference.py
164 passed, 1 warning in 103.82s
python tools/audit.py --check-against origin/main
baselines only tightened against origin/main

Also run: ruff check and ruff format --check on src tests data (clean), and tests/test_contracts.py and tests/test_docs.py with the guards on the previous commit of this branch (944 passed).

Reference check: 0 differences

data/reference/reference.py run on this branch (--parallel 2 --skip idr, 55 jobs, all exit 0), compared with the origin/main run of #653 using the fixed comparer: 0 differences. No group in the repository's data reaches the limit, so outputs change only where the rule asks for more than 100 times the objects acquired. The IDR job was skipped because it uses every CPU.

Not run: the whole suite (pytest on every CPU). It waits until another session's large end-to-end job on this machine has finished.

🤖 Generated with Claude Code

guijacquemet and others added 2 commits November 28, 2026 21:14
…(646)

When the rule asks for more than RULE_DRAW_LIMIT (100) times the objects a group
acquired, the row is not assessable, with the numbers said ("the rule asks for N
cells, X times the M acquired"), and no whole fields are drawn. On the v27 export a
DrugA field raised by 100 over a control mean of 0.25 asked for 11 and 45 million
cells and drew them for more than 15 minutes; it now takes under a second. Rows at
or below the limit are drawn exactly as before.

The draws move to their own private module, _whole_field_draws, since object_rules
was near the 600-line limit. Tests at, just below and just above the limit, and on
the v27 outlier with a time bound.

Fixes 646. Refs 501.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@guijacquemet
guijacquemet merged commit 1b9bc00 into main Nov 28, 2026
2 checks passed
@guijacquemet
guijacquemet deleted the claude/rule-draw-limit branch November 28, 2026 19:24
@guijacquemet

Copy link
Copy Markdown
Contributor Author

Whole suite run locally after merge, on main at 1b9bc00, which includes #653 and #654: pytest -n 4 (4 workers, one BLAS thread each, nice), 13 min 45 s.

1 failed, 4816 passed, 2 skipped, 6 xfailed, 42 warnings in 825.09s
FAILED tests/test_duplicates_tool.py::test_a_pass_that_cannot_run_is_skipped_with_its_reason

The one failure has nothing to do with these changes. It is about the machine: npx (Node.js) is not installed, so jscpd_review reports skipped: npx not found, while the test expects the message for a model that has not been downloaded. It fails the same way on main before both PRs (9fa2402). Neither PR touches tools/ or the duplicates test.

GitHub Actions also ran on both PRs: check and spec-pin pass on #653 and on #654.

🤖 Generated with Claude Code

@guijacquemet

Copy link
Copy Markdown
Contributor Author

Definitive timing (quiet machine, 2026-11-29)

One process pinned to one core, OMP_NUM_THREADS=1, NumPy 2.5.5, run one after another. Load average was under 1 at the start; it reached 4 near the end of the run (on a 20-core machine).

object_rule_check on the 646 case (v27, a DrugA rep1 field raised by 100, control CTRL; 16 rows):

code commit time largest rule_objects
before 9fa2402 1976 s (32.9 min) 45,397,547
chunked draws, identical outputs (#653) a4d1e11 1137 s (18.9 min), 1.74× 45,397,547
draw limit at 100× (#654), current main 5c5f582 0.39 s 214

Draw helper alone, best of 5 (5 fields of 2 objects, one outlier sum):

n before (ms/draw) after (ms/draw) speed-up
100,000 0.81 0.39 2.10×
1,000,000 7.77 3.53 2.20×
25,000,000 203.6 111.7 1.82×

The identical-output change alone takes the 646 case from 33 to 19 minutes. The draw limit is what brings it down to under half a second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

report runs >15 min in object_rules._fovs_until when one field is an outlier

1 participant