Skip to content

feat(concurrency)!: finalize parallel triangulation support#129

Merged
acgetchell merged 5 commits into
mainfrom
feat/88-multithreading-finalization
Jul 25, 2026
Merged

feat(concurrency)!: finalize parallel triangulation support#129
acgetchell merged 5 commits into
mainfrom
feat/88-multithreading-finalization

Conversation

@acgetchell

@acgetchell acgetchell commented Jul 24, 2026

Copy link
Copy Markdown
Owner
  • expose validated --threads limits in cdt and initialize
  • add the opt-in CGAL/oneTBB build, CI contract, and scaling records
  • persist thread limits and report source and toolchain provenance
  • finalize typed seeds, scoped enums, move APIs, and physical parameters
  • require CMake 4.4+ and enforce schema-12 configure diagnostics

BREAKING CHANGE: CMake 4.4.0 or newer is required. The final 1.0 C++ API replaces legacy snake_case types and get_* accessors, separates RandomSeed from RandomStream, removes the MoveTracker template parameter, and requires validated PhysicalParameters for generalized S3 actions.

Closes #88

Summary by CodeRabbit

  • New Features
    • Added cdt --threads with validation and “Maximum Delaunay threads” reporting, plus parallel.max_threads in reproducibility metadata.
    • Added opt-in parallel flows: just build-parallel, parallel CMake preset/build/test, and parallel CGAL benchmarking with warmups.
    • Build metadata now includes a source revision identifier.
  • Bug Fixes
    • Strengthened CLI help/persistence output validation, including explicit coverage for --threads 0.
  • Documentation
    • Updated quickstart, build/testing, multithreading, and reproducibility docs for threads/parallel runs.
  • Breaking Changes
    • Requires CMake 4.4.0+ and includes multiple public C++ API renames/type updates (threading, topology/artifact kinds, and move/strategy APIs).

- expose validated --threads limits in cdt and initialize
- add the opt-in CGAL/oneTBB build, CI contract, and scaling records
- persist thread limits and report source and toolchain provenance
- finalize typed seeds, scoped enums, move APIs, and physical parameters
- require CMake 4.4+ and enforce schema-12 configure diagnostics

BREAKING CHANGE: CMake 4.4.0 or newer is required. The final 1.0 C++ API replaces legacy snake_case types and get_* accessors, separates RandomSeed from RandomStream, removes the MoveTracker template parameter, and requires validated PhysicalParameters for generalized S3 actions.

Closes #88
@acgetchell acgetchell self-assigned this Jul 24, 2026
@acgetchell
acgetchell enabled auto-merge July 24, 2026 23:11
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The change adds opt-in CGAL/oneTBB parallel builds and bounded thread configuration, refreshes public C++ type and accessor contracts, persists thread metadata, strengthens validation and benchmark coverage, and updates CI, documentation, and build tooling.

Changes

Parallel execution and API contract refresh

