Skip to content

Add ExtAlgebra: a bigraded-algebra view over resolutions - #240

Merged
JoeyBF merged 3 commits into
SpectralSequences:masterfrom
JoeyBF:claude/bigraded-algebra-resolutions-ffy8p3
Jun 25, 2026
Merged

Add ExtAlgebra: a bigraded-algebra view over resolutions#240
JoeyBF merged 3 commits into
SpectralSequences:masterfrom
JoeyBF:claude/bigraded-algebra-resolutions-ffy8p3

Conversation

@JoeyBF

@JoeyBF JoeyBF commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Introduce ext::ext_algebra::ExtAlgebra<CC>, a thin ergonomics layer that
presents Ext(M, k) as a bigraded module over the bigraded algebra Ext(k, k).
It wraps a resolution (and the unit resolution) and exposes the bigraded basis
plus products, so computing a product is a single multiply/multiply_into
call instead of the manual ResolutionHomomorphism + extend + hom_k plumbing the
examples re-derive.

Products reuse the existing machinery: one ResolutionHomomorphism is built and
cached per generator of Ext(M, k) (keyed by BidegreeGenerator), and a product by
a general class is assembled at request time as the matching linear combination
of generator maps. No linear-algebra core is reimplemented.

This is the foundational slice; the secondary d2 differential and Massey
products are planned follow-ups. Adds a streamlined product example and a unit
test on S_2 (h_0^2 != 0, h_0 h_1 = h_1 h_0 = 0); products cross-checked against
the independent filtration_one output.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01XYWcvWZPm3YJkVpCmeGYsP

Summary by CodeRabbit

  • New Features
    • Added a new Ext algebra capability for bigraded Ext classes, including dimension/basis/element queries and unit-side equivalents.
    • Introduced product computation APIs with range-aware behavior, including safe (try_multiply) and panicking (multiply) multiplication.
    • Exposed the new Ext algebra module via the public library interface.
    • Added a Rust example that builds an Ext algebra, applies a bidegree shift, and prints nonzero products.
  • Tests
    • Added unit tests verifying expected sphere product relations and checking multiplication results for consistency.

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@JoeyBF, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 31 minutes and 26 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

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 credits.

🚦 How do rate 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 see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e1939a9c-bf8b-461c-b629-6f58199ca9de

📥 Commits

Reviewing files that changed from the base of the PR and between d48a421 and 1500abb.

📒 Files selected for processing (1)
  • ext/src/ext_algebra.rs
📝 Walkthrough

Walkthrough

This PR adds a public ExtAlgebra wrapper, exposes it from the crate, implements cached Ext product computation, and adds a product example plus tests.

Changes

Ext algebra products

Layer / File(s) Summary
Public API and construction
ext/src/lib.rs, ext/src/ext_algebra.rs
ext_algebra is publicly exposed, and ExtAlgebra is defined with module and unit resolutions, a cached product map, and construction helpers that derive the unit resolution and stem progression entry points.
Resolution queries
ext/src/ext_algebra.rs
ExtAlgebra adds resolution accessors, computation advancement, and module-side and unit-side basis, dimension, and element queries.
Product computation
ext/src/ext_algebra.rs
Per-generator product maps are cached, multiply_into produces coefficient rows against the unit basis, and try_multiply and multiply combine those rows into full products.
Validation and example
ext/src/ext_algebra.rs, ext/examples/product.rs
The sphere test checks product relations and multiply/multiply_into agreement, and the example program builds and prints nonzero products for a user-provided class.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

