From 754e947b1bf4bf1be01097297e3819fc09666600 Mon Sep 17 00:00:00 2001 From: Navid Nadali Date: Wed, 18 Nov 2026 22:24:01 +0000 Subject: [PATCH] fix(server): interrupted compaction no longer freezes the prune boundary Event-log compaction prunes through the mark the previous pass left once that mark is a day old, but it wrote the next mark only after the deletes finished. A due pass cut short by a restart left the old mark in place, so every later pass re-scanned the same range and the boundary never moved. The next mark is now written as a due pass starts, before any delete. Its claim, that every event at or below the head is committed, already holds then. Co-Authored-By: Claude Opus 5.5 --- .../src/orchestration-v2/ProjectionMaintenance.test.ts | 9 +++++++++ .../server/src/orchestration-v2/ProjectionMaintenance.ts | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/server/src/orchestration-v2/ProjectionMaintenance.test.ts b/apps/server/src/orchestration-v2/ProjectionMaintenance.test.ts index 1f42953cc4ec3..040b4aa6aee20 100644 --- a/apps/server/src/orchestration-v2/ProjectionMaintenance.test.ts +++ b/apps/server/src/orchestration-v2/ProjectionMaintenance.test.ts @@ -299,6 +299,15 @@ it.effect("prunes events the projections cover once the retained day has passed" ), ["Review prompt A. ".repeat(40)], ); + + // A due pass cut short by a restart still moves the boundary to its own head a day later. + yield* sink.write({ events: [itemEvent(threadId, now, itemSpecs[0], 4)] }); + const cutPassHead = yield* eventStore.latestSequence(); + yield* TestClock.adjust("1 day"); + yield* Effect.exit(maintenance.pruneEventStore(Effect.interrupt)); + yield* TestClock.adjust("1 day"); + yield* maintenance.pruneEventStore(); + assert.equal(yield* events.prunedThroughSequence, cutPassHead); }).pipe(Effect.provide(layerTest)), ); diff --git a/apps/server/src/orchestration-v2/ProjectionMaintenance.ts b/apps/server/src/orchestration-v2/ProjectionMaintenance.ts index 210322aed686f..cab0833b2b5e4 100644 --- a/apps/server/src/orchestration-v2/ProjectionMaintenance.ts +++ b/apps/server/src/orchestration-v2/ProjectionMaintenance.ts @@ -287,9 +287,12 @@ export const layer: Layer.Layer