Skip to content

Move committedCheckpointId from ChainManager to InMemoryStore - #1264

Merged
DZakh merged 2 commits into
mainfrom
claude/keen-mayer-Q4DrT
Jun 1, 2026
Merged

Move committedCheckpointId from ChainManager to InMemoryStore#1264
DZakh merged 2 commits into
mainfrom
claude/keen-mayer-Q4DrT

Conversation

@DZakh

@DZakh DZakh commented Jun 1, 2026

Copy link
Copy Markdown
Member

Summary

Refactors checkpoint tracking by moving committedCheckpointId from ChainManager to InMemoryStore, where it logically belongs as part of the in-memory state. This simplifies the ChainManager type and makes checkpoint state management more cohesive.

Key Changes

  • Removed committedCheckpointId field from ChainManager.t type
  • Updated ChainManager.createBatch to accept committedCheckpointId as a parameter instead of reading from the manager
  • Moved checkpoint initialization to InMemoryStore.make, accepting it as an optional parameter defaulting to Internal.initialCheckpointId
  • Updated Main.res to initialize InMemoryStore with the checkpoint ID from persisted state
  • Removed checkpoint update logic from GlobalState.updateProgressedChains (no longer needed in ChainManager)
  • Updated all call sites to pass committedCheckpointId from state.ctx.inMemoryStore instead of state.chainManager
  • Updated test fixtures to remove the field from ChainManager construction

Implementation Details

  • InMemoryStore.make now accepts an optional ~committedCheckpointId parameter, initialized from persisted state during startup
  • ChainManager.createBatch now requires committedCheckpointId as an explicit parameter, making the dependency clear at call sites
  • All references to checkpoint state now flow through InMemoryStore, centralizing state management

https://claude.ai/code/session_017aScst99c1b2ETxLY7fyTb

Summary by CodeRabbit

  • Refactor
    • Reorganized internal checkpoint state management to improve system reliability and code maintainability.

claude added 2 commits June 1, 2026 13:11
Remove the duplicated committedCheckpointId field from ChainManager and
read it from InMemoryStore instead. The store now seeds its committed
checkpoint from the resumed DB state so createBatch and rollback derive
the next checkpoint id from a single source.
@coderabbitai

coderabbitai Bot commented Jun 1, 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4300b929-b3f3-43ae-842b-f65d6fed67d6

📥 Commits

Reviewing files that changed from the base of the PR and between 4073059 and b1dad19.

📒 Files selected for processing (5)
  • packages/envio/src/ChainManager.res
  • packages/envio/src/GlobalState.res
  • packages/envio/src/InMemoryStore.res
  • packages/envio/src/Main.res
  • scenarios/test_codegen/test/ChainManager_test.res

📝 Walkthrough

Walkthrough

The PR refactors checkpoint state ownership by moving committedCheckpointId from ChainManager.t to InMemoryStore, threading it through startup and batch-creation flows. ChainManager.createBatch now accepts the checkpoint ID as an explicit parameter, and all callers (GlobalState, tests) source it from InMemoryStore instead of ChainManager.

Changes

Checkpoint state ownership refactoring

Layer / File(s) Summary
InMemoryStore checkpoint initialization
packages/envio/src/InMemoryStore.res
InMemoryStore.make now accepts an optional ~committedCheckpointId parameter (defaulting to Internal.initialCheckpointId) instead of hardcoding the initial value, enabling bootstrap with pre-existing checkpoint state.
Main startup checkpoint bootstrap
packages/envio/src/Main.res
Main.start now passes committedCheckpointId from the initialized persistence state into InMemoryStore.make, coupling in-memory and persisted checkpoint IDs at startup.
ChainManager.createBatch API update
packages/envio/src/ChainManager.res
ChainManager.t removes the committedCheckpointId field. createBatch now accepts ~committedCheckpointId as an explicit parameter instead of reading from the chainManager record, using it to compute checkpointIdBeforeBatch.
GlobalState batch and rollback routing
packages/envio/src/GlobalState.res
ProcessEventBatch, rollback diff preparation, and rollback logging now read committedCheckpointId from state.ctx.inMemoryStore instead of state.chainManager, and pass it explicitly to createBatch. updateProgressedChains no longer overwrites committedCheckpointId from batch results.
ChainManager_test updates
scenarios/test_codegen/test/ChainManager_test.res
Test helper removes explicit committedCheckpointId: 0n field from ChainManager construction (no longer part of type) and explicitly passes ~committedCheckpointId=Internal.initialCheckpointId to createBatch invocations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • enviodev/hyperindex#1247: Routes checkpoint-related rollback diff creation through InMemoryStore with updates to GlobalState.res and how InMemoryStore.prepareRollbackDiff uses committed checkpoint IDs.
  • enviodev/hyperindex#1263: Refactors checkpoint handling around committedCheckpointId in InMemoryStore/batch paths, threading it into ChainManager.createBatch and downstream entity history preservation.
  • enviodev/hyperindex#1256: Modifies rollback flow around checkpoint ID computation and persistence, representing both targetCheckpointId and diffCheckpointId through Persistence.rollback.

Suggested reviewers

  • JonoPrest
  • JasoonS
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main refactoring: moving committedCheckpointId state management from ChainManager to InMemoryStore, which is the central theme across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@DZakh
DZakh merged commit 68273e5 into main Jun 1, 2026
8 checks passed
@DZakh
DZakh deleted the claude/keen-mayer-Q4DrT branch June 1, 2026 13:37
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.

2 participants