Skip to the lesson
CivOps AI Academy · M03Scheduling and Dispatch: Finite-Capacity Scheduling on Your Own Platform
0%

Chapter 1 · Sessions 1 and 2

What the old schedule holds, and the tables that replace it

Before you build a scheduler, you find out whether the schedule you have today is finite at all, what it runs on, and what it costs, from its own screens and its own bill. Then one careful prompt adds the eleven scheduling tables to your platform, keyed to the presses and parts you already have, with tests that refuse impossible data.

25 min4 stepsAbout 7 hours hands-on across six sessionsSessions 1 and 2

By the end of this chapter you can

  • Inventory the current scheduling tool or board: resources, orders, users and the bill, read from its own screens and invoice.
  • Test whether today's schedule is finite or infinite capacity drawn as a Gantt chart, and whether it runs on nameplate rates.
  • Map the specification's spine names to your platform's tables and add only what is missing.
  • Have Claude Code write the eleven aps_ tables, their rules, tests and two small made-up seeded cases.

What this module replaces

Production scheduling turns released orders into a plan that says which operation runs on which press, line, crew or tool, and when. Vendors call the software advanced planning and scheduling (APS) [1][2]: PlanetTogether, Siemens Opcenter APS (Preactor), Asprova and DELMIA Ortems, and, far more often, a Smartsheet, monday.com or Excel board. ISA-95 Part 3 (IEC 62264-3) frames the job as detailed production scheduling, between planning above and execution below [3]. Material requirements (M12) and recording what happened (M04) belong to other modules; this one sits between them: orders in, a feasible plan out, actual times back.

Resource typeStamping plant exampleWhat limits it
machinePress P-03Its open hours and its rate
lineA transfer line treated as one unitThe slowest station
labor_poolDie setters on first shiftHeads available and skills
toolDie D-112Only one press can hold it at a time
vesselA wash tankBatch size and cleaning
work_centerThe six presses as a groupTheir combined hours
Infinite and finite capacityTwo timelines from 08:00 to 18:00. The first lets job B overlap job A on one machine. The second places jobs A, B and C one after another before the shift ends at 17:00 and marks job D late. 08:0009:0010:0011:0012:0013:0014:0015:0016:0017:0018:00Infinite capacity: the chart only drawslane 1Job Alane 2Job B, same machineFinite capacity: one machine, one job at a time, inside its open hoursMachineJob AJob BJob Cshift ends 17:00Job D does not fit: marked late, with the reason
The same press, two ways. Above, an infinite-capacity chart lets job B overlap job A. Below, a finite schedule runs one job at a time inside the open hours and says which job does not fit.
Step 1

Session 1: Count what the old schedule holds and costs, and test it

60 minutes

Why

The module is worth building only if it replaces a real tool, real workarounds and a real bill. Two checks on today's schedule (is it finite, and does it use measured rates?) tell you how far you have to go and give the planner a reason to trust the new one. Figures read from the tool and the invoice are what Session 6 compares against.

Do this

With the planner, gather from the tool's own screens and the vendor's account page (no customer names):

  • Every resource the schedule places work on, using the six types above, with its shift hours.
  • Every scheduling tool, board and spreadsheet: owner, logins, how people sign in, where its bill comes from; the amount, period, renewal date and notice period as printed.
  • Where orders come from (ERP, MRP, a spreadsheet, email) and how many are open this week, with the fields they carry.
  • For three presses, one day each: minutes of work the schedule places, minutes the press is open, any two jobs drawn at once or past the shift's end (the infinite-capacity test).
  • For the same three: the rate the schedule uses and where it came from (nameplate, routing, or measured).
  • Word for word, the planner's answer to: when you re-run the schedule, do the jobs you moved by hand stay put?
Paste into Claude Code, after replacing the <...> part
On a new branch aps/inventory, write docs/scheduling-inventory.md from what I give you below. Use only my numbers: where I wrote "unknown", write "unknown" and who can find out. Never estimate, round or fill a gap.

Tables:
1. Resources in the first scope: code, type, what it can do, shift hours, who looks after it.
2. Tools: name, owner, logins, bill per year, renewal date, notice period, export available, source of each figure.
3. Orders: where they come from, how many open this week, which fields they carry.
4. The infinite-capacity test: for three presses, work minutes, open minutes, load (work / open), any overlap or run past the shift, and a verdict "finite" or "infinite drawn as a Gantt chart".
5. Rates: the rate used, its source (nameplate, routing or measured), and the date.
6. Workarounds, and the planner's answer about re-runs, word for word.
7. The first scope to replace (one area with its bottleneck), why, and the planner and supervisor who will test it.

My notes:
<paste your notes here>

Open a pull request titled "Scheduling inventory" and show me the link.

You will see recreated screen

claude — acme-platform
⏺ Write(docs/scheduling-inventory.md)
+## The infinite-capacity test
+| Press | Work min | Open min | Load | Overlap or overrun | Verdict |
+| P-03 | 552 | 450 | 123% | J-2210 overlaps J-2211, 10:40-11:15 | infinite drawn as a Gantt chart |
+| P-05 | 410 | 450 | 91% | none | finite |
+## Rates
+| P-03 | 60 per hour | nameplate | 2019 install sheet |
1
⏺ Pull request #81 adds docs/scheduling-inventory.md. P-03 is loaded at 123% with an overlap, and its rate comes from the nameplate. The planner says overrides are lost on re-run. Two cells are unknown: the board's renewal date and the export format.2
Claude Code writes the inventory from your notes only, including the uncomfortable verdicts.
  1. The two checks, in numbers: a load over 100% or an overlap means the current chart is not a finite schedule.
  2. Unknowns stay unknown; the verdicts are written as found.

Check it worked

Pull request Scheduling inventory holds the seven tables, every figure with its source, and the infinite-capacity and rate results for three presses.

Fastest path

Do the three-press test on paper with the planner while you collect the other numbers, then paste everything in one go.

If it goes wrong

Claude Code filled in a price, a rate or a count you did not give it

Say: Remove every figure I did not give you and write unknown. We hit this on our own platform: screens showed numbers nobody had measured, because an agent filled gaps so a page looked finished.

The planner says the schedule lives only in their head or on a whiteboard

Write that down; it is the most common answer. Photograph one day of the whiteboard for the three-press test, with no customer names in the picture.

Your platform's names for the spine

The specification points at core_equipment, core_calendar, core_item, core_person and core_reason_code, with a tenant_id on every row. Your platform already has equipment and parts from Session 5. If you took another module first, docs/spine-map.md already exists: extend it, never start a second one. The scheduler must place work on your presses; a second press list would let a breakdown on one never reach the other.

Specification saysOn the stamping plant's platformIf missing
core_equipmentequipmentNever missing
core_itempartsNever missing
core_personSupabase sign-in users with membershipsA people table pointing at the sign-in user
core_calendar and shift definitionsusually missingAdd them: site, time zone, shifts, holidays
core_reason_codeusually missingAdd it: other modules use reason codes too
core_event_outbox, core_status_historymissing unless another module added themAdd them in the spine migration
tenant_id on every rowsite_id on every rowYour platform serves one company; site is the scope
Step 2

Session 2: Map the spine, and add only what is missing

15 minutes

Why

Calendars, shift definitions and reason codes are shared: maintenance, execution and quality modules all read them. Adding them once, in their own migration merged first, keeps one calendar per press. Putting them inside the scheduling migration would make the next module build a second calendar that disagrees.

Do this

Terminal or PowerShell
cd ~/code/acme-platform && git switch main && git pull && claude
Paste into Claude Code
Read docs/SCHEMA-PLAN.md, docs/naming-standard.md, every file in supabase/migrations, and docs/spine-map.md if it exists. Do not change any existing table or migration.

On a new branch spine/aps-prerequisites:
1. Create or extend docs/spine-map.md: for each of core_equipment, core_calendar (site, time zone, holidays), core_shift_definition (calendar, name, start and end time, days), core_item, core_person, core_job_role, core_reason_code (code, name, category), core_status_history and core_event_outbox, the table on this platform that plays that role, or "missing". Record: our scope column is site_id and our id type is the first migration's.
2. For every "missing" item, write ONE new migration (npx supabase migration new spine_for_scheduling) with this platform's conventions: primary key, site_id, created_at, created_by, updated_at, updated_by, row_version, archived_at, ext jsonb, timestamptz times, row-level security on with no policies; status history and outbox append-only. Add each new table to docs/matrix.json with no rights yet.
3. pgTAP tests for every new table: exists, primary key, row-level security on, append-only where stated.

