Skip to content

refactor(repair)!: box Delaunay repair flip errors#407

Merged
acgetchell merged 2 commits into
mainfrom
refactor/384-repair-error-boxing
May 20, 2026
Merged

refactor(repair)!: box Delaunay repair flip errors#407
acgetchell merged 2 commits into
mainfrom
refactor/384-repair-error-boxing

Conversation

@acgetchell
Copy link
Copy Markdown
Owner

  • Box DelaunayRepairError::Flip sources while preserving typed FlipError inspection through From<FlipError> and Error::source.
  • Update repair and construction mappings for the named boxed variant.
  • Cover clone and source behavior for wrapped linear-algebra errors.

BREAKING CHANGE: DelaunayRepairError::Flip is now a named variant with source: Box<FlipError> instead of the tuple variant Flip(FlipError). Callers that pattern-match this variant must use Flip { source } or construct it through DelaunayRepairError::from.

Closes #384

- Box `DelaunayRepairError::Flip` sources while preserving typed `FlipError`
  inspection through `From<FlipError>` and `Error::source`.
- Update repair and construction mappings for the named boxed variant.
- Cover clone and source behavior for wrapped linear-algebra errors.

BREAKING CHANGE: `DelaunayRepairError::Flip` is now a named variant with
`source: Box<FlipError>` instead of the tuple variant `Flip(FlipError)`.
Callers that pattern-match this variant must use `Flip { source }` or
construct it through `DelaunayRepairError::from`.

Closes #384
@acgetchell acgetchell self-assigned this May 20, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: a0527668-ae4a-4ae7-88e7-3c6b214939e5

📥 Commits

Reviewing files that changed from the base of the PR and between f839f6f and 739e422.

📒 Files selected for processing (1)
  • src/core/algorithms/flips.rs

Walkthrough

DelaunayRepairError::Flip is refactored from tuple-style Flip(FlipError) to struct-style Flip { source: Box }. All conversions, match sites, internal helpers, and tests are updated to construct via From and to inspect the inner FlipError via source.as_ref() or source() downcasts.

Changes

Error Enum Boxing Refactor

Layer / File(s) Summary
Core enum definition, docs, and conversions
src/core/algorithms/flips.rs
DelaunayRepairError::Flip changed to Flip { source: Box<FlipError> }. Documentation/examples updated. From<FlipError> for DelaunayRepairError now wraps the source in Box::new. Conversion to FlipNeighborRepairFailure updated to extract source_kind via source.as_ref(). Test-module import style adjusted.
Error-to-kind mapping and helper updates
src/core/algorithms/incremental_insertion.rs, src/delaunay/construction.rs
Mapping to DelaunayRepairErrorKind uses struct-style Flip { .. }. Internal helper is_geometric_repair_error changed from const fn to fn and now inspects boxed FlipError through source.as_ref() when delegating to is_geometric_flip_error.
Pattern matching updates in existing tests
src/core/algorithms/flips.rs, src/core/algorithms/incremental_insertion.rs, src/delaunay/construction.rs, src/delaunay/repair.rs, src/lib.rs, tests/prelude_exports.rs
Multiple unit tests updated to construct DelaunayRepairError via DelaunayRepairError::from(FlipError::...) and to match DelaunayRepairError::Flip { ref source } using source.as_ref() for underlying FlipError inspection.
New tests: boxing, size, and clone semantics
src/core/algorithms/flips.rs, src/geometry/matrix.rs, src/geometry/traits/coordinate.rs, src/lib.rs
New/adjusted tests verify From<FlipError> equality/inequality behavior, assert DelaunayRepairError is smaller than FlipError while still exposing the boxed FlipError via source()/downcast, and check clone semantics for several linear-algebra-wrapping errors (StackMatrixDispatchError::La, CoordinateConversionError::LinearAlgebraFailure, CircumcenterError::LinearAlgebraFailure).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related issues

  • #384: refactor: audit error clone semantics and repair error boxing policy — This PR implements the boxing policy change and adds clone-preservation tests covering the issue's scope.
  • #406 — The PR's boxing and conversion updates directly align with discussions about FlipError boxing and enum-size policy referenced in this issue.

