Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([universebuilder-collection-hook-flaky-batch-enrich]): drain-gate batch-enrich test instead of high-index-only check

[._.]/ Adam Eivy3702491211b1
diff --git a/server/services/universeBuilderCollectionHook.test.js b/server/services/universeBuilderCollectionHook.test.js
index d9f55f7044..24cbbeecb3 100644
--- a/server/services/universeBuilderCollectionHook.test.js
+++ b/server/services/universeBuilderCollectionHook.test.js
@@ -315,7 +315,13 @@ describe('universeBuilderCollectionHook', () => {
},
});
}
- await waitFor(() => existsSync(sidecarPath('batch-4.png')) && readSidecar('batch-4.png').entryName === 'Batchy');
+ // Gate on the run draining (every IIFE reached its `finally` and
+ // decremented pending → 0), not on batch-4 alone — the 5 IIFEs run in
+ // parallel via `Promise.all` and can complete out of order under CPU or
+ // disk-I/O pressure, so the highest-index file landing first leaves the
+ // assertion racing a still-pending mid-index write. Mirrors the
+ // drain-gate used by the earlier tests in this file.
+ await waitFor(() => hook.__testing.getActiveRuns().size === 0);
for (let i = 0; i < 5; i += 1) {
const sc = readSidecar(`batch-${i}.png`);
expect(sc.entryName).toBe('Batchy');