From e5cae03f9a852c16b2148e8634b31cd442b136ff Mon Sep 17 00:00:00 2001 From: fusion-merge-train Date: Sun, 5 Jul 2026 19:56:06 +0200 Subject: [PATCH] fix(engine): repair two stale test mocks broken by #1910 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit restart.integration.test.ts's `../pi.js` factory replaces the module wholesale but omits ModelFallbackExhaustedError, which triage.ts references via `err instanceof ModelFallbackExhaustedError` — evaluating the guard threw "No ModelFallbackExhaustedError export is defined on the mock". Added a plain Error-subclass stub (no restart test enters the fallback-exhausted branch). mission-validation-trigger-gap.test.ts's two recovery-path missionStore mocks omit getMission, which #1910's mission-active gate now walks (getSlice → getMilestone → getMission) inside resolveFeatureMission. The throw was swallowed by processTaskOutcome's catch, aborting recovery before it ensured assertions / started the validator run — surfacing as ensureFeatureAssertionLinked called 0 times. Added getMission returning an active mission. Co-Authored-By: Claude Opus 4.8 --- .../mission-validation-trigger-gap.test.ts | 10 ++++++++++ .../engine/src/__tests__/restart.integration.test.ts | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/packages/engine/src/__tests__/reliability-interactions/mission-validation-trigger-gap.test.ts b/packages/engine/src/__tests__/reliability-interactions/mission-validation-trigger-gap.test.ts index fe3064af92..2cbfdb9ba9 100644 --- a/packages/engine/src/__tests__/reliability-interactions/mission-validation-trigger-gap.test.ts +++ b/packages/engine/src/__tests__/reliability-interactions/mission-validation-trigger-gap.test.ts @@ -215,6 +215,11 @@ describe("FN-5715 reliability: mission validation trigger gap", () => { completeValidatorRun: vi.fn(), getSlice: vi.fn(() => ({ id: "SL-001", milestoneId: "MS-001", status: "active" })), getMilestone: vi.fn(() => ({ id: "MS-001", missionId: "M-001" })), + // resolveFeatureMission (reached via processTaskOutcome during recovery) + // walks getSlice → getMilestone → getMission to gate on mission.status. + // Without getMission the walk throws and recovery aborts before it can + // ensure assertions / start the validator run this test asserts on. + getMission: vi.fn(() => ({ id: "M-001", status: "active" })), logMissionEvent: vi.fn(), transitionLoopState: vi.fn(), setFeatureCurrentTaskRunId: vi.fn(), @@ -277,6 +282,11 @@ describe("FN-5715 reliability: mission validation trigger gap", () => { completeValidatorRun: vi.fn(), getSlice: vi.fn(() => ({ id: "SL-001", milestoneId: "MS-001", status: "active" })), getMilestone: vi.fn(() => ({ id: "MS-001", missionId: "M-001" })), + // resolveFeatureMission (reached via processTaskOutcome during recovery) + // walks getSlice → getMilestone → getMission to gate on mission.status. + // Without getMission the walk throws and recovery aborts before it can + // ensure assertions / start the validator run this test asserts on. + getMission: vi.fn(() => ({ id: "M-001", status: "active" })), logMissionEvent: vi.fn(), transitionLoopState: vi.fn(), setFeatureCurrentTaskRunId: vi.fn(), diff --git a/packages/engine/src/__tests__/restart.integration.test.ts b/packages/engine/src/__tests__/restart.integration.test.ts index 3bc7b31f15..285891d266 100644 --- a/packages/engine/src/__tests__/restart.integration.test.ts +++ b/packages/engine/src/__tests__/restart.integration.test.ts @@ -43,6 +43,12 @@ vi.mock("../pi.js", () => ({ // session. The mock must expose the export so the resume/triage paths can // reach finalization instead of throwing on a missing mock member. formatModelMarkerDetails: vi.fn((model: string) => model), + // triage.ts guards its catch block with `err instanceof ModelFallbackExhaustedError` + // (imported from pi.js). Because this factory replaces pi.js wholesale, the class + // must be exported or evaluating the `instanceof` throws "No ModelFallbackExhaustedError + // export is defined on the mock". No restart test enters the fallback-exhausted branch, + // so a plain Error subclass is a faithful stub (instanceof simply returns false). + ModelFallbackExhaustedError: class ModelFallbackExhaustedError extends Error {}, })); vi.mock("../reviewer.js", () => ({ reviewStep: vi.fn(),