Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/adapters/google-antigravity-replay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,15 @@ function refreshReplaySessionCandidate(key: string, entry: ReplayEntry): void {
}

function deleteExpiredReplaySessions(now: number): void {
for (const [key, entry] of replayCache) if (entry.expiresAtMs <= now) deleteReplaySession(key);
let deleted = false;
for (const [key, entry] of replayCache) {
if (entry.expiresAtMs > now) continue;
deleteReplaySession(key);
deleted = true;
}
// Expiry is a durable mutation too: rewrite the snapshot so opaque thought
// signatures do not remain at rest after their in-memory TTL has elapsed.
if (deleted) markReplayDirty();
}

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/google-antigravity-replay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,20 @@ describe("durable antigravity replay snapshot", () => {
await flushAntigravityReplay();
});

test("sweeping expired sessions removes them from the durable snapshot", async () => {
observeAntigravityReplay(MODEL, SESSION, [fcPart("get_x", { a: 1 }, SIG)]);
await flushAntigravityReplay();
expect(readFileSync(snapshotPath(), "utf8")).toContain(SIG);

expect(sweepExpiredAntigravityReplay(Number.MAX_SAFE_INTEGER)).toBe(1);
await flushAntigravityReplay();

const rawText = readFileSync(snapshotPath(), "utf8");
const snapshot = JSON.parse(rawText) as { sessions?: unknown[] };
expect(snapshot.sessions).toHaveLength(0);
expect(rawText).not.toContain(SIG);
});

test("snapshot cap keeps the most recently active sessions", async () => {
// A (two calls, ~899 serialized bytes) fits under the cap; A+B (~1,347)
// does not, so the cap must pick exactly one session by activity.
Expand Down
Loading