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: keep code review health import scoped

[._.]/ Adam Eivy0386d582f778
diff --git a/server/lib/importScoping.test.js b/server/lib/importScoping.test.js
index 9f84bfcc19..10d31d7ed9 100644
--- a/server/lib/importScoping.test.js
+++ b/server/lib/importScoping.test.js
@@ -803,7 +803,10 @@ describe('deferred imports stay deferred (#6156)', () => {
// imported at module scope even though each runs only from an explicit queue,
// mutation, forwarding, or H3-render path. Keep those boundaries deferred so
// unrelated server suites do not pay their subtrees.
-const MAX_STATIC_INSTANTIATIONS = 116500;
+// 116,500 -> 116,600 (reviewer configuration health): the health route's
+// code-review mock adds 47 measured static instantiations across the suite;
+// the production route keeps the service import dynamic to avoid that graph.
+const MAX_STATIC_INSTANTIATIONS = 116600;
const SKIP_DIRS = new Set(['node_modules', 'coverage', 'dist', 'data']);
diff --git a/server/routes/health.test.js b/server/routes/health.test.js
index 30626732ae..51205d9c88 100644
--- a/server/routes/health.test.js
+++ b/server/routes/health.test.js
@@ -89,10 +89,12 @@ vi.mock('../services/github.js', () => ({
})
}));
-vi.mock('../services/codeReview.js', () => ({
+const codeReviewMock = vi.hoisted(() => ({
getReviewerConfigHealth: vi.fn().mockResolvedValue({ status: 'ok', configFaults: {} }),
}));
+vi.mock('../services/codeReview.js', () => codeReviewMock);
+
vi.mock('../services/settings.js', () => ({
getSettings: vi.fn().mockResolvedValue({}),
updateSettings: vi.fn().mockResolvedValue({}),
@@ -110,8 +112,6 @@ vi.mock('../services/settings.js', () => ({
})
}));
-const { getReviewerConfigHealth } = await import('../services/codeReview.js');
-
describe('System Health Routes', () => {
const app = express();
app.use(express.json());
@@ -297,7 +297,7 @@ describe('System Health Routes', () => {
});
it('surfaces persisted reviewer configuration faults as install health', async () => {
- getReviewerConfigHealth.mockResolvedValueOnce({
+ codeReviewMock.getReviewerConfigHealth.mockResolvedValueOnce({
status: 'warning',
configFaults: { ollama: { code: 'NO_MODEL', lastFailureAt: 123 } },
});
diff --git a/server/services/codeReview.js b/server/services/codeReview.js
index 226a7002dd..0d63743121 100644
--- a/server/services/codeReview.js
+++ b/server/services/codeReview.js
@@ -45,7 +45,6 @@ import {
EFFORT_SELECTABLE_REVIEWERS,
MODEL_SELECTABLE_REVIEWERS,
} from '../lib/validation.js'
-import { isReviewerConfigFault } from '../lib/reviewerConfig.js'
import {
MAX_FIDELITY_DIFF_CHARS,
normalizeGoalFidelityVerdict,
@@ -56,6 +55,10 @@ import { getSettings, updateSettingsWith, settingsEvents } from './settings.js'
export const REVIEWER_PAUSE_MS = 24 * 60 * 60 * 1000
const QUOTA_FAILURE = /quota|rate.?limit|usage.?limit|allowance|credit|capacity|exhausted|too many requests|429/i
+// Keep this tiny predicate local: codeReview.js is imported by health and API
+// routes, so reaching into reviewerConfig.js here would pull the entire review
+// configuration graph into a widely-reached module and trip the import budget.
+const isReviewerConfigFault = (code) => code === 'NO_MODEL' || code === 'REVIEWER_UNSUPPORTED'
export const isReviewerQuotaFailure = (error) => QUOTA_FAILURE.test(String(error || ''))
const normalizeFallbackGroups = (groups) => Array.isArray(groups)