Repository navigation
feat(delivery): the no-collapse invariant — draws.py (ADR-013 §6) - #98
Merged
Merged
Conversation
The policy boundary named by views-models#149 and adopted in ADR-013: a sampled forecast must still be draws when it ships. assert_draws_uncollapsed raises DrawsCollapseError unless (1) the payload is 2-D (N,S); (2) payload S equals the header-declared sample_count; (3) sample_count >= the config-declared s_min (2 for the walking skeleton); (4) globally at least one row carries >1 distinct draw value — per-row zero variance is explicitly legal (zero-conflict cells dominate PGM), only an all-rows-degenerate payload fails (a collapsed forecast wearing a sampled header). House invariant style: representation-free (no pandas — design-contract test auto-covers it), declare-don't-guess (sample_count/s_min are declared by the caller from header/config, never inferred), fail loud naming expected vs found. NaN rows count as varied by design (documented + pinned): NaN payloads are the null gates' job. Wiring into the delivery path lands with the sink-adapter leg (#91) per the contract; this story is the invariant + tests. 10 tests incl. the PGM zero-inflation non-rule and the skeleton floor (S=2). ruff clean; 142 passed, 43 xfailed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first build leg of the adopted wire contract (ADR-013 §6) — the policy boundary views-models#149 asked to have named and owned: views-postprocessing owns it, and this is it.
delivery/draws.py—assert_draws_uncollapsed(values, sample_count, *, s_min, label)raisesDrawsCollapseErrorunless:(N, S);sample_count;sample_count >= s_min(config-declared; 2 for the walking skeleton);House invariant style: representation-free (pandas-free, auto-covered by the design-contract test), declare-don't-guess (nothing inferred from the payload), fail loud with expected-vs-found. NaN rows count as varied by design (documented + pinned — NaN is the null gates' job). Wiring into the live path lands with the #91 sink-adapter leg per the contract.
10 tests incl. the zero-inflation non-rule, the skeleton floor, header/payload mismatch naming both values. ruff clean; 142 passed, 43 xfailed.
Refs: ADR-013 §6, views-models#149 (adoption comment), #45.