Skip to content

refactor(validation)!: reconcile topology validation policy (#385)#404

Merged
acgetchell merged 1 commit into
mainfrom
refactor/385-validation-policy-topology
May 20, 2026
Merged

refactor(validation)!: reconcile topology validation policy (#385)#404
acgetchell merged 1 commit into
mainfrom
refactor/385-validation-policy-topology

Conversation

@acgetchell
Copy link
Copy Markdown
Owner

  • Add explicit caller-owned validation mode for PL-manifold topology guarantees.
  • Reject incoherent topology guarantee and validation policy pairings through typed fallible setters.
  • Keep compatibility setters non-committal when a requested pairing is invalid.
  • Derive builder validation policy from the selected topology guarantee and document the compatibility matrix.

BREAKING CHANGE: ValidationPolicy::Never is now only coherent with TopologyGuarantee::Pseudomanifold; PL-manifold callers should use ValidationPolicy::ExplicitOnly for manual full-validation checkpoints.

Closes #385

- Add explicit caller-owned validation mode for PL-manifold topology guarantees.
- Reject incoherent topology guarantee and validation policy pairings through typed fallible setters.
- Keep compatibility setters non-committal when a requested pairing is invalid.
- Derive builder validation policy from the selected topology guarantee and document the compatibility matrix.

BREAKING CHANGE: `ValidationPolicy::Never` is now only coherent with `TopologyGuarantee::Pseudomanifold`; PL-manifold callers should use `ValidationPolicy::ExplicitOnly` for manual full-validation checkpoints.
@acgetchell acgetchell self-assigned this May 20, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

Review Change Stack

Walkthrough

This PR resolves the overlapping TopologyGuarantee and ValidationPolicy API axes by introducing typed fallible setters that reject incoherent combinations, a new ExplicitOnly validation mode for caller-owned validation, and builder-level policy derivation from topology guarantees. Public exports, documentation, and tests are updated to reflect the new compatibility matrix.

Changes

ValidationPolicy Extension and Typed Configuration API

Layer / File(s) Summary
ValidationPolicy extension and core compatibility infrastructure
src/core/validation.rs
ValidationPolicy gains ExplicitOnly variant (for manual validation checkpoints), should_validate returns false for both Never and ExplicitOnly, and a new ValidationConfigurationError enum with validate_configuration helper enforce compatibility between TopologyGuarantee and ValidationPolicy.
Triangulation try_set methods and compatibility delegation
src/core/validation.rs
Triangulation::try_set_validation_policy and try_set_topology_guarantee provide typed fallible configuration; existing set_* methods delegate to these and only warn on rejection, preventing silent incompatible state.
Configuration compatibility and policy tests
src/core/validation.rs
Unit tests verify ExplicitOnly does not auto-validate, topology/validation compatibility matrix includes ExplicitOnly, explicit-only supports manual PL-manifold validation, and typed try_set_* rejection of incompatible pairs.

DelaunayTriangulation Public Wrapper and Builder Integration

Layer / File(s) Summary
DelaunayTriangulation try_set wrappers and documentation
src/delaunay/query.rs
DelaunayTriangulation exposes try_set_validation_policy and try_set_topology_guarantee forwarding to underlying triangulation; set_* method docs now recommend typed variants for explicit error handling.
Builder topology-driven policy initialization
src/delaunay/construction.rs, src/delaunay/builder.rs
Empty triangulation construction directly assigns validation policy derived from topology guarantee via default_validation_policy(); builder documentation clarifies no separate validation policy knob exists.
Prelude export test and property test updates
tests/prelude_exports.rs, tests/proptest_delaunay_triangulation.rs
New prelude smoke test verifies ValidationConfigurationError conversions and aliases; property test switches from ValidationPolicy::Never to ExplicitOnly.

Public Exports, Documentation, and Examples

Layer / File(s) Summary
Crate root and prelude re-exports
src/lib.rs
ValidationConfigurationError is re-exported from crate root and added to all prelude submodules; documentation examples updated to use try_set_validation_policy(ValidationPolicy::ExplicitOnly).
Policy matrix and usage documentation
README.md, docs/api_design.md, docs/validation.md, docs/workflows.md, docs/production_review_remediation_checklist.md, tests/triangulation_builder.rs
Documentation and tests clarify ValidationPolicy::ExplicitOnly semantics, try_set_* typed feedback for incompatible pairs, builder derivation of policy from guarantee, and integration test confirming policy derivation behavior.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • acgetchell/delaunay#301: Both PRs modify triangulation initialization so validation_policy is derived from TopologyGuarantee::default_validation_policy() rather than using a fixed default.
  • acgetchell/delaunay#157: This PR extends prior validation-policy changes by adding the new ValidationPolicy::ExplicitOnly variant and updating the corresponding try_set_* configuration APIs and error types.
  • acgetchell/delaunay#139: This PR's changes introduce ValidationPolicy-driven control of when Level 3 manifold topology checks run automatically, which is directly tied to the Level 3 validate_manifold() behavior introduced in that PR.

Suggested labels

rust, topology, api, documentation, enhancement

Poem

🐰 A topology garden grows neat,
Where guarantees and policies meet,
No incoherent state to greet—
Just try_set methods, typed and sweet,
And ExplicitOnly makes it complete! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarizes the main objective: reconciling topology validation policy by introducing explicit validation modes and typed fallible setters for incompatible pairings.
Description check ✅ Passed The description is directly related to the changeset, explaining the four main objectives (explicit validation mode, rejecting incoherent pairings, non-committal compatibility setters, and policy derivation) and the breaking change.
Linked Issues check ✅ Passed The PR fully addresses all coding requirements from issue #385: introduces ValidationPolicy::ExplicitOnly, adds typed fallible setters (try_set_validation_policy, try_set_topology_guarantee), documents the compatibility matrix, and updates tests across Triangulation and DelaunayTriangulation surfaces.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #385 objectives: validation/topology policy reconciliation, typed error APIs, builder derivation, documentation, and comprehensive test coverage. No unrelated changes detected.
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/385-validation-policy-topology

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

@acgetchell acgetchell enabled auto-merge (squash) May 20, 2026 02: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 100.00% diff coverage · +0.02% coverage variation

Metric Results
Coverage variation +0.02% coverage variation (-1.00%)
Diff coverage 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (bc5d48f) 62304 56378 90.49%
Head commit (910530e) 62378 (+74) 56460 (+82) 90.51% (+0.02%)

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 (#404) 124 124 100.00%

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 documentation Improvements or additions to documentation enhancement New feature or request rust Pull requests that update rust code api topology 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.

🧹 Nitpick comments (2)
src/delaunay/construction.rs (1)

6274-6300: ⚡ Quick win

Add the PLManifold → ExplicitOnly case to this derivation test.

This only exercises the strict and pseudomanifold ends of the matrix, so a regression in the new breaking-change path for TopologyGuarantee::PLManifold would slip through here.

➕ Suggested test addition
         let strict: DelaunayTriangulation<_, (), (), 3> =
             DelaunayTriangulation::empty_with_topology_guarantee(
                 TopologyGuarantee::PLManifoldStrict,
             );
         assert_eq!(
             strict.topology_guarantee(),
             TopologyGuarantee::PLManifoldStrict
         );
         assert_eq!(strict.validation_policy(), ValidationPolicy::Always);
 
+        let manifold: DelaunayTriangulation<_, (), (), 3> =
+            DelaunayTriangulation::empty_with_topology_guarantee(
+                TopologyGuarantee::PLManifold,
+            );
+        assert_eq!(manifold.topology_guarantee(), TopologyGuarantee::PLManifold);
+        assert_eq!(manifold.validation_policy(), ValidationPolicy::ExplicitOnly);
+
         let pseudomanifold: DelaunayTriangulation<_, (), (), 3> =
             DelaunayTriangulation::with_empty_kernel_and_topology_guarantee(
                 FastKernel::<f64>::new(),
                 TopologyGuarantee::Pseudomanifold,
             );
As per coding guidelines, "Unit tests in Rust must cover known values, error paths, and dimension-generic correctness."
🤖 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 6274 - 6300, Add a third case in
test_empty_topology_guarantee_derives_validation_policy that constructs a
triangulation with TopologyGuarantee::PLManifold (use
DelaunayTriangulation::with_empty_kernel_and_topology_guarantee(FastKernel::<f64>::new(),
TopologyGuarantee::PLManifold)), then assert that .topology_guarantee() is
TopologyGuarantee::PLManifold and that .validation_policy() equals
ValidationPolicy::ExplicitOnly so the PLManifold → ExplicitOnly derivation is
covered.
src/core/validation.rs (1)

1913-2056: ⚡ Quick win

Parameterize the new configuration-path tests across D=2..5.

The new try_set_*/compatibility coverage is mostly 2D-only even though this API is const-generic and this file already uses pastey for dimension fan-out. Please mirror that here so the success and rejection paths are exercised for D=2 through D=5 as well.

As per coding guidelines, Unit tests in Rust must cover known values, error paths, and dimension-generic correctness. Dimension-generic tests must cover D=2 through D=5 whenever feasible; use pastey macros to generate per-dimension tests.

🤖 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/validation.rs` around lines 1913 - 2056, The new configuration-path
tests (functions like
incompatible_policy_rejected_even_when_completion_validation_succeeds,
incompatible_guarantee_rejected_even_when_completion_validation_succeeds,
incompatible_policy_rejected_when_completion_validation_fails,
incompatible_guarantee_rejected_when_completion_validation_fails, etc.) are
written only for D=2; update them to be generated for D=2..=5 using the existing
pastey test expansion pattern so the const-generic Triangulation<..., D>
coverage exercises try_set_validation_policy, try_set_topology_guarantee,
validate_at_completion and set_* variants across dimensions 2–5; replace each
lone #[test] with a pastey macro (or wrap the test body in a pastey-generated
per-dimension test) that instantiates Triangulation::<FastKernel<f64>, (), (),
D> for D=2..=5 to assert both success and rejection paths.
🤖 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.

Nitpick comments:
In `@src/core/validation.rs`:
- Around line 1913-2056: The new configuration-path tests (functions like
incompatible_policy_rejected_even_when_completion_validation_succeeds,
incompatible_guarantee_rejected_even_when_completion_validation_succeeds,
incompatible_policy_rejected_when_completion_validation_fails,
incompatible_guarantee_rejected_when_completion_validation_fails, etc.) are
written only for D=2; update them to be generated for D=2..=5 using the existing
pastey test expansion pattern so the const-generic Triangulation<..., D>
coverage exercises try_set_validation_policy, try_set_topology_guarantee,
validate_at_completion and set_* variants across dimensions 2–5; replace each
lone #[test] with a pastey macro (or wrap the test body in a pastey-generated
per-dimension test) that instantiates Triangulation::<FastKernel<f64>, (), (),
D> for D=2..=5 to assert both success and rejection paths.

In `@src/delaunay/construction.rs`:
- Around line 6274-6300: Add a third case in
test_empty_topology_guarantee_derives_validation_policy that constructs a
triangulation with TopologyGuarantee::PLManifold (use
DelaunayTriangulation::with_empty_kernel_and_topology_guarantee(FastKernel::<f64>::new(),
TopologyGuarantee::PLManifold)), then assert that .topology_guarantee() is
TopologyGuarantee::PLManifold and that .validation_policy() equals
ValidationPolicy::ExplicitOnly so the PLManifold → ExplicitOnly derivation is
covered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 78a7e666-4b73-45ee-84cf-157f1ab4192f

📥 Commits

Reviewing files that changed from the base of the PR and between bc5d48f and 910530e.

📒 Files selected for processing (13)
  • README.md
  • docs/api_design.md
  • docs/production_review_remediation_checklist.md
  • docs/validation.md
  • docs/workflows.md
  • src/core/validation.rs
  • src/delaunay/builder.rs
  • src/delaunay/construction.rs
  • src/delaunay/query.rs
  • src/lib.rs
  • tests/prelude_exports.rs
  • tests/proptest_delaunay_triangulation.rs
  • tests/triangulation_builder.rs

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.50%. Comparing base (bc5d48f) to head (910530e).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #404      +/-   ##
==========================================
+ Coverage   90.47%   90.50%   +0.02%     
==========================================
  Files          71       71              
  Lines       62100    62174      +74     
==========================================
+ Hits        56188    56270      +82     
+ Misses       5912     5904       -8     
Flag Coverage Δ
unittests 90.50% <100.00%> (+0.02%) ⬆️

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.

@acgetchell acgetchell merged commit e5a74a1 into main May 20, 2026
20 checks passed
@acgetchell acgetchell deleted the refactor/385-validation-policy-topology branch May 20, 2026 03:19
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 rust Pull requests that update rust code topology

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor!: reconcile topology guarantee and validation policy API

1 participant