fix: `mock.module()` in enhance-prompt tests poisons global module cache, breaking 149 tests
Problem
test/altimate/enhance-prompt.test.ts uses mock.module() to replace 7 core infrastructure modules (@/util/log, @/session/message-v2, @/session/llm, @/config/config, @/agent/agent, @/session/schema, @/provider/provider) with incomplete stubs.
Bun's mock.module() replaces modules globally for the entire process with no restore mechanism. This causes 149 test failures when running the full test suite (bun test), because the mocked stubs (e.g., Log without Default, empty MessageV2) are used by all subsequent test files instead of the real modules.
All 149 tests pass individually; they only fail when run together.
Root cause
mock.module("@/util/log")replacesLogwith a stub missingDefault→ 53 failuresmock.module("@/session/message-v2")replacesMessageV2with{}→ ~70 failuresmock.module("@/session/llm")replacesLLMwith a minimal stub → 5 failuresmock.module("@/config/config")replaces Config → remaining failures
Fix
Replace mock.module() with spyOn() — spies override specific methods on the real module objects and can be cleaned up via mockRestore() in afterAll. The 4 unnecessary mocks are removed entirely since the real modules work fine in the test environment.