Skip to content

refactor(api)!: replace raw TDS access with owner topology queries#502

Merged
acgetchell merged 3 commits into
mainfrom
feat/253-pachner-monte-carlo-stress
Jul 4, 2026
Merged

refactor(api)!: replace raw TDS access with owner topology queries#502
acgetchell merged 3 commits into
mainfrom
feat/253-pachner-monte-carlo-stress

Conversation

@acgetchell

Copy link
Copy Markdown
Owner
  • 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

- 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
@acgetchell acgetchell self-assigned this Jul 4, 2026
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 046d6a0f-d1ef-4697-976a-237be615ad99

📥 Commits

Reviewing files that changed from the base of the PR and between 2f7bac8 and 310ed68.

📒 Files selected for processing (6)
  • benches/README.md
  • docs/dev/commands.md
  • docs/dev/debug_env_vars.md
  • justfile
  • tests/benchmark_flip_fixtures.rs
  • tests/public_topology_api.rs
✅ Files skipped from review due to trivial changes (3)
  • docs/dev/debug_env_vars.md
  • docs/dev/commands.md
  • benches/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/benchmark_flip_fixtures.rs

Walkthrough

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

Changes

Owner-level APIs and validation surface

Layer / File(s) Summary
Docs and public surface
Cargo.toml, README.md, benches/README.md, docs/*.md, src/lib.rs, src/core/vertex.rs, src/core/util/canonical_points.rs
Adds the new dev-dependency, updates validation and ridge-link documentation, adjusts crate/prelude exports, and refreshes smaller doc comments/example scaffolding.
Query, ridge, facet, and validation APIs
src/core/query.rs, src/topology/ridge.rs, src/core/edge.rs, src/core/facet.rs, src/core/facet_incidence.rs, src/core/adjacency.rs, src/core/validation.rs, src/core/util/*.rs, src/core/simplex.rs, src/geometry/algorithms/convex_hull.rs, src/topology/*, src/delaunay/property_validation.rs
Adds UUID identity, edge, facet, ridge, and validation helpers on Triangulation, tightens internal accessor visibility, and updates supporting docs/tests.
Incremental insertion and locate refactor
src/core/algorithms/incremental_insertion.rs, src/core/algorithms/locate.rs
Reduces insertion helper visibility, simplifies cavity fill dispatch, and narrows locate/conflict signatures and diagnostics gating.
Raw flip execution
src/core/algorithms/flips.rs, src/delaunay/flips.rs
Introduces rollback-safe raw flip entrypoints, embedded flip postcondition checks, and new flip error variants.
Delaunay core workflow refactor
src/delaunay/deletion.rs, src/delaunay/insertion.rs, src/delaunay/repair.rs, src/delaunay/delaunayize.rs, src/delaunay/validation.rs, src/delaunay/triangulation.rs, src/delaunay/builder.rs
Updates deletion, repair, delaunayize, validation, and periodic-construction paths to the new owner-level APIs and local fault-injection helpers.
DelaunayError expansion
src/delaunay/construction.rs
Adds umbrella error variants and conversions, and switches retry-time verification to the flip-predicate entry point.
Examples
examples/*.rs
Simplifies example error handling and moves snippets to owner-level handle/query/validation methods.
Benchmarks
benches/*.rs
Migrates benchmarks to triangulation-level APIs, adds a repair transaction-pressure case, and introduces the Pachner Monte Carlo stress benchmark.
Semgrep enforcement
semgrep.yaml, tests/semgrep/*
Adds rules and fixtures that enforce the new accessor and benchmark boundaries.
Test migrations
tests/*.rs
Updates flip/Pachner workflow tests, validation/property tests, serialization tests, prelude coverage, and regression tests to the owner-level APIs.
Misc docs/tests
tests/README.md, src/core/vertex.rs, src/core/util/canonical_points.rs
Refreshes test docs and minor doc comments to align with the new APIs and example style.

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
Loading

Possibly related PRs

  • acgetchell/delaunay#333: The flip-predicate verification rename/routing changes overlap directly with the validation flow in this PR.
  • acgetchell/delaunay#476: The ridge/facet/query API expansion here aligns with the owner-aware boundary and ridge-view work in that PR.
  • acgetchell/delaunay#489: The Pachner workflow tests and benchmark changes use the same staged move APIs introduced there.

Poem

I hopped through queries, quick and neat,
With ridge and facet paths complete.
Raw flips rolled safe beneath my paws,
And Monte Carlo kept its laws. 🐇
The Tds burrow closed at last,
New APIs race by, smooth and fast.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR also includes a broad owner-API refactor, docs, and Semgrep changes that go beyond the benchmark-only linked issue scope. Split the benchmark work from the API/docs/semgrep refactor, or add linked issues covering the broader topology-query migration.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main API refactor: replacing raw TDS access with owner-level topology queries.
Description check ✅ Passed The description is clearly related to the code changes and matches the refactor and benchmark work in the PR.
Linked Issues check ✅ Passed The PR adds the Pachner Monte Carlo stress benchmark with random moves, periodic validation, metrics, and large-vertex workflows for #253.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 feat/253-pachner-monte-carlo-stress

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

@acgetchell
acgetchell enabled auto-merge (squash) July 4, 2026 06:49
@codacy-production

codacy-production Bot commented Jul 4, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 291 complexity

Metric Results
Complexity 291

View in Codacy

🟢 Coverage 92.07% diff coverage

Metric Results
Coverage variation Report missing for a096ece1
Diff coverage 92.07% diff coverage

View coverage diff in Codacy

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.

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

Level 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 lists Tds::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 value

Avoid rescanning all simplices for each ridge candidate.

ridge_support_points now does a full dt.simplices() scan for every candidate ridge, and flippable_k3_ridge calls 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

📥 Commits

Reviewing files that changed from the base of the PR and between a096ece and 5c4c983.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (100)
  • Cargo.toml
  • README.md
  • benches/README.md
  • benches/allocation_hot_paths.rs
  • benches/ci_performance_suite.rs
  • benches/common/flip_workflows.rs
  • benches/delaunay_repair.rs
  • benches/locate.rs
  • benches/pachner_stress.rs
  • benches/pl_manifold_repair.rs
  • benches/profiling_suite.rs
  • benches/tds_clone.rs
  • docs/api_design.md
  • docs/architecture/prelude_reference.md
  • docs/dev/testing.md
  • docs/diagnostics.md
  • docs/invariants.md
  • docs/topology.md
  • docs/validation.md
  • docs/workflows.md
  • examples/delaunayize_repair.rs
  • examples/diagnostics.rs
  • examples/topology_editing.rs
  • semgrep.yaml
  • src/bench_fixtures.rs
  • src/core/adjacency.rs
  • src/core/algorithms/flips.rs
  • src/core/algorithms/incremental_insertion.rs
  • src/core/algorithms/locate.rs
  • src/core/collections/key_maps.rs
  • src/core/collections/secondary_maps.rs
  • src/core/edge.rs
  • src/core/facet.rs
  • src/core/facet_incidence.rs
  • src/core/insertion.rs
  • src/core/query.rs
  • src/core/repair.rs
  • src/core/simplex.rs
  • src/core/tds/keys.rs
  • src/core/tds/mutation.rs
  • src/core/tds/storage.rs
  • src/core/tds/validation.rs
  • src/core/traits/facet_incidence_analysis.rs
  • src/core/triangulation.rs
  • src/core/util/canonical_points.rs
  • src/core/util/facet_keys.rs
  • src/core/util/facet_utils.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/deletion.rs
  • src/delaunay/flips.rs
  • src/delaunay/insertion.rs
  • src/delaunay/property_validation.rs
  • src/delaunay/query.rs
  • src/delaunay/repair.rs
  • src/delaunay/triangulation.rs
  • src/delaunay/validation.rs
  • src/geometry/algorithms/convex_hull.rs
  • src/geometry/kernel.rs
  • src/geometry/robust_predicates.rs
  • src/geometry/util/measures.rs
  • src/geometry/util/triangulation_generation.rs
  • src/lib.rs
  • src/topology/characteristics/euler.rs
  • src/topology/characteristics/validation.rs
  • src/topology/manifold.rs
  • src/topology/ridge.rs
  • src/topology/spaces/toroidal.rs
  • tests/README.md
  • tests/benchmark_flip_fixtures.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/insert_with_statistics.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/docs/validation_levels.md
  • tests/semgrep/src/project_rules/rust_style.rs
  • tests/serialization_vertex_preservation.rs
  • tests/trait_bound_ergonomics.rs
  • tests/triangulation_builder.rs
💤 Files with no reviewable changes (2)
  • src/core/util/canonical_points.rs
  • src/core/vertex.rs

Comment thread semgrep.yaml
Comment thread tests/proptest_tds.rs Outdated
- 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.
@acgetchell
acgetchell disabled auto-merge July 4, 2026 09:02
@codecov

codecov Bot commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.56755% with 118 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.17%. Comparing base (9cecd49) to head (310ed68).
⚠️ 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 82.99% 42 Missing ⚠️
src/delaunay/construction.rs 72.41% 32 Missing ⚠️
src/core/query.rs 93.27% 15 Missing ⚠️
src/delaunay/builder.rs 59.09% 9 Missing ⚠️
src/delaunay/flips.rs 94.06% 7 Missing ⚠️
src/delaunay/deletion.rs 90.32% 6 Missing ⚠️
src/core/facet_incidence.rs 75.00% 3 Missing ⚠️
src/core/insertion.rs 83.33% 2 Missing ⚠️
src/core/tds/mutation.rs 95.83% 1 Missing ⚠️
src/delaunay/insertion.rs 97.14% 1 Missing ⚠️
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     
Flag Coverage Δ
unittests 91.17% <90.56%> (+0.11%) ⬆️

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.

@acgetchell
acgetchell enabled auto-merge (squash) July 4, 2026 09:14
- 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.
@acgetchell
acgetchell merged commit bc53e32 into main Jul 4, 2026
23 checks passed
@acgetchell
acgetchell deleted the feat/253-pachner-monte-carlo-stress branch July 4, 2026 10:21
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.

Add Pachner Move Monte-Carlo Stress Benchmark

1 participant