feat(docs): streamline scheduling guides and simplify playground settings labels #131
29 changed files with 831 additions and 1241 deletions
|
|
@ -5,5 +5,6 @@
|
|||
**I18n**: Bilingual strings for the Recipe Studio drawer of the playground:
|
||||
|
||||
- Labels for the scheduling settings, the section activity indicators and the explanatory tooltips of every setting
|
||||
- The summary of the "Schedule & Service" section is now fully translated: the serving time, custom hours, and the mise en place and waits chosen no longer show up in French on the English playground
|
||||
- The summary of the schedule section is now fully translated: the serving time, custom hours, and the mise en place and waits chosen no longer show up in French on the English playground
|
||||
- Simplified section titles (Schedule, Quantities, Baker's percentages, Display, Nutrition and mass, Stocked bases) in English and French, and refreshed the onboard settings hint
|
||||
- The physical analysis summary and the list of serving times that don't work are translated too, and the serving time field is called "Serving time" ("Heure de service" in French)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@ const SITE_URL = 'https://gram-lang.org';
|
|||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
site: 'https://gram-lang.org',
|
||||
redirects: {
|
||||
'/docs/explanation/mise-en-place-and-planning': '/docs/explanation/planning',
|
||||
'/docs/explanation/planning-in-real-time': '/docs/explanation/planning',
|
||||
'/fr/docs/explanation/mise-en-place-and-planning': '/fr/docs/explanation/planning',
|
||||
'/fr/docs/explanation/planning-in-real-time': '/fr/docs/explanation/planning'
|
||||
},
|
||||
devToolbar: {
|
||||
enabled: false
|
||||
},
|
||||
|
|
@ -151,8 +157,7 @@ export default defineConfig({
|
|||
{ label: 'Nutrition', slug: 'docs/explanation/nutrition' },
|
||||
{ label: 'Shopping lists', translations: { fr: 'Liste de courses' }, slug: 'docs/explanation/shopping-list-aggregation' },
|
||||
{ label: 'Scaling', translations: { fr: "Ajustement des proportions" }, slug: 'docs/explanation/scaling' },
|
||||
{ label: 'Mise en place & planning', translations: { fr: 'Mise en place & planning' }, slug: 'docs/explanation/mise-en-place-and-planning', badge: { text: 'v1.4.0', variant: 'default' } },
|
||||
{ label: 'Planning in real time', translations: { fr: 'Planifier en heures réelles' }, slug: 'docs/explanation/planning-in-real-time', badge: { text: 'v1.4.0', variant: 'default' } }
|
||||
{ label: 'Planning & run sheet', translations: { fr: 'Planification & plan de marche' }, slug: 'docs/explanation/planning', badge: { text: 'v1.4.0', variant: 'default' } }
|
||||
]
|
||||
},
|
||||
{ label: 'Changelog', translations: { fr: 'Changelog' }, slug: 'docs/changelog' }
|
||||
|
|
|
|||
|
|
@ -709,7 +709,7 @@ Roast the chicken for ~{40-50min}.
|
|||
|
||||
The interpretation of a range differs fundamentally based on timer type:
|
||||
|
||||
- **A passive range represents elasticity.** The declaration `~_{12-24h}` states: "ready from 12 hours, optimal up to 24 hours". By default, the timeline lays out the shortest bound (`'shortest'`). You can select alternative elasticity strategies (`'shortest'`, median `'balanced'`, or longest `'longest'`) via the `--rests` CLI option, the `gram.rests` VS Code setting, or the `rests` renderer option. When provided with a target serving time and kitchen availability, the scheduler uses this elasticity to bridge overnight non-working hours without requiring cook intervention (see [Planning in real time](/docs/explanation/planning-in-real-time/)).
|
||||
- **A passive range represents elasticity.** The declaration `~_{12-24h}` states: "ready from 12 hours, optimal up to 24 hours". By default, the timeline lays out the shortest bound (`'shortest'`). You can select alternative elasticity strategies (`'shortest'`, median `'balanced'`, or longest `'longest'`) via the `--rests` CLI option, the `gram.rests` VS Code setting, or the `rests` renderer option. When provided with a target serving time and kitchen availability, the scheduler uses this elasticity to bridge overnight non-working hours without requiring cook intervention (see [Planning and run sheets](/docs/explanation/planning/)).
|
||||
- **How the <Term id="runSheet" /> reflects ranges.** The run sheet displays each passive wait with its scheduled duration and, when adjusted, reminds you of the original range specified in the recipe (e.g. `15 h 50 (12 to 48 h)`). This elasticity is what grants an anticipation margin to a kitchen visit ("Possible from 18:00"), since a stretchable wait allows upstream tasks to be performed earlier. Conversely, an exact passive duration fixes the visit time in place ("Can't start earlier"). See [Plan a meal](/docs/how-to/plan-a-meal/).
|
||||
- **An active range represents operational uncertainty.** The declaration `~{40-50min}` represents how long the chicken takes to roast. The schedule always defaults to the longest bound (50 minutes) so that service is never delayed. Passive elasticity settings (`rests`) do not apply to active timers.
|
||||
|
||||
|
|
@ -880,14 +880,14 @@ Warnings are non-blocking by default, but can be enforced as errors via `gram ch
|
|||
href="/docs/explanation/alap-scheduling/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Planning in real time"
|
||||
description="How the scheduler projects tasks onto clock times and user availability windows."
|
||||
href="/docs/explanation/planning-in-real-time/"
|
||||
title="Planning and run sheets"
|
||||
description="Mise en place modes, elastic timers, calendar projection, and run sheet generation."
|
||||
href="/docs/explanation/planning/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Mise en place and planning"
|
||||
description="Explore how preparation costs, section day anchors, and multi-day recipes interact."
|
||||
href="/docs/explanation/mise-en-place-and-planning/"
|
||||
title="Plan a meal"
|
||||
description="Step-by-step practical guide to calculating schedules with gram plan."
|
||||
href="/docs/how-to/plan-a-meal/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Compiler warnings reference"
|
||||
|
|
|
|||
|
|
@ -1,33 +1,33 @@
|
|||
---
|
||||
title: "ALAP scheduling"
|
||||
description: "How Gram's reverse ALAP scheduling engine optimizes kitchen timelines, eliminates idle bottlenecks, and schedules active tasks in masked time."
|
||||
description: "How Gram's As Late As Possible (ALAP) reverse scheduling eliminates downtime, keeps ingredients fresh, and handles shared cookware tracks."
|
||||
---
|
||||
|
||||
import Since from '../../../../components/Since.astro';
|
||||
import { Steps, LinkCard, CardGrid } from '@astrojs/starlight/components';
|
||||
import Term from '../../../../components/Term.astro';
|
||||
|
||||
Gram does not simply read recipes from top to bottom: it actively computes their optimal schedule to save valuable kitchen time.
|
||||
Gram does not simply read recipes top to bottom: it actively calculates their optimal timeline to save you valuable time in the kitchen.
|
||||
|
||||
To achieve this, the engine relies on a reverse planning algorithm called **ALAP (*As Late As Possible*)**. This ensures every ingredient or intermediate preparation finishes exactly when the subsequent step requires it, preventing components from lingering and deteriorating on the kitchen counter.
|
||||
To achieve this, the engine relies on a reverse scheduling algorithm called **ALAP (*As Late As Possible*)**. This ensures every ingredient or intermediate component finishes right when the next step requires it, preventing delicate items from sitting idle on the counter.
|
||||
|
||||
## The problem: forward scheduling
|
||||
## The problem: naive forward scheduling
|
||||
|
||||
Consider a classic recipe combining a dough that requires 1 hour of rising, a quick sauce taking 10 minutes of active preparation, and a final oven bake:
|
||||
Consider a classic recipe combining dough that needs 1 hour to rise, a quick sauce requiring 10 minutes of active prep, and a final bake:
|
||||
|
||||
```gram
|
||||
[Knead] The @flour with the @water and let it rise ~_{1h}. ->&dough
|
||||
[Knead] Mix @flour with @water and let rise ~_{1h}. ->&dough
|
||||
|
||||
[Mix] The sauce ingredients ~{10min}. ->&sauce
|
||||
[Stir] Combine @tomato sauce{} and @basil ~{10min}. ->&sauce
|
||||
|
||||
[Bake] The &dough with the &sauce in the oven for ~_{30min}.
|
||||
[Bake] Bake &dough with &sauce in the oven ~_{30min}.
|
||||
```
|
||||
|
||||
With naive top-to-bottom forward scheduling (*Forward Scheduling*), the timeline produces significant idle delays:
|
||||
With naive forward scheduling (starting each task as early as possible), the timeline has an obvious flaw:
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title Forward schedule (50 min of wasted idle time)
|
||||
title Naive forward scheduling (50 min idle wait)
|
||||
dateFormat m
|
||||
axisFormat %M
|
||||
|
||||
|
|
@ -36,26 +36,24 @@ gantt
|
|||
Dough rise (passive timer) : a2, after a1, 60m
|
||||
|
||||
section Sauce
|
||||
Mix (active work) : active, a3, after a1, 10m
|
||||
Sauce sitting idle (50 min wasted) : crit, a4, after a3, 50m
|
||||
Stir (active work) : active, a3, after a1, 10m
|
||||
Sauce sits idle (50 min wasted) : crit, a4, after a3, 50m
|
||||
|
||||
section Bake
|
||||
Oven baking (passive timer) : a5, after a2, 30m
|
||||
Bake in oven (passive timer) : a5, after a2, 30m
|
||||
```
|
||||
|
||||
The flaw is obvious: the sauce finishes at minute 12, whereas dough rising completes only at minute 62. The sauce sits on the counter for 50 minutes cooling or breaking before it is finally baked!
|
||||
The sauce is ready at minute 12, but dough rising finishes only at minute 62. The sauce sits idle on the counter for 50 minutes, separating or cooling down.
|
||||
|
||||
## The solution: ALAP reverse scheduling
|
||||
## The solution: reverse ALAP scheduling
|
||||
|
||||
Instead of scheduling steps as early as possible, Gram's compiler works **backwards** starting from the recipe's target completion deadline.
|
||||
Instead of starting tasks as early as possible, Gram's compiler works **backward** from the final serving deadline.
|
||||
|
||||
When the engine detects that the final `[Bake]` step requires both `&dough` and `&sauce`, it sets a strict deadline for both. It then shifts sauce preparation to the latest possible start time, ensuring it finishes *exactly* as the dough completes its rise and enters the oven.
|
||||
|
||||
Here is the optimized timeline generated by Gram:
|
||||
When the engine detects that `[Bake]` consumes both `&dough` and `&sauce`, it calculates their exact completion deadline. It then shifts sauce preparation to the latest possible start time, ensuring it concludes *precisely* when dough fermentation ends:
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title ALAP schedule (Gram — Optimized masked time)
|
||||
title ALAP scheduling (Gram — Masked time execution)
|
||||
dateFormat m
|
||||
axisFormat %M
|
||||
|
||||
|
|
@ -64,89 +62,17 @@ gantt
|
|||
Dough rise (passive timer) : b2, after b1, 60m
|
||||
|
||||
section Sauce
|
||||
Mix (active work) : active, b3, 52, 10m
|
||||
Stir (active work) : active, b3, 52, 10m
|
||||
|
||||
section Bake
|
||||
Oven baking (passive timer) : b4, after b2, 30m
|
||||
Bake in oven (passive timer) : b4, after b2, 30m
|
||||
```
|
||||
|
||||
*(Note: In the absence of an explicit active timer, Gram automatically assigns 2 minutes of active work to kneading).*
|
||||
*(Note: when an active step lacks an explicit timer, Gram allocates a default 2-minute active duration).*
|
||||
|
||||
By aligning sauce preparation with the end of the rise, Gram schedules this active work **during** the dough's passive time. Your workflow remains continuous, total duration is optimized, and ingredients preserve maximum freshness.
|
||||
By aligning sauce completion with the end of dough fermentation, Gram nests active prep **inside** the passive wait. Your tasks flow naturally, overall time is minimized, and preparations remain at peak freshness.
|
||||
|
||||
## Scheduling the mise en place
|
||||
<Since v="1.4.0" />
|
||||
|
||||
Section mise en place (gathering and measuring ingredients, setting out cookware) is scheduled as a dedicated task at the start of that section. Consider a dough followed by a cooked filling:
|
||||
|
||||
```gram
|
||||
## Dough ->&dough
|
||||
|
||||
[Mix] @flour{500g} and @water{300ml} in a #bowl.
|
||||
|
||||
[Rise] Let the dough rise ~_{2h}.
|
||||
|
||||
## Filling ->&filling
|
||||
|
||||
[Sauté] Sauté @onions{200g}(sliced) in a #pan.
|
||||
|
||||
## Assembly
|
||||
|
||||
[Spread] Spread &filling over &dough.
|
||||
|
||||
[Bake] In the #oven for ~{25min}.
|
||||
```
|
||||
|
||||
Scheduled **by section** (the default mode), each preparation takes place right before execution. Filling and assembly preparations slide into the dough's 2-hour rise in masked time:
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title Mise en place by section (2 h 32)
|
||||
dateFormat HH:mm
|
||||
axisFormat %H:%M
|
||||
todayMarker off
|
||||
section Dough
|
||||
Mise en place : p1, 00:00, 3m
|
||||
Mix : active, a1, 00:03, 2m
|
||||
Rise (passive) : r1, 00:05, 120m
|
||||
section Filling
|
||||
Mise en place : p2, 01:56, 4m
|
||||
Sauté : active, a2, 02:00, 2m
|
||||
section Assembly
|
||||
Mise en place : p3, 02:02, 3m
|
||||
Spread : active, a3, 02:05, 2m
|
||||
Bake : active, a4, 02:07, 25m
|
||||
```
|
||||
|
||||
Scheduled **all at the start**, raw ingredient preparation is grouped upfront before any cooking begins:
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title Mise en place all at the start (2 h 39)
|
||||
dateFormat HH:mm
|
||||
axisFormat %H:%M
|
||||
todayMarker off
|
||||
section Mise en place
|
||||
Dough : p1, 00:00, 3m
|
||||
Filling : p2, 00:03, 4m
|
||||
Assembly : p3, 00:07, 3m
|
||||
section Dough
|
||||
Mix : active, a1, 00:10, 2m
|
||||
Rise (passive) : r1, 00:12, 120m
|
||||
section Filling
|
||||
Sauté : active, a2, 02:10, 2m
|
||||
section Assembly
|
||||
Spread : active, a3, 02:12, 2m
|
||||
Bake : active, a4, 02:14, 25m
|
||||
```
|
||||
|
||||
Both schedules accurately represent the same recipe. Total duration differs by only 7 minutes (4 min filling prep + 3 min assembly prep) that are no longer absorbed in masked time during the rise. While "by section" optimizes total elapsed time, "all at the start" suits cooks who prefer clearing their preparation counter before turning on the heat.
|
||||
|
||||
:::note[Intermediate ingredient handling]
|
||||
An intermediate ingredient (`&dough`) requires approximately 1 minute of handling. This preparation cost is allocated to the section that **consumes** it (here, assembly), rather than the section producing it.
|
||||
:::
|
||||
|
||||
## Dedicated equipment tracks (named tracks)
|
||||
## Shared cookware and named tracks
|
||||
|
||||
Gram's ALAP engine natively manages shared physical resources through **named tracks**. When you assign the same track identifier to multiple passive timers (e.g. `~_oven{20min}` and `~_oven{30min}`), Gram enforces sequential execution on that specific piece of equipment.
|
||||
|
||||
|
|
@ -169,17 +95,6 @@ gantt
|
|||
|
||||
`Prep bread` is automatically scheduled during tart baking (minutes 20 to 25): bread is ready to bake the exact moment the tart leaves the oven at minute 25.
|
||||
|
||||
## Time anchors, working days, and dependencies
|
||||
|
||||
A section's retro-planning anchor (`~{-2d}`) defines a **strict completion deadline** relative to final serving time. Between anchored sections, intermediate steps align backwards automatically through dependency chaining.
|
||||
|
||||
Key guidelines for multi-day recipes:
|
||||
|
||||
- **Anchor using calendar days (`~{-Nd}`)**: working day segmentation relies exclusively on day anchors (`~{-1d}`, `~{-2d}`). Unanchored sections inherit the day of the furthest downstream day anchor.
|
||||
- **Long passive timers do not create working days**: a step with `~_{48h}` shifts steps backwards on the timeline, but does not initiate a D-2 working day without an explicit section day anchor (`## Cream ~{-2d}`).
|
||||
- **Hour anchors (`~{-Nh}`) do not create working days**: values like `~{-18h}` or `~{-36h}` establish intra-day deadlines without opening a separate working day. To open the previous working day, use `~{-1d}`.
|
||||
- **Successive sections on the same day**: anchor only the final section (`## Tart ~{-1d}`) and leave preceding sections unanchored. Assigning the same anchor to interdependent sections triggers a time paradox warning.
|
||||
|
||||
## Modular anchoring (`@use ... ~{-1d}`)
|
||||
|
||||
When assembling modular recipes with `@gram-lang/modules`, you can attach a retro-planning offset directly to an import directive:
|
||||
|
|
@ -211,28 +126,28 @@ To maximize the efficiency of Gram's ALAP scheduling engine, follow these practi
|
|||
Steps without timers receive a default 2-minute active duration. Model coherent kitchen actions rather than micro-steps to prevent artificially inflating cumulative active time.
|
||||
</Steps>
|
||||
|
||||
## Visualization and user interface integration
|
||||
## From algorithm to schedule
|
||||
|
||||
Because Gram's ALAP engine deterministically computes minute-accurate `start` and `end` bounds, client applications require zero custom date calculation: they directly consume the planned task graph.
|
||||
ALAP scheduling produces the foundational timeline (`layout()`). This structure serves as the basis for all presentation and planning options:
|
||||
|
||||
A timeline representation (such as the Mermaid `gantt` charts above) clearly highlights passive task overlap and active task interleaving in masked time. These are the exact same data points that the <Term id="runSheet" /> visualizes. You can test and inspect this scheduling behavior interactively in the **[Gram Playground](/play/)**.
|
||||
- **Mise en place strategies**: by section (in masked time), upfront, or per working day.
|
||||
- **Multi-day recipes**: automated day division via day anchors (`~{-1d}`, `~{-2d}`).
|
||||
- **Real-time calendar projection**: dynamically fitting tasks into your kitchen availability and serving target.
|
||||
|
||||
### What ALAP means for the margin
|
||||
|
||||
Because planning operates strictly **as late as possible**, a kitchen visit can only be moved **earlier**, never later: delaying it would inevitably push back serving time. The anticipation margin shown in the run sheet ("Possible from 18:00") indicates how far a visit can be shifted forward as long as adjacent passive rests remain within their declared ranges. A recipe with elastic rest ranges yields anticipation margins, whereas one with fixed passive waits offers none. See [the scheduling engine](/docs/explanation/engine/scheduler/#from-the-schedule-to-the-run-sheet).
|
||||
To explore these capabilities and see how they form the <Term id="runSheet" />, see the dedicated deep dive [Planning and run sheets](/docs/explanation/planning/).
|
||||
|
||||
## Related resources
|
||||
|
||||
<CardGrid>
|
||||
<LinkCard
|
||||
title="Planning in real time"
|
||||
description="See how ALAP schedules translate onto actual calendar hours and user availability."
|
||||
href="/docs/explanation/planning-in-real-time/"
|
||||
title="Planning and run sheets"
|
||||
description="Mise en place strategies, multi-day recipes, calendar projection, and run sheet generation."
|
||||
href="/docs/explanation/planning/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Mise en place and planning"
|
||||
description="Understand how preparation work interacts with temporal planning and section day anchors."
|
||||
href="/docs/explanation/mise-en-place-and-planning/"
|
||||
title="Plan a meal"
|
||||
description="Step-by-step practical guide: CLI commands, Markdown export, and calendar synchronization (.ics)."
|
||||
href="/docs/how-to/plan-a-meal/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Times and durations syntax"
|
||||
|
|
@ -240,8 +155,8 @@ Because planning operates strictly **as late as possible**, a kitchen visit can
|
|||
href="/docs/reference/syntax/times/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Scheduler API reference"
|
||||
description="Complete documentation for layout(), project(), and the scheduler engine."
|
||||
href="/docs/reference/api/scheduler/"
|
||||
title="The scheduling engine"
|
||||
description="Architecture of the @gram-lang/scheduler package, task graph, and pure functions."
|
||||
href="/docs/explanation/engine/scheduler/"
|
||||
/>
|
||||
</CardGrid>
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ Compiling a Gram recipe flows through a deterministic, one-way pipeline:
|
|||
|
||||
`@gram-lang/scheduler` sits beneath the Kitchen: Kitchen depends on it, never the reverse. The scheduler operates without knowledge of the AST or `.gram` syntax, processing only an agnostic task graph. It fulfills two primary roles:
|
||||
- **`layout()`** arranges the task graph along a relative timeline, tailored to chosen mise en place placement and passive duration elasticity.
|
||||
- **`project()`** projects this schedule onto the real calendar given a target serving time, time zone, and availability windows. Next, `runSheet()` groups it into days, active kitchen visits, and passive threads: the core data powering the <Term id="runSheet" />. The scheduling engine's responsibility ends here: the run sheet, playground, and editor extensions are downstream **views** that consume this data (principally via `@gram-lang/renderer`). See [Planning in real time](/docs/explanation/planning-in-real-time/) and [The scheduling engine](/docs/explanation/engine/scheduler/).
|
||||
- **`project()`** projects this schedule onto the real calendar given a target serving time, time zone, and availability windows. Next, `runSheet()` groups it into days, active kitchen visits, and passive threads: the core data powering the <Term id="runSheet" />. The scheduling engine's responsibility ends here: the run sheet, playground, and editor extensions are downstream **views** that consume this data (principally via `@gram-lang/renderer`). See [Planning and run sheets](/docs/explanation/planning/) and [The scheduling engine](/docs/explanation/engine/scheduler/).
|
||||
|
||||
### Cross-cutting infrastructure (`@gram-lang/i18n` and `@gram-lang/format`)
|
||||
- **`@gram-lang/i18n`**: Serves as the single source of truth for language normalization dictionaries, unit conversion tables (`UNIT_CONVERSIONS`), duration multipliers (`TIME_TO_MINUTES`), and category keys (`CATEGORY_KEYS`).
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ This renderer serves as a reference implementation without prescribing a single
|
|||
|
||||
Standard recipe views (`toHTML`, `toMarkdown`, `toPrintHTML`) focus exclusively on culinary execution (the *how*) without exposing the timeline. With the `runSheet` option enabled, they append the run sheet right after the recipe in a single unified document. See [Build a custom UI](/docs/how-to/build-custom-ui/) to render a custom planning view directly from the underlying data.
|
||||
|
||||
The `miseEnPlace` option (`"perSection"` by default, `"upfront"`, or `"perDay"`) and the `rests` option (`"shortest"` by default, `"balanced"`, `"longest"`) choose the timeline whose total and idle durations the document headers show (see [Scheduling the mise en place](/docs/explanation/alap-scheduling#scheduling-the-mise-en-place)).
|
||||
The `miseEnPlace` option (`"perSection"` by default, `"upfront"`, or `"perDay"`) and the `rests` option (`"shortest"` by default, `"balanced"`, `"longest"`) choose the timeline whose total and idle durations the document headers show (see [The three mise en place strategies](/docs/explanation/planning/#the-three-mise-en-place-strategies)).
|
||||
|
||||
:::note[Gantt chart deprecation]
|
||||
The `toGanttHTML` and `attachGanttInteractivity` functions are deprecated since version 1.4.0 and will be removed in 2.0.0: no Gram surface renders a Gantt chart any more. See [Deprecations](/docs/how-to/deprecations/).
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ Waits written as a range follow the strategy specified via `rests` (`"shortest"`
|
|||
|
||||
- Any active work stretch falling into unavailable hours is shifted by lengthening or shortening the nearest flexible wait (written as a range) downstream.
|
||||
- The entire timeline is re-laid out on each adjustment to verify dependencies and track availability against the concrete result.
|
||||
- For an end-to-end explanation, see [Planning in real time](/docs/explanation/planning-in-real-time/).
|
||||
- For a step-by-step walkthrough, see [Planning and run sheets](/docs/explanation/planning/).
|
||||
|
||||
Internal time is counted in continuous absolute minutes since the POSIX epoch. Local time display relies on `Intl.DateTimeFormat` with an explicit time zone. No third-party date library or implicit system clock is involved: the plan remains byte-for-byte identical regardless of host environment, and a 23-hour or 25-hour daylight saving transition day counts for its actual duration.
|
||||
|
||||
|
|
@ -85,20 +85,18 @@ The engine produces **pure structural data**; the run sheet is one way to displa
|
|||
|
||||
Every metric is calculated by the engine as relative minutes from serving time, whether in an abstract schedule or a concrete timestamped calendar.
|
||||
|
||||
A visit's anticipation margin is guaranteed safe by construction:
|
||||
- Planning is computed as late as possible (ALAP), meaning a visit can only ever be shifted earlier;
|
||||
- Shifting it earlier shortens the preceding passive rest and lengthens the succeeding one;
|
||||
- Both bounds are strictly checked against their declared ranges and the nominal scheduled time of neighboring visits.
|
||||
The anticipation margin quantifies how far a visit can be shifted earlier without disrupting the rest of the recipe:
|
||||
- Because scheduling works as late as possible (ALAP), a visit can only ever be moved earlier, never delayed without pushing back serving time;
|
||||
- Moving it earlier shortens the preceding passive wait and extends the succeeding one, within their declared ranges;
|
||||
- If an actual delay occurs during cooking, the engine does not retroactively rewrite past events: simply run a fresh projection with an updated target time.
|
||||
|
||||
Advancing one or several visits never invalidates the margin of another visit. The calculated margin is occasionally conservative, but mathematically always safe. Conversely, an actual execution delay (starting a visit after its scheduled time) invalidates the downstream schedule: because the engine does not automatically recalculate schedules in the background, you must run projection again with an updated serving target or starting time.
|
||||
|
||||
How these details are presented, and with what editorial tone, is entirely up to the viewing layer. Gram's default [run sheet](/docs/how-to/plan-a-meal/) splits a day whenever a passive rest reaches one hour, displays margins starting at 15 minutes (`WINDOW_MIN_MINUTES`), and reads equipment ("To take out") and tasks ("To do") directly from the compiled recipe. Custom applications are free to adopt different visual conventions using the exact same underlying data (see [Build a custom UI](/docs/how-to/build-custom-ui/)).
|
||||
How these details are presented is up to the viewing layer. Gram's default [run sheet](/docs/how-to/plan-a-meal/) splits a day whenever a passive rest reaches one hour, displays margins starting at 15 minutes, and extracts ingredients and equipment from the compiled recipe. Custom applications are free to adopt different visual conventions using the exact same underlying data (see [Build a custom UI](/docs/how-to/build-custom-ui/)).
|
||||
|
||||
### What the engine does not support
|
||||
|
||||
- **One recipe at a time**: Planning a multi-recipe menu simultaneously with shared physical tracks is not yet supported (`MULTI_RECIPE_UNSUPPORTED`).
|
||||
- **One recipe at a time**: Planning a multi-recipe menu simultaneously with shared physical tracks is planned for a future release (`MULTI_RECIPE_UNSUPPORTED`).
|
||||
- **No background live replanning**: Because scheduling is a deterministic, pure function of its inputs, an actual delay requires invoking the engine again with updated parameters.
|
||||
- **No arbitrary schedule decisions**: The engine evaluates candidate serving times provided by the user (`findServeTimes()` targeting usual meal times, or `earliestServe()` starting right now), reporting which slots succeed and why others fail.
|
||||
- **No arbitrary decisions**: The engine evaluates candidate serving times provided by the user (`findServeTimes()` targeting usual meal times, or `earliestServe()` starting right now), reporting which slots succeed and why others fail.
|
||||
|
||||
## Two diagnostic families
|
||||
|
||||
|
|
@ -123,14 +121,9 @@ Downstream views (the default run sheet or custom UI components) sit **after** t
|
|||
|
||||
<CardGrid>
|
||||
<LinkCard
|
||||
title="Scheduler API reference"
|
||||
description="Function signatures, options, and TypeScript types for layout(), project(), runSheet() and the serving time search."
|
||||
href="/docs/reference/api/scheduler/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Planning in real time"
|
||||
description="How the scheduler projects tasks onto clock times and user availability windows."
|
||||
href="/docs/explanation/planning-in-real-time/"
|
||||
title="Planning and run sheets"
|
||||
description="Mise en place strategies, multi-day recipes, calendar projection, and run sheet generation."
|
||||
href="/docs/explanation/planning/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="ALAP scheduling"
|
||||
|
|
@ -138,8 +131,13 @@ Downstream views (the default run sheet or custom UI components) sit **after** t
|
|||
href="/docs/explanation/alap-scheduling/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Mise en place and planning"
|
||||
description="How preparation costs and multi-day recipes interact with temporal planning."
|
||||
href="/docs/explanation/mise-en-place-and-planning/"
|
||||
title="Plan a meal"
|
||||
description="Step-by-step practical guide: CLI commands, Markdown export, and calendar synchronization (.ics)."
|
||||
href="/docs/how-to/plan-a-meal/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Scheduler API reference"
|
||||
description="Function signatures, options, and TypeScript types for layout(), project(), and runSheet()."
|
||||
href="/docs/reference/api/scheduler/"
|
||||
/>
|
||||
</CardGrid>
|
||||
|
|
|
|||
|
|
@ -1,267 +0,0 @@
|
|||
---
|
||||
title: "Ingredients, mise en place and planning"
|
||||
description: "How Gram distinguishes what a recipe needs, the preparation work, and temporal scheduling, and the impact of each configuration."
|
||||
---
|
||||
|
||||
import Since from '../../../../components/Since.astro';
|
||||
import { LinkCard, CardGrid } from '@astrojs/starlight/components';
|
||||
import Term from '../../../../components/Term.astro';
|
||||
|
||||
<Since v="1.4.0" />
|
||||
|
||||
When reading a recipe, three distinct concepts are often conflated: **raw ingredient requirements**, **prior preparation work**, and **temporal scheduling**. Gram explicitly separates these three dimensions, with only the last being subject to user preference.
|
||||
|
||||
For a straightforward recipe, default settings handle scheduling automatically without extra configuration. The following sections are intended for those orchestrating multi-component recipes or preparations spanning several days.
|
||||
|
||||
## Three concepts, one choice
|
||||
|
||||
| | Definition | Affected by scheduling choice? |
|
||||
|---|---|---|
|
||||
| **Ingredients** | Material requirements: section ingredient lists, consolidated shopping list | No |
|
||||
| **Mise en place** | Preparation work: fetching, weighing, washing, peeling, chopping. Each section reports its own preparation cost (`miseEnPlace`) | No |
|
||||
| **Planning** | Temporal scheduling: relative timeline, total duration, overall passive duration, and the <Term id="runSheet" /> | **Yes**, this is the only dimension modified |
|
||||
|
||||
A recipe never imposes its own schedule. It declares culinary facts (required ingredients and estimated preparation time); it is up to the **user** to decide how to organize this work along the timeline.
|
||||
|
||||
A straightforward rule to remember: switching scheduling strategies never changes the ingredients, the shopping list, the preparation time, or the active work. It solely shifts work blocks across the timeline.
|
||||
|
||||
## The three mise en place strategies
|
||||
|
||||
Gram provides three strategies to schedule mise en place. Consider this recipe:
|
||||
|
||||
```gram
|
||||
## Dough ->&dough
|
||||
|
||||
[Mix] Mix @flour{500g} and @water{300ml} in a #bowl.
|
||||
|
||||
[Rise] Let it rise ~_{30min}.
|
||||
|
||||
## Filling ->&filling
|
||||
|
||||
[Slice] Slice @onions{200g}(finely sliced).
|
||||
|
||||
## Assembly
|
||||
|
||||
[Combine] Combine &dough and the &filling, then bake ~{25min}.
|
||||
```
|
||||
|
||||
Gram automatically calculates preparation time for each section based on ingredients to weigh or chop and cookware required (here: 3 min for dough, 3 min for filling, 2 min for assembly, totaling 8 min). Cumulative active cooking work is 29 minutes across all scheduling choices.
|
||||
|
||||
### By section (default)
|
||||
|
||||
This mode schedules each section's preparation as close as possible to its execution. Whenever a passive duration occurs (fermentation, oven baking, cooling), Gram inserts the preparation of subsequent steps.
|
||||
|
||||
In culinary and manufacturing operations, this is known as working in **masked time**: active work performed *during* a passive wait adds zero extra minutes to the recipe's total duration.
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title By section — Masked time execution (1 h 00)
|
||||
dateFormat HH:mm
|
||||
axisFormat %H:%M
|
||||
todayMarker off
|
||||
section Dough
|
||||
Mise en place : p1, 00:00, 3m
|
||||
Mix : active, a1, 00:03, 2m
|
||||
Rise (passive) : r1, 00:05, 30m
|
||||
section Filling
|
||||
Mise en place : p2, 00:28, 3m
|
||||
Slice : active, a2, 00:31, 2m
|
||||
section Assembly
|
||||
Mise en place : p3, 00:33, 2m
|
||||
Combine and bake : active, a3, 00:35, 25m
|
||||
```
|
||||
|
||||
- Dough is prepared at 00:00, then rises for 30 minutes (from 00:05 to 00:35).
|
||||
- Filling and assembly preparations occur in masked time toward the end of the rise (starting at 00:28): chopped onions stay fresh rather than lingering on the counter.
|
||||
- Overall total duration is optimized to **1 h 00** (60 min).
|
||||
|
||||
### All at the start
|
||||
|
||||
This mode groups all ingredient weighing and chopping before beginning the first step:
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title All at the start — Upfront preparation (1 h 03)
|
||||
dateFormat HH:mm
|
||||
axisFormat %H:%M
|
||||
todayMarker off
|
||||
section Mise en place
|
||||
Dough : p1, 00:00, 3m
|
||||
Filling : p2, 00:03, 3m
|
||||
section Dough
|
||||
Mix : active, a1, 00:06, 2m
|
||||
Rise (passive) : r1, 00:08, 30m
|
||||
section Filling
|
||||
Slice : active, a2, 00:34, 2m
|
||||
section Assembly
|
||||
Retrieve intermediates : p3, 00:36, 2m
|
||||
Combine and bake : active, a3, 00:38, 25m
|
||||
```
|
||||
|
||||
- Dough and filling ingredients are prepared upfront starting at 00:00 (until 00:06).
|
||||
- Total duration increases to **1 h 03** (63 min), as filling prep is no longer absorbed in masked time during the rise.
|
||||
|
||||
### By working day
|
||||
|
||||
This mode consolidates preparation by working day. When a recipe fits within a single day (with no past day anchors like `~{-1d}`), this mode yields results identical to "All at the start". Its primary purpose is structuring multi-day production schedules (see below). A working day is not a single visit to the kitchen: if a day holds a morning visit and an evening one, its mise en place is still gathered once, before the first visit. To take things out right before each visit instead, use "By section".
|
||||
|
||||
No single mode is universally superior: the first optimizes total duration and ingredient freshness; the second suits cooks who prefer gathering all ingredients beforehand; the third organizes complex multi-day workflows.
|
||||
|
||||
:::note[Special case: intermediates are never prepared before they exist]
|
||||
An intermediate ingredient (`&dough`) is produced during recipe execution: it cannot be retrieved or measured before its producing section completes. This rule applies across all scheduling modes:
|
||||
|
||||
- **Accounting**: an intermediate is counted in the mise en place of the section that **consumes** it, not the one that produces it.
|
||||
- **In "All at the start" mode**: raw ingredients are gathered upfront, but the intermediate is retrieved only when downstream steps require it (in our example, `&dough` is retrieved after rising, right before assembly).
|
||||
:::
|
||||
|
||||
## Elastic passive durations written as ranges
|
||||
|
||||
A passive duration can be fixed (`~_{12h}`) or specified as a range (`~_{12-24h}`: ready after 12 hours, viable up to 24 hours). A fixed passive duration never shifts. In contrast, a range introduces temporal elasticity, and you decide how to interpret it via the `rests` option, just as you choose mise en place placement:
|
||||
|
||||
- **`shortest`** (default): selects the range's minimum duration;
|
||||
- **`balanced`**: selects the median duration;
|
||||
- **`longest`**: selects the maximum duration.
|
||||
|
||||
This selection affects total duration, idle passive time, and the run sheet, while leaving active cooking work unchanged. Conversely, an active timer specified as a range (`~{40-50min}`) reflects cooking uncertainty rather than elasticity: it is always scheduled using its maximum duration to ensure service is never delayed.
|
||||
|
||||
When a target serving time and cooking availability are provided, Gram utilizes this elasticity to shift active work away from overnight hours: see [Planning in real time](/docs/explanation/planning-in-real-time/).
|
||||
|
||||
## Scheduling configuration
|
||||
|
||||
A cornerstone of Gram's architecture is that **a recipe contains no syntax to dictate its schedule**. It describes purely culinary facts (ingredients, cookware, actions, and durations).
|
||||
|
||||
During compilation, Kitchen preserves data neutrality. The compiled recipe output carries raw facts (`miseEnPlace`, and `tasks`: the neutral dependency graph) alongside a single default schedule in `schedule` (mise en place by section, shortest passive durations):
|
||||
|
||||
```json
|
||||
{
|
||||
"miseEnPlace": { /* raw facts: estimated durations per section */ },
|
||||
"tasks": { /* neutral task graph */ },
|
||||
"schedule": { /* default schedule laid out from tasks */ }
|
||||
}
|
||||
```
|
||||
|
||||
Any alternative configuration (upfront, per-day, longest passive durations...) is computed on demand from `tasks` using the pure `layout()` function of `@gram-lang/scheduler`, **without recompiling**. The scheduling choice occurs **at rendering, export, or display time**:
|
||||
|
||||
| Tool | Mise en place placement | Passive duration selection |
|
||||
|---|---|---|
|
||||
| **CLI** (`gram view`, `export`, `print`, `plan`) | `--mise-en-place <per-section\|upfront\|per-day>` | `--rests <shortest\|balanced\|longest>` |
|
||||
| **VS Code** | `gram.miseEnPlace` setting | `gram.rests` setting |
|
||||
| **Playground** | "Mise en place" selector | "Rests" selector |
|
||||
| **Renderer** (`@gram-lang/renderer`) | `miseEnPlace: "perSection" \| "upfront" \| "perDay"` | `rests` option |
|
||||
|
||||
For application developers building custom interfaces, this separation eliminates the need to reimplement scheduling logic: read `schedule` for default planning, or invoke `layout()` for customized projections (see the [kitchen API reference](/docs/reference/api/kitchen/) and the [scheduler API reference](/docs/reference/api/scheduler/)).
|
||||
|
||||
## Recipes over several days
|
||||
|
||||
Lengthy recipes (**sourdough bread**, **marinated meats**, **croissants**, or **gravlax**) naturally break down into working days: each day, one prepares only what that specific day requires. The **by working day** strategy (`per-day`) generates a daily production roadmap based on the retro-planning day anchors (`~{-1d}`, `~{-2d}`) declared in the recipe.
|
||||
|
||||
```gram
|
||||
---
|
||||
title: Filled tart
|
||||
---
|
||||
|
||||
## Cream ~{-3d} ->&cream
|
||||
|
||||
[Whisk] Whisk @milk{500ml} and @eggs{4}.
|
||||
|
||||
[Chill] Let it set at ^{4C} for ~_{24h}.
|
||||
|
||||
## Crust ->&crust
|
||||
|
||||
[Work] Work &cream{150g} with @flour{300g} and @butter{150g}.
|
||||
|
||||
## Tart ~{-1d}
|
||||
|
||||
[Fill] Fill with &crust{400g}.
|
||||
|
||||
[Bake] Bake for ~{30min}.
|
||||
|
||||
## Serve
|
||||
|
||||
[Dust] Dust with @sugar{10g}.
|
||||
```
|
||||
|
||||
### Working day segmentation
|
||||
|
||||
To structure a recipe into working days, the scheduling engine relies exclusively on section anchors specified **in days** (`~{-1d}`, `~{-2d}`, `~{-3d}`):
|
||||
|
||||
- **`~{-Nd}` (days) = a distinct working day.** This conveys explicit human intent (*"prepare the day before (D-1)"*, *"two days prior (D-2)"*). Gram then groups the mise en place of those sections into a dedicated working day.
|
||||
- **`~{-Nh}` (hours) = a relative deadline within a day.** An anchor such as `~{-2h}` or `~{-36h}` indicates that a step must complete 2 hours (or 36 hours) before serving, but **never** initiates a new working day on its own. Because a `.gram` recipe has no knowledge of actual meal timing, converting hours into calendar days would introduce meal-dependent ambiguity (`~{-12h}` lands in the morning for an 8 p.m. dinner, but at midnight the day before for a noon lunch).
|
||||
|
||||
An unanchored section attaches to the day anchor **that follows it** (the furthest one among the sections after it), or to Day D when there is none. This is the opposite of the reading direction, on purpose: the engine reasons backward from serving, and an anchor means "this section, and everything before it that has no anchor, is done by that day at the latest".
|
||||
|
||||
:::caution[An anchor does not apply to the sections after it]
|
||||
In the example, the **crust** has no anchor and is written right after the cream `~{-3d}`, but it is **not** made on D-3. It attaches to the tart `~{-1d}`, which comes after it: it is made on D-1, right before the tart, because scheduling places every step as late as possible.
|
||||
:::
|
||||
|
||||
Here is the run sheet Gram produces for this recipe (`gram plan tart.gram`):
|
||||
|
||||
```text
|
||||
D-3 ▮ ~ 5min Cream
|
||||
┆ Cream : Chill 1d
|
||||
D-1 ▮ ~ 40min Crust, Tart
|
||||
Day D ▮ ~ 5min Serve
|
||||
★ Serve
|
||||
```
|
||||
|
||||
To make the crust on a day of its own, between the cream and the tart, anchor it explicitly: `## Crust ~{-2d} ->&crust` gives a visit on D-2.
|
||||
|
||||
```text
|
||||
D-3 ▮ ~ 5min Cream
|
||||
┆ Cream : Chill 1d
|
||||
D-2 ▮ ~ 5min Crust
|
||||
D-1 ▮ ~ 35min Tart
|
||||
Day D ▮ ~ 5min Serve
|
||||
★ Serve
|
||||
```
|
||||
|
||||
Anchoring the crust at `~{-3d}`, like the cream, makes no sense here: it uses the cream, which rests for 24 hours. Gram accepts it but reports a timeline conflict ("the working day starts before its 24 h window opens").
|
||||
|
||||
:::caution[Common pitfalls]
|
||||
Two frequent patterns do **not** initiate a new working day:
|
||||
|
||||
1. **A long passive timer without section anchor**: a step with `~_{48h}` pushes the step two days backward on the timeline, but does not create a D-2 working day without an explicit section day anchor (`## Cream ~{-2d}`).
|
||||
2. **An anchor in hours**: a value like `~{-18h}` or `~{-36h}` remains a deadline within that section's assigned day. To open a genuine working day the previous day, use `~{-1d}` explicitly.
|
||||
:::
|
||||
|
||||
In the example above:
|
||||
- **Cream** is prepared on **D-3**;
|
||||
- **Crust** and **tart** are executed on **D-1** (the crust attaches to the tart, which follows it);
|
||||
- **Serving** occurs on **Day D**.
|
||||
|
||||
Each working day is designed to fit within the 24 hours preceding the next. If an extensive passive duration forces active work outside this window, Gram emits a `DAY_OVERFLOW` diagnostic and recommends anchoring the section further back.
|
||||
|
||||
### Mise en place aggregation per working day
|
||||
|
||||
At the start of each working day, Gram consolidates the mise en place required for that day's steps:
|
||||
|
||||
- An intermediate **produced on an earlier day** (the cream, prepared on D-3) is retrieved at the start of the working day where it is consumed (on D-1).
|
||||
- An intermediate **produced on the same day** (the crust for the tart) is prepared immediately prior to assembly, as it does not yet exist at the start of the day.
|
||||
|
||||
Cumulative preparation time and active cooking work remain strictly identical across all scheduling strategies.
|
||||
|
||||
The recipe text does not directly materialize these step blocks: mise en place is accounted for as an overhead in the recipe's time badges and schedule calculation. The concrete list of items required and their exact moment of use correspond to the **"To take out"** list displayed at the start of each visit in the [run sheet](/docs/how-to/plan-a-meal/), computed for every strategy: by section, each section carries its own raw ingredients, right before its steps; per working day, they are listed together at the top of the visit with the quantities summed; upfront, they are all listed at the first visit. A preparation is always listed at the visit of the first step that uses it.
|
||||
|
||||
:::tip[Chaining sections]
|
||||
When several sections follow each other on the same day, anchor only the final one (`## Tart ~{-1d}`) and leave upstream sections unanchored (like the crust above): they automatically inherit its day and sequence immediately before it. Assigning `~{-1d}` to each creates concurrent deadlines at the exact same moment, causing a time paradox warning when dependencies exist between them.
|
||||
:::
|
||||
|
||||
## Related resources
|
||||
|
||||
<CardGrid>
|
||||
<LinkCard
|
||||
title="Times and durations syntax"
|
||||
description="Learn how to declare active durations, passive rests, and section day anchors."
|
||||
href="/docs/reference/syntax/times/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="ALAP scheduling"
|
||||
description="How the compiler calculates backwards timeline alignment and named track contention."
|
||||
href="/docs/explanation/alap-scheduling/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Planning in real time"
|
||||
description="Project recipe timelines onto actual clock times and availability windows."
|
||||
href="/docs/explanation/planning-in-real-time/"
|
||||
/>
|
||||
</CardGrid>
|
||||
|
|
@ -1,157 +0,0 @@
|
|||
---
|
||||
title: "Planning in real time"
|
||||
description: "How Gram puts a recipe on the calendar: a serving time, a time zone and your availability turn a timeline into dated visits to the kitchen, with waits stretched or shortened to keep your work out of the night."
|
||||
---
|
||||
|
||||
import Since from '../../../../components/Since.astro';
|
||||
import { Steps, LinkCard, CardGrid } from '@astrojs/starlight/components';
|
||||
import Term from '../../../../components/Term.astro';
|
||||
|
||||
<Since v="1.4.0" />
|
||||
|
||||
A recipe describes its own timing: tasks, how long they last, and what dependencies they wait for. That is enough to calculate an overall metric—such as "this recipe takes 17 hours, 50 minutes of it in active work". It is not enough to say **when to start**. For that, Gram needs three inputs that only you know: when you serve, in which time zone, and when you can actually cook.
|
||||
|
||||
Provide those three parameters, and Gram positions each task along a backward calendar schedule from the serving time, organizing work days, active kitchen visits, and background resting intervals. The <Term id="runSheet" /> provides the operational presentation of this data.
|
||||
|
||||
## Inputs
|
||||
|
||||
| Parameter | Example | Description |
|
||||
|---|---|---|
|
||||
| **Serving time** | `2026-10-11 13:00` | Target local date and time, expressed in the time zone below |
|
||||
| **Time zone** | `Europe/Paris` | An IANA zone: determines clock readings and daylight saving adjustments. The CLI resolves it in order: `--tz`, the project (or global) `timezone` setting, then the host machine's time zone |
|
||||
| **Availability** | `08:00-22:00`, `fri=18:00-22:00`, `2026-10-09=none` | When you can work: a default daily range, plus exceptions by day of the week or by calendar date. The CLI resolves it in order: `--available`, the project (or global) `availability` setting, then all day |
|
||||
|
||||
Availability is structured as an object: a default daily range (`daily`), exceptions by day of the week (`weekdays`), and exceptions by calendar date (`dates`). A date exception always overrides a weekday rule, which in turn overrides the default daily range. An empty list indicates complete unavailability on that day. A range that ends before it starts spans across midnight continuously (e.g. `22:00-02:00`).
|
||||
|
||||
:::note[Absolute determinism]
|
||||
Gram never queries the system clock to compute a schedule. With the same recipe, serving time, time zone, and availability, the resulting plan is byte-for-byte identical across all environments.
|
||||
:::
|
||||
|
||||
## How the plan is made
|
||||
|
||||
The recipe's theoretical timeline (see [Mise en place and planning](/docs/explanation/mise-en-place-and-planning/)) is first anchored so that it completes at the serving time. Gram then examines the constraints of **your hands-on work** (active tasks and mise en place):
|
||||
|
||||
<Steps>
|
||||
1. **Grouping uninterrupted stretches**
|
||||
Tasks that cannot be interrupted are grouped into a continuous block. For example, a preparation followed immediately by the step it prepares, with no wait between them, forms a single indivisible block: Gram cannot assume you can pause a kneading step halfway through to go to sleep.
|
||||
|
||||
2. **Validating compatible stretches**
|
||||
Any continuous stretch that fits entirely within your availability windows remains unchanged.
|
||||
|
||||
3. **Adjusting conflicting stretches**
|
||||
Any stretch that overlaps with an unavailable period is shifted by adjusting the **nearest flexible wait (defined with a range) downstream**:
|
||||
- **lengthening** the wait moves preceding work earlier (e.g. to the evening before);
|
||||
- **shortening** the wait shifts preceding work later (e.g. to the next morning).
|
||||
|
||||
Gram favors the direction preferred by your wait strategy (shortest duration by default, hence shortening first), and selects the smaller shift when both are equal. It never exceeds the bounds of the range and never alters a fixed-duration wait.
|
||||
|
||||
4. **Propagation and traceability**
|
||||
Each adjustment cascades to all tasks scheduled before that wait. The plan explicitly logs every change: which wait was adjusted, the initial and updated duration, and the reason for the change.
|
||||
</Steps>
|
||||
|
||||
A wait assigned to a named track (`~_oven{40min}`) is only stretched if that track remains unoccupied throughout the extended duration. The scheduler recomputes the entire timeline on every adjustment: dependencies and track allocations are verified on the concrete layout rather than guessed.
|
||||
|
||||
### Concrete example
|
||||
|
||||
```gram
|
||||
## Dough ->&dough
|
||||
|
||||
[Knead] Knead @flour{500g} with @water{350ml}, ~{20min}.
|
||||
|
||||
[Rise] Let it rise ~_{8-16h}.
|
||||
|
||||
## Bake
|
||||
|
||||
[Bake] Shape &dough{850g} and bake for ~{30min}.
|
||||
```
|
||||
|
||||
Served on Sunday at 13:00, with `08:00-22:00` daily availability, an 8-hour rise would place the kneading at 04:10. Gram automatically stretches the rise to 14 h 30 so that the kneading finishes at 22:00 on Saturday evening:
|
||||
|
||||
```text
|
||||
To fix
|
||||
! The work of Day D falls on Saturday, October 10 instead of Sunday, October 11.
|
||||
|
||||
SAT 10 ▮ 21:40 – 22:00 Dough
|
||||
┆ Dough : Rise 14h 30min (8h to 16h)
|
||||
SUN 11 ▮ 12:30 – 13:00 Bake
|
||||
★ 13:00 Serve
|
||||
|
||||
SATURDAY, OCTOBER 10 21:40 → 22:00
|
||||
! Dough : Rise extended to 14h 30min (planned 8h to 16h) so the work falls within your availability.
|
||||
Possible from 20:10.
|
||||
```
|
||||
|
||||
The "To fix" message at the top is expected here. The recipe has no day anchor: all its work is assumed to fall on Day D, the Sunday. But the kneading had to move to Saturday evening, and Gram says so (`DAY_MISMATCH`). The plan is still valid; it is information.
|
||||
|
||||
Do not silence it by anchoring the section (`## Dough ~{-1d}`): a day anchor fixes the section's day, and Gram then no longer stretches the rise to fit your availability. If the rise should adapt to your hours, leave the recipe without an anchor.
|
||||
|
||||
If the rise were exact (`~_{8h}`), or if the range was too narrow to absorb the offset (`~_{8-10h}`), no adjustment could be made: the scheduler leaves the kneading at 04:10 and logs the diagnostic.
|
||||
|
||||
## Diagnostics and unresolved constraints
|
||||
|
||||
Gram never conceals a scheduling conflict it cannot resolve. Any remaining issue is reported alongside the plan:
|
||||
|
||||
| Diagnostic | Meaning | Recommended action |
|
||||
|---|---|---|
|
||||
| `ACTIVE_OUTSIDE_AVAILABILITY` | Active hands-on work falls during unavailable hours, and no wait can move it (fixed wait, insufficient range, or no wait downstream). | Widen your availability windows or provide a flexible wait range. |
|
||||
| `ACTIVE_BLOCK_EXCEEDS_AVAILABILITY` | An uninterrupted block of hands-on work is longer than your longest continuous availability window. | Widen your availability window (no wait adjustment can split this block). |
|
||||
| `DAY_MISMATCH` | A working day falls on a different calendar day than intended (work tagged with `~{-1d}` landing two days prior). | Anchor the section explicitly or adjust intermediate waits. |
|
||||
| `START_IN_PAST` | The first task should have started before the current planning time. | Set a later serving time or shorten waits. |
|
||||
| `MULTI_RECIPE_UNSUPPORTED` | Multiple recipes were supplied; only the first was planned. | Plan recipes individually. |
|
||||
|
||||
:::note[Planning diagnostics vs Compiler warnings]
|
||||
These diagnostics are specific to calendar projection: they depend directly on **your** availability constraints rather than recipe defects. Compiler warnings inherent to the recipe code itself (such as `DAY_OVERFLOW`, when an excessive wait pushes a working day out of its 24-hour day) are documented in [Times and durations](/docs/reference/syntax/times/#error-handling).
|
||||
:::
|
||||
|
||||
## Time zones and daylight saving
|
||||
|
||||
Calculations take place in absolute minutes along a continuous timeline; conversion to local wall-clock time occurs only during final output rendering. A 24-hour wait (a dough in the fridge, say) spanning the autumn daylight saving transition lasts 24 true hours: if it begins at 13:30 on the clock the day before, it ends at 12:30 local time. Non-existent local times (e.g. 02:30 during the spring forward transition) are shifted to the next valid time; repeated times in autumn resolve to the first occurrence.
|
||||
|
||||
## The run sheet
|
||||
|
||||
Calendar projection produces a comprehensive data model: exact timestamps for each block, adjusted passive rests, non-working intervals, and diagnostics for unresolved constraints. The [`runSheet()`](/docs/explanation/engine/scheduler/#from-the-schedule-to-the-run-sheet) function organizes this data into work days, **active kitchen visits**, and **background resting threads** (proofing, chilling, resting), while calculating the scheduling margin available for each intervention.
|
||||
|
||||
The **run sheet** is the operational view built on top of this model. For each day, it outlines required kitchen presence, equipment and ingredients to take out, actionable steps to execute alongside recipe sections, and unattended processes that continue in the background. To reflect culinary practice, displayed times are rounded to the nearest five minutes (while internal engine calculations remain accurate to the minute). Rest adjustments are highlighted at the top of the relevant day, and unresolved constraints are grouped at the top of the document. These presentation rules (grouping tasks into a single visit across rests under one hour, displaying margins starting at 15 minutes) belong to the rendering layer rather than rigid engine constraints.
|
||||
|
||||
The plan can be generated as plain text, Markdown, standalone HTML, a print-ready document (one day per page with check boxes), or exported to an iCalendar file (`.ics`). With `--view run-sheet`, `gram print` and `gram export` render the run sheet instead of the recipe. While the recipe describes **how** to cook, the run sheet specifies **when** to take action.
|
||||
|
||||
Without a target serving time, this same data is displayed as a relative countdown (`D-2`, `D-1`, `Day D`) with estimated durations per day (e.g. "about 55 min") and the earliest achievable serving time. Scheduling margins and rest adjustments are calculated only when real calendar availability is provided.
|
||||
|
||||
See [Plan a meal](/docs/how-to/plan-a-meal/) for an end-to-end practical guide.
|
||||
|
||||
## Available integrations
|
||||
|
||||
| Tool | Usage |
|
||||
|---|---|
|
||||
| CLI | `gram plan recipe.gram --serve "2026-10-11 13:00" --available 08:00-22:00` (optional `--tz` if set in config); `--find` to look for a serving time |
|
||||
| Playground | The "Run sheet" view and the "Plan" panel, with "When to serve?" |
|
||||
| VS Code | `Gram: Run Sheet`, in days before the service, or on the calendar with the **Served at** field and its "When to serve?" suggestions |
|
||||
| `@gram-lang/scheduler` | `project()`, `runSheet()`, `findServeTimes()` and `earliestServe()` (see the [scheduler API reference](/docs/reference/api/scheduler/)) |
|
||||
| `@gram-lang/renderer` | `runSheetToText`, `runSheetToMarkdown`, `runSheetToHTML`, `runSheetToPrintHTML`, and associated modular helpers (`visitKit`, `sectionProgram`, `sectionSteps`) |
|
||||
|
||||
## Current limitations
|
||||
|
||||
- **Single recipe scheduling**: planning a complete menu (synchronizing starter, main, and dessert for the same service while sharing a single cook and oven) will be supported in a future release; the API already accepts a list of recipes, and reports `MULTI_RECIPE_UNSUPPORTED` for more than one.
|
||||
- **No live state tracking**: the schedule is purely deterministic and maintains no persistent live runtime state. If a visit is delayed, simply run `gram plan` again to recalculate viable slots from the new time.
|
||||
- **Shared resources**: equipment (oven preheating time, refrigerator space) does not yet act as globally pooled resources beyond explicit named tracks.
|
||||
- **Heuristic approach**: the scheduling algorithm is greedy and deterministic (designed to be explainable and predictable rather than optimal in a mathematical programming sense): it resolves conflicts starting from the latest event and works backward in time.
|
||||
|
||||
## Related resources
|
||||
|
||||
<CardGrid>
|
||||
<LinkCard
|
||||
title="Plan a meal"
|
||||
description="Step-by-step practical guide to the run sheet, the serving time search and the calendar."
|
||||
href="/docs/how-to/plan-a-meal/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Ingredients, mise en place and planning"
|
||||
description="How the compiler infers task dependencies, durations, and preparation costs."
|
||||
href="/docs/explanation/mise-en-place-and-planning/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Scheduler API reference"
|
||||
description="Complete documentation for project(), layout(), runSheet(), and calendar options."
|
||||
href="/docs/reference/api/scheduler/"
|
||||
/>
|
||||
</CardGrid>
|
||||
298
packages/docs/src/content/docs/docs/explanation/planning.mdx
Normal file
298
packages/docs/src/content/docs/docs/explanation/planning.mdx
Normal file
|
|
@ -0,0 +1,298 @@
|
|||
---
|
||||
title: "Planning and run sheets"
|
||||
description: "How Gram turns recipe facts into an organized schedule: mise en place modes, multi-day structure, real-time calendar projection, and run sheet generation."
|
||||
---
|
||||
|
||||
import Since from '../../../../components/Since.astro';
|
||||
import { Steps, LinkCard, CardGrid } from '@astrojs/starlight/components';
|
||||
import Term from '../../../../components/Term.astro';
|
||||
|
||||
<Since v="1.4.0" />
|
||||
|
||||
A recipe describes **what it requires** and **how each step is carried out**: ingredients, cookware, active steps, and timings. However, it does not dictate how you organize your time in the kitchen.
|
||||
|
||||
Switching planning strategies never changes the required ingredients, the shopping list, estimated preparation times, or actual active cooking work. It solely rearranges the timeline of tasks to match your schedule and availability.
|
||||
|
||||
## Three concepts, one choice
|
||||
|
||||
To understand how Gram handles time, consider three distinct dimensions:
|
||||
|
||||
| Concept | Role | Changed by planning choices? |
|
||||
|---|---|---|
|
||||
| **Ingredients** | The raw materials required by each section and the consolidated shopping list. | No |
|
||||
| **Mise en place** | Upfront preparation work: measuring, washing, peeling, chopping. Each section reports its estimated cost (`miseEnPlace`). | No |
|
||||
| **Planning** | The chronological layout of tasks: relative timeline, total duration, and the <Term id="runSheet" />. | **Yes**, this is the only dimension modified. |
|
||||
|
||||
Gram automatically derives these aspects directly from your recipe markup. No manual calculations are needed.
|
||||
|
||||
## The three mise en place strategies
|
||||
|
||||
Consider a simple recipe with dough and filling:
|
||||
|
||||
```gram
|
||||
## Dough ->&dough
|
||||
|
||||
[Mix] Mix @flour{500g} and @water{300ml} in a #bowl.
|
||||
|
||||
[Rise] Let it rest ~_{30min}.
|
||||
|
||||
## Filling ->&filling
|
||||
|
||||
[Slice] Slice @onions{200g}(finely sliced).
|
||||
|
||||
## Assembly
|
||||
|
||||
[Combine] Combine &dough and the &filling, then bake ~{25min}.
|
||||
```
|
||||
|
||||
Gram calculates preparation time for each section based on ingredients and cookware (here: 3 min for dough, 3 min for filling, 2 min for assembly, totaling 8 min). Cumulative active cooking work remains 29 minutes in all cases.
|
||||
|
||||
Three options determine how preparation is scheduled:
|
||||
|
||||
### 1. By section (`perSection`, default)
|
||||
|
||||
Preparation for each section is placed as close as possible to its execution. Whenever passive downtime occurs (proofing, resting, baking), Gram schedules subsequent prep during that window in **masked time**: active work performed *during* a passive timer adds zero extra minutes to overall duration.
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title By section — Masked time execution (1 h 00)
|
||||
dateFormat HH:mm
|
||||
axisFormat %H:%M
|
||||
todayMarker off
|
||||
section Dough
|
||||
Mise en place : p1, 00:00, 3m
|
||||
Mix : active, a1, 00:03, 2m
|
||||
Rest (passive) : r1, 00:05, 30m
|
||||
section Filling
|
||||
Mise en place : p2, 00:28, 3m
|
||||
Slice : active, a2, 00:31, 2m
|
||||
section Assembly
|
||||
Mise en place : p3, 00:33, 2m
|
||||
Combine and bake : active, a3, 00:35, 25m
|
||||
```
|
||||
|
||||
The dough rests for 30 minutes. Toward the end of this rest (from 00:28), filling and assembly prep happen just in time: prepped ingredients stay fresh without crowding counter space, and total time is minimized (**1 h 00**).
|
||||
|
||||
### 2. Upfront (`upfront`)
|
||||
|
||||
All measuring and chopping of raw ingredients takes place before starting any cooking steps:
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title Upfront — Grouped preparation (1 h 03)
|
||||
dateFormat HH:mm
|
||||
axisFormat %H:%M
|
||||
todayMarker off
|
||||
section Mise en place
|
||||
Dough : p1, 00:00, 3m
|
||||
Filling : p2, 00:03, 3m
|
||||
section Dough
|
||||
Mix : active, a1, 00:06, 2m
|
||||
Rest (passive) : r1, 00:08, 30m
|
||||
section Filling
|
||||
Slice : active, a2, 00:34, 2m
|
||||
section Assembly
|
||||
Retrieve preparations : p3, 00:36, 2m
|
||||
Combine and bake : active, a3, 00:38, 25m
|
||||
```
|
||||
|
||||
Dough and filling prep occur together at 00:00. Total duration increases to **1 h 03**, as filling preparation is no longer masked during dough fermentation. This mode suits cooks who prefer clearing their workstation before turning on the heat.
|
||||
|
||||
### 3. Per working day (`perDay`)
|
||||
|
||||
Preparation is consolidated at the start of each working day. For single-day recipes, this produces the exact same layout as upfront preparation. Its true power shines in multi-day recipes.
|
||||
|
||||
:::note[Handling intermediate preparations]
|
||||
An intermediate ingredient (`&dough`) does not exist at the start of a recipe: it cannot be prepared before being produced. Regardless of the chosen mode, fetching or measuring an intermediate is always attributed to the section that **consumes** it, scheduled right when that step begins.
|
||||
:::
|
||||
|
||||
## Configuring options across tools
|
||||
|
||||
Gram enforces a strict rule: a recipe contains no presentation flags or rigid scheduling directives. It only states culinary facts. Readers and cooks choose their preferred mise en place mode and resting strategy when viewing or rendering:
|
||||
|
||||
| Tool | Mise en place mode | Rest strategy |
|
||||
|---|---|---|
|
||||
| **CLI** (`gram view`, `plan`, `export`, `print`) | `--mise-en-place <per-section\|upfront\|per-day>` | `--rests <shortest\|balanced\|longest>` |
|
||||
| **VS Code** | Setting `gram.miseEnPlace` | Setting `gram.rests` |
|
||||
| **Playground** | "Mise en place" selector | "Rests" selector |
|
||||
| **Renderer** (`@gram-lang/renderer`) | Option `miseEnPlace` | Option `rests` |
|
||||
|
||||
In compiled JSON, `schedule` contains the default timeline (by section, shortest rests). Alternative schedules are calculated on the fly from `tasks` using `@gram-lang/scheduler`'s pure `layout()` function, without recompiling the recipe.
|
||||
|
||||
## Passive timers and elasticity
|
||||
|
||||
Passive durations can be fixed (`~_{12h}`) or specified as an **elastic range** (`~_{12-24h}`).
|
||||
|
||||
A range indicates an acceptable window: ready in 12 hours, preserving optimal quality up to 24 hours. This elasticity allows Gram to adjust schedules without compromising the recipe:
|
||||
|
||||
- **On theoretical timelines**, the `rests` option sets default behavior:
|
||||
- `shortest` (default): chooses the lower bound;
|
||||
- `balanced`: chooses the midpoint;
|
||||
- `longest`: chooses the upper bound.
|
||||
- **On real-calendar schedules**, this elasticity lets the engine extend or compress waiting periods so active cooking never falls in the middle of the night.
|
||||
|
||||
Active ranges (`~{40-50min}`) indicate cooking uncertainty rather than elasticity: they are always scheduled at their maximum nominal duration to guarantee you never serve late.
|
||||
|
||||
## Multi-day recipes and day anchors
|
||||
|
||||
Long recipes (sourdough bread, pastries, laminated dough, cured meats) naturally span multiple working days.
|
||||
|
||||
```gram
|
||||
---
|
||||
title: Layered tart
|
||||
---
|
||||
|
||||
## Custard ~{-3d} ->&custard
|
||||
|
||||
[Whisk] @milk{500ml} and @eggs{4}.
|
||||
|
||||
[Chill] Chill at ^{4C} for ~_{24h}.
|
||||
|
||||
## Crust ->&crust
|
||||
|
||||
[Knead] Work &custard{150g} with @flour{300g} and @butter{150g}.
|
||||
|
||||
## Tart ~{-1d}
|
||||
|
||||
[Fill] Fill with &crust{400g}.
|
||||
|
||||
[Bake] For ~{30min}.
|
||||
|
||||
## Serve
|
||||
|
||||
[Dust] Dust with @sugar{10g}.
|
||||
```
|
||||
|
||||
Structuring multi-day recipes relies on two straightforward principles:
|
||||
|
||||
1. **Only day anchors (`~{-Nd}`) open working days.** Anchors such as `~{-1d}` or `~{-2d}` state clear intent (*"prep done the day before (D-1)"* or *"two days ahead (D-2)"*). In contrast, hour anchors (`~{-18h}`) or standalone long timers (`~_{24h}`) push tasks upstream along the timeline, but never open autonomous calendar days.
|
||||
2. **Unanchored sections attach to the next anchor.** Because scheduling works backward from serving time, an unanchored section is placed as late as possible—sharing the same working day as the anchored section following it. In the example above, the crust has no anchor, so it is made on **D-1**, immediately before the tart.
|
||||
|
||||
For this recipe, Gram outputs:
|
||||
|
||||
```text
|
||||
D-3 ▮ ~ 5min Custard
|
||||
┆ Custard : Chill 1d
|
||||
D-1 ▮ ~ 40min Crust, Tart
|
||||
Day D ▮ ~ 5min Serve
|
||||
★ Serve
|
||||
```
|
||||
|
||||
:::tip[Consecutive sections on the same day]
|
||||
When multiple sections occur on the same day, anchor only the last one (`## Tart ~{-1d}`). Preceding sections attach to it cleanly without timeline conflicts.
|
||||
:::
|
||||
|
||||
Each working day fits within a theoretical 24-hour window. If an excessively long passive wait pushes active steps further back beyond this window, Gram emits a `DAY_OVERFLOW` compiler warning and suggests anchoring the section one day earlier (`~{-2d}`).
|
||||
|
||||
## Real-time calendar planning
|
||||
|
||||
A relative timeline tells you how long a recipe takes. To find out **when to start**, Gram matches this model against three inputs:
|
||||
|
||||
1. **Target serving time** (`--serve "2026-10-18 13:00"`).
|
||||
2. **Time zone** (`--tz Europe/Paris`, or the project `timezone` setting).
|
||||
3. **Kitchen availability** (`--available`, or the project `availability` setting).
|
||||
|
||||
### Defining your availability
|
||||
|
||||
The availability syntax is concise and flexible:
|
||||
- `08:00-22:00`: daily default window;
|
||||
- `sat=09:00-23:00`: weekday exception (`mon` through `sun`);
|
||||
- `2026-10-09=none`: complete unavailability on a specific calendar date;
|
||||
- `22:00-02:00`: a range whose end time precedes its start time crosses midnight continuously.
|
||||
|
||||
A specific date override takes precedence over a weekday rule, which in turn overrides the daily default.
|
||||
|
||||
:::note[Time zones and daylight saving]
|
||||
Internal calculations use continuous absolute minutes. A 24-hour dough rise crossing a daylight saving transition lasts 24 real hours: if it begins at 14:00 the day before, it finishes at 13:00 local clock time. No timezone quirks distort culinary precision.
|
||||
:::
|
||||
|
||||
### How Gram avoids overnight cooking
|
||||
|
||||
The engine anchors the end of the recipe to the serving time, then works backward:
|
||||
|
||||
<Steps>
|
||||
1. **Detecting overlaps**
|
||||
Continuous active tasks without pauses form indivisible blocks. Any block overlapping unavailable periods (such as 22:00 to 08:00) is flagged.
|
||||
|
||||
2. **Adjusting through elastic rests**
|
||||
To move active work into your available hours, Gram extends or shortens the nearest downstream elastic rest (`~_{8-16h}`). Extending a rest pushes prep earlier (e.g. to the evening before); shortening it shifts it to the next morning.
|
||||
|
||||
3. **Strict verification**
|
||||
The entire timeline is recalculated with every adjustment. Gram never exceeds defined range bounds and never alters fixed timers.
|
||||
</Steps>
|
||||
|
||||
### Example: overnight fermentation
|
||||
|
||||
```gram
|
||||
## Dough ->&dough
|
||||
|
||||
[Knead] Knead @flour{500g} and @water{350ml} for ~{20min}.
|
||||
|
||||
[Rise] Let rise ~_{8-16h}.
|
||||
|
||||
## Bake
|
||||
|
||||
[Bake] Shape &dough{850g} and bake ~{30min}.
|
||||
```
|
||||
|
||||
For Sunday lunch at 13:00 with availability from `08:00-22:00`, a minimal 8-hour rise would schedule kneading at 04:10 AM.
|
||||
|
||||
Using the `8-16h` range, Gram automatically extends the rise to 14 h 30 min. Kneading shifts to Saturday night at 21:40, finishing right at 22:00 before bed:
|
||||
|
||||
```text
|
||||
SAT. 10 ▮ 21:40 – 22:00 Dough
|
||||
┆ Dough : Rise 14h 30min (nominal 8h to 16h)
|
||||
SUN. 11 ▮ 12:30 – 13:00 Bake
|
||||
★ 13:00 Serve
|
||||
```
|
||||
|
||||
## From calendar to run sheet
|
||||
|
||||
Calendar projection provides all the operational data needed during cooking. The <Term id="runSheet" /> renders this data:
|
||||
|
||||
- **Kitchen visits (`▮`)**: each hands-on cooking session, showing start time, end time, and available advance margin ("Possible from...").
|
||||
- **Passive waiting threads (`┆`)**: unattended tasks (baking, chilling, fermentation) progressing while you step out of the kitchen.
|
||||
- **Detailed mise en place**: for each visit, ingredients to measure, preparations to retrieve, and cookware to set up.
|
||||
|
||||
Without a target serving time (`gram plan recipe.gram`), Gram outputs a relative countdown (`D-2`, `D-1`, `Day D`) showing estimated durations per day and the earliest possible tasting time (`earliestServe`) starting immediately. Margins and calendar adjustments only apply when a target serving time is set.
|
||||
|
||||
### Diagnostics and unresolved constraints
|
||||
|
||||
When real-world constraints cannot be met (availability too narrow, or a fixed timer forcing overnight work), Gram presents them under a **"To fix"** header:
|
||||
|
||||
| Diagnostic | Meaning | Recommended action |
|
||||
|---|---|---|
|
||||
| `ACTIVE_OUTSIDE_AVAILABILITY` | Active work lands outside available hours, with no elastic timer capable of shifting it. | Expand availability windows or widen the elastic timer range. |
|
||||
| `ACTIVE_BLOCK_EXCEEDS_AVAILABILITY` | An unbroken active task block is longer than your largest availability window. | Lengthen available cooking hours to fit the uninterrupted task. |
|
||||
| `DAY_MISMATCH` | A task landed on a different date than intended (for example, unanchored work pushed to the day before). | Informational: the schedule remains valid, or explicitly anchor the section if desired. |
|
||||
| `START_IN_PAST` | The first step would have needed to start before the current time. | Push the serving time later or shorten waiting times. |
|
||||
| `MULTI_RECIPE_UNSUPPORTED` | Multiple recipes were supplied together; only the first was planned. | Plan recipes individually. |
|
||||
|
||||
:::note[Planning diagnostics vs compilation errors]
|
||||
These diagnostics depend strictly on **your calendar constraints**: they do not represent syntax or compilation errors in your `.gram` recipe file.
|
||||
:::
|
||||
|
||||
## Next steps
|
||||
|
||||
<CardGrid>
|
||||
<LinkCard
|
||||
title="Plan a meal"
|
||||
description="Step-by-step guide: CLI commands, Markdown export, and calendar synchronization (.ics)."
|
||||
href="/docs/how-to/plan-a-meal/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="ALAP scheduling"
|
||||
description="Understand the reverse scheduling algorithm that optimizes active and passive workflow."
|
||||
href="/docs/explanation/alap-scheduling/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="The scheduling engine"
|
||||
description="Architecture of the @gram-lang/scheduler package, task graph, and pure functions."
|
||||
href="/docs/explanation/engine/scheduler/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Scheduler API reference"
|
||||
description="TypeScript types and function signatures for layout(), project(), and runSheet()."
|
||||
href="/docs/reference/api/scheduler/"
|
||||
/>
|
||||
</CardGrid>
|
||||
|
|
@ -233,7 +233,7 @@ const recipe = applyScale(compile(ast), 6 / 4); // from 4 portions to 6
|
|||
const html = toHTML(recipe); // shows "6 portions ×1.5"
|
||||
```
|
||||
|
||||
The option keeps working until 2.0.0. In the playground, the portions are set in the **Portions & Scale** settings, which a click on the portions of the recipe opens.
|
||||
The option keeps working until 2.0.0. In the playground, the portions are set in the **Quantities** settings, which a click on the portions of the recipe opens.
|
||||
|
||||
### Backwards compatibility with older JSON
|
||||
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@ The recipe says **how** to do things. The <Term id="runSheet" link={false} /> sa
|
|||
|
||||
## Mousse ->&mousse ~{-1d}
|
||||
|
||||
[Whip] Whip @cream{250g} with @sugar{30g} and @milk{100g} using the #stand mixer{} ~{10min}.
|
||||
[Whip] Whip @cream{250g} with @sugar{30g} and @milk{100g} using the #stand mixer{} for ~{10min}.
|
||||
|
||||
[Assemble] Layer &sponge, &insert and the mousse in the #20 cm ring{} ~{10min}, then freeze ~_{12-48h}.
|
||||
[Layer] The &sponge, &insert and mousse in the #ring{}(20 cm), then freeze for ~_{12-48h}.
|
||||
|
||||
## Finish
|
||||
|
||||
[Unmould] Unmould the entremets and cover it with &glaze ~{5min}.
|
||||
[Unmould] Unmould the entremets and glaze with &glaze.
|
||||
|
||||
[Thaw] Thaw in the fridge for ~_{6h}.
|
||||
```
|
||||
|
|
@ -52,9 +52,9 @@ The recipe says **how** to do things. The <Term id="runSheet" link={false} /> sa
|
|||
|
||||
## Sponge ->&sponge
|
||||
|
||||
[Mix] Mix @pistachios{80g}, @eggs{3} and @sugar{60g} ~{10min}.
|
||||
[Mix] Mix @pistachios{80g}, @eggs{3} and @sugar{60g}.
|
||||
|
||||
[Bake] Bake at ^{180C} ~{12min}.
|
||||
[Bake] Bake at ^{180C} for ~{12min}.
|
||||
```
|
||||
|
||||
```gram title="bases/raspberry-insert.gram"
|
||||
|
|
@ -64,9 +64,9 @@ The recipe says **how** to do things. The <Term id="runSheet" link={false} /> sa
|
|||
|
||||
## Insert ->&insert
|
||||
|
||||
[Cook] Cook @raspberries{200g} and @sugar{40g} ~{5min}.
|
||||
[Cook] Cook @raspberries{200g} and @sugar{40g} for ~{5min}.
|
||||
|
||||
[Freeze] Let it set in the freezer ~_{12-72h}.
|
||||
[Freeze] Freeze for ~_{12-72h}.
|
||||
```
|
||||
|
||||
```gram title="bases/white-chocolate-glaze.gram"
|
||||
|
|
@ -76,7 +76,7 @@ The recipe says **how** to do things. The <Term id="runSheet" link={false} /> sa
|
|||
|
||||
## Glaze ->&glaze
|
||||
|
||||
[Heat] Heat @white chocolate{150g} and @cream{100g} ~{5min}.
|
||||
[Heat] Heat @white chocolate{150g} and @cream{100g} for ~{5min}.
|
||||
```
|
||||
|
||||
The durations and times shown below are the ones Gram computes with these three bases.
|
||||
|
|
@ -85,7 +85,7 @@ The recipe says **how** to do things. The <Term id="runSheet" link={false} /> sa
|
|||
See [Exact times and ranges](/docs/reference/syntax/times/#exact-times-and-ranges) and [Days and hours](/docs/reference/syntax/times/#days-and-hours).
|
||||
|
||||
:::tip
|
||||
**Name your steps with `[Action]`**: The run sheet names steps and background threads after their actions (e.g. `Mousse : Assemble 12h to 2d` in the timeline and in the waits you leave running). Prefixing each step that carries a timer or wait with an `[Action]` ensures clear, descriptive labels there rather than raw durations or generic fallbacks like `Rest`.
|
||||
**Name your steps with an `[Action]`**: The run sheet names steps and background threads after their actions (e.g. `Mousse : Layer 12h to 2d` in the timeline and in the waits you leave running). Prefixing each step that carries a timer or wait with an `[Action]` ensures clear, descriptive labels there rather than raw durations or generic fallbacks like `Rest`.
|
||||
:::
|
||||
|
||||
2. ### Choose when to serve
|
||||
|
|
@ -98,11 +98,11 @@ The recipe says **how** to do things. The <Term id="runSheet" link={false} /> sa
|
|||
```
|
||||
|
||||
```text
|
||||
Thursday, October 15 20:00 — start Tue 13:29 · 3 visits to the kitchen · no wait adjusted
|
||||
Friday, October 16 20:00 — start Wed 13:29 · 3 visits to the kitchen · no wait adjusted
|
||||
Saturday, October 17 20:00 — start Thu 13:29 · 3 visits to the kitchen · no wait adjusted
|
||||
Thursday, October 15 20:00 — start Tue 13:37 · 3 visits to the kitchen · no wait adjusted
|
||||
Friday, October 16 20:00 — start Wed 13:37 · 3 visits to the kitchen · no wait adjusted
|
||||
Saturday, October 17 20:00 — start Thu 13:37 · 3 visits to the kitchen · no wait adjusted
|
||||
...
|
||||
Thursday, October 15 12:30 — not possible. Mise en place — Sponge, around Tue 06:00, falls when you are not available, and no wait can be moved to fix it. (+2)
|
||||
Thursday, October 15 12:30 — not possible. Mise en place — Sponge, around Tue 06:05, falls when you are not available, and no wait can be moved to fix it. (+2)
|
||||
```
|
||||
|
||||
Compatible options are listed first (prioritizing fewer adjusted waits, then fewer visits, then the earliest dates). For each incompatible slot, Gram explains the blocking constraint.
|
||||
|
|
@ -130,12 +130,12 @@ The recipe says **how** to do things. The <Term id="runSheet" link={false} /> sa
|
|||
```text
|
||||
Run sheet — Pistachio raspberry entremets
|
||||
For Saturday, October 17 at 20:00 · 6 portions
|
||||
3 days · 3 visits to the kitchen · 1h 5min of work in all
|
||||
3 days · 3 visits to the kitchen · 45min of work in all
|
||||
|
||||
THU 15 ▮ 13:30 – 14:00 Sponge, Insert
|
||||
THU 15 ▮ 13:35 – 14:00 Sponge, Insert
|
||||
┆ Insert : Freeze 12h to 3d
|
||||
FRI 16 ▮ 13:35 – 14:00 Mousse
|
||||
┆ Mousse : Assemble 12h to 2d
|
||||
FRI 16 ▮ 13:40 – 14:00 Mousse
|
||||
┆ Mousse : Layer 12h to 2d
|
||||
SAT 17 ▮ 13:55 – 14:00 Finish
|
||||
┆ Finish : Thaw 6h
|
||||
★ 20:00 Serve
|
||||
|
|
@ -153,16 +153,20 @@ The recipe says **how** to do things. The <Term id="runSheet" link={false} /> sa
|
|||
#### Day-by-day detail
|
||||
Each visit has its own actionable checklist, grouped under the day it falls on:
|
||||
|
||||
- **Mise en place**: the required ingredients, preparations made during an earlier visit (`Sponge, made Thursday`), stocked items (`glaze, in stock`), and cookware, which is listed once per visit with how many you need and its size when the recipe says so (`tart tin (24cm)`, `tray ×2`). When the [mass standardization](/docs/reference/api/analyzer/) is on, an ingredient written in cups, spoons or millilitres also shows its weight (`flour 2 cup · 260.3 g`), summed when several sections use it. Check them off while you set up. Where it goes follows your [mise en place mode](/docs/explanation/mise-en-place-and-planning/): by section (the default), each section is a station with its own mise en place, right above its steps, and the cookware is named once, at the first section that uses it; per working day, one block at the top of the visit sums the raw ingredients (e.g. `sugar 90 g (60 + 30)`); upfront, that block holds everything raw at the first visit. A preparation is always listed at the visit of the first step that uses it.
|
||||
- **Execution**: the steps of each section, written out as in the recipe and numbered the same way, with their action, temperatures and timers, and the time the section starts (`Start: 13:40`, only when the plan has a serving time). A section that comes from an import names its source file, a section that goes on from an earlier visit is marked "continued", and a standalone note stays where the recipe puts it. The mise en place has check boxes; the steps do not.
|
||||
- **Mise en place**: everything to measure and set up before starting tasks:
|
||||
- *Raw ingredients*: check off each ingredient as you weigh it. When [mass standardization](/docs/reference/api/analyzer/) is active, volume quantities also display their gram equivalent (`flour 2 cup · 260.3 g`).
|
||||
- *Intermediate preparations*: components made during an earlier visit (`Sponge, made Thursday`) or stocked items (`glaze, in stock`).
|
||||
- *Cookware*: listed once per visit with quantity and size (`tart tin (24cm)`, `tray ×2`).
|
||||
- *Layout*: organized by section (default), per working day (`per-day`), or upfront (`upfront`), following your [mise en place mode](/docs/explanation/planning/#the-three-mise-en-place-strategies).
|
||||
- **Execution**: the steps of each section, written out as in the recipe and numbered the same way, with their action, temperatures and timers, and the time the section starts (`Start: 13:40`).
|
||||
- **Before leaving**: passive processes that continue unattended, and the exact time of your next kitchen visit.
|
||||
- **Possible from... / Can't start earlier**: shows how early this visit could start without affecting the rest of the schedule, or names the wait that holds it in place (for example, a 2 h chill that must end when you serve).
|
||||
- **Possible from... / Can't start earlier**: shows how early this visit could start without affecting the rest of the schedule.
|
||||
- **Adjusted waits**: any passive rest that the scheduler shortened or lengthened to fit your available hours is reported at the top of that day.
|
||||
|
||||
```text
|
||||
FRIDAY, OCTOBER 16 13:35 → 14:00
|
||||
FRIDAY, OCTOBER 16 13:40 → 14:00
|
||||
Possible from 08:00.
|
||||
MOUSSE (Start: 13:40)
|
||||
MOUSSE (Start: 13:50)
|
||||
Mise en place
|
||||
[ ] cream 250 g
|
||||
[ ] sugar 30 g
|
||||
|
|
@ -170,12 +174,12 @@ The recipe says **how** to do things. The <Term id="runSheet" link={false} /> sa
|
|||
[ ] Sponge, made Thursday
|
||||
[ ] Insert, made Thursday
|
||||
[ ] stand mixer
|
||||
[ ] 20 cm ring
|
||||
[ ] ring (20 cm)
|
||||
Execution
|
||||
1. [Whip] Whip cream with sugar and milk using the stand mixer 10 min.
|
||||
2. [Assemble] Layer sponge, insert and the mousse in the 20 cm ring 10 min, then freeze 12-48 h.
|
||||
1. [Whip] Whip cream with sugar and milk using the stand mixer for 10 min.
|
||||
2. [Layer] The sponge, insert and mousse in the ring, then freeze for 12-48 h.
|
||||
BEFORE LEAVING
|
||||
Mousse : Assemble 12h to 2d, until 02:00
|
||||
Mousse : Layer 12h to 2d, until 02:00
|
||||
Next visit: Saturday 13:55
|
||||
```
|
||||
|
||||
|
|
@ -183,7 +187,7 @@ The recipe says **how** to do things. The <Term id="runSheet" link={false} /> sa
|
|||
|
||||
In "Before leaving", `until 02:00` is the time the wait can end **at the earliest** (2 p.m. + 12 h), not the time it stops: the mousse must come out of the freezer before the finish, on Saturday. In between it stays in the freezer about 24 h, within its 12 to 48 h range.
|
||||
|
||||
Any constraints the engine could not resolve (a start time already in the past, work outside your available hours, or an incompatible rest) are listed under **"To fix"** at the top. See [Diagnostics and unresolved constraints](/docs/explanation/planning-in-real-time/#diagnostics-and-unresolved-constraints).
|
||||
Any constraints the engine could not resolve (a start time already in the past, work outside your available hours, or an incompatible rest) are listed under **"To fix"** at the top. See [Diagnostics and unresolved constraints](/docs/explanation/planning/#diagnostics-and-unresolved-constraints).
|
||||
|
||||
5. ### Export, print, or sync your calendar
|
||||
|
||||
|
|
@ -214,7 +218,7 @@ If a visit takes longer than expected or your day gets shifted, simply run `gram
|
|||
|
||||
## In the playground
|
||||
|
||||
In the online studio, open the settings and their "Schedule & Service" section, then enter a serving time, time zone, and your availability:
|
||||
In the online studio, open the settings and their "Schedule" section, then enter a serving time, time zone, and your availability:
|
||||
- The **Run sheet** view instantly displays the schedule with real dates and times.
|
||||
- The **"When to serve?"** buttons test and propose optimal meal slots.
|
||||
- The **"Ready as early as"** button calculates the fastest serving time starting right now.
|
||||
|
|
@ -254,9 +258,9 @@ The plain text output above is only one presentation layer: the scheduler produc
|
|||
href="/docs/explanation/engine/scheduler/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Planning in real time"
|
||||
description="How the serving time, your availability and the ranges turn into a calendar."
|
||||
href="/docs/explanation/planning-in-real-time/"
|
||||
title="Planning and run sheets"
|
||||
description="Mise en place modes, multi-day recipes, kitchen availability, and rest adjustments."
|
||||
href="/docs/explanation/planning/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Scheduler API reference"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import Term from '../../../../../components/Term.astro';
|
|||
|
||||
Gram's scheduling engine takes an agnostic **task graph** (the `tasks` field of a compiled recipe) and answers two fundamental questions: how do these tasks lay out chronologically (`layout`), and precisely when should each task begin, given a target serving time and cooking availability (`project`).
|
||||
|
||||
The scheduler has no knowledge of the AST or the `.gram` syntax, operating solely on the neutral task graph. See [The scheduling engine](/docs/explanation/engine/scheduler/) for how its architecture works and [Planning in real time](/docs/explanation/planning-in-real-time/) for practical usage.
|
||||
The scheduler has no knowledge of the AST or the `.gram` syntax, operating solely on the neutral task graph. See [The scheduling engine](/docs/explanation/engine/scheduler/) for how its architecture works and [Planning and run sheets](/docs/explanation/planning/) for practical usage.
|
||||
|
||||
:::note[Pure functions and determinism]
|
||||
Every function in the engine is pure: identical inputs always yield identical outputs. Nothing is read from the runtime environment (no system clock, no host time zone), and input arguments are never mutated.
|
||||
|
|
@ -240,7 +240,7 @@ type ProjectionDiagnostic =
|
|||
| { code: "MULTI_RECIPE_UNSUPPORTED"; recipes: number };
|
||||
```
|
||||
|
||||
These diagnostics depend on the user's execution context: they are included directly in the `ProjectedPlan` result rather than being compiler warnings. See [Planning in real time](/docs/explanation/planning-in-real-time/#diagnostics-and-unresolved-constraints) for a detailed breakdown of each code.
|
||||
These diagnostics depend on the user's execution context: they are included directly in the `ProjectedPlan` result rather than being compiler warnings. See [Planning and run sheets](/docs/explanation/planning/#diagnostics-and-unresolved-constraints) for a detailed breakdown of each code.
|
||||
|
||||
## `runSheet`
|
||||
|
||||
|
|
@ -414,9 +414,9 @@ A date that does not exist (a 30th of February, a 31st of April) is refused with
|
|||
|
||||
<CardGrid>
|
||||
<LinkCard
|
||||
title="Planning in real time"
|
||||
title="Planning and run sheets"
|
||||
description="Understand how target serving times and availability constraints form a prep timeline."
|
||||
href="/docs/explanation/planning-in-real-time/"
|
||||
href="/docs/explanation/planning/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="The scheduling engine"
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ Roast the chicken for ~{40-50min}.
|
|||
|
||||
The interpretation of a range differs fundamentally based on timer type:
|
||||
|
||||
- **A passive range represents elasticity.** The declaration `~_{12-24h}` states: "ready from 12 hours, optimal up to 24 hours". By default, the timeline lays out the shortest bound (`'shortest'`). You can select alternative elasticity strategies (`'shortest'`, median `'balanced'`, or longest `'longest'`) via the `--rests` CLI option, the `gram.rests` VS Code setting, or the `rests` renderer option. When provided with a target serving time and kitchen availability, the scheduler uses this elasticity to bridge overnight non-working hours without requiring cook intervention (see [Planning in real time](/docs/explanation/planning-in-real-time/)).
|
||||
- **A passive range represents elasticity.** The declaration `~_{12-24h}` states: "ready from 12 hours, optimal up to 24 hours". By default, the timeline lays out the shortest bound (`'shortest'`). You can select alternative elasticity strategies (`'shortest'`, median `'balanced'`, or longest `'longest'`) via the `--rests` CLI option, the `gram.rests` VS Code setting, or the `rests` renderer option. When provided with a target serving time and kitchen availability, the scheduler uses this elasticity to bridge overnight non-working hours without requiring cook intervention (see [Planning and run sheets](/docs/explanation/planning/)).
|
||||
- **How the <Term id="runSheet" /> reflects ranges.** The run sheet displays each passive wait with its scheduled duration and, when adjusted, reminds you of the original range specified in the recipe (e.g. `15 h 50 (12 to 48 h)`). This elasticity is what grants an anticipation margin to a kitchen visit ("Possible from 18:00"), since a stretchable wait allows upstream tasks to be performed earlier. Conversely, an exact passive duration fixes the visit time in place ("Can't start earlier"). See [Plan a meal](/docs/how-to/plan-a-meal/).
|
||||
- **An active range represents operational uncertainty.** The declaration `~{40-50min}` represents how long the chicken takes to roast. The schedule always defaults to the longest bound (50 minutes) so that service is never delayed. Passive elasticity settings (`rests`) do not apply to active timers.
|
||||
|
||||
|
|
@ -224,14 +224,14 @@ Warnings are non-blocking by default, but can be enforced as errors via `gram ch
|
|||
href="/docs/explanation/alap-scheduling/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Planning in real time"
|
||||
description="How the scheduler projects tasks onto clock times and user availability windows."
|
||||
href="/docs/explanation/planning-in-real-time/"
|
||||
title="Planning and run sheets"
|
||||
description="Mise en place modes, elastic timers, calendar projection, and run sheet generation."
|
||||
href="/docs/explanation/planning/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Mise en place and planning"
|
||||
description="Explore how preparation costs, section day anchors, and multi-day recipes interact."
|
||||
href="/docs/explanation/mise-en-place-and-planning/"
|
||||
title="Plan a meal"
|
||||
description="Step-by-step practical guide to calculating schedules with gram plan."
|
||||
href="/docs/how-to/plan-a-meal/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Compiler warnings reference"
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ gram plan bread.gram --find 2026-10-10/2026-10-14 --available 08:00-22:00 # Fi
|
|||
- `--available <range>`, repeatable: defines working availability windows for active kitchen tasks. `08:00-22:00` applies to all days; a day-of-week prefix (`fri=18:00-22:00`, from `mon` to `sun`) restricts the rule to that day; a specific date prefix (`2026-10-09=none`) overrides a calendar date (`none` indicating complete unavailability). Multiple intervals can follow a single key separated by commas (`sat=08:00-09:00,18:00-22:00`), and an interval whose end time precedes its start time spans across midnight. Without the flag, the `availability` setting of your project (or global config) applies <Since v="1.4.0" />, in the same syntax; without either, availability is treated as continuous (24/7). A flag replaces the setting rather than adding to it.
|
||||
- `--find <from>/<to>`: scans a time range (e.g. `2026-10-12/2026-10-15`, dates or full timestamps) to identify viable meal times, ranked by preference (best options first), explaining the blocking constraints for each rejected slot. Formats: `text`, `md`, `json`. Incompatible with `--serve`.
|
||||
- `--meal-times <HH:MM,HH:MM>`: candidate meal times evaluated by `--find` (default: value from `mealTimes` config, otherwise `12:30,20:00`).
|
||||
- Range-based passive timers (`~_{8-16h}`) are automatically adjusted (extended or shortened) by the scheduler to align active tasks within your availability windows; the schedule documents all adjustments made and lists any unresolved constraints. See [Planning in real time](/docs/explanation/planning-in-real-time/).
|
||||
- Range-based passive timers (`~_{8-16h}`) are automatically adjusted (extended or shortened) by the scheduler to align active tasks within your availability windows; the schedule documents all adjustments made and lists any unresolved constraints. See [Planning and run sheets](/docs/explanation/planning/).
|
||||
- `--format text|md|html|json`: output format (default `text`). `json` outputs the structured `{ plan, runSheet }` object (or `runSheet` only alongside the `earliest` field when no serving time is given, or candidate and rejection lists with `--find`). See [the run sheet](/docs/reference/api/data-formats/#5-the-run-sheet).
|
||||
- `--ics <file>`: generates an iCalendar (`.ics`) file with one event per kitchen visit (timestamped in UTC and automatically displayed in your local time zone by your calendar client), a 10-minute reminder alarm, and the checklists in its description. Requires `--serve`. The confirmation message is printed to `stderr`, keeping piping via `--format json --ics …` fully usable.
|
||||
- `--comments <show|hide>` <Since v="1.4.0" /> shows (default) or hides recipe comments in the run sheet. When shown, they remain discreet: a standalone note sits beneath its step in small, muted text, while an end-of-line note stays in parentheses within the step sentence.
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Considérons une recette classique associant une pâte nécessitant 1 heure de l
|
|||
```gram
|
||||
[Pétrir] La @farine avec l'@eau et laisser lever ~_{1h}. ->&pâte
|
||||
|
||||
[Mélanger] Les ingrédients de la sauce ~{10min}. ->&sauce
|
||||
[Mélanger] Les la @purée de tomate{} et le @basilic ~{10min}. ->&sauce
|
||||
|
||||
[Cuire] La &pâte avec la &sauce au four pendant ~_{30min}.
|
||||
```
|
||||
|
|
@ -70,82 +70,10 @@ gantt
|
|||
Cuire au four (temps passif) : b4, after b2, 30m
|
||||
```
|
||||
|
||||
*(Note : à défaut de minuteur actif explicite sur le pétrissage, Gram lui alloue automatiquement 2 minutes de travail actif).*
|
||||
*(Note : à défaut de minuteur actif explicite sur le pétrissage, Gram lui alloue automatiquement 2 minutes de travail actif forfaitaire).*
|
||||
|
||||
En calant la confection de la sauce sur la fin de la pousse, Gram intercale ce travail actif **pendant** le temps passif de la pâte. Vos gestes s'enchaînent de manière fluide, le temps total est rationalisé et vos préparations conservent une fraîcheur maximale.
|
||||
|
||||
## Planifier la mise en place
|
||||
<Since v="1.4.0" />
|
||||
|
||||
La mise en place d'une section (rassembler et peser les ingrédients, sortir le matériel) constitue une tâche à part entière planifiée en tête de section. Prenons l'exemple d'une pâte suivie d'une garniture à cuire :
|
||||
|
||||
```gram
|
||||
## Pâte ->&pâte
|
||||
|
||||
[Mélanger] La @farine{500g} et l'@eau{300ml} dans un #saladier.
|
||||
|
||||
[Pointer] Laisser lever la pâte ~_{2h}.
|
||||
|
||||
## Garniture ->&garniture
|
||||
|
||||
[Suer] Faire revenir les @oignons{200g}(émincés) dans une #poêle.
|
||||
|
||||
## Montage
|
||||
|
||||
[Étaler] La &garniture sur la &pâte.
|
||||
|
||||
[Cuire] Au #four pendant ~{25min}.
|
||||
```
|
||||
|
||||
Ordonnancée **par section** (le mode par défaut), la préparation de chaque section se place au plus près de son exécution. Les préparations de la garniture et du montage glissent naturellement au sein des 2 heures de pousse de la pâte, en temps masqué :
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title Mise en place par section (2 h 32)
|
||||
dateFormat HH:mm
|
||||
axisFormat %H:%M
|
||||
todayMarker off
|
||||
section Pâte
|
||||
Mise en place : p1, 00:00, 3m
|
||||
Mélanger : active, a1, 00:03, 2m
|
||||
Pousse (temps passif) : r1, 00:05, 120m
|
||||
section Garniture
|
||||
Mise en place : p2, 01:56, 4m
|
||||
Suer : active, a2, 02:00, 2m
|
||||
section Montage
|
||||
Mise en place : p3, 02:02, 3m
|
||||
Étaler : active, a3, 02:05, 2m
|
||||
Cuire : active, a4, 02:07, 25m
|
||||
```
|
||||
|
||||
Ordonnée **tout au début**, la mise en place de tous les ingrédients bruts est regroupée en amont de toute cuisson :
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title Mise en place tout au début (2 h 39)
|
||||
dateFormat HH:mm
|
||||
axisFormat %H:%M
|
||||
todayMarker off
|
||||
section Mise en place
|
||||
Pâte : p1, 00:00, 3m
|
||||
Garniture : p2, 00:03, 4m
|
||||
Montage : p3, 00:07, 3m
|
||||
section Pâte
|
||||
Mélanger : active, a1, 00:10, 2m
|
||||
Pousse (temps passif) : r1, 00:12, 120m
|
||||
section Garniture
|
||||
Suer : active, a2, 02:10, 2m
|
||||
section Montage
|
||||
Étaler : active, a3, 02:12, 2m
|
||||
Cuire : active, a4, 02:14, 25m
|
||||
```
|
||||
|
||||
Les deux plannings décrivent fidèlement la même recette. La durée globale varie uniquement de 7 minutes (les 4 minutes de préparation de la garniture et les 3 minutes du montage) qui ne sont plus absorbées en temps masqué pendant la pousse. Le mode « par section » optimise la durée totale, tandis que « tout au début » séduit les cuisiniers souhaitant dégager leur plan de travail avant d'allumer les feux.
|
||||
|
||||
:::note[Pesée des intermédiaires]
|
||||
Un ingrédient intermédiaire (`&pâte`) requiert environ une minute de manipulation. Ce coût est imputé à la section qui le **consomme** (ici, le montage), et non à celle qui le produit.
|
||||
:::
|
||||
|
||||
## Pistes d'équipement dédiées (named tracks)
|
||||
|
||||
L'algorithme rétrograde ALAP gère nativement les ressources physiques limitées via les **pistes nommées** (*named tracks*). Lorsque vous affectez le même identifiant à plusieurs minuteurs passifs (par exemple, `~_four{20min}` et `~_four{30min}`), Gram interdit leur chevauchement et impose une exécution séquentielle sur cet équipement.
|
||||
|
|
@ -169,17 +97,6 @@ gantt
|
|||
|
||||
L'étape `Préparer le pain` est automatiquement programmée pendant la cuisson de la tarte (entre la 20e et la 25e minute) : le pain est ainsi prêt à enfourner dès que la tarte libère le four à la 25e minute.
|
||||
|
||||
## Ancres temporelles, journées de travail et dépendances
|
||||
|
||||
L'ancre de rétroplanning d'une section (`~{-2d}`) exprime une **échéance impérative** : le travail de cette section doit être achevé à ce moment précis, compté à rebours depuis l'heure de service. Entre deux sections ancrées, les étapes intermédiaires s'alignent automatiquement par rétro-propagation.
|
||||
|
||||
Quelques règles essentielles pour modéliser des recettes s'étendant sur plusieurs jours :
|
||||
|
||||
- **Ancrez en jours calendaires (`~{-Nd}`)** : le découpage en journées de travail repose exclusivement sur les ancres exprimées en jours (`~{-1d}`, `~{-2d}`). Une section sans ancre est rattachée au jour de l'ancre en jours la plus lointaine parmi les sections avales.
|
||||
- **Un temps passif long n'initie pas de nouvelle journée** : une étape comportant `~_{48h}` décale bien l'étape vers l'amont sur la chronologie, mais ne crée pas de journée J-2 en l'absence d'une ancre de section explicite (`## Crème ~{-2d}`).
|
||||
- **Une ancre en heures (`~{-Nh}`) n'ouvre pas de journée de travail** : une valeur comme `~{-18h}` ou `~{-36h}` fixe une échéance stricte au sein de la journée, mais n'ouvre pas de journée autonome. Pour débuter formellement la veille, utilisez l'ancre `~{-1d}`.
|
||||
- **Sections successives au cours du même jour** : ancrez uniquement la dernière section (`## Tarte ~{-1d}`) et laissez les sections amont sans ancre. Assigner la même ancre à deux sections interdépendantes générerait un diagnostic de paradoxe temporel.
|
||||
|
||||
## Ancrage modulaire (`@use ... ~{-1d}`)
|
||||
|
||||
Lors de l'assemblage de recettes modulaires avec `@gram-lang/modules`, vous pouvez déclarer un décalage rétro-planning directement sur une directive d'importation :
|
||||
|
|
@ -199,7 +116,7 @@ Pour exploiter toute la puissance de l'ordonnancement ALAP de Gram, appliquez ce
|
|||
|
||||
<Steps>
|
||||
1. **Distinguez soigneusement travail actif et temps passif (`~_`)**
|
||||
Dès qu'une opération n'exige pas la présence continue du cuisinier (cuisson au four, fermentation, mijotage, refroidissement), utilisez un minuteur passif (`~_`). Si vous utilisiez par erreur un minuteur actif (`~{1h}` au lieu de `~_{1h}`), Gram supposerait que vous manipulez la préparation pendant une heure pleine, ce qui bloquerait l'ordonnancement d'autres tâches en temps masqué.
|
||||
Dès qu'une opération n'exige pas votre présence continue (cuisson au four, fermentation, refroidissement), utilisez un minuteur passif (`~_`). Si vous utilisiez par erreur un minuteur actif (`~{1h}` au lieu de `~_{1h}`), Gram supposerait que vous manipulez la préparation pendant une heure pleine, ce qui bloquerait l'ordonnancement d'autres tâches en temps masqué.
|
||||
|
||||
2. **Déclarez les intermédiaires au plus tôt, consommez-les au plus tard**
|
||||
Déclarez un ingrédient intermédiaire (`->&nom`) dès que sa confection active s'achève, et référencez-le (`&nom`) uniquement dans l'étape où il est incorporé. Gram ajustera automatiquement l'intervalle entre production et consommation.
|
||||
|
|
@ -211,28 +128,28 @@ Pour exploiter toute la puissance de l'ordonnancement ALAP de Gram, appliquez ce
|
|||
Chaque étape sans minuteur hérite d'une durée forfaitaire de 2 minutes de travail actif. Privilégiez des étapes décrivant des unités de geste cohérentes plutôt qu'un découpage excessif qui alourdirait inutilement la durée active totale.
|
||||
</Steps>
|
||||
|
||||
## Visualisation et intégration dans les interfaces
|
||||
## De l'algorithme à la planification
|
||||
|
||||
Grâce au calcul déterministe des bornes temporelles `start` et `end` par le moteur ALAP, les interfaces utilisateur n'ont aucune logique de calcul de dates à implémenter : elles exploitent directement les données du graphe planifié.
|
||||
L'algorithme ALAP produit la chronologie de base (`layout()`). C'est cette ossature qui sert ensuite de socle à toutes les options de mise en scène :
|
||||
|
||||
Une représentation chronologique (à l'image des diagrammes `gantt` Mermaid ci-dessus) met parfaitement en évidence le chevauchement des temps passifs et l'insertion du travail actif en temps masqué. Ce sont exactement ces mêmes données que met en scène le <Term id="runSheet" />. Vous pouvez tester et visualiser cet ordonnancement en direct dans le **[Playground de Gram](/fr/play/)**.
|
||||
- **Organisation de la mise en place** : ordonnancement par section (en temps masqué), groupé au début, ou par journée.
|
||||
- **Recettes multi-jours** : découpage automatique grâce aux ancres calendaires (`~{-1d}`, `~{-2d}`).
|
||||
- **Projection sur le calendrier** : adaptation dynamique à votre heure de service et à vos disponibilités en cuisine.
|
||||
|
||||
### Ce que l'ALAP implique pour la marge
|
||||
|
||||
Puisque la planification s'effectue **au plus tard**, un passage en cuisine ne peut qu'être **avancé**, jamais différé sans repousser directement l'heure de service. L'indication de marge du plan de marche (« Possible dès 18:00 ») quantifie ainsi l'anticipation maximale admissible pour un passage tant que les temps d'attente qui l'encadrent respectent leurs fourchettes de durée. Une recette modélisée avec des durées passives flexibles bénéficie de marges d'anticipation, tandis qu'une recette aux attentes strictement figées n'en dispose d'aucune. Pour approfondir le calcul de ces fenêtres, consultez la section dédiée dans [Le moteur d'ordonnancement](/fr/docs/explanation/engine/scheduler/#de-la-chronologie-au-plan-de-marche).
|
||||
Pour explorer ces fonctionnalités et découvrir comment elles forment le <Term id="runSheet" />, consultez le guide approfondi [Planification et plan de marche](/fr/docs/explanation/planning/).
|
||||
|
||||
## Ressources associées
|
||||
|
||||
<CardGrid>
|
||||
<LinkCard
|
||||
title="Planifier en heures réelles"
|
||||
description="Découvrez comment le rétroplanning ALAP s'articule avec les horaires réels et vos disponibilités."
|
||||
href="/fr/docs/explanation/planning-in-real-time/"
|
||||
title="Planification et plan de marche"
|
||||
description="Mise en place, recettes sur plusieurs jours, projection calendaire et fiches de production."
|
||||
href="/fr/docs/explanation/planning/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Mise en place et planification"
|
||||
description="Comprenez l'articulation entre le travail préparatoire, l'ordonnancement et les ancres journalières."
|
||||
href="/fr/docs/explanation/mise-en-place-and-planning/"
|
||||
title="Planifier un repas"
|
||||
description="Guide pratique pas-à-pas pour générer votre plan de marche avec la CLI ou dans l'éditeur."
|
||||
href="/fr/docs/how-to/plan-a-meal/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Syntaxe des temps et durées"
|
||||
|
|
@ -240,8 +157,8 @@ Puisque la planification s'effectue **au plus tard**, un passage en cuisine ne p
|
|||
href="/fr/docs/reference/syntax/times/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Référence de l'API Scheduler"
|
||||
description="Documentation complète de layout(), project() et du moteur d'ordonnancement."
|
||||
href="/fr/docs/reference/api/scheduler/"
|
||||
title="Le moteur d'ordonnancement"
|
||||
description="Architecture du paquet @gram-lang/scheduler, graphe de tâches et fonctions pures."
|
||||
href="/fr/docs/explanation/engine/scheduler/"
|
||||
/>
|
||||
</CardGrid>
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ La compilation d'une recette Gram s'effectue au travers d'un flux de traitement
|
|||
|
||||
`@gram-lang/scheduler` se situe sous le compilateur Kitchen : Kitchen dépend de lui, jamais l'inverse. Le scheduler n'a aucune connaissance de l'AST ou de la syntaxe `.gram`, n'opérant que sur un graphe neutre de tâches. Il assure deux missions majeures :
|
||||
- **`layout()`** ordonnance le graphe de tâches sur une chronologie relative, selon les options de mise en place et la durée choisie pour les temps passifs élastiques.
|
||||
- **`project()`** projette cet ordonnancement sur le calendrier réel à partir d'une heure de service cible, d'un fuseau horaire et de plages de disponibilité. Ensuite, `runSheet()` structure l'ensemble en journées, passages en cuisine et processus passifs : ce sont les données fondamentales du <Term id="runSheet" />. La responsabilité du moteur s'arrête là : le plan de marche, le playground et les extensions d'éditeur constituent des **vues** en aval qui consomment ces structures (notamment via le paquet `@gram-lang/renderer`). Consultez [Planifier en heures réelles](/fr/docs/explanation/planning-in-real-time/) et [Le moteur d'ordonnancement](/fr/docs/explanation/engine/scheduler/).
|
||||
- **`project()`** projette cet ordonnancement sur le calendrier réel à partir d'une heure de service cible, d'un fuseau horaire et de plages de disponibilité. Ensuite, `runSheet()` structure l'ensemble en journées, passages en cuisine et processus passifs : ce sont les données fondamentales du <Term id="runSheet" />. La responsabilité du moteur s'arrête là : le plan de marche, le playground et les extensions d'éditeur constituent des **vues** en aval qui consomment ces structures (notamment via le paquet `@gram-lang/renderer`). Consultez [Planification et plan de marche](/fr/docs/explanation/planning/) et [Le moteur d'ordonnancement](/fr/docs/explanation/engine/scheduler/).
|
||||
|
||||
### Infrastructure transversale (`@gram-lang/i18n` et `@gram-lang/format`)
|
||||
- **`@gram-lang/i18n`** : Référentiel centralisé pour la normalisation linguistique, les tables de conversion d'unités (`UNIT_CONVERSIONS`), les durées (`TIME_TO_MINUTES`) et les clés de catégorisation (`CATEGORY_KEYS`).
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ Cette restitution sert d'implémentation de référence sans prétendre imposer
|
|||
|
||||
Les vues de recette standard (`toHTML`, `toMarkdown`, `toPrintHTML`) se concentrent sur la réalisation culinaire (le *comment*) sans exposer l'ordonnancement temporel. En activant l'option `runSheet`, elles ajoutent le plan de marche à la suite de la recette au sein d'un document unique. Consultez le guide [Créer une interface sur mesure](/fr/docs/how-to/build-custom-ui/) pour concevoir une vue planning personnalisée directement à partir des données.
|
||||
|
||||
L'option `miseEnPlace` (`"perSection"` par défaut, `"upfront"` ou `"perDay"`) et l'option `rests` (`"shortest"` par défaut, `"balanced"`, `"longest"`) choisissent la chronologie dont les en-têtes des documents montrent les durées totale et passive (voir [Planifier la mise en place](/fr/docs/explanation/alap-scheduling#planifier-la-mise-en-place)).
|
||||
L'option `miseEnPlace` (`"perSection"` par défaut, `"upfront"` ou `"perDay"`) et l'option `rests` (`"shortest"` par défaut, `"balanced"`, `"longest"`) choisissent la chronologie dont les en-têtes des documents montrent les durées totale et passive (voir [Les trois stratégies de mise en place](/fr/docs/explanation/planning/#les-trois-stratégies-de-mise-en-place)).
|
||||
|
||||
:::note[Remplacement du diagramme de Gantt]
|
||||
Les fonctions `toGanttHTML` et `attachGanttInteractivity` sont dépréciées depuis la version 1.4.0 et seront retirées en 2.0.0 : plus aucune surface de Gram n'utilise de diagramme de Gantt. Consultez la page [Dépréciations](/fr/docs/how-to/deprecations/) pour plus de détails.
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ Les attentes écrites sous forme de fourchette adoptent la stratégie spécifié
|
|||
|
||||
- Tout bloc de travail actif débordant sur une plage d'indisponibilité est décalé en allongeant ou en raccourcissant l'attente flexible (écrite sous forme de fourchette) la plus proche en aval.
|
||||
- L'ordonnancement complet est recalculé à chaque ajustement pour vérifier la validité des dépendances et l'absence de conflit de piste.
|
||||
- Pour une explication pas à pas, consultez le guide [Planifier en heures réelles](/fr/docs/explanation/planning-in-real-time/).
|
||||
- Pour une explication pas à pas, consultez le guide [Planification et plan de marche](/fr/docs/explanation/planning/).
|
||||
|
||||
Le temps interne est compté en minutes continues absolues depuis l'époque POSIX. La restitution en heure locale s'appuie sur `Intl.DateTimeFormat` avec un fuseau horaire explicite. Aucun recours à une bibliothèque tierce ou à une horloge système implicite n'est nécessaire : le plan reste strictement identique quel que soit l'environnement hôte, et une journée de 23 ou 25 heures (changement d'heure) est restituée avec sa durée réelle.
|
||||
|
||||
|
|
@ -85,27 +85,25 @@ Le moteur génère des **données structurelles pures** ; le plan de marche cons
|
|||
|
||||
Chaque indicateur est calculé par le moteur, sous forme de minutes relatives avant le service, qu'il s'agisse d'une chronologie abstraite ou d'un calendrier horodaté.
|
||||
|
||||
La marge d'anticipation d'un passage est garantie par construction :
|
||||
- La planification étant calée au plus tard (ALAP), un passage ne peut qu'être avancé ;
|
||||
- L'avancer réduit l'attente passive qui le précède et allonge celle qui lui succède ;
|
||||
- Chaque borne est validée par rapport à la fourchette autorisée et à l'horaire nominal des passages adjacents.
|
||||
La marge d'anticipation quantifie la possibilité d'avancer un passage sans perturber le reste de la recette :
|
||||
- La planification étant calée au plus tard (ALAP), un passage ne peut qu'être avancé, jamais retardé sans impacter le service ;
|
||||
- L'avancer réduit l'attente passive précédente et allonge la suivante, dans les limites strictes de leurs fourchettes autorisées ;
|
||||
- Si un passage prend du retard en pratique, le moteur ne réajuste pas le passé : il suffit de relancer une projection avec une heure cible ou des paramètres actualisés.
|
||||
|
||||
Avancer un ou plusieurs passages ne remet donc jamais en cause la marge d'un autre passage. La marge calculée est parfois prudente, mais mathématiquement toujours sûre. En revanche, un retard d'exécution (un passage démarré après son heure planifiée) invalide la chronologie aval : le moteur ne réajustant pas automatiquement les horaires en cours de route, il convient alors de relancer une projection avec une nouvelle heure cible ou un point de départ réactualisé.
|
||||
|
||||
Le choix de la restitution et des termes éditoriaux relève entièrement de la vue. Le [plan de marche](/fr/docs/how-to/plan-a-meal/) par défaut de Gram découpe une journée dès qu'une pause passive atteint une heure, signale les marges dès 15 minutes (`WINDOW_MIN_MINUTES`), et extrait le matériel (« À sortir ») ainsi que les tâches (« Au programme ») depuis la recette compilée. Une interface tierce est libre d'adopter des règles de présentation différentes à partir de ces mêmes données (voir le guide [Créer une interface sur mesure](/fr/docs/how-to/build-custom-ui/)).
|
||||
Le choix de la restitution relève entièrement de la vue. Le [plan de marche](/fr/docs/how-to/plan-a-meal/) par défaut de Gram découpe une journée dès qu'une pause passive atteint une heure, signale les marges dès 15 minutes, et extrait les ingrédients et le matériel depuis la recette compilée. Une interface tierce peut adopter des règles différentes à partir de ces mêmes données (voir le guide [Créer une interface sur mesure](/fr/docs/how-to/build-custom-ui/)).
|
||||
|
||||
### Ce que le moteur ne prend pas en charge
|
||||
|
||||
- **Une seule recette à la fois** : La planification simultanée d'un menu complet multi-recettes partageant des ressources matérielles n'est pas encore gérée (`MULTI_RECIPE_UNSUPPORTED`).
|
||||
- **Pas de replanification automatique en direct** : Une planification étant une fonction déterministe et pure de ses entrées, tout retard réel nécessite d'invoquer à nouveau le moteur avec des paramètres actualisés.
|
||||
- **Aucune décision arbitraire sur vos horaires** : Le moteur évalue les créneaux de service que vous lui soumettez (`findServeTimes()` calé sur vos heures de repas habituelles, ou `earliestServe()` calculé dès maintenant), en indiquant rigoureusement lesquels sont réalisables et les motifs d'incompatibilité pour les autres.
|
||||
- **Une seule recette à la fois** : La planification coordonnée d'un menu multi-recettes partageant des ressources fera l'objet d'une évolution ultérieure (`MULTI_RECIPE_UNSUPPORTED`).
|
||||
- **Pas de suivi d'état en direct** : Le moteur est une fonction déterministe pure. En cas de retard imprévu en cuisine, une nouvelle projection doit être invoquée.
|
||||
- **Aucune décision arbitraire** : Le moteur teste les créneaux soumis (`findServeTimes()` sur vos heures de repas, ou `earliestServe()` calculé dès maintenant) et détaille les motifs d'incompatibilité pour les créneaux rejetés.
|
||||
|
||||
## Deux familles de diagnostics
|
||||
|
||||
Le moteur distingue rigoureusement deux catégories d'anomalies :
|
||||
|
||||
- **Diagnostics intrinsèques à la recette** : identifiés dès la phase d'ordonnancement par `layout()` (`TIME_PARADOX`, `TRACK_CONTENTION`, `DAY_OVERFLOW`). Kitchen les transforme en avertissements de compilation (`WarningCode`), enrichis du titre de la section et de son emplacement dans le code source pour l'affichage dans l'éditeur.
|
||||
- **Diagnostics contextuels de projection** : ils n'apparaissent qu'une fois l'heure de service et les disponibilités utilisateur confrontées à la recette (`ACTIVE_OUTSIDE_AVAILABILITY`, `ACTIVE_BLOCK_EXCEEDS_AVAILABILITY`, `DAY_MISMATCH`, `START_IN_PAST`, `MULTI_RECIPE_UNSUPPORTED`). Ils font partie du résultat retourné par `project()` et ne constituent pas des erreurs de compilation.
|
||||
- **Diagnostics intrinsèques à la recette** : identifiés dès l'ordonnancement par `layout()` (`TIME_PARADOX`, `TRACK_CONTENTION`, `DAY_OVERFLOW`). Kitchen les transforme en avertissements de compilation (`WarningCode`), avec titre de section et ligne source pour l'éditeur.
|
||||
- **Diagnostics contextuels de projection** : issus de la confrontation avec l'heure de service et vos disponibilités (`ACTIVE_OUTSIDE_AVAILABILITY`, `ACTIVE_BLOCK_EXCEEDS_AVAILABILITY`, `DAY_MISMATCH`, `START_IN_PAST`, `MULTI_RECIPE_UNSUPPORTED`). Portés par le résultat de `project()`, ils ne constituent pas des erreurs de compilation.
|
||||
|
||||
## Intégration dans le pipeline
|
||||
|
||||
|
|
@ -117,20 +115,15 @@ flowchart LR
|
|||
Project --> Sheet["📋 runSheet()<br/><i>fiche de production</i>"]
|
||||
```
|
||||
|
||||
Les vues de restitution (le plan de marche ou vos composants d'interface personnalisés) se situent **en aval** du moteur et consomment directement ses structures de données. Pour explorer les signatures de fonctions et leurs types TypeScript, consultez la [référence de l'API scheduler](/fr/docs/reference/api/scheduler/).
|
||||
Les vues de restitution (le plan de marche ou vos composants personnalisés) consomment directement ces structures de données. Pour explorer les signatures de fonctions et leurs types TypeScript, consultez la [référence de l'API scheduler](/fr/docs/reference/api/scheduler/).
|
||||
|
||||
## Ressources associées
|
||||
|
||||
<CardGrid>
|
||||
<LinkCard
|
||||
title="Référence de l'API Scheduler"
|
||||
description="Signatures de fonctions, options et types TypeScript pour layout(), project(), runSheet() et la recherche d'heure de service."
|
||||
href="/fr/docs/reference/api/scheduler/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Planifier en heures réelles"
|
||||
description="Comment le moteur projette les tâches sur des horaires réels et vos plages de disponibilité."
|
||||
href="/fr/docs/explanation/planning-in-real-time/"
|
||||
title="Planification et plan de marche"
|
||||
description="Mise en place, recettes multi-jours, projection calendaire et fiches de production."
|
||||
href="/fr/docs/explanation/planning/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Ordonnancement ALAP"
|
||||
|
|
@ -138,8 +131,13 @@ Les vues de restitution (le plan de marche ou vos composants d'interface personn
|
|||
href="/fr/docs/explanation/alap-scheduling/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Mise en place et planification"
|
||||
description="Comment les coûts de préparation et les recettes sur plusieurs jours interagissent."
|
||||
href="/fr/docs/explanation/mise-en-place-and-planning/"
|
||||
title="Planifier un repas"
|
||||
description="Guide pas-à-pas pour générer un plan de marche avec la CLI ou dans votre agenda."
|
||||
href="/fr/docs/how-to/plan-a-meal/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Référence de l'API scheduler"
|
||||
description="Signatures de fonctions, options et types TypeScript pour layout(), project() et runSheet()."
|
||||
href="/fr/docs/reference/api/scheduler/"
|
||||
/>
|
||||
</CardGrid>
|
||||
|
|
|
|||
|
|
@ -1,267 +0,0 @@
|
|||
---
|
||||
title: "Ingrédients, mise en place et planning"
|
||||
description: "Comment Gram distingue ce dont une recette a besoin, le travail de préparation et l'ordonnancement temporel, et l'impact de chaque configuration."
|
||||
---
|
||||
|
||||
import Since from '../../../../../components/Since.astro';
|
||||
import { LinkCard, CardGrid } from '@astrojs/starlight/components';
|
||||
import Term from '../../../../../components/Term.astro';
|
||||
|
||||
<Since v="1.4.0" />
|
||||
|
||||
Lors de la lecture d'une recette, trois notions complémentaires sont fréquemment confondues : **les besoins bruts**, **le travail de préparation préalable** et **l'ordonnancement temporel**. Gram distingue formellement ces trois aspects, seul le dernier dépendant des choix de l'utilisateur.
|
||||
|
||||
Pour une recette simple, la configuration par défaut planifie l'ensemble sans réglage particulier. Les sections suivantes s'adressent à celles et ceux qui souhaitent orchestrer une recette élaborée, composée de plusieurs préparations ou étalée sur plusieurs journées.
|
||||
|
||||
## Trois notions, un seul choix
|
||||
|
||||
| | Définition | Modifié par le choix d'ordonnancement ? |
|
||||
|---|---|---|
|
||||
| **Ingrédients** | Besoins matériels : la liste d'ingrédients de chaque section, la liste de courses consolidée | Non |
|
||||
| **Mise en place** | Travail de préparation amont : pesée, lavage, épluchage, découpe. Chaque section annonce son propre coût (`miseEnPlace`) | Non |
|
||||
| **Planning** | Ordonnancement temporel : chronologie relative, temps total, durée passive globale et <Term id="runSheet" /> | **Oui**, c'est l'unique dimension modifiée |
|
||||
|
||||
La recette ne dicte jamais son propre ordonnancement. Elle énonce des faits culinaires (les ingrédients requis et le temps estimé pour les préparer) ; il revient à **l'utilisateur** de décider comment organiser ce travail dans le temps.
|
||||
|
||||
Une règle simple à retenir : changer d'option d'ordonnancement ne modifie jamais les ingrédients, la liste de courses, le temps de préparation ni le travail actif. Cela déplace uniquement les blocs de travail sur la chronologie.
|
||||
|
||||
## Les trois stratégies de mise en place
|
||||
|
||||
Gram propose trois stratégies pour organiser la mise en place. Prenons cette recette :
|
||||
|
||||
```gram
|
||||
## Pâte ->&pâte
|
||||
|
||||
[Mélanger] La @farine{500g} et l'@eau{300ml} dans un #saladier.
|
||||
|
||||
[Pointer] Laisser reposer ~_{30min}.
|
||||
|
||||
## Garniture ->&garniture
|
||||
|
||||
[Émincer] Les @oignons{200g}(finement émincés).
|
||||
|
||||
## Montage
|
||||
|
||||
[Assembler] La &pâte et la &garniture, puis cuire ~{25min}.
|
||||
```
|
||||
|
||||
Gram estime automatiquement un temps de préparation pour chaque section selon les ingrédients à peser ou découper et le matériel requis (ici : 3 min pour la pâte, 3 min pour la garniture, 2 min pour le montage, soit 8 min au total). Le travail actif cumulé est de 29 minutes, quelle que soit la stratégie retenue.
|
||||
|
||||
### Par section (défaut)
|
||||
|
||||
Ce mode positionne la préparation de chaque section au plus près de son exécution. Dès qu'un temps passif se présente (fermentation, cuisson au four, refroidissement), Gram y insère la préparation de l'étape suivante.
|
||||
|
||||
En cuisine professionnelle comme en gestion de production, c'est ce que l'on nomme le travail en **temps masqué** : une tâche active effectuée *pendant* une durée passive n'ajoute aucune minute supplémentaire au temps total de la recette.
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title Par section — Travail en temps masqué (1 h 00)
|
||||
dateFormat HH:mm
|
||||
axisFormat %H:%M
|
||||
todayMarker off
|
||||
section Pâte
|
||||
Mise en place : p1, 00:00, 3m
|
||||
Mélanger : active, a1, 00:03, 2m
|
||||
Repos (passif) : r1, 00:05, 30m
|
||||
section Garniture
|
||||
Mise en place : p2, 00:28, 3m
|
||||
Émincer : active, a2, 00:31, 2m
|
||||
section Montage
|
||||
Mise en place : p3, 00:33, 2m
|
||||
Assembler et cuire : active, a3, 00:35, 25m
|
||||
```
|
||||
|
||||
- La pâte est préparée à 00:00, puis fermente pendant 30 minutes (de 00:05 à 00:35).
|
||||
- La garniture et le montage sont préparés en temps masqué vers la fin de la pousse de la pâte (à partir de 00:28) : les ingrédients découpés restent frais sans encombrer inutilement le plan de travail.
|
||||
- La durée totale est optimisée à **1 h 00** (60 min).
|
||||
|
||||
### Tout au début
|
||||
|
||||
Ce mode rassemble l'ensemble des pesées et découpes des ingrédients bruts avant d'entamer la première manipulation :
|
||||
|
||||
```mermaid
|
||||
gantt
|
||||
title Tout au début — Préparation groupée (1 h 03)
|
||||
dateFormat HH:mm
|
||||
axisFormat %H:%M
|
||||
todayMarker off
|
||||
section Mise en place
|
||||
Pâte : p1, 00:00, 3m
|
||||
Garniture : p2, 00:03, 3m
|
||||
section Pâte
|
||||
Mélanger : active, a1, 00:06, 2m
|
||||
Repos (passif) : r1, 00:08, 30m
|
||||
section Garniture
|
||||
Émincer : active, a2, 00:34, 2m
|
||||
section Montage
|
||||
Récupérer les préparations : p3, 00:36, 2m
|
||||
Assembler et cuire : active, a3, 00:38, 25m
|
||||
```
|
||||
|
||||
- La pâte et la garniture sont préparées dès 00:00 (jusqu'à 00:06).
|
||||
- La durée totale passe à **1 h 03** (63 min), la préparation de la garniture n'étant plus réalisée en temps masqué pendant la pousse de la pâte.
|
||||
|
||||
### Par journée de travail
|
||||
|
||||
Ce mode regroupe la préparation par journée de travail. Lorsque la recette s'exécute sur une seule journée (sans ancre temporelle passée comme `~{-1d}`), ce mode produit un résultat strictement identique à « Tout au début ». Il prend tout son sens pour les recettes planifiées sur plusieurs jours (voir ci-après). Une journée de travail n'est pas une seule visite en cuisine : si elle compte un passage le matin et un autre le soir, la mise en place est tout de même réunie une seule fois, avant le premier passage. Pour sortir les choses juste avant chaque passage, choisissez plutôt « Par section ».
|
||||
|
||||
Aucune stratégie n'est intrinsèquement supérieure aux autres : la première optimise la durée totale et la fraîcheur des découpes en exploitant les temps masqués ; la deuxième convient aux personnes préférant réunir et peser l'ensemble des ingrédients avant d'allumer le feu ; la troisième structure les feuilles de route de production réparties sur plusieurs jours.
|
||||
|
||||
:::note[Cas particulier : un intermédiaire n'est jamais préparé avant d'exister]
|
||||
Un ingrédient intermédiaire (`&pâte`) est produit au cours de la recette : il ne peut être mobilisé ou pesé avant que la section qui le fabrique ne soit achevée. Cette règle s'applique à toutes les stratégies d'ordonnancement :
|
||||
|
||||
- **Comptabilisation** : l'intermédiaire entre dans la mise en place de la section qui le **consomme**, non de celle qui le produit.
|
||||
- **En mode « Tout au début »** : les ingrédients bruts sont préparés dès le départ, mais l'intermédiaire n'est mobilisé qu'au moment précis où la section avale en a besoin (dans notre exemple, `&pâte` est récupéré après son repos, juste avant le montage).
|
||||
:::
|
||||
|
||||
## Durées passives élastiques en fourchette
|
||||
|
||||
Une durée passive peut être fixe (`~_{12h}`) ou spécifiée sous forme de fourchette (`~_{12-24h}` : résultat optimal dès 12 heures, préservé jusqu'à 24 heures). Une durée passive fixe ne subit aucun ajustement. Une fourchette offre en revanche une marge d'élasticité dont vous déterminez le comportement par défaut via l'option `rests`, tout comme vous choisissez la stratégie de mise en place :
|
||||
|
||||
- **`shortest`** (par défaut) : retient la borne inférieure de la fourchette ;
|
||||
- **`balanced`** : retient la valeur médiane ;
|
||||
- **`longest`** : retient la borne supérieure.
|
||||
|
||||
Ce choix influe sur le temps total, le temps passif global et le plan de marche, sans modifier le travail actif. À l'inverse, un minuteur actif écrit en fourchette (`~{40-50min}`) exprime une incertitude de cuisson et non une marge d'élasticité : il est systématiquement planifié sur sa durée maximale, garantissant ainsi de ne jamais servir en retard.
|
||||
|
||||
Lorsque vous fournissez une heure de service et vos disponibilités, Gram utilise cette marge élastique pour ajuster l'ordonnancement et éviter le travail actif nocturne : voir [Planifier en heures réelles](/fr/docs/explanation/planning-in-real-time/).
|
||||
|
||||
## Configuration de l'ordonnancement
|
||||
|
||||
Une règle fondamentale régit l'architecture de Gram : **la recette ne contient aucune directive pour imposer son ordonnancement**. Elle décrit exclusivement des faits culinaires (ingrédients, matériel, gestes et durées).
|
||||
|
||||
Lors de la compilation, Kitchen conserve la neutralité des données. Le JSON compilé transporte les faits bruts (`miseEnPlace`, et `tasks` : le graphe de dépendances neutre) ainsi qu'un unique ordonnancement par défaut dans `schedule` (mise en place par section, durées passives au plus court) :
|
||||
|
||||
```json
|
||||
{
|
||||
"miseEnPlace": { /* faits bruts : durées estimées par section */ },
|
||||
"tasks": { /* graphe de tâches agnostique */ },
|
||||
"schedule": { /* ordonnancement par défaut, calculé à partir de tasks */ }
|
||||
}
|
||||
```
|
||||
|
||||
Toute autre configuration (tout au début, par journée, durées passives maximales...) se calcule à la demande à partir de `tasks`, via la fonction pure `layout()` de `@gram-lang/scheduler`, **sans nécessiter de recompilation**. Le choix de l'ordonnancement intervient donc **au moment du rendu, de l'export ou de l'affichage** :
|
||||
|
||||
| Outil | Positionnement de la mise en place | Choix des durées passives |
|
||||
|---|---|---|
|
||||
| **CLI** (`gram view`, `export`, `print`, `plan`) | `--mise-en-place <per-section\|upfront\|per-day>` | `--rests <shortest\|balanced\|longest>` |
|
||||
| **VS Code** | Réglage `gram.miseEnPlace` | Réglage `gram.rests` |
|
||||
| **Playground** | Sélecteur « Mise en place » | Sélecteur « Repos » |
|
||||
| **Moteur de rendu** (`@gram-lang/renderer`) | Option `miseEnPlace: "perSection" \| "upfront" \| "perDay"` | Option `rests` |
|
||||
|
||||
Pour les développeurs concevant une interface personnalisée, cette séparation évite de réécrire un algorithme d'ordonnancement : lisez `schedule` pour le planning par défaut, ou appelez `layout()` pour une variante sur mesure (voir la [référence de l'API kitchen](/fr/docs/reference/api/kitchen/) et celle de l'[API scheduler](/fr/docs/reference/api/scheduler/)).
|
||||
|
||||
## Les recettes sur plusieurs jours
|
||||
|
||||
Une recette longue (**pain au levain**, **viande marinée**, **croissants** ou **saumon gravlax**) s'organise naturellement par journées de travail : chaque jour, on prépare uniquement ce dont la journée a besoin. La stratégie **par journée de travail** (`per-day`) génère une feuille de route quotidienne, en se basant sur les ancres de rétroplanning (`~{-1d}`, `~{-2d}`) déclarées dans la recette.
|
||||
|
||||
```gram
|
||||
---
|
||||
title: Tarte garnie
|
||||
---
|
||||
|
||||
## Crème ~{-3d} ->&crème
|
||||
|
||||
[Fouetter] Le @lait{500ml} et les @œufs{4}.
|
||||
|
||||
[Refroidir] Laisser prendre à ^{4C} pendant ~_{24h}.
|
||||
|
||||
## Fond ->&fond
|
||||
|
||||
[Travailler] La &crème{150g} avec la @farine{300g} et le @beurre{150g}.
|
||||
|
||||
## Tarte ~{-1d}
|
||||
|
||||
[Garnir] Avec le &fond{400g}.
|
||||
|
||||
[Cuire] Cuire ~{30min}.
|
||||
|
||||
## Service
|
||||
|
||||
[Saupoudrer] De @sucre{10g}.
|
||||
```
|
||||
|
||||
### Découpage des journées de travail
|
||||
|
||||
Pour structurer une recette en journées de travail, le moteur d'ordonnancement s'appuie exclusivement sur des ancres exprimées **en jours** (`~{-1d}`, `~{-2d}`, `~{-3d}`) :
|
||||
|
||||
- **`~{-Nd}` (jours) = une journée de travail.** Cela exprime une intention explicite (*« préparation réalisée la veille (J-1) »*, *« deux jours avant (J-2) »*). Gram regroupe alors la mise en place de ces sections dans une journée de travail dédiée.
|
||||
- **`~{-Nh}` (heures) = une échéance relative au sein de la journée.** Une ancre telle que `~{-2h}` ou `~{-36h}` indique que l'étape doit s'achever 2 heures (ou 36 heures) avant le service, mais n'ouvre **jamais** de nouvelle journée à elle seule. Une recette `.gram` ne connaissant pas l'heure réelle de votre repas, convertir des heures en jours introduirait des ambiguïtés dépendantes de l'heure du repas (`~{-12h}` tombe le matin pour un dîner à 20 h, mais la veille à minuit pour un déjeuner à 12 h).
|
||||
|
||||
Une section sans ancre se rattache à l'ancre en jours **qui la suit** (la plus lointaine parmi les sections situées après elle), ou au jour J s'il n'y en a pas. C'est l'inverse du sens de lecture, et c'est voulu : le moteur raisonne depuis le service en remontant le temps, et une ancre dit « cette section, et tout ce qui la précède sans ancre, est faite au plus tard ce jour-là ».
|
||||
|
||||
:::caution[Une ancre ne s'applique pas aux sections qui la suivent]
|
||||
Dans l'exemple, le **fond** n'a pas d'ancre et il est écrit juste après la crème `~{-3d}`, mais il n'est **pas** fait à J-3. Il se rattache à la tarte `~{-1d}`, qui vient après lui : il est donc fait à J-1, juste avant elle, puisque l'ordonnancement place chaque étape au plus tard.
|
||||
:::
|
||||
|
||||
Voici le plan de marche que Gram produit pour cette recette (`gram plan tarte.gram`) :
|
||||
|
||||
```text
|
||||
J-3 ▮ ~ 5min Crème
|
||||
┆ Crème : Refroidir 1j
|
||||
J-1 ▮ ~ 40min Fond, Tarte
|
||||
Jour J ▮ ~ 5min Service
|
||||
★ Servir
|
||||
```
|
||||
|
||||
Pour faire le fond un jour à part, entre la crème et la tarte, ancrez-le explicitement : `## Fond ~{-2d} ->&fond` donne un passage à J-2.
|
||||
|
||||
```text
|
||||
J-3 ▮ ~ 5min Crème
|
||||
┆ Crème : Refroidir 1j
|
||||
J-2 ▮ ~ 5min Fond
|
||||
J-1 ▮ ~ 35min Tarte
|
||||
Jour J ▮ ~ 5min Service
|
||||
★ Servir
|
||||
```
|
||||
|
||||
Ancrer le fond à `~{-3d}`, comme la crème, n'a pas de sens ici : il consomme la crème, qui repose 24 heures. Gram l'accepte mais signale un conflit de chronologie (« la journée de travail commence avant l'ouverture de sa fenêtre de 24 h »).
|
||||
|
||||
:::caution[Points d'attention]
|
||||
Deux situations courantes n'ouvrent **pas** de nouvelle journée de travail :
|
||||
|
||||
1. **Un temps passif long sans ancre de section** : une étape comportant `~_{48h}` décale l'étape de deux jours vers l'amont sur la chronologie, mais ne crée pas de journée J-2 sans ancre de section explicite (`## Crème ~{-2d}`).
|
||||
2. **Une ancre exprimée en heures** : une valeur comme `~{-18h}` ou `~{-36h}` demeure une échéance interne au jour de la section. Pour ouvrir une véritable journée de travail la veille, utilisez l'ancre en jours `~{-1d}`.
|
||||
:::
|
||||
|
||||
Dans l'exemple ci-dessus :
|
||||
- La **crème** est préparée à **J-3** ;
|
||||
- Le **fond** et la **tarte** sont réalisés à **J-1** (le fond se rattache à la tarte, qui le suit) ;
|
||||
- Le **service** s'effectue le **jour J**.
|
||||
|
||||
Chaque journée est conçue pour s'inscrire dans les 24 heures précédant la suivante. Si un long temps passif repousse le travail d'une journée hors de cette fenêtre, Gram émet le diagnostic `DAY_OVERFLOW` et suggère d'ancrer la section plus en amont.
|
||||
|
||||
### Agrégation de la mise en place par journée de travail
|
||||
|
||||
Au début de chaque journée de travail, Gram rassemble la mise en place requise pour les étapes du jour :
|
||||
|
||||
- Un ingrédient intermédiaire **confectionné lors d'un jour antérieur** (la crème, préparée à J-3) est sorti dès le début de la journée où il est consommé (à J-1).
|
||||
- Un intermédiaire **confectionné le jour même** (le fond pour la tarte) est préparé immédiatement avant l'étape de montage, puisqu'il n'existe pas encore au démarrage de la journée.
|
||||
|
||||
Le temps de préparation cumulé et le travail actif demeurent strictement identiques entre toutes les stratégies d'ordonnancement.
|
||||
|
||||
Le texte de la recette ne matérialise pas directement ces blocs d'étapes : la mise en place est comptabilisée comme une charge dans les indicateurs temporels de la recette et dans le calcul de son ordonnancement. La liste concrète des éléments requis et leur moment exact d'utilisation correspondent au bloc **« À sortir »** présenté au début de chaque passage du [plan de marche](/fr/docs/how-to/plan-a-meal/), calculé pour chaque stratégie : par section, chaque section intègre ses propres ingrédients bruts juste avant ses étapes ; par journée de travail, ils sont réunis en tête de passage avec les quantités cumulées ; en amont (`upfront`), ils sont tous rassemblés dès le premier passage. Une préparation, quant à elle, est toujours listée lors du premier passage où elle intervient.
|
||||
|
||||
:::tip[Enchaînement de sections]
|
||||
Lorsque plusieurs sections se succèdent au cours de la même journée, ancrez uniquement la dernière (`## Tarte ~{-1d}`) et laissez les sections amont sans ancre (comme le fond ci-dessus) : elles héritent naturellement de son jour et s'insèrent immédiatement avant elle. Assigner `~{-1d}` à chacune créerait des échéances concurrentes au même instant, déclenchant un avertissement de paradoxe temporel en présence de dépendances.
|
||||
:::
|
||||
|
||||
## Ressources associées
|
||||
|
||||
<CardGrid>
|
||||
<LinkCard
|
||||
title="Syntaxe des temps et durées"
|
||||
description="Découvrez comment déclarer durées actives, repos passifs et ancres de journées de travail."
|
||||
href="/fr/docs/reference/syntax/times/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Ordonnancement ALAP"
|
||||
description="Comment le compilateur rétroplanifie les tâches et résout les conflits de pistes nommées."
|
||||
href="/fr/docs/explanation/alap-scheduling/"
|
||||
/>
|
||||
<LinkCard
|
||||
title="Planifier en heures réelles"
|
||||
description="Projetez le rétroplanning de la recette sur des horaires réels et vos plages de disponibilité."
|
||||
href="/fr/docs/explanation/planning-in-real-time/"
|
||||
/>
|
||||
</CardGrid>
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue