Skip to content

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

Open
flexi767 wants to merge 2 commits into
Runfusion:mainfrom
flexi767:fix/stale-test-mocks
Open

fix(engine): repair two stale test mocks broken by #1910#1919
flexi767 wants to merge 2 commits into
Runfusion:mainfrom
flexi767:fix/stale-test-mocks

Conversation

@flexi767

@flexi767 flexi767 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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)

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.

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 Runfusion#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 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 5, 2026 17:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 34adbab9-5d1c-4055-bd66-5c37626b952c

📥 Commits

Reviewing files that changed from the base of the PR and between 17c4007 and e5cae03.

📒 Files selected for processing (2)
  • packages/engine/src/__tests__/reliability-interactions/mission-validation-trigger-gap.test.ts
  • packages/engine/src/__tests__/restart.integration.test.ts

📝 Walkthrough

Walkthrough

Test mocks were updated in two files: mission recovery tests now mock missionStore.getMission to support recovery traversal logic, and a restart integration test's pi.js mock now exports ModelFallbackExhaustedError as an Error subclass to prevent instanceof check failures.

Changes

Test mock fixes

Layer / File(s) Summary
Mission recovery getMission mock
packages/engine/src/__tests__/reliability-interactions/mission-validation-trigger-gap.test.ts
Added getMission implementation to mocked missionStore in two periodic recovery tests to support the getSlicegetMilestonegetMission traversal used during processTaskOutcome-driven recovery.
Restart pi.js mock export
packages/engine/src/__tests__/restart.integration.test.ts
Added ModelFallbackExhaustedError (an Error subclass) to the ../pi.js mock so instanceof checks in restart/triage code paths do not fail.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • Runfusion/Fusion#1345: Both PRs touch mission recovery/validation in processTaskOutcome, with this PR's test mocks matching the recovery logic changes in the related PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing two stale engine test mocks broken by #1910.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR repairs stale engine test mocks. The main changes are:

  • Added active mission data to the mission recovery test mocks.
  • Added a ModelFallbackExhaustedError export to the restart test's pi.js mock.
  • Kept the changes limited to test files.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
packages/engine/src/tests/reliability-interactions/mission-validation-trigger-gap.test.ts Adds getMission to recovery-path mission store mocks so the active mission gate can resolve the test fixture.
packages/engine/src/tests/restart.integration.test.ts Adds the missing fallback-exhaustion error export to the wholesale pi.js mock used by restart tests.

Reviews (2): Last reviewed commit: "Merge branch 'main' into fix/stale-test-..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants