Skip to content

fix(selection): CladeThompson.tau reads non-finite budgets as full and caps before overflow (#280) - #281

Merged
Birfy merged 8 commits into
mainfrom
fix/issue-280-clade-thompson-tau
Oct 16, 2026
Merged

Birfy merged 8 commits into
mainfrom
fix/issue-280-clade-thompson-tau

Conversation

@Birfy

@Birfy Birfy commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Closes #280

CladeThompson.tau() (#276/#279) mishandled three input edge cases:

  • Non-finite budget_remaining: +inf (a caller's "no ceiling") and NaN returned max_tau, maximal exploitation from round one. They now read as a full budget (tau = 1), matching CostEfficient's clamp and BudgetGovernor.remaining_fraction()'s "no budget means 1.0". Only <= 0 (and -inf) means exhausted.
  • Overflow: b ** -beta was evaluated before the cap, and a Python float ** raises OverflowError instead of returning inf (for example cool_down_beta=40, budget_remaining=1e-9). The exponent is now computed in log space and capped at max_tau before exponentiating.
  • Constructor: NaN/inf cool_down_beta and NaN/inf max_tau slipped past the < 0 / < 1 checks; an infinite cap could hand random.betavariate an infinite tau. Both are rejected with ValueError now.

Existing test_tau_schedule expectations are unchanged. docs/api.md was regenerated and docs/selection.md documents the budget reading.

Tests: 3 new tests (7 cases) in tests/test_selection_hgm.py; 6 fail on main and all pass here. Full local suite passed.

Birfy added 2 commits October 15, 2026 16:11
…aps before overflow (#280)

+inf/NaN budget_remaining now mean a full budget (tau=1), matching
CostEfficient's clamp and remaining_fraction()'s no-ceiling convention;
only <=0 means exhausted. The power is computed in log space and capped at
max_tau before exponentiating, so a small fraction with a steep beta no
longer raises OverflowError. Non-finite cool_down_beta/max_tau are rejected.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T08:38:06.775214Z befeca9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review (Closes #280)

Verdict: LGTM — posting as COMMENT because GitHub blocks self-approve on Birfy→Birfy PRs.

Correctness

All three #280 failure modes are fixed and match the issue repro on main at HEAD:

  1. Non-finite budget — +inf / NaN → tau = 1 (full exploration); only <= 0 / -inf → max_tau. Aligns with CostEfficient's clamp (max(0, min(1, budget)), which already maps +inf→1 and — via min(1.0, nan) argument order — NaN→1) and with BudgetGovernor.remaining_fraction() / default budget_remaining=1.0 when there is no ceiling.
  2. Overflow — log-space log_tau = -β · log(b) capped before exp avoids the Python float ** OverflowError on steep β × tiny legal fractions (1e-9, even 5e-324). Schedule for in-range values unchanged (tau(0.002) ≈ 500 with β=1).
  3. Constructor — not (isfinite(x) and …) correctly rejects NaN/±inf knobs that slipped past the old < 0 / < 1 checks; an infinite max_tau can no longer hand random.betavariate an infinite α/β.

Existing test_tau_schedule expectations are preserved; cool_down_beta == 0 short-circuit still returns 1 without touching the budget.

Design / docs fit

  • Small, single-purpose fix on the surface added in #279; no API shape change.
  • docs/selection.md documents the CostEfficient-aligned reading; docs/api.md gains the tau method row; CHANGELOG Fixed entry is clear and issue-linked.

Tests

Locally: tests/test_selection_hgm.py — 15 passed on this branch.
Against main code with the new test file: 6 failed, 9 passed (the three new tests / parametrize cases), matching the PR claim.

Coverage is tight: non-finite budgets, overflow + select() still works under a tiny budget, and constructor rejections including max_tau < 1.

Nits (non-blocking)

  • Docstring says CostEfficient “reads” NaN as full; that is true for the current clamp expression order, but it is accidental (order-dependent min/max with NaN) rather than an explicit isnan branch. CladeThompson’s explicit math.isnan is the clearer contract — fine as written.
  • docs/api.md table line for tau is one-line only; the non-finite convention lives in selection.md / the method docstring, which is enough.

CI

Checks were still pending / in progress at review time (build + test matrix 3.9–3.13). No merge from this review.

Ship it once CI is green.

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review at c56fabc: still LGTM (COMMENT, since self-approve is blocked). This push only merges current main (3947aee, after #262 landed). The sole conflict was CHANGELOG.md, resolved by keeping both Fixed entries, so the branch diff against main is otherwise unchanged. tests/test_selection_hgm.py: 15 passed locally. Exact-head CI (build + 3.9–3.13) is green, the PR is MERGEABLE, the Codex review on befeca9 finished with no findings, and there is no open blocking feedback.

@Birfy Birfy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-checked after merging main (924c25c, includes #272) at 42a9cd3. The only conflict was CHANGELOG.md (### Fixed): both entries are kept, the #280 CladeThompson.tau entry above the #271 runstore entry. No code conflicts. tests/test_selection_hgm.py and tests/test_selection.py pass locally on the merge commit, and CI is fully green (build + 3.9–3.13). No unresolved review threads. LGTM, still merge-ready.

@Birfy

Birfy commented Oct 16, 2026

Copy link
Copy Markdown
Owner Author

Merged main (751b8dd) into this branch — CHANGELOG-only conflict resolved (kept #280 + #286 Fixed entries). Head 669a196. tests/test_selection_hgm.py 15 passed locally.

LGTM once CI is green.

@Birfy
Birfy enabled auto-merge (squash) October 16, 2026 04:51
Birfy added 3 commits October 16, 2026 13:29
Keep both CHANGELOG Fixed bullets (#280 CladeThompson.tau + main Fixed entries).
Stop editing CHANGELOG.md so open PRs no longer conflict on Unreleased.
@Birfy
Birfy merged commit b775322 into main Oct 16, 2026
7 checks passed
@Birfy
Birfy deleted the fix/issue-280-clade-thompson-tau branch October 16, 2026 06:20
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.

selection.CladeThompson: tau() treats +inf/NaN budget as exhausted and overflows on small fractions; constructor accepts non-finite knobs

1 participant