MCPcopy Index your code
hub / github.com/garrytan/gstack / readSnapshot

Function readSnapshot

lib/gstack-decision.ts:233–241  ·  view source on GitHub ↗
(paths: DecisionPaths)

Source from the content-addressed store, hash-verified

231
232/** Read the bounded active snapshot. Returns [] if missing/corrupt (caller may rebuild). */
233export function readSnapshot(paths: DecisionPaths): ActiveDecision[] {
234 if (!existsSync(paths.snapshot)) return [];
235 try {
236 const v = JSON.parse(readFileSync(paths.snapshot, "utf-8"));
237 return Array.isArray(v) ? (v as ActiveDecision[]) : [];
238 } catch {
239 return [];
240 }
241}
242
243/** Recompute active from the event log and refresh the snapshot. Returns active. */
244export function rebuildSnapshot(paths: DecisionPaths): ActiveDecision[] {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected