Skip to content

feat(rung4): every memory row carries a weight; the refit and the oracle weigh a row by t × weight, and weight one is today's run bit for bit - #91

Merged
AlecROndo merged 21 commits into
mainfrom
AlecROndo/pr-2-handoff-prompt
Nov 9, 2026
Merged

AlecROndo merged 21 commits into
mainfrom
AlecROndo/pr-2-handoff-prompt

Conversation

@AlecROndo

@AlecROndo AlecROndo commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

PR 2 of the targeted-sampling plan for rung 4, built on PR 1's head (#89). Every memory row now carries a weight; the refit's loss and the oracle weigh a row by t × weight. Nothing yet offers a weight other than one, so a run is bit for bit what it was: the oracle pin passes unchanged, and the net's fit at weight one is the unweighted fit's weights exactly.

What it is

The targeted-sampling plan's boost stage (PR 4) will add, at a chosen infoset, one row holding the EXACT regret under the current strategy, weighted (1 − α) · K · arrival — the number of sampled rows the walk would have put there in expectation — and turn the walk's own rows there down to α. This PR is the column that carries that factor, and the two places that read it:

  • reservoir.py — the row is (row, t, target, weight), 28 bytes (was 24); a 50M-row memory is 1.4 GB (was 1.2). 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, so a saved run resumes as the run it was. Refused by name: a negative, non-finite (checked after the cast to float32, so a float64 past its range is caught as the inf it became), mis-shaped or non-numeric weight on merge, and one whose t × weight overflows float32 at the stamp's t; on load, a weight array of the wrong length or dtype, or holding a value merge would have refused.
  • fit.py — _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 (t · 1.0 is t in float32). A batch whose every row weighs 0 divides by a clamped mean and has loss 0, not NaN. 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, overflowing t × weight in float32, or all zero (nothing to fit, as an empty memory is).
  • train.py — Learner.fit(rows, t, targets, weight, *, seed), 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 the fit and the held batch's loss after pot_scaled and rule_targets act on the target: the weight says how loudly a row counts, never what it says. OracleLearner.write multiplies each sample by its weight in float64 before LCFR's per-t′ np.add.at sum, where × 1.0 is exact.
  • policy.py — fit_policy takes the column positionally so fit_policy(*memory.contents(), …) in the grader keeps working; policy rows always weigh one.

No new DeepConfig field, so nothing for ADDED_LATER or SAMPLE_FIELDS; the resume state's file set is unchanged.

Tests

  • test_the_oracle_loop_is_lcfr_bit_for_bit passes unchanged.

  • reservoir: a weight rides its row through eviction and the later-offer-wins tie-break; rows offered without a weight weigh one; bad weights refused on merge; a file written before the column loads with ones and keeps filling; a weight of the wrong length or dtype is refused naming the file.

  • fit (torch): weight one is the unweighted fit bit for bit (torch.equal on every parameter); a row of weight 0 is inert; the loss weighs a row by t × weight (the weighted least-squares answer moves from +0.5 to 0 when weights (1, 3) cancel t = (3, 1)); a batch of weightless rows has loss 0 and finite gradients; bad weights refused by name.

  • train: a weight of 2 banks what the row offered twice would (to the bit when alone at the column; otherwise up to rounding, as the docstring says), and a weight of 0 nothing (array_equal on the whole table); a 2-wide and a 3-wide row with weights 3 and 2 in one model bank what the rows offered three and two times would, so a weight on a neighbour's columns would show; oracle models round-trip the weight and load as ones without it; NetLearner hands the weight through untouched under pot scaling and under DCFR.

  • The weight-one pin is against the pre-column loss restated inline in the test (t / mean(t) over the legal squared error), to the bit, then through the whole fit.

  • A scalar rows or weight and a corrupt pre-column file are refused by name (a fresh-context review found the ones default running ahead of the checks it relied on; fixed in the last commit).

uv run pytest with torch installed: 1,747 passed, 17 skipped. Without torch: the rung-4 directory 156 passed, 6 skipped (the torch tests skip).

Rulings against the plan's appendix

  • merge takes weight=None meaning ones rather than requiring the column, so collect.rows_of and step are untouched and the policy memory never names a weight; the Learner seam, by contrast, requires it.
  • fit_from_scratch refuses a memory whose weights are all zero, which the appendix does not mention: 4,000 steps of zero gradient would "fit" nothing and say so nowhere.
  • OracleLearner.load reads a model file without a weight as ones, like a reservoir file, so a test-saved oracle run from before this PR still opens.

Not in this PR

