diff --git a/packages/engine/src/__tests__/self-healing-db-corruption.test.ts b/packages/engine/src/__tests__/self-healing-db-corruption.test.ts index 8d42d6d549..439f79b9ac 100644 --- a/packages/engine/src/__tests__/self-healing-db-corruption.test.ts +++ b/packages/engine/src/__tests__/self-healing-db-corruption.test.ts @@ -123,6 +123,31 @@ function stubMaintenance(manager: SelfHealingManager) { for (const method of BATCH2_METHODS) { vi.spyOn(manager as never, method).mockResolvedValue(0 as never); } + /* + FNXC:TestInfrastructure 2026-08-01-23:05 (the suite exited 1 with ZERO failing tests): + STUBBING THE SWEEPS IS NOT ENOUGH — the shared surfacing cycle is built in the ARGUMENT. + `runMaintenance` invokes the surfacing family as `() => this.surfaceInReviewStalled(maintenanceSurfacing())`, + and `maintenanceSurfacing()` lazily calls `openSurfacingCycle()`, which does + `await this.store.listTasks({ slim: false })`. Spying on `surfaceInReviewStalled` replaces the + METHOD but the call site still evaluates its argument, so the cycle opened anyway against a mock + store that deliberately implements only what corruption surfacing needs. + + The result was nine `TypeError: this.store.listTasks is not a function` UNHANDLED REJECTIONS raised + after the tests had already passed: `engine-default` exited 1 while reporting 736 files passed and + 0 failed. Worse than a plain failure — the lane is red, nothing names a test, and a real regression + arriving later reads as more of the same noise. + + Two fixes that look right and are not, both tried and reverted: + adding `listTasks` to the mock -> 3 tests fail; the sweeps then run far enough to record audit + events the assertions do not expect. + stubbing the 27 maintenance -> 5 tests fail AND all nine errors remain, because + methods missing from the lists `openSurfacingCycle` is not among `runMaintenance`'s own calls. + + Stubbing the cycle is the honest seam: `null` is exactly what it returns when the engine is paused, + so every consumer already handles it, and the corruption path this suite exists to test is + untouched. + */ + vi.spyOn(manager as never, "openSurfacingCycle").mockResolvedValue(null as never); vi.spyOn(manager, "archiveStaleDoneTasks").mockResolvedValue(0); }