singularity-forge/src/resources/extensions/gsd/cache.ts
ace-pm 172753c3b2 refactor(forge): complete gsd → forge rebrand across native, logging, and build system
- Rename native Rust crates: gsd-engine → forge-engine, gsd-ast → forge-ast, gsd-grep → forge-grep
- Update all crate dependencies (Cargo.toml, .rs source) and N-API artifacts
- Mass rename log prefix [gsd] → [forge] across 81 files (scripts, src/, extensions, tests)
- Rename log prefix "gsd-db:" → "forge-db:" in template literals
- Update nix flake: add sf-run-native devShell with Rust toolchain for native addon builds
- Update CI workflow artifact names (build-native.yml)
- Verify only packages/native/* touched (no upstream pi-* packages renamed)

Rationale: Complete gsd-2 → singularity-forge rebrand (2026-04-15). Native addon is
sf-run-specific; all gsd-prefixed logging and crate names must align with new identity.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 14:11:45 +02:00

29 lines
1.1 KiB
TypeScript

// GSD Extension — Cache Invalidation
//
// Three module-scoped caches exist across the GSD extension:
// 1. State cache (state.ts) — memoized deriveState() result
// 2. Path cache (paths.ts) — directory listing results (readdirSync)
// 3. Parse cache (files.ts) — parsed markdown file results
//
// After any file write that changes .gsd/ contents, all three must be
// invalidated together to prevent stale reads. This module provides a
// single function that clears all three atomically.
import { invalidateStateCache } from './state.js';
import { clearPathCache } from './paths.js';
import { clearParseCache } from './files.js';
import { clearArtifacts } from './gsd-db.js';
/**
* Invalidate all GSD runtime caches in one call.
*
* Call this after file writes, milestone transitions, merge reconciliation,
* or any operation that changes .gsd/ contents on disk. Forgetting to clear
* any single cache causes stale reads (see #431, #793).
*/
export function invalidateAllCaches(): void {
invalidateStateCache();
clearPathCache();
clearParseCache();
clearArtifacts();
}