fix(import): address PR review feedback · Entire

fix(import): address PR review feedback

c4bfa4f→main·

computermode·3w ago·5 files·+36 added/-18 removed

- explain: cap live (commit-linked + temporary) checkpoints to the limit before appending imported ones, so a large import can't evict recent checkpoints from 'checkpoint list' - agentimport: redact each session transcript once per file instead of once per turn (O(files) not O(turns)) - correct stale 'local-only'/'entire/imports/v1' wording in Kind/flag/field comments — imported checkpoints live on v1 and push like normal checkpoints

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

Sessions

f553c0e9a83cView transcript

[?
Generalize Agent Import Across PlatformsClaude Code·Opus 4.8·2 steps](/content/gh/entireio/cli/session/b1e13e56-e9ae-469a-a30d-7c57d70e2f1f#timeline-f553c0e9a83c/index.html)

Changes

5

282 unmodified lines

283
284
285
286
286
287
288
289
175 unmodified lines

465
466
467
468
469
468
469
470
471
472

282 unmodified lines

SessionIDs   []string // All session IDs that contributed

// Imported is true when this checkpoint was imported from pre-existing
    // agent history (Kind == "imported"): read-only, commit-less, local-only.
    // agent history (Kind == "imported"): read-only and commit-less.
    Imported bool
}

175 unmodified lines

HasInvestigation bool `json:"has_investigation,omitempty"`

// Imported is true when this checkpoint was imported from pre-existing
    // agent history (a session with Kind == "imported"): read-only,
    // commit-less, and local-only this pass.
    // agent history (a session with Kind == "imported"): read-only and
    // commit-less.
    Imported bool `json:"imported,omitempty"`
}

Mapi/checkpoint/metadata.go+3/-3

145 unmodified lines

146
147
148
149
150
151
152
153
154
155
156
157
4 unmodified lines

162
163
164
159
165
166
167
168
169
170
171
172
173
174
175
3 unmodified lines

179
180
181
169
170
171
172
173
182
183
184
185

145 unmodified lines

if splitErr != nil {
        return res, fmt.Errorf("split %s session %s: %w", imp.Name(), sf.SessionID, splitErr)
    }
    // Redact the session transcript once and reuse it for every turn's
    // checkpoint (each turn stores the full session transcript with its own
    // CheckpointTranscriptStart). Redacting per turn would be O(turns).
    // Computed lazily so a fully-skipped or dry-run file pays nothing.
    var red redact.RedactedBytes
    redacted := false
    for _, turn := range turns {
        cid := DeriveCheckpointID(sf.SessionID, turn.UUID)
        if existing[cid.String()] {

res.TurnsImported++ // counts what would import
            continue
        }
        if err := writeTurn(ctx, stores, imp, cid, sf, full, turn); err != nil {
            if !redacted {
                r, rerr := redact.JSONLBytes(full)
                if rerr != nil {
                    return res, fmt.Errorf("redact %s transcript: %w", sf.SessionID, rerr)
                }
                red, redacted = r, true
            }
            if err := writeTurn(ctx, stores, imp, cid, sf, red, turn); err != nil {
                return res, err
            }
            existing[cid.String()] = true
3 unmodified lines

return res, nil
}

func writeTurn(ctx context.Context, stores *cp.Stores, imp Importer, cid id.CheckpointID, sf SessionFile, full []byte, turn Turn) error {
    red, err := redact.JSONLBytes(full)
    if err != nil {
        return fmt.Errorf("redact transcript: %w", err)
    }
func writeTurn(ctx context.Context, stores *cp.Stores, imp Importer, cid id.CheckpointID, sf SessionFile, red redact.RedactedBytes, turn Turn) error {
    prov := &cp.Provenance{
        Source: imp.Name(), TranscriptPath: sf.Path, SessionID: sf.SessionID,
        TurnUUID: turn.UUID, ParentUUID: turn.ParentUUID,

Mcmd/entire/cli/agentimport/agentimport.go+15/-6

2153 unmodified lines

2154
2155
2156
2157
2158
2159
2160
2157
2158
2159
2160
2161
2164
2165
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180

2153 unmodified lines

tempPoints := getReachableTemporaryCheckpoints(ctx, repo, stores.Ephemeral(), head.Hash(), isOnDefault, limit)
    points = append(points, tempPoints...)

// Add imported (read-only, commit-less) checkpoints from entire/imports/v1.
    points = append(points, getImportedRewindPoints(ctx, repo)...)

// Sort by date, most recent first
    // Sort live points (commit-linked + temporary) and apply the limit FIRST, so
    // a large historical import can't evict recent commit-linked checkpoints.
    sort.Slice(points, func(i, j int) bool {
        return points[i].Date.After(points[j].Date)
    })

// Apply limit
    if len(points) > limit {
        points = points[:limit]
    }

// Append imported (read-only, commit-less) checkpoints after the live points,
    // bounded by the same limit so a one-month import doesn't produce an
    // unbounded list. They get their own budget and never displace live points.
    imported := getImportedRewindPoints(ctx, repo)
    sort.Slice(imported, func(i, j int) bool {
        return imported[i].Date.After(imported[j].Date)
    })
    if len(imported) > limit {
        imported = imported[:limit]
    }
    points = append(points, imported...)

return points, nil
}

Mcmd/entire/cli/explain.go+14/-6

59 unmodified lines

60
61
62
63
64
63
64
65
66
67
68

59 unmodified lines

KindAgentInvestigate Kind = "agent_investigate"

// KindImported tags a checkpoint created by `entire import` from a
    // pre-existing agent transcript. Imported checkpoints are read-only,
    // commit-less, and (this pass) local-only.
    // pre-existing agent transcript. Imported checkpoints are read-only and
    // commit-less; they live on the v1 metadata branch and push like any other
    // checkpoint.
    KindImported Kind = "imported"
)

Mcmd/entire/cli/session/state.go+3/-2

97 unmodified lines

98
99
100
101
101
102
103
104

97 unmodified lines

SessionPrompts []string

// Imported indicates this point is a read-only imported (commit-less)
    // checkpoint from entire/imports/v1. Imported points are not rewindable.
    // checkpoint on the v1 metadata branch. Imported points are not rewindable.
    Imported bool
}

Mcmd/entire/cli/strategy/strategy.go+1/-1