Push, open a pull request titled "Spine for scheduling", wait for every check to finish, and tell me the result in plain words. If a check fails, fix it and wait again before reporting.

You will see recreated screen

claude — acme-platform
⏺ Read(docs/spine-map.md)
⎿ Read 24 lines (written by an earlier module)
1
⏺ Write(docs/spine-map.md)
+| core_calendar | missing: created in spine_for_scheduling |
+| core_shift_definition | missing: created |
+| core_reason_code | missing: created |
+| core_event_outbox | core_event_outbox (already created by spine_for_modules) |
⏺ Bash(gh pr checks --watch)
⎿ schema / test pass 2m10s
⏺ Pull request #82 is green. Three new spine tables; the outbox and status history already existed, so I reused them. No existing migration changed.2
Claude Code extends the existing map and creates only what is missing.
  1. An earlier module's map is extended, not replaced.
  2. Reused where it exists: one outbox for every module.

Check it worked

Pull request Spine for scheduling is green, and its Files changed tab shows one new migration and no edit to an older one.

If it goes wrong

Claude Code created a second calendar or reason-code table beside one that exists

Say: Remove the duplicate and point at the existing table, recorded in docs/spine-map.md.

It renamed equipment to core_equipment

Say: Revert every rename; map names in docs/spine-map.md instead. A rename that is only half done breaks every query that used the old name; we hit exactly that on our platform.

It reports success but a check is red

Say: A check is red. Run gh pr checks, read the failed log, fix it and wait for green before you report. Trust the check on GitHub, never the summary.

The eleven tables

The module's tablesEleven aps_ tables in three groups: master data (resource, capability, resource capability, calendar exception, setup matrix), scenario (scenario, job, scheduled operation, constraint, KPI) and feedback (adherence). Below them are the spine tables they point at. Master dataaps_resourceaps_capabilityaps_resource_capabilityaps_calendar_exceptionaps_setup_matrixScenarioaps_scenarioaps_jobaps_scheduled_operationaps_constraintaps_scenario_kpiFeedbackaps_adherenceSpine tables the module points at, never recreatescore_equipmentcore_calendarcore_itemcore_personcore_reason_code
Eleven tables in three groups. Master data says what can be scheduled, scenarios hold the plans, adherence records what happened. The spine names at the bottom are read through docs/spine-map.md.

The reference below is the specification's, column by column: req means required, a list after a colon is the only values allowed, an arrow is a link to another table. You do not type any of it: Step 3's prompt carries it into your repository.

TableHoldsColumns
aps_resourceSchedulable resource, usually linked to equipmentcode text req, unique; name text req; equipment_id → core_equipment; resource_type text req: machine, line, labor_pool, tool, vessel, work_center; capacity_units num req; efficiency_factor num; calendar_id → core_calendar; is_bottleneck bool
aps_capabilityCapability that operations requirecode text req, unique; name text req
aps_resource_capabilityWhat a resource can do and how fastresource_id → aps_resource req; capability_id → aps_capability req; rate_per_hour num; preference int
aps_calendar_exceptionDowntime, extra shifts or holidays per resourceresource_id → aps_resource req; starts_at ts req; ends_at ts req; kind text req: unavailable, overtime, planned_maintenance, holiday; note text
aps_setup_matrixSequence-dependent changeover time between product attributesresource_id → aps_resource req; attribute_key text req; from_value text req; to_value text req; setup_min num req; setup_cost money
aps_scenarioSchedule version: draft what-if or publishedname text req; status text req: draft, published, archived; horizon_start ts req; horizon_end ts req; objective_weights json; solver text req: rules, heuristic, cp_sat, manual; created_from_id → aps_scenario; published_at ts; published_by → core_person
aps_jobOrder to be scheduled within a scenarioscenario_id → aps_scenario req; order_ref_type text req: production_order, planned_order, manual; order_ref_id uuid; item_id → core_item; qty qty; due_at ts; release_at ts; priority int; status text req: unscheduled, scheduled, late, infeasible
aps_scheduled_operationOperation placed on a resource with timesscenario_id → aps_scenario req; job_id → aps_job req; seq int req; capability_id → aps_capability; resource_id → aps_resource; start_at ts; end_at ts; setup_min num; run_min num; locked bool; sequence_on_resource int
aps_constraintAdditional scenario constraintscenario_id → aps_scenario req; constraint_type text req: material, labor_skill, tool, max_wait, precedence, batch, custom; params json req
aps_scenario_kpiKPI value computed per scenario for comparisonscenario_id → aps_scenario req; kpi text req: on_time_pct, total_lateness_h, total_setup_h, utilization_pct, makespan_h, wip_count; value num req
aps_adherenceScheduled against actual per operationscheduled_operation_id → aps_scheduled_operation req; actual_start ts; actual_end ts; start_deviation_min num; reason_code_id → core_reason_code
Step 3

Session 2: One prompt: the eleven tables, their rules and their tests

25 minutes

Why

A rule kept in the table protects every screen, import and scheduler run, including ones not written yet. A calendar exception that ends before it starts, or a published scenario that can be edited, would quietly corrupt every plan built on it. Giving Claude Code the exact column list stops it inventing or dropping a column.

Do this

Paste into Claude Code
On a new branch aps/tables, add this module's own section to docs/spine-map.md, the one shared map (never a separate tables file), with exactly this content, then use it.

## M03 Scheduling tables (from the module specification M03)
Every table also has the standard columns recorded above in this map. "req" means not null. A list after a colon is a check constraint. "→ core_x" means a foreign key to the table docs/spine-map.md maps core_x to. Types: ts = timestamptz, qty, num and money = numeric, json = jsonb.

### aps_resource
Schedulable resource, usually linked to equipment.
- code text req, unique
- name text req
- equipment_id → core_equipment
- resource_type text req: machine, line, labor_pool, tool, vessel, work_center
- capacity_units num req
- efficiency_factor num
- calendar_id → core_calendar
- is_bottleneck bool

### aps_capability
Capability that operations require.
- code text req, unique
- name text req

### aps_resource_capability
What a resource can do and how fast.
- resource_id → aps_resource req
- capability_id → aps_capability req
- rate_per_hour num
- preference int

### aps_calendar_exception
Downtime, extra shifts or holidays per resource.
- resource_id → aps_resource req
- starts_at ts req
- ends_at ts req
- kind text req: unavailable, overtime, planned_maintenance, holiday
- note text

### aps_setup_matrix
Sequence-dependent changeover time between product attributes.
- resource_id → aps_resource req
- attribute_key text req
- from_value text req
- to_value text req
- setup_min num req
- setup_cost money

### aps_scenario
Schedule version: draft what-if or published.
- name text req
- status text req: draft, published, archived
- horizon_start ts req
- horizon_end ts req
- objective_weights json
- solver text req: rules, heuristic, cp_sat, manual
- created_from_id → aps_scenario
- published_at ts
- published_by → core_person

### aps_job
Order to be scheduled within a scenario.
- scenario_id → aps_scenario req
- order_ref_type text req: production_order, planned_order, manual
- order_ref_id uuid
- item_id → core_item
- qty qty
- due_at ts
- release_at ts
- priority int
- status text req: unscheduled, scheduled, late, infeasible

### aps_scheduled_operation
Operation placed on a resource with times.
- scenario_id → aps_scenario req
- job_id → aps_job req
- seq int req
- capability_id → aps_capability
- resource_id → aps_resource
- start_at ts
- end_at ts
- setup_min num
- run_min num
- locked bool
- sequence_on_resource int

### aps_constraint
Additional scenario constraint.
- scenario_id → aps_scenario req
- constraint_type text req: material, labor_skill, tool, max_wait, precedence, batch, custom
- params json req

### aps_scenario_kpi
KPI value computed per scenario for comparison.
- scenario_id → aps_scenario req
- kpi text req: on_time_pct, total_lateness_h, total_setup_h, utilization_pct, makespan_h, wip_count
- value num req

### aps_adherence
Scheduled against actual per operation.
- scheduled_operation_id → aps_scheduled_operation req
- actual_start ts
- actual_end ts
- start_deviation_min num
- reason_code_id → core_reason_code

Then write ONE migration (npx supabase migration new aps_tables) that creates all eleven tables exactly as listed, and:
- codes unique per site; one resource-capability pair once; one setup_matrix row per resource, attribute_key, from_value and to_value;
- capacity_units, rate_per_hour and setup_min not negative; efficiency_factor above 0 and at most 1.5; an exception's ends_at after its starts_at;
- at most one published scenario per site (a partial unique index);
- a trigger that refuses any insert, update or delete of jobs, operations, constraints or KPIs of a scenario whose status is published or archived;
- row-level security on every table with no policies, the touch-row and audit triggers, and each table added to docs/matrix.json with no rights yet.