Layer / File(s) Summary
Build and toolchain wiring
.github/workflows/*, CMakeLists.txt, CMakePresets.json, Justfile, scripts/*
Adds selectable reference and parallel presets, CMake 4.4.0 validation, pinned CI toolchains, and parallel build and benchmark recipes.
Runtime and persistence contracts
include/Runtime_config.hpp, src/*, include/Utilities.hpp, cmake/*
Adds --threads, oneTBB limits, source revision metadata, persisted parallel.max_threads, and validation for runtime and manifest values.
Public C++ API refresh
include/*.hpp
Introduces typed random, topology, artifact, cell, edge, move, and strategy contracts; refactors MoveCommand, Metropolis, S3 actions, foliation validation, and geometry accessors.
Validation and benchmarks
tests/*
Adds replayable parallel stress coverage, ownership and atomicity checks, warmup-aware benchmark samples, per-doctest CTest discovery, stronger persistence and API assertions, and updated move tests.
Documentation and maintenance updates
README.md, docs/*, .github/CONTRIBUTING.md, .clang-format, semgrep.yaml
Documents parallel execution boundaries, reproducibility, benchmark protocols, finalized API compatibility rules, maintenance commands, and formatting conventions.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related issues

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant RuntimeConfig
  participant TBB
  participant Persistence
  CLI->>RuntimeConfig: make_triangulation(..., threads)
  RuntimeConfig->>RuntimeConfig: validate thread limit
  RuntimeConfig-->>CLI: Triangulation with threads()
  CLI->>TBB: set max_allowed_parallelism
  CLI->>Persistence: write parallel.max_threads
  Persistence-->>CLI: validate persisted metadata
Loading

Poem

Presets wake the threads in line,
Typed seeds keep streams aligned.
Metadata records the race,
Tests guard every shared place.
Parallel paths, contracts bright—
Reference anchors right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 46.99% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: finalized parallel triangulation support.
Linked Issues check ✅ Passed The PR adds opt-in parallel triangulation, thread limits, invariants, tests, docs, and scaling records matching #88.
Out of Scope Changes check ✅ Passed The changes are broadly aligned with the parallel-support and API-finalization goals, with no clearly unrelated additions visible.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/88-multithreading-finalization

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 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 @.github/CONTRIBUTING.md:
- Around line 57-58: Update the GitHub Actions CI description in CONTRIBUTING.md
to state that Ubuntu GCC, Ubuntu Clang, macOS AppleClang, and Windows MSVC jobs
run both `just ci` and `just build-parallel`, preserving the existing compiler
and LLVM tooling details.

In @.github/workflows/ci.yml:
- Around line 149-155: Update the CI matrix around “Run the opt-in CGAL/oneTBB
contract” so the parallel build runs only on platform/toolchain combinations
where CGAL and oneTBB are reliably available through vcpkg, rather than
unconditionally on all jobs. Preserve the standard reference build/test for
every matrix entry and avoid making unsupported or unavailable parallel
dependencies fail the entire matrix.

In `@CMakeLists.txt`:
- Around line 33-60: Ensure the CDT_SOURCE_REVISION computation is rerun when
Git metadata changes during incremental builds by registering .git/HEAD and
.git/index as CMake configure dependencies. Update the existing Git revision
logic around CDT_SOURCE_REVISION without changing its commit and dirty-state
detection behavior.

In `@include/Foliated_triangulation.hpp`:
- Around line 1049-1062: Update the predicate in find_invalid_timevalue_cells to
compute expected_cell_type<dimension>(cell) once per cell, store the
classification locally, and compare that cached value against ACAUSAL and
UNCLASSIFIED. Preserve the existing filtering behavior and return type.

In `@include/Move_tracker.hpp`:
- Around line 60-79: In generate_random_move_3 and move_from_index, enforce at
compile time that the move lookup array contains exactly NUMBER_OF_3D_MOVES
entries before allowing the optional dereference. Keep the existing distribution
and invalid-index handling unchanged, but make any future mismatch fail
compilation rather than relying on unchecked synchronization.

In `@include/Utilities.hpp`:
- Around line 638-655: Extend Parsed_persistence_metadata to store the validated
parallel.max_threads value, then update read_persistence_metadata to copy the
parsed value into that field when constructing its return object. Preserve the
optional-field behavior by representing an absent thread limit consistently with
the existing metadata parsing conventions, so downstream consumers such as
validate_payload_integrity can retrieve it.
🪄 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.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 54882790-dd48-431b-b0ea-4296f4e1bd0d

📥 Commits

Reviewing files that changed from the base of the PR and between ed104ab and 862637a.

📒 Files selected for processing (72)
  • .clang-format
  • .github/CONTRIBUTING.md
  • .github/workflows/ci.yml
  • .github/workflows/codecov-upload.yml
  • CMakeLists.txt
  • CMakePresets.json
  • Justfile
  • README.md
  • cmake/RunCdtNoOutputTest.cmake
  • cmake/RunPersistenceOutputTest.cmake
  • cmake/Version.hpp.in
  • docs/api-boundary.md
  • docs/cgal-integration.md
  • docs/multithreading.md
  • docs/reproducibility.md
  • include/Apply_move.hpp
  • include/Ergodic_moves_3.hpp
  • include/Foliated_triangulation.hpp
  • include/Formatters.hpp
  • include/Manifold.hpp
  • include/Metropolis.hpp
  • include/Move_always.hpp
  • include/Move_command.hpp
  • include/Move_outcome.hpp
  • include/Move_run.hpp
  • include/Move_strategy.hpp
  • include/Move_tracker.hpp
  • include/Mpfr_value.hpp
  • include/Random.hpp
  • include/Runtime_config.hpp
  • include/S3Action.hpp
  • include/Settings.hpp
  • include/Torus_d.hpp
  • include/Utilities.hpp
  • scripts/build.bat
  • scripts/build.sh
  • scripts/pkgx-build.sh
  • scripts/slurm.sh
  • semgrep.yaml
  • src/CMakeLists.txt
  • src/cdt-viewer.cpp
  • src/cdt.cpp
  • src/initialize.cpp
  • tests/Apply_move_test.cpp
  • tests/Bistellar_flip_test.cpp
  • tests/CGAL_benchmark.cpp
  • tests/CGAL_integration_test.cpp
  • tests/CMakeLists.txt
  • tests/Ergodic_moves_3_audit_test.cpp
  • tests/Ergodic_moves_3_test.cpp
  • tests/Foliated_triangulation_test.cpp
  • tests/Function_ref_test.cpp
  • tests/Geometry_test.cpp
  • tests/Manifold_test.cpp
  • tests/Metropolis_test.cpp
  • tests/Move_always_test.cpp
  • tests/Move_command_test.cpp
  • tests/Move_outcome_test.cpp
  • tests/Move_run_test.cpp
  • tests/Move_tracker_test.cpp
  • tests/Parallel_triangulation_test.cpp
  • tests/Public_api_consumer.cpp
  • tests/Random_benchmark.cpp
  • tests/Random_test.cpp
  • tests/Runtime_config_test.cpp
  • tests/S3Action_test.cpp
  • tests/Settings_test.cpp
  • tests/Tetrahedron_test.cpp
  • tests/Torus_test.cpp
  • tests/Utilities_test.cpp
  • tests/Vertex_test.cpp
  • tests/semgrep/functional_boundaries.cpp

Comment thread .github/CONTRIBUTING.md Outdated
Comment thread .github/workflows/ci.yml
Comment thread CMakeLists.txt
Comment thread include/Foliated_triangulation.hpp
Comment thread include/Move_tracker.hpp
Comment thread include/Utilities.hpp
- Correct pkgx tool-list handling across CI and coverage workflows.
- Refresh source revision metadata when the Git state changes.
- Preserve optional thread limits when parsing persistence metadata.
- Enforce move-table consistency and avoid duplicate cell classification.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
CMakeLists.txt (1)

36-41: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Track the resolved branch ref and worktree Git directory.

HEAD is normally symbolic, so a branch commit updates refs/heads/<branch>, not .git/HEAD; linked worktrees also use a .git file and skip this block. Resolve paths via git rev-parse --git-path and register the resolved branch ref plus packed-refs, HEAD, and index.

#!/usr/bin/env bash
set -euo pipefail

git rev-parse --is-inside-work-tree
git rev-parse --git-path HEAD
git rev-parse --git-path index
git rev-parse --git-path packed-refs

ref="$(git symbolic-ref -q HEAD || true)"
if [[ -n "${ref}" ]]; then
  git rev-parse --git-path "${ref}"
fi
🤖 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 `@CMakeLists.txt` around lines 36 - 41, Update the Git dependency configuration
around the CMAKE_CONFIGURE_DEPENDS property to support linked worktrees and
symbolic branches: use git rev-parse --git-path to resolve HEAD, index,
packed-refs, and the current symbolic HEAD ref, then register the resolved
paths. Replace the IS_DIRECTORY .git guard so repositories whose .git entry is a
file are handled as well.
🤖 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.

Duplicate comments:
In `@CMakeLists.txt`:
- Around line 36-41: Update the Git dependency configuration around the
CMAKE_CONFIGURE_DEPENDS property to support linked worktrees and symbolic
branches: use git rev-parse --git-path to resolve HEAD, index, packed-refs, and
the current symbolic HEAD ref, then register the resolved paths. Replace the
IS_DIRECTORY .git guard so repositories whose .git entry is a file are handled
as well.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: af5b010a-014e-4504-a57a-341ef649c450

📥 Commits

Reviewing files that changed from the base of the PR and between 862637a and 6ef7dd6.

📒 Files selected for processing (9)
  • .github/CONTRIBUTING.md
  • .github/workflows/ci.yml
  • .github/workflows/codecov-upload.yml
  • CMakeLists.txt
  • CMakePresets.json
  • include/Foliated_triangulation.hpp
  • include/Move_tracker.hpp
  • include/Utilities.hpp
  • tests/Utilities_test.cpp
💤 Files with no reviewable changes (1)
  • CMakePresets.json

Keep Unix CI on pkgx and restrict the CMake and Ninja wheel fallback to
Windows, where the pkgx packages are unavailable.

- Install locked Python tooling exclusively from wheels
- Use pinned upstream actionlint and zizmor distributions
- Enforce the toolchain policy with a repository Semgrep rule
- Refresh development-tool and GitHub Action pins

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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 23-27: Update the semgrep rule’s pattern-either matcher to
recognize uv tool install commands, including flags such as --no-build, when
installing cmake or ninja. Preserve the existing Windows fallback fixture and
add a non-Windows negative fixture covering the uv installation path.
🪄 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.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5e6f79ae-9977-4c36-8eac-597324b56f3f

📥 Commits

Reviewing files that changed from the base of the PR and between 6ef7dd6 and f01fca6.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (10)
  • .github/CONTRIBUTING.md
  • .github/actions/setup-just/action.yml
  • .github/workflows/ci.yml
  • Justfile
  • README.md
  • pyproject.toml
  • scripts/mnist_experiment.py
  • scripts/optimize_initialize.py
  • semgrep.yaml
  • tests/semgrep/tooling_policy.yml

Comment thread semgrep.yaml
Resolve pkgx’s concrete CA path before vcpkg bootstrap so Unix CI and
coverage jobs do not pass an unexpanded fallback expression to curl.

Extend the pkgx-first Semgrep policy to reject non-Windows uv toolchain
installations while preserving the approved Windows wheel fallback.
- Disable unused C++ module scanning so CodeQL can observe compiler calls.
- Run the CGAL/oneTBB contract only on pinned Ubuntu toolchains while retaining reference coverage across all platforms.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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 28-39: The Windows exclusion in the Semgrep rule must only allow
the documented pinned cmake/ninja fallback, not every Windows uv tool install.
Update the rule near the existing Windows pattern exclusion to require the
permitted fallback conditions, and add negative Windows fixtures in
tests/semgrep/tooling_policy.yml at lines 30-34 for installs lacking --no-build
or a pinned cmake/ninja package; preserve the existing documented pinned
fallback fixture.
🪄 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.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0b1b98ba-5616-4505-9f50-7ead280bf63e

📥 Commits

Reviewing files that changed from the base of the PR and between f01fca6 and 56f13cd.

📒 Files selected for processing (8)
  • .github/CONTRIBUTING.md
  • .github/workflows/ci.yml
  • .github/workflows/codecov-upload.yml
  • CMakeLists.txt
  • README.md
  • docs/multithreading.md
  • semgrep.yaml
  • tests/semgrep/tooling_policy.yml

Comment thread semgrep.yaml
@acgetchell
acgetchell merged commit 49dbce2 into main Jul 25, 2026
13 checks passed
@acgetchell
acgetchell deleted the feat/88-multithreading-finalization branch July 25, 2026 05:57
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.

Restore and validate multithreaded C++ support

1 participant