When a test uses process-global/irreversible module mocking, prevent cross-test contamination by isolating the affected test files into separate bun test runs (batch isolation). Keep mocks narrowly scoped so tests don’t need to mock large dependency graphs, and avoid importing “config/provider” chains in units where tests shouldn’t require them.

Practical checklist:

Example (pattern):

// conversations.test.ts
mock.module('../config/config-loader', () => ({
  loadConfig: mock(async () => ({ assistant: 'claude' })),
}));

Then run it as an isolated invocation:

cd packages/core && bun test packages/core/src/db/conversations.test.ts

This ensures your tests remain deterministic and don’t break due to local .archon/config.yaml contents or prior mocked state from other test files.