pgTAP tests in supabase/tests/aps.test.sql proving the database refuses: an unknown resource_type, an exception that ends before it starts, a duplicate resource code, a second published scenario, and a change to an operation of a published scenario. Show me each test failing before its rule exists and passing after.

Do not connect to any Supabase project. Push, open a pull request titled "Scheduling tables", wait for every check, and tell me the result in plain words.

You will see recreated screen

claude — acme-platform
⏺ Edit(docs/spine-map.md)
⎿ Added the section M03 Scheduling tables, 118 lines
1
⏺ Write(supabase/migrations/20261103111500_aps_tables.sql)
+create unique index aps_one_published_per_site
+ on public.aps_scenario (site_id) where status = 'published';
+create trigger aps_operation_frozen before insert or update or delete
+ on public.aps_scheduled_operation for each row execute function public.aps_refuse_if_published();
2
⏺ Bash(npx supabase test db)
⎿ aps.test.sql .. 5 of 5 failed (rules removed on purpose) aps.test.sql .. ok (rules restored)
⏺ Pull request #83 is green. Eleven tables; a published scenario cannot be changed and only one can be published per site. The five refusal tests failed without the rules and pass with them.
The reference file first, then the migration from it, then each rule proven by breaking it.
  1. The column list now lives in the one shared map, in its own section.
  2. Two rules that protect the floor: one published plan, and a published plan nobody can edit.

Check it worked

Pull request Scheduling tables is green; you saw the five tests red then green; no older migration is edited.

Fastest path

Asking for red-then-green in the prompt saves the round trip where you discover a test that could never fail.

If it goes wrong

A screen fails later with "column does not exist"

Say: Rebuild the local database from supabase/migrations only, run supabase db diff, and write any difference as a new migration. We merged ten columns without a migration once; the fresh-database check catches it.

The check went green after a test or CI file changed

Say: Undo every change to tests and CI. Never weaken a check to get to green; stop and explain instead. On our platform an agent that was refused one command used another to do the same thing.

Run minutes of an operationFour boxes: 96 units, an effective rate of 48 an hour from a rate of 60 and an efficiency factor of 0.8, 2 hours, and 120 run minutes. Quantity96 unitsEffective rate60 × 0.8 = 48 an hourHours96 ÷ 48 = 2 hoursRun minutes2 × 60 = 120Quantity ÷ (rate per hour × efficiency factor) × 60 = run minutesOn the nameplate rate alone the same job looks like 96 minutes: 24 minutes of promise the machine cannot keep.
Run minutes on the seeded case. 96 units at an effective 48 an hour (60 × 0.8) take 120 minutes. The nameplate rate alone would say 96.
Step 4

Session 2: Two small seeded cases, tried on the development project

20 minutes

Why

The scheduler in Session 4 is tested against answers you can work out on paper: these two cases are those answers. The tests read them from a fixture with fixed times; the screens read the same cases as seed rows shifted onto today, made up and marked, so they never age and never reach production. Pushing the migrations and seed to the development project yourself proves they work on a real project before the deploy pipeline applies the migrations to production on merge.

Do this

Paste into Claude Code
On the branch aps/tables, write supabase/seeds/scheduling.sql and list it under [db.seed] sql_paths in supabase/config.toml, after the Foundation seed. Never append to supabase/seed.sql, and never seed production. Every row is made up and marked SYNTHETIC: codes start SYN-, names start "SYNTHETIC · ". The seed's day is the next working day after the seed runs, read once, in the site's time zone, so the rows are shifted onto today; it is safe to run twice (a second run leaves the same rows).

One calendar, one shift 08:00 to 17:00 with no breaks. Press SYN-P-03 (machine, capability "stamp", rate 60 per hour, efficiency_factor 0.8, source "SYNTHETIC: not measured" in ext, is_bottleneck true), the only resource with that capability. Setup matrix on attribute "family": A to B 30 minutes, B to A 60, same family 0.
Seed 1 (scenario "SYN Seed setups"): jobs J1, J2, J3, J4 of 96 units, families A, B, A, B, released 08:00, due 17:00.
Seed 2 (scenario "SYN Seed rules"): P 144 units (3 hours) due 11:00, Q 48 units (1 hour) due 12:00, R 96 units (2 hours) due 13:00, all released 08:00, family A.
Three reason codes for late starts (SYN-LATE-MATERIAL, SYN-LATE-TOOL, SYN-LATE-CREW).

Also write the two cases as hand-worked examples with fixed times on a fixed day in tests/fixtures/scheduling-cases.json; Session 4's tests read that fixture, never the seed rows. Add a test that runs the seed twice on an empty database and checks the same rows are there. Push to the same pull request and wait for the checks.

When it is green, push to the development project yourself, in a terminal (not inside Claude Code), pasting the password from the entry Supabase: acme-platform-dev database password:

Terminal or PowerShell
cd ~/code/acme-platform && git fetch && git switch aps/tables && npx supabase link --project-ref tsrqponmlkjihgfedcba
Terminal or PowerShell
npx supabase db push --include-seed
Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/editor

The development project's Table Editor: open aps_job.

That is the first load. After it, reload the made-up rows with npm run seed:dev, never with supabase db reset. Then owner two approves and you merge; the deploy workflow applies the migrations (never the seed) to production.

You will see recreated screen

supabase.com/dashboard/project/tsrqponmlkjihgfedcba/editor
aps_jobaps_resourceaps_scenarioaps_setup_matrix
aps_job
1
scenarioorder_refqtydue_atstatus
SYN Seed setupsSYN-J19617:00unscheduled
SYN Seed setupsSYN-J29617:00unscheduled
SYN Seed rulesSYN-P14411:00unscheduled
The seeded jobs in the development project. Every code says it is made up.
  1. Unscheduled until Session 4's scheduler places them.
  2. Expected until Session 3 adds the access rules.

Check it worked

acme-platform-dev shows the two seeded scenarios with their jobs, the pull request is merged, and the deploy run on main is green.

If it goes wrong

A week later the seeded day is in the past and the Gantt is empty

The seed used fixed dates. Say: Make every seeded time relative to one clock reading at seed time; fixed-date examples belong in tests/fixtures/scheduling-cases.json. Then reload with npm run seed:dev. We hit this: eleven days after seeding, every recent-hours panel was blank.

A later step expects a number the seed does not give

Say: List every count and time a later step expects, and show the seed line that makes it. Fix the seed, not the check. Reviews of five of our modules found this mismatch.

Claude Code offers to run db push for you

Refuse; the deny rule from Session 1 stops it anyway. You run it, on the development project.

Someone suggests supabase db reset --linked to start again

Do not. To start the made-up rows again on the development project, run npm run seed:dev.

Knowledge check

A press has a rate of 50 units an hour and an efficiency factor of 0.8. How many minutes does an order of 200 units take?

Knowledge check

Which describes an infinite-capacity schedule?

References

  1. PlanetTogether: APS frequently asked questions. https://www.planettogether.com/faq
  2. SYMESTIC: what is an APS system. https://www.symestic.com/en-us/what-is/aps-system
  3. ISA: ISA-95 standard, Enterprise-Control System Integration. https://www.isa.org/standards-and-publications/isa-standards/isa-95-standard
  4. Supabase Docs: Testing your database. https://supabase.com/docs/guides/database/testing

Chapter 2 · Session 3

Who may plan, publish and dispatch, and their screens

A published schedule is what the floor is told to do, so who may change and publish it matters. You write the planner, supervisor and operator into the role matrix, generate the access rules from it, prove every refusal, and build the Gantt for the planner and the dispatch list for the operator's phone.

20 min2 steps3 roles, 2 machine accounts

By the end of this chapter you can

  • Add the module's roles, scopes and rights to docs/matrix.json and regenerate the access rules and route list.
  • Prove that only the planner publishes and nobody edits a published plan.
  • Build the Gantt, scenario compare and a phone dispatch list whose Start and Finish taps work offline and never count twice.
RoleScopeMayMay never
PlannerOwn siteResources, calendars, setup matrix; build, copy, compare and publish scenarios; lock operationsEdit a published scenario
SupervisorOwn areaRead the published plan; record downtime and extra shifts as exceptions; give reasons for late startsPublish, or change the plan
OperatorOwn areaSee the dispatch list; tap Start and FinishOpen set-up or the Gantt
aps_importer (machine)Its import onlyInsert resources, capabilities, rates and open jobsRead, change or delete anything; publish
Scheduler run (machine)Draft scenariosPlace operations, set job status and KPIs in a draftTouch a published scenario
Step 5

