Skip to content
This repository was archived by the owner on Aug 12, 2026. It is now read-only.

feat(reproducibility): add initial-state loading and checkpoint resume - #157

Merged
acgetchell merged 4 commits into
mainfrom
docs/90-release-readiness
Aug 11, 2026
Merged

feat(reproducibility): add initial-state loading and checkpoint resume#157
acgetchell merged 4 commits into
mainfrom
docs/90-release-readiness

Conversation

@acgetchell

@acgetchell acgetchell commented Aug 11, 2026

Copy link
Copy Markdown
Owner
  • let initialize publish manifested states that cdt validates before starting a new seeded transition stream
  • persist PCG state, global pass cadence, transition trace, counters, and producer identity for exact continuation
  • expose load and resume workflows for local and interrupted HPC runs
  • canonicalize CGAL flip descriptors and reject ambiguous coordinate states at evolution boundaries
  • reorganize user and maintainer documentation around the supported archival workflows

Closes #90

Summary by CodeRabbit

  • New Features

    • Added command-line and Justfile workflows for loading initial states and resuming checkpoints.
    • Resumed runs preserve random state, progress, transition statistics, and reproducibility metadata.
    • Added validation for input artifacts, checkpoints, provenance, compatibility, and invalid resume scenarios.
    • Improved move handling to reject duplicate coordinates and produce deterministic results.
  • Documentation

    • Reorganized the README and expanded maintenance, reproducibility, API, workflow, and reference documentation.
  • Bug Fixes

    • Improved canonical move execution and prevented state changes when invalid moves are rejected.
  • Tests

    • Added integration and regression coverage for initialization, checkpoint recovery, persistence, randomness, and move behavior.

- let initialize publish manifested states that cdt validates before starting a new seeded transition stream
- persist PCG state, global pass cadence, transition trace, counters, and producer identity for exact continuation
- expose load and resume workflows for local and interrupted HPC runs
- canonicalize CGAL flip descriptors and reject ambiguous coordinate states at evolution boundaries
- reorganize user and maintainer documentation around the supported archival workflows
@acgetchell acgetchell self-assigned this Aug 11, 2026
@acgetchell
acgetchell enabled auto-merge August 11, 2026 04:51
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 35 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8a754115-1c3e-48b7-a50a-79baf24086e2

📥 Commits

Reviewing files that changed from the base of the PR and between 17bb7fb and 7e8734f.

📒 Files selected for processing (9)
  • cmake/RunCheckpointResumeTest.cmake
  • cmake/RunInitializeToCdtTest.cmake
  • include/Metropolis.hpp
  • include/Random.hpp
  • tests/CMakeLists.txt
  • tests/Metropolis_test.cpp
  • tests/Move_run_test.cpp
  • tests/Random_emulated_test.cpp
  • tests/Utilities_test.cpp

Walkthrough

The change adds initial-triangulation input and exact checkpoint resumption. It extends persistence metadata with provenance, RNG state, counters, and validation. It hardens move determinism, adds integration tests, updates workflow recipes, and expands archival documentation.

Changes

Artifact workflows and reproducibility

Layer / File(s) Summary
Canonical move execution
include/Ergodic_moves_3.hpp, tests/Ergodic_moves_3_audit_test.cpp, docs/ergodic-moves.md
Move execution now canonicalizes descriptors, validates stale references, and rejects duplicate centroids atomically.
Persistence and continuation state
include/Utilities.hpp, include/Random.hpp, include/Metropolis.hpp, include/Move_run.hpp, include/Move_always.hpp, tests/Random_test.cpp, tests/Metropolis_test.cpp, tests/Move_run_test.cpp, tests/Utilities_test.cpp
Metadata now stores validated provenance, PCG state, cumulative counters, toolchain data, and checkpoint continuation state.
Input and resume command workflows
src/cdt.cpp, Justfile, cmake/RunInitializeToCdtTest.cmake, cmake/RunCheckpointResumeTest.cmake, src/CMakeLists.txt
The CLI and workflow recipes support initial artifacts and checkpoint resumption. Integration tests cover successful, rejected, corrupted, completed, and extended resumes.
Maintenance and artifact documentation
.github/CONTRIBUTING.md, README.md, docs/api-boundary.md, docs/reproducibility.md, reference/README.md, scripts/validate_generated_site.py
Archival maintenance, platform requirements, artifact contracts, reproducibility rules, validation commands, and generated-site requirements are documented.

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

Sequence Diagram(s)

sequenceDiagram
  participant initializer
  participant cdt
  participant read_initial_triangulation
  participant read_checkpoint
  participant Metropolis
  initializer->>initializer: write initial-triangulation artifact
  cdt->>read_initial_triangulation: validate --input artifact
  read_initial_triangulation->>Metropolis: provide new-run triangulation
  cdt->>read_checkpoint: validate --resume artifact
  read_checkpoint->>Metropolis: provide exact continuation state
