Skip to content

fix(fitstats): fail closed for S-X2 and person fit - #771

Merged
seonghobae merged 1 commit into
mainfrom
fix/fitstats-sx2-person-rust-required
Aug 11, 2026
Merged

fix(fitstats): fail closed for S-X2 and person fit#771
seonghobae merged 1 commit into
mainfrom
fix/fitstats-sx2-person-rust-required

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Buyer-visible numerical-ownership defect

Issue #627 requires ordinary public fit-statistics results to have one Rust/PyO3 numerical owner. Protected main previously let s_x2() and person_fit() drop into substantial Python/NumPy numerical implementations when the compiled core or required entrypoint was absent; s_x2() additionally bypassed its existing Rust entrypoint whenever prior_mean was supplied even though the native API accepts the prior vector.

GREEN contract

  • Public s_x2() / person_fit() require s_x2_stat / person_fit_stat and fail closed with RuntimeError("fit statistics require the compiled Rust core") when the core is missing or incomplete.
  • Nonzero trait prior_mean for S-X² is validated and transported to native s_x2_stat (no Python _icc_grid fallback).
  • NumPy bodies retained as _s_x2_python_reference / _person_fit_python_reference for parity/tests only.

Evidence

  • Local: pytest tests/test_fitstats_rust_ownership_failclosed.py tests/test_fitstats_rust_required.py tests/test_fitstats.py → 32 passed (Python 3.14)
  • Changelog fragment docs/changelog.d/771-fitstats-sx2-person-rust-required.md rendered into Unreleased

Product gates

Merge when python (aggregate + 3.12/3.14) + rust + package + fuzz are green.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@seonghobae, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ada7b0a2-0ef7-404b-8fb1-69a2d6532a84

📥 Commits

Reviewing files that changed from the base of the PR and between 02fe62d and 009a09c.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • docs/changelog.d/627-fitstats-sx2-person-rust-required.md
  • docs/doctoring/fitstats_sx2_person_rust_required.md
  • python/fast_mlsirm/fitstats.py
  • tests/test_fitstats.py
  • tests/test_fitstats_rust_ownership_failclosed.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

@opencode-agent address

Bounded single-writer handoff for Draft #771. Immediately before writing, refetch exact source head 2993ea4ecda12954d2b4d6d90a707c33eb006c03, independently resolve protected main (currently a891f843e9fb1f67688d38da759e80abb1e5ca44), and inspect this PR for any newer writer evidence. Abort source writes if the branch/base moved incompatibly or another writer is active; do not force-push/rebase or create another PR/workflow.

Preserve the intentional fail-first commit. Run the focused ownership tests first and confirm the RED is at the forbidden Python numerical boundaries, not setup. Then implement the smallest GREEN in python/fast_mlsirm/fitstats.py only as needed:

  1. Ordinary public s_x2() must require compatible _core.s_x2_stat and fail closed with the existing fit-stat Rust-required error before _icc_grid/Lord-Wingersky/Python statistic arithmetic when absent.
  2. Remove the prior_mean is None native-dispatch restriction. Validate/broadcast the declared prior mean to the actual trait dimension and pass it to s_x2_stat with the existing unit prior-SD contract; do not silently fall back to Python for a nonzero prior.
  3. Ordinary public person_fit() must require compatible _core.person_fit_stat and fail closed before Python probability/log-likelihood/l_z arithmetic when absent.
  4. Do not delete explicit private/reference helpers merely to satisfy a source-string rule; make them non-selectable by ordinary public production dispatch. Preserve formulas, missingness, BH/effect-size semantics, l_z/l_z* interpretation and stable errors.
  5. Add focused prior-mean public↔Rust parity/shape/finiteness coverage if the current test does not fully prove transport, then run existing S-X2/person-fit/reference/parity tests and changed-branch coverage.
  6. Add APA-linked doctoring and a correctly structured changelog fragment (# title + ## Fixed/Changed); use the repository changelog renderer and --check rather than hand-editing generated blocks.

After GREEN, run focused + full applicable Python/Rust/PyO3/package/security/SAST/fuzz gates on one unchanged head and update the PR with exact evidence. Keep Draft while any gate is non-passing. Do not change unrelated fit statistics, dependencies, workflows, credentials, version/release state, GPU behavior, or canonical architecture authority.

Require compiled Rust entrypoints for public s_x2 and person_fit, always
dispatch trait prior_mean through native S-X2, and remove Python/NumPy
numerical fallbacks so missing cores cannot silently change results.
@seonghobae
seonghobae force-pushed the fix/fitstats-sx2-person-rust-required branch from 2993ea4 to 009a09c Compare August 11, 2026 20:05
@seonghobae
seonghobae marked this pull request as ready for review August 11, 2026 20:05
@seonghobae
seonghobae merged commit cbe8ce6 into main Aug 11, 2026
18 of 19 checks passed
@seonghobae
seonghobae deleted the fix/fitstats-sx2-person-rust-required branch August 11, 2026 20:05
seonghobae added a commit that referenced this pull request Aug 12, 2026
#771 already fails closed for public S-X2 and person-fit; keep the cov-C
NumPy-fallback suite aligned so product CI does not re-execute removed
reference bodies.
seonghobae added a commit that referenced this pull request Aug 12, 2026
* fix(fitstats): fail closed for M2 and infit/outfit ownership

Require compiled m2_stat and infit_outfit_stat for ordinary public calls,
retarget NumPy-fallback coverage, and sync documentation maturity vocabulary
plus shipped capability rows for parallel bounds and dark-mode accents.

* docs: scope protected rotation status evidence

* test(fitstats): retarget S-X2/person-fit cov fallbacks fail-closed

#771 already fails closed for public S-X2 and person-fit; keep the cov-C
NumPy-fallback suite aligned so product CI does not re-execute removed
reference bodies.

* fix(multilevel): reject hostile numeric conversion hooks (#790)

Fail closed on float subclasses for membership weights and AR(1)
coefficients so hostile __float__ callbacks cannot leak into contract
errors. Stacked on fitstats/docs fail-closed base for product CI.
seonghobae added a commit that referenced this pull request Aug 12, 2026
* fix(fitstats): fail closed for M2 and infit/outfit ownership

Require compiled m2_stat and infit_outfit_stat for ordinary public calls,
retarget NumPy-fallback coverage, and sync documentation maturity vocabulary
plus shipped capability rows for parallel bounds and dark-mode accents.

* fix(automation): retire competing hourly review-repair caller

Remove the repository-local scheduled caller that lacks startup acceptance
and conflicts with organization single-writer continuous-execution
governance (ADR-0013).

* docs: scope protected rotation status evidence

* test(fitstats): retarget S-X2/person-fit cov fallbacks fail-closed

#771 already fails closed for public S-X2 and person-fit; keep the cov-C
NumPy-fallback suite aligned so product CI does not re-execute removed
reference bodies.

---------

Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
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