Skip to content

refactor: type repair diagnostics and harden invariants (#332)#352

Merged
acgetchell merged 4 commits intomainfrom
refactor/332-repair-diagnostics-invariants
Apr 29, 2026
Merged

refactor: type repair diagnostics and harden invariants (#332)#352
acgetchell merged 4 commits intomainfrom
refactor/332-repair-diagnostics-invariants

Conversation

@acgetchell
Copy link
Copy Markdown
Owner

  • Replace stringified flip-repair skip samples with typed diagnostic context.
  • Make vertex removal transactional across post-removal repair and orientation canonicalization.
  • Deprecate DelaunayTriangulation::as_triangulation_mut ahead of removal in v0.8.0.
  • Use scale-aware degeneracy checks for low-dimensional simplex and facet measures.
  • Add regression and property coverage for rollback behavior, typed diagnostics, and scaled valid measures.
  • Tolerate throughput formatting precision in benchmark baseline round-trip tests.

Closes #332

- Replace stringified flip-repair skip samples with typed diagnostic context.
- Make vertex removal transactional across post-removal repair and orientation canonicalization.
- Deprecate DelaunayTriangulation::as_triangulation_mut ahead of removal in v0.8.0.
- Use scale-aware degeneracy checks for low-dimensional simplex and facet measures.
- Add regression and property coverage for rollback behavior, typed diagnostics, and scaled valid measures.
- Tolerate throughput formatting precision in benchmark baseline round-trip tests.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

Walkthrough

Replaces stringified repair skip diagnostics with typed sample structs, introduces transactional remove_vertex with snapshot/rollback and repair-only TDS access (tds_mut_for_repair()), adds scale-aware degeneracy tolerances for geometric measures, and updates tests/docs to use direct set_*_data APIs and reflect repair semantics.

Changes

Cohort / File(s) Summary
Repair diagnostics typing
src/core/algorithms/flips.rs
Replace three Option<String> skip-sample fields with typed structs (InsertedSimplexSkipSample, RidgeMultiplicitySkipSample, MissingCellSkipSample), remove lazy FnOnce() -> String closures, update call sites and tests.
Transactional removal & repair caching
src/triangulation/delaunay.rs, src/triangulation/delaunayize.rs
Add tds_mut_for_repair(), snapshot/rollback around remove_vertex, preserve typed RepairOperationFailed { operation, source }, and ensure cache invalidation; adjust delaunayize fallback semantics and tests.
Geometry degeneracy & tests
src/geometry/util/measures.rs, tests/proptest_geometry.rs
Introduce scale-aware degeneracy_tolerance/is_zero_or_roundoff, remove Gram clamping in favor of validation, update volume/facet/inradius checks, and add scale-parameterized property tests.
API usage & docs/tests updates
src/core/tds.rs, src/triangulation/triangulation.rs, src/triangulation/builder.rs, README.md, docs/*, tests/*
Switch tests/docs to set_vertex_data/set_cell_data, clone triangulation in examples to avoid as_triangulation_mut() borrows, document transactional removal and typed diagnostics.
Delaunayize outcome semantics
src/triangulation/delaunayize.rs
When topology repair fails but fallback rebuild succeeds, preserve failure stats (topology_repair.succeeded remains false) and set used_fallback_rebuild = true; add regression test and rustdoc note.
Small tests & tooling tweaks
scripts/tests/test_benchmark_utils.py, tests/proptest_triangulation.rs, tests/delaunay_public_api_coverage.rs, tests/prelude_exports.rs
Loosen throughput assertions to tolerance-based checks, avoid mutable as_triangulation_mut() by cloning, add public-API integration tests exercising repair diagnostics.
Spatial hash grid test helpers
src/core/collections/spatial_hash_grid.rs
Add test-only HashGridIndexSnapshot and debug_snapshot() to provide deterministic internal-state snapshots for tests.
Crate comment / migration notes
src/lib.rs
Update crate-level migration notes to mention planned as_triangulation_mut() removal (comment-only).

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant DelaunayTriangulation as DT
    participant SnapshotStore as Snapshot
    participant TDS
    participant RepairEngine as Repair

    Caller->>DT: remove_vertex(key)
    DT->>Snapshot: take_snapshot(tds, insertion_state, spatial_index)
    DT->>TDS: tds_mut_for_repair() (invalidate caches)
    TDS->>Repair: perform_flip_repair(context)
    alt Repair succeeds
        Repair-->>TDS: success (mutated TDS)
        DT-->>Caller: Ok
    else Repair fails
        Repair-->>DT: DelaunayRepairError
        DT->>Snapshot: restore_snapshot()
        DT-->>Caller: Err(RepairOperationFailed { operation: VertexRemoval, source })
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 I hop through code with cautious feet,

Typed samples keep the logs neat,
When flips tumble I stitch the seam,
If fixes fail, I roll back the dream,
Tiny scales hum safe and sweet.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive While issue #332 focuses on typed diagnostics, the PR extends scope to transactional vertex removal, scale-aware degeneracy checks, and deprecation planning—all related enhancements that harden invariants and improve robustness beyond the core issue. Clarify whether expanded scope (transactional removal, scale-aware checks, deprecation) was intentional or should be split into separate focused PRs aligned with issue #332.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main refactoring: replacing stringified repair diagnostics with typed structures while hardening invariants across vertex removal and measure checks.
Description check ✅ Passed The description provides a clear, multi-point overview of the changes including typed diagnostics, transactional vertex removal, deprecation, scale-aware checks, test coverage, and benchmark tolerance adjustments.
Linked Issues check ✅ Passed The PR fully implements issue #332: stringified RepairDiagnostics fields are replaced with typed sample structs (InsertedSimplexSkipSample, RidgeMultiplicitySkipSample, MissingCellSkipSample), call sites across flip queue processing are updated, and tests verify typed semantics.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.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/332-repair-diagnostics-invariants

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@acgetchell acgetchell enabled auto-merge (squash) April 29, 2026 02:58
@coderabbitai coderabbitai Bot added enhancement New feature or request rust Pull requests that update rust code geometry Geometry-related issues api topology labels Apr 29, 2026
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 29, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 14 complexity

Metric Results
Complexity 14

View in Codacy

🟢 Coverage 94.01% diff coverage · +0.72% coverage variation

Metric Results
Coverage variation +0.72% coverage variation (-1.00%)
Diff coverage 94.01% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (fea5898) 50908 45309 89.00%
Head commit (a95c610) 51492 (+584) 46199 (+890) 89.72% (+0.72%)

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 (#352) 802 754 94.01%

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.

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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/triangulation/delaunay.rs`:
- Around line 8169-8207: The test
test_remove_vertex_rolls_back_on_repair_failure should assert the specific
RepairFailed error instead of accepting any Err and should be made
dimension-generic; replace the broad assert!(result.is_err()) with a precise
assertion that the error matches the RepairFailed variant (e.g. using
matches!(result.unwrap_err(), DelaunayError::RepairFailed{..}) or equivalent
pattern match against RepairFailed) to ensure the forced-repair path (activated
by ForceRepairNonconvergentGuard::enable()) was exercised, and refactor the test
into a pastey macro to run for D=2..=5 so the failure/rollback behavior is
validated across dimensions.
- Around line 6302-6365: After a successful remove_vertex transaction you must
invalidate cached topology-dependent state to avoid stale keys: in the
Ok(cells_removed) success path (the match on result after the closure) clear
self.last_inserted_cell (set to None) and reset/clear self.spatial_index (use
its clear() or replace with an empty spatial index instance) so both caches are
invalidated before returning Ok(cells_removed); locate the match result handling
around remove_vertex / apply_bistellar_flip_k1_inverse and update the success
branch accordingly.

In `@src/triangulation/delaunayize.rs`:
- Around line 559-562: The topology pass is being marked as succeeded
unconditionally by setting topology_repair: PlManifoldRepairStats { succeeded:
true, .. } even when repair_facet_oversharing failed; update the logic in
delaunayize.rs so that topology_repair.succeeded reflects the actual outcome of
repair_facet_oversharing (or the returned PlManifoldRepairStats) instead of
hardcoding true—propagate the real PlManifoldRepairStats from the repair attempt
into topology_repair and only set succeeded = true when the repair call
indicates success (leave false or the default when it failed and a fallback
rebuild is performed).
🪄 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: 24f0f56e-563b-427a-9d47-5679e8405796

📥 Commits

Reviewing files that changed from the base of the PR and between fea5898 and 0971280.

📒 Files selected for processing (11)
  • scripts/tests/test_benchmark_utils.py
  • src/core/algorithms/flips.rs
  • src/core/tds.rs
  • src/core/triangulation.rs
  • src/geometry/util/measures.rs
  • src/lib.rs
  • src/triangulation/builder.rs
  • src/triangulation/delaunay.rs
  • src/triangulation/delaunayize.rs
  • tests/proptest_geometry.rs
  • tests/proptest_triangulation.rs

Comment thread src/triangulation/delaunay.rs
Comment thread src/triangulation/delaunay.rs
Comment thread src/triangulation/delaunayize.rs Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 94.01496% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.70%. Comparing base (fea5898) to head (a95c610).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/core/algorithms/flips.rs 86.95% 30 Missing ⚠️
src/triangulation/delaunay.rs 96.87% 13 Missing ⚠️
src/triangulation/delaunayize.rs 93.47% 3 Missing ⚠️
src/geometry/util/measures.rs 97.64% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #352      +/-   ##
==========================================
+ Coverage   88.98%   89.70%   +0.72%     
==========================================
  Files          58       58              
  Lines       50713    51297     +584     
==========================================
+ Hits        45125    46015     +890     
+ Misses       5588     5282     -306     
Flag Coverage Δ
unittests 89.70% <94.01%> (+0.72%) ⬆️

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.

- Make vertex removal transactional across repair and orientation canonicalization failures.
- Preserve typed repair sources with operation-specific Delaunay diagnostics.
- Deprecate direct mutable triangulation access ahead of planned v0.8.0 removal.
- Clarify delaunayize fallback repair statistics and documentation.
- Add regression, coverage, doctest, and prelude coverage for repair diagnostics and invariant behavior.
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: 3

♻️ Duplicate comments (1)
src/triangulation/delaunay.rs (1)

4702-4710: ⚠️ Potential issue | 🟠 Major

Use the new repair-access invalidation path consistently.

tds_mut_for_repair() clears last_inserted_cell, but the in-file manual repair entrypoints still mutate self.tri.tds directly. After a successful repair_delaunay_with_flips* call, the next insert can still carry a stale cell hint from pre-repair topology. Please route those paths through the same invalidation logic, or clear the caches before borrowing self.tri.tds.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/triangulation/delaunay.rs` around lines 4702 - 4710, Several in-file
manual repair entrypoints (e.g., repair_delaunay_with_flips and its variants)
mutate self.tri.tds directly but do not run the same cache invalidation done by
tds_mut_for_repair(), so stale hints (insertion_state.last_inserted_cell /
spatial_index) survive and break subsequent inserts; update those repair call
sites to obtain mutable access via tds_mut_for_repair() instead of borrowing
self.tri.tds directly, or explicitly clear insertion_state.last_inserted_cell =
None and spatial_index = None immediately before any direct mutation of
self.tri.tds so all repair paths share the same invalidation logic.
🧹 Nitpick comments (1)
src/triangulation/delaunay.rs (1)

8433-8474: Assert cache restoration in the rollback helper too.

This helper proves vertex/cell rollback, but the new contract also restores insertion_state and spatial_index. Add assertions for last_inserted_cell and spatial_index before/after the forced failure so the transactional guarantee stays covered end-to-end.

As per coding guidelines, "Unit tests must cover known values, error paths, and dimension-generic correctness for Rust; dimension-generic tests MUST cover D=2 through D=5 using pastey macros".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/triangulation/delaunay.rs` around lines 8433 - 8474, The test
assert_remove_vertex_rollback must also capture and assert restoration of
insertion-related caches: record dt.last_inserted_cell and a snapshot of
dt.spatial_index (or dt.insertion_state/spatial_index representation) before
calling dt.remove_vertex, then after the forced failure assert those values
equal the originals to prove rollback restored last_inserted_cell and
spatial_index; add these checks around the ForceRepairNonconvergentGuard::enable
/ dt.remove_vertex call in assert_remove_vertex_rollback and expand the
dimension-generic test to cover D=2 through D=5 using the existing pastey macro
pattern so the cache-restore assertions run for each dimension.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/core/algorithms/flips.rs`:
- Around line 8241-8310: The test dynamic_flip_rejects_bad_context is only
instantiated for D=3 and must be made dimension-generic for D=2..=5; wrap the
test body in a pastey macro that generates the same assertions for const D =
2..=5, replacing concrete type uses (Tds<f64, (), (), 3>, VertexKey, CellKey)
with generic equivalents parameterized on D and ensuring FlipContextDyn and
apply_bistellar_flip_dynamic are constructed with the correct arities per D (use
the same removed_face_vertices/inserted_face_vertices/removed_cells shapes but
sized according to D), and invoke apply_bistellar_flip_dynamic(&mut tds, k,
&context) as before; keep all existing assertion messages and final
tds.number_of_vertices()/number_of_cells() checks so the runtime-k guards are
exercised for every dimension.
- Around line 4358-4383: The derived Debug impls for InsertedSimplexSkipSample,
RidgeMultiplicitySkipSample, MissingCellSkipSample and RepairSkipLocation
changed the log payload shape; update these types so emit_repair_debug_summary
continues to emit the original raw summary format by implementing a custom Debug
or Display that reproduces the previous summary string shape (or alternatively
modify emit_repair_debug_summary to format these types explicitly rather than
using ?sample). Locate the types InsertedSimplexSkipSample,
RidgeMultiplicitySkipSample, MissingCellSkipSample and enum RepairSkipLocation
and add a manual fmt::Debug or fmt::Display impl that formats fields exactly as
the old summary text, ensuring all places that call emit_repair_debug_summary
(reference function emit_repair_debug_summary) keep compatible output.

In `@tests/delaunay_public_api_coverage.rs`:
- Around line 141-147: The tracing::debug! diagnostics in
tests/delaunay_public_api_coverage.rs (the calls logging case,
vertex_key/inserted_uuid, "initial vertices" loop, and "inserted vertex coords")
must be gated behind the test-debug feature; wrap those debug invocations in a
feature guard (e.g., surrounding the block with if cfg!(feature = "test-debug")
{ ... } or annotate helper functions/blocks with #[cfg(feature = "test-debug")])
so the logging only runs when the test-debug feature is enabled, keeping the
existing messages and variables (vertex_key, inserted_uuid, vertices,
inserted_coords) intact.

---

Duplicate comments:
In `@src/triangulation/delaunay.rs`:
- Around line 4702-4710: Several in-file manual repair entrypoints (e.g.,
repair_delaunay_with_flips and its variants) mutate self.tri.tds directly but do
not run the same cache invalidation done by tds_mut_for_repair(), so stale hints
(insertion_state.last_inserted_cell / spatial_index) survive and break
subsequent inserts; update those repair call sites to obtain mutable access via
tds_mut_for_repair() instead of borrowing self.tri.tds directly, or explicitly
clear insertion_state.last_inserted_cell = None and spatial_index = None
immediately before any direct mutation of self.tri.tds so all repair paths share
the same invalidation logic.

---

Nitpick comments:
In `@src/triangulation/delaunay.rs`:
- Around line 8433-8474: The test assert_remove_vertex_rollback must also
capture and assert restoration of insertion-related caches: record
dt.last_inserted_cell and a snapshot of dt.spatial_index (or
dt.insertion_state/spatial_index representation) before calling
dt.remove_vertex, then after the forced failure assert those values equal the
originals to prove rollback restored last_inserted_cell and spatial_index; add
these checks around the ForceRepairNonconvergentGuard::enable / dt.remove_vertex
call in assert_remove_vertex_rollback and expand the dimension-generic test to
cover D=2 through D=5 using the existing pastey macro pattern so the
cache-restore assertions run for each dimension.
🪄 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: 65efe486-d59a-453c-ad12-584b62a430d7

📥 Commits

Reviewing files that changed from the base of the PR and between 0971280 and 70c901a.

📒 Files selected for processing (10)
  • README.md
  • docs/api_design.md
  • docs/dev/rust.md
  • docs/workflows.md
  • src/core/algorithms/flips.rs
  • src/geometry/util/measures.rs
  • src/triangulation/delaunay.rs
  • src/triangulation/delaunayize.rs
  • tests/delaunay_public_api_coverage.rs
  • tests/prelude_exports.rs
✅ Files skipped from review due to trivial changes (2)
  • README.md
  • src/geometry/util/measures.rs

Comment thread src/core/algorithms/flips.rs Outdated
Comment thread src/core/algorithms/flips.rs Outdated
Comment thread tests/delaunay_public_api_coverage.rs
- Preserve legacy repair-summary sample formatting while keeping typed diagnostic samples.
- Exercise dynamic flip context guards across D=2 through D=5.
- Invalidate insertion caches consistently before repair-driven TDS mutations.
- Assert remove-vertex rollback restores insertion hints and spatial-index state.
- Gate public API coverage debug tracing behind the test-debug feature.
@coderabbitai coderabbitai Bot added the documentation Improvements or additions to documentation label Apr 29, 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

🧹 Nitpick comments (1)
tests/delaunay_public_api_coverage.rs (1)

89-160: Consider gating the manual search helper behind test-debug.

This is investigation tooling rather than stable regression coverage, so moving it behind the feature flag would keep the default test suite smaller while still preserving the repro hunt when needed.

Suggested tweak
+#[cfg(feature = "test-debug")]
 #[test]
 #[ignore = "manual search helper; run explicitly to discover natural repro cases"]
 fn find_stale_key_after_rebuild() {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/delaunay_public_api_coverage.rs` around lines 89 - 160, The test
function find_stale_key_after_rebuild is manual investigation tooling and should
be compiled only when the test-debug feature is enabled; wrap the whole test
with a conditional compile attribute (e.g. add #[cfg(feature = "test-debug")]
immediately above the function) and keep or remove the #[ignore = "..."]
attribute as you prefer (keeping it is fine) so the helper is excluded from
default test builds and only available when the test-debug feature is enabled.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/triangulation/delaunay.rs`:
- Around line 8455-8536: The test only exercises the inverse-k=1 fast-path
because assert_remove_vertex_rollback() creates the removable vertex via
flip_k1_insert(), leaving the fallback self.tri.remove_vertex(vertex_key) path
untested; add a new dimension-generic test (using the existing
gen_remove_vertex_rollback_tests! macro pattern) or extend
assert_remove_vertex_rollback() to also construct a removable vertex whose star
is not a simplex (i.e., create/insert a vertex that does not use
flip_k1_insert() so that remove_vertex() takes the fallback transactional path),
then run the same forced-repair guard and rollback assertions (checking
dt.number_of_vertices, dt.number_of_cells, insertion_state.last_inserted_cell,
spatial_index snapshot, and that the inserted UUID is present) to cover the
inverse-k!=1 branch for D=2..5.

---

Nitpick comments:
In `@tests/delaunay_public_api_coverage.rs`:
- Around line 89-160: The test function find_stale_key_after_rebuild is manual
investigation tooling and should be compiled only when the test-debug feature is
enabled; wrap the whole test with a conditional compile attribute (e.g. add
#[cfg(feature = "test-debug")] immediately above the function) and keep or
remove the #[ignore = "..."] attribute as you prefer (keeping it is fine) so the
helper is excluded from default test builds and only available when the
test-debug feature is enabled.
🪄 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: ae61e5c4-77d3-4791-a3c8-0f66d116e635

📥 Commits

Reviewing files that changed from the base of the PR and between 70c901a and a460305.

📒 Files selected for processing (4)
  • src/core/algorithms/flips.rs
  • src/core/collections/spatial_hash_grid.rs
  • src/triangulation/delaunay.rs
  • tests/delaunay_public_api_coverage.rs
✅ Files skipped from review due to trivial changes (1)
  • src/core/collections/spatial_hash_grid.rs

Comment thread src/triangulation/delaunay.rs Outdated
- Add D=2..=5 rollback coverage for the non-k1 remove_vertex fallback path.
- Reuse cache and topology rollback assertions across fast-path and fallback removal tests.
- Compile the stale-key investigation helper only with the test-debug feature.
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.

🧹 Nitpick comments (1)
src/triangulation/delaunay.rs (1)

4782-4786: Reuse invalidate_repair_caches() here to avoid drift.

as_triangulation_mut() duplicates the invalidation logic that now has a dedicated helper.

♻️ Proposed refactor
     pub fn as_triangulation_mut(&mut self) -> &mut Triangulation<K, U, V, D> {
         // Direct mutable access can invalidate performance caches.
-        self.insertion_state.last_inserted_cell = None;
-        self.spatial_index = None;
+        self.invalidate_repair_caches();
         &mut self.tri
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/triangulation/delaunay.rs` around lines 4782 - 4786, The method
as_triangulation_mut currently duplicates cache invalidation by manually
clearing insertion_state.last_inserted_cell and spatial_index; replace that
duplicated logic with a call to the existing helper invalidate_repair_caches()
at the start of as_triangulation_mut so the same centralized invalidation
behavior is used before returning &mut self.tri, ensuring no drift between
implementations and keeping insertion_state.last_inserted_cell and spatial_index
cleared consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/triangulation/delaunay.rs`:
- Around line 4782-4786: The method as_triangulation_mut currently duplicates
cache invalidation by manually clearing insertion_state.last_inserted_cell and
spatial_index; replace that duplicated logic with a call to the existing helper
invalidate_repair_caches() at the start of as_triangulation_mut so the same
centralized invalidation behavior is used before returning &mut self.tri,
ensuring no drift between implementations and keeping
insertion_state.last_inserted_cell and spatial_index cleared consistently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 0e60ce5e-7cbb-46b0-8e7c-1ad2e8e8d448

📥 Commits

Reviewing files that changed from the base of the PR and between a460305 and a95c610.

📒 Files selected for processing (2)
  • src/triangulation/delaunay.rs
  • tests/delaunay_public_api_coverage.rs

@acgetchell acgetchell merged commit a244053 into main Apr 29, 2026
19 checks passed
@acgetchell acgetchell deleted the refactor/332-repair-diagnostics-invariants branch April 29, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api documentation Improvements or additions to documentation enhancement New feature or request geometry Geometry-related issues rust Pull requests that update rust code topology

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: type RepairDiagnostics skip samples instead of stringifying

1 participant