Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ path = "src/main.rs"
name = "cdt_benchmarks"
harness = false

[features]
slow-tests = [ ]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The library leverages high-performance [Delaunay triangulation] backends and pro

## ✨ Features

- [x] Explicit 1+1 CDT strip and toroidal S¹×S¹ constructors with foliation invariants
- [x] Delaunay-built 1+1 CDT strip and periodic toroidal S¹×S¹ constructors with foliation invariants
- [x] Foliation-aware topology, causality, and cell-classification validation
- [x] Proposal-before-mutation Metropolis-Hastings simulation with rollback on failed accepted moves
- [x] Regge action calculation with configurable coupling constants
Expand Down
17 changes: 10 additions & 7 deletions docs/code_organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ causal-triangulations/
│ │ └── rust_style.rs
│ ├── cli.rs
│ ├── integration_tests.rs
│ ├── physics_integration.rs
│ ├── proptest_foliation.rs
│ └── proptest_metropolis.rs
│ ├── proptest_metropolis.rs
│ └── regressions.rs
├── .bencher.toml
├── .codecov.yml
├── .coderabbit.yml
Expand Down Expand Up @@ -175,16 +177,16 @@ Assigns each vertex to a discrete time slice, enabling classification of edges a
This is CDT domain logic layered over the geometry backend interface. It may use `DelaunayBackend2D` and crate-owned Delaunay handles, but it does not reach through to upstream `delaunay::` APIs directly.

- Owns the `CdtTriangulation` wrapper, `CdtMetadata`, `SimulationEvent`, metadata validation, cached simplex-count accessors, and common backend-agnostic wrapper methods
- `from_cdt_strip(vertices_per_slice, num_slices)` — explicit open-boundary 1+1 CDT strip with strict Up/Down cell classification
- `from_toroidal_cdt(vertices_per_slice, num_slices)` — explicit S¹×S¹ toroidal CDT (χ = 0); requires `vertices_per_slice ≥ 3` and `num_slices ≥ 3`
- `from_cdt_strip(vertices_per_slice, num_slices)` — Delaunay-built open-boundary 1+1 CDT strip with strict Up/Down cell classification and upstream Level 1–4 Delaunay validation before wrapping
- `from_toroidal_cdt(vertices_per_slice, num_slices)` — periodic Delaunay S¹×S¹ toroidal CDT (χ = 0) with upstream Level 1–4 validation before wrapping; requires `vertices_per_slice ≥ 3` and `num_slices ≥ 3`
- `assign_foliation_by_y(num_slices)` — bin existing vertices into time slices
- Query methods: `time_label`, `edge_type`, `vertices_at_time`, `slice_sizes`, `has_foliation`
- Validation: `validate_topology()` (χ expectation depends on `CdtTopology`), `validate_foliation()` (structural; closed S¹ spacelike rings on toroidal), `validate_causality()` (no edge spans >1 slice), `validate_cell_classification()` (strict Up/Down cell classification and validation pass)
- Validation: constructors require upstream Delaunay Level 1–4 validation for initial meshes; `validate()` is the post-move/final-state contract and requires upstream structural validity plus CDT topology, foliation, causality, and strict Up/Down cell classification
- Mutable backend access is not exposed. CDT code mutates Delaunay state only through narrow crate-internal operations (`flip_edge`, `subdivide_face`, `remove_vertex`, `set_vertex_data`) that invalidate cached counts and foliation synchronization bookkeeping on success.

The implementation is split into child modules under `src/cdt/triangulation/`:

