Address ULID review: display, fetch-hint, docs, id-const, lazy mint · Entire
Address ULID review: display, fetch-hint, docs, id-const, lazy mint
c6fd45b→main· Soph·1w ago·8 files·+136 added/-34 removed
Follow-ups from review of the git-refs ULID-emission PR (the id-kind read-routing item, #1, and the write-boundary kind guard, #2, are deferred — see below):
- id.CheckpointID.DisplayShort() (new): kind-aware trim — legacy hex shows its 12-char prefix, a ULID is shown in full (front-truncating a ULID drops its entropy tail and yields an ambiguous, unresolvable prefix).
- explain checkpoint-list view uses DisplayShort instead of a blind 12-char cut, so ULID checkpoints no longer collapse to near-identical timestamp prefixes.
- blame --long sizes the Checkpoint/Session column to its content (attributionCheckpointColumnWidth) so a 26-char ULID + session renders whole instead of being clipped to a session-less 21-char prefix.
- attach's fetch hint now resolves its target via resolveCheckpointFetchTarget — the same path FetchCheckpointRef uses — so the pasteable command matches the remote the fetch actually ran (fixes a bare "git fetch origin …" that fails in a token-only environment with an SSH origin).
- id.MaxIDLength ties to oklog/ulid's EncodedSize instead of a third hardcoded 26.
- eager-condense mints the checkpoint ID only after the skip checks, so a no-op session stop no longer pays the mint (and its checkpoints-config load).
- docs/architecture/sessions-and-checkpoints.md: checkpoint IDs are 12-hex OR ULID (not fixed-width), minted via checkpoint.GenerateCheckpointID.
Deferred to the id-kind read-routing follow-up (tracked separately):
- #1 attach routes presence/refresh/fetch-hint by current config, not by the trailer ID's kind — after a git-branch⇄git-refs flip attach looks in the wrong place and can suggest an unfixable fetch. This is the read-routing work the PR body already names; the two concrete attach dead-ends belong in that issue.
- #2 the ULID⇒refs invariant has no write-boundary guard. A naive "git-branch store saw a ULID → warn" misfires when git-branch is a mirror of a git-refs primary (a valid topology where ULIDs legitimately reach it), so the correct guard needs topology-role awareness and belongs with the routing work.
Tests: TestCheckpointID_DisplayShort, TestAttributionCheckpointColumnWidth.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Sessions
14006b64f8d1View transcript
?\ Build Checkpoints Store Based on DesignClaude Code·Opus 4.8[1m]·1 step
Changes
8
cmd/entire/cli
Mattach.go+6/-9
Mattribution.go+24/-7
Mattribution_test.go+28
checkpoint/id
Mid.go+22/-2
Mid_test.go+27
Mexplain.go+3/-6
strategy
Mmanual_commit_condensation.go+12/-8
docs/architecture
Msessions-and-checkpoints.md+14/-2
return suggestFetchCommand(ctx, refName.String()+":"+refName.String())
// suggestFetchCommand builds a "git fetch
func suggestFetchCommand(ctx context.Context, refspec string) string { if remote.Configured(ctx) { if url, err := remote.FetchURL(ctx); err == nil && url != "" { return fmt.Sprintf("git fetch %s %s", url, refspec) } } return "git fetch origin " + refspec return fmt.Sprintf("git fetch %s %s", resolveCheckpointFetchTarget(ctx), refspec) }
func resolveCheckpointID(ctx context.Context, headCommit *object.Commit) (id.CheckpointID, bool) {
```go
func renderAttributionBlameLong(w io.Writer, result *fileAttributionResult, lineFlag string) {
renderAttributionBlameTable(w, result, lineFlag, func(sty statusStyles) {
lineWidth := attributionLineColumnWidth(result.Lines)
const checkpointColumnWidth = 21
fmt.Fprintf(w, " %*s Tag %-12s %-18s %-16s %-21s Content\n",
lineWidth, "Line", "Agent", "Model", "Author", "Checkpoint/Session")
fmt.Fprintf(w, " %s\n", sty.render(sty.dim, strings.Repeat("─", lineWidth+92)))
// Size the Checkpoint/Session column to its content so a ULID checkpoint
// (26 chars, vs a 12-hex ID) is not front-truncated into an unresolvable,
// session-less prefix. The other columns sum to 71 alongside these two.
cpWidth := attributionCheckpointColumnWidth(result.Lines)
ruleWidth := lineWidth + cpWidth + 71
fmt.Fprintf(w, " %*s Tag %-12s %-18s %-16s %-*s Content\n",
lineWidth, "Line", "Agent", "Model", "Author", cpWidth, "Checkpoint/Session")
fmt.Fprintf(w, " %s\n", sty.render(sty.dim, strings.Repeat("─", ruleWidth)));
for _, line := range result.Lines {
fmt.Fprintf(w, " %s %s %-12s %-18s %-16s %-21s %s %s\n",
fmt.Fprintf(w, " %s %s %-12s %-18s %-16s %-*s %s %s\n",
sty.render(sty.dim, fmt.Sprintf("%*d", lineWidth, line.LineNumber)),
renderAttributionTag(sty, line.Authorship),
stringutil.TruncateRunes(line.Agent, 12, ""),
stringutil.TruncateRunes(line.Model, 18, ""),
stringutil.TruncateRunes(shortAuthorName(line.Author), 16, ""),
stringutil.TruncateRunes(shortCheckpointSession(line), checkpointColumnWidth, ""),
cpWidth, shortCheckpointSession(line),
sty.render(sty.dim, attributionLineMarker(line)),
renderAttributionContent(sty, line),
)
}
fmt.Fprintf(w, " %s\n", sty.render(sty.dim, strings.Repeat("─", lineWidth+92)))
fmt.Fprintf(w, " %s\n", sty.render(sty.dim, strings.Repeat("─", ruleWidth)))
})
}
// attributionCheckpointColumnWidth sizes the Checkpoint/Session column to the
// widest value it must show (header label or any rendered checkpoint/session),
// so ULID checkpoints render in full rather than being clipped to a 12-hex width.
func attributionCheckpointColumnWidth(lines []attributionLine) int {
w := len("Checkpoint/Session")
for i := range lines {
if n := len(shortCheckpointSession(lines[i])); n > w {
w = n
}
}
return w
}
func renderAttributionSummary(w io.Writer, sty statusStyles, summary attributionSummary, lineFlag string) {
parts := []string{
sty.render(sty.green, fmt.Sprintf("AI: %d (%d%%)", summary.AILines, summary.AIPercentage)),
}