Add repo checkpoint policy - #1496
Conversation
Define checkpoint format parsing and policy validation for the repo-wide checkpoint policy ref. Entire-Checkpoint: 1d8503f2a450
Read and write checkpoint policy commits at refs/entire/policies/checkpoint using the existing checkpoint commit signing path. Entire-Checkpoint: 6d613e0a7f30
Fetch, fast-forward, and strictly push the checkpoint policy ref through the configured checkpoint remote. Entire-Checkpoint: adbacd1779b7
Expose repo-wide checkpoint policy inspection and updates through entire policy checkpoint. The update path fetches the remote policy before validation, rejects downgrades unless forced, and pushes only the checkpoint policy ref. Entire-Checkpoint: 5578a456290c
Warn interactive users when the repo policy requires newer checkpoint support. Reject user-driven checkpoint reads for unsupported formats, and skip checkpoint writes or pushes from hooks when the configured policy cannot be written by this CLI. Entire-Checkpoint: b2c7f027b944
Describe the checkpoint policy ref, schema, synchronization points, and hook behavior. Entire-Checkpoint: 20bac3016946
There was a problem hiding this comment.
Pull request overview
This PR introduces a repo-wide checkpoint policy stored in Git (refs/entire/policies/checkpoint) so the CLI and hooks can warn/skip incompatible checkpoint writes and fail clearly on unsupported checkpoint reads, improving cross-version compatibility for checkpoint data.
Changes:
- Add a new
checkpointpolicypackage that reads/writes a versionedpolicy.jsoncommit and can sync/push it against the configured checkpoint remote. - Add
entire policy checkpointfor inspecting/updating the repo policy, plus a global post-command warning when the policy requires a newer CLI. - Enforce checkpoint format compatibility checks in user-driven commands (explain/resume) and in manual-commit strategy flows (pre-push, condensation, log restore).
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/architecture/sessions-and-checkpoints.md | Documents the new repo-wide checkpoint policy ref, schema, and hook/command behaviors. |
| cmd/entire/main.go | Adds a post-command policy upgrade warning gate based on the executed command. |
| cmd/entire/cli/versioncheck/versioncheck.go | Exposes an exported helper to produce the update command for the current binary. |
| cmd/entire/cli/versioncheck/versioncheck_test.go | Adds coverage for the exported update-command wrapper. |
| cmd/entire/cli/strategy/manual_commit_rewind.go | Rejects restoring logs for checkpoints with unsupported checkpoint versions. |
| cmd/entire/cli/strategy/manual_commit_push.go | Syncs policy during pre-push and blocks checkpoint pushing when writes are unsupported. |
| cmd/entire/cli/strategy/manual_commit_hooks.go | Skips committed checkpoint finalization when policy disallows writes. |
| cmd/entire/cli/strategy/manual_commit_condensation.go | Skips condensation (committed checkpoint write) when policy disallows it. |
| cmd/entire/cli/strategy/checkpoint_policy.go | Implements strategy-level helpers for policy read/sync + warn/log behavior. |
| cmd/entire/cli/strategy/checkpoint_policy_test.go | Verifies pre-push behavior when policy requires a newer checkpoint writer. |
| cmd/entire/cli/root.go | Registers the new policy noun group. |
| cmd/entire/cli/resume.go | Enforces checkpoint-version readability when resuming sessions and when reading checkpoint info. |
| cmd/entire/cli/policy_group.go | Adds entire policy command group with git-repo prerequisite check. |
| cmd/entire/cli/policy_checkpoint.go | Implements entire policy checkpoint sync/update/push and output. |
| cmd/entire/cli/policy_checkpoint_test.go | Adds tests for defaults, rejects unsupported versions/downgrades, and pushes only the policy ref. |
| cmd/entire/cli/explain.go | Enforces checkpoint-version readability before decoding checkpoint content. |
| cmd/entire/cli/checkpointpolicy/policy.go | Defines policy schema, validation, and read-compat enforcement helpers. |
| cmd/entire/cli/checkpointpolicy/policy_test.go | Tests default policy and validation error cases. |
| cmd/entire/cli/checkpointpolicy/format.go | Adds parsing/comparison and read/write support matrices for checkpoint formats. |
| cmd/entire/cli/checkpointpolicy/format_test.go | Tests format parsing and support matrix behavior. |
| cmd/entire/cli/checkpointpolicy/store.go | Implements local policy ref read/write using a signed/versioned commit with policy.json. |
| cmd/entire/cli/checkpointpolicy/store_test.go | Tests local policy read/write behavior and malformed/unsupported policy handling. |
| cmd/entire/cli/checkpointpolicy/remote.go | Implements remote check/fetch/sync and push of the policy ref, including diverged-local detection. |
| cmd/entire/cli/checkpointpolicy/remote_test.go | Tests sync/push behaviors against a bare remote, including divergence and fast-forward failures. |
| cmd/entire/cli/checkpointpolicy/update.go | Implements update flow using remote as baseline and downgrade rejection unless --force. |
| cmd/entire/cli/checkpointpolicy/update_test.go | Tests downgrade rejection and --force override behavior. |
| cmd/entire/cli/checkpointpolicy/warning_test.go | Tests upgrade warning text and per-checkpoint read-compat enforcement. |
| cmd/entire/cli/checkpoint/open.go | Adjusts the temporary store accessor (but currently drops an ireturn suppression). |
| cmd/entire/cli/checkpoint_policy_warning.go | Adds logic to decide whether to show policy warnings and prints upgrade guidance when needed. |
| cmd/entire/cli/checkpoint_policy_warning_test.go | Adds tests for warning emission and command filtering logic. |
| cmd/entire/cli/checkpoint_policy_read_test.go | Adds a regression test ensuring unsupported checkpoint versions are rejected when reading checkpoint info. |
Allow checkpoint.TemporaryStore as a capability interface for ireturn. This matches the existing committed-store exception and keeps CI's non-fixing golangci-lint run aligned with the local fixer. Entire-Checkpoint: b8a4d6cdf265
…-config # Conflicts: # .golangci.yaml
Reject unsupported checkpoint reads and user-driven checkpoint writes consistently. Resolve policy refs through the configured checkpoint remote and skip checkpoint pushes when local policy state diverges from remote policy. Entire-Checkpoint: 9fc06b382e3e
Keep malformed checkpoint_version values as parse errors instead of classifying them as unsupported readable formats. Unsupported-version detection now only marks known formats this CLI cannot read. Entire-Checkpoint: f8e660ebe779
Share remote baseline loading between policy sync and update. Keep checkpoint policy state focused on data by removing test-only format knowledge, target labels, and preformatted warning text. Entire-Checkpoint: 0e1a4e82890c
Preserve local policy history when updating and reject true divergence before rewriting the policy ref. Accept SHA-256 object IDs from remote policy refs and keep policy upgrade warnings enabled for hidden user aliases while still excluding hidden infrastructure commands. Entire-Checkpoint: 2bfd7535ed16
Resolve checkpoint policy refs through the existing checkpoint remote fetch resolver. This keeps user commands and hooks on one repo-wide policy target instead of threading the current push remote into policy resolution. Entire-Checkpoint: 9367989f9e6d
Keep the repo policy command invokable while removing it from help output until the surface is ready. Add command-tree coverage so the hidden group remains callable through its checkpoint subcommand. Entire-Checkpoint: 99b815203b44
|
Bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 99336ff. Configure here.
Remove the unused ConfiguredURL helper and replace the hand-rolled compareInt with the standard library cmp.Compare. Entire-Checkpoint: 98bdb23e3c44
Keep resume usable when a squash commit lists an older unsupported checkpoint before a readable one, while preserving unsupported-version failures when no readable checkpoint remains. Silence policy command cancellation and use the safe update instruction for checkpoint policy upgrade warnings. Entire-Checkpoint: 8a621d57590d
|
This PR will be split up into three to separate out logical parts. Closing this for now. |