- `builders.rs` — Delaunay-backed random/seeded/labeled builders plus explicit strip and toroidal CDT builders
- `builders.rs` — Delaunay-backed random/seeded/labeled builders plus strip and periodic toroidal CDT builders
- `foliation.rs` — foliation assignment, slice and label queries, volume profiles, cell/edge classification, and foliation synchronization
- `moves.rs` — narrow crate-internal Delaunay mutation hooks used by ergodic moves
- `validation.rs` — full CDT validation and Delaunay-backed causality checks
Expand Down Expand Up @@ -232,13 +234,14 @@ The implementation is split into child modules under `src/cdt/triangulation/`:
- `generate_delaunay2` — builds a 2D Delaunay triangulation with optional seed
- `build_delaunay2_with_data` — builds from coordinate + vertex-data pairs
- `build_delaunay2_from_cells` / `build_delaunay2_with_topology` — builds from explicit cell connectivity (no Delaunay point insertion); the latter also accepts `TopologyGuarantee` and `GlobalTopology` metadata so non-sphere Euler characteristics validate correctly
- `build_toroidal_delaunay2` — convenience wrapper for explicit toroidal meshes (χ = 0)
- `build_toroidal_delaunay2` — convenience wrapper for explicit toroidal meshes (χ = 0; no point-insertion Delaunay guarantee)
- `build_periodic_toroidal_delaunay2` — builds true periodic toroidal Delaunay meshes through the upstream image-point constructor
- `random_delaunay2`, `seeded_delaunay2` — convenience wrappers
- `DelaunayTriangulation2D` — type alias for the concrete 2D triangulation type

Together with `backends/delaunay.rs`, this module is the only place that directly imports from the `delaunay` crate.

The CDT strip and toroidal constructors keep their internal cell working sets as fixed triangles (`[usize; 3]`) and reserve storage up front. They currently adapt those triangles to `Vec<Vec<usize>>` at the generator boundary because the explicit-cell generator API still accepts Vec-backed cell index lists; a future generator cleanup should accept fixed triangle cells directly to remove that per-triangle allocation.
The toroidal CDT constructor builds from labeled lattice vertices and delegates to the upstream periodic image-point constructor, then validates the resulting Delaunay triangulation before CDT foliation, causality, topology, and cell-classification checks run.

### `util.rs` — Numeric helpers

Expand Down
1 change: 1 addition & 0 deletions docs/dev/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ just test-python # pytest
| Run lints | `just check` |
| Run unit tests | `just test` |
| Run integration tests | `just test-integration` |
| Run slow tests | `just test-slow` |
| Run all tests | `just test-all` |
| Run Python tests | `just test-python` |
| Run examples | `just examples` |
Expand Down
1 change: 1 addition & 0 deletions docs/dev/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ Focused preludes under `prelude::` must remain small, orthogonal, and purpose-sp
- `prelude::triangulation` for CDT wrappers, foliation classification, topology metadata, and triangulation queries
- `prelude::moves` for local ergodic move kernels, move results, move types, and move statistics
- `prelude::action` for standalone action configuration and Regge action calculations
- `prelude::errors` for crate error types and typed error-category enums needed to pattern-match failures
- `prelude::simulation` for Metropolis/action simulation workflows, proposal types, simulation result types, and telemetry needed to inspect or debug simulations
- `prelude::observables` for user-facing analysis APIs that measure triangulations or derived physical observables, such as volume profiles, Hausdorff-dimension estimators, and spectral-dimension estimators

Expand Down
22 changes: 22 additions & 0 deletions docs/dev/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ Integration tests should validate:

---

### Regression Tests

Location:

```text
tests/regressions.rs
```

Regression tests capture specific previously observed bugs or blocking upstream limitations. Each regression test should document:

- the issue, blocker, or failure mode it guards
- the user-visible symptom that exposed the bug
- how expectations should change when the underlying fix lands

---

### Python Tests