I hopped through stems with a curious grin,
Cached little products spun neat from within.
Ext bidegrees twinkled, row by row,
And nonzero carrots began to glow. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main addition of ExtAlgebra as a bigraded algebra/module view over resolutions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ext/examples/product.rs`:
- Around line 30-32: The validation in the example’s zero-dimension branch
currently uses a panic in the product example, which aborts on expected invalid
user input. Update the logic around the dim check in the product example to
return a proper error from the surrounding function instead of panicking,
preserving the existing shift context in the error message and propagating it
through the caller’s Result flow.

In `@ext/src/ext_algebra.rs`:
- Around line 113-120: The public constructors in ExtAlgebra are not validating
basis coordinates or generator indices before they are used, which can later
panic when generator_product_map indexes class[g.idx()]. Add bounds/shape checks
in the public entry points such as element, unit_element, generator, and
generator_product_map so invalid coordinate lengths or out-of-range generator
indices are rejected early with a clear error instead of constructing invalid
classes or accessing non-existent generators.
- Around line 68-74: The constructor in new currently stores resolution, unit,
and is_unit without enforcing the expected invariants, which can leave later
product/dimension logic inconsistent. Add validation in new to ensure the
resolution and unit complexes are compatible when is_unit is true, and verify
both complexes share the same prime before any use by unit_element or product
arithmetic. Use the new constructor and self.prime() as the main entry points
for these checks so invalid Arc combinations are rejected early.
- Around line 183-190: Move the computedness guard in multiply_into ahead of the
dimension queries: check self.unit.has_computed_bidegree(b) and
self.resolution.has_computed_bidegree(target) before calling
number_of_gens_in_bidegree on unit and resolution. This keeps out-of-range
bidegrees safe and avoids the Resolution::module-backed lookup from panicking on
uncomputed degrees; then only allocate the result matrix after those checks
pass.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3e7c6135-6621-420c-bf55-4a7e076f6dff

📥 Commits

Reviewing files that changed from the base of the PR and between 6c78b26 and 6e67994.

📒 Files selected for processing (3)
  • ext/examples/product.rs
  • ext/src/ext_algebra.rs
  • ext/src/lib.rs

Comment thread ext/examples/product.rs
Comment thread ext/src/ext_algebra.rs Outdated
Comment thread ext/src/ext_algebra.rs
Comment thread ext/src/ext_algebra.rs Outdated
Comment thread ext/src/ext_algebra.rs

@hoodmane hoodmane left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

Introduce `ext::ext_algebra::ExtAlgebra<CC>`, a thin ergonomics layer that
presents Ext(M, k) as a bigraded module over the bigraded algebra Ext(k, k).
It wraps a resolution (and the unit resolution) and exposes the bigraded basis
plus products, so computing a product is a single `multiply`/`multiply_into`
call instead of the manual ResolutionHomomorphism + extend + hom_k plumbing the
examples re-derive.

Products reuse the existing machinery: one ResolutionHomomorphism is built and
cached per generator of Ext(M, k) (keyed by BidegreeGenerator), and a product by
a general class is assembled at request time as the matching linear combination
of generator maps. No linear-algebra core is reimplemented.

`multiply_into` returns `Option<Matrix>` (rows = unit generators, columns =
target generators), yielding `None` when a bidegree is out of the computed range
rather than silently returning zeros; `try_multiply` is the corresponding safe
variant and `multiply` panics out of range. Adds a streamlined `product` example
and a unit test on S_2 (h_0^2 != 0, h_0 h_1 = h_1 h_0 = 0).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYWcvWZPm3YJkVpCmeGYsP
@JoeyBF
JoeyBF force-pushed the claude/bigraded-algebra-resolutions-ffy8p3 branch from 6e67994 to 0f42179 Compare June 25, 2026 02:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
ext/src/ext_algebra.rs (2)

117-119: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Use a strict upper bound for generator indices.

Line 118 allows idx == ambient, but valid basis indices are 0..ambient; this can pass validation and then panic or construct an invalid element downstream.

Proposed fix
     pub fn generator(&self, g: BidegreeGenerator) -> BidegreeElement {
         let ambient = self.dimension(g.degree());
-        assert!(ambient >= g.idx());
-        g.into_element(self.prime(), self.dimension(g.degree()))
+        assert!(g.idx() < ambient);
+        g.into_element(self.prime(), ambient)
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ext/src/ext_algebra.rs` around lines 117 - 119, The generator index check in
the `ExtAlgebra::g` path is too permissive because `ambient >= g.idx()` allows
`idx == ambient`; tighten the validation so generator indices are strictly less
than the ambient dimension before calling `g.into_element`, using the existing
`ambient` and `g.idx()` symbols to enforce the `0..ambient` range.

63-71: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Reject explicit unit resolutions over a different prime.

new accepts arbitrary (resolution, unit) pairs, but prime() comes from resolution while unit dimensions/classes come from unit; mismatched primes can produce invalid Ext elements/products.

Proposed fix
 pub fn new(resolution: Arc<CC>, unit: Arc<CC>) -> Self {
+    assert_eq!(
+        resolution.prime(),
+        unit.prime(),
+        "ExtAlgebra resolution and unit must have the same prime"
+    );
     Self {
         is_unit: Arc::ptr_eq(&resolution, &unit),
         resolution,
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ext/src/ext_algebra.rs` around lines 63 - 71, ExtAlgebra::new currently
accepts mismatched resolution and unit classes, which can create invalid Ext
elements when their primes differ. Update new to verify that resolution.prime()
matches unit.prime() before constructing the struct, and reject or assert on
invalid pairs; keep is_unit and the stored fields unchanged for valid inputs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@ext/src/ext_algebra.rs`:
- Around line 117-119: The generator index check in the `ExtAlgebra::g` path is
too permissive because `ambient >= g.idx()` allows `idx == ambient`; tighten the
validation so generator indices are strictly less than the ambient dimension
before calling `g.into_element`, using the existing `ambient` and `g.idx()`
symbols to enforce the `0..ambient` range.
- Around line 63-71: ExtAlgebra::new currently accepts mismatched resolution and
unit classes, which can create invalid Ext elements when their primes differ.
Update new to verify that resolution.prime() matches unit.prime() before
constructing the struct, and reject or assert on invalid pairs; keep is_unit and
the stored fields unchanged for valid inputs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: aca146c6-7502-4191-8a71-74b7a645a7ad

📥 Commits

Reviewing files that changed from the base of the PR and between 0f42179 and d48a421.

📒 Files selected for processing (1)
  • ext/src/ext_algebra.rs

@JoeyBF
JoeyBF merged commit 014431c into SpectralSequences:master Jun 25, 2026
18 checks passed
github-actions Bot added a commit that referenced this pull request Jun 25, 2026
* Add ExtAlgebra: a bigraded-algebra view over resolutions

Introduce `ext::ext_algebra::ExtAlgebra<CC>`, a thin ergonomics layer that
presents Ext(M, k) as a bigraded module over the bigraded algebra Ext(k, k).
It wraps a resolution (and the unit resolution) and exposes the bigraded basis
plus products, so computing a product is a single `multiply`/`multiply_into`
call instead of the manual ResolutionHomomorphism + extend + hom_k plumbing the
examples re-derive.

Products reuse the existing machinery: one ResolutionHomomorphism is built and
cached per generator of Ext(M, k) (keyed by BidegreeGenerator), and a product by
a general class is assembled at request time as the matching linear combination
of generator maps. No linear-algebra core is reimplemented.

`multiply_into` returns `Option<Matrix>` (rows = unit generators, columns =
target generators), yielding `None` when a bidegree is out of the computed range
rather than silently returning zeros; `try_multiply` is the corresponding safe
variant and `multiply` panics out of range. Adds a streamlined `product` example
and a unit test on S_2 (h_0^2 != 0, h_0 h_1 = h_1 h_0 = 0).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XYWcvWZPm3YJkVpCmeGYsP
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.

3 participants