refactor(planning): consolidate calculation, projection and worker ownership #298

Merged
nessar merged 8 commits from feature/planning-architecture into develop 2026-10-17 11:53:20 +02:00
Owner

Implements the four planning-architecture tickets on the shared integration branch. There is no intended visible behaviour change, except the declaration-entry month list noted below.

Closes #274
Closes #275
Closes #276
Closes #277

Changes

  • #274: Removed the writable remaining-balance mirror (remainingVacationDaysSignal), its legacy VacDay conversion, and the VacDay.classification/reason fields only that conversion used. The summary and details read the displayed plan.

  • #275: The new PlanningCalculationService owns:

    • request construction; the duration estimator reads the same request;
    • start()/cancel();
    • read-only pending and accepted state, plus explanation delivery for the accepted calculation.

    CalendarYear and UserInput derive their state from it. Dialogs, focus, live announcements and calendar-ready duration calibration stay in the component. Re-mounting the calendar does not re-announce or re-calibrate a previous result. Starting a calculation during a cancellation keeps focus where it is.

  • #276: CalendarService.project() returns the covered months together with immutable SelectedDates. Grouping is internal, and the class exposes isSelected/isStart/isEnd/dayTypes/getClasses. The raw/grouped array mutation contract and the min/max tracking are gone.

    • Decision taken during review: in declaration entry, the month grid stays fixed to the planning period (fixedMonths), so declaring an edge date never inserts a disabled month. Selections keep the connected-period widening.
  • #277: A single internal startWorkerJob owns worker creation, handler cleanup, termination and supersession for the plan, counterfactual and checkpoint-explanation jobs. leave-planner.worker-messages.ts is the shared request/response contract. PlanningCalculationContext is unchanged.