Poem

🐰 A stack grows lighter when we tuck errors tight,
Boxed and still visible, everything's just right.
From tuple to struct, the inner truth stays near,
Clone and downcast whisper, "Yes, I'm still here!"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor(repair)!: box Delaunay repair flip errors' directly and specifically describes the main change—boxing the DelaunayRepairError::Flip variant—and uses standard conventional commit format.
Description check ✅ Passed The description clearly outlines all major changes: boxing DelaunayRepairError::Flip, preserving typed inspection, updating mappings, adding tests, and documenting the breaking change. It is directly related to the changeset.
Linked Issues check ✅ Passed The PR successfully addresses all objectives from #384: boxes DelaunayRepairError::Flip sources [flips.rs], preserves typed FlipError inspection via From trait and Error::source, updates construction/repair mappings [incremental_insertion.rs, construction.rs, repair.rs], and adds clone/source tests for wrapped linear-algebra errors [matrix.rs, coordinate.rs, lib.rs]. Tests pass.
Out of Scope Changes check ✅ Passed All changes are directly related to boxing the DelaunayRepairError::Flip variant and updating dependent code paths. No unrelated features or refactoring outside the scope of #384 are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 100.00%.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/384-repair-error-boxing

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

@acgetchell acgetchell enabled auto-merge (squash) May 20, 2026 14:55
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 20, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

🟢 Coverage 93.42% diff coverage · +0.01% coverage variation

Metric Results
Coverage variation +0.01% coverage variation (-1.00%)
Diff coverage 93.42% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (71336b5) 62391 56471 90.51%
Head commit (739e422) 62454 (+63) 56536 (+65) 90.52% (+0.01%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#407) 76 71 93.42%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@coderabbitai coderabbitai Bot added rust Pull requests that update rust code breaking change geometry Geometry-related issues api labels May 20, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@src/core/algorithms/flips.rs`:
- Around line 4386-4395: The test
test_delaunay_repair_error_boxes_large_flip_sources incorrectly expects
Error::source() to expose a Box<FlipError>; change the downcast to look for
FlipError directly (use downcast_ref::<FlipError>()) because #[source] on a
Box<T> returns &T; update the assertion that extracts the source accordingly
while keeping the Flip { source } variant handling unchanged.
🪄 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: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 89115868-4a35-4c12-82e6-1c244dc21246

📥 Commits

Reviewing files that changed from the base of the PR and between 71336b5 and f839f6f.

📒 Files selected for processing (8)
  • src/core/algorithms/flips.rs
  • src/core/algorithms/incremental_insertion.rs
  • src/delaunay/construction.rs
  • src/delaunay/repair.rs
  • src/geometry/matrix.rs
  • src/geometry/traits/coordinate.rs
  • src/lib.rs
  • tests/prelude_exports.rs

Comment thread src/core/algorithms/flips.rs
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 92.64706% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.51%. Comparing base (71336b5) to head (739e422).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/core/algorithms/flips.rs 93.54% 2 Missing ⚠️
src/delaunay/repair.rs 66.66% 2 Missing ⚠️
src/delaunay/construction.rs 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #407      +/-   ##
==========================================
+ Coverage   90.50%   90.51%   +0.01%     
==========================================
  Files          71       71              
  Lines       62187    62244      +57     
==========================================
+ Hits        56281    56340      +59     
+ Misses       5906     5904       -2     
Flag Coverage Δ
unittests 90.51% <92.64%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Add coverage for converting a boxed `DelaunayRepairError::Flip` source into
`FlipNeighborRepairFailure::Flip` while preserving the derived flip failure kind.
@acgetchell acgetchell merged commit 1789ceb into main May 20, 2026
20 checks passed
@acgetchell acgetchell deleted the refactor/384-repair-error-boxing branch May 20, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api breaking change geometry Geometry-related issues rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: audit error clone semantics and repair error boxing policy

1 participant