Problem
.agents/rules/stack.md requires per-test Layer.build inside it.effect bodies. Using @effect/vitest layer(...) memoizes the Layer graph across tests in a suite, which can leak stateful services between tests.
Current violations:
packages/server/test/events.test.ts — layer(EventBusLayer)("EventBus", ...)
packages/server/test/harness/session.test.ts — module-scoped const layer = SessionServiceLayer.pipe(Layer.provide(EventBusLayer)) with a shared run() helper
packages/server/test/observability/turn-log.test.ts already documents the correct pattern with an inline comment explaining why layer(EventBusLayer) is wrong.
Why it matters
Stateful services (EventBus, session instances) can leak between tests, producing order-dependent failures that are hard to reproduce.
Suggested fix
Migrate these suites to @effect/vitest it.effect with Layer.build (or scoped Effect.gen) per test, matching turn-log.test.ts and launcher.test.ts.
Related
Severity
P2
Problem
.agents/rules/stack.mdrequires per-testLayer.buildinsideit.effectbodies. Using@effect/vitestlayer(...)memoizes the Layer graph across tests in a suite, which can leak stateful services between tests.Current violations:
packages/server/test/events.test.ts—layer(EventBusLayer)("EventBus", ...)packages/server/test/harness/session.test.ts— module-scopedconst layer = SessionServiceLayer.pipe(Layer.provide(EventBusLayer))with a sharedrun()helperpackages/server/test/observability/turn-log.test.tsalready documents the correct pattern with an inline comment explaining whylayer(EventBusLayer)is wrong.Why it matters
Stateful services (EventBus, session instances) can leak between tests, producing order-dependent failures that are hard to reproduce.
Suggested fix
Migrate these suites to
@effect/vitestit.effectwithLayer.build(or scopedEffect.gen) per test, matchingturn-log.test.tsandlauncher.test.ts.Related
Severity
P2