Skip to content

checkpoint: extract persistent contract to api/checkpoint#1504

Open
Soph wants to merge 4 commits into
feat/checkpoint-persistent-renamefrom
feat/api-checkpoint-contract-v2
Open

checkpoint: extract persistent contract to api/checkpoint#1504
Soph wants to merge 4 commits into
feat/checkpoint-persistent-renamefrom
feat/api-checkpoint-contract-v2

Conversation

@Soph

@Soph Soph commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

https://entire.io/gh/entireio/cli/trails/647

Stacked on #1495 (the persistent/ephemeral split + scope-based read/write API). Review/merge that first; this diff is against that branch. Carries the same latest-main merge as #1495.

What

The final step of the #1433 reorder: extract the persistent-checkpoint contract into a new github.com/entireio/cli/api/checkpoint package — born with the persistent vocabulary and scope-based names (the whole reason we did the rename before relocating).

Moved to api/checkpoint:

  • Persisted document types: Metadata, CheckpointSummary, Summary/LearningsSummary/CodeLearning, Attribution, SessionFilePaths, SessionMetrics, CheckpointInfo, SessionContent.
  • Option types: WriteOptions, UpdateOptions, PrecomputedTranscriptBlobs.
  • Contract surface:
    • read tiers CheckpointReader (Read, List) + SessionReader (the four session reads), composed into PersistentStore;
    • Writer + the sealed WriteRequest union (Session / SessionTranscript / SessionSummary / CheckpointAttribution);
    • the reader helpers (ReadCheckpoint, ReadLatestSessionContent, ReadRawSessionLogForCheckpoint), the sentinel errors, and CheckpointVersionBranchV1.

The contract depends only on leaf packages (agent/types, checkpoint/id, redact, go-git plumbing) — a backend can implement it without the CLI's agent/TUI/git machinery.

Stays in cmd/entire/cli/checkpoint: GitStore + methods, Open, the Stores facade, PersistentRefs, AuthorReader, normalizeCheckpointSummary, and the entire git-only ephemeral surface.

Zero call-site churn

cmd/entire/cli/checkpoint imports the contract and re-exports every moved symbol via aliases (aliases.go):

type CheckpointSummary = apicheckpoint.CheckpointSummary
var  ErrCheckpointNotFound = apicheckpoint.ErrCheckpointNotFound
func ReadCheckpoint(...) (...) { return apicheckpoint.ReadCheckpoint(...) }

All existing importers compile unchanged; the backend imports api/checkpoint directly. (Helpers are thin wrapper funcs, not mutable vars — addressing the earlier review note.)

Cleanup (post-review /simplify pass)

  • Extracted a shared getSessionTree helper: the four SessionReader methods each repeated the same context-check → fetching-tree → checkpoint-tree → session-subtree navigation (with identical ErrCheckpointNotFound wrapping) before reading their files. Behavior unchanged.

Notes

  • PrecomputedTranscriptBlobs.isUsable → exported IsUsable (its one caller is now across the package boundary).
  • The Write union is sealed to api/checkpoint, so the impl-package unknown-request test was dropped (no longer expressible); per-request dispatch coverage remains.
  • Doc-comment terminology aligned to "persistent" (was "committed") on the moved option types.

Verification

go build ./..., full go test ./..., and mise run lint (0 issues) green; validated with codex exec review (which confirmed errors.Is still works across the alias boundary) and a 4-agent /simplify review (reuse / simplification / efficiency / altitude).

Copilot AI review requested due to automatic review settings June 23, 2026 07:55
@Soph Soph requested a review from a team as a code owner June 23, 2026 07:55

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

Extracts the persistent-checkpoint storage contract into a new github.com/entireio/cli/api/checkpoint package so non-CLI backends can implement persistence without depending on the CLI’s git/TUI/runtime packages, while preserving existing CLI imports via re-exports.

Changes:

  • Introduces api/checkpoint containing persistent metadata types, read/write interfaces, the sealed WriteRequest union, helper readers, and sentinel errors.
  • Re-exports the new contract from cmd/entire/cli/checkpoint via aliases.go to avoid call-site churn.
  • Updates the git-backed persistent implementation and tests to use the exported PrecomputedTranscriptBlobs.IsUsable and the updated “persistent” error message.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cmd/entire/cli/checkpoint/persistent.go Updates transcript replacement flow to use exported IsUsable on precomputed transcript blobs.