Loading

Possibly related PRs

Poem

Initial states find their way,
Checkpoints wake to finish play.
Counters, seeds, and paths align,
Moves stay canonical and fine.
Tests guard every stored sign.
Archive doors now close in time.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.58% 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 changes: initial-state loading and checkpoint resumption for reproducibility.
Linked Issues check ✅ Passed The changes implement the manifested initial-state workflow, input validation, provenance, checkpoint resume, CTest coverage, and required documentation for issue #90.
Out of Scope Changes check ✅ Passed The changes support the stated reproducibility, integrity, testing, canonicalization, and archival documentation objectives without adding unrelated scientific or architectural work.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/90-release-readiness

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 `@cmake/RunInitializeToCdtTest.cmake`:
- Around line 166-180: Create a checkpoint artifact in a separate temporary
directory within the test flow, then invoke the CDT executable with that
checkpoint via --input using the same initial-artifact validation pattern as the
final-artifact case. Require a nonzero result and verify the output/error log
contains “CDT input must be an initial-triangulation artifact,” using the
existing checkpoint-generation symbols and cleanup conventions.

In `@docs/ergodic-moves.md`:
- Around line 123-128: Update the list around the malformed-handle and
facet-centroid items by removing the trailing “and” connector from the earlier
item, leaving the connector only on the final list item.

In `@include/Utilities.hpp`:
- Around line 2415-2418: Introduce a role-neutral artifact type for the shared
structure currently represented by Initial_triangulation_artifact, then define
both Initial_triangulation_artifact and Checkpoint_artifact as aliases to it.
Update the relevant template documentation and preserve existing reader
interfaces while ensuring read_checkpoint exposes the neutral type name.
- Around line 1443-1455: Ensure the provenance construction used by Metropolis_3
supplies max_threads for resumable checkpoints, or marks metadata non-resumable
when the caller omits it. Update the relevant default-provenance/API path while
preserving max_threads in complete_resume_state, since resume handling requires
it to determine the effective thread count.

In `@tests/Ergodic_moves_3_audit_test.cpp`:
- Around line 727-728: Update the assertion around cell_iteration_order in the
affected test to avoid requiring CGAL’s raw finite-cell traversal order; either
change REQUIRE_FALSE to WARN_FALSE for diagnostic-only output or remove the
check, while preserving canonical-state equality as the test contract.

In `@tests/Utilities_test.cpp`:
- Around line 757-773: Extract the duplicated resumable-checkpoint metadata
assignments into a local helper named make_resumable_checkpoint_metadata near
the existing test helpers, returning the fully initialized
Reproducibility_metadata. Replace the repeated setup in both scenarios with
calls to this helper, preserving all current values and ensuring both tests use
the same complete resume contract.
🪄 Autofix

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: ef7a04ea-2390-41d0-9c6d-d4518f84c813

📥 Commits

Reviewing files that changed from the base of the PR and between bdb756c and e1305d6.

📒 Files selected for processing (23)
  • .github/CONTRIBUTING.md
  • Justfile
  • README.md
  • cmake/RunCheckpointResumeTest.cmake
  • cmake/RunInitializeToCdtTest.cmake
  • docs/api-boundary.md
  • docs/ergodic-moves.md
  • docs/reproducibility.md
  • include/Ergodic_moves_3.hpp
  • include/Metropolis.hpp
  • include/Move_always.hpp
  • include/Move_run.hpp
  • include/Random.hpp
  • include/Utilities.hpp
  • reference/README.md
  • scripts/validate_generated_site.py
  • src/CMakeLists.txt
  • src/cdt.cpp
  • tests/Ergodic_moves_3_audit_test.cpp
  • tests/Metropolis_test.cpp
  • tests/Move_run_test.cpp
  • tests/Random_test.cpp
  • tests/Utilities_test.cpp

Comment thread cmake/RunInitializeToCdtTest.cmake
Comment thread docs/ergodic-moves.md
Comment thread include/Utilities.hpp
Comment thread include/Utilities.hpp Outdated
Comment thread tests/Ergodic_moves_3_audit_test.cpp Outdated
Comment thread tests/Utilities_test.cpp Outdated
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.72358% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.43%. Comparing base (bdb756c) to head (7e8734f).

Files with missing lines Patch % Lines
include/Utilities.hpp 97.97% 6 Missing ⚠️
src/cdt.cpp 96.93% 5 Missing ⚠️
include/Ergodic_moves_3.hpp 96.15% 2 Missing ⚠️
include/Random.hpp 95.23% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #157      +/-   ##
==========================================
+ Coverage   91.11%   92.43%   +1.32%     
==========================================
  Files          19       19              
  Lines        3476     3990     +514     
  Branches     1614     1908     +294     