Location:
Expand Down Expand Up @@ -149,6 +165,12 @@ Run integration tests:
just test-integration
```

Run feature-gated slow integration tests:

```bash
just test-slow
```

Run all tests:

```bash
Expand Down
1 change: 1 addition & 0 deletions docs/dev/tooling-alignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Some differences remain because CDT has different workflows and project invarian
- CDT runs examples through `scripts/run_all_examples.sh`, which discovers current examples dynamically and applies a timeout. Its `--validate` mode checks stable semantic output markers for known Cargo examples without requiring exact numeric output.
- CDT keeps `archive-changelog` so completed release series move under `docs/archive/changelog/`; MCMC does not yet archive old changelog sections.
- CDT keeps a dedicated `performance.yml` workflow and local `perf-*` recipes. MCMC does not have matching CDT benchmark-baseline tooling.
- CDT exposes feature-gated long-running Rust checks through the `slow-tests` Cargo feature and the `just test-slow` recipe, keeping normal CI fast while giving stabilization work a named path for heavier integration coverage.
- CDT has a repository rule SARIF workflow for the local Semgrep rules. A Codacy workflow was not ported because it depends on project-specific `CODACY_PROJECT_TOKEN` setup and would duplicate the existing repository-rule SARIF signal until Codacy is configured for this repository.
- CDT Semgrep rules include geometry-backend isolation, foliation/topology validation, focused prelude imports, Python support-script discipline, and typed error policies. These are repository-specific and should not be weakened while porting generic rules.
- CDT and MCMC both require Python `>=3.12` for repository-managed support tooling.
Expand Down
19 changes: 15 additions & 4 deletions docs/foliation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,31 @@ Vertex data is set at construction time via `VertexBuilder::data(t)`. For post-c

## Time Label Assignment

For `from_cdt_strip()` and `from_toroidal_cdt()`, time labels are assigned directly while building vertices. Vertex `(i, t)` receives label `t`, so each slice starts with exactly `vertices_per_slice` vertices and every constructed triangle spans adjacent slices.
For `from_cdt_strip()` and `from_toroidal_cdt()`, time labels are assigned directly while building vertices. Vertex `(i, t)` receives label `t`, so each slice starts with exactly `vertices_per_slice` vertices. The constructors require their Delaunay-built cells to span adjacent slices before returning.

`assign_foliation_by_y()` uses band-based bucketing and writes labels through the same CDT-owned label-write path.

## Grid Construction (`from_cdt_strip`)
## Delaunay Construction

The open-boundary strip constructor places vertices on a grid with:
The open-boundary strip constructor places vertices in a lightly perturbed layered grid with:

- **Spatial extent**: 1.0, with `vertices_per_slice` evenly spaced vertices per slice
- **Temporal gap**: 1.0, with integer y-coordinates `0, 1, 2, ...`
- **Connectivity**: each quad between adjacent slices is split into one Up `(2,1)` and one Down `(1,2)` triangle
- **Connectivity**: produced by Delaunay point insertion, then checked for strict Up/Down cell classification

Parameters: `vertices_per_slice ≥ 4`, `num_slices ≥ 2`.

The toroidal constructor places vertices on a unit lattice in an `N × T` periodic domain and uses the upstream periodic image-point Delaunay constructor. It then checks the requested `V = N·T`, `E = 3·N·T`, `F = 2·N·T` toroidal counts and strict CDT classification.

## Initialization vs Evolution Validation

Initial CDT constructors are stricter than post-move validation:

- **Initialization**: `from_cdt_strip()` and `from_toroidal_cdt()` must pass upstream Delaunay Level 1-4 validation before returning. This certifies the starting mesh as a valid, well-behaved PL-manifold and Delaunay triangulation.
- **After ergodic moves / simulation completion**: `CdtTriangulation::validate()` requires upstream structural validity plus CDT topology, foliation, causality, and cell-classification invariants. It intentionally does not require Level 4 Delaunay-ness, because the CDT move kernels are not expected to preserve the Delaunay empty-circumsphere predicate.

If the move set is ever changed to preserve Delaunay-ness, final-state validation should be tightened to include Level 4 as well.

## Edge Classification

`EdgeType` is an enum:
Expand Down
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ help-workflows:
@echo "Testing:"
@echo " just test # Lib and doc tests only (fast, used by CI)"
@echo " just test-integration # Integration tests (tests/)"
@echo " just test-slow # Feature-gated slow integration tests"
@echo " just test-all # All tests (lib + doc + integration + Python)"
@echo " just test-python # Python tests only (pytest)"
@echo " just test-release # All tests in release mode"
Expand Down Expand Up @@ -636,6 +637,9 @@ test-doc:
test-integration:
cargo test --tests --verbose

test-slow:
cargo test --tests --features slow-tests --verbose

test-examples:
cargo test --examples --verbose

Expand Down
Loading
Loading