fix(engine): repair two stale test mocks broken by #1910 (#1919)

Two engine test files fail on current `main` (17c4007). Both are stale
**test-mock** breakages — no production code is touched.

### 1. `restart.integration.test.ts`
Its `vi.mock("../pi.js", …)` factory replaces the module wholesale but
omits `ModelFallbackExhaustedError`. `triage.ts` guards its catch block
with `err instanceof ModelFallbackExhaustedError` (imported from
`pi.js`), so evaluating that guard throws *"No
ModelFallbackExhaustedError export is defined on the mock"*.

Fix: export a plain `Error`-subclass stub from the factory. No restart
test enters the fallback-exhausted branch, so `instanceof` simply
returns `false` — a faithful stub.

### 2. `reliability-interactions/mission-validation-trigger-gap.test.ts`
Two recovery-path `missionStore` mocks omit `getMission`. #1910's
mission-active gate now walks `getSlice → getMilestone → getMission`
inside `resolveFeatureMission`. The resulting throw is swallowed by
`processTaskOutcome`'s `catch`, aborting recovery before it can ensure
assertions / start the validator run — surfacing as
`ensureFeatureAssertionLinked` asserted called-once but seen 0 times.

Fix: add `getMission` returning an active mission to both mocks.

### Verification
```
npx vitest run src/__tests__/reliability-interactions/mission-validation-trigger-gap.test.ts src/__tests__/restart.integration.test.ts
Test Files  2 passed (2)
Tests  54 passed (54)
```

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Tests**
* Improved coverage for mission recovery and restart flows, making
validation scenarios more reliable.
* Fixed test mocks so recovery and triage paths can run without
unexpected errors during assertions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
gsxdsm
2026-07-06 13:11:45 -07:00
committed by GitHub
2 changed files with 16 additions and 0 deletions

View File

@@ -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(),

View File

@@ -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(),