Session 3: The roles in the matrix, rules generated, refusals proven

30 minutes

Why

If rights are written by hand they drift from what was agreed; if they are generated from docs/matrix.json, the database, the routes and the menus always agree. The two rules that matter most here, only the planner publishes and nobody edits a published plan, must be proven by tests that try and fail.

Do this

Paste into Claude Code
Read docs/matrix.json, scripts/gen-policies.mjs, scripts/gen-routes.mjs, lib/access/routes.ts and docs/spine-map.md with its M03 section. Before writing any route code, read the relevant guide in node_modules/next/dist/docs/ (this Next.js version keeps request middleware in proxy.ts).

On a new branch aps/access, add to docs/matrix.json:
1. Roles planner, supervisor, operator; machine accounts aps_importer and aps_scheduler. In a separate migration create both as database logins with NOLOGIN, no BYPASSRLS, owning nothing; I set their passwords myself on each project, and you list them by name (never a value) in docs/KEYS.md.
2. Scopes: planner by site; supervisor and operator by area (the area equipment their membership names).
3. Rights from nothing: planner reads every aps_ table and the lookups, writes master data and draft scenarios, publishes; supervisor reads the published scenario and adherence in their area, inserts calendar exceptions for their area's resources, sets reason_code_id on late adherence rows; operator reads the published operations of their area and inserts and updates their own aps_adherence rows (actual_start, actual_end only); aps_scheduler updates operations, job status and KPIs of draft scenarios only; aps_importer only inserts: resources, capabilities, resource capabilities, setup matrix rows, a draft scenario and its jobs; it never reads, updates or deletes. Nobody gets delete.
4. Screens and routes: /scheduling/resources and /scheduling/gantt and /scheduling/compare (planner; Gantt read-only for supervisor), /scheduling/adherence (planner, supervisor), /scheduling/dispatch (operator, supervisor), /api/scheduling/run, /api/scheduling/publish (planner only), /api/scheduling/adherence (operator). No import page or route: real records arrive only through the import workflow in Session 6.

Run node scripts/gen-policies.mjs and node scripts/gen-routes.mjs (it writes lib/access/routes.ts). Write docs/aps-rights-walk.md listing every right Sessions 4 to 6 need, with a test that fails if any is not allowed. Add to supabase/tests/access.test.sql: one allowed and one refused per role and table; nobody but the planner publishes; nobody updates an operation of a published scenario; a supervisor of another area cannot see this area's adherence; aps_importer cannot read anything, adherence included; for every permitted update, the row really changed; a signed-out request to every new screen and route is refused.

Push, open a pull request titled "Scheduling access", wait for every check, and tell me the result in plain words. If a check fails, fix the matrix or the code, never the test.

You will see recreated screen

claude — acme-platform
⏺ Write(docs/matrix.json)
+"operator": { "scope": "area", "aps_adherence": { "insert": true, "update": ["actual_start", "actual_end"] } },
1
⏺ Bash(node scripts/gen-policies.mjs)
⎿ Wrote supabase/migrations/20261110150000_policies_aps.sql (88 policies)
⏺ Bash(npx supabase test db)
⎿ access.test.sql .. 164 tests, ok aps-rights-walk .. 41 lines, all allowed
⏺ Pull request #84 is green. Only the planner can publish; an update to an operation of the published scenario is refused for every role, the planner included. I changed no test.2
The matrix is the file you decide; the rules are generated from it and the tests try every refusal.
  1. An operator may write only two columns on their own adherence rows.
  2. Even the planner cannot edit a published plan: they copy it.

Check it worked

Pull request Scheduling access is green, docs/aps-rights-walk.md passes, and there is a refused test for every role.

If it goes wrong

A Finish tap reports success but actual_end stays empty

The operator's read rule does not cover the row after the change, so the update finds nothing. Say: Make the operator's read rule cover their adherence rows before and after the update, and test that the row really changed. We hit this in three of our modules.

A supervisor can publish because they are signed in

Signed in is not allowed. Say: Add a refused-role test for every role on /api/scheduling/publish. On our platform any signed-in user could delete a whole site.

The generator refuses: a table is missing from the matrix

Correct. Add the row with no rights, then grant only what the walk needs.

Step 6

Session 3: The Gantt, the comparison and the phone dispatch list

45 minutes

Why

The planner judges a schedule by looking at it, so the Gantt must show load and conflicts honestly. The operator's dispatch list is where the plan meets the floor; if Start and Finish do not work in a dead spot, or count twice, adherence numbers become fiction. Building both against the seed lets the planner and an operator try them before the scheduler exists.

Do this

Paste into Claude Code
Read the operator, supervisor and manager screens from Foundation Sessions 12 and 13, including how the operator screens queue taps offline, and follow them. Read node_modules/next/dist/docs/ before adding routes; check proxy.ts still denies every route not in lib/access/routes.ts.

On a new branch aps/screens, against the seed on the development project:
1. /scheduling/resources (planner): resources, rates, efficiency factor with its source, calendar exceptions, setup matrix.
2. /scheduling/gantt (planner; read-only for supervisor): a row per resource, a bar per operation with setup shown separately, closed hours shaded, a resource load view; any overlap or bar outside open hours shown in red with its reason; locked operations marked.
3. /scheduling/compare (planner): two scenarios side by side with their six KPIs.
4. /scheduling/dispatch (operator, phone first): the published operations of my area in start order, one card each (part, quantity, press, planned start and end, setup); big Start and Finish buttons. Each tap records the phone's time and a row id made on the phone, is queued offline, and is sent until confirmed; the same id sent twice makes one row; the server computes start_deviation_min.

44 px tap targets, 16 px fields, 15 px text, no sideways scroll at 360 and 390 px. Empty lists say "Nothing scheduled", never made-up rows. Screen tests for each role, a refused role per screen, and a test that sends the same Start twice and finds one row.

Push, open a pull request titled "Scheduling screens", wait for every check including the preview, and give me the preview address and the demo login for each role.
Open

https://github.com/acme-ops/acme-platform/pulls

Open the pull request and its Vercel preview; try the dispatch list on your phone in flight mode, then reconnect.

You will see recreated screen

acme-platform-git-aps-screens-acme-ops.vercel.app/scheduling/dispatch
SYN-P-03 · today
SYN-J1 · 96 parts08:00–10:00 · setup none
Finish2
SYN-J3 · 96 parts10:00–12:00 · setup none
Start
The dispatch list on a phone. Taps made with no signal wait on the phone and are sent once.
  1. The tap is kept on the phone and sent when the signal returns.
  2. Sending twice makes one row: the id was made on the phone.

You will see recreated screen

acme-platform-git-aps-screens-acme-ops.vercel.app/scheduling/gantt
SYN Seed setups · draft
Resource08:0012:0016:00Load
SYN-P-03–––0%
The planner's Gantt, before the scheduler exists: the seeded jobs are unscheduled, and the chart says so instead of drawing them anywhere.
  1. No made-up bars: an empty plan is shown as empty.

Check it worked

The preview opens on your phone; a Start tapped in flight mode arrives once after reconnecting; an operator sent to /scheduling/gantt is refused; the screen tests are green.

If it goes wrong

A Start tapped twice makes two adherence rows

Say: Make the row id on the phone and insert with on conflict do nothing on that id; test the same tap sent twice.

Every adherence row shows the same operator

The page sent the person and the server trusted it. Say: Take the operator from the signed-in session on the server. We hit this: every record said it was created by the founder.

A link on the Gantt opens a blank 404

Say: Start the build, sign in as each role, visit every page and link on the four screens, and report every 404. We once had 130 links pointing nowhere.

Knowledge check

Who may change an operation of a published scenario?

Knowledge check

An operator taps Start twice with no signal, and both taps arrive later. What should the database hold?

References

  1. Supabase Docs: Row Level Security. https://supabase.com/docs/guides/database/postgres/row-level-security
  2. W3C: Web Content Accessibility Guidelines (WCAG) 2.2. https://www.w3.org/TR/WCAG22/
  3. PostgreSQL Documentation: INSERT, including ON CONFLICT. https://www.postgresql.org/docs/current/sql-insert.html

Chapter 3 · Session 4

A finite scheduler, end to end

You predict the answers on paper first, then Claude Code builds the scheduler to match them: finite capacity forward and backward, four dispatch rules, changeover-aware sequencing from the setup matrix, locks that survive a re-run, and scenarios you copy, compare and publish. Three of its tests are the module's definition of done.