Integration gate (#275)

  • bun run lint, bun run format:check, both tsc configs: pass.
  • vitest run --coverage --maxWorkers=1 --exclude='src/app/benchmark/**': 37 files, 716 tests pass. The full suite including the benchmark: 39 files pass.
  • Benchmark-caller spec (src/app/benchmark): pass. Fixtures and assertions are unchanged.
  • Production build: pass. The two budget warnings (initial bundle and calendar-year.scss) already exist on develop; the bundle is about 1.5 kB smaller.
  • Browser QA, automated with Playwright on Chromium against ng serve, all passing:
    • initial calculation;
    • the previous result stays visible while a calculation runs;
    • keyboard cancel moves focus to the results title;
    • keyboard placement stepping and highlighting;
    • the comparison dialog opens with results and closes with Escape;
    • recalculation;
    • declaration toggle and erase;
    • no horizontal scroll at 375 px;
    • no console errors.
  • Review: an independent Opus verification of each ticket, and a two-axis code review (standards and spec). The findings were fixed in 43677ff, feb6511, a472347 and cee67ce. The remaining standards notes are judgement-call smells, for example the settle-once skeleton shared by the counterfactual and checkpoint-explanation jobs.

The branch is rebased on the latest origin/develop. Full benchmark performance acceptance stays in #78/#288. CI and benchmark policy are unchanged.

🤖 Generated with Claude Code

Implements the four planning-architecture tickets on the shared integration branch. There is no intended visible behaviour change, except the declaration-entry month list noted below. Closes #274 Closes #275 Closes #276 Closes #277 ## Changes - **#274**: Removed the writable remaining-balance mirror (`remainingVacationDaysSignal`), its legacy `VacDay` conversion, and the `VacDay.classification`/`reason` fields only that conversion used. The summary and details read the displayed plan. - **#275**: The new `PlanningCalculationService` owns: - request construction; the duration estimator reads the same request; - `start()`/`cancel()`; - read-only pending and accepted state, plus explanation delivery for the accepted calculation. `CalendarYear` and `UserInput` derive their state from it. Dialogs, focus, live announcements and calendar-ready duration calibration stay in the component. Re-mounting the calendar does not re-announce or re-calibrate a previous result. Starting a calculation during a cancellation keeps focus where it is. - **#276**: `CalendarService.project()` returns the covered months together with immutable `SelectedDates`. Grouping is internal, and the class exposes `isSelected`/`isStart`/`isEnd`/`dayTypes`/`getClasses`. The raw/grouped array mutation contract and the min/max tracking are gone. - Decision taken during review: in declaration entry, the month grid stays fixed to the planning period (`fixedMonths`), so declaring an edge date never inserts a disabled month. Selections keep the connected-period widening. - **#277**: A single internal `startWorkerJob` owns worker creation, handler cleanup, termination and supersession for the plan, counterfactual and checkpoint-explanation jobs. `leave-planner.worker-messages.ts` is the shared request/response contract. `PlanningCalculationContext` is unchanged. ## Integration gate (#275) - `bun run lint`, `bun run format:check`, both `tsc` configs: pass. - `vitest run --coverage --maxWorkers=1 --exclude='src/app/benchmark/**'`: 37 files, 716 tests pass. The full suite including the benchmark: 39 files pass. - Benchmark-caller spec (`src/app/benchmark`): pass. Fixtures and assertions are unchanged. - Production build: pass. The two budget warnings (initial bundle and `calendar-year.scss`) already exist on `develop`; the bundle is about 1.5 kB smaller. - Browser QA, automated with Playwright on Chromium against `ng serve`, all passing: - initial calculation; - the previous result stays visible while a calculation runs; - keyboard cancel moves focus to the results title; - keyboard placement stepping and highlighting; - the comparison dialog opens with results and closes with Escape; - recalculation; - declaration toggle and erase; - no horizontal scroll at 375 px; - no console errors. - Review: an independent Opus verification of each ticket, and a two-axis code review (standards and spec). The findings were fixed in `43677ff`, `feb6511`, `a472347` and `cee67ce`. The remaining standards notes are judgement-call smells, for example the settle-once skeleton shared by the counterfactual and checkpoint-explanation jobs. The branch is rebased on the latest `origin/develop`. Full benchmark performance acceptance stays in #78/#288. CI and benchmark policy are unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
nessar added 8 commits 2026-10-17 11:36:34 +02:00
The summary and details already read the displayed plan's remaining
balances, so the writable mirror, its legacy conversion and the VacDay
classification/reason fields it alone populated are removed.

Refs #274

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Planning, counterfactual analysis and checkpoint explanation now share
one internal worker-job owner for creation, handler cleanup,
termination and supersession, and one request/response message
contract between the coordinator and the worker. Job-specific progress,
checkpoint recovery and completion rules stay explicit.

Refs #277

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PlanningCalculationService now builds the submitted request, owns the
pending and accepted calculation state, and delivers explanations for
the accepted calculation only. The duration estimator reads the same
request. The calendar and leave-balance summary consume the accepted
outcome instead of coordinating writable state on the input service.

Refs #275

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CalendarService.project returns the covered months together with the
projected selections, so month enumeration and selected-day rendering
share one projection horizon. SelectedDates is built once from the
complete range list and groups connected periods internally, exposing
read-only selection, boundary and day-type queries.

In declaration entry, months reached by adjacent declared or
non-working days are now shown, matching the projected selections.

Refs #276

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
release() already clears the worker handlers, so the released checks
inside them could never run. The lifetime test now states what it
checks: no handler is left for late messages.

Refs #277

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Re-mounting the calendar no longer records a duration sample or
announces the previous result, explanation or rejected explanation.
Starting a calculation during a cancellation announces loading and
keeps focus where it is. Only rejected explanation deliveries are
announced, as before. Replacement tests now replace a real plan.

Refs #275, #274

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Declaring a date at the edge of the planning period widened the
projection and inserted a disabled month above the grid. Declaration
entry now lists only the planning period's months, while selections
keep the connected-period widening.

Refs #276

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
refactor(calendar): drop the unused projection horizon
CI / policy (push) Successful in 7s
CI / validate (push) Successful in 1m2s
CI / build (push) Successful in 1m27s
CI / policy (pull_request) Successful in 11s
CI / security (push) Successful in 1m12s
CI / validate (pull_request) Successful in 1m21s
CI / benchmark (push) Successful in 4m10s
CI / test (push) Successful in 4m19s
CI / security (pull_request) Successful in 1m3s
CI / test (pull_request) Successful in 3m23s
CI / images (push) Successful in 1m34s
CI / build (pull_request) Successful in 34s
CI / required (push) Successful in 3s
CI / benchmark (pull_request) Successful in 7m13s
CI / images (pull_request) Successful in 1m56s
CI / required (pull_request) Successful in 2s
cee67ce3df
No caller read CalendarProjection.horizon, and with fixed months it no
longer described the listed months.

Refs #276

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nessar merged commit 752c8b7a99 into develop 2026-10-17 11:53:20 +02:00
Sign in to join this conversation.