Back to examples

Halfway through: replan without rewriting history

Three weeks into the build phase of a website relaunch, things happen: someone is off, the client wants one more page, a task takes longer than planned. Replanning has to move the future and leave the past alone. Press an event above the chart and watch what the engine moves, and what it refuses to move.

A plain scheduler gets this wrong. Ask it to fit three more days of design and it happily slides tasks that started weeks ago, as if the work already done could start later. Here the line marks today. Bars left of it are fact; bars right of it are the forecast the engine is allowed to change.

What is fact

Two rules hold the past in place. With freeze_started on, a task with progress above zero keeps its dates, like a manually scheduled task. The freezeBefore cutoff pins every task that starts before today and puts a floor under everything else, so no solve places new work in the past. The demo derives each started task's progress from the plan at today; the darker part of a bar is the work done. Research and the other early work ended before the chart starts and are left out.

Load the running project
// Started tasks keep their dates: a leaf with progress > 0
// is fixed like a manual task.
project.solve({
  config: {
    compat: "gantt",
    freeze_started: true,
    project_end: "2026-10-28 00:00",
  },
  calendars, tasks, links, resources, assignments,
});

Drag the line to any day from the plan start to the deadline and the plan is worked out for that “today”: whatever the current plan had before the new date becomes fact. Tasks that ended by then are done, a task running across it gets its elapsed share as progress, and later tasks get none, so they are placed again from the cutoff on. Bars left of the line never move when it does, and the events you already pressed stay applied.

Move today
// Today moves to Wed 7 Oct: progress is read from the current plan.
const freezeBefore = "2026-10-07 00:00";
project.apply({ tasks: { update: [
  { id: 9, progress: 1 },        // Visual design: ended, done
  { id: 16, progress: 0.7 },     // Integration: runs across today
  { id: 18, progress: 0.5 },     // Accessibility review: same
  // moving back: progress 0 for tasks now after today
] } });
project.level({ freezeBefore });
// then getState and analyze, as after every change

What moves

Every event is one apply, followed by the same three calls, all for the same cutoff: level, which solves first and then levels, getState for the plan the chart draws, and analyze for its slack and critical path. Leveling starts from a clean plan each time (clearFirst is on by default), so the panel lists every bar after today that ended up somewhere else. A change the engine rejects is not applied in part: the plan stays as it was.

Replan after a change
// "Today" is a per-call option, not config.
// Pass the same cutoff to every call while the date holds.
const freezeBefore = "2026-09-21 00:00";

// what happened this week: all of it, or nothing
project.apply(changes);
// solves first; nothing is placed or leveled before today
const leveled = project.level({ freezeBefore });
const { baselineId } = leveled;
// every task: dates, delay, pauses
const plan = project.getState({ baselineId });
// slack and the critical path of that plan
const { analytics } = project.analyze(null, {
  baselineId, analytics: { slack: true, criticalPath: true },
});

When Ana is off for a week, her next task moves out of the week and its successors follow. Her usability tests already started, so they keep their start; the last day moves after her leave. The client's task starts today, where Dee has room for it, and nothing else moves.

The events
// Ana is off for a week from today: a calendar based on the work week
// with those days off, added and given to her in one change set.
project.apply({
  calendars: { add: [{ id: "ana-off", base: "global",
    worktime: { exceptions: [{ from: "2026-09-21", to: "2026-09-27" }] } }] },
  resources: { update: [{ id: "ana", calendar_id: "ana-off" }] },
});

// The client adds a task: it starts today, never at the plan start.
// A start before the cutoff would pin the new task in the past.
project.apply({
  tasks: { add: [{ id: 23, start_date: freezeBefore, duration: 5 }] },
  links: { add: [{ id: 100, source: 23, target: 16, type: "fs" }] },
  assignments: { add: [{ id: "a23", task: 23, resource: "dee", value: 1 }] },
});

What the conflicts mean

The engine never resolves a conflict by moving history. When Visual design takes three days longer, it keeps its start and ends later. The front-end build is linked to it finish-to-finish and is already running, so it can't follow: the link is reported as a dependency-violation, drawn as a red dashed arrow. The design QA chain to the launch does move, and the launch lands after the deadline: a project-end-violation, and negative slack on the launch milestone. Each conflict carries its size, the working days it is short or late by, which the list shows.

Conflicts in the result
// What the fixed past breaks comes back as data, not as moved bars.
leveled.conflicts = [
  // Visual design → Front-end build (FF)
  { kind: "dependency-violation", link: 3, task: 10,
    required: "2026-10-02 00:00", actual: "2026-09-30 00:00",
    // the build's end, two working days short
    anchor: "end", size: 2 },
  // Launch
  { kind: "project-end-violation", task: 22,
    required: "2026-10-28 00:00", actual: "2026-10-29 00:00", size: 1 },
];
// and the launch milestone's total slack is negative: -1 working day

Both are decisions for a person: speed up the build, cut scope, or move the deadline. The remaining work of a started task isn't modelled; a longer task simply ends later. Overloads that leveling can't resolve before today, because the work there is fact, would appear in the same list.

The next demo pauses a task on purpose: the client hasn't answered yet, and leveling has to work around the hold.