refactor(api)!: replace raw TDS access with owner topology queries#502
Conversation
- Expose owner-bound topology, identity, ridge, facet, locate, and validation queries on Triangulation and DelaunayTriangulation so callers no longer need raw TDS access. - Route Pachner moves through the owner transaction API with rollback, orientation repair, and post-move validation while keeping primitive flips as internal building blocks. - Publish Level 3 topology helpers for PL-manifold checks, including ridge-link and vertex-link validation, and align docs, examples, doctests, and preludes around the new API surface. - Add MCMC-backed Pachner stress and repair transaction-pressure benchmarks with diagnostics for failed long-run move chains. - Extend Semgrep rules to prevent regressions into public TDS/storage access and validation naming drift. BREAKING CHANGE: Public callers should use owner-level query and validation methods instead of `tds()` or `as_triangulation().tds()` to inspect topology storage. Closes #253
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR expands owner-level triangulation query and validation APIs, refactors flip and repair execution to raw rollback-based paths, adds a Monte Carlo Pachner stress benchmark, and updates docs, examples, tests, and Semgrep rules to the new APIs and boundaries. ChangesOwner-level APIs and validation surface
Estimated code review effort: 5 (Critical) | ~150 minutes Sequence Diagram(s)sequenceDiagram
participant Justfile
participant CriterionBench
participant PachnerStress
participant DelaunayTriangulation
Justfile->>CriterionBench: cargo bench pachner_stress
CriterionBench->>PachnerStress: run 3D/4D Monte Carlo stress
PachnerStress->>DelaunayTriangulation: propose_pachner / attempt_on
PachnerStress->>DelaunayTriangulation: validate_structure / topology checks
PachnerStress->>CriterionBench: emit metrics and report lines
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 291 |
🟢 Coverage 92.07% diff coverage
Metric Results Coverage variation Report missing for a096ece1 Diff coverage ✅ 92.07% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (a096ece) Report Missing Report Missing Report Missing Head commit (310ed68) 78537 71625 91.20% 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 (#502) 1602 1475 92.07% 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%1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.
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.
There was a problem hiding this comment.
Actionable comments posted: 2
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)
306-313: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winLevel 2 "Methods" list wasn't updated to mention the new owner-level helpers.
The "Diagnostics" line and every Level 2 code example in this doc were migrated to
dt.is_valid_structure()/dt.validate_structure(), but the "Methods" bullet list just above (lines 306-313) still only listsTds::is_valid()/Tds::validate()/ etc. and omits the new owner-bound convenience methods that the rest of the section now demonstrates.📝 Proposed fix
### Methods - `Tds::is_valid()` - Level 2 (structural) checks only (fast-fail). - `Tds::structure_diagnostic()` - First actionable Level 2 diagnostic. - `Tds::structure_report()` - All checkable Level 2 structural failures. - `Tds::validate()` - Levels 1–2 (elements + structural). +- `DelaunayTriangulation::is_valid_structure()` / `Triangulation::is_valid_structure()` - Owner-bound fast-fail Level 2 check. +- `DelaunayTriangulation::validate_structure()` / `Triangulation::validate_structure()` - Owner-bound Levels 1–2 check. - `DelaunayTriangulation::validation_report()` - Cumulative diagnostic report across Levels 1–5.Also applies to: 379-382
🤖 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 306 - 313, Update the Level 2 “Methods” list to include the new owner-level helpers shown elsewhere in this section, specifically the DelaunayTriangulation-bound convenience methods such as dt.is_valid_structure() and dt.validate_structure(). Keep the existing Tds:: methods, but add the owner-facing equivalents so the “Methods” bullet list matches the revised Diagnostics text and Level 2 examples throughout validation.md.
🧹 Nitpick comments (1)
benches/common/flip_workflows.rs (1)
1384-1397: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueAvoid rescanning all simplices for each ridge candidate.
ridge_support_pointsnow does a fulldt.simplices()scan for every candidate ridge, andflippable_k3_ridgecalls it across test/bench fixtures. That adds an O(ridges × simplices) setup cost that can make the larger 4D/5D cases noticeably slower. Consider reusing a localized star/adjacency traversal here instead.🤖 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/common/flip_workflows.rs` around lines 1384 - 1397, `ridge_support_points` is doing a full `dt.simplices()` scan for every ridge candidate, which creates an avoidable O(ridges × simplices) cost in the `flippable_k3_ridge` benchmark/test path. Update `ridge_support_points` to reuse a localized star/adjacency traversal around the candidate ridge instead of iterating all simplices, and keep the existing `vertex_points(dt, &keys)` behavior unchanged. Use the existing `ridge_candidate`, `star_simplex`, and `dt` flow to locate the hot path and move the lookup to a more targeted neighborhood traversal.
🤖 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 `@semgrep.yaml`:
- Around line 338-357: The `no-public-api-cfg-test-shim` rule’s `pattern-regex`
is using a backtracking-heavy shape that can time out on large non-matching Rust
files. Update the regex in `semgrep.yaml` to avoid the `(?s)` plus
negative-lookahead repeated block, keeping the match line-local with
`[^\\n]*\\n` or another non-backtracking form, while preserving the intent of
detecting `cfg(test)`-gated `pub use`/`pub fn`/`pub const fn` patterns.
In `@tests/proptest_tds.rs`:
- Around line 443-447: The assertion in the connectivity property test is too
broad because `is_valid_topology()` checks more than connectedness. Update the
check in `tests/proptest_tds.rs` around the `dt.as_triangulation()` assertion to
use a connectivity-specific predicate if available, or otherwise rename the
test/message to reflect full topology validity. Keep the assertion text aligned
with the actual condition being verified in the
`is_valid_topology`/`number_of_simplices` block.
---
Outside diff comments:
In `@docs/validation.md`:
- Around line 306-313: Update the Level 2 “Methods” list to include the new
owner-level helpers shown elsewhere in this section, specifically the
DelaunayTriangulation-bound convenience methods such as dt.is_valid_structure()
and dt.validate_structure(). Keep the existing Tds:: methods, but add the
owner-facing equivalents so the “Methods” bullet list matches the revised
Diagnostics text and Level 2 examples throughout validation.md.
---
Nitpick comments:
In `@benches/common/flip_workflows.rs`:
- Around line 1384-1397: `ridge_support_points` is doing a full `dt.simplices()`
scan for every ridge candidate, which creates an avoidable O(ridges × simplices)
cost in the `flippable_k3_ridge` benchmark/test path. Update
`ridge_support_points` to reuse a localized star/adjacency traversal around the
candidate ridge instead of iterating all simplices, and keep the existing
`vertex_points(dt, &keys)` behavior unchanged. Use the existing
`ridge_candidate`, `star_simplex`, and `dt` flow to locate the hot path and move
the lookup to a more targeted neighborhood traversal.
🪄 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: d3cebde4-d13a-45ee-8fc3-ed6d48288482
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (100)
Cargo.tomlREADME.mdbenches/README.mdbenches/allocation_hot_paths.rsbenches/ci_performance_suite.rsbenches/common/flip_workflows.rsbenches/delaunay_repair.rsbenches/locate.rsbenches/pachner_stress.rsbenches/pl_manifold_repair.rsbenches/profiling_suite.rsbenches/tds_clone.rsdocs/api_design.mddocs/architecture/prelude_reference.mddocs/dev/testing.mddocs/diagnostics.mddocs/invariants.mddocs/topology.mddocs/validation.mddocs/workflows.mdexamples/delaunayize_repair.rsexamples/diagnostics.rsexamples/topology_editing.rssemgrep.yamlsrc/bench_fixtures.rssrc/core/adjacency.rssrc/core/algorithms/flips.rssrc/core/algorithms/incremental_insertion.rssrc/core/algorithms/locate.rssrc/core/collections/key_maps.rssrc/core/collections/secondary_maps.rssrc/core/edge.rssrc/core/facet.rssrc/core/facet_incidence.rssrc/core/insertion.rssrc/core/query.rssrc/core/repair.rssrc/core/simplex.rssrc/core/tds/keys.rssrc/core/tds/mutation.rssrc/core/tds/storage.rssrc/core/tds/validation.rssrc/core/traits/facet_incidence_analysis.rssrc/core/triangulation.rssrc/core/util/canonical_points.rssrc/core/util/facet_keys.rssrc/core/util/facet_utils.rssrc/core/util/jaccard.rssrc/core/validation.rssrc/core/vertex.rssrc/delaunay/builder.rssrc/delaunay/construction.rssrc/delaunay/delaunayize.rssrc/delaunay/deletion.rssrc/delaunay/flips.rssrc/delaunay/insertion.rssrc/delaunay/property_validation.rssrc/delaunay/query.rssrc/delaunay/repair.rssrc/delaunay/triangulation.rssrc/delaunay/validation.rssrc/geometry/algorithms/convex_hull.rssrc/geometry/kernel.rssrc/geometry/robust_predicates.rssrc/geometry/util/measures.rssrc/geometry/util/triangulation_generation.rssrc/lib.rssrc/topology/characteristics/euler.rssrc/topology/characteristics/validation.rssrc/topology/manifold.rssrc/topology/ridge.rssrc/topology/spaces/toroidal.rstests/README.mdtests/benchmark_flip_fixtures.rstests/delaunay_edge_cases.rstests/delaunay_incremental_insertion.rstests/delaunay_repair_fallback.rstests/delaunayize_workflow.rstests/euler_characteristic.rstests/insert_with_statistics.rstests/large_scale_debug.rstests/pachner_roundtrip.rstests/prelude_exports.rstests/proptest_convex_hull.rstests/proptest_delaunay_triangulation.rstests/proptest_euler_characteristic.rstests/proptest_facet.rstests/proptest_flips.rstests/proptest_orientation.rstests/proptest_serialization.rstests/proptest_simplex.rstests/proptest_tds.rstests/proptest_triangulation.rstests/public_topology_api.rstests/regressions.rstests/semgrep/docs/validation_levels.mdtests/semgrep/src/project_rules/rust_style.rstests/serialization_vertex_preservation.rstests/trait_bound_ergonomics.rstests/triangulation_builder.rs
💤 Files with no reviewable changes (2)
- src/core/util/canonical_points.rs
- src/core/vertex.rs
- Split 3D flip fixture coverage by move kind so failures identify the affected Pachner workflow. - Use localized ridge-star views for k=3 support inspection and surface typed traversal failures. - Align topology proptest assertions and exact-predicate regression diagnostics with the validators they exercise. - Document owner-level structure validators and make the cfg(test) shim Semgrep rule line-local.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #502 +/- ##
==========================================
+ Coverage 91.06% 91.17% +0.11%
==========================================
Files 87 87
Lines 77679 78316 +637
==========================================
+ Hits 70738 71406 +668
+ Misses 6941 6910 -31
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
- Add 3D, 4D, and combined Pachner Monte Carlo stress recipes with report output enabled. - Document manual stress diagnostics, release-active knobs, and Pachner stress defaults. - Cover owner-level structure validation helpers and keep benchmark flip fixture checks under CI timeouts.
BREAKING CHANGE: Public callers should use owner-level query and validation methods instead of
tds()oras_triangulation().tds()to inspect topology storage.Closes #253