@@ -37,6 +37,16 @@ type WriteOptions struct {
3737 // Branch is the branch name where the checkpoint was created (empty if detached HEAD)
3838 Branch string
3939
40+ // CommitSHA links this checkpoint to an existing commit without a trailer.
41+ // It is an anchor — "imported at this point in time" — not attribution.
42+ // Currently set only by `entire import`: imported history has no
43+ // Entire-Checkpoint trailer (we never rewrite existing commits), so import
44+ // stamps the resolved anchor commit here (the default branch head when
45+ // resolvable; see resolveImportLinkCommitSHA for the fallback order).
46+ // Empty for all other writers. This comment is the canonical description;
47+ // Metadata.CommitSHA and CheckpointSummary.CommitSHA point back here.
48+ CommitSHA string
49+
4050 // Transcript is the session transcript content (full.jsonl).
4151 // Must be pre-redacted (via redact.JSONLBytes or redact.AlreadyRedacted for trusted sources).
4252 Transcript redact.RedactedBytes
@@ -293,6 +303,14 @@ type CheckpointInfo struct {
293303 // Imported is true when this checkpoint was imported from pre-existing
294304 // agent history (Kind == "imported"): read-only and commit-less.
295305 Imported bool
306+
307+ // ListedStub is true for names-only remote-discovery List entries that still
308+ // need hydration (or have not yet failed a hydration attempt). It is cleared
309+ // after a successful hydrate and also after a failed attempt (fail-once), so
310+ // callers do not re-fetch forever. A local ref whose root metadata was
311+ // unreadable has the same zero SessionID/SessionCount shape but ListedStub
312+ // false — do not treat field zero-ness alone as stub-ness.
313+ ListedStub bool `json:"-"`
296314}
297315
298316// SessionContent contains the actual content for a session.
@@ -316,13 +334,17 @@ type SessionContent struct {
316334
317335// Metadata contains the metadata stored in metadata.json for each checkpoint.
318336type Metadata struct {
319- CLIVersion string `json:"cli_version,omitempty"`
320- CheckpointID id.CheckpointID `json:"checkpoint_id"`
321- SessionID string `json:"session_id"`
322- Strategy string `json:"strategy"`
323- CreatedAt time.Time `json:"created_at"`
324- Branch string `json:"branch,omitempty"` // Branch where checkpoint was created (empty if detached HEAD)
325- CheckpointsCount int `json:"checkpoints_count"`
337+ CLIVersion string `json:"cli_version,omitempty"`
338+ CheckpointID id.CheckpointID `json:"checkpoint_id"`
339+ SessionID string `json:"session_id"`
340+ Strategy string `json:"strategy"`
341+ CreatedAt time.Time `json:"created_at"`
342+ Branch string `json:"branch,omitempty"` // Branch where checkpoint was created (empty if detached HEAD)
343+ // CommitSHA anchors an imported checkpoint to an existing commit; empty for
344+ // non-imported checkpoints, which link via the Entire-Checkpoint trailer.
345+ // See WriteOptions.CommitSHA for the full semantics.
346+ CommitSHA string `json:"commit_sha,omitempty"`
347+ CheckpointsCount int `json:"checkpoints_count"`
326348 // SaveStepCount is the number of SaveStep-recorded steps for this session.
327349 // Honest "real checkpoint work happened" signal (0 = commit-only/fallback
328350 // session), kept separate from the displayed CheckpointsCount prompt count.
@@ -474,10 +496,12 @@ type SessionFilePaths struct {
474496//
475497//nolint:revive // Named CheckpointSummary to avoid conflict with existing Summary struct
476498type CheckpointSummary struct {
477- CLIVersion string `json:"cli_version,omitempty"`
478- CheckpointID id.CheckpointID `json:"checkpoint_id"`
479- Strategy string `json:"strategy"`
480- Branch string `json:"branch,omitempty"`
499+ CLIVersion string `json:"cli_version,omitempty"`
500+ CheckpointID id.CheckpointID `json:"checkpoint_id"`
501+ Strategy string `json:"strategy"`
502+ Branch string `json:"branch,omitempty"`
503+ // CommitSHA: import-only anchor; see WriteOptions.CommitSHA.
504+ CommitSHA string `json:"commit_sha,omitempty"`
481505 CheckpointsCount int `json:"checkpoints_count"`
482506 FilesTouched []string `json:"files_touched"`
483507 Sessions []SessionFilePaths `json:"sessions"`
0 commit comments