Skip to content

SIP279 SIPNET Restart MVP - #276

Merged
dlebauer merged 67 commits into
masterfrom
codex/restart-mvp-master
Mar 16, 2026
Merged

SIP279 SIPNET Restart MVP#276
dlebauer merged 67 commits into
masterfrom
codex/restart-mvp-master

Conversation

@dlebauer

@dlebauer dlebauer commented Feb 22, 2026

Copy link
Copy Markdown
Member

Summary

  • What: Adds MVP full-state restart support for segmented SIPNET runs.
    • Introduces ASCII text restart file as restart schema v1.0
    • Stops at end of .clim file and writes a restart file RESTART_OUT
    • Restarts by specifying RESTART_IN file
    • Writes one output file per climate segment (these outputs can be concatenated downstream)
  • Motivation:
    1. To support parameter changes to represent planting of a different PFT
    2. To support state data assimilation

How was this change tested?

Ran:

  • make sipnet
  • make testbuild
  • make testrun
  • make smoke

Added restart test coverage:

  • hop test: continuous vs segmented equivalence
  • same-day multi-event boundary non-replay
  • climate ordering
  • schema mismatch failure
  • model/build mismatch failure
  • truncated checkpoint failure
  • no-restart unchanged behavior

Key Changes

  • Runtime restart module:
    • src/sipnet/restart.c
    • src/sipnet/restart.h
  • Runtime wiring:
    • src/sipnet/sipnet.c
    • src/common/context.c
    • src/sipnet/cli.c
  • Event determinism helpers:
    • src/sipnet/events.c
    • src/sipnet/events.h
  • Tests:
    • tests/sipnet/test_restart_infrastructure/testRestartMVP.c
  • Docs:
    • docs/user-guide/running-sipnet.md
    • docs/developer-guide/restart-checkpoint.md
    • mkdocs.yml

Related Issues

Checklist

  • Related issues are listed above. PRs without an approved, related issue may not get reviewed.
  • PR title has the issue number in it ("[#] <concise description of proposed change>")
  • Tests added/updated for new features (if applicable)
  • Documentation updated (if applicable)
  • docs/CHANGELOG.md updated with noteworthy changes
  • Code formatted with clang-format (run git clang-format if needed)

Notes

  • Restart climate input must begin with a timestamp (year, day, time) that occurs after the last segment.
  • Implementation and initial test scaffolding in this PR was generated with OpenAI Codex based on my specifications and review, but my C skills are limited. My specifications were based on issues linked above.

Copilot AI review requested due to automatic review settings February 22, 2026 06:57

Copilot AI 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.

Pull request overview

Adds strict binary restart checkpointing to SIPNET to support segmented runs with deterministic resume validation (climate boundary, runtime flags, event cursor determinism), plus integration-style unit tests and documentation.

Changes:

  • Introduces src/sipnet/restart.c/.h to write/load full-state checkpoints with strict compatibility checks.
  • Wires restart options through CLI + Context and integrates checkpoint load/write into the main run loop.
  • Adds event determinism helpers (event cursor + hashing) and new restart-focused tests/docs.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
