feat(combinatorics): verify submitted P-recursive tables - #1285
Conversation
54c3bdf to
d8e4786
Compare
Refresh #1285 while preserving its finite-table semantic scope.
Coverage ReportTotal coverage: 78% (threshold: 50%) |
AttributionThe exact caller-supplied P-recursive table verification originated in #1182, authored by @yuelgrace1810-ops. This PR ports that semantic work onto the current typed ownership model and preserves that authorship. |
|
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 402c28a944
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if polynomial[-1].as_fraction() == 0: | ||
| raise ValueError("coefficient polynomial must omit trailing zero terms") |
There was a problem hiding this comment.
Accept the canonical zero coefficient polynomial
Allow a singleton zero polynomial ([{"num":"0","den":"1"}]) and reject a trailing zero only when the vector has multiple coefficients. Zero lag polynomials are valid in sum_j p_j(n)a_(n-j)=0—for example, a_n-a_(n-2)=0 requires p_1=0—but this validator rejects every such table even though the existing P-recursive contract and independent checker both accept [0], silently narrowing the advertised recurrence domain.
AGENTS.md reference: AGENTS.md:L55-L58
Useful? React with 👍 / 👎.
| value, | ||
| max_digits=MAX_COMBINATORICS_INPUT_RATIONAL_DIGITS, | ||
| label="submitted recurrence table value", | ||
| ) | ||
| return self |
There was a problem hiding this comment.
Validate the complete ledger against the inline size limit
Add an aggregate result-size check before accepting the request, or publish this result durably. A maximum-order, maximum-degree table with many pairwise-coprime bounded denominators can produce hundreds of individually valid residuals whose combined encoding exceeds the 10 MiB InlinePublication limit; this validator checks only each input rational, so the producer performs the expensive complete replay and then fails during publication instead of rejecting the request up front.
AGENTS.md reference: AGENTS.md:L150-L153
Useful? React with 👍 / 👎.
| polynomials = tuple( | ||
| tuple(value.as_fraction() for value in polynomial) | ||
| for polynomial in request.coefficient_polynomials | ||
| ) | ||
| values = tuple(value.as_fraction() for value in request.values) |
There was a problem hiding this comment.
Expose computational rationals from the native API
Keep CanonicalRational conversion in the capability adapter and make the public jacobian.math.combinatorics kernel accept and return computational values such as Fraction-based domain values. As exported here, native callers must construct Pydantic wire requests containing decimal strings, and the function immediately converts those strings to Fraction before converting results back to wire models, making the supported native API itself a wire boundary rather than a computational API.
AGENTS.md reference: AGENTS.md:L92-L96
Useful? React with 👍 / 👎.
| __all__ = [ | ||
| "IndexedRecurrenceResidual", | ||
| "PolynomialCoefficientRecurrenceTableRequest", | ||
| "PolynomialCoefficientRecurrenceTableResult", | ||
| "recurrence_table_residuals", |
There was a problem hiding this comment.
Register the new public combinatorics module
Add combinatorics to jacobian.math.__all__ and to the public namespace/import-isolation manifests. This package declares a supported public surface, but import jacobian.math does not expose it like the other domain modules, and the unchanged PUBLIC_API table means its symbols and isolation behavior receive none of the required API checks.
AGENTS.md reference: AGENTS.md:L65-L68
Useful? React with 👍 / 👎.
Summary
Supersedes #1182 with a post-#1276 typed semantic port.
jacobian.math.combinatoricsfor complete caller-supplied rational tables;sum_j p_j(n) a_(n-j)=0without generating or repairing terms;fractions.Fraction.Ownership
The math layer owns the finite table and residual semantics. The combinatorics domain publishes a thin
OperationSpecand owns the checker declaration. The existing clean-process recurrence checker independently rebuilds the residual ledger.The typed value contains no backend, assurance, workflow, or infinite-recurrence claim. Finite-table verification establishes only the exact supplied table and relation.
Validation
The branch is based directly on
195c4c1ddcb836206fcc759d602d3cf77eb2d7cf. Its port workflow compiled all changed source/test files and removed itself before committing. Tests cover a valid factorial table, a corrupted final term, and a forged success result.Credit
This post-#1276 port carries forward the original P-recursive table-verification work in #1182 by @yuelgrace1810-ops. Their investigation and implementation work are the basis for this replacement.