Skip to content

feat(rung4): the boost target — extra samples of a high-noise row's regret, every source below it sampled k of n or enumerated, each unbiased against the exact sum kept as EXACT, the arrival always exact - #89

Merged
AlecROndo merged 11 commits into
mainfrom
AlecROndo/canary-handoff-pr-1-build
Nov 9, 2026

Conversation

@AlecROndo

@AlecROndo AlecROndo commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

PR 1 of the targeted-sampling plan for rung 4. It began as the exact target and is now a sampling framework, with the exact sum kept as its oracle. At a chosen high-noise row it draws extra, lower-noise samples of the same regret the walk banks there, and each sample is unbiased. Nothing consumes it yet; the boost stage is PR 4.

What it is

minidrawmaha/solver/boost_target.py (renamed from exact_target.py; ExactTargets → BoostTargets).

boost = BoostTargets.build()
sigma = boost.sigma(table)
regret, arrival = boost.targets(sigma, seat=0, rows=rows, sampling=Sampling(), seed=seed, t=t)
regret, arrival = boost.targets(sigma, seat=0, rows=rows, sampling=EXACT)      # the oracle

A play-out starts at the row and faces the opponent's range, back-solved exactly from the rules. It then plays the hand out. Sampling names how much of each random source below the row it takes; None takes all of it:

field default sampled form why it stays unbiased
playouts 1 M independent play-outs, averaged mean of unbiased estimates
opponent_range None (whole range) k hands per physical entry, ∝ weight, among those sharing no card with the entry each hand carries 1/k of the entry's total
board_cards 1 k of the 14 second-board cards, without replacement each kept branch scaled 14/k
opponent_draws 1 k of 12 replacements per opponent hand scaled 12/k
hero_draws 1 k of 12 replacements per hero hand, per throw scaled 12/k; the throws themselves are all walked
opponent_actions 1 k actions per opponent state drawn from σ 1/k each, so an action's expected share is σ(a)
  • The defaults are the walk's own sampling below the row, against the whole opponent range. EXACT enumerates everything.
  • A chance count at or above its fan is enumeration. A Sampling that draws nothing, however it is spelled, counts as exact: it needs no seed and refuses playouts > 1.
  • The traverser's own actions are never sampled, as in the walk.
  • The arrival is always exact. It is the cheap upward half. An exact denominator under an unbiased numerator keeps the regret unbiased, and a sampled denominator would not.
  • Row r draws from default_rng([seed, t, seat, r, "BOOST"]). That stream is separate from the walk's and the reservoir's, and a row's target never depends on which rows share the call.

The exact path (EXACT) is the code that was here before, with one seam threaded through it. It reproduces the pre-change output bit for bit. I checked this against the previous module, run side by side and not committed: 50 draw and round-2 rows on one table, and 32 round-1 rows on two tables, both seats each time. One change touches the exact path: an opponent line that carries no weight is skipped. Its value is zero, so the output is unchanged.

Measured (this Mac, a table with every action positive)

row exact Sampling()
round 2 ~2 ms 3–4 ms
draw 160–230 ms 25–32 ms
round 1 0.5–0.75 s 100–130 ms

The board card and the hero's replacements are what sampling cuts. Against a whole range, sampling the opponent's actions saves nothing: splitting by σ is one array operation. It only adds noise and a little time, so it pays only when opponent_range is a few hands. Sampling(opponent_actions=None) is the cheaper and quieter choice with the whole range.

Tests (tests/minidrawmaha/test_boost_target.py)

All of PR 1's exact tests are kept, now run with sampling=EXACT:

  • the reach equals the grader's to 1e-10
  • the arrival equals the grader's frequency
  • the world-by-world oracle to 1e-9
  • the 6,000-walk sampled comparison
  • refusals, the unreachable row, the import check

New tests:

  • Bad counts are refused by name: 0, negative, bool, float, and playouts > 1 under EXACT. So is a sampled call without seed/t, and a sampling that is not a Sampling.
  • A count at or above its fan equals EXACT bit for bit, at a draw row and a round-1 row.
  • Every n/k scale is pinned with no noise. Each chance source (board card, either seat's replacements) is kept one branch at a time; the average over its branches must equal the exact sum to 1e-10. This runs in the full game and in a restricted one where a key's two physical entries differ. A scale off by one branch in twelve fails it.
  • The range draw is unbiased where a key's two entries face wide and different ranges, before and after a throw. The restricted game is set up so the suit relabelling maps the opponent's allowed hands onto their complement.
  • Every sampled form is unbiased. Each source alone at a row where it is live (both seats for hero draws), the walk's sampling, everything at k = 1, and everything at k = 2 with two play-outs. Each case runs 60–400 seeds; the mean must sit within 4.5 s.e. of the exact regret in every moving column. The test also asserts that the source actually moved the target (not vacuous), that unmoved columns equal the exact ones, and that the arrival equals arrivals() exactly. A mutation check (not committed) confirmed the gates bite. Dropping any n/k scale, the playouts division or σ's 1/k fails them, as does a 10% bias in the range draw, an n−1 in place of any n, or one entry's total used for another's. The seed counts' resolving power (3–8% for actions, range and the opponent's draws) is stated beside them. The hero's draws, the board card and the mixed forms resolve only 13% and up statistically; that is why their scales are pinned by the exact branch check instead.
  • A row's sample depends on (seed, t, seat, row) only: reversed, split, or duplicated rows give the same values, and a new t gives new ones.
  • playouts = 8 shrinks the variance by a factor in (1/16, 1/4).
  • An unreachable row is zero under range sampling.
  • Cost: the three costs are printed on every run; the sampled draw and round-1 rows must cost under half their exact sum.

uv run pytest: 1,705 passed, 22 skipped at b53f2a3. The test file and the instruction-file check were re-run at b4ee6e4: 74 passed, 2 skipped.

Not in this PR

The implementation plan is docs/superpowers/plans/2026-11-06-boost-target-modular-sampling.md.

…every opponent hand and every physical entry of its key, and the walk's arrival rate, from the rules alone

