@spexcode/spec-core 0.7.0-next.1 → 0.7.0-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/git.d.ts +1 -0
- package/dist/git.js +25 -0
- package/package.json +1 -1
package/dist/git.d.ts
CHANGED
|
@@ -122,6 +122,7 @@ export declare function historyCacheStats(): {
|
|
|
122
122
|
historyRoots: number;
|
|
123
123
|
driftRoots: number;
|
|
124
124
|
};
|
|
125
|
+
export declare function pruneHistoryCaches(activeRoots: Iterable<string>): void;
|
|
125
126
|
export declare function resetHistoryCachesForTests(): void;
|
|
126
127
|
export declare function historyEventCachePathForTests(root: string): string;
|
|
127
128
|
export declare function ancestorsOf(idx: Reachability, sha: string): Uint8Array | undefined;
|
package/dist/git.js
CHANGED
|
@@ -2270,6 +2270,31 @@ export function sourceIndexes(root, tip = 'HEAD') {
|
|
|
2270
2270
|
export function historyCacheStats() {
|
|
2271
2271
|
return { historyHeads: indexCache.size, driftHeads: driftIdxCache.size, historyRoots: indexRoots.size, driftRoots: driftRoots.size };
|
|
2272
2272
|
}
|
|
2273
|
+
// A backend snapshot is the authority for which checkout roots are live. Release cache ownership for roots
|
|
2274
|
+
// that disappeared from that snapshot so closed session worktrees do not keep immutable history warm until
|
|
2275
|
+
// the generic slot bound happens to evict them. Shared entries survive while another live root still names
|
|
2276
|
+
// the same immutable key; an in-flight promise remains usable by its current caller even after its cache key
|
|
2277
|
+
// is released.
|
|
2278
|
+
export function pruneHistoryCaches(activeRoots) {
|
|
2279
|
+
const active = new Set([...activeRoots].map(rootKey));
|
|
2280
|
+
for (const [root] of indexRoots)
|
|
2281
|
+
if (!active.has(root))
|
|
2282
|
+
indexRoots.delete(root);
|
|
2283
|
+
for (const [root] of driftRoots)
|
|
2284
|
+
if (!active.has(root))
|
|
2285
|
+
driftRoots.delete(root);
|
|
2286
|
+
const referencedHistory = new Set(indexRoots.values());
|
|
2287
|
+
const referencedDrift = new Set(driftRoots.values());
|
|
2288
|
+
for (const key of indexCache.keys())
|
|
2289
|
+
if (!referencedHistory.has(key))
|
|
2290
|
+
indexCache.delete(key);
|
|
2291
|
+
for (const key of driftIdxCache.keys())
|
|
2292
|
+
if (!referencedDrift.has(key))
|
|
2293
|
+
driftIdxCache.delete(key);
|
|
2294
|
+
for (const root of eventPathMemo.keys())
|
|
2295
|
+
if (!active.has(root))
|
|
2296
|
+
eventPathMemo.delete(root);
|
|
2297
|
+
}
|
|
2273
2298
|
// Tests deliberately clear process-local promises and path identity to exercise both cold and read-back paths.
|
|
2274
2299
|
// Production callers retain the bounded index caches; this is not a correctness escape hatch.
|
|
2275
2300
|
export function resetHistoryCachesForTests() {
|