core: write only new history and share files on Windows

The store rewrote all of history.json, 19 MB here, on every 60 s
refresh. It now appends each refresh's changes to a journal and compacts
into monthly files and a state checkpoint at 8 MiB, so an idle refresh
writes only snapshot.json. Bucket updates are keyed, unchanged limit
samples are kept at most hourly, Codex replays are bounded by session
totals, and Claude dedupe keys expire after 60 days.

Readers of atomically replaced files allow delete sharing, and the
replace retries briefly, so the Stream Deck plugin reading snapshot.json
cannot make a refresh fail. Claude's <synthetic> entries are skipped,
and repeated diagnostics fold into one entry with a count.

Refs #1
This commit is contained in:
Florian Schmidt
2026-10-14 19:59:58 +02:00
parent 14223b05df
commit c2f97e9384
15 changed files with 849 additions and 71 deletions
@@ -22,7 +22,9 @@ public class StorageTests
Assert.Equal(0, (await scanner.ScanAsync(TestContext.Current.CancellationToken)).AddedEvents);
await File.WriteAllTextAsync(source, Fixtures.Claude(), cancellationToken: TestContext.Current.CancellationToken);
Assert.Equal(0, (await scanner.ScanAsync(TestContext.Current.CancellationToken)).AddedEvents);
var previousWrite = File.GetLastWriteTimeUtc(source);
await File.WriteAllTextAsync(source, Fixtures.Claude("c"), cancellationToken: TestContext.Current.CancellationToken);
File.SetLastWriteTimeUtc(source, previousWrite.AddSeconds(1));
Assert.Equal(1, (await scanner.ScanAsync(TestContext.Current.CancellationToken)).AddedEvents);
directory.Write("claude/projects/other/copied.jsonl", Fixtures.Claude("b"));
Assert.Equal(0, (await scanner.ScanAsync(TestContext.Current.CancellationToken)).AddedEvents);