PR 3 (targeting) and PR 4 (the boost stage) wait on the plan's open decisions.

Carried from PR 1 and main by merge (2026-11-06)

This branch is stacked on PR 1 (#89) by merge, per the repo's PR rule. Its diff against main therefore also shows PR 1's files until #89 lands:

  • src/drawmaha_solver/minidrawmaha/solver/boost_target.py (renamed from exact_target.py, now with the Sampling framework)
  • tests/minidrawmaha/test_boost_target.py
  • docs/superpowers/plans/2026-11-06-boost-target-modular-sampling.md

They are reviewed on #89, not here. main was merged in too, for #92; the one conflict was in src/drawmaha_solver/deepcfr/AGENTS.md, where both notes are kept. Nothing in this PR's weight column changed.

On the two weight formulas. The boost row's stored weight is (1 − α) · K · arrival, the number of sampled rows it stands for. The refit then weighs every row by t × weight. So the boost module's K · arrival · t and this PR's (1 − α) · K · arrival are the same quantity at α = 0: one counts the fit's t, the other leaves it to the fit.

…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.
…, 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.
… 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.
…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
…9 at n = 10, biting from n ≈ 45 — and the arrival seeds checked named
…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.
…y'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.
…cle 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.
… 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.
@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 39s —— View job


Review of PR #91 (weight column for rung 4)

I read the diffs of reservoir.py, fit.py, train.py and policy.py. I did not run the test suite. The weight-one-is-today's-run argument holds on paper: t * 1.0 == t in float32, and x * 1.0 is exact in float64. Findings are below, each with severity and my confidence.

1. Docstring claim is overstated: "a row of weight 2 banks what the same row offered twice would"

  • File: train.py, OracleLearner docstring. Severity: low–medium (docstring accuracy). Confidence: high.
  • It says "(r + r = 2r exactly)". np.add.at accumulates sequentially per column, so (a + r) + r does not generally equal a + 2r in floating point. The claim holds only when the row is the first to hit that column, or when the sums are exact.
  • The test uses array_equal on the whole table. I did not check whether its inputs happen to make the sums exact. If they do, say so in the test. Either way, soften the docstring to "equal up to rounding, and exactly when the partial sums are exact".

2. merge can let an infinite weight through, and load does not check weight values

  • File: reservoir.py, _validate_offer and load. Severity: medium. Confidence: medium–high.
  • _validate_offer checks isfinite on the input dtype and then calls astype(np.float32). A float64 weight of 1e300 passes and becomes inf in the stored column, which the finite check was meant to prevent.
  • Check finiteness and non-negativity after the cast, or reject values above float32 max.
  • load checks the weight's shape and dtype but not that its values are finite and ≥ 0. A corrupt or hand-edited file with NaN or negative weights loads silently, and fit_from_scratch would only catch it later.
  • Reusing the merge check on load would be consistent with "refused by name".
  • Also, np.asarray(weight) on a bool or object array is accepted by merge. I'm unsure whether that matters.

3. Possible float32 overflow in t * weight

  • File: fit.py, _weighted_loss. Severity: low. Confidence: medium.
  • Large finite weights times t ≤ 2000 can overflow float32, giving an inf scale and then NaN through scale / mean. The clamp only covers a zero mean. Bounding the weight at validation (item 2) would close this.

4. Weight-zero rows in the held batch

  • File: train.py, NetLearner.fit. Severity: low. Confidence: low–medium.
  • The held-batch loss is 0 when every held row weighs 0. Under the boost, a held loss of 0 could look like a perfect fit to any divergence or quality check that reads it. Check whether anything compares it against a threshold. I could not confirm this either way.

5. The oracle's np.repeat(weight, width) relies on the layout of legal

  • File: train.py, OracleLearner.write. Severity: low. Confidence: medium.
  • The code assumes every row in a ledger group has the same width and that legal is row-major. The comment says this. An assertion on values.shape == repeated.shape would turn a silent misalignment into a loud failure.

6. Scope

7. Small things

  • reservoir.py: the load error message changed from {rows.shape[0]} rows to {rows.shape} rows. This is harmless, but it is an unrelated edit.
  • batch_loss defaults weight=None, while Learner.fit deliberately has no default. That is defensible, since the seam is the place where dropping the weight is dangerous. A one-line note in batch_loss saying why the two differ would help.
  • The fallback to ones for a file with no weight is well tested. A .npz containing weight with a legacy dtype such as float64 is rejected by the dtype check. I think that is correct, since the files are written by save.

Tests

  • Coverage looks good: weight-one bit-for-bit, inert zero row, t×weight least-squares, all-zero batch, and bad-weight refusals.
  • Missing: a merge test for a float64 weight that overflows float32 (item 2), and a load test for a NaN or negative weight value.

…ight 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.
@claude

claude Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

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


Re-review of PR #91 after the latest push (11b6e7b)

I read the new reservoir.py, train.py and fit.py code and the commit log. I did not run the test suite.

Resolved by 394f9f7 and 11b6e7b

Still open (low severity)

  1. Scope (confidence high, severity low). The PR still contains exact_target.py (882 lines) and its tests (669 lines). They are from 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, which this branch is built on, and the repo rules require that stacking. It is not a defect. The diff shrinks once 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 merges.
  2. np.repeat alignment (confidence medium). A cheap assert values.shape == repeated.shape would turn a silent misalignment of weight and legal entries into a loud failure. Please check whether it already exists.
  3. batch_loss default (confidence medium). batch_loss defaults weight=None while Learner.fit requires the weight. This is defensible. A one-line docstring note on why the two differ would help.
  4. Missing tests (confidence medium). I did not confirm tests for these cases:
    • a merge with a float64 weight that overflows float32;
    • a load of a file with a NaN or negative weight;
    • a load of a file whose t × weight overflows float32.
      The commit message implies they exist. If they do, this item is moot.

I found no new correctness problems. The weight-one argument still holds: t * 1.0 == t in float32, and x * 1.0 is exact in float64. I'd merge once item 4 is confirmed.

@AlecROndo

Copy link
Copy Markdown
Owner Author

Round 1 of the review, dispositioned in 11b6e7b.

  1. "Offered twice" claim — fixed. The OracleLearner docstring now says a row of weight 2 banks 2r, which equals the row offered twice to the bit only when the two are the only samples at the column in that t′ (0 + r + r is 2r exactly), and otherwise agrees up to rounding, since np.add.at sums one at a time and (a + r) + r is not a + 2r. The test's comment says its inputs are that exact case.
  2. Infinite weight through the cast; load not checking values — fixed. _validate_offer casts to float32 FIRST and checks finite / non-negative after, and refuses a bool or non-numeric weight by name (weight must be a float or int array). Reservoir.load refuses a NaN, negative, or t × weight-overflowing weight naming the file, as merge never writes one. Tests: float64 1e300 on merge, a bool array, and test_load_refuses_a_weight_with_a_bad_value_by_name (NaN, negative, overflow at t = 2, and the same 2e38 accepted at t = 1).
  3. float32 overflow in t × weight — fixed with a direct check rather than a bound: merge refuses a weight whose t × weight overflows float32 at the stamp's t (the t the row carries forever), load the same per row, and fit_from_scratch the same (t × weight must fit float32), with tests at all three. The batch mean is of b ≤ 10,000 finite products, so it cannot overflow unless a product is already within a factor of b of float32's maximum, far past any weight the plan produces ((1 − α) · K · arrival ≤ K).
  4. Held-batch loss of 0 — nothing decides on it: fitted.loss goes into StepStats.loss and from there to the progress line's "loss" field (train.py:439, :893), and no code compares it against a threshold (the only diverged the run has is fit_from_scratch's own non-finite-weights check, which is unrelated). A comment in NetLearner.fit now says so.
  5. np.repeat(weight, width) relying on legal's layout — covered by a test instead of an assertion: values and the repeated weights have the same length by construction (both sum the widths), so a shape assertion would never fire; a misalignment would be a weight on a neighbour's columns at the same total length. test_the_oracle_keeps_each_weight_on_its_own_row_across_widths puts a 2-wide and a 3-wide row in one model with weights 3 and 2 and pins the table against the rows offered three and two times (array_equal), and checks the swapped weights give a different table. width is per row (widths[rows]), so no assumption that rows in a group share a width is made.
  6. Scope — exact_target.py, its tests and the minidrawmaha/AGENTS.md / tests/AGENTS.md lines are PR 1 (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), which this branch is built on per the repo's rule that each PR branches from its predecessor's head and targets main (never stacked, never rebased). Once 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 merges, this PR's diff is the six rung-4 files plus the plan. Nothing to review here for those files.
  7. Small things — {rows.shape} in the load message is deliberate from the last commit: with a scalar (0-d) rows array, rows.shape[0] raises IndexError before the named ValueError, so the whole-shape form is what lets a corrupt file be refused by name. batch_loss now says why it defaults the weight while Learner.fit does not. Agreed that a float64 weight in a file is rightly refused: save only ever writes float32.

