Skip to content

refactor(schedule): the two legs become two functions - #293

Merged
JanWelker merged 1 commit into
mainfrom
refactor/cold-and-room-schedules
Sep 5, 2026
Merged

refactor(schedule): the two legs become two functions#293
JanWelker merged 1 commit into
mainfrom
refactor/cold-and-room-schedules

Conversation

@JanWelker

Copy link
Copy Markdown
Owner

The last item from the review: computeSchedule's cold/room split.

Why

180 lines in which the interesting fork — which leg spends the window — sat in the middle of an if/else, writing into four lets declared above it, and mutating prefermentDurationsMin in one branch only. Reading the cold path meant skipping past the room path and remembering which variables each had assigned.

What

coldSchedule() and roomSchedule() each take a PlanArgs and return a FermentPlan — yeast percent, steps, and the two cold-bulk signals. computeSchedule now reads as three parts:

  1. read the inputs (durations, temperatures, warnings that don't depend on the leg)
  2. pick the leg — one line
  3. assemble the answer

No let and no mutation left: the room leg's pre-ferment clamp returns a new list instead of reassigning the one the caller built.

Behaviour

Identical. The yeast-solve and mass-balance matrices already cover both legs exhaustively — {fresh, instant, active-dry, sourdough} × {none, biga, poolish, both} × {room, cold} × {spiral, stand, hand} × ball proof — and all 940 pass unchanged, as do the 90 browser tests.

One thing the split made worth stating

Room mode returns null for both cold-bulk signals; cold mode returns both. quality.ts reads exactly that to tell which leg ran, so it is a contract — and nothing checked it while the two legs shared a pair of lets. Now pinned in schedule.test.ts, including that the natural value is the desired one capped at the 48 h ceiling.

Checks

940 unit (+2), 90 browser, coverage 100 %.

computeSchedule was 180 lines in which the interesting fork — which leg
spends the window — sat in the middle of an if/else, writing into four
`let`s declared above it and mutating the pre-ferment durations in one
branch only.

coldSchedule() and roomSchedule() each take what they need and return a
FermentPlan: yeast percent, steps, and the two cold-bulk signals.
computeSchedule now reads as three parts — read the inputs, pick the
leg, assemble the answer — with the choice on one line.

No `let` and no mutation left: the room leg's pre-ferment clamp returns
a new list rather than reassigning the one the caller built.

Behaviour is identical, which the yeast-solve and mass-balance matrices
already cover exhaustively. What they did not cover is the contract the
split now states outright: room mode reports null for both cold-bulk
signals and cold mode reports both, which is how quality.ts tells which
leg ran. Pinned.

Baseline: 940 unit (+2).
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-09-05 11:17 UTC

@JanWelker
JanWelker merged commit f80ed43 into main Sep 5, 2026
6 of 7 checks passed
@JanWelker
JanWelker deleted the refactor/cold-and-room-schedules branch September 5, 2026 11:16
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.

1 participant