test(8.0): cover pending-tier range queries + setRetentionBudget adaptive reclaim

Closes the two coverage gaps a temporal-completeness audit surfaced (the code
was already correct, just untested):
- changedBetween / generationsTouching include un-flushed PENDING generations
  and stay identical across the flush — the building blocks of since/diff/history
  see single-op writes with no forced flush.
- setRetentionBudget() drives adaptive auto-compaction on flush() down to the
  byte budget: history is reclaimed, the live record is untouched (the cor #65
  retention-consume wiring, proven end-to-end).

65 generation/temporal tests green; 1528 unit green.
This commit is contained in:
David Snelling 2026-06-23 11:11:43 -07:00
parent 5c3bb2c864
commit 3783e61b30
2 changed files with 38 additions and 0 deletions

View file

@ -363,6 +363,24 @@ describe('db/GenerationStore', () => {
expect(store.hasCommittedAfter(g1)).toBe(true)
})
it('range queries (changedBetween / generationsTouching) include un-flushed pending generations', async () => {
// Two single-op writes to different ids, NEITHER flushed (still in the
// pending tier). diff()/since()/history() are built on these, so they must
// see un-flushed single-ops with NO forced flush.
const g1 = await singleOpWrite(ID_A, 1)
const g2 = await singleOpWrite(ID_B, 1)
expect(store.committedGeneration()).toBe(0) // nothing on disk yet
const changed = await store.changedBetween(0, store.generation())
expect(changed.nouns).toEqual([ID_A, ID_B]) // resolves over committed pending
expect(await store.generationsTouching('noun', ID_A, 0, store.generation())).toEqual([g1])
expect(await store.generationsTouching('noun', ID_B, 0, store.generation())).toEqual([g2])
// …and the range stays identical across the flush (now reading from disk).
await store.flushPendingSingleOps()
expect((await store.changedBetween(0, store.generation())).nouns).toEqual([ID_A, ID_B])
})
it('flush persists pending single-op generations (groupCommit-marked) and advances committed', async () => {
await singleOpWrite(ID_A, 1)
await singleOpWrite(ID_A, 2)