cmd/entire/cli/checkpoint/persistent_write.go Removes local contract types/docs and relies on the re-exported api/checkpoint request union for write dispatch.
cmd/entire/cli/checkpoint/persistent_write_test.go Drops now-unreachable in-package “unknown request” test and keeps per-request dispatch coverage.
cmd/entire/cli/checkpoint/persistent_reader.go Keeps implementation-only helpers/capabilities (AuthorReader, summary normalization) after contract extraction.
cmd/entire/cli/checkpoint/persistent_reader_test.go Updates expected error text to “read persistent checkpoint”.
cmd/entire/cli/checkpoint/checkpoint.go Removes persistent-contract definitions from the implementation package, leaving the generic/ephemeral surface.
cmd/entire/cli/checkpoint/aliases.go Re-exports api/checkpoint symbols (types, interfaces, helpers, sentinel errors) to preserve existing imports.
api/checkpoint/doc.go Adds package docs explaining the extracted persistent contract and why it exists.
api/checkpoint/errors.go Defines sentinel errors and the persistent metadata format constant in the contract package.
api/checkpoint/interfaces.go Defines persistent reader/store interfaces, sealed write union, and helper read functions.
api/checkpoint/metadata.go Hosts persistent metadata/options/types moved out of the CLI implementation package, including IsUsable.

Comment thread api/checkpoint/metadata.go Outdated
Comment thread api/checkpoint/metadata.go Outdated
Comment thread cmd/entire/cli/checkpoint/persistent_reader_test.go
Soph added a commit that referenced this pull request Jun 23, 2026
Address Copilot review on #1504: the verbatim-moved WriteOptions/UpdateOptions
doc comments still said 'committed checkpoint' (the store concept) — reword to
'persistent checkpoint' to match the rest of the api/checkpoint contract. Rename
the ReadCheckpoint tests (TestReadCommittedCheckpoint* -> TestReadCheckpoint*)
to match the renamed function.

References to the git 'committed tree' and the TotalCommitted/total_committed
attribution field are left as-is — those correctly describe git commits, not the
store.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 6206fb18d245
Soph added a commit that referenced this pull request Jun 23, 2026
Address Copilot review on #1504: the verbatim-moved WriteOptions/UpdateOptions
doc comments still said 'committed checkpoint' (the store concept) — reword to
'persistent checkpoint' to match the rest of the api/checkpoint contract. Rename
the ReadCheckpoint tests (TestReadCommittedCheckpoint* -> TestReadCheckpoint*)
to match the renamed function.

References to the git 'committed tree' and the TotalCommitted/total_committed
attribution field are left as-is — those correctly describe git commits, not the
store.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 6206fb18d245
@Soph Soph force-pushed the feat/api-checkpoint-contract-v2 branch from 3f7067c to 221c89f Compare June 23, 2026 12:59
@Soph Soph force-pushed the feat/checkpoint-persistent-rename branch from 3210376 to 5a4925d Compare June 23, 2026 13:52
Soph and others added 3 commits June 23, 2026 15:52
Move the persistent-checkpoint contract — the persisted document types
(Metadata, CheckpointSummary, Summary, Attribution, ...), the option types
(WriteOptions/UpdateOptions/PrecomputedTranscriptBlobs), the reader/writer
interfaces, the Write request union, the sentinel errors, and the
CheckpointVersionBranchV1 const — into a new github.com/entireio/cli/api/checkpoint
package, born with the persistent vocabulary.

The contract depends only on leaf packages (agent/types, checkpoint/id, redact,
go-git plumbing), so a storage backend can implement it without the CLI's
agent/TUI/git machinery. The git implementation (GitStore, Open, the Stores
facade, AuthorReader, and the ephemeral shadow-branch surface) stays in
cmd/entire/cli/checkpoint, which imports the contract and re-exports every
moved symbol via aliases (aliases.go) — all existing call sites compile
unchanged.

Notes:
- PrecomputedTranscriptBlobs.isUsable is now exported (IsUsable); its one
  caller is across the new package boundary.
- The Write union is sealed to api/checkpoint, so the impl-package
  unknown-request test was removed (no longer expressible); per-request
  dispatch coverage remains.
- normalizeCheckpointSummary stays in the impl (read-time normalization).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: a808b47c0633
Address Copilot review on #1504: the verbatim-moved WriteOptions/UpdateOptions
doc comments still said 'committed checkpoint' (the store concept) — reword to
'persistent checkpoint' to match the rest of the api/checkpoint contract. Rename
the ReadCheckpoint tests (TestReadCommittedCheckpoint* -> TestReadCheckpoint*)
to match the renamed function.

References to the git 'committed tree' and the TotalCommitted/total_committed
attribution field are left as-is — those correctly describe git commits, not the
store.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 6206fb18d245
The four SessionReader methods (ReadSessionMetadata, ReadSessionPrompts,
ReadSessionMetadataAndPrompts, ReadSessionContent) each repeated the same
prologue: context check, getFetchingTree, navigate to the checkpoint tree,
then the session subtree, with identical ErrCheckpointNotFound wrapping.

Extract that navigation into getSessionTree so each reader is just "resolve
session tree, read the files it needs." Behavior is unchanged — the helper
returns the same ErrCheckpointNotFound (wrapping "session N not found" when
the session subtree is missing).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Entire-Checkpoint: 9cd97a095dda
@Soph Soph force-pushed the feat/api-checkpoint-contract-v2 branch from 2904262 to 089e4b6 Compare June 23, 2026 13:57
Comment thread api/checkpoint/doc.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants