Build checkpoint subtree paths via path.Join helper (no tree change)

main

Commit

Soph2mo ago

A reviewer flagged fmt.Sprintf("%s%d/%s", basePath, idx, paths.MetadataFileName) as looking like a missing slash — it's correct only because basePath carries a trailing "/". Replace the string-concat path construction with a checkpointSubtreePath(base, segs...) helper over stdlib path.Join, so paths join correctly without relying on that invariant.

  • Helper uses the path package (NEVER path/filepath — git tree paths are always "/"; filepath.Join would emit "" on Windows and corrupt tree keys). path.Join cleans separators, so base may be "" (ref root), "<shard>/<id>/" (v1, trailing slash), or a clean dir — all join identically.
  • Converted every full-path site and routed the directory-prefix intermediates through the helper as CLEAN dirs (sessionDir, taskDir), updating their consumers (writeSessionToSubdirectory, writeTranscript, writeCompactTranscript, replaceTranscript, replaceSkillEvents, copyMetadataDir, writeTaskCheckpoint*).
  • The two prefix-scoping deletes that relied on the trailing slash now append it explicitly: HasPrefix(key, sessionDir+"/") (so "1" doesn't match sibling "10") and the transcript chunk cleanup. Leading-slash SessionFilePaths values become "/" + checkpointSubtreePath(...).

No behavior change: committed-tree assertions (checkpoint write/read, tripwire, update), integration (378), and both canary modes (git-branch 59/59, git-refs 58/59 +1 skip) are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com Entire-Checkpoint: 973f8248e820

Checkpoints

Build Checkpoints Store Based on Design

Claude CodeOpus 4.8
View session
Checkpoint 1