Tests at 11b6e7b: tests/deepcfr 223 passed, 1 skipped with torch; 156 passed, 6 skipped without; the oracle pin unchanged.

@AlecROndo

Copy link
Copy Markdown
Owner Author

Round 2, against 11b6e7b. No code changed; every open item is already in that commit or dismissed with the reason below.

  1. Scope — as you say: 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's files, stacked per the repo rule, not a defect. Nothing to do here.
  2. np.repeat alignment assertion — there is none, on purpose. values is targets[at][legal], a boolean mask over an (n, 4) array whose row i has width[i] True entries, so its length is Σ width; np.repeat(weight[at], width) has length Σ width by definition. The two shapes are equal by construction for every input, so assert values.shape == repeated.shape could never fire — and a real misalignment (a weight sitting on a neighbour's columns) keeps the same total length, so the assertion would not catch it either. What catches it is the test added in 11b6e7b, tests/deepcfr/test_train.py::test_the_oracle_keeps_each_weight_on_its_own_row_across_widths: a 2-wide and a 3-wide row in one model with weights 3 and 2, pinned array_equal against the rows offered three and two times, and shown to differ when the weights are swapped.
  3. batch_loss default note — present in 11b6e7b, fit.py batch_loss docstring: "weight left out is a batch of plain samples, every row weighing 1: a default here, where a caller hands arrays it built itself, while Learner.fit in train.py has none, because that is where a memory's column could be dropped by accident."
  4. Tests — all three are in 11b6e7b:
    • merge with a float64 weight that overflows float32: tests/deepcfr/test_reservoir.py::test_merge_refuses_bad_weights, the np.array([1.0, 1e300]) case (match="finite"), plus a float32 2e38 accepted at t = 1 and refused at t = 2 (match="fit float32"), plus a bool array (match="float or int").
    • load of a NaN or negative weight: tests/deepcfr/test_reservoir.py::test_load_refuses_a_weight_with_a_bad_value_by_name (nan.npz, negative.npz, each matched with the file's name).
    • load whose t × weight overflows float32: the same test, overflow.npz at t = 2 refused, and the same weight at t = 1 loaded and read back.
    • And in the fit: tests/deepcfr/test_fit.py::test_fit_refuses_bad_weights, the 1e300 and the t = 2 × 2e38 cases.

…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 20s —— View job


Re-review of PR #91 at 2d1ed62

I did not run the test suite. This pass was shallow. I diffed the commit log and read only the docstring and function layout of the new boost_target.py. I did not re-derive the math in the new code.

Prior rounds (weight column)

  • Nothing I read in 11b6e7b changes my previous assessment. The weight-one argument holds on paper: t * 1.0 == t in float32, and x * 1.0 is exact in float64.
  • Your round-2 reasoning on np.repeat is sound. The two shapes are equal by construction, so a shape assertion could never fire. The width-mixed test is the right guard.
  • The batch_loss docstring note and the three test cases you listed match what I'd asked for. I did not open the tests to confirm they assert what you describe.

What changed since my last review

  • The branch now merges canary-handoff-pr-1-build. boost_target.py (1,093 lines) and test_boost_target.py (930 lines) are in the diff.
  • These files are not in the PR description. The description still says PR 2 is only the weight column.
  • This is stacked-PR content from a predecessor branch, which the repo rules require. It is not a defect. Update the description, or say that the diff will shrink once the predecessor merges, so a reviewer doesn't take it as in scope.
  • The description's "Not in this PR" section says PR 4, the boost stage, waits. The module docstring says the boost stage will use the weight K · arrival · t. The PR body says (1 − α) · K · arrival. These agree only if the t is the fit's own t × weight factor. A one-line cross-reference would avoid confusion.

Open items, low severity

  1. Description is stale (confidence high). See above: the PR body doesn't mention boost_target.py, its tests, or the second plan doc.
  2. boost_target.py is unreviewed here (confidence high). Two things to check when it is reviewed on its own PR.
    • The docstring's unbiasedness claims need re-deriving: n/k scaling without replacement, and the opponent range draw "in proportion to weight … each carrying 1/k of the entry's total".
    • The claim that a sampled row's target has expectation regret/arrival depends on the arrival being exact. The docstring says so, and that is the correct argument.
  3. Test coverage for the new column (confidence low, severity low). I did not independently verify that every new weight code path in train.py is covered. I took that from the PR description and your replies.

I found no new correctness problems in the weight column. The remaining risk sits in boost_target.py, which I did not examine in depth.

@AlecROndo

Copy link
Copy Markdown
Owner Author

Thanks. Both items are addressed in the description:

  1. The PR 1 files in the diff. They are here by merge, because this branch is stacked on 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 per the repo rule. They are reviewed on 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, whose latest claude-review re-derived the sampling math and found no correctness problems. The diff shrinks once 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 lands.
  2. The two weight formulas. The new section says how (1 − α) · K · arrival, the stored weight, relates to K · arrival · t: the fit's t × weight supplies the t, and the two agree at α = 0.

The weight-column code is unchanged since the last round.

… — 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
@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

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


Re-review of PR #91 at 4782d43

I did not run the test suite. I diffed 2d1ed62..HEAD and read the changes in full.

Weight column: unchanged since my last round, so my earlier assessment stands. I found no correctness problems there.

What changed: only boost_target.py and test_boost_target.py, which come from #89 by merge (commit b4ee6e4). They are reviewed on #89, not here.

  • Sampling.__post_init__ now accepts numbers.Integral. numpy ints pass, and import numbers is present. bool is still refused by the explicit check. np.bool_ is not registered as Integral, so it is refused too.
  • is_exact now treats a chance count at or above its fan as exact.
    • The fans are _BOARD_FAN = len(DECK) - 1 (14) and _REPLACEMENT_FAN = len(DECK) - HOLE_CARDS (12).
    • opponent_range and opponent_actions must still be None. That is correct, because they are not enumerated by count.
    • The test checks both fans against the description's own shapes and that playouts=2 is refused. That ties the constants to the game rules.
  • Stream-tag comment: the new wording is accurate. Below 2³² for each of seed, t, seat and row, the stream has six words. Above that it differs from the other streams in its last two words.

Low-severity notes (confidence medium):

  1. test_sampling_counts_take_any_integer_type only checks board_cards. It does not cover is_exact with np.int64 counts at the fan. I think that path works, since np.int64 >= int compares fine.
  2. If the deck or hole size ever changes, _BOARD_FAN and _REPLACEMENT_FAN are computed from DECK and HOLE_CARDS. The test's shape asserts would catch a drift between them and the description.

Nothing blocking. I'd merge once #89 is settled.

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

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


Re-review of PR #91 at 3a1257a

I did not run the tests. I diffed 4782d43..HEAD and read it in full.

Weight column: unchanged since my last round. My earlier assessment stands, and I found no correctness problems there.

What changed: one line in boost_target.py:250, which comes from #89 by merge. It is the error message in Sampling.__post_init__ for playouts != 1 on an exact sampling. The old text said "enumerates every source". The new text says "draws nothing (every count None, or a chance count at its fan)", which matches what is_exact now means after b4ee6e4. The wording is accurate.

Low-severity notes

  1. Test pin (confidence medium). I didn't check whether test_boost_target.py matches this message text. The diff touched no test, so if a test matches the old wording, it would fail. The earlier rounds' tests probably match on playouts must be 1, which is still present. Worth a quick uv run pytest tests/minidrawmaha/test_boost_target.py.
  2. Line length (confidence low). The f-string is one long line. Nothing in the diff suggests a lint rule against it.

Nothing blocking. The remaining review of boost_target.py belongs on #89.
· branch AlecROndo/pr-2-handoff-prompt

@AlecROndo

Copy link
Copy Markdown
Owner Author

Checked: the refusal tests match on playouts must be 1, which the message still contains. uv run pytest tests/minidrawmaha/test_boost_target.py -k 'fan or refused or refuses' passes (9 tests) on both branches. The wording nit from #89 ('at or above its fan') has landed here by merge.

@claude

claude Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

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


Re-review of PR #91 at cbb5308

I did not run the test suite. I diffed 3a1257a..HEAD and read it in full.

Weight column: unchanged since my last round. I found no correctness problems there.

What changed: one line, in boost_target.py:250, which comes from #89 by merge. The Sampling.__post_init__ error message now says "at or above its fan" instead of "at its fan".

  • The new wording is accurate. It matches the is_exact docstring at boost_target.py:255 and the Sampling docstring at :226, both of which say "at or above its fan".
  • The two tests that check this refusal (test_boost_target.py:694 and :724) match on playouts must be 1. That text is still in the message, so neither test should break. I confirmed this with grep and did not run them.

Low-severity note (confidence low): the message line is long, but nothing in the diff suggests a lint rule against that.

Nothing blocking. Further review of boost_target.py belongs on #89.
· branch AlecROndo/pr-2-handoff-prompt

This branch was successfully deployed

1 active deployment
Preview — cbb53088 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