Skip to content

refactor(flips)!: box nested FlipError payloads (#406)#435

Merged
acgetchell merged 3 commits into
mainfrom
refactor/406-box-flip-errors
Jun 7, 2026
Merged

refactor(flips)!: box nested FlipError payloads (#406)#435
acgetchell merged 3 commits into
mainfrom
refactor/406-box-flip-errors

Conversation

@acgetchell

Copy link
Copy Markdown
Owner
  • Box nested typed FlipError payloads and the inserted-simplex witness while keeping scalar and key diagnostics inline.
  • Preserve typed inspection through Error::source, reason.as_ref(), and source.as_ref() for flip context, predicate, adjacency, simplex, neighbor-wiring, and mutation failures.
  • Add repository Semgrep checks for the boxed-source policy and document the tooling rationale.
  • Preserve padded changelog category headings during post-processing.

BREAKING CHANGE: FlipError variants carrying nested typed errors or inserted-simplex witnesses now store those payloads in Box, so direct constructors and pattern matches must use boxed payloads and inspect them through as_ref().

Closes #406

- Box nested typed `FlipError` payloads and the inserted-simplex witness while keeping scalar and key diagnostics inline.
- Preserve typed inspection through `Error::source`, `reason.as_ref()`, and `source.as_ref()` for flip context, predicate, adjacency, simplex, neighbor-wiring, and mutation failures.
- Add repository Semgrep checks for the boxed-source policy and document the tooling rationale.
- Preserve padded changelog category headings during post-processing.

BREAKING CHANGE: `FlipError` variants carrying nested typed errors or inserted-simplex witnesses now store those payloads in `Box`, so direct constructors and pattern matches must use boxed payloads and inspect them through `as_ref()`.

Closes #406
@acgetchell acgetchell self-assigned this Jun 7, 2026
@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

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: 36ed7a30-604f-4d36-a252-b02a23c26250

📥 Commits

Reviewing files that changed from the base of the PR and between ba83229 and 862766d.

📒 Files selected for processing (3)
  • .codecov.yml
  • justfile
  • src/delaunay/construction.rs
✅ Files skipped from review due to trivial changes (1)
  • .codecov.yml

Walkthrough

FlipError variants were converted to use boxed typed payloads and marked as sources; From impls and callers were updated to box reasons; runtime classification and many tests match boxed inner errors via reason.as_ref(); Semgrep rules, fixtures, justfile wiring, and docs were added; changelog heading parsing and codecov target adjusted.

Changes

FlipError Payload Boxing

Layer / File(s) Summary
FlipError enum contract and boxing policy
src/core/algorithms/flips.rs
FlipError variants and docs now box large/nested typed payloads (adjacency, context, predicate, neighbor wiring, mutation, simplex witness) and expose them as #[source] where appropriate.
Error construction and From conversions
src/core/algorithms/flips.rs
Construction sites now return typed error .into() values and updated From<...> for FlipError impls wrap typed payloads in Box.
Runtime classification and matching
src/core/algorithms/flips.rs, src/delaunay/construction.rs
Classification and failure-kind mapping inspect boxed reasons with reason.as_ref(); is_geometric_flip_error converted to non-const fn with equivalent pattern logic.
Behavioral tests updated for boxed shapes
src/core/algorithms/flips.rs, src/delaunay/construction.rs
Tests updated to construct boxed reasons (Box::new(...)) and to pattern-match boxed payloads via ref reason + reason.as_ref() across mapping, rollback, and dynamic rejection tests.
Sizing and downcasting tests
src/core/algorithms/flips.rs
New assertions check size/alignment invariants and that nested boxed typed payloads are recoverable via Error::source() downcasting; test imports adjusted for mem::size_of/align_of.

Semgrep Rule Enforcement & Tooling

Layer / File(s) Summary
Semgrep rules for payload boxing enforcement
semgrep.yaml
Added delaunay.rust.flip-error-nested-payloads-boxed and delaunay.rust.flip-error-boxed-payloads-are-sources to detect unboxed nested payloads and missing #[source] on boxed fields.
Test fixture with error enum definitions
tests/semgrep/src/project_rules/rust_style.rs
Added FlipContextError, SimplexValidationError, and a representative FlipError with boxed payloads and #[source]/#[from] annotations to validate rule matching.
Semgrep test recipe and cleanup
justfile
semgrep-test now creates per-fixture state_dir/state_root, symlinks semgrep.yaml per fixture, sets SEMGREP_SEND_METRICS=off, and runs semgrep scan --strict --config <config> <fixture> per fixture; cleanup updated.
Tooling docs
docs/dev/tooling-alignment.md
Documented repository-owned Semgrep enforcement for FlipError layout policy (inline scalars/keys, boxed nested typed payloads).

Changelog & Coverage

Layer / File(s) Summary
Boundary parsing normalization and test coverage
scripts/postprocess_changelog.py, scripts/tests/test_postprocess_changelog.py
ATX heading detection now trims matched titles and returns False on non-matches; added test ensuring "### Fixed ###" preserves category heading normalization.
Patch coverage target
.codecov.yml
Patch coverage target increased from 50% to 70%.

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • acgetchell/delaunay#407: Boxes DelaunayRepairError flip wrapper and updates source traversal logic; closely related to this PR's FlipError boxing and source handling.
  • acgetchell/delaunay#363: Refactors flip failure taxonomy and FlipError→failure-kind conversions that interact with the boxed payload changes here.
  • acgetchell/delaunay#391: Modifies FlipContextError variants used inside FlipError; overlaps with the boxed FlipContextError treatment.

"🐰 I boxed my errors, snug and tight,
So sources gleam in error-light.
Tests updated, semgrep nods with glee,
No hidden reasons hiding from me,
Hoppity hop — clean traces in sight!"

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: boxing nested FlipError payloads, which is the primary refactoring across multiple files.
Description check ✅ Passed The description is directly related to the changeset, detailing the boxed payloads, preservation of typed inspection, Semgrep checks, and breaking changes.
Linked Issues check ✅ Passed The PR successfully addresses all coding objectives from #406: boxed nested typed payloads while preserving scalars inline, typed inspection through Error::source and as_ref(), repository Semgrep enforcement, updated tests/docs, and measured size improvements with justified policy.
Out of Scope Changes check ✅ Passed All changes are within scope: FlipError boxing (core objective), changelog postprocessing normalization (supporting doc infrastructure), Semgrep rules (policy enforcement), updated tests and construction logic, and Codecov threshold raise (CI hardening for policy validation).
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/406-box-flip-errors

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

@acgetchell acgetchell enabled auto-merge (squash) June 7, 2026 01:32
@codacy-production

codacy-production Bot commented Jun 7, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

🟢 Coverage 83.03% diff coverage · +0.03% coverage variation

Metric Results
Coverage variation +0.03% coverage variation (-1.00%)
Diff coverage 83.03% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (289b9b7) 62863 56884 90.49%
Head commit (862766d) 63058 (+195) 57077 (+193) 90.52% (+0.03%)

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 (#435) 277 230 83.03%

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 Jun 7, 2026

@coderabbitai coderabbitai Bot 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.

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 13776-13783: The test test_flip_error_boxes_nested_typed_payloads
uses ABI-dependent byte-size assertions on FlipError (size_of::<FlipError>() <=
48 and size_of::<Result<(), FlipError>>() == size_of::<FlipError>()); change
these to target-agnostic checks: remove hardcoded byte expectations and either
assert structural properties (e.g., that Result<(), FlipError> has the same
alignment/representation intent) or gate exact-size assertions behind
cfg(target_arch/target_pointer_width) so CI platforms don't fail; update the
test to reference FlipError and Result<(), FlipError> and use
platform-conditional checks or loosened bounds instead of fixed 48-byte
assertions.
🪄 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: 9020ab7e-fff5-4c0d-aa65-32b64b574297

📥 Commits

Reviewing files that changed from the base of the PR and between 289b9b7 and 0743aa2.

📒 Files selected for processing (8)
  • docs/dev/tooling-alignment.md
  • scripts/postprocess_changelog.py
  • scripts/tests/test_postprocess_changelog.py
  • semgrep.yaml
  • src/core/algorithms/flips.rs
  • src/delaunay/construction.rs
  • src/delaunay/insertion.rs
  • tests/semgrep/src/project_rules/rust_style.rs

Comment thread src/core/algorithms/flips.rs Outdated
@codecov

codecov Bot commented Jun 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.03249% with 47 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.50%. Comparing base (289b9b7) to head (862766d).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/core/algorithms/flips.rs 81.52% 46 Missing ⚠️
src/delaunay/insertion.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #435      +/-   ##
==========================================
+ Coverage   90.48%   90.50%   +0.02%     
==========================================
  Files          71       71              
  Lines       62653    62848     +195     
==========================================
+ Hits        56689    56882     +193     
- Misses       5964     5966       +2     
Flag Coverage Δ
unittests 90.50% <83.03%> (+0.02%) ⬆️

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

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

- Isolate Semgrep settings state from generated rule-test config temp dirs.
- Replace fixed FlipError byte-size expectations with target-agnostic layout checks.
@coderabbitai coderabbitai Bot added the documentation Improvements or additions to documentation label Jun 7, 2026
- Raise the Codecov patch coverage target to 70%.
- Run Semgrep fixture tests with isolated per-fixture state so Windows CI avoids shared settings-file races.
- Cover boxed simplex-creation repair errors so geometric degeneracies remain soft-fail eligible while duplicate vertices stay hard failures.
@acgetchell acgetchell merged commit 2f310d9 into main Jun 7, 2026
22 checks passed
@acgetchell acgetchell deleted the refactor/406-box-flip-errors branch June 7, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api breaking change documentation Improvements or additions to documentation 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 FlipError size and boxing policy

1 participant