MCPcopy Create free account
hub / github.com/JordanCoin/codemap / ReadLatest

Function ReadLatest

handoff/storage.go:56–73  ·  view source on GitHub ↗

ReadLatest reads the latest handoff artifact if it exists. Returns (nil, nil) when no artifact is present.

(root string)

Source from the content-addressed store, hash-verified

54// ReadLatest reads the latest handoff artifact if it exists.
55// Returns (nil, nil) when no artifact is present.
56func ReadLatest(root string) (*Artifact, error) {
57 path := LatestPath(root)
58 data, err := os.ReadFile(path)
59 if err != nil {
60 if os.IsNotExist(err) {
61 return nil, nil
62 }
63 return nil, err
64 }
65
66 var artifact Artifact
67 if err := json.Unmarshal(data, &artifact); err != nil {
68 return nil, err
69 }
70 normalizeArtifact(&artifact)
71
72 return &artifact, nil
73}
74
75// WriteLatest writes an artifact atomically to .codemap/handoff.latest.json.
76func WriteLatest(root string, artifact *Artifact) error {

Callers 8

runHandoffSubcommandFunction · 0.92
getRecentHandoffFunction · 0.92
writeSessionHandoffFunction · 0.92
buildContextEnvelopeFunction · 0.92
handleGetHandoffFunction · 0.92
BuildFunction · 0.85
TestBuildWriteReadFunction · 0.85
TestReadLatestMissingFunction · 0.85

Calls 2

LatestPathFunction · 0.85
normalizeArtifactFunction · 0.85

Tested by 2

TestBuildWriteReadFunction · 0.68
TestReadLatestMissingFunction · 0.68