Repository navigation
draws.py: the docstring lied about S, and the code lied about empty payloads - #329
Conversation
The module docstring claimed FAO receives ``(N, S≈1024)`` draws per cell. That was a design target stated as delivered fact, and it named the wrong consumer: ADR-013 §6's gate is partner-neutral and has run for CRAF'd as well as FAO since #153. Rather than correct the number, remove it. The delivered width is a property of the run, declared in the §2 header and floored per product by ``S_MIN``; a value written into this docstring is a third copy of a fact with two homes, and it is the copy nothing checks. It had already drifted once. Measured today: the staged chrome_box wire's headers declare ``sample_count = 1024`` in all 108 shards, with ``num_rows / 64,742 = 1,024`` — one ensemble's pooled width, not a constant. ``docs/ADRs/013`` §74 is left alone: it says production *aims* at S≈1024, which is true as an aim. The docstring's error was restating an aim as a measurement. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9
Review of the previous commit caught that it asserted the floor has exactly two declared homes while check 3's own description, unchanged in the same docstring, named a third: "the consumer-facing floor (2 for the walking skeleton; region-pinned for production)". Measured: nothing region-pins the draw width. Neither product module mentions ``region`` at all, and ``delivery/coverage.py`` pins cell counts, not sample widths. The floor is a plain per-product constant. So the fix for one stale copy of a fact shipped beside another stale copy of the same fact. Also tightened the paragraph the previous commit added: it said the header and ``S_MIN`` were "its two homes", eliding that the header declares the width while ``S_MIN`` declares the floor — two facts, not one with two homes, which is the distinction the paragraph exists to draw. ruff clean; 41 passed on -k "draws or collapse or doc_accuracy". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9
… is not a verdict
The docstring work on this branch asserted that check 4 fails "only [when]
*every* row is draw-degenerate". For an empty payload the code did not honour
that, so fixing the prose without fixing the code would have left the file
self-contradictory in a new way. Both found by /code-review max's sweep.
**Empty payload, misdiagnosed.** `np.any(arr != arr[:, :1], axis=1).any()` over
zero rows is False, so the degeneracy branch fired. Measured before the fix:
(0, 8) -> "every one of the 0 rows is draw-degenerate (all 8 draws
identical per row)"
(3, 0) -> "every one of the 3 rows is draw-degenerate (all 0 draws
identical per row)"
Vacuously true, and it pointed the reader at the summarizer and the ADR-013 §6
contract when the real fault was a target that resolved to no rows — which would
have delivered zero cells to a partner. Now refused as what it is, naming the
resolution step upstream. (The `(3, 0)` shape is unreachable in production:
check 2 or check 3 catches a zero width first, since S_MIN is 2.)
**Ragged input, mislabelled.** `np.asarray([[1,2],[3]])` raises numpy's bare
`ValueError`, and because `DrawsCollapseError` subclasses `ValueError` a caller
catching the narrow type missed it while a caller catching `ValueError` blamed
the §6 policy gate for malformed input. Now wrapped, saying that nothing about
the draws has been checked.
Both refusals are documented as sitting **outside** §6's four rules, because in
both cases there is no payload to judge. The four-rule numbering is deliberately
left intact: ADR-013 counts four, and renumbering would widen the drift that
review finding (c) already records.
ruff clean; tests/test_draws.py 12 passed; full suite 529 passed, 3 skipped,
41 xfailed, 0 failed (excluding the untracked stub, which is in no commit).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9
Scope changed: this PR is no longer docs-only
PR retitled accordingly. Added in
|
…verclaim /falsify, claim mode, on "ready to merge": FALSIFIED by the prose added in 2190bd6. It said the two new refusals mean "the Raises contract below holds for every input". Measured: s_min=None -> TypeError (escapes DrawsCollapseError) s_min="2" -> TypeError (escapes DrawsCollapseError) Both from check 3's `sample_count < s_min`. Since DrawsCollapseError subclasses ValueError, neither is catchable as a draws failure, so "every input" was false on the third probe that looked for it. Narrowed to what was measured: no *payload* can now reach a caller as a bare ValueError, and the declared ints remain unenforced — stated explicitly, with the reason it is tolerable (sink.py passes a product constant) rather than left for the next reader to discover. This is the third stale or overstated claim in this one docstring, and the second one introduced while fixing the previous. Recorded in the commit rather than the prose, because the file does not need a changelog of its own prose. ruff clean; full suite 529 passed, 3 skipped, 41 xfailed, 0 failed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9
What
views_postprocessing/delivery/draws.py's module docstring claimed that FAO receives the full posterior mixture —(N, S≈1024)draws per cell. Two things wrong in one sentence:S≈1024is ADR-015's aspiration on the produced count, not a width any FAO delivery has carried.sink.deliver_runtakess_minandconsumer_nameas parameters and reaches for neither partner's facts.Why remove the number rather than correct it
The delivered width is a property of the run. It is declared in the §2 header and floored per product by
S_MIN— those are its two homes. A value written into this docstring is a third copy of a fact nothing checks, and it is the copy that had already drifted.Correcting
1024to a current number would reintroduce exactly the thing that failed: ADR-015 expects the width to move upward (512–1024 per constituent), so any number written here is scheduled to go stale. The docstring now says whatSis — header-declared, pooled across the ensemble's members, differing per ensemble — and points at where to read it.This follows the repo's one-home-per-fact rule: reasoning lives in the register, docstrings point at it, and declarations are the authority.
Evidence
Measured this turn, from the staged chrome_box wire:
sample_count = 1024in all 108 shard headers, one distinct valuenum_rows / 64,742 = 1,024on first and last shard{"ensemble": "chrome_box", "pipeline_core_version": "3.4.0", "reconciled": true}So 1,024 is one ensemble's pooled width, not a constant — which is the point.
Deliberately not changed
docs/ADRs/013_sampled_forecast_wire_contract.md:74reads "Production aims at S≈1024." That is true as an aim and stays. The docstring's error was restating an aim as a measurement, not the aim itself.Verification
ruff check views_postprocessing/delivery/draws.py— all checks passedpytest -k "draws or collapse"— 11 passed, 0 failed1024literals intests/test_draws.py:44-46andtests/test_track_a_source.py:105-106are fixtures for a header-declares-1024-vs-payload-mismatch case, untouched by this change.Docstring only — no behaviour change.
🤖 Generated with Claude Code
https://claude.ai/code/session_01ANY1CCy9Xo7zjMY4XJ69v9