30 min3 stepsThe three checks that define done

By the end of this chapter you can

  • Predict the seeded cases on paper and turn the predictions into tests.
  • Have Claude Code build a deterministic finite scheduler with EDD, SPT, CR and FIFO, proven never to overload a resource.
  • Prove that changing the setup matrix changes the sequence as predicted, and that locks survive a re-run.
  • Copy, compare and publish a scenario, with one published plan and an event for other modules.
RuleWhich job goes firstGood at
EDD (earliest due date)The one due soonestKeeping the worst lateness small
SPT (shortest processing time)The shortest jobFinishing the most jobs soonest
CR (critical ratio)Lowest of time left to due ÷ work leftShowing which job is most at risk
FIFO (first in, first out)The earliest releaseFairness and simplicity

The production-planning body of knowledge the specification points to (ASCM's CPIM) covers these dispatching rules alongside capacity planning [1]. No rule wins every measure, which is why the seeded cases test them against each other.

Dispatch rules on the seeded caseTwo timelines from 08:00 to 14:00. Earliest due date runs P, Q, R and R is one hour late. Shortest processing time runs Q, R, P and P is three hours late. 08:0009:0010:0011:0012:0013:0014:00EDDPQREarliest due date first: R ends 14:00, due 13:00. Total lateness 1 hour.SPTQRPShortest processing time first: P ends 14:00, due 11:00. Total lateness 3 hours.Due times: P 11:00, Q 12:00, R 13:00. Both rules finish at 14:00 and have two of three jobs on time.
Seed 2 under two rules, to scale. EDD: R ends 14:00, 1 hour late in total. SPT: P ends 14:00, 3 hours late.
Step 7

Session 4: Predict on paper, then build the finite scheduler

35 minutes

Why

A scheduler is only trustworthy if you can say in advance what it will do. Writing the answers on paper first and handing them to Claude Code as tests means the code is judged against your plant sense, not its own. The test that tries hundreds of random cases and finds no overloaded press is the first check that defines done.

Do this

On paper, with this chapter: Seed 2 under EDD (P 08:00–11:00, Q 11:00–12:00, R 12:00–14:00, total lateness 1 hour) and under SPT (Q, R, P; P ends 14:00, 3 hours late); backward from the due dates, P would need to start at 07:00, before the shift, so it is infeasible. Then write docs/scheduling-rules.md with the planner: the start tolerance in minutes that counts as on time, and the longest wait for a scheduler answer they will accept.

Paste into Claude Code
Read the M03 section of docs/spine-map.md, docs/scheduling-rules.md and tests/fixtures/scheduling-cases.json. On a new branch aps/scheduler:

1. lib/scheduling/ (plain TypeScript, no database calls inside the algorithm): run minutes = qty / (rate_per_hour × efficiency_factor) × 60; forward and backward finite scheduling on each resource's calendar and exceptions; jobs never overlap on a resource and never sit outside open hours; a job that cannot fit is marked late or infeasible with the reason; dispatch rules EDD, SPT, CR, FIFO as sort keys with ties broken by job code. Same input, same plan, every time.
2. /api/scheduling/run (planner): loads a draft scenario, runs as aps_scheduler, writes operations, job status and the six KPIs, and records how long it took.
3. Tests that read tests/fixtures/scheduling-cases.json, with my predictions written into it as the expected answers: Seed 2 EDD gives P 08:00–11:00, Q 11:00–12:00, R 12:00–14:00 and total lateness 1 hour; SPT gives total lateness 3 hours; backward marks P infeasible with the reason "starts before the shift opens"; Seed 1 run minutes are 120. And a property-based test (fast-check): for 500 random sets of resources, calendars, exceptions and jobs, no resource ever has overlapping operations or work outside its open hours.
4. Time the run on the seeds and on generated sets of 10, 100 and 1,000 jobs, and write the seconds into docs/scheduling-rules.md beside the planner's limit.

Show me the property test failing on a scheduler that ignores calendars, then passing. Push, open a pull request titled "Finite scheduler", wait for every check, and tell me the result in plain words.

You will see recreated screen

claude — acme-platform
⏺ Bash(npx vitest run tests/scheduling)
⎿ ✓ seed 2 EDD: P 08:00-11:00, Q 11:00-12:00, R 12:00-14:00, lateness 1h ✓ seed 2 SPT: lateness 3h ✓ backward: P infeasible (starts before the shift opens) ✓ property: 500 random plants, no overload, no work outside open hours
1
⏺ Bash(node scripts/time-scheduler.mjs)
⎿ 10 jobs 0.02s · 100 jobs 0.3s · 1000 jobs 4.1s (limit: 30s)
2
⏺ Pull request #85 is green. With calendars ignored, the property test found an overload in 3 of 500 cases; with them, none. The 1,000-job run takes 4.1 seconds against the planner's 30-second limit.
Your paper answers are now tests; the property test tries hundreds of plants that do not exist.
  1. The first check that defines done: no overload, found by random cases, not by the three you thought of.
  2. Latency to answer, measured against the planner's own limit.

Check it worked

Pull request Finite scheduler is green; your paper answers for Seed 2 are its tests; the property test was shown failing then passing; the timings are in docs/scheduling-rules.md.

If it goes wrong

The Gantt shows two bars overlapping on one press

The chart is drawing something the scheduler did not place, or the scheduler is not finite. Say: Add this case as a test that fails, then fix the scheduler, never the test.

Running twice gives two different plans

The scheduler is not deterministic (a tie broken at random, or an unordered list). Say: Find every tie and break it by job code; add a test that runs the same input twice and compares.

A test was green from the start

Say: Break the scheduler on purpose (ignore calendars) and show me the test fails, then restore it. Our page-presence check reported 350 present and 0 absent for weeks because it could only ever say yes.

The setup matrixTwo small tables of changeover minutes between product family A and family B. Seed 1 has A to B 30 and B to A 60. In the test A to B is changed to 90. Seed 1 (aps_setup_matrix, attribute family)to Ato Bfrom A0 min30 minfrom B60 min0 minThe test: A to B becomes 90to Ato Bfrom A0 min90 minfrom B60 min0 minSetup depends on the pair: going A to B costs a different time from going B to A.
The setup matrix for Seed 1. A to B 30 minutes, B to A 60. The test changes A to B to 90.
Same four jobs, two ordersTwo timelines from 08:00 to 18:00. Running families A, B, A, B needs 120 minutes of setup and ends at 18:00, after the shift closes. Running A, A, B, B needs 30 minutes of setup and ends at 16:30. 08:0009:0010:0011:0012:0013:0014:0015:0016:0017:0018:00Order J1, J2, J3, J4 (families A, B, A, B)J1 A30J2 B60 minJ3 A30J4 BSetup 30 + 60 + 30 = 120 minutes. J4 ends 18:00, an hour after the shift closes.Order J1, J3, J2, J4 (families A, A, B, B)J1 AJ3 A30J2 BJ4 BSetup 30 minutes. The last job ends 16:30, inside the shift.shift ends 17:00
Same jobs, different order, to scale. Alternating A, B, A, B costs 120 minutes of setup and ends at 18:00; grouping costs 30 and ends at 16:30.
A locked operationTwo timelines from 08:00 to 14:00. Without a lock EDD runs P, Q, R. With Q locked from 10:00 to 11:00, R runs first from 08:00 to 10:00 and P runs from 11:00 to 14:00. 08:0009:0010:0011:0012:0013:0014:00No lockPQRQ lockedRQ lockedPEDD alone: R is one hour late.Q is pinned at 10:00 to 11:00. R takes the gap before it; P does not fit there and ends 14:00, three hours late.Run it again on the same input: the same plan, with Q where the planner put it.
Q locked at 10:00 to 11:00. R fills the gap before it; P ends at 14:00, three hours late. Running again gives the same plan.
Step 8

Session 4: Setups that change the sequence, and locks that survive a re-run

30 minutes

Why

Changeover time is where a good sequence earns its keep, so the sequencer must react to the setup matrix exactly as you predict; if it does not, either the matrix or the code is wrong, and now you can tell which. Planners override for reasons the data does not know, and if a re-run moves their locked work, they stop trusting the tool. These are the second and third checks that define done.

Do this

On paper: Seed 1 in arrival order costs 30 + 60 + 30 = 120 minutes of setup and ends at 18:00, past the shift. Grouped (J1, J3, J2, J4) it costs 30 and ends 16:30. Change A to B to 90: grouped A first now ends 17:30, past the close, while J2, J4, J1, J3 costs 60 and ends at 17:00 exactly. Seed 2 with Q locked at 10:00–11:00 under EDD: R 08:00–10:00, Q, then P 11:00–14:00.

Paste into Claude Code
On a new branch aps/sequence:
1. A sequencer: try each job first, then always take the job with the smallest setup from the one just placed (ties: earlier due date, then lower job code); keep the order with the smallest total setup (ties: lower first job code). setup_min is written on the operation when it is placed, so a later matrix change never rewrites a published plan. The first job on a resource needs no setup.
2. Locks: a locked operation keeps its resource and times on every re-run and everything else is planned around it; a lock in closed hours or overlapping another lock is refused with the reason.
3. Tests from my predictions, added to tests/fixtures/scheduling-cases.json: Seed 1 grouped gives J1, J3, J2, J4, 0.5 setup hours, ends 16:30. With A to B set to 90 in the test, the order becomes J2, J4, J1, J3 with 1.0 setup hours, ending 17:00. Seed 2 with Q locked at 10:00-11:00 under EDD gives R 08:00-10:00, Q 10:00-11:00, P 11:00-14:00; a second run gives the identical plan. A property test: for 300 random scenarios with random locks, every locked operation is unchanged after a re-run.

Show each new test failing before the change and passing after. Push, open a pull request titled "Setups and locks", wait for every check, and tell me the result in plain words.

You will see recreated screen

claude — acme-platform
⏺ Bash(npx vitest run tests/scheduling/sequence.test.ts)
⎿ ✓ seed 1 grouped: J1 J3 J2 J4 · setup 0.5h · ends 16:30 ✓ A→B = 90: J2 J4 J1 J3 · setup 1.0h · ends 17:00
1
⏺ Bash(npx vitest run tests/scheduling/locks.test.ts)
⎿ ✓ seed 2, Q locked: R 08:00-10:00, Q 10:00-11:00, P 11:00-14:00 ✓ re-run identical ✓ property: 300 random scenarios, locks unchanged
2
⏺ Pull request #86 is green. Changing one number in the setup matrix changed the sequence and the setup-hours KPI exactly as you predicted.
The second and third checks that define done, each matching your paper prediction.
  1. Predict, change one number, check: the matrix and the sequencer agree.
  2. Locks survive every re-run, in your case and in 300 random ones.

Check it worked

Pull request Setups and locks is green, and its tests are your paper predictions.

If it goes wrong

With A to B at 90 the sequencer still picks J1 first

Either the test changed the matrix in the wrong place, or the sequencer reads a cached matrix. Say: Show me the setup values the sequencer used for this run, and why it chose J1.

A planner's lock moved after a run

Stop and add the case as a failing test. The third pitfall is exactly this; it must never reach the floor.

Scenario to dispatchFour steps: a draft scenario, a copy, a compare of KPIs and publish. Publishing archives the old plan, writes events to the outbox and makes the dispatch list appear. Draft scenarioinputs and a ruleCopycreated_from_id setComparesix KPIs side by sidePublishone transactionOld plan archivedonly one published at a timeEvents in the outboxaps.scenario.publishedaps.job.late_predictedDispatch listoperators see their areaA published scenario is read-only: change it by copying it.
From draft to dispatch. Copy to try, compare to decide, publish to hand over. One published plan at a time; the old one is archived in the same step.
Step 9

Session 4: Copy, compare and publish a scenario

25 minutes

Why

Planners need to ask "what if we add Saturday?" without touching the plan the floor is running. Publishing must be all or nothing: the new plan becomes the one, the old is archived, and other modules are told, in one step, so the floor never sees half a plan.

Do this

Paste into Claude Code
On a new branch aps/publish:
1. Copy a scenario: a new draft with created_from_id set, all jobs, operations (locks kept), constraints and KPIs copied; the original untouched.
2. /scheduling/compare shows the six KPIs of two scenarios side by side.
3. /api/scheduling/publish (planner only), in one transaction: refuse if any resource is loaded beyond capacity; set status published with published_at and published_by from the session; archive the previously published scenario; write status history; write aps.scenario.published and one aps.job.late_predicted per late job to core_event_outbox.
4. Tests: a copy leaves the original unchanged; publish archives the old one and leaves one published; a scenario with an overload cannot be published; the outbox holds the events; publish by a supervisor is refused.

Push, open a pull request titled "Scenarios and publish", wait for every check, and tell me the result in plain words.

Then try it on the preview: copy SYN Seed rules, switch the copy to SPT, run both, compare, and publish the better one.

You will see recreated screen

acme-platform-git-aps-publish-acme-ops.vercel.app/scheduling/compare
Compare scenarios
1
KPISYN Seed rules · EDDCopy · SPT
On time %6767
Total lateness (h)1.03.0
Total setup (h)0.00.0
Makespan (h)6.06.0
Publish SYN Seed rules · EDD2
Scenario compare on the preview: the planner decides from numbers, not from a feeling about the chart.
  1. Six values per scenario, computed by the run, never typed.
  2. Publishing archives the current plan in the same step.

Check it worked

Pull request Scenarios and publish is green; on the preview, exactly one scenario is published and the outbox holds aps.scenario.published.

If it goes wrong

Two scenarios show as published

The one-published index or the transaction is missing. Say: Show me the publish transaction and the partial unique index; add a test that publishes twice.

Publish shows success but the floor still sees the old plan

Say: After publishing, read the published scenario back from the database and show its id; if it did not change, show an error. On our platform a button reported success while nothing had happened.

Knowledge check

Three jobs: P 3 h due 11:00, Q 1 h due 12:00, R 2 h due 13:00, all from 08:00. Under EDD, how late is R?

Knowledge check

Why does a property-based test, not three hand-picked cases, prove the scheduler never overloads a press?

References

  1. ASCM: CPIM, Certified in Planning and Inventory Management. https://www.ascm.org/learning-development/certifications-credentials/cpim/
  2. Fabrico: what is advanced planning and scheduling (APS). https://www.fabrico.io/blog/what-is-advanced-planning-and-scheduling-aps/
  3. Google OR-Tools: CP-SAT solver. https://developers.google.com/optimization/cp/cp_solver

Chapter 4 · Sessions 5 and 6

Move resources and orders, and switch the old tool off

Resources, routings and open orders come from your ERP or MRP export; old schedules rarely need to move. The import is proven on made-up data, rehearsed once on the development project with a copy IT has approved, and run into production through the pipeline at the start of a side-by-side week. Then the measured week decides the cutover.

30 min5 stepsEnds with the module gate

By the end of this chapter you can

  • Build an import that is safe to run twice and refuses a bottleneck with no measured efficiency source.
  • Rehearse it on the development project with a copy IT approved in writing, and remove the rehearsal the same day.
  • Import into production through import-scheduling.yml, started by a person from main for an approved export, run a week side by side, and compare on-time delivery, changeover hours and adherence.
  • Feed measured performance back into capacity, cut over, and record the saving from invoices.
Nameplate and measured ratesTwo pairs of bars to scale. A nameplate rate of 60 an hour against a measured 48 an hour, and 96 minutes for 96 units on the nameplate against 120 minutes in practice. Rate (units an hour)Nameplate60Measured: 60 × 0.848Time for 96 units (minutes)Scheduled on nameplate96What the machine takes120The 24-minute gap is a promise the schedule cannot keep.
The same order, two answers. On the nameplate rate 96 units take 96 minutes; at the measured 80 percent they take 120.

Scheduling has no regulation of its own; the risk is credibility. If capacity data is wrong, the schedule promises dates that cannot be kept and the floor learns to ignore it. So efficiency factors come from measured OEE (availability × performance × quality, as ISO 22400-2 defines the KPIs [1]), each with its source, period and date. A bottleneck with no measured source is a known risk, written down, never a guess.

KPIDefinitionCompared in Session 6
Schedule adherenceOperations started within tolerance ÷ operations scheduledNew module only (the old tool rarely records it)
On-time delivery (planned)Jobs finishing on or before due ÷ jobsOld against new
Changeover hoursSum of setup time per period and resourceOld against new
Bottleneck utilisationLoad ÷ available time on constraint resourcesOld against new
Key or secretWhat it unlocksWhere it livesWho holds itNever
aps_importer password (development)Signing in as the insert-only import login on acme-platform-dev; listed by name in docs/KEYS.mdPassword manager; GitHub secret APS_IMPORTER_PASSWORD_DEVpat@acme.com, sam@acme.comNever in a file, a chat or Claude Code
aps_importer password (production)Signing in as the insert-only import login on acme-platform-prod, until it is set to NOLOGIN at cut-over; listed by name in docs/KEYS.mdPassword manager; GitHub secret APS_IMPORTER_PASSWORD_PRODpat@acme.com, sam@acme.comNever on a laptop outside the password manager
The ERP or MRP exportResources, routings and open orders, with customer namesA private folder, then the private Storage bucket imports; its sha256 and counts in docs/imports/scheduling-approved.mdThe plannerNever in the repository, a test, or a chat
Step 10

Session 5: The import, built and tested on a made-up export

35 minutes

Why

An import that cannot run twice, or that writes when you only meant to look, makes the cutover guesswork. A dry run with a report of every row it cannot map, a refusal to load a bottleneck without a measured efficiency source, and a refusal of any export nobody approved mean real data only ever meets a script that has already been reviewed and proven on made-up data.

Do this

First, with the planner, write docs/aps-import-map.md: the export's columns, how ERP work centres map to resources, routings to capabilities and rates, and orders to jobs; and, for each bottleneck, its measured OEE with source and period (or "not measured").

Paste into Claude Code
Read docs/aps-import-map.md, the M03 section of docs/spine-map.md and docs/matrix.json. On a new branch aps/import:

1. scripts/import/aps-import.mjs: reads one export file (a zip of the export's CSV files), connects as the database login aps_importer with the password from the environment variable APS_IMPORTER_PASSWORD (never printed), and inserts resources, capabilities, resource capabilities with rates, setup matrix rows and open orders as jobs in a new draft scenario named "Imported <date>". It only inserts: rows that already exist (same code, same order number) are skipped with on conflict do nothing and listed, never read or overwritten, so a second run adds nothing. A resource marked bottleneck with no measured efficiency source is refused and listed. Every row carries ext.import_run.
   --dry-run writes a report (counts per kind, every row it cannot map) and changes nothing.
2. supabase/snippets/aps-remove-run.sql, for the development project only: deletes only the rows whose ext.import_run is the run id I type in, and prints what it removed. I paste it into that project's SQL editor myself; nothing runs it automatically.
3. A CI test that fails if any bottleneck resource has no measured efficiency source in ext.
4. tests/import/ on a made-up export (SYN- names): dry run changes nothing; counts match; second run adds nothing; unmeasured bottleneck refused; an export whose sha256 is not approved is refused; a count that differs from the approved counts fails the run; the removal snippet removes only its own run.
5. .github/workflows/import-scheduling.yml: started by hand only (workflow_dispatch) and refusing to run from any branch but main; inputs target (development or production) and dry_run. It downloads the export from the private Storage bucket imports of the target and computes its sha256; it refuses unless that sha256 and the expected count per kind are recorded for that target in docs/imports/scheduling-approved.md on main; it runs the script with APS_IMPORTER_PASSWORD_DEV or APS_IMPORTER_PASSWORD_PROD; it fails on any count mismatch (rows in the export must equal the approved counts, and imported plus skipped must equal the rows in the export); it writes the counts to the job summary and uploads the report as an artifact. No GitHub environment with required reviewers. Never print a secret.

Push, open a pull request titled "Scheduling import", wait for every check, and tell me the result in plain words. Do not run the workflow.

You will see recreated screen

claude — acme-platform
⏺ Bash(npx vitest run tests/import)
⎿ ✓ dry run changes nothing ✓ counts match ✓ second run adds 0 rows ✓ bottleneck without measured source refused ✓ unapproved sha256 refused ✓ count mismatch fails the run
1
⏺ Pull request #87 is green. The workflow is manual only, runs only from main, and I did not run it. It refuses any export whose sha256 and counts are not in docs/imports/scheduling-approved.md on main. It needs APS_IMPORTER_PASSWORD_DEV and APS_IMPORTER_PASSWORD_PROD, which you type on GitHub yourself.
The import, proven on made-up data; the workflow waits for a person and an approved export.
  1. The refusal that keeps nameplate rates out: a bottleneck must have a measured source.

Check it worked

Pull request Scheduling import is green and merged; the workflow's only trigger is workflow_dispatch, it refuses any branch but main, and it reads the approved sha256 and counts from docs/imports/scheduling-approved.md.

If it goes wrong

Claude Code asks for the importer password to test

Refuse. Tests use the made-up export and CI's own throwaway database; you type real passwords only into GitHub's secrets page and the project's SQL editor.

Claude Code suggests a GitHub environment with required reviewers

Say: No environments with required reviewers; the reviewed pull request that records the sha256 is the approval. On the Team plan they are not available for private repositories.

The planner has no measured OEE for a bottleneck

Measure one week by hand tally (planned time, run time, count, good count) before Session 6, or write it as a known risk and keep that press's factor at what the planner can defend.

Step 11

Session 5: Rehearse the import on the development project

25 minutes

Why

The first run against real data finds what made-up data could not: a work centre with no calendar, a routing with no rate, an order for a part that is not in the spine. Finding them on the development project, with a copy IT has approved in writing, costs nothing; removing the rehearsal the same day keeps that project made-up only.

Do this

Ask IT to approve one copy of the export for the rehearsal, in writing, redacted where it holds personal data (people's names on orders or crews). Work out its fingerprint in a terminal (on Windows, Get-FileHash in PowerShell):

Terminal (Mac)
shasum -a 256 ~/private/aps-export.zip
Paste into Claude Code, after filling the <...> parts
On a new branch aps/import-approval-dev, create docs/imports/scheduling-approved.md with a section "development rehearsal": export file aps-export.zip, sha256 <paste the value>, expected counts <resources, capabilities, rates, setup rows, open orders>, IT's written approval for one rehearsal on acme-platform-dev given on <date> by <role>, redacted where it held personal data, and a line "removed on:" left empty. Open a pull request titled "Scheduling: approve rehearsal export".

Owner two approves the pull request and you merge it. On the development project, set the import login's password yourself in the SQL editor (alter role aps_importer login password '…', the value from the password manager), then:

Open

https://github.com/acme-ops/acme-platform/settings/secrets/actions

If missing: new secret APS_IMPORTER_PASSWORD_DEV, the value only.

Open

https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/storage/buckets

Upload the approved copy to the private bucket imports.

Open

https://github.com/acme-ops/acme-platform/actions/workflows/import-scheduling.yml

Run workflow from main: target development, dry_run true; read the summary; then dry_run false.

The same day: paste supabase/snippets/aps-remove-run.sql with the run id into the development project's SQL editor, delete the file from the bucket, and record the date on the "removed on:" line through a pull request.

You will see recreated screen

github.com/acme-ops/acme-platform/actions/workflows/import-scheduling.yml
import-scheduling · target development · dry_run false
2
KindApprovedIn exportImportedSkipped
Resources1414131
Rates5252520
Open orders2362362360
Skipped: 1WC-PRESS-06 marked bottleneck, no measured efficiency source.3
The rehearsal's summary. Counts decide, not the green tick.
  1. It ran only because the export is the approved one.
  2. Approved, in the export and imported plus skipped must all agree, or the run fails.
  3. The guard working: measure it, record the source, run again.

Check it worked

Counts agree with the approved counts with every skip explained; a draft run of the imported scenario places every job with no overload; the same day the rehearsal rows are removed, the file is deleted from the bucket, and the date is recorded in docs/imports/scheduling-approved.md.

If it goes wrong

The run refuses: sha256 not approved

The file in the bucket is not the one recorded on main (a re-export changes it). Record the new value through a pull request owner two approves, or upload the approved file.

The run fails at sign-in although the secret exists

The value is probably wrong: on our Academy a key's value was its own name, pasted by mistake. Paste the value only, never NAME=value.

The imported scenario has jobs marked infeasible

Read each reason. Usually a calendar is missing or a due date is already past; fix the map or the calendar, not the scheduler.

Step 12

Session 6: Import into production through the pipeline, and start the side-by-side week

25 minutes, then a week

Why

Real resources and orders reach production only through reviewed code that a person starts from main, for an export whose fingerprint and counts were approved in a reviewed pull request, never from a laptop, an upload page or an agent. Importing at the start of the side-by-side week means both schedules plan the same orders on the same Monday, so the week's comparison is fair.

Do this

On the Monday the old tool publishes its plan: take a fresh export, work out its sha256, and add a "production" section to docs/imports/scheduling-approved.md (file, sha256, expected counts, date) through a pull request; owner two approves and you merge. Set aps_importer's password on production yourself in its SQL editor. Then:

Open

https://github.com/acme-ops/acme-platform/actions/workflows/deploy.yml

Check the latest deploy on main is green, so production has every migration.

Open

https://github.com/acme-ops/acme-platform/settings/secrets/actions

If missing: APS_IMPORTER_PASSWORD_PROD, the value only.

Open

https://supabase.com/dashboard/project/abcdefghijklmnopqrst/storage/buckets

Production Storage: upload the export to the private bucket imports.

Open

https://github.com/acme-ops/acme-platform/actions/workflows/import-scheduling.yml

Run workflow from main: target production, dry_run true, then false, then false once more (it must add nothing).

Open

https://acme-platform.vercel.app/scheduling/gantt

As the planner: run the imported draft, check no overload, and publish it for the first scope.

You will see recreated screen

https://acme-platform.vercel.app/scheduling/gantt
Imported 2026-11-23 · draft
ResourceLoadLate jobs
WC-PRESS-0394%2
WC-PRESS-0688%0
Publish2
The planner publishes the imported plan beside the old one. Both plan the same orders this week.
  1. The first check that defines done, on real orders.
  2. Only the planner sees this button; the old published plan, if any, is archived in the same step.

Check it worked

The run's sha256 matched the approved production entry, production counts equal the approved counts, a second run added nothing, and the imported scenario is published with no resource over capacity. Write the counts in docs/cutover.md.

If it goes wrong

The run fails with "relation does not exist"

Production is missing a migration. Check the deploy run and the daily freshness check from Session 11; fix the deploy, never apply by hand. Our production database once fell nine migrations behind main.

The run fails on a count mismatch

Do not edit the approved counts to make it pass. Read the report, find which rows are missing or extra, fix the export or the map, and record the new file through a reviewed pull request.

Operators see no dispatch list

Check their membership names the area that the resources sit under; the access rules scope by area.

The adherence loopSix boxes in a loop: the published schedule, the dispatch list, start and finish taps, adherence rows, reasons and measured rates, and capacity updated for the next schedule. Published scheduleaps_scenarioDispatch listone card per operationStart and Finish tapson the operator's phoneCapacity updatedefficiency_factor, with sourceReasons and ratesreason codes, measured outputaps_adherence rowsactual times, deviationThe next run of the scheduler uses what the floor really did, not what the nameplate says.
The adherence loop. Taps on the floor, reasons from the supervisor, measured output, and a corrected efficiency factor for the next run.
Step 13

Session 6: Compare the week, and feed what you measured back

30 minutes

Why

A week of both schedules, measured the same way, is the evidence for switching. Comparing on-time delivery, changeover hours and bottleneck load, and reading adherence with its reasons, shows whether the new plan is better and whether the floor followed it. Feeding measured output back into the efficiency factors is what keeps the next week's promises honest.

Do this

Paste into Claude Code, after replacing the <...> part
On a new branch aps/cutover, write docs/cutover.md from what I give you:
1. Old against new for the week: planned on-time delivery, changeover hours per resource, bottleneck utilisation, each with its source (the old tool's report name; the new module's query). Explain every difference I give you; where I wrote "unexplained", say we are not ready.
2. Schedule adherence from the new module: operations started within the tolerance in docs/scheduling-rules.md ÷ operations scheduled, and the late starts by reason code.
3. The three checks that define done, run on the deployed demo address with date and who ran them: no overload in any published scenario (property test), the setup-matrix prediction, locks kept on re-run.
4. Each resource whose starts or finishes ran consistently late: its measured output this week against its efficiency_factor, and the new factor with its source and period. Then update those factors through the planner's resources screen, never by hand in the database.

My figures:
<paste the old tool's figures, the new module's figures and the check results>

Open a pull request titled "Scheduling cutover evidence".

You will see recreated screen

github.com/acme-ops/acme-platform/blob/aps/cutover/docs/cutover.md
docs/cutover.md
1
MeasureOld boardNew moduleNote
On time (planned)71%86%same 236 orders
Changeover hours31.522.0families grouped
Bottleneck load123%94%old board was infinite
Adherencenot recorded82%tolerance 15 min
Factor updatedWC-PRESS-03: 0.80 → 0.74, measured 2026-11-23 to 27, supervisor tally2
The comparison the cutover decision rests on.
  1. Every figure has a source; the old board's 123% shows why the new one is needed.
  2. A factor never changes without a recorded measurement.

Check it worked

docs/cutover.md is merged with no unexplained difference, adherence with reasons, the three checks passing on the deployed address, and every changed factor with its measured source.

If it goes wrong

The new plan looks worse on on-time delivery

Check both planned the same orders with the same due dates. A finite plan often shows lateness the old infinite chart hid; that is the truth arriving, and the planner should see it as such.

Adherence is very low in the first days

Read the reasons before changing anything: often operators are still tapping late. Fix the habit first, then the factors.

Step 14

Session 6: Cut over, and cancel with the saving written down

20 minutes

Why

The module is finished when the old board or tool stops costing money and nobody plans in it. The saving written as arithmetic from invoices proves the work paid for itself; the module's checks in the testing protocol keep it honest after you have moved on.

Do this

Tell the floor the new dispatch list is the plan, retire the old board, keep the old tool's last export with its sha256 in private storage, set the import login to NOLOGIN on production and development (alter role aps_importer nologin in each project's SQL editor), read the cancellation terms from your own account page and cancel (or note the end date). Then:

Paste into Claude Code, after replacing the <...> parts
On the branch aps/cutover, update docs/cutover.md and docs/scheduling-inventory.md from what I give you: the cutover date; in docs/KEYS.md, aps_importer set to NOLOGIN on both projects with the date; where the old export is stored and its sha256; the old annual cost from invoice <number>, the cancellation or end date, and the saving as arithmetic from the invoices I give you, never an estimate; each tool and workaround marked replaced, retired or still in use, with the date. Add this module's checks to docs/testing-protocol.md (no-overload property test, setup-matrix prediction, locks on re-run, the bottleneck-source check). Push and tell me when the pull request is green.

My figures:
<paste the dates, invoice figures and storage location>

You will see recreated screen

claude — acme-platform
⏺ Write(docs/testing-protocol.md)
+| Scheduling: no overload in any published scenario | npx vitest run tests/scheduling | planner |
+| Scheduling: locks kept on re-run | npx vitest run tests/scheduling/locks.test.ts | planner |
1
⏺ Pull request #90 is green. The saving is the two invoice figures you gave me; I wrote the arithmetic, not a rounded total.
The last change: evidence written down, and the module's checks added to the testing protocol.
  1. The module's gates now run on every later change to the platform.

Check it worked

The old tool is cancelled or has an end date, aps_importer is NOLOGIN on both projects, its export is stored with its fingerprint, the saving is written from invoices, and docs/testing-protocol.md lists the module's checks.

If it goes wrong

A planner keeps a private spreadsheet "just in case"

Ask what it holds that the module does not. If it is a constraint (a die that cannot follow another), add it as an aps_constraint; if it is a habit, give it a week.

Before you go on · The module is done whenTick each one

Knowledge check

Where must a bottleneck's efficiency factor come from?

Knowledge check

Why is the production import run at the start of the side-by-side week?

References

  1. ISO 22400-2:2014, KPIs for manufacturing operations management. https://www.iso.org/standard/54497.html
  2. GitHub Docs: Manually running a workflow. https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
  3. GitHub Docs: Using secrets in GitHub Actions. https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions
  4. Capterra: PlanetTogether overview and reviews. https://www.capterra.com/p/80205/PlanetTogether/reviews/

Chapter 5 · 12 questions · 80% passes

Final assessment

Twelve questions across the module. Score 80% (10 of 12) to pass. Your LMS records your score and each answer; you can review the chapters and try again.

15 min12 questions≈ 15 minutesRetake allowed

Choose one answer for each question, then submit. You will see the right answer and why for every question.

1. What does a finite-capacity scheduler never do?
2. A machine has a rate of 60 units an hour and an efficiency factor of 0.8. How long does an order of 96 units take?
3. Which source should the efficiency factor of a bottleneck resource come from?
4. Backward scheduling answers which question?
5. Three jobs wait for one machine: P takes 3 hours (due 11:00), Q takes 1 hour (due 12:00), R takes 2 hours (due 13:00), all released at 08:00. Under EDD, when does R finish and how late is it?
6. How do real resources and open orders reach production?
7. Why does a setup matrix store minutes for a pair of values rather than one number per product?
8. Seed 1 has four 120-minute jobs (A, B, A, B), A to B 30 minutes and B to A 60, in a shift from 08:00 to 17:00. What does running them in the order A, B, A, B do?
9. Why must a locked operation keep its place when the scheduler is re-run?
10. What is the rule for a published scenario?
11. Where are the planner's, supervisor's and operator's rights decided?
12. 80 operations were scheduled and 68 started within the tolerance. Which KPI is 85 percent?