Why
Repositories need a repo-wide checkpoint policy so older CLIs can warn users before writing incompatible checkpoint data, and user-driven commands can fail clearly when they cannot decode a checkpoint format.
Usage Examples
The policy command is hidden while the surface is still in active development, but it is callable directly.
Inspect the current effective policy:
Example output:
Set the checkpoint version the repo should write:
Set the minimum checkpoint version required by the repo:
Set both values in one update:
Allow an explicit downgrade:
On updates, the command refreshes the latest policy from the configured checkpoint remote, validates the requested change against the current CLI capabilities, updates the local
refs/entire/policies/checkpointref, and pushes only that policy ref.What Changed
This adds a checkpoint policy stored in
refs/entire/policies/checkpoint, backed by a versionable commit containingpolicy.json. Policy commits follow the existing checkpoint commit-signing settings when signing is configured. If no signing is configured, policy commits are not signed.The PR adds hidden
entire policy checkpointcommands for inspection and updates, applies compatibility warnings to user-driven commands, and teaches hooks and pre-push to respect the policy without breaking ordinary git workflows.Technical Tradeoffs
.entire/settings.json: this makes the policy repo-wide, versionable, and compatible with commit signing, but it adds Git ref sync and divergence handling.branch-v1.Decisions And Assumptions
entire policy checkpointrather thanentire configureso users do not expect.entire/settings.jsonto change.refs/entire/policies/checkpoint, aligned with the singularpolicy checkpointcommand.branch-v1; that behavior comes from the predecessor checkpoint-version PR.--forceis provided.branch-v1readable and writable today. Known future families such asrefs-v1are parsed but treated as unsupported until this CLI learns to read or write them.Reviewer Notes
The policy flow intentionally follows the configured checkpoint remote. For repos with a separate checkpoint storage remote, this may differ from the ordinary Git
origin, and that should be called out during rollout.Policy commit signature verification is intentionally out of scope for this change.
Note
Medium Risk
Touches checkpoint write/read paths across hooks, pre-push, attach, resume, and explain—incorrect policy sync or enforcement could skip metadata pushes or block legitimate workflows, but behavior is largely fail-closed with tests and offline hook fallbacks.
Overview
Introduces repo-wide checkpoint policy stored at
refs/entire/policies/checkpoint(policy.jsonwithcheckpoint_version/checkpoint_min_version), plus a newcheckpointpolicypackage for format parsing (branch-v1vs future families likerefs-v1), validation, local Git storage, and remote sync/push against the configured checkpoint remote.Adds hidden
entire policy checkpointto inspect or update policy (with downgrade protection unless--force), pushing only the policy ref on updates. User-driven writes (attach, explain summary generation) fail when local policy requires a checkpoint format this CLI cannot write; reads (explain, export, resume, rewind) fail on unsupported per-checkpointcheckpoint_version. Hooks skip checkpoint writes and warn in interactive TTY when write policy is unsupported; pre-push syncs remote policy and can skip checkpoint pushes on unsupported write or diverged local/remote policy. Successful CLI runs (except hooks/analytics) can print an upgrade warning when policy needs a newer Entire.Also refactors checkpoint-remote HTTPS token handling into
checkpointTokenTransportand addsConfiguredURLfor policy remote resolution; documents checkpoint policy in architecture docs.Reviewed by Cursor Bugbot for commit 99336ff. Configure here.