fix(mmle): wrap stale marginal ABI TypeError as RuntimeError - #933
Merged
seonghobae merged 17 commits intoAug 17, 2026
Conversation
A version-1 fit_marginal callable that rejects the current keyword contract now raises the package-owned ABI RuntimeError instead of leaking TypeError, and ownership tests inject the incomplete core so the fail-closed path does not depend on a compiled extension. Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Document the fail-closed RuntimeError for a version-matched stale fit_marginal keyword signature in Unreleased. Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
State that rust/auto marginal MMLE requires a matching MARGINAL_CAPABILITY_VERSION and never falls back to NumPy, with the Jeon et al. (2021) APA 7 citation on the estimator docstring. Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Contributor
Author
There was a problem hiding this comment.
Review: #933 head 094616e7
This successor closes the residual on #823 59332c93. After MARGINAL_CAPABILITY_VERSION == 1 and a callable fit_marginal, a stale keyword signature is now raised as the package-owned ABI RuntimeError (with causal chaining) and does not leak TypeError or enter fit_marginal_numpy.
No merge-blocking source defect on this head.
What was checked
python/fast_mlsirm/fit.pyfail-closed import, integer capability gate, callable gate, andexcept TypeErrorwrap around the native call.- Rust export of
MARGINAL_CAPABILITY_VERSION = 1next to the existingfit_marginalkeyword contract (pop_kind, anchors, covariates, zero-inflation). - Ownership tests inject the incomplete / stale
_coreviafast_mlsirm._core(honored byfrom . import _core). LocalPYTHONPATH=python pyteston the three new files: 9 passed, 1 skipped (test_compiled_rust_core_exports_current_marginal_capabilitywithout a compiled extension; CI builds the extension). backend="auto"is still fail-closed atresolve_backendwhen_coreis missing; the new auto test covers the production path once it has already resolved to rust.
Not blocking (do not open a competing MMLE PR)
- The
TypeErrorhandler is broader than unexpected-keyword failures. That is acceptable fail-closed behavior; the original exception remains on__cause__. - A version-1 callable that accepts the keywords but returns an incomplete dict can still leak
KeyErrorafter the call. Out of scope for this wrap. - Pre-existing: Rust
fit_marginalacceptssinglefreewhile the invalid-pop_kinderror text omits it. Not introduced here.
Next action
- Mark this draft ready for review once required checks are green on this exact SHA (
094616e7454fbec8241ada1405f06306f5dfd4ad). - Get a non-author approval. This automation will not approve or merge its own lineage.
- Merge #933, then close #823 as superseded. Do not merge #823.
- Do not open another marginal-MMLE ABI PR while this is the landing vehicle.
Sent by Cursor Automation: Fix Issues
seonghobae
marked this pull request as ready for review
August 17, 2026 04:20
Contributor
Author
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
seonghobae
approved these changes
Aug 17, 2026
seonghobae
enabled auto-merge (squash)
August 17, 2026 04:20
seonghobae
deleted the
cursor/bc-fdce5e1e-163c-4424-9d96-e5213933ebe1-8551
branch
August 17, 2026 04:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Scope
Close the residual fail-closed hole on #823: a version-matched
fit_marginalcallable that rejects the current keyword contract must raise the package-owned ABIRuntimeError, never a leakedTypeErrorand never NumPy production arithmetic.Test-first lineage
#823 already rejects missing, malformed, stale, and future
MARGINAL_CAPABILITY_VERSIONbefore dispatch. Review of head59332c93found that aftercapability == 1andcallable(fit_marginal), onlyValueErrorwas wrapped. A stale keyword signature still leakedTypeError.Implemented GREEN
TypeErrorfrom nativefit_marginaland raise the existing ABIRuntimeErrorwith causal chaining.fit(..., estimator="mmle", model="MLS2PLM")regression that injects a version-1 callable raising keywordTypeErrorand asserts no NumPy fallback.fit._MARGINAL_CAPABILITY_VERSION.Boundaries
No NumPy production fallback, no formula redesign, and no gate weakening. Prefer this branch over merging #823 as-is.
Next action
Review this successor, wait for exact-head required checks, then merge this PR and close #823 as superseded.