Skip to content

refactor(api)!: normalize fallible constructors (#459)#464

Merged
acgetchell merged 4 commits into
mainfrom
refactor/459-constructor-naming
Jun 16, 2026
Merged

refactor(api)!: normalize fallible constructors (#459)#464
acgetchell merged 4 commits into
mainfrom
refactor/459-constructor-naming

Conversation

@acgetchell

Copy link
Copy Markdown
Owner
  • Rename fallible Delaunay triangulation and convex hull constructors to explicit try_* forms while keeping infallible constructors for validated inputs.
  • Remove the raw-array validated-coordinate constructor path in favor of Point::try_new and validated coordinate proofs.
  • Update documentation, examples, benchmarks, and Semgrep guardrails for the constructor naming contract and panic-free public snippets.
  • Report generated simplex counts in the large-scale smoke benchmark output.

BREAKING CHANGE: Fallible public constructors now use explicit try_* names. Use DelaunayTriangulation::try_new*, DelaunayTriangulation::try_with_*, ConvexHull::try_from_triangulation, and Point::try_new or validated Point values instead of the previous fallible DelaunayTriangulation::new*/with_* constructors, ConvexHull::from_triangulation, and Point::from_validated_coords raw-array path.

Closes #459

- Rename fallible Delaunay triangulation and convex hull constructors to explicit `try_*` forms while keeping infallible constructors for validated inputs.
- Remove the raw-array validated-coordinate constructor path in favor of `Point::try_new` and validated coordinate proofs.
- Update documentation, examples, benchmarks, and Semgrep guardrails for the constructor naming contract and panic-free public snippets.
- Report generated simplex counts in the large-scale smoke benchmark output.

BREAKING CHANGE: Fallible public constructors now use explicit `try_*` names. Use `DelaunayTriangulation::try_new*`, `DelaunayTriangulation::try_with_*`, `ConvexHull::try_from_triangulation`, and `Point::try_new` or validated `Point` values instead of the previous fallible `DelaunayTriangulation::new*/with_*` constructors, `ConvexHull::from_triangulation`, and `Point::from_validated_coords` raw-array path.

Closes #459
@acgetchell acgetchell self-assigned this Jun 16, 2026
@acgetchell acgetchell enabled auto-merge (squash) June 16, 2026 09:16
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The PR normalizes constructor naming and fallible construction flows across core geometry, Delaunay APIs, docs, tests, benchmarks, and tooling. It also adds validated-point helpers, fallible random-point generation, new Semgrep rules, and a fixture-config generation script.

Changes

Constructor normalization and propagation

Layer / File(s) Summary
Docs and examples
README.md, docs/**, examples/*, src/* doc/tests
Public examples and rustdoc snippets switch to try_* constructors, ?-based propagation, and thiserror-style example errors, with matching updates in example tests.
Geometry and sampling
src/geometry/*, src/topology/*
Point validation, kernel predicates, random point generation, circumcenter output, and geometry/topology tests move to fallible validation paths and renamed helpers.
Core and Delaunay APIs
src/core/*, src/delaunay/*, src/lib.rs
Validated vertex helpers, TDS accessors, core construction docs, Delaunay constructors, builder flows, and call sites are renamed or rewired to fallible try_* forms.
Benchmarks, scripts, and Semgrep
benches/*, justfile, scripts/*, semgrep.yaml
Benchmark harnesses, benchmark docs, the fixture-config script, the justfile, and Semgrep rules are updated around fallible generators, new API names, and fixture-specific config generation.
Integration and support tests
tests/*
Integration tests, prelude coverage, and support fixtures migrate to the fallible constructor vocabulary and updated hull/validation helpers.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~100 minutes

Possibly related PRs

  • acgetchell/delaunay#410: Also replaces panic-based public examples with typed Result flows and updated error wrappers.
  • acgetchell/delaunay#450: Closely matches the fallible constructor and toroidal naming migration in docs and APIs.
  • acgetchell/delaunay#68: Related to the benchmark suite changes that this PR updates for fallible construction.

Poem

🐇 I nibbled the old new signs away,
and taught each example to ? and stay.
With try_* hops and typed-error bread,
the bunnies now test the paths ahead.
Semgrep watches the moonlit trail,
while fallible carrots never fail.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/459-constructor-naming

@codacy-production

codacy-production Bot commented Jun 16, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 85 complexity

Metric Results
Complexity 85

View in Codacy

🟢 Coverage 99.22% diff coverage · +0.07% coverage variation

Metric Results
Coverage variation +0.07% coverage variation (-1.00%)
Diff coverage 99.22% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (bda1cd5) 67983 62288 91.62%
Head commit (c55a8b3) 68283 (+300) 62613 (+325) 91.70% (+0.07%)

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 (#464) 2572 2552 99.22%

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.

@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.55117% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.67%. Comparing base (bda1cd5) to head (c55a8b3).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/geometry/kernel.rs 89.06% 7 Missing ⚠️
src/geometry/util/point_generation.rs 98.40% 2 Missing ⚠️
src/geometry/util/triangulation_generation.rs 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #464      +/-   ##
==========================================
+ Coverage   91.59%   91.67%   +0.07%     
==========================================
  Files          72       72              
  Lines       67771    68063     +292     
==========================================
+ Hits        62078    62395     +317     
+ Misses       5693     5668      -25     
Flag Coverage Δ
unittests 91.67% <99.55%> (+0.07%) ⬆️

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.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
benches/profiling_suite.rs (1)

839-843: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fail fast when the benchmark setup cannot build a triangulation.

if let Ok(dt) turns a construction failure into a no-op sample, so the allocation run can silently measure the wrong path and skew the numbers. Abort or skip the entry here the same way the other suites do.

🛠️ Proposed fix
-                    let alloc_info = measure(|| {
-                        if let Ok(dt) = DelaunayTriangulationBuilder::new(&vertices).build::<()>() {
-                            black_box(dt);
-                        }
-                    });
+                    let alloc_info = measure(|| {
+                        let dt = bench_result(
+                            DelaunayTriangulationBuilder::new(&vertices).build::<()>(),
+                            "failed to build triangulation for memory benchmark",
+                        );
+                        black_box(dt);
+                    });
🤖 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 `@benches/profiling_suite.rs` around lines 839 - 843, The
DelaunayTriangulationBuilder::new(&vertices).build::<()>() call in the
allocation measurement silently succeeds or fails without asserting on success,
which causes benchmark samples to measure different code paths when construction
fails. Remove the if let Ok guard and instead use a pattern that panics or
early-returns on failure (similar to how other benchmark suites in the file
handle this), ensuring the benchmark only measures the successful triangulation
path.
docs/diagnostics.md (1)

125-138: ⚠️ Potential issue | 🟡 Minor

Add coordinate-conversion error variant to the example enum.

Vertex::try_new(...)? on lines 135–138 returns CoordinateConversionError, but DiagnosticsExampleError only maps construction and validation errors. The example will not compile as written.

Suggested fix
 use delaunay::prelude::DelaunayValidationError;
+use delaunay::prelude::geometry::CoordinateConversionError;
 
 #[derive(Debug, thiserror::Error)]
 enum DiagnosticsExampleError {
+    #[error(transparent)]
+    Coordinate(#[from] CoordinateConversionError),
     #[error(transparent)]
     Construction(#[from] DelaunayTriangulationConstructionError),
     #[error(transparent)]
     Validation(#[from] DelaunayValidationError),
 }
🤖 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 `@docs/diagnostics.md` around lines 125 - 138, The DiagnosticsExampleError enum
is missing a variant to handle CoordinateConversionError. Since
Vertex::try_new(...) returns a CoordinateConversionError, the ? operator on
lines 135-138 will fail to convert the error to DiagnosticsExampleError. Add a
new variant to the DiagnosticsExampleError enum with #[error(transparent)] and
#[from] attributes to handle CoordinateConversionError, similar to the existing
Construction and Validation variants.
src/geometry/point.rs (1)

369-374: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Document signed-zero canonicalization in the TryFrom<[T; D]> contract.

TryFrom<[T; D]> now normalizes -0.0 to 0.0 (Line 415), but that behavior is not explicitly stated in the conversion doc block. Please add a short note there so sign normalization is explicit at the API boundary.

As per coding guidelines: “No f64 operation may silently lose sign information …”.

Also applies to: 415-419

🤖 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 `@src/geometry/point.rs` around lines 369 - 374, The TryFrom<[T; D]>
implementation for Point normalizes -0.0 to 0.0 during conversion at line
415-419, but this behavior is not documented in the docstring of the impl block
starting at line 369. Add a note to the docstring explicitly documenting the
signed-zero canonicalization behavior to make it clear at the API boundary that
-0.0 values will be converted to 0.0 as part of the fallible conversion process.

Source: Coding guidelines

src/core/tds.rs (1)

77-77: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update the validation table to the fallible point constructor.

This row still points users to Point::from() for coordinate validation, which conflicts with the new try_new/try_from parse boundary used throughout the updated examples. Use the fallible point constructor names here too.

Suggested documentation update
-//! | **Vertex Validity** | `Point::from()` (coordinates) + UUID auto-gen + `vertex.is_valid()` | Construction + runtime validation |
+//! | **Vertex Validity** | `Point::try_new()` / `Point::try_from()` (coordinates) + UUID auto-gen + `vertex.is_valid()` | Construction + runtime validation |
🤖 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 `@src/core/tds.rs` at line 77, The documentation table row for "Vertex
Validity" still references the infallible Point::from() constructor for
coordinate validation, but the updated examples throughout the codebase now use
fallible constructors like try_new or try_from at the parse boundary. Update
this table row to replace the Point::from() reference with the appropriate
fallible constructor names (try_new or try_from) to maintain consistency with
the new validation pattern.
src/delaunay/construction.rs (1)

3907-3928: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate after entering the Constructed state.

finalize_bulk_construction validates while the TDS is still in its prior construction state, then marks it Constructed on Line 3928. The shuffled retry paths return after is_delaunay_via_flips() and do not run a full is_valid() after this assignment, so any validation gated on TriangulationConstructionState::Constructed can be skipped.

Proposed fix
+        let prior_construction_state = self.tri.tds.construction_state().clone();
+        self.tri.tds.construction_state = TriangulationConstructionState::Constructed;
+
         tracing::debug!("post-construction: starting topology validation (finalize)");
         let validation_started = Instant::now();
         let validation_result = self.tri.validate();
@@
         if let Err(err) = validation_result {
+            self.tri.tds.construction_state = prior_construction_state;
             return Err(TriangulationConstructionError::FinalTopologyValidation {
                 message: "topology validation failed after construction".to_string(),
                 source: err.into(),
             }
             .into());
         }
-        self.tri.tds.construction_state = TriangulationConstructionState::Constructed;
 
         Ok(())

As per coding guidelines, “Every mutating operation must preserve invariants checked by Tds::is_valid (Level 1-3) and DelaunayTriangulation::is_valid (Level 4).”

🤖 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 `@src/delaunay/construction.rs` around lines 3907 - 3928, The topology
validation in the finalize_bulk_construction method is currently performed
before setting the construction_state to Constructed on line 3928, but
validation should occur after entering the Constructed state to ensure
invariants are checked in the final state. Move the line that sets
self.tri.tds.construction_state to TriangulationConstructionState::Constructed
to execute before the validation_result assignment and validation logic, so that
any validation checks that depend on TriangulationConstructionState::Constructed
will execute properly and all invariants will be validated in the final
constructed state.

Source: Coding guidelines

🧹 Nitpick comments (1)
benches/profiling_suite.rs (1)

92-113: 💤 Low value

Document the new private benchmark helpers.

finite_point, retry_attempts, coordinate_range, wide_bounds, adversarial_bounds, and generated_points_in_range are private helpers with no /// context. That makes the setup code harder to maintain.

As per coding guidelines, private functions must have a brief doc comment explaining why they exist.

Also applies to: 307-316

🤖 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 `@benches/profiling_suite.rs` around lines 92 - 113, The private helper
functions `finite_point`, `retry_attempts`, `coordinate_range`, `wide_bounds`,
and `adversarial_bounds` in benches/profiling_suite.rs at lines 92-113 (anchor)
are missing documentation comments. Additionally, the
`generated_points_in_range` function at lines 307-316 (sibling) also lacks
documentation. Add brief `///` doc comments to each of these private functions
explaining their purpose and why they exist, following the coding guidelines
that require all private functions to have documentation context. This will
improve maintainability of the benchmark setup code.

Source: Coding guidelines

🤖 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 `@docs/dev/testing.md`:
- Around line 277-279: The code example in the testing documentation references
QueryError::MissingSimplex which does not actually exist in src/core/query.rs,
making the example non-compilable. Replace the reference to
QueryError::MissingSimplex with a locally-defined error type that is specific to
the example code block. Define a simple custom error enum within the example
itself (for instance, a local enum with a MissingSimplex variant) and use that
in the else block instead of relying on the non-existent QueryError variant.
This makes the example self-contained and demonstrable without requiring
external crate errors that don't exist.

In `@docs/validation.md`:
- Around line 112-115: The example code uses the ? operator on
Vertex::try_new(...) calls which return CoordinateConversionError, but the
ValidationExampleError enum does not implement From<CoordinateConversionError>,
causing the example to fail compilation. Add a From<CoordinateConversionError>
implementation to the ValidationExampleError enum (or add a variant that wraps
CoordinateConversionError if using an enum-based approach) so that the ?
operator can properly convert the error type when calling try_new() at the
specified lines.

In `@src/delaunay/construction.rs`:
- Around line 6576-6592: The test function
test_constructed_delaunay_exposes_constructed_tds_state is currently hardcoded
to test only D=3 (as seen in the Vertex<(), 3> and DelaunayTriangulation<_, (),
(), 3> declarations). To comply with coding guidelines, refactor this test to be
dimension-generic by creating a pastey macro that generates the same test cases
for D=2 through D=5, using standard-simplex fixtures for each dimension. Apply
this same pattern to all other new constructor/finalization/statistics test
functions in the same file that currently only cover D=3.

In `@src/geometry/kernel.rs`:
- Around line 666-669: The `expect("finite point coordinates")` calls in the
Point creation code will panic on user input in library runtime paths, violating
the coding guidelines that forbid panics on user input in library code. Replace
these `expect()` calls with proper error propagation using the `?` operator or
match expressions to return the `CoordinateConversionError` to the caller
instead. This issue occurs at multiple locations in the file (the primary
location and additional occurrences as noted in the comment), and each should be
fixed by removing the `expect()` and allowing the error to propagate through the
Result return type of the containing function.

In `@src/geometry/util/point_generation.rs`:
- Around line 151-156: Add a focused unit test to exercise the error path where
`Point::try_new` fails due to coordinate validation and maps to the new
`GeneratedPointCoordinateRejected` error variant. The test should verify that
when invalid point coordinates are provided, the error is properly caught and
the `GeneratedPointCoordinateRejected` variant is returned with the correct
`CoordinateValidationError` source. Include test cases that cover known invalid
coordinate values and verify dimension-generic correctness to prevent regression
of this boundary condition.
- Around line 307-315: The `random_range` method can panic when calculating
`high - low` overflows for floats, even though `CoordinateRange` validates
bounds are finite and min < max. Add an explicit overflow check in
`sample_point_in_range` before the call to
`rng.random_range(range.min()..range.max())` to detect when `max - min` would
overflow, and map the failure into `RandomPointGenerationError` instead of
allowing a panic. Apply the same overflow check to the ball-sampling code path
that also calls `random_range`. Additionally, add a test case that exercises the
`GeneratedPointCoordinateRejected` error variant to verify the error contract is
reachable.

In `@tests/proptest_convex_hull.rs`:
- Around line 56-60: The proptest cases are silently passing when constructor or
method calls fail by using if let Ok(...) patterns, which weakens invariant
coverage. For deterministic simplex cases at tests/proptest_convex_hull.rs lines
56-60 and 91-95, replace the if let Ok checks with prop_assert! calls to ensure
DelaunayTriangulation::try_new_with_topology_guarantee and
ConvexHull::try_from_triangulation succeed deterministically. For randomized
domain cases at lines 136-141, 187-196, 205-206, 246-251, and 288-294, use
prop_assume!(result.is_ok()) followed by unwrap() before assertions so that
invalid inputs are rejected rather than silently counted as passing test runs,
ensuring only valid invariant checks are counted toward test coverage.

---

Outside diff comments:
In `@benches/profiling_suite.rs`:
- Around line 839-843: The
DelaunayTriangulationBuilder::new(&vertices).build::<()>() call in the
allocation measurement silently succeeds or fails without asserting on success,
which causes benchmark samples to measure different code paths when construction
fails. Remove the if let Ok guard and instead use a pattern that panics or
early-returns on failure (similar to how other benchmark suites in the file
handle this), ensuring the benchmark only measures the successful triangulation
path.

In `@docs/diagnostics.md`:
- Around line 125-138: The DiagnosticsExampleError enum is missing a variant to
handle CoordinateConversionError. Since Vertex::try_new(...) returns a
CoordinateConversionError, the ? operator on lines 135-138 will fail to convert
the error to DiagnosticsExampleError. Add a new variant to the
DiagnosticsExampleError enum with #[error(transparent)] and #[from] attributes
to handle CoordinateConversionError, similar to the existing Construction and
Validation variants.

In `@src/core/tds.rs`:
- Line 77: The documentation table row for "Vertex Validity" still references
the infallible Point::from() constructor for coordinate validation, but the
updated examples throughout the codebase now use fallible constructors like
try_new or try_from at the parse boundary. Update this table row to replace the
Point::from() reference with the appropriate fallible constructor names (try_new
or try_from) to maintain consistency with the new validation pattern.

In `@src/delaunay/construction.rs`:
- Around line 3907-3928: The topology validation in the
finalize_bulk_construction method is currently performed before setting the
construction_state to Constructed on line 3928, but validation should occur
after entering the Constructed state to ensure invariants are checked in the
final state. Move the line that sets self.tri.tds.construction_state to
TriangulationConstructionState::Constructed to execute before the
validation_result assignment and validation logic, so that any validation checks
that depend on TriangulationConstructionState::Constructed will execute properly
and all invariants will be validated in the final constructed state.

In `@src/geometry/point.rs`:
- Around line 369-374: The TryFrom<[T; D]> implementation for Point normalizes
-0.0 to 0.0 during conversion at line 415-419, but this behavior is not
documented in the docstring of the impl block starting at line 369. Add a note
to the docstring explicitly documenting the signed-zero canonicalization
behavior to make it clear at the API boundary that -0.0 values will be converted
to 0.0 as part of the fallible conversion process.

---

Nitpick comments:
In `@benches/profiling_suite.rs`:
- Around line 92-113: The private helper functions `finite_point`,
`retry_attempts`, `coordinate_range`, `wide_bounds`, and `adversarial_bounds` in
benches/profiling_suite.rs at lines 92-113 (anchor) are missing documentation
comments. Additionally, the `generated_points_in_range` function at lines
307-316 (sibling) also lacks documentation. Add brief `///` doc comments to each
of these private functions explaining their purpose and why they exist,
following the coding guidelines that require all private functions to have
documentation context. This will improve maintainability of the benchmark setup
code.
🪄 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: 74e82b52-9e97-4dac-8c44-0c53e1acdb81

📥 Commits

Reviewing files that changed from the base of the PR and between bda1cd5 and ad52b41.

📒 Files selected for processing (118)
  • README.md
  • benches/PERFORMANCE_RESULTS.md
  • benches/README.md
  • benches/allocation_hot_paths.rs
  • benches/boundary_uuid_iter.rs
  • benches/ci_performance_suite.rs
  • benches/circumsphere_containment.rs
  • benches/cold_path_predicates.rs
  • benches/common/flip_workflows.rs
  • benches/profiling_suite.rs
  • benches/remove_vertex.rs
  • benches/tds_clone.rs
  • benches/topology_guarantee_construction.rs
  • docs/api_design.md
  • docs/dev/rust.md
  • docs/dev/testing.md
  • docs/dev/tooling-alignment.md
  • docs/diagnostics.md
  • docs/numerical_robustness_guide.md
  • docs/production_review_remediation_checklist.md
  • docs/roadmap.md
  • docs/topology.md
  • docs/validation.md
  • docs/workflows.md
  • examples/delaunayize_repair.rs
  • examples/diagnostics.rs
  • examples/numerical_robustness.rs
  • examples/triangulation_and_hull.rs
  • justfile
  • scripts/semgrep_fixture_config.py
  • scripts/tests/test_semgrep_fixture_config.py
  • semgrep.yaml
  • src/core/adjacency.rs
  • src/core/algorithms/flips.rs
  • src/core/algorithms/incremental_insertion.rs
  • src/core/algorithms/locate.rs
  • src/core/algorithms/pl_manifold_repair.rs
  • src/core/boundary.rs
  • src/core/collections/aliases.rs
  • src/core/collections/key_maps.rs
  • src/core/collections/secondary_maps.rs
  • src/core/construction.rs
  • src/core/edge.rs
  • src/core/facet.rs
  • src/core/insertion.rs
  • src/core/query.rs
  • src/core/repair.rs
  • src/core/simplex.rs
  • src/core/tds.rs
  • src/core/tds_snapshot.rs
  • src/core/traits/boundary_analysis.rs
  • src/core/traits/facet_cache.rs
  • src/core/triangulation.rs
  • src/core/util/canonical_points.rs
  • src/core/util/deduplication.rs
  • src/core/util/delaunay_validation.rs
  • src/core/util/facet_keys.rs
  • src/core/util/facet_utils.rs
  • src/core/util/hilbert.rs
  • src/core/util/jaccard.rs
  • src/core/validation.rs
  • src/core/vertex.rs
  • src/delaunay/builder.rs
  • src/delaunay/construction.rs
  • src/delaunay/delaunayize.rs
  • src/delaunay/flips.rs
  • src/delaunay/insertion.rs
  • src/delaunay/locality.rs
  • src/delaunay/query.rs
  • src/delaunay/repair.rs
  • src/delaunay/serialization.rs
  • src/delaunay/triangulation.rs
  • src/delaunay/validation.rs
  • src/geometry/algorithms/convex_hull.rs
  • src/geometry/kernel.rs
  • src/geometry/point.rs
  • src/geometry/predicates.rs
  • src/geometry/quality.rs
  • src/geometry/robust_predicates.rs
  • src/geometry/sos.rs
  • src/geometry/traits/coordinate.rs
  • src/geometry/util/circumsphere.rs
  • src/geometry/util/conversions.rs
  • src/geometry/util/measures.rs
  • src/geometry/util/point_generation.rs
  • src/geometry/util/triangulation_generation.rs
  • src/lib.rs
  • src/topology/characteristics/euler.rs
  • src/topology/characteristics/validation.rs
  • src/topology/manifold.rs
  • tests/README.md
  • tests/dedup_batch_construction.rs
  • tests/delaunay_edge_cases.rs
  • tests/delaunay_incremental_insertion.rs
  • tests/delaunay_repair_fallback.rs
  • tests/delaunayize_workflow.rs
  • tests/euler_characteristic.rs
  • tests/example_workflows.rs
  • tests/large_scale_debug.rs
  • tests/pachner_roundtrip.rs
  • tests/prelude_exports.rs
  • tests/proptest_convex_hull.rs
  • tests/proptest_delaunay_triangulation.rs
  • tests/proptest_euler_characteristic.rs
  • tests/proptest_facet.rs
  • tests/proptest_flips.rs
  • tests/proptest_orientation.rs
  • tests/proptest_serialization.rs
  • tests/proptest_simplex.rs
  • tests/proptest_tds.rs
  • tests/proptest_triangulation.rs
  • tests/public_topology_api.rs
  • tests/regressions.rs
  • tests/semgrep/doctests/unwrap_expect.txt
  • tests/semgrep/src/project_rules/rust_style.rs
  • tests/serialization_vertex_preservation.rs
  • tests/trait_bound_ergonomics.rs
  • tests/triangulation_builder.rs

Comment thread docs/dev/testing.md
Comment thread docs/validation.md
Comment thread src/delaunay/construction.rs Outdated
Comment thread src/geometry/kernel.rs Outdated
Comment thread src/geometry/util/point_generation.rs
Comment thread src/geometry/util/point_generation.rs Outdated
Comment thread tests/proptest_convex_hull.rs Outdated
- Replace public trusted vertex batch construction with try_vertices_from_points so point-to-vertex conversion re-enters the coordinate validation boundary.
- Collapse trusted vertex construction onto one internal from_validated_point path that carries optional payload data.
- Add repository guardrails that keep from_validated* constructors internal, scarce, and separate from public parsing APIs.
- Harden random point generation against sampler range overflow with a typed CoordinateRangeWidthOverflow error.

BREAKING CHANGE: Vertex::from_validated_points is no longer public. Callers converting Point values into vertices should use try_vertices_from_points and handle CoordinateConversionError.

@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

🧹 Nitpick comments (1)
benches/profiling_suite.rs (1)

308-313: ⚡ Quick win

Preserve vertex-conversion error context.

try_vertices_from_points is the fallible fixture conversion boundary; a raw std::process::abort() makes failures untriageable. Route it through bench_result like the other setup helpers.

Suggested fix
 fn benchmark_vertices_from_generated_points<const D: usize>(
     points: &[Point<D>],
 ) -> Vec<Vertex<(), D>> {
-    try_vertices_from_points(points).unwrap_or_else(|_| std::process::abort())
+    bench_result(
+        try_vertices_from_points(points),
+        format!(
+            "failed to convert {} generated points into {D}D benchmark vertices",
+            points.len()
+        ),
+    )
 }
🤖 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 `@benches/profiling_suite.rs` around lines 308 - 313, The
`benchmark_vertices_from_generated_points` function uses a raw
`std::process::abort()` when `try_vertices_from_points` fails, discarding error
context and making failures hard to diagnose. Instead of `unwrap_or_else(|_|
std::process::abort())`, route the error through `bench_result` like the other
setup helper functions in the file do, so that vertex conversion failures are
properly captured and reported with their error context preserved.
🤖 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 `@docs/diagnostics.md`:
- Around line 123-133: The `DiagnosticsExampleError` enum is using the incorrect
error type for coordinate operations. Replace `CoordinateValidationError` with
`CoordinateConversionError` in both the import statement and the enum variant
definition. The `Vertex::try_new(...)` calls throw `CoordinateConversionError`,
so using the correct error type will ensure the `?` operator properly maps
errors to `DiagnosticsExampleError` variants without conversion issues.

---

Nitpick comments:
In `@benches/profiling_suite.rs`:
- Around line 308-313: The `benchmark_vertices_from_generated_points` function
uses a raw `std::process::abort()` when `try_vertices_from_points` fails,
discarding error context and making failures hard to diagnose. Instead of
`unwrap_or_else(|_| std::process::abort())`, route the error through
`bench_result` like the other setup helper functions in the file do, so that
vertex conversion failures are properly captured and reported with their error
context preserved.
🪄 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: ce11f9c9-0b21-4206-be1f-d43f4b9e487a

📥 Commits

Reviewing files that changed from the base of the PR and between ad52b41 and a7cd09f.

📒 Files selected for processing (40)
  • benches/allocation_hot_paths.rs
  • benches/boundary_uuid_iter.rs
  • benches/ci_performance_suite.rs
  • benches/profiling_suite.rs
  • benches/remove_vertex.rs
  • benches/tds_clone.rs
  • docs/dev/rust.md
  • docs/dev/testing.md
  • docs/diagnostics.md
  • docs/validation.md
  • examples/triangulation_and_hull.rs
  • semgrep.yaml
  • src/core/boundary.rs
  • src/core/insertion.rs
  • src/core/tds.rs
  • src/core/util/deduplication.rs
  • src/core/validation.rs
  • src/core/vertex.rs
  • src/delaunay/builder.rs
  • src/delaunay/construction.rs
  • src/delaunay/delaunayize.rs
  • src/delaunay/query.rs
  • src/geometry/algorithms/convex_hull.rs
  • src/geometry/kernel.rs
  • src/geometry/point.rs
  • src/geometry/util/point_generation.rs
  • src/geometry/util/triangulation_generation.rs
  • src/lib.rs
  • tests/prelude_exports.rs
  • tests/proptest_convex_hull.rs
  • tests/proptest_delaunay_triangulation.rs
  • tests/proptest_facet.rs
  • tests/proptest_flips.rs
  • tests/proptest_orientation.rs
  • tests/proptest_serialization.rs
  • tests/proptest_simplex.rs
  • tests/proptest_tds.rs
  • tests/proptest_triangulation.rs
  • tests/semgrep/src/project_rules/rust_style.rs
  • tests/serialization_vertex_preservation.rs
✅ Files skipped from review due to trivial changes (1)
  • docs/dev/rust.md
🚧 Files skipped from review as they are similar to previous changes (12)
  • benches/allocation_hot_paths.rs
  • examples/triangulation_and_hull.rs
  • benches/tds_clone.rs
  • docs/validation.md
  • docs/dev/testing.md
  • src/core/validation.rs
  • src/core/insertion.rs
  • src/delaunay/delaunayize.rs
  • benches/ci_performance_suite.rs
  • src/core/util/deduplication.rs
  • src/delaunay/query.rs
  • src/delaunay/construction.rs

Comment thread docs/diagnostics.md Outdated
- Route profiling benchmark vertex conversion failures through bench_result instead of aborting without the underlying error.
- Update the diagnostics example to use CoordinateConversionError for Vertex::try_new failures.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/validation.md (1)

164-187: ⚠️ Potential issue | 🔴 Critical

Fix examples that use Vertex::try_new() with incompatible error types.

Code examples at lines 164-187, 315-344, 400-423, and 472-494 use Vertex::<(), _>::try_new(...)? which returns CoordinateConversionError, but the function signatures return DelaunayTriangulationConstructionError. No From<CoordinateConversionError> implementation exists on DelaunayTriangulationConstructionError, so the ? operator will fail to compile.

All other doc examples in the codebase handle this by wrapping both error types in a custom error enum with #[from] attributes. Apply the same pattern to these validation.md examples, or change the return type to Result<(), CoordinateConversionError>.

🤖 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 `@docs/validation.md` around lines 164 - 187, The example code blocks using
Vertex::try_new() have a type mismatch error: Vertex::try_new() returns
CoordinateConversionError but the function signatures return
DelaunayTriangulationConstructionError, and no From implementation exists
between these types so the ? operator will fail to compile. Fix all four
affected example code blocks in validation.md (the main function shown and the
other examples at the specified line ranges) by either wrapping both error types
in a custom error enum with #[from] attributes (as other doc examples in the
codebase do) or by changing the return type to Result<(),
CoordinateConversionError>. Ensure the chosen approach is applied consistently
across all affected examples.
🤖 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.

Outside diff comments:
In `@docs/validation.md`:
- Around line 164-187: The example code blocks using Vertex::try_new() have a
type mismatch error: Vertex::try_new() returns CoordinateConversionError but the
function signatures return DelaunayTriangulationConstructionError, and no From
implementation exists between these types so the ? operator will fail to
compile. Fix all four affected example code blocks in validation.md (the main
function shown and the other examples at the specified line ranges) by either
wrapping both error types in a custom error enum with #[from] attributes (as
other doc examples in the codebase do) or by changing the return type to
Result<(), CoordinateConversionError>. Ensure the chosen approach is applied
consistently across all affected examples.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 21374842-d872-4cba-8f35-8693e2051947

📥 Commits

Reviewing files that changed from the base of the PR and between 5fd3a24 and c55a8b3.

📒 Files selected for processing (1)
  • docs/validation.md

@acgetchell acgetchell merged commit 0fb6607 into main Jun 16, 2026
22 checks passed
@acgetchell acgetchell deleted the refactor/459-constructor-naming branch June 16, 2026 21:43
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.

refactor(api): normalize constructor naming after TDS boundary cleanup

1 participant