==========================================
+ Hits         3167     3688     +521     
+ Misses        309      302       -7     
Files with missing lines Coverage Δ
include/Metropolis.hpp 96.74% <100.00%> (+2.00%) ⬆️
include/Move_always.hpp 89.55% <ø> (ø)
include/Move_run.hpp 97.22% <100.00%> (+0.12%) ⬆️
include/Random.hpp 92.06% <95.23%> (+1.58%) ⬆️
include/Ergodic_moves_3.hpp 94.58% <96.15%> (+0.51%) ⬆️
src/cdt.cpp 93.35% <96.93%> (+4.70%) ⬆️
include/Utilities.hpp 86.14% <97.97%> (+4.34%) ⬆️

... and 3 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bdb756c...7e8734f. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Reject checkpoint artifacts supplied as fresh CDT input.
- Advertise checkpoints as resumable only with complete thread and RNG state.
- Validate restored PCG streams against the engine’s normalized stream.
- Share one artifact representation across initialization and checkpoint roles.

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
include/Metropolis.hpp (1)

251-266: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Validate the supplied generator against checkpoint state.

Lines 251-266 only require that transition_random_state exists. They do not verify that m_generator is restored to that state. A caller can pass another cdt::Random with resumable metadata. The strategy then restores counters but advances a different PCG state. The generated checkpoint can falsely claim exact continuation.

Compare the supplied generator seed, stream, and serialized state with the recorded checkpoint state before clearing transition_random_state. Add a rejection test that supplies a different generator.

Proposed fix
       if (m_completed_passes > 0 || m_reproducibility.transition_random_state)
       {
         if (!m_reproducibility.configured_passes ||
             *m_reproducibility.configured_passes != total_passes ||
             !m_reproducibility.transition_random_state)
         {
           throw std::invalid_argument(
               "Checkpoint resume state does not match its pass range.");
         }
+        if (m_generator.seed() != m_reproducibility.seed ||
+            m_generator.stream() != m_reproducibility.transition_stream ||
+            m_generator.serialized_state() !=
+                *m_reproducibility.transition_random_state)
+        {
+          throw std::invalid_argument(
+              "Checkpoint resume generator does not match saved state.");
+        }
         restore_statistics(m_reproducibility);
         m_resume_pending = true;
       }

As per path instructions: "Focus on design patterns, interfaces, and encapsulation".

🤖 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 `@include/Metropolis.hpp` around lines 251 - 266, Update the resume validation
in the constructor or setup method containing m_reproducibility so it compares
the supplied m_generator’s seed, stream, and serialized state with
transition_random_state before restore_statistics and before clearing it. Reject
any mismatch, while preserving the existing pass-range validation and successful
continuation for an identical generator; add a test that resumes with a
different cdt::Random and expects rejection.

Source: Path instructions

🤖 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 `@include/Metropolis.hpp`:
- Around line 550-554: Update the checkpoint branch in Metropolis serialization
to require metadata.max_threads to contain a positive value, not merely any
optional value, before assigning transition_random_state. Preserve the existing
checkpoint and state-serialization behavior for valid positive limits, and add
coverage for max_threads = 0.

---

Outside diff comments:
In `@include/Metropolis.hpp`:
- Around line 251-266: Update the resume validation in the constructor or setup
method containing m_reproducibility so it compares the supplied m_generator’s
seed, stream, and serialized state with transition_random_state before
restore_statistics and before clearing it. Reject any mismatch, while preserving
the existing pass-range validation and successful continuation for an identical
generator; add a test that resumes with a different cdt::Random and expects
rejection.
🪄 Autofix

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: 45249292-030a-43cc-bc61-b86bd6f2dc7e

📥 Commits

Reviewing files that changed from the base of the PR and between e1305d6 and 17bb7fb.

📒 Files selected for processing (8)
  • cmake/RunInitializeToCdtTest.cmake
  • docs/ergodic-moves.md
  • include/Metropolis.hpp
  • include/Random.hpp
  • include/Utilities.hpp
  • tests/Ergodic_moves_3_audit_test.cpp
  • tests/Metropolis_test.cpp
  • tests/Utilities_test.cpp

Comment thread include/Metropolis.hpp
- reject generators and thread limits that cannot reproduce saved state
- restore PCG checkpoints when using emulated 128-bit arithmetic
@acgetchell
acgetchell merged commit 169c272 into main Aug 11, 2026
18 checks passed
@acgetchell
acgetchell deleted the docs/90-release-readiness branch August 11, 2026 09:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Approve CDT++ v1.0.0 release readiness

1 participant