feat(mcp): restore durable checkpoints - #8703
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
There was a problem hiding this comment.
Effect service conventions review of the changed TypeScript. Three findings, all in the new checkpoint-restore path: two concern classifying tagged failures by message/tag text instead of structurally, and one is a namespace-erasing service import in the new integration test. Everything else (new CheckpointStore.readWorkspaceFingerprint, VcsCheckpointOps extension, Schema.TaggedErrorClass usage, layer wiring) follows the conventions.
Posted via Macroscope — Effect Service Conventions
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR introduces a new destructive MCP checkpoint-restore workflow spanning contracts, Git state handling, orchestration, provider rollback, durable outbox recovery, and shared concurrency control. Its filesystem and provider side effects, partial-failure semantics, and changes to existing rollback execution require human review. You can add or adjust custom eligibility rules. Learn more. |
301bc3e to
620f80d
Compare
620f80d to
dbf55ef
Compare
There was a problem hiding this comment.
One convention finding: the new optional reason discriminator on CheckpointRestoreError drives caller control flow (and the caller-visible PARTIAL/FAILED status), which the conventions ask to model as distinct error classes. The three issues raised on the previous revision (message-substring classification of orchestrator failures, lastError.includes("result is partial"), and layer as ... aliased service imports in the integration test) are all resolved.
Posted via Macroscope — Effect Service Conventions
Thread transfer impact
This comment will update automatically after the next completed run. |
There was a problem hiding this comment.
Effect service conventions review: one finding on error modeling for the new checkpoint restore path. The import/namespace and Effect.catchTags issues raised on the previous revision look addressed.
Posted via Macroscope — Effect Service Conventions
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
Bugbot Autofix is ON, but a cloud agent failed to start.
Reviewed by Cursor Bugbot for commit dbf55ef. Configure here.
There was a problem hiding this comment.
One convention finding on the new guarded-restore failure classification. Details inline.
Posted via Macroscope — Effect Service Conventions
There was a problem hiding this comment.
One convention issue found in the new checkpoint rollback error model.
Posted via Macroscope — Effect Service Conventions
There was a problem hiding this comment.
One convention finding on the new checkpoint rollback error split. Everything else in the changed Effect service code (namespace imports, Foo["Service"] usage, Effect.catchTags at the MCP dispatch boundary, structured Schema.TaggedErrorClass failures with preserved cause, and the new ThreadDispatchLockV2 tag/layer wiring) looks consistent with the conventions.
Posted via Macroscope — Effect Service Conventions

Agents could identify durable checkpoints but had no safe MCP path to request the application's existing serialized rollback workflow or observe its durable outcome.
This adds explicit
t3_checkpoint_restoreover ordinary V2checkpoint.rollback, including exact scope/checkpoint identity, an explicit discard acknowledgement, durable idempotency keys, accepted receipts, and truthful REQUESTED/APPLIED/FAILED/PARTIAL outcomes.Behavior:
Focused validation:
Dependency: upper layer of native stack #8713; requires #8702 for checkpoint discovery, identity, and MCP registration.
Implemented by GPT-5.6-Sol via Codex in T3 Code.
Note
High Risk
Destructive Git workspace restore with new concurrency guards and partial-failure semantics; mistakes could corrupt worktrees or mis-report rollback outcomes to agents.
Overview
Adds
t3_checkpoint_restore, an MCP entry point that accepts an exact checkpoint/scope, requiresdiscardChanges: true, and drives the existing V2checkpoint.rollbackcommand with durableclientRequestIdidempotency, receipts, and REQUESTED / APPLIED / FAILED / PARTIAL status from outbox effects.Before dispatch, the service validates thread idle state, provider rollback support, ref availability, and captures an
expectedWorkspaceFingerprintvia newreadWorkspaceFingerprint(Git temp-index hash of tracked, untracked, and staged state scoped to restore cwd).CheckpointService.restorerefuses to mutate the worktree when the fingerprint drifts or optional pre-restore checks fail.CheckpointRollbackServicenow runs underThreadDispatchLockV2, re-reads projections at admission, rejects ambiguous rollback targets, and maps filesystem/provider/persistence failures into rejected, retryable preflight, or partial errors. Guarded rollbacks carryexpectedIdleand the fingerprint on outboxprovider-thread.rollbackeffects; the worker assignscheckpoint_restore_rejected/checkpoint_restore_partialfailure codes, avoids retrying partial outcomes, and marks uncertain guarded restores failed after process loss.Unit and integration tests cover MCP restore behavior, fingerprint edge cases, admission races, and rollback error classification.
Reviewed by Cursor Bugbot for commit 8f94a42. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add durable
t3_checkpoint_restoreMCP tool with guarded, idempotent checkpoint rollbackt3_checkpoint_restorethat dispatches acheckpoint.rollbackcommand withexpectedIdleandexpectedWorkspaceFingerprintguards, then reports idempotent results (REQUESTED, APPLIED, FAILED, PARTIAL) via durable command receipts and effect status.readWorkspaceFingerprintinGitVcsDriverandCheckpointStoreto hash the worktree tree OID and staged index, detecting concurrent changes before a restore.ThreadDispatchLockV2serial executor and performs two-phase admission: an initial snapshot check, then avalidateBeforeRestoreprecondition check immediately before mutating the workspace.CheckpointRollbackRejectedError(precondition/idle/target violations),CheckpointRollbackPreflightError(retryable preflight failures), andCheckpointRollbackPartialError(restore completed but provider rollback or finalization failed); these map to structuredfailureCodevalues persisted in the effect outbox.reconcileAfterProcessLossterminally fails guarded rollback effects ascheckpoint_restore_partialinstead of requeueing, preventing unsafe replay after a partial filesystem restore.CheckpointServiceV2Errorreplaces the singleCheckpointRestoreErrorwith a union of three variants; callers that pattern-matched on the oldCheckpointRestoreErrortag must update to handleCheckpointRestorePreconditionError,CheckpointRestorePreflightError, andCheckpointRestoreOutcomeUnknownError.Macroscope summarized 8f94a42.