PR 1 of the targeted-sampling plan. `minidrawmaha/solver/exact_target.py`
computes, for any table row, the regret the walk's samples there estimate
(the mean over the opponent's hands of u − ⟨σ, u⟩, weighted by the deck and
the opponent's own play, normalised by the arrival) and the probability one
walk visits the row. It re-derives the public tree, key maps, draw maps and
showdown from rules/ and never imports the grader, which grades what this
will feed.

Measured: a round-2 row costs 0.8 ms, the arrival alone 0.3 ms; a draw row
45–85 ms and a round-1 row 0.2–0.6 s, because the value below expands over
the traverser's own replacements and the second board card.

Tests: the back-solved reach equals the grader's carried vector on every
board of every point (1e-10, full and restricted deals); arrival at a seat's
first decision is the grader's frequency and sums to one; regret and
arrival equal a world-by-world walk through MiniState on a small restricted
game (1e-9) and the mean and visit count of 6,000 Collector walks row by
row within 4 s.e. and pooled; the module's import block holds no grader.
@vercel

vercel Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
drawmaha-solver Ready Ready Preview Nov 6, 2026 10:21am UTC

Request Review

@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 1m 15s —— View job


Review of PR #89: exact target (exact_target.py)

I read exact_target.py in full and re-derived the main identities by hand. I did not run the test suite (80 s test), and I only skimmed the test file. Nothing below is a confirmed bug. The math I could check holds up.

Re-derived and found correct

  • Deal weights. 455 × C(12,3) = 100,100 deals. Seat 0 carries 1/pairs and seat 1 carries 1, so deal_h · reach_o is 1/pairs for either traverser.
  • Post-draw deal factor. _own_deal sums over kept + thrown for each possible drawn card. These are three distinct pre-draw holes, and thrown ∈ hole is skipped.
  • Replacement probability. The 1/|stub| is applied once, to the opponent's carried vector at the chance node, and hero's 12-way fan is summed unweighted. This is consistent in both _reach and _value.
  • Showdown share. ¼(2 + sign_inner + sign_outer) equals ½·win_inner + ½·win_outer with ties at ½. The net is pot·share − committed[hero]·compat, and the fold branch uses the loser's stake. Both are right.
  • Compat fold. Per-hole totals minus the slots that threw a card hero holds. holds includes hero's thrown card, so the disjointness test is complete.
  • Grader independence. The imports are rules/ and PackedTable only, with no exploitability.py.

Findings

# Sev Conf Where Issue
1 Low Medium module docstring, "Cost" section The memo bound "29 × 15 + 20 × 210 = 4,635 vectors, ~270 MB" is stated as a hard cap. _reach memoises on node.level <= 1 or (parent is CHANCE and deals_board). That covers every level-0/1 node: the chance nodes after throws and the board-deal chance node as well as the 29 decision points. The count is therefore an under-count. The measured 260 MB peak is real, but the "at most" claim is not derived from the code. Either count nodes or say "about". Per AGENTS.md ("a wrong claim in a docstring is a bug"), this should be fixed in this PR. The 260 MB figure is also untested, unlike the timing.
2 Low High _reach (root), reach() _reach returns self.weight[carried] and the memoised arrays themselves, with no copy. reach() is public, and the memo is per call, so mutation can't leak across calls. A caller who does r *= … on a result from a shallow point would still corrupt shared state for that call. This is cheap to guard with setflags(write=False).
3 Low Medium test_exact_target.py (sampled test) The pooled mean of z² is accepted in (0.4, 2.0). If the exact target is right, the mean sits near 1. A window this wide would pass an s.e. that is off by ~1.4× either way, but the means are what matter. Please justify the window (for example, a rough sd of the pooled statistic over the number of rows) or tighten it. The 4 s.e. per-row check with only 40+ visits uses a plug-in s.e. from a heavy-tailed sample, so a rare per-row flake is possible. I can't see a seed-stability argument from the PR text.
4 Low Medium module docstring, "regret is the conditional mean of the banked sample given a visit" This is exact only for rows visited at most once per walk. AGENTS.md notes that about 1 in 1000 traversals banks a row twice. The targets() docstring mentions this for arrival but the module-level statement does not. A short caveat would keep the claim strictly true.
5 Low High docstring ("the plan rules out", "the plan's §3") The plan is not in the repo, and the docstring gives no path. AGENTS.md says the design record should be in docstrings, so a reader of exact_target.py can't follow this pointer. Please name the spec file under docs/superpowers/ or inline the one-line reason.
6 Info Medium _weights Duplicate holes in holes= are silently de-duplicated by the set. That is harmless, but a restricted-deal set that is not size-checked (for example a hole of the wrong length) is caught only via unknown. This looks fine as-is.
7 Info Low scope arrivals(), reach() and entries_of() are public API with no consumer in this PR (PR 3 is named in the description). They are tested, so I'm not flagging them, but remove anything unused if PR 3 changes shape.

Tests

Coverage is strong for a first PR: (a) the reach against the grader to 1e-10, an exact world-by-world oracle on a restricted deal with two non-closed suit relabellings, a sampled test, and refusals. The default suite stays free of torch, Modal and network, as AGENTS.md requires. I'd still ask that the author paste the uv run pytest tests/minidrawmaha/test_exact_target.py output after any fix for #1 and #3.

…, 5,190 vectors, re-derived by a test; the sampled tests select rows by expected count, so a row cannot enter because it fluctuated high

Review follow-ups on #89. The docstring counted the memo's level-1 points
alone (29) where the chance nodes on the paths are memoised too (66 in
all); the test now walks the ancestor closure and pins 66, 20 and 5,190.
`reach()` hands out a copy. The pooled z² windows are a 4-sd band on the
chi-square mean, √(2/n), instead of fixed numbers. The gated 200,000-walk
test kept rows by observed count ≥ 100, which let seat 1's draw rows in
only when they had fluctuated high (mean z +1.8 on two seeds); rows are
now kept by expected count ≥ 80 against an observed cutoff of 40, and
both seats read mean z within 0.01 of zero over thousands of rows. The
module docstring names the double-visit caveat and no longer points at a
plan outside the repo without saying where it is.
@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 28s —— View job


Re-review of PR #89 after 8ed5c32

I read the new commit's diff to exact_target.py. I did not run the test suite, and I did not re-read the test changes in full.

Earlier findings, status

Remaining nits (Low)

  • The docstring's Cost paragraph runs two sentences together on one overlong line (...about 260 MB. \tests/minidrawmaha/test_exact_target.py` prints the`). This is cosmetic only.
  • The memo comment says the 66 nodes are on "the path to a decision", but the code memoises every node.level <= 1 node it visits. The test pins the count, so the two agree today. If the tree changes, the comment and the test would be the places that drift.
  • Info: the 302 MB bound is a computed cap. Only the 260 MB peak was measured. This is fine as written.

I found no new correctness problems in the changes since the last review.

… the mean of z², and cap a single row at six standard errors — the deal alone dealt one picture 292 times against 220 at seed 12

The pooled mean is the sharp bias test (a tenth of a standard error in
every row is caught at 1,600 rows); the per-row cap is loose because of
about 3,000 rows one passes 5 in a run out of a thousand, and the deal
itself did it at seed 12 in a count that involves nothing of this module.
Run with MINIDRAWMAHA_FULL_TARGET=1: both seats pass.
@AlecROndo

Copy link
Copy Markdown
Owner Author

Disposition of the review's findings, after 8ed5c32 and the commit above.

# Finding Done
1 Memo bound under-counted (29 points; the level-1 chance nodes are memoised too) Fixed. The bound is now the ancestor closure: 66 level-1 nodes (29 decisions, 37 chance nodes) × 15 boards + 20 round-2 opening decisions × 210 = 5,190 vectors, 302 MB. test_build_is_one_object_per_deal_set_over_a_shared_description walks the closure from the tree and pins 66, 29, 20 and 5,190, so the docstring and the code cannot drift apart silently.
2 reach() returned the deal-weight array itself Fixed: it returns a copy.
3 z² window unjustified; per-row plug-in s.e. flake risk The pooled tests are now derived bands: mean of z within 4/√n of 0 and mean of z² within 4√(2/n) of 1. The per-row check stays at 4 s.e. for the regret means (40+ samples) and is 6 s.e. for visit counts in the gated test, with the reason in a comment. Rows are also now selected by expected count (≥ 80 against an observed cutoff of 40), which is the real fix: selecting on observed count let seat 1's draw rows in only when they had fluctuated high (mean z +1.8 on two seeds); with fair selection both seats read a mean z within 0.01 of zero over 2,800 and 3,800 rows.
4 Double-visit caveat missing from the module docstring Added: arrival is expected visits per walk; regret the mean banked sample per visit.
5 Docstring pointed at a plan outside the repo without saying where It now gives the reason inline and says where the plan lives, as AGENTS.md does for the rung-3 plan.
6 holes= de-duplicates silently Working as intended; a hole of the wrong length is refused by name.
7 arrivals(), reach(), entries_of() have no consumer yet Kept: PR 3 draws by arrivals, PR 4 uses targets; reach and entries_of are what the tests check against the grader.

Re-review nits: the long docstring line and the "path to a decision" wording describe the same closure the test pins; left as is.

One finding of my own while running the gated test. At seed 12, seat 1's picture 3c 3d 4h with 2c on the board (six relabellings) was dealt 292 times in 200,000 walks against an expected 220, 4.9 standard errors, in a count that involves no σ and nothing of this module (221, 219, 222 on three other seeds). The exact arrival for that row equals a direct enumeration of every deal and board through MiniState (5.391e-4, both), and across all 970 rows of the point the walks and the module agree (99,771 visits against 99,721 expected, mean z 0.005). It is a tail event in the sampler; the test's per-row cap is set so it does not read as one of ours.

Test output after the fixes:

uv run pytest tests/minidrawmaha/test_exact_target.py -q
15 passed, 2 skipped in 133.34s

MINIDRAWMAHA_FULL_TARGET=1 uv run pytest tests/minidrawmaha/test_exact_target.py -q -k "two_hundred or sampled"
3 passed, 14 deselected in 410.42s

uv run pytest -q   (before the test-only follow-ups)
1673 passed, 22 skipped in 587.13s

@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 38s —— View job


Re-review of PR #89 after 0712aa1

I read the diff of the latest commit, which only touches tests/minidrawmaha/test_exact_target.py. I did not run the suite, including the MINIDRAWMAHA_FULL_TARGET=1 run the commit message cites.

What changed: the sampled tests and the 200k-walk test now also pin |mean(z)| < 4/√n. The per-row cap on the 200k-walk test goes from 5 to 6.

Checked and correct

  • Pooled mean of z is a good bias test. It is sharper than the z² band, because z² only sees a bias at second order.
  • The odds in the comment hold. P(|z|>5) is about 5.7e-7 per row, so about 1.7e-3 over 3,000 rows. P(|z|>6) is about 2e-9, which is negligible.
  • (292 − 220)/√220 ≈ 4.85, which matches the "4.9 standard errors" in the comment.

Remaining nits (all Low)

  1. Overclaim in the comment (confidence High). "A bias of a tenth of a standard error in every row is caught at n ≈ 1,600." At n = 1,600 the band is 4/√1600 = 0.1, so a 0.1 bias sits exactly on the threshold and is caught about half the time. Say "n ≈ 1,600 is where it reaches the band, and about 3,000 rows catch it reliably", or change the number.
  2. Independence assumption in the pooled bands (confidence Medium).
    • The 1/√n and √(2/n) widths assume the z's are independent across rows.
    • In the sampled regret test, rows on one path share the same walks. Their z's are probably positively correlated, so the real sd of the mean is larger than 1/√n, and 4 sd may be less than 4 real sd.
    • In the arrival test, counts across rows are negatively correlated (they come from one multinomial-like process), so the band is conservative.
    • The seeds are fixed, so this will not flake in CI. Say so in the comment, or the "4-sd" claim reads as stronger than it is.
  3. Heavy tails for z² (confidence Medium, carried over from earlier). z uses a plug-in s.e., and with 40+ visits it is not exactly normal. The √(2/n) band for z² assumes normal z. Kurtosis inflates the sd of z², so the z² band is tighter than "4 sd" suggests. The fixed seed hides this. Point out in the comment that the thresholds were checked at the seeds used and are not distributional guarantees.
  4. Duplicated assertions (confidence Low). The same two pooled asserts now appear in both the sampled test and the 200k-walk test. A small helper such as _assert_pooled(z) would remove the drift risk when the bands change again.

Overall: I found no correctness problems in exact_target.py or its tests. Earlier findings #1–#5 from the first review remain resolved as noted in the second.
· branch AlecROndo/canary-handoff-pr-1-build

…e band's assumptions written beside it — the "caught at 1,600 rows" line was a half-truth; the band is reached there and reliable at about 3,000
@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 19s —— View job


Re-review of PR #89 after 918a76c

I read the diff of this commit, which touches only tests/minidrawmaha/test_exact_target.py. I did not run the suite, and I did not run the MINIDRAWMAHA_FULL_TARGET=1 test.

Earlier nits, status

  • Overclaim about n ≈ 1,600: fixed. The helper docstring now says the band is reached at about 1,600 rows and caught reliably by about 3,000. At n = 1,600 the band is 4/√1600 = 0.1, so a 0.1 bias sits right on the threshold. The new wording is accurate.
  • Independence assumption: fixed. The docstring says rows on one path share walks, which narrows the regret band, and that visit counts over rows come from one multinomial, which makes that band conservative.
  • Heavy tails and fixed seeds: fixed. The docstring says the plug-in s.e. gives heavier tails, and that the thresholds are a calibrated regression gate, not a distributional guarantee.
  • Duplicated pooled asserts: fixed. assert_pooled_fair is now shared by the sampled test and the 200k-walk test.

Remaining nits (all Low)

  1. Unverifiable claim (confidence Medium). The docstring says the thresholds were "checked at those seeds and on several others". The PR text only gives seed-12 and three other seeds for the arrival count, and mean z within 0.01 of zero on two seeds for the selection fix. Naming the seeds checked would make the claim auditable.
  2. Helper placement (confidence Low). assert_pooled_fair sits directly after rows_at with a single blank line before the next section banner. This is cosmetic.
  3. Inline comment at the helper's call site (confidence Low). # (−1.3, 1.3) and (0.4, 1.6) at n = 10 is correct: 4/√10 ≈ 1.26 and 4·√0.2 ≈ 1.79, so the z² band is (−0.79, 2.79), not (0.4, 1.6).
    • The second pair is wrong for the helper as written. The old comment's (0.4, 1.6) corresponds to 4·√(2/n) only at n ≈ 44. At n = 10 the z² band is 1 ± 1.79, which means 0 < mean(z²) < 2.79, so the lower bound is vacuous.
    • Per AGENTS.md, a wrong number in a comment is a bug. Please correct it to (−1.26, 1.26) and (−0.79, 2.79), or drop it.
    • The consequence is small: at n ≥ 8 the z² check is nearly toothless on the low side, but the real runs use n in the thousands.

Overall: I found no correctness problems in exact_target.py or the tests. All earlier findings are resolved except the comment arithmetic above.
· branch AlecROndo/canary-handoff-pr-1-build

…9 at n = 10, biting from n ≈ 45 — and the arrival seeds checked named
@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 11s —— View job


Re-review of PR #89 after 30b7951

I read the diff of this commit, which touches only a docstring and one comment in tests/minidrawmaha/test_exact_target.py. I did not run the suite.

Earlier nits, status

  • Wrong (−1.3, 1.3) and (0.4, 1.6) at n = 10 comment: fixed by deleting it. The docstring now says the z² band is 1 ± 1.79 at n = 10. 4·√(2/10) = 1.79, which is correct.
  • Unnamed seeds: fixed. The docstring names seed 12 for both seats and seeds 13–19 for seat 1.

Remaining nit (Low, confidence High)

  • The docstring says the z² low side "bites only from n ≈ 45 (1 ± 0.84)". The 0.84 figure is right for n = 45: 4·√(2/45) = 0.843. The low side actually starts to bite when the half-width drops below 1, because mean z² is never negative. That happens at 4·√(2/n) < 1, so n > 32. Write "from n ≈ 33" or "by n = 45 the band is 1 ± 0.84".
  • This changes nothing in practice, since the real runs use n in the thousands.

Overall: I found no correctness problems in exact_target.py or its tests. All earlier findings from the four previous reviews are resolved except the n ≈ 45 versus n > 32 wording above.
· branch AlecROndo/canary-handoff-pr-1-build

@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 9s —— View job


Re-review of PR #89 after 23cd464

I read the diff of this commit. It changes one docstring in tests/minidrawmaha/test_exact_target.py (assert_pooled_fair). I did not run the suite.

Previous nit, status

  • z² low side "from n ≈ 45": fixed. The half-width is 4·√(2/n). At n = 32 it is exactly 1.0, so the lower bound is 0 and the check is vacuous. At n = 33 it is 4·√(2/33) ≈ 0.985, so the lower bound is positive. "From n = 33 (1 ± 0.98)" is therefore correct. The n = 45 figure of 1 ± 0.84 also checks out (4·√(2/45) ≈ 0.843). One rounding quibble: 0.985 prints as 0.98 or 0.99 depending on convention, which does not matter.

Remaining findings: none. The docstring is the only change, and it is now arithmetically correct. exact_target.py is untouched since the last review.

Overall: I found no correctness, test or pedagogy problems in the latest commit. All findings from the earlier reviews are resolved.
· branch AlecROndo/canary-handoff-pr-1-build

…high-noise row — board card, both seats' replacements, the opponent's actions and range — each unbiased against the exact sum, which stays as EXACT, with the arrival always exact and one stream per (seed, t, seat, row)

exact_target.py becomes boost_target.py (ExactTargets → BoostTargets). targets()
takes a required Sampling; EXACT reproduces the previous output bit for bit.
… one branch at a time, averaged, is the exact sum to 1e-10 — and the range draw is tested where a key's two entries face different ranges; the stream's tail is two words, not one, and seed and t take any integer
@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 1m 33s —— View job


Review of PR #89 after b53f2a3 (exact target → boost target, Sampling)

I read boost_target.py in full, the plan, and the sampling half of test_boost_target.py. I did not run the suite or the gated tests, and I did not re-read the exact-target half of the tests, which earlier rounds covered. Nothing below is a confirmed bug in the math.

Re-derived and found correct

  • Chance fans. _action_values keeps k of 12 replacements per (board, hero state) and scales the throw's value by 12/k. _value keeps k of 14 board cards and scales spread by 14/k. _push scales opponent replacements by 12/k. Each is unbiased, because each branch survives with probability k/n.
  • Index alignment in _push. np.repeat(played[:, source], kept, axis=1).ravel() is hole-major then k, which matches targets.ravel(). The take_along_axis pick keeps that order.
  • Opponent actions. cdf[..., -1] = 1.0 plus rand < cdf with argmax gives P(a) = σ(a). Zero-probability columns can't be picked. One draw is shared across all edges of a node, which is correct.
  • Range draw. Drawing k states ∝ live and giving each W/k has expectation live. The clash matrix is built from holds, which includes the thrown card, so it matches _showdown's compat.
  • Exact denominator. The numerator is unbiased and the arrival is a constant, so the ratio is unbiased. The docstring's reason (a mean of ratios is not a ratio of means) is correct.
  • EXACT path. _EXACT_DRAWS never touches the RNG. The pushed.any() prune only drops terms that are exactly zero, since the value is linear in u.
  • Memo count. 66 × 15 + 20 × 210 = 5,190 vectors. At 7,280 × 8 = 58,240 bytes each that is 302 MB, as stated.

Findings

# Sev Conf Where Issue
1 Medium High PR title and body They still describe exact_target.py / ExactTargets, "Nothing else changes", and a cost table of 0.8 ms (round-2 row), 45–85 ms (draw row) and 0.2–0.6 s (round-1 row). The branch now renames to boost_target.py, adds Sampling, _Draws and per-row streams, and the module docstring gives 2 ms, 160–230 ms and 0.5–0.75 s. The plan's Task 4 step 3 already says to retitle and rewrite. Until then the PR text makes claims the code no longer matches (AGENTS.md: a wrong claim in README.md or a docstring is a bug; the PR body is the same kind of record).
2 Medium High test_boost_target.py, UNBIASED (~L725–755) For hero draws, opponent draws and board cards, the per-source unbiasedness test cannot detect a wrong scale factor, and the test file's own comment says so. It runs 60–200 seeds with a 4.5 s.e. gate, resolving a 13% to over-100% relative bias. The branch-by-branch oracle (test_a_chance_source_kept_one_branch_at_a_time…) pins those scale factors exactly, so coverage exists, but the plan's Task 3 step 1 asked for 400 seeds and assert_pooled_fair over the pooled z. The pooled check is not applied in this test, and it is the sharper bias test. Please apply it across the cases, or state in the test that these cases only check composition.
3 Low High Sampling.__post_init__ vs targets Sampling(board_cards=np.int64(1)) raises (isinstance(value, int)), while seed/t accept any numbers.Integral. Pick one rule.
4 Low High Sampling.__post_init__ / is_exact A call with every count at or above its fan, for example board_cards=14, opponent_draws=12, hero_draws=12 with opponent_actions=None, opponent_range=None, enumerates everything. It is not is_exact, so it demands seed/t and accepts playouts>1, which averages identical play-outs at M× the cost. The tests only pin it bit-for-bit at playouts=1. Either refuse it or document it.
5 Low Medium _STREAM_TAG comment (L192–196) "A row's stream has six words and can never equal a walk's four-word stream" holds only for seed, t, seat and row below 2³². The last commit says seed and t take any integer, and a larger one adds words. Say "for seed and t below 2³²", or drop "never".
6 Low Medium module docstring, Cost paragraph "Round-2 about 2 ms, draw row 160–230 ms, round-1 0.5–0.75 s, sampled 25–32 ms and 100–130 ms, sampled round-2 3–4 ms" are session measurements, not recomputed values. The benchmark prints them, and the only assertions are exact < 50 ms and a 2× ratio, skipped for round 2. Per the plan ("every number in it must be recomputed by a test or printed") they are printed, so this is acceptable. Note that the "costs more sampled than exact at round 2" claim has no assertion, so it can drift.
7 Info Medium _Draws.opponents The per-entry Python loop calls rng.choice over 7,280 states for each of up to 6 entries per play-out, with the p normalised each time. This is fine at k=1 on a few rows. If PR 3 boosts many rows per iteration it may dominate. A vectorised inverse-CDF draw would also remove the p-sums-to-1 tolerance dependency.
8 Info Medium _Draws.subset np.argsort(rng.random((*shape, n))) costs O(nb × 455 × 12 log 12) per edge and column for opponent draws. At nb = 210 that is about 1.1M uniforms per call. This is correct, and cheaper alternatives exist (a partial argpartition) if the cost table shows it.
9 Info Low plan doc The plan mixes design record (the Sampling fields, the review focus) with process steps (merging into the PR 2 branch, workspace bariloche's git pull). The latter will go stale at merge. Consider trimming them once #89 and #91 land.

Tests, in short

  • Strong:
    • the bit-for-bit enumeration test;
    • per-row stream independence (reversed order, split calls, duplicate row, t+1);
    • the unreachable-row case under range sampling;
    • the spread > 0 non-vacuity assertion;
    • the variance ratio window (1/16, 1/4) around the expected 1/8. Its window is wide for 200 seeds, but that is fine.
  • Weak: finding fix(deploy): add vercel python entrypoint serving a status page #2 above.
  • The new gates are justified in comments. I saw no loosened thresholds.

Overall: no correctness problems found in the sampling math or the seams. The PR text (#1) and the pooled-bias coverage (#2) are what I'd fix before merge.
· branch AlecROndo/canary-handoff-pr-1-build

@AlecROndo AlecROndo changed the title feat(rung4): the exact target — a row's sampled regret averaged over every opponent hand and every physical entry of its key, and the walk's arrival rate, from the rules alone feat(rung4): the boost target — extra samples of a high-noise row's regret, every source below it sampled k of n or enumerated, each unbiased against the exact sum kept as EXACT, the arrival always exact Nov 6, 2026
… — None, or a chance count at its fan — so it needs no seed and refuses extra play-outs; counts take any integer type, as seed and t do; the stream comment says when six words hold
@AlecROndo

Copy link
Copy Markdown
Owner Author

Addressed at b4ee6e4:

  1. PR text. The title and body are rewritten for the boost target, with the measured cost table.
  2. Pooled bias in UNBIASED. A pooled z² over the ≤ 4 columns of one case cannot resolve anything: its band at n = 4 is 1 ± 2.8. The scale factors are pinned instead by test_a_chance_source_kept_one_branch_at_a_time_averages_to_the_exact_sum, which is exact to 1e-10 and has no noise. A mutation check showed it fails on an n−1 in place of any n. The comment above UNBIASED already says those cases check composition and non-vacuity, and states each one's resolving power.
  3. Integer types. Sampling counts now accept any numbers.Integral except bool, as seed/t do. A test covers this.
  4. Counts at their fan. is_exact is now 'draws nothing': every count None, or a chance count at or above its fan (14 board, 12 replacements; the test checks both against the description). Such a call needs no seed and refuses playouts > 1.
  5. Stream words. The comment now says the six-word count holds for seed, t, seat and row below 2³², and that the last two words distinguish the stream at any size.
  6. Cost figures. Agreed: they are printed, not asserted, as the plan said. The round-2 claim is worded as a measurement.
    7–8. The range draw and subset cost. Noted for PR 4, which knows how many rows it boosts.
  7. Process steps in the plan doc. Kept as written: docs/AGENTS.md makes dated plans records that are not rewritten after the fact.

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 17s —— View job


Re-review of PR #89 after b4ee6e4 (Sampling.is_exact, integer types, stream comment)

I read the diff of this commit: boost_target.py (+24/-5) and a 13-line addition to test_boost_target.py. I did not run the suite. I did not open the new tests' bodies, and I did not check how _Draws handles a count above its fan.

Earlier findings, status

  • feat(viz): add interactive rung-0 regret-matching visualizer #3, np.int64 counts rejected: fixed. The check is now numbers.Integral, the same rule as seed and t. bool is still excluded explicitly, which is right because bool is an Integral.
  • chore(ci): add claude code review workflow for pull requests #4, counts at the fan not exact: fixed. is_exact is now true when opponent_range and opponent_actions are None and every chance count is None or at least its fan. The fans are right:
    • A second board card has 14 options, which is len(DECK) - 1.
    • A replacement has 12 options, which is len(DECK) - HOLE_CARDS. This matches the 12 and 14 I re-derived last round.
    • opponent_range and opponent_actions have no fan, so only None counts as drawing nothing. That is correct.
  • fix(rps): guard exploitability anchor so small --iters runs don't crash #5, "never equal" in the _STREAM_TAG comment: fixed. It now says six words hold for seed, t, seat and row below 2³², and that the last two words separate the stream from the others at any size. The second claim assumes SeedSequence entropy words are laid out in order with the tag last, and I did not check that.

Remaining nits (all Low)

  1. Count above the fan (confidence Medium). A count above its fan is now "exact", so the code behind it must clamp or treat it as the whole fan. If _Draws.subset or the 12/k and 14/k scale factors use k unclamped, then board_cards=20 would scale by 14/20 on an exact path. I didn't trace this. The commit says the new tests pin the case, so please confirm that one of them uses a count strictly above a fan, not only equal to it.
  2. playouts message (confidence Low). The error for is_exact and playouts != 1 should say that a count at its fan counts as exact. Otherwise a user who passes hero_draws=12, playouts=4 sees a message about None.
  3. Findings feat(rps): rung 0 — RPS framework, regret matching, convergence analysis #1, fix(deploy): add vercel python entrypoint serving a status page #2 and feat(web): serve rung-0 visualizer at /rung0 and redesign ladder page #6 to feat(kuhn): add the infoset table and give the ledger its two CFR weights #9 from the last review are not addressed in this commit. feat(rps): rung 0 — RPS framework, regret matching, convergence analysis #1 matters most: the PR title and body still describe exact_target.py, the "Nothing else changes" claim and the old cost table. fix(deploy): add vercel python entrypoint serving a status page #2 is the per-source unbiasedness test, which still lacks the pooled-z check.

Overall: no correctness problems found in this commit. The change is small and matches what I flagged. The two open items worth doing before merge are the PR text and the pooled-bias coverage.
· branch AlecROndo/canary-handoff-pr-1-build

@AlecROndo

Copy link
Copy Markdown
Owner Author

At e566120:

  1. A count above its fan. test_a_count_at_or_above_its_fan_is_enumeration_bit_for_bit uses hero_draws=99, strictly above 12, and asserts the result equals EXACT bit for bit. In the code, an is_exact Sampling takes the _EXACT_DRAWS path, so the RNG is never touched. In any case _Draws.subset returns None when k >= n, and every scale is applied only when kept < fan, so no unclamped k reaches a 12/k or a 14/k.
  2. The play-outs refusal. The message now names both spellings: every count None, or a chance count at its fan.
  3. feat(rps): rung 0 — RPS framework, regret matching, convergence analysis #1 and fix(deploy): add vercel python entrypoint serving a status page #2. The title and body were rewritten at 10:01, just after the review you ran started. fix(deploy): add vercel python entrypoint serving a status page #2 is answered in the comment above: a pooled z² over ≤ 4 columns has a band of 1 ± 2.8, so the scales are pinned exactly by the branch oracle instead.

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 28s —— View job


Re-review of PR #89 after e566120 (play-outs refusal message)

I read the diff of this commit. It changes one error string in Sampling.__post_init__ (boost_target.py). I did not run the suite.

Previous nits, status

  • Count above the fan (Medium): resolved. _Draws.subset returns None (the whole fan) when k is None or k >= n (L282), so a count above the fan takes the unscaled enumeration path. test_boost_target.py:715 uses hero_draws=99, strictly above its fan of 12, and compares against the exact result. I did not open that test's body, so I haven't confirmed it is bit-for-bit.
  • playouts message (Low): fixed. It now reads "draws nothing (every count None, or a chance count at its fan)". "At its fan" does not quite cover a count above the fan. "at or above its fan" would be exact (Low, High confidence).

Still open from the earlier review

Overall: I found no correctness problems in this commit. The PR text was rewritten, and the earlier findings are addressed or deliberately deferred.
· branch AlecROndo/canary-handoff-pr-1-build

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Claude finished @AlecROndo's task in 10s —— View job


Re-review of PR #89 after 47a7718 (play-outs refusal wording)

I read the diff of this commit. It changes one error string in Sampling.__post_init__ (src/drawmaha_solver/minidrawmaha/solver/boost_target.py, around L250). I did not run the suite.

Previous nit, status

  • "at its fan" vs. a count above the fan (Low): fixed. The message now reads "a chance count at or above its fan". This matches is_exact, and _Draws.subset returns the whole fan when k >= n.

Remaining findings: none new. The commit touches one string. Confidence is High that it is correct.

Still open from earlier rounds, all deliberate or deferred

  • The per-source UNBIASED cases have no pooled-z check. The author's reasoning holds: a pooled z² over 4 columns or fewer has a band of 1 ± 2.8. The scales are pinned noise-free by the one-branch-at-a-time test instead.
  • The per-entry rng.choice loop in _Draws.opponents and the argsort in _Draws.subset are deferred to PR 4.
  • The plan doc keeps its process steps, because dated plans are records.

Overall: I found no correctness, test or pedagogy problems in this commit.
· branch AlecROndo/canary-handoff-pr-1-build

@AlecROndo
AlecROndo merged commit 2e9ad36 into main Nov 9, 2026
3 checks passed
@AlecROndo
AlecROndo deleted the AlecROndo/canary-handoff-pr-1-build branch November 9, 2026 05:14
AlecROndo added a commit that referenced this pull request Nov 9, 2026
…cle weigh a row by t × weight, and weight one is today's run bit for bit (#91)

* feat(rung4): the exact target — a row's sampled regret averaged over every opponent hand and every physical entry of its key, and the walk's arrival rate, from the rules alone

PR 1 of the targeted-sampling plan. `minidrawmaha/solver/exact_target.py`
computes, for any table row, the regret the walk's samples there estimate
(the mean over the opponent's hands of u − ⟨σ, u⟩, weighted by the deck and
the opponent's own play, normalised by the arrival) and the probability one
walk visits the row. It re-derives the public tree, key maps, draw maps and
showdown from rules/ and never imports the grader, which grades what this
will feed.

Measured: a round-2 row costs 0.8 ms, the arrival alone 0.3 ms; a draw row
45–85 ms and a round-1 row 0.2–0.6 s, because the value below expands over
the traverser's own replacements and the second board card.

Tests: the back-solved reach equals the grader's carried vector on every
board of every point (1e-10, full and restricted deals); arrival at a seat's
first decision is the grader's frequency and sums to one; regret and
arrival equal a world-by-world walk through MiniState on a small restricted
game (1e-9) and the mean and visit count of 6,000 Collector walks row by
row within 4 s.e. and pooled; the module's import block holds no grader.

* fix(rung4): the reach memo is 66 level-1 nodes and 20 round-2 openers, 5,190 vectors, re-derived by a test; the sampled tests select rows by expected count, so a row cannot enter because it fluctuated high

Review follow-ups on #89. The docstring counted the memo's level-1 points
alone (29) where the chance nodes on the paths are memoised too (66 in
all); the test now walks the ancestor closure and pins 66, 20 and 5,190.
`reach()` hands out a copy. The pooled z² windows are a 4-sd band on the
chi-square mean, √(2/n), instead of fixed numbers. The gated 200,000-walk
test kept rows by observed count ≥ 100, which let seat 1's draw rows in
only when they had fluctuated high (mean z +1.8 on two seeds); rows are
now kept by expected count ≥ 80 against an observed cutoff of 40, and
both seats read mean z within 0.01 of zero over thousands of rows. The
module docstring names the double-visit caveat and no longer points at a
plan outside the repo without saying where it is.

* fix(rung4): the sampled tests pin the pooled mean of z at 4/√n beside the mean of z², and cap a single row at six standard errors — the deal alone dealt one picture 292 times against 220 at seed 12

The pooled mean is the sharp bias test (a tenth of a standard error in
every row is caught at 1,600 rows); the per-row cap is loose because of
about 3,000 rows one passes 5 in a run out of a thousand, and the deal
itself did it at seed 12 in a count that involves nothing of this module.
Run with MINIDRAWMAHA_FULL_TARGET=1: both seats pass.

* fix(rung4): one pooled-fairness helper for the sampled tests, with the band's assumptions written beside it — the "caught at 1,600 rows" line was a half-truth; the band is reached there and reliable at about 3,000

* fix(rung4): the pooled band's small-n width stated as it is — 1 ± 1.79 at n = 10, biting from n ≈ 45 — and the arrival seeds checked named

* fix(rung4): the z² band's low side bites from n = 33, where its half-width drops under 1, not from 45

* feat(rung4): every memory row carries a float32 weight, one unless a caller says otherwise; a file without the column loads as ones

PR 2 of the targeted-sampling plan, first of three commits. The reservoir's
row grows from (row, t, target) to (row, t, target, weight): 24 to 28 bytes,
a 50M-row memory 1.2 to 1.4 GB. The weight rides its row's slot through
Algorithm R's eviction, save and load; merge without a weight stamps ones;
a file with no weight key is from before the column and loads with ones.
Refused by name: a negative, non-finite, mis-shaped weight on merge, and a
weight array of the wrong length or dtype on load.

The learner seam still takes three arrays, so tests/deepcfr/test_train.py
is red until the next commit, which threads the column through it.

* feat(rung4): the refit weighs a row by t × weight; weight one is today's loss bit for bit and a row of weight zero is inert

Second of PR 2's three commits. _weighted_loss scales each row's squared
error by (t · w) / mean(t · w): with w ≡ 1 that is t / mean(t) in the same
bits, since t · 1.0 is t in float32. fit_from_scratch and batch_loss take
the weight as a fourth positional array, None meaning ones, and refuse a
weight that is not 1-D, not the memory's length, non-finite, negative, or
all zero (nothing to fit, as an empty memory is). A batch whose every row
weighs 0 divides by a clamped mean and has loss 0, not NaN. fit_policy
takes the column positionally so the policy memory's contents() unpack
straight in; its weights are all one.

* feat(rung4): the learner seam and the oracle take the weight; the oracle banks Σ t′ · w · r in LCFR's order, so weight one keeps the pin bit for bit

Last of PR 2's three commits. Learner.fit takes the memory's four arrays,
the weight positional with no default so no learner can drop it by
accident; step is unchanged, the four-tuple from contents() flowing
through. NetLearner hands the weight to fit_from_scratch and the held
batch's loss, after the pot scaling and the regret rules act on the target:
the weight says how loudly a row counts, never what it says. The oracle
multiplies each sample by its weight in float64 before the per-t′ np.add.at
sum, where × 1.0 is exact, so the LCFR pin passes unchanged; a weight of 2
banks what the row offered twice would, a weight of 0 nothing. Oracle model
files carry the weight and load as ones without it.

* fix(rung4): a scalar rows or weight and a corrupt pre-column file are refused by name — the ones default ran ahead of the checks it relied on; and the weight-one pin is against the old loss formula, not the code itself

From the fresh-context review before the push. Reservoir.load sized the
default weight from a negative `offered` before refusing it; merge and
fit_from_scratch sized it from a 0-d rows before the 1-D check; a 0-d
weight on load indexed its own empty shape. Each now fails on the by-name
ValueError the old code gave. test_weight_one_is_the_unweighted_fit_bit_for_bit
compared the fit to itself (both paths built the same ones); it now
restates the pre-column loss, t / mean(t) over the legal squared error,
and pins batch_loss at weight one and by default against it to the bit,
then the whole fit.

* fix(rung4): a weight is checked after its cast to float32, and t × weight for overflow, on merge, on load and in the fit — a float64 weight past float32's range passed the finite check and was stored as inf; and the oracle's "offered twice" claim holds to the bit only when the two are alone at the column

- `_validate_offer` casts to float32 first and checks finite, non-negative and t × weight finite after; a bool or non-numeric weight is refused by name.
- `Reservoir.load` refuses a weight that is NaN, negative or overflows t × weight, naming the file, as `merge` never writes one.
- `fit_from_scratch` refuses a t × weight that overflows float32, the loss's scale.
- `OracleLearner` docstring: weight 2 equals the row offered twice exactly only when nothing else sits at the column in that t′; otherwise up to rounding, since `np.add.at` sums one at a time. A new test pins two rows of widths 2 and 3 with weights 3 and 2 against the rows offered three and two times, so a weight landing on a neighbour's columns would show.
- `batch_loss` says why it defaults the weight while `Learner.fit` does not; `NetLearner.fit` notes the held loss is a log line nothing decides on.

* feat(rung4): the boost target samples k of n of every source below a high-noise row — board card, both seats' replacements, the opponent's actions and range — each unbiased against the exact sum, which stays as EXACT, with the arrival always exact and one stream per (seed, t, seat, row)

exact_target.py becomes boost_target.py (ExactTargets → BoostTargets). targets()
takes a required Sampling; EXACT reproduces the previous output bit for bit.

* fix(rung4): every chance source's n/k scale is pinned with no noise — one branch at a time, averaged, is the exact sum to 1e-10 — and the range draw is tested where a key's two entries face different ranges; the stream's tail is two words, not one, and seed and t take any integer

* fix(rung4): a Sampling that draws nothing is exact whatever spells it — None, or a chance count at its fan — so it needs no seed and refuses extra play-outs; counts take any integer type, as seed and t do; the stream comment says when six words hold

* fix(rung4): the play-outs refusal names both spellings of a Sampling that draws nothing

* fix(rung4): the play-outs refusal says at or above its fan
AlecROndo added a commit that referenced this pull request Nov 9, 2026
…et and draws B rows without replacement ∝ arrival — on LCFR-2M the line arm's draws land mostly on round-1 and draw rows, ~100× dearer than round 2's (#93)

* feat(rung4): the exact target — a row's sampled regret averaged over every opponent hand and every physical entry of its key, and the walk's arrival rate, from the rules alone

PR 1 of the targeted-sampling plan. `minidrawmaha/solver/exact_target.py`
computes, for any table row, the regret the walk's samples there estimate
(the mean over the opponent's hands of u − ⟨σ, u⟩, weighted by the deck and
the opponent's own play, normalised by the arrival) and the probability one
walk visits the row. It re-derives the public tree, key maps, draw maps and
showdown from rules/ and never imports the grader, which grades what this
will feed.

Measured: a round-2 row costs 0.8 ms, the arrival alone 0.3 ms; a draw row
45–85 ms and a round-1 row 0.2–0.6 s, because the value below expands over
the traverser's own replacements and the second board card.

Tests: the back-solved reach equals the grader's carried vector on every
board of every point (1e-10, full and restricted deals); arrival at a seat's
first decision is the grader's frequency and sums to one; regret and
arrival equal a world-by-world walk through MiniState on a small restricted
game (1e-9) and the mean and visit count of 6,000 Collector walks row by
row within 4 s.e. and pooled; the module's import block holds no grader.

* fix(rung4): the reach memo is 66 level-1 nodes and 20 round-2 openers, 5,190 vectors, re-derived by a test; the sampled tests select rows by expected count, so a row cannot enter because it fluctuated high

Review follow-ups on #89. The docstring counted the memo's level-1 points
alone (29) where the chance nodes on the paths are memoised too (66 in
all); the test now walks the ancestor closure and pins 66, 20 and 5,190.
`reach()` hands out a copy. The pooled z² windows are a 4-sd band on the
chi-square mean, √(2/n), instead of fixed numbers. The gated 200,000-walk
test kept rows by observed count ≥ 100, which let seat 1's draw rows in
only when they had fluctuated high (mean z +1.8 on two seeds); rows are
now kept by expected count ≥ 80 against an observed cutoff of 40, and
both seats read mean z within 0.01 of zero over thousands of rows. The
module docstring names the double-visit caveat and no longer points at a
plan outside the repo without saying where it is.

* fix(rung4): the sampled tests pin the pooled mean of z at 4/√n beside the mean of z², and cap a single row at six standard errors — the deal alone dealt one picture 292 times against 220 at seed 12

The pooled mean is the sharp bias test (a tenth of a standard error in
every row is caught at 1,600 rows); the per-row cap is loose because of
about 3,000 rows one passes 5 in a run out of a thousand, and the deal
itself did it at seed 12 in a count that involves nothing of this module.
Run with MINIDRAWMAHA_FULL_TARGET=1: both seats pass.

* fix(rung4): one pooled-fairness helper for the sampled tests, with the band's assumptions written beside it — the "caught at 1,600 rows" line was a half-truth; the band is reached there and reliable at about 3,000

* fix(rung4): the pooled band's small-n width stated as it is — 1 ± 1.79 at n = 10, biting from n ≈ 45 — and the arrival seeds checked named

* fix(rung4): the z² band's low side bites from n = 33, where its half-width drops under 1, not from 45

* feat(rung4): every memory row carries a float32 weight, one unless a caller says otherwise; a file without the column loads as ones

PR 2 of the targeted-sampling plan, first of three commits. The reservoir's
row grows from (row, t, target) to (row, t, target, weight): 24 to 28 bytes,
a 50M-row memory 1.2 to 1.4 GB. The weight rides its row's slot through
Algorithm R's eviction, save and load; merge without a weight stamps ones;
a file with no weight key is from before the column and loads with ones.
Refused by name: a negative, non-finite, mis-shaped weight on merge, and a
weight array of the wrong length or dtype on load.

The learner seam still takes three arrays, so tests/deepcfr/test_train.py
is red until the next commit, which threads the column through it.

* feat(rung4): the refit weighs a row by t × weight; weight one is today's loss bit for bit and a row of weight zero is inert

Second of PR 2's three commits. _weighted_loss scales each row's squared
error by (t · w) / mean(t · w): with w ≡ 1 that is t / mean(t) in the same
bits, since t · 1.0 is t in float32. fit_from_scratch and batch_loss take
the weight as a fourth positional array, None meaning ones, and refuse a
weight that is not 1-D, not the memory's length, non-finite, negative, or
all zero (nothing to fit, as an empty memory is). A batch whose every row
weighs 0 divides by a clamped mean and has loss 0, not NaN. fit_policy
takes the column positionally so the policy memory's contents() unpack
straight in; its weights are all one.

* feat(rung4): the learner seam and the oracle take the weight; the oracle banks Σ t′ · w · r in LCFR's order, so weight one keeps the pin bit for bit

Last of PR 2's three commits. Learner.fit takes the memory's four arrays,
the weight positional with no default so no learner can drop it by
accident; step is unchanged, the four-tuple from contents() flowing
through. NetLearner hands the weight to fit_from_scratch and the held
batch's loss, after the pot scaling and the regret rules act on the target:
the weight says how loudly a row counts, never what it says. The oracle
multiplies each sample by its weight in float64 before the per-t′ np.add.at
sum, where × 1.0 is exact, so the LCFR pin passes unchanged; a weight of 2
banks what the row offered twice would, a weight of 0 nothing. Oracle model
files carry the weight and load as ones without it.

* fix(rung4): a scalar rows or weight and a corrupt pre-column file are refused by name — the ones default ran ahead of the checks it relied on; and the weight-one pin is against the old loss formula, not the code itself

From the fresh-context review before the push. Reservoir.load sized the
default weight from a negative `offered` before refusing it; merge and
fit_from_scratch sized it from a 0-d rows before the 1-D check; a 0-d
weight on load indexed its own empty shape. Each now fails on the by-name
ValueError the old code gave. test_weight_one_is_the_unweighted_fit_bit_for_bit
compared the fit to itself (both paths built the same ones); it now
restates the pre-column loss, t / mean(t) over the legal squared error,
and pins batch_loss at weight one and by default against it to the bit,
then the whole fit.

* fix(rung4): a weight is checked after its cast to float32, and t × weight for overflow, on merge, on load and in the fit — a float64 weight past float32's range passed the finite check and was stored as inf; and the oracle's "offered twice" claim holds to the bit only when the two are alone at the column

- `_validate_offer` casts to float32 first and checks finite, non-negative and t × weight finite after; a bool or non-numeric weight is refused by name.
- `Reservoir.load` refuses a weight that is NaN, negative or overflows t × weight, naming the file, as `merge` never writes one.
- `fit_from_scratch` refuses a t × weight that overflows float32, the loss's scale.
- `OracleLearner` docstring: weight 2 equals the row offered twice exactly only when nothing else sits at the column in that t′; otherwise up to rounding, since `np.add.at` sums one at a time. A new test pins two rows of widths 2 and 3 with weights 3 and 2 against the rows offered three and two times, so a weight landing on a neighbour's columns would show.
- `batch_loss` says why it defaults the weight while `Learner.fit` does not; `NetLearner.fit` notes the held loss is a log line nothing decides on.

* feat(rung4): the boost target samples k of n of every source below a high-noise row — board card, both seats' replacements, the opponent's actions and range — each unbiased against the exact sum, which stays as EXACT, with the arrival always exact and one stream per (seed, t, seat, row)

exact_target.py becomes boost_target.py (ExactTargets → BoostTargets). targets()
takes a required Sampling; EXACT reproduces the previous output bit for bit.

* fix(rung4): every chance source's n/k scale is pinned with no noise — one branch at a time, averaged, is the exact sum to 1e-10 — and the range draw is tested where a key's two entries face different ranges; the stream's tail is two words, not one, and seed and t take any integer

* feat(rung4): targeting names four granularities of group over the table's rows — 141 lines and 3,870 line × hand classes, from the rules alone

* feat(rung4): the noise score is one walk's relative error at a group, √(E[r²]/p)/|E[r]|, from the memory's own walk rows only — an exact row is a mean, not a sample

* feat(rung4): the aimed arms rank groups by leak × noise per reached infoset and take them until the pool is 20 × B reached rows; infoset takes the B best outright

* feat(rung4): a target set draws B rows a seat without replacement ∝ arrival by exponential keys, reproducible from (seed, t, seat, stream) and never the same row twice

* feat(rung4): one call turns leak, frequency and the memories into a frozen target set, asking for arrivals at the pool alone; the Refresher protocol is the seam PR 4 calls

* feat(rung4): no module of the trainer's package imports the grader, checked on every import statement

* fix(rung4): a Sampling that draws nothing is exact whatever spells it — None, or a chance count at its fan — so it needs no seed and refuses extra play-outs; counts take any integer type, as seed and t do; the stream comment says when six words hold

* feat(rung4): the leak by betting line — the four leakiest lines are round 1's and hold 19% of LCFR-2M's exploitability on 0.07% of its reached infosets; the 20 leakiest hold 57% on a quarter

* fix(rung4): the play-outs refusal names both spellings of a Sampling that draws nothing

* fix(rung4): a one-step gain a few ulps under zero is rounding and reads as zero; a real negative is still refused — the LCFR-2M release has gains at −7e-12

* feat(rung4): the grader-backed refresher grades the exact average (or, by choice, the current strategy), weighs the pool by the walk's arrival, and is the only importer of the meter on the trainer's side

* feat(rung4): round_two_only, off by default, keeps every arm off the one-board-card rows, whose exact rows cost about a hundred times a round-2 row's

* feat(rung4): the docs name targeting and its refresher — the eight round-1 lines hold 22% of LCFR-2M's leak on 0.13% of its reached infosets, read by a test from the committed file

* feat(rung4): the PR 3 plan — targeting's contract, the two provisional decisions, and the row-cost finding behind round_two_only

* fix(rung4): the play-outs refusal says at or above its fan

* fix(rung4): the noise score reads one walk's total as one visit or none, √(E[r²]/p − μ²)/|μ|, so a line every walk reaches scores its scatter σ/|μ| rather than √(σ² + μ²)/|μ|; the tests now pin p's memory share and make only the noise break a tie

* fix(rung4): the layout test reads every point's first and last row through the table's own index, and a pool landing exactly on pool × B is pinned to take no further group

* fix(rung4): a fresh interpreter checks that targeting loads neither the meter nor the analysis; float rows, non-int draws and a bad K are refused by name before any walk; a saved set reads back every spec field; σ is read only when an arrival is asked for; the package docs count ten modules

* fix(rung4): the plan states the noise score as built, √(E[r²]/p − μ²)/|μ|, and the random arm's measured refresh, eight minutes a seat

* fix(rung4): p's estimator is unbiased with exact rows in a full memory, because size and offered both count them — said in the docstring and pinned over 400 eviction streams; an infoset set's unread weights must be ones

* fix(rung4): noise's docstring says the exact rows cancel in n_g / size · offered

This branch was successfully deployed

1 active deployment
Preview — 47a77183 Deployed Nov 6, 2026 by vercel[bot]
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.

1 participant