diff --git a/tests/integration/idle-costs-nothing.test.ts b/tests/integration/idle-costs-nothing.test.ts index b5c386cf..2374627e 100644 --- a/tests/integration/idle-costs-nothing.test.ts +++ b/tests/integration/idle-costs-nothing.test.ts @@ -88,11 +88,36 @@ describe('an idle brain costs nothing', () => { } // (a) + (b): nothing ran, nothing was said. - expect(logged.filter((l) => /All indexes flushed to disk/.test(l))).toEqual([]) - expect(logged.filter((l) => /Flushing Brainy indexes/.test(l))).toEqual([]) + // + // THE SPIES COME FIRST, AND THEY ARE THE ATTRIBUTABLE HALF. They are bound + // to THIS brain's providers, so they answer "did this brain flush?" and + // nothing else. The console filters below cannot: the gate config runs the + // whole suite in ONE process (`pool: 'forks'`, `singleFork: true`), so + // `console.log` carries the narration of every brain alive in that + // process — including one a previous file opened and never closed, whose + // unref'd cadence timer is still doing honest work. A neighbour narrating + // is a REAL finding about suite hygiene, but it is not this brain failing + // its own law, and the two must not be reported as the same thing. + // + // So: spies first (whose failure means the engine broke the law), console + // second (whose failure means SOMETHING in the process narrated), and the + // console assertion carries the captured lines in its message. vitest's + // stdout blocks are prefixed `stdout | > `, so those lines + // plus the surrounding gate log name the brain that printed them. expect(countsSpy).not.toHaveBeenCalled() expect(metadataSpy).not.toHaveBeenCalled() expect(graphSpy).not.toHaveBeenCalled() + + const flushChatter = logged.filter( + (l) => /All indexes flushed to disk/.test(l) || /Flushing Brainy indexes/.test(l) + ) + expect( + flushChatter, + `a flush narrated during the ${IDLE_WATCH_MS}ms idle window. This brain's own ` + + `providers were NOT called (asserted above), so the lines below were printed by ` + + `another brain alive in this process — find it by the 'stdout | > ' ` + + `prefix in the run log:\n${flushChatter.join('\n')}` + ).toEqual([]) }, 180_000) it('an explicit flush over a clean brain calls no provider and prints nothing', async () => {