Makefile Adds restart.c to SIPNET build.
src/sipnet/sipnet.c Loads checkpoint at run start, records processed climate steps, writes checkpoint at run end.
src/sipnet/state.h Adds Trackers.lastYear so yearly rollover state can be checkpointed/restored.
src/sipnet/restart.c Implements schema v1 restart header/payload read/write + strict validations.
src/sipnet/restart.h Declares restart module APIs used by runtime.
src/sipnet/events.c Adds event cursor indexing and deterministic hashing helpers.
src/sipnet/events.h Exposes new event cursor/hash APIs for restart determinism checks.
src/sipnet/cli.c Adds --restart-in/--restart-out and --restart-strict; fixes --file-name to require an argument.
src/sipnet/cli.h Updates flag-option count for CLI/context mapping.
src/common/context.c Adds restart config keys, enforces strict mode when restart is used, hides restart keys from config dump.
src/common/context.h Adds restartStrict, restartIn, restartOut fields to Context.
tests/sipnet/test_restart_infrastructure/Makefile Builds/runs the new restart MVP test binary in the unit test harness.
tests/sipnet/test_restart_infrastructure/testRestartMVP.c Adds restart MVP integration test coverage (equivalence, mismatch failures, truncation, etc.).
tests/sipnet/test_restart_infrastructure/restart.param Parameter fixture for deterministic restart tests.
tests/sipnet/test_restart_infrastructure/events_base.in Event fixture used to validate deterministic event resume.
tests/sipnet/test_restart_infrastructure/restart_cont.in Continuous-run input fixture.
tests/sipnet/test_restart_infrastructure/restart_seg1.in Segment 1 input fixture (writes checkpoint).
tests/sipnet/test_restart_infrastructure/restart_seg2.in Segment 2 input fixture (loads checkpoint).
tests/sipnet/test_restart_infrastructure/restart_seg2_bad.in Segment 2 input fixture for mismatch failure.
tests/sipnet/test_restart_infrastructure/restart_full.clim Climate fixture for continuous run.
tests/sipnet/test_restart_infrastructure/restart_segment1.clim Climate fixture for segment 1.
tests/sipnet/test_restart_infrastructure/restart_segment2.clim Climate fixture for segment 2 (valid boundary row).
tests/sipnet/test_restart_infrastructure/restart_segment2_bad.clim Climate fixture for segment 2 mismatch failure.
docs/user-guide/running-sipnet.md Documents restart options and strict constraints for users.
docs/user-guide/model-inputs.md Adds restart options/flag to the run-time options documentation.
docs/developer-guide/restart-checkpoint.md Adds developer-facing checkpoint schema/validation contract.
mkdocs.yml Adds restart checkpoint spec page to MkDocs navigation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sipnet/restart.c Outdated
Comment thread src/sipnet/restart.c Outdated
Comment thread src/sipnet/sipnet.c Outdated
Comment thread src/common/context.c Outdated
Comment thread docs/user-guide/model-inputs.md Outdated
@dlebauer
dlebauer marked this pull request as draft February 23, 2026 18:44
@dlebauer dlebauer changed the title Add strict MVP restart checkpoints with deterministic resume validation SIPNET Restart MVP Feb 23, 2026
@dlebauer
dlebauer marked this pull request as ready for review February 23, 2026 22:17
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@dlebauer
dlebauer requested a review from Copilot February 23, 2026 22:45

Copilot AI 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.

Pull request overview

Copilot reviewed 29 out of 29 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/sipnet/restart.c Outdated
Comment thread src/sipnet/restart.c Outdated
Comment thread src/common/context.c Outdated
Comment thread docs/user-guide/model-inputs.md Outdated

@dlebauer dlebauer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Bump version before merging

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@dlebauer dlebauer linked an issue Feb 24, 2026 that may be closed by this pull request

Copilot AI 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.

Pull request overview

Copilot reviewed 59 out of 60 changed files in this pull request and generated 12 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/sipnet/test_restart_infrastructure/testRestartMissedEnvi.c
Comment thread tests/sipnet/test_restart_infrastructure/testRestartMissedCtx.c
Comment thread tests/utils/tUtils.h Outdated
Comment thread tests/sipnet/test_restart_infrastructure/testRestartMVP.c
Comment thread tests/sipnet/test_restart_infrastructure/testRestartMVP.c
Comment thread docs/developer-guide/restart-checkpoint.md Outdated
Comment thread tests/utils/tUtils.h Outdated
Comment thread tests/sipnet/test_restart_infrastructure/testRestartMVP.c Outdated
Comment thread src/sipnet/restart.c Outdated
Comment thread CMakeLists.txt Outdated
Alomir and others added 3 commits March 16, 2026 16:36
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@Alomir Alomir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me (and to copilot, which is good given how much I reworked)

@dlebauer
dlebauer merged commit 2dec362 into master Mar 16, 2026
12 checks passed
@dlebauer
dlebauer deleted the codex/restart-mvp-master branch March 16, 2026 21:06
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.

Implement MVP full-state restart support in SIPNET

4 participants