test(planning): script calculation lifecycle specs through jobs instead of fake Workers #337

Closed
opened 2026-11-10 17:53:48 +01:00 by nessar · 0 comments
Owner

Parent

#335

What to build

This ticket belongs to workstream A (decided). Migrate the largest planner spec, the one for the planning calculation module (about 4,200 lines, the biggest in the repository), so it stops choosing an engine by stubbing the global window and stops scripting lifecycle behavior with hand-written fake Worker classes. At the time of writing it has 46 window stubs and 12 fake Worker classes.

  • Planner behavior tests, which today stub the window (directly or through a small helper) to reach the in-process planner, use the in-process job helper from the first A ticket.
  • Lifecycle tests, which today install a fake Worker class to script messages, now script a job with the scripted-job helper. Keep each test's intent and its assertions about outcome, explanation, artifacts and release. The rules they cover are: user cancellation including a natural result that arrives after Cancel, replacement by a newer calculation, liveness expiry after thirty seconds without a heartbeat, progress or checkpoint, checkpoint recovery and checkpoint explanation, post failure and unexpected responses, delayed or failing artifacts, and superseded counterfactual analyses.
  • One test covers a browser that cannot start a worker: it uses a factory whose job cannot start and expects worker-unavailable. The test that expects invalid input when no Worker exists and the window does is rewritten to use the in-process job (see the spec's note on this nuance) and says so in the PR.
  • Where an old expectation held only because a non-worker branch behaved differently from the production lifecycle, the production behavior wins and the PR lists each such change.
  • Both non-worker branches stay in the module in this ticket; they are deleted by the last A ticket.

Acceptance criteria

  • A repository search for stubbing the global window finds none in this spec, and a search for hand-written Worker or WebSocket classes finds none in it.
  • bun run lint, bun run format:check, bun run typecheck and bun run test pass.
  • No lifecycle rule loses its coverage. A removal experiment is recorded in the PR: temporarily disable each of the cancel-after-result rule, the thirty-second inactivity rule, the stale-calculation reason, checkpoint recovery and the worker-unavailable result, and show that at least one test in the suite fails for each.
  • The number of tests is not reduced, except for named tests that only covered a deleted branch's own flags; each is listed with its reason in the PR.
  • The frozen-engine differential check and the benchmark gate still pass unchanged.
  • The PR states the net line change of the spec. A net reduction is expected; an increase is explained.
  • Delivered on a feature/* branch from the current origin/develop, PR to develop with a Conventional Commit title, merge commit.

Blocked by

## Parent #335 ## What to build This ticket belongs to workstream A (decided). Migrate the largest planner spec, the one for the planning calculation module (about 4,200 lines, the biggest in the repository), so it stops choosing an engine by stubbing the global window and stops scripting lifecycle behavior with hand-written fake Worker classes. At the time of writing it has 46 window stubs and 12 fake Worker classes. - Planner behavior tests, which today stub the window (directly or through a small helper) to reach the in-process planner, use the in-process job helper from the first A ticket. - Lifecycle tests, which today install a fake Worker class to script messages, now script a job with the scripted-job helper. Keep each test's intent and its assertions about outcome, explanation, artifacts and release. The rules they cover are: user cancellation including a natural result that arrives after Cancel, replacement by a newer calculation, liveness expiry after thirty seconds without a heartbeat, progress or checkpoint, checkpoint recovery and checkpoint explanation, post failure and unexpected responses, delayed or failing artifacts, and superseded counterfactual analyses. - One test covers a browser that cannot start a worker: it uses a factory whose job cannot start and expects worker-unavailable. The test that expects invalid input when no Worker exists and the window does is rewritten to use the in-process job (see the spec's note on this nuance) and says so in the PR. - Where an old expectation held only because a non-worker branch behaved differently from the production lifecycle, the production behavior wins and the PR lists each such change. - Both non-worker branches stay in the module in this ticket; they are deleted by the last A ticket. ## Acceptance criteria - [ ] A repository search for stubbing the global window finds none in this spec, and a search for hand-written Worker or WebSocket classes finds none in it. - [ ] `bun run lint`, `bun run format:check`, `bun run typecheck` and `bun run test` pass. - [ ] No lifecycle rule loses its coverage. A removal experiment is recorded in the PR: temporarily disable each of the cancel-after-result rule, the thirty-second inactivity rule, the stale-calculation reason, checkpoint recovery and the worker-unavailable result, and show that at least one test in the suite fails for each. - [ ] The number of tests is not reduced, except for named tests that only covered a deleted branch's own flags; each is listed with its reason in the PR. - [ ] The frozen-engine differential check and the benchmark gate still pass unchanged. - [ ] The PR states the net line change of the spec. A net reduction is expected; an increase is explained. - [ ] Delivered on a `feature/*` branch from the current `origin/develop`, PR to `develop` with a Conventional Commit title, merge commit. ## Blocked by - #336
nessar added the ready-for-agent label 2026-11-10 17:53:48 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nessar/vac-optimizer#337