Chapter 1 · Sessions 1–2
What the old WMS holds, and the tables that replace it
A stock ledger knows how many units of which lot sit in which location. A warehouse management system (WMS) adds what has to happen and who did it: it directs every physical move, checks it by scan, and posts the result to the ledger. Session 1 finds out what your WMS does and costs, from its own reports and bills. Session 2 adds the fifteen wms_ tables, the rules, a worked example, a made-up seed and the GS1 label parser, with the one rule above all others: the warehouse keeps no stock quantity of its own.
30 minAbout 7 hours hands-on across six sessionsSessions 1–2: 6 steps15 tables, 0 quantities of its own
By the end of this chapter you can
- Inventory the WMS you pay for from its own reports and bill, and take four baseline measures.
- Map the module onto your spine and the M12 ledger, then have Claude Code write the tables, views, rules, tests, the worked example and the seed.
- Build the GS1-128 label parser with its test labels, and try the tables on the development project yourself.
What a WMS adds to the ledger
Module M13 directs and verifies every physical warehouse move by scan: receiving against advance ship notices (ASNs, the supplier's message saying what is on the truck), quality quarantine, directed put-away, replenishment, picking, packing, shipping and cycle counting. It replaces tools such as Manhattan Active WM, Blue Yonder WMS, SAP EWM, Oracle WMS Cloud, Infios, Infor WMS and Made4net, and for smaller businesses Fishbowl, NetSuite WMS, Logiwa and Extensiv [1][2].
Think of two books. The M12 ledger is the book of how much: item, lot, location and status, one row per movement. The warehouse module is the book of what has to happen and who did it. The second book never copies a quantity from the first.
Session 1: Map the warehouse and the WMS you pay for, from its own reports and bill
35 minutesWhy
The module must replace real things, not guesses. A number read from the tool's own report or invoice can be checked by anyone; a number from memory is the first thing finance knocks down, and the saving in Session 6 rests on this bill. The map in the repository gives Claude Code your zones, labels and rules instead of letting it invent them.
Do this
Walk the building from inbound dock to outbound dock with the supervisor. Photograph labels and locations, never people, and only with permission. Then:
cd ~/code/acme-platform && git switch main && git pull && claudeOn a new branch wms/map, create docs/wms-map.md for Acme Bottling as a form I will fill in from the old WMS's own reports and invoices. Do not invent any number, name or price: where I have not given one, write "not known: ask <role>".
Sections:
1. Zones (receiving, reserve, forward pick, quarantine or hold, staging, shipping, line-side, returns): number of locations, how they are named, how a person finds stock.
2. Handling units and labels: pallets, cases, totes, cartons; whether license plates are used, who prints them; which GS1 application identifiers the inbound and outbound labels carry (00 SSCC, 01 GTIN, 10 lot, 17 expiry, 21 serial) or "own text only"; whether we hold a GS1 company prefix (from our own GS1 account).
3. Tools: the WMS, scanners, label printers, spreadsheets, paper pick lists, the ASN inbox: owner, users, the invoice amount and what it covers, renewal date, notice period, leased devices as their own line, and which exports it gives (locations, on-hand by license plate, open ASNs and orders, history, users).
4. The seven jobs (receiving, put-away, replenishment, picking, packing, shipping, cycle counting): who, which shifts, confirmed by scan, paper or memory. EDI messages exchanged (X12 856, 940, 945, EDIFACT DESADV), recorded only.
5. Four baselines for the latest month, each with its source: dock-to-stock time (ten receipts), pick accuracy, order cycle time (ten orders), inventory record accuracy with the tolerance used. "not recorded" where nobody records it.
6. Workarounds, in the users' own words, and where scanners lose their connection.
7. Special rules: lots and expiry, quality holds, temperature, serial tracing (DSCSA or "not applicable"), customer label requirements.
8. The pilot area: one flow from receiving to shipping, an item family of at least two items, one with lots and expiry, and a named supervisor.
Then ask me for each section in turn and write my answers in. Open a pull request titled "Warehouse map" when I say it is complete.You will see recreated screen
- Prices start as "not known".
- "Not recorded" is a finding, not a gap to fill with an estimate.
Check it worked
docs/wms-map.md has every section filled from a report, an invoice or a named person, each number with its source.
Fastest path
Take one test export of the location list and on-hand by license plate into a private folder now, and count the rows: Session 5 needs to know what the export really holds.
If it goes wrong
Claude Code fills in a price or a location count I never gave it
Say: Remove every number I did not give you and write "not known: ask <role>". Every number in this file must name its source.
The supervisor wants the test export in the repository "for convenience"
No: it holds item and customer data. Keep it in a private company folder; only the column headers go anywhere Claude Code can read.
Session 1: Take four baselines, hear the workarounds, choose the pilot
25 minutesWhy
Session 6 decides whether to cancel the old tool by comparing the new module against these numbers. A baseline taken from records now, with its definition written beside it, is the only fair comparison; and the workarounds pickers and receivers describe are exactly the moves the scan-verified tasks must catch.
Do this
From your own records for the latest month: dock-to-stock time for ten receipts, pick accuracy from complaints, returns and pack-check records, order cycle time for ten orders, and inventory record accuracy from the latest counts with the tolerance used. Ask pickers and receivers, not only the supervisor, what they do to get round the system.
Add what I give you below to docs/wms-map.md (sections 5, 6 and 8), each number with its source and definition. Then open the pull request "Warehouse map", wait for the checks, and tell me the result in plain words.
Baselines: <paste>
Workarounds: <paste>
Pilot area and why: <paste>Have the supervisor read the pilot area; owner two approves and it merges.
You will see recreated screen
| Measure | Value | Source |
|---|---|---|
| Dock-to-stock | median 6.5 h | 10 receipts, Oct |
| Pick accuracy | 98.1% | pack-check log |
| Order cycle time | median 21 h | 10 orders |
| Record accuracy | not recorded |
- Each number with its source and definition.
- A pilot with a shelf-life item, so earliest-expiry-first can be shown.
Check it worked
docs/wms-map.md is merged with four baselines (or "not recorded"), the workarounds in the users' words, a bill and renewal date for each paid tool, and a pilot area read by the supervisor.
If it goes wrong
Claude Code says the checks passed but the pull request shows a red check
Say: The check is red. Run gh pr checks, read the failed log, fix it and wait for green before you report. We trust the check on GitHub, never the summary.
Fifteen tables, two views, one label
Every table has the standard columns id, site_id (the specification's tenant_id, so each table keeps one simple access rule), created_at, created_by, updated_at, updated_by, row_version, archived_at and ext. The module keeps no location, item, lot or people list of its own: it points at the spine tables the library calls core_storage_location, core_item, core_item_class, core_lot, core_uom, core_party, core_address and core_person. A qty is stored as numeric(18,6), never floating point. Five columns are soft links (plain uuid, no foreign key) to M12: po_ref, sales_order_ref and the three inventory_txn_ref, each of the last three unique where set, so one ledger row belongs to one task, receipt or count line [3].
| Table | Holds | Columns |
|---|---|---|
| wms_location_profile | WMS attributes on a spine storage location | storage_location_id → core_storage_location req, unique; zone_type text req: receiving, reserve, forward_pick, staging, shipping, quarantine, line_side or returns; max_volume_l num; max_weight_kg num; max_pallets int; pick_sequence int; putaway_sequence int; temperature_class text: ambient, cool, frozen or controlled; mixed_items_allowed bool; mixed_lots_allowed bool; pickable bool req |
| wms_handling_unit | A license plate: pallet, case, tote, container or carton, with an optional SSCC | lpn text req, unique; hu_type text req: pallet, case, tote, container or carton; sscc text; parent_hu_id → wms_handling_unit; storage_location_id → core_storage_location; status text req: open, closed, in_transit, shipped or consumed; weight_kg num |
| wms_inbound_shipment | An expected receipt (the ASN) | asn_no text req, unique; supplier_party_id → core_party; carrier_party_id → core_party; po_ref uuid (soft link to inv_purchase_order); expected_at ts; dock_door text; status text req: expected, arrived, receiving, received or closed |
| wms_inbound_line | One line of the ASN | inbound_shipment_id → wms_inbound_shipment req; item_id → core_item req; qty_expected qty req; qty_received qty; uom_id → core_uom req; lot_no text; expiry_date date |
| wms_receipt | A scanned receipt into a handling unit | inbound_line_id → wms_inbound_line; item_id → core_item req; qty qty req; uom_id → core_uom req; lot_id → core_lot; handling_unit_id → wms_handling_unit; received_by → core_person req; received_at ts req; qc_required bool req; damage bool; inventory_txn_ref uuid (soft link to inv_inventory_transaction) |
| wms_putaway_rule | A directed put-away rule | priority int req; item_class_id → core_item_class; zone_type text; strategy text req: fixed, nearest_empty, consolidate, velocity or fefo_zone; params json; active bool req |
| wms_replenishment_rule | Pick-face or line-side replenishment | storage_location_id → core_storage_location req; item_id → core_item req; min_qty qty req; max_qty qty req; trigger text req: min_max, kanban or demand; source_zone text; active bool req |
| wms_wave | A group of order lines released for picking | wave_no text req, unique; wave_type text req: wave, batch, zone, cluster or discrete; status text req: planned, released, picking, picked or closed; released_at ts; planned_ship_at ts |
| wms_task | A directed warehouse task | task_no text req, unique; task_type text req: putaway, pick, replenish, move, count, load or unload; status text req: open, assigned, in_progress, done, short or cancelled; priority int; item_id → core_item; lot_id → core_lot; qty qty; uom_id → core_uom; from_location_id → core_storage_location; to_location_id → core_storage_location; handling_unit_id → wms_handling_unit; wave_id → wms_wave; order_line_ref uuid; assigned_to → core_person; created_at_task ts; completed_at ts; inventory_txn_ref uuid (soft link to inv_inventory_transaction) |
| wms_outbound_order | An order to ship | order_no text req, unique; order_type text req: customer, transfer, line_side or vendor_return; customer_party_id → core_party; sales_order_ref uuid (soft link to inv_sales_order); ship_by ts; carrier_party_id → core_party; service_level text; ship_to_address_id → core_address; status text req: new, allocated, released, picking, packed, shipped or cancelled |
| wms_outbound_line | A line to pick | outbound_order_id → wms_outbound_order req; item_id → core_item req; qty_ordered qty req; qty_allocated qty; qty_picked qty; qty_shipped qty; uom_id → core_uom req; lot_requirement text |
| wms_shipment | A shipment with its carrier documents | shipment_no text req, unique; carrier_party_id → core_party; tracking_no text; bol_no text; shipped_at ts; total_weight_kg num; package_count int; status text req: open, loaded, shipped or delivered |
| wms_package | A packed carton or pallet in a shipment | shipment_id → wms_shipment req; handling_unit_id → wms_handling_unit; outbound_order_id → wms_outbound_order; length_cm num; width_cm num; height_cm num; weight_kg num; label_zpl text |
| wms_cycle_count | One instance of a count programme | count_no text req, unique; method text req: abc, location, item, ad_hoc or wall_to_wall; status text req: planned, counting, review or posted; scheduled_at date; blind bool req |
| wms_cycle_count_line | A counted location and item, with its variance | cycle_count_id → wms_cycle_count req; storage_location_id → core_storage_location req; item_id → core_item; lot_id → core_lot; system_qty qty; counted_qty qty; variance qty; counted_by → core_person; recount bool; approved_by → core_person; inventory_txn_ref uuid (soft link to inv_inventory_transaction) |
A handling unit holds one item and one lot, and no quantity: a view, wms_hu_lot, names its item and lot. A second view, wms_allocatable, is the only stock an order may take: pickable, active reserve or forward-pick locations, released lots, less open pick and replenish tasks. Both are created with security_invoker so they apply the reader's rights [4]. Held and quarantined stock is not in the view, so it can never be offered.
| Location | Zone type | Pickable | Pick seq. | Put-away seq. | Max pallets |
|---|---|---|---|---|---|
| DOCK-IN | receiving | no | 6 | ||
| QUAR-1 | quarantine | no | 2 | ||
| RES-A1 | reserve | yes | 20 | 10 | 4 |
| RES-A2 | reserve | yes | 30 | 20 | 4 |
| PICK-B1 | forward_pick | yes | 10 | ||
| STAGE-OUT | staging | no | 6 |
GS1 labels
GS1 publishes the identification keys suppliers, carriers and warehouses share [5]. A GTIN identifies a kind of item; an SSCC identifies one pallet. A GS1-128 label holds data fields, each started by an application identifier (AI): 00 SSCC (18 digits), 01 GTIN (14), 10 lot (up to 20), 17 expiry (YYMMDD, read as 20YY), 21 serial (up to 20). The last digit of an SSCC or GTIN is a check digit: from the right, multiply alternately by 3 and 1, add, and the check digit brings the sum to the next multiple of ten [6].
Session 2: Map the module onto your spine and the M12 ledger, before any table
15 minutesWhy
The module posts every move to M12's ledger and points at spine tables your Foundation may already hold under its own names. Building them blind is how a plant ends up with two location lists and a second stock book. A written map makes Claude Code extend what exists, create only what is missing, and stop if the ledger it must post to is not there.
Do this
Read docs/SCHEMA-PLAN.md, docs/naming-standard.md, docs/matrix.json and every file in supabase/migrations. Do not write any SQL yet.
On a new branch wms/spine, add a section "## M13 Warehouse (WMS)" to docs/spine-map.md, the one spine map every module shares (if it does not exist yet, create it with the heading "# Spine map" first; never a separate map file for this module). Put in the section, under "### Tables", exactly the text between the lines below. Then, under "### Map":
- For each spine table or function the module needs (core_site, core_uom, core_item, core_item_class, core_storage_location, core_lot, core_party, core_person, core_job_role, core_address, core_reason_code, core_number_sequence, core_comment, core_event_outbox, core_audit_log with core_audit_row(), core_touch_row(), core_current_tenant()): "we have it as <our table>, missing columns: ..." or "missing". Never plan a second table for something we have.
- For M12: whether inv_inventory_transaction, inv_inventory_balance, inv_available, inv_balance_from_ledger, the inventory-post route and scripts/check-balances.mjs exist. If any is missing, STOP and tell me: this module adds no inv_ table and changes none.
- Module tables carry site_id in place of the specification's tenant_id, so each keeps one simple access rule.
End the section with "Questions for me". Then write one spine migration (npx supabase migration new wms_spine) adding only what is missing, with row-level security on and no policies, and pgTAP tests that each new table exists with RLS on. Open "WMS spine map", wait for the schema check, and report.
----- tables for docs/spine-map.md -----
# The module's fifteen tables (from module library M13)
Standard columns on every table: id, site_id (in place of tenant_id), created_at, created_by, updated_at, updated_by, row_version, archived_at, ext.
Types: text, int, num (decimal), qty (numeric(18,6)), bool, date, ts (timestamptz), uuid, json (jsonb). "req" = not null. A list after a colon = the only allowed values. "→" = foreign key. Soft links are uuid with no foreign key.
## wms_location_profile
WMS attributes on a spine storage location.
- storage_location_id → core_storage_location req, unique
- zone_type text req: receiving, reserve, forward_pick, staging, shipping, quarantine, line_side or returns
- max_volume_l num
- max_weight_kg num
- max_pallets int
- pick_sequence int
- putaway_sequence int
- temperature_class text: ambient, cool, frozen or controlled
- mixed_items_allowed bool
- mixed_lots_allowed bool
- pickable bool req
## wms_handling_unit
A license plate: pallet, case, tote, container or carton, with an optional SSCC.
- lpn text req, unique
- hu_type text req: pallet, case, tote, container or carton
- sscc text
- parent_hu_id → wms_handling_unit
- storage_location_id → core_storage_location
- status text req: open, closed, in_transit, shipped or consumed
- weight_kg num
## wms_inbound_shipment
An expected receipt (the ASN).
- asn_no text req, unique
- supplier_party_id → core_party
- carrier_party_id → core_party
- po_ref uuid (soft link to inv_purchase_order)
- expected_at ts
- dock_door text
- status text req: expected, arrived, receiving, received or closed
## wms_inbound_line
One line of the ASN.
- inbound_shipment_id → wms_inbound_shipment req
- item_id → core_item req
- qty_expected qty req
- qty_received qty
- uom_id → core_uom req
- lot_no text
- expiry_date date
## wms_receipt
A scanned receipt into a handling unit.
- inbound_line_id → wms_inbound_line
- item_id → core_item req
- qty qty req
- uom_id → core_uom req
- lot_id → core_lot
- handling_unit_id → wms_handling_unit
- received_by → core_person req
- received_at ts req
- qc_required bool req
- damage bool
- inventory_txn_ref uuid (soft link to inv_inventory_transaction)
## wms_putaway_rule
A directed put-away rule.
- priority int req
- item_class_id → core_item_class
- zone_type text
- strategy text req: fixed, nearest_empty, consolidate, velocity or fefo_zone
- params json
- active bool req
## wms_replenishment_rule
Pick-face or line-side replenishment.
- storage_location_id → core_storage_location req
- item_id → core_item req
- min_qty qty req
- max_qty qty req
- trigger text req: min_max, kanban or demand
- source_zone text
- active bool req
## wms_wave
A group of order lines released for picking.
- wave_no text req, unique
- wave_type text req: wave, batch, zone, cluster or discrete
- status text req: planned, released, picking, picked or closed
- released_at ts
- planned_ship_at ts
## wms_task
A directed warehouse task.
- task_no text req, unique
- task_type text req: putaway, pick, replenish, move, count, load or unload
- status text req: open, assigned, in_progress, done, short or cancelled
- priority int
- item_id → core_item
- lot_id → core_lot
- qty qty
- uom_id → core_uom
- from_location_id → core_storage_location
- to_location_id → core_storage_location
- handling_unit_id → wms_handling_unit
- wave_id → wms_wave
- order_line_ref uuid
- assigned_to → core_person
- created_at_task ts
- completed_at ts
- inventory_txn_ref uuid (soft link to inv_inventory_transaction)
## wms_outbound_order
An order to ship.
- order_no text req, unique
- order_type text req: customer, transfer, line_side or vendor_return
- customer_party_id → core_party
- sales_order_ref uuid (soft link to inv_sales_order)
- ship_by ts
- carrier_party_id → core_party
- service_level text
- ship_to_address_id → core_address
- status text req: new, allocated, released, picking, packed, shipped or cancelled
## wms_outbound_line
A line to pick.
- outbound_order_id → wms_outbound_order req
- item_id → core_item req
- qty_ordered qty req
- qty_allocated qty
- qty_picked qty
- qty_shipped qty
- uom_id → core_uom req
- lot_requirement text
## wms_shipment
A shipment with its carrier documents.
- shipment_no text req, unique
- carrier_party_id → core_party
- tracking_no text
- bol_no text
- shipped_at ts
- total_weight_kg num
- package_count int
- status text req: open, loaded, shipped or delivered
## wms_package
A packed carton or pallet in a shipment.
- shipment_id → wms_shipment req
- handling_unit_id → wms_handling_unit
- outbound_order_id → wms_outbound_order
- length_cm num
- width_cm num
- height_cm num
- weight_kg num
- label_zpl text
## wms_cycle_count
One instance of a count programme.
- count_no text req, unique
- method text req: abc, location, item, ad_hoc or wall_to_wall
- status text req: planned, counting, review or posted
- scheduled_at date
- blind bool req
## wms_cycle_count_line
A counted location and item, with its variance.
- cycle_count_id → wms_cycle_count req
- storage_location_id → core_storage_location req
- item_id → core_item
- lot_id → core_lot
- system_qty qty
- counted_qty qty
- variance qty
- counted_by → core_person
- recount bool
- approved_by → core_person
- inventory_txn_ref uuid (soft link to inv_inventory_transaction)
----- end -----You will see recreated screen
- If M12 is missing, Claude Code stops: build M12 Sessions 2–4 first.
Check it worked
Pull request WMS spine map is green, the M13 section of docs/spine-map.md has no open questions, M12's ledger is confirmed present, and no new table duplicates one you had.
If it goes wrong
The map says M12's ledger is missing
Stop here and build M12 Sessions 2 to 4 first. Never let Claude Code create an inv_ table in this module: two modules would then own the same book.
CI fails with: column does not exist, on a fresh database
A column has no migration. Say: Rebuild from nothing using only supabase/migrations, run supabase db diff, and write any missing change as a new migration. We hit this: ten columns merged with no migration.
Session 2: One prompt: the tables, the views, the rules page, the tests, the worked example and the seed
30 minutesWhy
The rules that keep the book honest (no quantity outside the ledger, one ledger row per task, held stock never offered) must exist in the database and in one readable page before any route exists. The worked example is fixed and small, kept as a test fixture so that Session 4 can be worked by hand to the unit; the seed gives the development project the same rows shifted onto today.
Do this
After the spine pull request has merged:
Read the M13 section of docs/spine-map.md and docs/naming-standard.md. Use our table names from the map wherever the library says core_...
On a new branch wms/tables:
1. npx supabase migration new wms_tables: the fifteen tables exactly as the M13 section of docs/spine-map.md lists them, with site_id in place of tenant_id (allowed values as check constraints, qty as numeric(18,6), soft links plain uuid). Every table: index on its scope column, row-level security on with no policies, touch and audit triggers. Unique indexes on each inventory_txn_ref where not null. Checks: receipt qty > 0; task qty > 0 when set; counted_qty >= 0; qty_allocated <= qty_ordered, qty_picked <= qty_allocated, qty_shipped <= qty_picked. Not wms_dock_appointment (yard management, an extension).
2. Views with security_invoker: wms_hu_lot (each unit's item and lot from its receipt, its opening ledger row, or ext when loaded in check mode) and wms_allocatable (inv_available in locations with pickable true, zone reserve or forward_pick, status active, for released lots, less open, assigned or in-progress pick and replenish tasks).
3. docs/wms-rules.md, one page: a unit holds one item and one lot; quantities live only in the ledger; a move is one transfer_in with both locations and both statuses set to the stock's current status; a receipt is a po_receipt; a pick changes available to allocated; shipment from allocated; FEFO then pick_sequence then lowest LPN, undated lots last by FIFO, only from wms_allocatable; every post carries ref_type, ref_id and client_ref; count variances post one cycle_count per line, zero variance posts nothing; no costs, no reversals; config/wms.json receipt_over_pct 0, recount_tolerance_units 1; the five events (wms.receipt.posted, wms.receipt.qc_required, wms.task.completed, wms.shipment.shipped, wms.count.variance) written to the outbox in the same transaction.
4. pgTAP tests: the database refuses a duplicate lpn, a zone_type outside the list, a task status outside the list, a receipt of quantity zero, a line with qty_picked above qty_allocated; and a test that fails if any function or route other than inventory-post writes inv_inventory_balance.
5. The worked example, exactly as I give it in the next message, in two places: tests/fixtures/wms-worked.json with its fixed dates, which the seed test loads into the test database and checks against the counts; and supabase/seeds/wms.sql, listed under [db.seed] sql_paths in supabase/config.toml, holding the same rows shifted onto today (every date moved by the same whole number of weeks, so week 1 starts this Monday), marked SYNTHETIC, and safe to run twice. Never appended to supabase/seed.sql, never in a migration; the deploy workflow never seeds production.
Do not connect to or change any live project. Then wait for my next message.The worked example for the warehouse module. Fixed dates, as written here, go into tests/fixtures/wms-worked.json; week 1 starts Monday 2026-11-02. supabase/seeds/wms.sql holds the same rows shifted onto today. Every row is made up, marked SYNTHETIC, and carries ext synthetic true and a seed_key; rows M12's seed already made (unit EA, Supplier One, Customer One, reason codes OPENING and COUNT-VAR) are looked up by code or name and reused, never duplicated. The GTINs and SSCCs are made up with valid check digits; never print them on real goods.
Spine: site WH1 (warehouse); parties Supplier One, Carrier One, Customer One; item classes STD-FG and INSPECT; items FG-10 (STD-FG, GTIN 11234567000104) and FG-20 (INSPECT, GTIN 11234567000272), finished_good, lot-controlled, EA; reason codes OPENING, COUNT-VAR, QC-RELEASE; sequences LPN- (next 101), T-, W-, SHP-, BOL-, CNT- (next 1) and OUT- (next 2002), padding 4.
Locations (ambient) with profiles (zone, pickable, pick seq, put-away seq, max pallets, mixed items, mixed lots): DOCK-IN receiving no - - 6 yes yes; QUAR-1 quarantine no - - 2 yes yes; RES-A1 reserve yes 20 10 4 no yes; RES-A2 reserve yes 30 20 4 no yes; PICK-B1 forward_pick yes 10 - - no yes; STAGE-OUT staging no - - 6 yes yes.
Put-away rules: 10 class INSPECT zone quarantine fixed QUAR-1; 20 class STD-FG zone reserve consolidate; 90 any class zone reserve nearest_empty. Replenishment: PICK-B1 FG-10 min 45 max 100 min_max from reserve.
Lots: L-4001 FG-10 released exp 2027-01-31; L-4002 released exp 2026-12-31; L-4003 on_hold exp 2026-11-30. Units: LPN-0001 tote at PICK-B1; LPN-0002 pallet at RES-A1, SSCC 012345670000000022; LPN-0003 pallet at RES-A1, SSCC 012345670000000039; all closed. Opening ledger through inventory-post, three adjustments reason OPENING at 2026-11-02 06:00, ref_type wms_handling_unit: 50 L-4001 at PICK-B1 on LPN-0001 available; 30 L-4002 at RES-A1 on LPN-0002 available; 20 L-4003 at RES-A1 on LPN-0003 hold.
Inbound ASN-1001 from Supplier One by Carrier One, door D1, expected 2026-11-03 08:00, status expected: line 1 FG-10 100 EA lot L-5001 exp 2027-03-31; line 2 FG-20 24 EA lot L-6001 exp 2027-06-30. Outbound OUT-2001 for Customer One, customer, Carrier One, ship by 2026-11-06 17:00, new, no address: line 1 FG-10 40; line 2 FG-20 12.
The seed test, on the fixture and again on the shifted seed, must prove: 19 wms_ rows (6 profiles, 3 units, 1 ASN, 2 ASN lines, 3 put-away rules, 1 replenishment rule, 1 order, 2 order lines); 3 opening ledger rows at WH1's locations; wms_hu_lot gives 3 units; wms_allocatable gives 50 of L-4001 at PICK-B1 and 30 of L-4002 at RES-A1 (80) and never the 20 on hold; a second seed run adds nothing; scripts/check-balances.mjs passes.
Now push, open a pull request titled "WMS tables", wait for every check, and tell me the result in plain words. If a check fails, fix it and wait again before reporting.You will see recreated screen
- Production gets this file from the deploy pipeline on merge, never by hand.
- Held stock cannot be offered because it is not in this view.
- The numbers Session 4 starts from.
Check it worked
Pull request WMS tables is green with the five refusals, the balance-write test, the seed run twice without duplicates, and wms_allocatable at 80 without the held 20.
Fastest path
Two messages sent one after the other replace a dozen exchanges: the rules first, then the worked example and the counts the test must prove.
If it goes wrong
The seed adds a second Supplier One or a second OPENING reason
M12's seed made them without a seed_key. Say: Look up rows M12's seed made by code or name and reuse them; use seed_key only for rows this seed creates.
Claude Code adds a quantity column to wms_handling_unit "to make screens faster"
Refuse: Quantities live only in the ledger. Read them from inv_available or wms_allocatable. That shortcut is the module's first pitfall.
A later step expects a count the seed does not give
Say: List every count a later step or test expects and show the seed line that creates it. Fix the seed, not the check.
Session 2: The GS1-128 label parser, proven with test labels
20 minutesWhy
Receiving believes what a label says only after the server has decoded it and recomputed its check digits. A parser written and tested before any route uses it, with labels that must decode and labels that must be refused, means a misread digit or an impossible expiry is caught at the dock rather than found in a customer's warehouse.
Do this
On a new branch wms/gs1, write lib/gs1.ts: parse a GS1-128 string in the bracketed human form and in the raw form (character 29 after variable fields, optional leading ]C1). Decode 00 (SSCC, 18 digits), 01 (GTIN, 14), 10 (lot, up to 20), 17 (expiry YYMMDD read as 20YY), 21 (serial, up to 20). Recompute the check digits of 00 and 01 and refuse a mismatch; refuse an impossible date (including day 00), a lot over 20 characters and an unknown AI. Tests that must decode:
(00)076543210000001012(01)11234567000104(17)270331(10)L-5001
(00)076543210000001029(01)11234567000104(17)270331(10)L-5001
(00)076543210000001036(01)11234567000272(17)270630(10)L-6001
(01)11234567000104(21)SN-0007 then character 29 then (10)L-5001
(00)012345670000000022
Must be refused: (01)11234567000105 (check digit) and (17)270231 (31 February).
Show each test failing with the check-digit rule removed, then passing. Open "GS1 label parser", wait for checks, report.Before you read the result, work the first label by hand: split it, check the SSCC's 18th digit and the GTIN's 14th, read the expiry. Your page should agree with the parser field by field.
You will see recreated screen
- A test that cannot fail proves nothing.
- The phone may show what it read; only the server's reading is believed.
Check it worked
Pull request GS1 label parser is merged; the five labels decode and the two bad ones are refused; your hand-worked label agrees.
If it goes wrong
The parser accepts (17)270231
Say: Validate the date as a real calendar date; add 270229 (not a leap year) and 270100 to the refused tests.
A real supplier label fails to decode
Read the raw scan: suppliers often end a variable field with character 29. Add the label (with made-up numbers in the same shape) as a test before changing the parser.
Session 2: Try it on the development project yourself
15 minutesWhy
CI proves the files build a database from nothing; the development project proves they apply on top of your real Foundation and M12. You run it, in your own terminal, because changing a database is kept for a person; production then gets the same migrations from the deploy pipeline on merge.
Do this
In a terminal, not inside Claude Code. The password is in the password manager under Supabase: acme-platform-dev database password:
cd ~/code/acme-platform && git fetch && git switch wms/tablesnpx supabase link --project-ref tsrqponmlkjihgfedcbacat supabase/.temp/project-refIt must print tsrqponmlkjihgfedcba. If it prints abcdefghijklmnopqrst, stop: that is production. Then push the migrations and load the new seed file the first time (after that, reload the made-up rows with npm run seed:dev):
npx supabase db push --include-seedhttps://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new
The development project's SQL editor. Paste the query below and press Run.
select l.code as location, lot.lot_no, a.qty
from wms_allocatable a
join core_storage_location l on l.id = a.location_id
join core_lot lot on lot.id = a.lot_id
order by lot.expires_at;Owner two approves and the pull request merges; the deploy pipeline applies it to production.
You will see recreated screen
- The development project. Check every time.
You will see recreated screen
| location | lot_no | qty |
|---|---|---|
| RES-A1 | L-4002 | 30 |
| PICK-B1 | L-4001 | 50 |
- 80 in all. L-4003 expires first but is on hold, so it is not here.
Check it worked
The query shows 30 of L-4002 and 50 of L-4001 and no L-4003; the pull request is merged and the deploy pipeline run is green on the Actions tab.
If it goes wrong
db push says: Remote migration versions not found in local migrations directory
The development project has a migration your branch does not. Do not force anything. In Claude Code: List which versions differ and which branch each came from, without changing any project.
The migration changed in review after I pushed it to the development project
Never reset the database. Say: Write the change as a new migration, never by editing one already pushed. Push it to the development project yourself, then reload the made-up rows with npm run seed:dev; the seed is safe to run twice.
Knowledge check
Where does the warehouse module keep how many units of a lot are in a location?
Knowledge check
A scan decodes as (01)11234567000105. What must the parser do?
References
- Made4net: which is the best WMS for business (core and extended capabilities). https://made4net.com/knowledge-center/which-is-the-best-wms-for-business/
- Infios: Leader in the 2025 Gartner Magic Quadrant for WMS (core capability list). https://www.infios.com/en/knowledge-center/news/infios-leader-in-2025-gartner-magic-quadrant-wms
- PostgreSQL documentation: Unique indexes. https://www.postgresql.org/docs/current/indexes-unique.html
- PostgreSQL documentation: CREATE VIEW (the security_invoker option). https://www.postgresql.org/docs/current/sql-createview.html
- GS1: GS1 General Specifications. https://www.gs1.org/standards/barcodes-epcrfid-id-keys/gs1-general-specifications
- GS1: how to calculate a check digit manually. https://www.gs1.org/services/how-calculate-check-digit-manually
Chapter 2 · Session 3
Who may do what, and the screens
Five roles, an insert-only loader and a read-only checker go into docs/matrix.json, with four rules that take rights away on purpose: nobody approves their own count, nobody releases what they received, a blind count stays blind, and the loader writes only marked rows. Then Claude Code builds the phone screens for gloves and glare, and the desk screens.
20 minSession 3: 2 steps5 roles, 2 identities9 routes, 9 screens
By the end of this chapter you can
- Add the roles, identities, tables, routes and screens to docs/matrix.json with the four restrictive rules, and regenerate the access rules.
- Walk Sessions 4 to 6 against the matrix so no later step is refused.
- Have Claude Code build the scan screens and the desk screens and test them signed out, per role and at phone width.
| Role | Does | May not |
|---|---|---|
| wh_receiver | Receives against ASNs, puts away, completes moves | Release stock they received from quarantine |
| wh_picker | Picks, replenishes, moves, counts (blind) | Read system_qty or variance on count lines; approve a count |
| wh_packer | Packs cartons, loads them | Ship (the supervisor ships) |
| wh_supervisor | Enters orders and ASNs, allocates, releases waves, assigns tasks, ships, approves counts | Approve a line they counted |
| inventory_control | Owns locations and rules, releases from quarantine, plans and approves counts | Release what they received; approve a line they counted |
| wms_loader (identity) | Inserts locations, profiles, units and opening rows marked imported, only through import-wms.yml (Sessions 5–6) | Update or delete anything; sign in after cut-over (set NOLOGIN) |
| wms_check (identity) | Reads tasks, receipts, units, counts and the ledger for the checks | Write anything |
A restrictive policy can only remove rights: a row must pass it as well as the policy that grants the right, so no other grant gets round it [1]. In Postgres an update finds rows only through the role's read rule, and the changed row must still pass it, so a read limited to "status is open" would refuse the update that sets it to done [2]: write reads broad and put narrow conditions in the route.
| Route | Called by | Posts to the ledger |
|---|---|---|
| wms-orders | wh_supervisor | nothing |
| wms-receive | wh_receiver | po_receipt |
| wms-task | receiver, picker, supervisor, inventory control | transfer_in |
| wms-allocate | wh_supervisor | nothing |
| wms-wave | wh_supervisor | nothing |
| wms-pack | wh_packer | nothing |
| wms-ship | wh_packer loads; wh_supervisor ships | shipment |
| wms-release | inventory_control | status_change |
| wms-count | inventory control plans; picker counts; supervisor or inventory control approves | cycle_count |
| Key or secret | What it unlocks | Where it lives | Who holds it | Never |
|---|---|---|---|---|
| wms_loader password | Lets .github/workflows/import-wms.yml sign in as wms_loader, which may only insert locations, units and opening stock marked imported | GitHub Actions secret WMS_LOADER_PASSWORD, typed by a person; password manager; named in docs/KEYS.md | pat@acme.com | In Vercel, the repository or a chat; the account is set NOLOGIN at cut-over |
| wms_check password | Lets scripts/check-wms.mjs read as wms_check | WMS_CHECK_PASSWORD in Vercel (Preview, Production), typed by a person; password manager; named in docs/KEYS.md | pat@acme.com and sam@acme.com | Given write rights of any kind |
Session 3: The roles, identities and restrictive rules into the matrix
35 minutesWhy
Access decided once in the matrix and generated everywhere cannot drift. The four restrictive rules are the module's separation of duties, and the walk through every later step is what stops Session 4 failing halfway through a wave, or a confirm that reports success and changes nothing because the role could not read the row.
Do this
Read docs/matrix.json, the M13 section of docs/spine-map.md, docs/wms-rules.md, scripts/gen-policies.mjs and docs/access-review.md.
On a new branch wms/access, add to docs/matrix.json, starting every cell blank and adding only what the job needs (scope: own site): the roles wh_receiver, wh_picker, wh_packer, wh_supervisor, inventory_control, and the identities wms_loader (insert-only) and wms_check (read-only), each its own sign-in with a password a person sets and names in docs/KEYS.md, never the service key, with exactly the rights in element M13 chapter 2's table, which I paste below; the routes wms-orders, receive, task, allocate, wave, pack, ship, release, count (the load is a workflow, not a route); and the screens /warehouse/receive, /warehouse/tasks, /warehouse/pack, /warehouse/load, /warehouse/count (phone), /warehouse/orders, /warehouse/shipping, /warehouse/control (desk), /warehouse/kpis (manager). No delete for anyone.
Four restrictive policies: the person who counted a line cannot approve it; the person who received a lot cannot release it from quarantine; the loader inserts only rows with ext imported; the picker cannot read system_qty or variance (a column right).
Then write docs/access-walk.md: one line per step of Sessions 4, 5 and 6 in element M13 (I paste the list below): role or identity, table, action, the cell that allows it. Mark and add any missing cell.
Run scripts/gen-policies.mjs (Session 8) and scripts/gen-routes.mjs, which writes lib/access/routes.ts (Session 9). Add tests for each restrictive rule, that wms_check can write nothing, that nobody can delete, a cross-site test, and for each role that updates a table, that the row really changed. In the WMS seed file only (never a migration, never a page or switch in the app), add public.dev_act_as(email text, person_code text), refusing any person without ext synthetic true. Push, open "WMS access", wait for every check, report.
<paste the role table and the step list>You will see recreated screen
- A blind count stays blind: the picker's role cannot read the system quantity at all.
- Two refusals found now instead of in the middle of a wave.
Check it worked
Pull request WMS access is green; docs/access-walk.md has a cell for every line; the four restrictive-rule tests and the really-changed tests are in supabase/tests/access.test.sql.
If it goes wrong
A confirm reports success but the task is still open
The role can update rows it cannot read, so the update matched nothing. Say: Check the read policy covers the row before and after, and add a test that performs the change and checks the row really changed. We met this in three modules.
Claude Code proposes the service_role key for the load
Refuse: wms_loader is its own insert-only sign-in with only its matrix rights. Never service_role.
Claude Code put dev_act_as in a migration or added an "act as" switch
Say: Remove it. It lives only in the seed, which never runs in production. A demo switch once made every visitor an administrator in production.
Session 3: The screens: scan on the phone, plan at the desk
40 minutesWhy
Warehouse floors have glare and people wear gloves. A scan screen with one task at a time, large targets and a confirm that stays disabled until the scans match is what makes pick accuracy measured instead of assumed; and refusing to confirm with no connection stops a queued confirm posting stock into a location frozen in the meantime.
Do this
Read node_modules/next/dist/docs/ first: this version of Next.js differs from what you know, and request checks live in proxy.ts. Then read docs/matrix.json, lib/access/routes.ts, docs/wms-rules.md and the screens from Foundation Sessions 12 to 15.
On a new branch wms/screens, build the nine screens. Phone screens (/warehouse/receive, tasks, pack, load, count): one task at a time in large type, the location to go to and the unit to scan; scan by the phone camera with a barcode library in the page (Code 128), or a handheld scanner typing into the focused box; confirm disabled until the scans match the task; refuse to confirm with no connection, saying so, rather than queueing. Desk screens (/warehouse/orders, shipping, control) and /warehouse/kpis (read only, "No data" where there is none, never 0).
The server takes the person from the signed-in session, never from the page, and sets every time from its own clock. Tests: every screen and route signed out lands on sign-in; each role sees only its screens; the phone screens pass at 360 and 390 px with 44 px targets and 16 px fields; a scan recorded by the receiver names the receiver whoever the page claims. Push, open "WMS screens", wait for every check including the preview, and report with the preview link.https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/sql/new
Run select public.dev_act_as('pat@acme.com', '<person>'); in the development project's SQL editor to act as a receiver, picker, packer, supervisor or inventory control.
Give a receiver and a picker a phone with the preview, gloves on. Do not explain. Write down every place they stop, and give the list to Claude Code.
You will see recreated screen
- Made-up data says so. If a preview shows real stock, stop.
- Disabled until the location and the unit both match. The server checks again.
Check it worked
Pull request WMS screens is green; each role sees only its screens; the phone screens pass at 360 and 390 px; confirm stays disabled until the scans match; you have notes from a receiver and a picker.
If it goes wrong
The camera does not open on the preview
Camera access needs a secure page (https) and the person's permission in the browser; previews are https. Check the browser's site settings before changing code.
The KPI screen shows 100% pick accuracy before anything was picked
Say: Show "No data" when there is none, never a number, and add a test per widget rendered empty. A chart once graded twelve hard-coded points "In control" on 87 screens.
A page answers without sign-in
Stop. Say: Call every /warehouse page and wms- route signed out and show me each status code. A prior build had 376 of 449 route handlers with no guard.
Knowledge check
A picker counted a line 2 short. Who may approve it?
Knowledge check
A receiver scanned in lot L-6001, which is in quarantine. Who may release it?
References
- PostgreSQL documentation: Row security policies (including restrictive policies). https://www.postgresql.org/docs/current/ddl-rowsecurity.html
- Supabase Docs: Row Level Security. https://supabase.com/docs/guides/database/postgres/row-level-security
- W3C: Understanding WCAG 2.2, Target Size (Enhanced). https://www.w3.org/WAI/WCAG22/Understanding/target-size-enhanced.html
Chapter 3 · Session 4
The workflow: every move scanned and posted once
The seed's ASN-1001 goes through the building on the preview: received and decoded from its labels, one item to quarantine, every pallet put away by rule, stock allocated earliest-expiry first, a wave released, picks confirmed by scan, a replenishment, packing, shipping and a blind count whose variance someone else approves. Every completed task posts exactly one ledger row, and two scripts prove it.
30 minSession 4: 5 steps, two sittings11 tasks, 19 ledger rowsFG-10 ends at 158
By the end of this chapter you can
- Have Claude Code build the nine routes on inventory-post, with the refusal tests.
- Work ASN-1001 and OUT-2001 end to end on a phone and check each ledger row.
- Prove the book with check-wms and check-balances, each shown failing on a planted fault.
| Step | Ledger transaction | Status |
|---|---|---|
| Receive | po_receipt into DOCK-IN | available (quarantine for class INSPECT) |
| Put-away, move, replenish | transfer_in, both locations and both statuses set | unchanged |
| Release from quarantine | status_change at QUAR-1 | quarantine to available |
| Allocate | none | none |
| Pick | transfer_in to STAGE-OUT (a short pick posts what was found) | available to allocated |
| Load | shipment from STAGE-OUT | from allocated |
| Count variance | cycle_count out of (or into) the location | from the line's balance_status |
Session 4: One prompt for the routes on inventory-post, with the refusal tests
30 minutesWhy
Every route calls inventory-post inside its own database transaction with a client_ref built from the task, so the ledger row and the warehouse rows are saved together or not at all, and the same request sent twice changes the data once. Writing the refusals as tests in the same pull request proves the server, not the screen, decides.
Do this
Read docs/wms-rules.md, docs/matrix.json and lib/gs1.ts. On a new branch wms/workflow, build the nine routes in this order, each on inventory-post inside its own database transaction, with client_ref from the task, receipt or count line, the transaction id written back to inventory_txn_ref, and the event written to the outbox in the same transaction:
wms-receive (decode every label with lib/gs1.ts on the server; match GTIN to item and lot and expiry to the ASN line; create the lot once (quarantine for class INSPECT, else released), the unit with the SSCC and the next LPN, the receipt, a po_receipt into DOCK-IN; refuse above the ASN quantity, a lot that differs from the line, a scan matching no line; keep arrived_at in ext);
wms-task (put-away by the first active rule that finds an active location with pallet room and acceptable mixing; complete any task by scanning location and unit, checked again on the server; a refused scan writes a SCAN-REFUSED comment; short picks post what was found; min/max replenishment after a pick; a kanban card scan at a line_side location creates one replenish task for max_qty);
wms-allocate (FEFO from wms_allocatable only), wms-wave, wms-pack (the server sets package_count and total_weight_kg, ignoring the browser), wms-ship, wms-release (refuses the receiver), wms-count (blind; recount beyond tolerance; approval by someone else; one cycle_count per line with a variance, from the line's balance_status), wms-orders.
Tests in tests/wms-workflow.test.mjs against a database the test sets up and rolls back: wrong location scan refused with SCAN-REFUSED; a fifth pallet for RES-A1 goes to RES-A2; put-away into a blocked location refused; an order for 200 of FG-10 allocates 180 and never the 20 on hold; a short pick of 8 against 10 posts 8 and leaves the line open; the same task completed twice posts one row; cancelling a released order refused; the kanban card at a test LINE-1 creates exactly one replenish task for 20. Show each failing with its rule removed first. Push, open "WMS workflow", wait for every check and report.You will see recreated screen
- The server checks the scan again, whatever the screen did, and keeps a record of the refusal.
Check it worked
Pull request WMS workflow is green with each refusal test shown red first, and the test that only inventory-post writes balances still passes.
Fastest path
"Build them in this order" means each route can be read before the next uses it; one prompt with the order and the tests replaces ten rounds of "now add the next route".
If it goes wrong
Two pickers confirm the same task at once and both succeed
Say: Include the task's row_version in the update's WHERE clause so the second confirm is refused, and add a test with two confirms from the same copy. Two saves from one starting copy is how a record gets lost.
A test only checks that inventory-post is mentioned in the route
Say: Rewrite it to call the route and check the ledger row and the task's inventory_txn_ref. A test of a word is not a test of behaviour.
Claude Code goes round in circles on the same failing test
After the second identical failure: Stop. Quote the error, what you tried, whether the cause is in our code or outside it, and what you need from me.
Session 4, first sitting: receive ASN-1001, quarantine FG-20, put every pallet away
20 minutesWhy
Receiving is where a label becomes stock. Watching the server decode each label, the INSPECT item go to quarantine, and the put-away rules choose each destination is how you learn to trust (or question) every later number.
Do this
On the preview of WMS workflow, as the receiver (switch with dev_act_as): mark ASN-1001 arrived; scan DOCK-IN, then each supplier label, keying 60, 40 and 24:
(00)076543210000001012(01)11234567000104(17)270331(10)L-5001
(00)076543210000001029(01)11234567000104(17)270331(10)L-5001
(00)076543210000001036(01)11234567000272(17)270630(10)L-6001Then complete the three put-away tasks by scanning each destination and pallet. Expect LPN-0101 and LPN-0102 to RES-A1 (consolidate), LPN-0103 to QUAR-1 (fixed).
Read-only, on the development project as inventory control: the balance rows at DOCK-IN, RES-A1 and QUAR-1 by lot and status; the six ledger rows for ASN-1001 with their types and statuses; and the dock-to-stock hours of each receipt.You will see recreated screen
- Quarantined stock is never in wms_allocatable, so no order can take it.
You will see recreated screen
- Six rows for six completed actions; RES-A1 now holds 4 of its 4 pallets.
Check it worked
Checkpoint A: ASN-1001 received with three labels decoded on the server, L-6001 in quarantine at QUAR-1, three put-aways each with one transfer_in, and the refusal tests still green.
If it goes wrong
The put-away of the quarantined pallet is refused for a balance below zero
The transfer_in left the statuses empty, which M12 reads as available. Say: Set from_status and to_status both to the status the stock is in now (quarantine).
The preview shows real stock
Stop. Previews must use the development project (Session 11). Ask Claude Code which project the Preview variables name (names only) and fix it in Vercel yourself.
Session 4, second sitting: allocate, release quarantine, wave, pick and replenish
20 minutesWhy
Allocation is where held stock would do damage if it were offered. Seeing FEFO skip the held lot, the quarantined line wait until inventory control releases it, and the first pick trigger exactly one replenishment shows the book and the rules agreeing under real moves.
Do this
- As the supervisor: allocate OUT-2001. Expect line 1: 30 from L-4002 (RES-A1, LPN-0002), 10 from L-4001 (PICK-B1, LPN-0001); line 2: nothing, L-6001 is in quarantine.
- As inventory control (not the receiver): release L-6001 with reason QC-RELEASE and the quality result as a comment. As the receiver, complete a move of LPN-0103 from QUAR-1 to RES-A2. Allocate again: line 2 takes 12 from RES-A2.
- As the supervisor: create and release a wave holding OUT-2001; assign the first task to Picker One.
- As the picker: pick 10 of L-4001 (not empty), 30 of L-4002 (empty: the unit becomes consumed), 12 of L-6001. After the first pick, complete the one replenish task for 60 of L-5001 from LPN-0101 to PICK-B1.
Read-only, on the development project as the supervisor: OUT-2001's lines (allocated, picked), the pick and replenish tasks with their status and ledger rows, and FG-10 by lot, location and status. Confirm L-4003 was never offered.You will see recreated screen
| Line | Lot | Expiry | From | Qty |
|---|---|---|---|---|
| FG-10 | L-4002 | 2026-12-31 | RES-A1 | 30 |
| FG-10 | L-4001 | 2027-01-31 | PICK-B1 | 10 |
| FG-20 | 0 (quarantine) |
- Earliest expiry among released lots first.
- Held stock is not in the view, so it cannot be offered.
Check it worked
FEFO took 30 from L-4002 then 10 from L-4001 and never L-4003; line 2 waited until the release, then took 12 from RES-A2; three picks and one replenishment each posted one transfer_in.
If it goes wrong
The receiver could release L-6001
The restrictive rule is missing or the route skips it. Add the failing test first, then the rule; never release it by editing the lot's status.
Two replenish tasks appeared for PICK-B1
The route did not count open replenish tasks. Say: Create a replenish task only when none is open for the location and item; add a test with two picks in a row.
Session 4, second sitting: pack, load, ship, and a blind count
20 minutesWhy
Shipping is where stock leaves the book, and counting is where the book meets the shelf. A server that sets the carton weights itself, and a count that is blind, recounted and approved by someone else, are the two cheapest controls in the module.
Do this
- As the packer: pack into three cartons (LPN-0104 to -0106): 30 of L-4002 (40 × 30 × 30 cm, 12.5 kg), 10 of L-4001 (30 × 20 × 20, 4.2 kg), 12 of L-6001 (30 × 20 × 20, 5.0 kg). Choose the lot from the order's done picks. Load each carton by scanning STAGE-OUT and the carton.
- As the supervisor: ship SHP-0001 with a made-up tracking number; the route sets BOL-0001. Close ASN-1001.
- As inventory control: plan CNT-0001, method location, blind, for PICK-B1. As the picker: count 38 (L-4001) and 60 (L-5001); recount the first (beyond tolerance 1): 38 again. As the supervisor: approve both lines.
Read-only, on the development project as the supervisor: SHP-0001 (package_count, total_weight_kg, bol_no, status), the three shipment ledger rows, CNT-0001's lines (system, counted, variance, approver) and its one cycle_count row, and inventory record accuracy for the count.You will see recreated screen
- The difference is beyond the tolerance, so it is counted again before anyone approves it.
You will see recreated screen
- A zero variance posts nothing: a ledger quantity must be above zero.
Check it worked
SHP-0001 shipped with BOL-0001 and 21.7 kg; CNT-0001 posted one variance of 2, approved by someone other than the counter; inventory record accuracy for the count is 50%.
If it goes wrong
The shipment total is whatever the browser sent
Say: The server sums package_count and total_weight_kg from the packages and ignores any total the browser sends; add a test that sends a wrong total.
The picker could approve their own count line
The restrictive rule is missing. Add the failing test, then the rule.
Session 4: Prove the book, and see each check fail on a planted fault
15 minutesWhy
Two scripts prove the module agrees with the ledger: every complete task has exactly one ledger row, and balances recomputed from the ledger equal the stored ones. A check you have never seen fail proves nothing, so each is shown failing on a fault planted in a copy that is thrown away.
Do this
On wms/workflow, write scripts/check-wms.mjs, run as wms_check (password WMS_CHECK_PASSWORD from the environment, never printed): every complete task (done, or short with qty above zero) has exactly one non-reversal ledger row with ref_type wms_task equal to its inventory_txn_ref; no ledger row names a task that is not complete; every receipt and every approved non-zero count line has its row. Add a CI test that runs check-wms.mjs and M12's check-balances.mjs on the seeded, worked database, then, inside a transaction it rolls back, edits one balance by hand (check-balances must fail) and clears one done task's inventory_txn_ref (check-wms must fail). Push, wait for checks, and give me the command to run check-wms on the development project myself.Set the wms_check account's password yourself (make it with the command below, keep it in the password manager, name it in docs/KEYS.md), add it as WMS_CHECK_PASSWORD for Preview in Vercel, then run the check yourself:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"npx vercel env pull .env.local --environment=preview && node --env-file=.env.local scripts/check-wms.mjsYou will see recreated screen
- Only rows at WH1's six locations; M12's own rows are left out.
- 38 + 60 at PICK-B1, 40 at RES-A1, and the 20 on hold.
Check it worked
check-wms and check-balances pass on the development project; the CI test shows each failing on its planted fault; FG-10 stands at 158 with 138 available. Owner two approves and the workflow pull request merges.
Fastest path
Planting the faults inside a rolled-back transaction in CI means you never break the development project to see a check fail.
If it goes wrong
check-wms reports 12 task rows for 11 tasks
A task posted twice. Find which: its client_ref was not set or not unique. Fix the route and add the twice-completed test for that task type.
The check ran green on an empty database
It could never fail. Say: Make the check refuse to report "pass" when it finds no tasks at all; that is "could not measure".
Knowledge check
OUT-2001 asks for 40 of FG-10. L-4003 expires first but is on hold. What does allocation take first?
Knowledge check
A counted line is 2 units short with recount_tolerance_units 1. What happens next?
References
- GS1: reference list of GS1 application identifiers. https://ref.gs1.org/ai/
- PostgreSQL documentation: Constraints. https://www.postgresql.org/docs/current/ddl-constraints.html
- W3C: Understanding WCAG 2.2, Contrast (Minimum). https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html
Chapter 4 · Sessions 5–6
Load the stock, count it, switch the old WMS off
The specification's migration rule is short: load the location master, then opening balances by license plate as ledger transactions, and run a wall-to-wall count at cut-over. You rehearse the load on the development project with a copy IT approved, load production through a workflow a person starts from main with an export owner two approved, run side by side for a week, count wall to wall, close the loader, cut over and cancel with the saving from invoices.
25 minSessions 5–6: 4 stepsLoad twice, add nothingEnds with the module gate
By the end of this chapter you can
- Map the export and dry-run the loader in post or check mode, refusing mixed units.
- Rehearse on the development project and reconcile on-hand three ways.
- Load production through import-wms.yml with an approved export, run side by side, count wall to wall, close the loader and cancel.
| KPI | Definition | How the module measures it |
|---|---|---|
| Dock-to-stock time | Hours from arrival to put-away confirmed | Put-away completed_at minus the ASN's arrived_at |
| Pick accuracy | Lines picked correctly ÷ lines picked | Done picks with no SCAN-REFUSED ÷ done plus short picks |
| Order cycle time | Release to ship hours | Wave released_at to shipment shipped_at |
| Inventory record accuracy | Count lines within tolerance ÷ count lines | From wms_cycle_count_line |
The two pick-accuracy figures are not the same measure: the module counts refused scans and short picks, the old tool usually counts mistakes found at pack check or by customers. Say so beside the comparison [1].
Session 5: Map the export and dry-run the loader
30 minutesWhy
A load that cannot account for every row is not finished, and a unit with mixed contents loaded as if it held one lot puts a wrong number in the book for good. A mapping written first, a loader that refuses what it cannot place, and a dry run that writes nothing catch that before any ledger row exists.
Do this
Take the export again from the old tool's own export page just before the load; keep it in a private company folder, never in the repository. Items and units must already be loaded by M12's import.
I will describe the old WMS export's files and column headers below (no data). On a new branch wms/import:
1. docs/wms-mapping.md: old location to storage location and profile (parents before children; closed locations load blocked or inactive); old zone names to the eight zone types; unit types to hu_type; stock statuses to a balance status (available, quarantine, hold, damaged) and a lot status; my real line-side locations and kanban rules from docs/wms-map.md.
2. scripts/load-wms.mjs, dry run by default, writing only with --post or --check: post mode posts one adjustment (reason OPENING, ref_type wms_handling_unit, dated at the cut-off, with the old status) per accepted unit, signed in as wms_loader, through inventory-post's posting code; check mode, used when M12 already posted opening stock, adds profiles and units (item and lot in the unit's ext) and compares quantities, posting nothing. Refuse and list a unit with mixed items or lots. client_ref from LPN, item, lot and status. Never write inv_inventory_balance.
3. .github/workflows/import-wms.yml, run only by hand (workflow_dispatch) from main, refusing any other branch, with inputs target (dev or production), mode (post or check) and dry_run (default true). It downloads the export from the private Storage bucket imports of the target project; refuses it unless every file's sha256 and expected counts are listed in docs/imports/wms-approved.md on main; signs in as wms_loader with the password in that target's Actions secret (never the service key); runs scripts/load-wms.mjs; and fails on any count that differs from the approved file. Counts go to the job summary. No GitHub environment with required reviewers: the reviewed pull request that merges the approved file is the approval. A migration creates wms_loader as a database role with NOLOGIN, insert-only (no update, no delete); a person turns its login on with a password they set. Every row ext imported with the old id.
4. Tests on a made-up export (marked synthetic) with a mixed unit, an unknown location and a closed location; read = loaded + refused per file; a second run adds nothing; a file whose sha256 is not approved is refused; a count mismatch fails; wms_loader cannot update or delete.
Push, open "WMS load", wait for every check and report.
<paste the file names and column headers, no data>node scripts/load-wms.mjs --from ~/private/wms-exportYou will see recreated screen
- Fix the mapping or the order, never the data.
- A mixed unit is split in the old tool or on the floor, then loaded.
Check it worked
The dry run explains every refused row; read = would-load + refused per file; the mode (post or check) and the reason are written in docs/wms-mapping.md; the pull request is merged.
If it goes wrong
Claude Code asks to read the export to check the format
Give it the column headers and made-up rows of the same shape, never the real file.
Items are missing
Items and units belong to M12's import. Load them there first; the warehouse loader creates neither.
Session 5: Rehearse on the development project and reconcile three ways
40 minutesWhy
The first load of real stock should never be the one into production. A rehearsal through the same workflow, with a copy IT approved in writing, shows the counts, the second run adding nothing, and on-hand by location agreeing three ways (the old tool's report, the export, the ledger), and the copy is removed the same day.
Do this
Get IT's written approval to load a copy into acme-platform-dev for one rehearsal, redacted where it holds personal data (user names in the history). In the development project's SQL editor, turn on wms_loader's login with a password you make (alter role wms_loader login password '…'); keep it in the password manager, type it into the Actions secret WMS_LOADER_PASSWORD_DEV and name it in docs/KEYS.md. Create a private Storage bucket imports in the development project and upload the copy.
https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/storage/buckets
Development project Storage: a private bucket named imports; upload the approved copy.
shasum -a 256 *.csvOn a new branch wms/import-approval, write docs/imports/wms-approved.md with a section "Rehearsal (development project only)": each file's name, sha256 and expected row count (I paste them below), the date the copy was taken, what was redacted, the mode (post or check), and IT's written approval (date and role). Open a pull request titled "WMS: approve rehearsal export".
<paste the shasum lines and row counts>Owner two reviews and approves; merge. Run the workflow with target dev, dry run first, then for real, then a second time.
https://github.com/acme-ops/acme-platform/actions/workflows/import-wms.yml
Run workflow from main: target dev, dry_run true; read the counts; then dry_run false, twice.
Read-only, on the development project as inventory control: opening rows loaded against docs/imports/wms-approved.md, and whether the second load added any; then on-hand by location, item, lot and status from inv_balance_from_ledger beside the old tool's report I paste below, with the difference on each row; and confirm held and quarantined stock is absent from wms_allocatable. Then run check-balances.mjs. Old report: <paste>Explain every difference with a cause you can open. Then remove the copy from the development project the same day (ask Claude Code for a statement that removes only rows with ext imported, which you run yourself in the SQL editor), delete the file from the bucket, and write the date of removal in docs/imports/wms-approved.md.
You will see recreated screen
| File | Read | Loaded | Refused |
|---|---|---|---|
| locations.csv | 412 | 410 | 2 (listed) |
| onhand.csv | 1,906 | 1,903 | 3 (listed) |
- Only an export owner two approved can be loaded, and only from main.
You will see recreated screen
- Safe to run twice: the client_ref makes it so.
- A difference with a cause you can open, not a rounding to accept.
Check it worked
The rehearsal ran through import-wms.yml with the approved copy, loaded every accepted row once, the second run added nothing, on-hand agreed three ways or every difference has a proven cause, and the copy was removed from the development project the same day, with the date recorded.
If it goes wrong
The workflow refuses: sha256 not approved
The file changed since you recorded it (often opened and saved in a spreadsheet, which rewrites it). Upload the approved file again, or record the new fingerprint through a pull request owner two approves.
A difference has no cause you can find
You are not ready. Write "not ready" and who looks next; never adjust the ledger to make it match.
Held stock shows in wms_allocatable
A status was mapped wrongly. Fix the mapping (hold, quarantine) and reload; a held lot must never be offered.
Session 6: Load production through the workflow, and reconcile
30 minutesWhy
Production gets the stock the way the rehearsal proved: a person starts import-wms.yml from main, it reads an export whose fingerprint and counts owner two approved in a reviewed pull request, and it signs in as the insert-only wms_loader. Nobody runs SQL against the live database and no upload page exists in the app. Freezing the pilot area for the load means no move happens between the export and the first ledger row.
Do this
Agree a cut-off with the supervisor; take the final export; block every location in the pilot area (a blocked location refuses moves but allows counting). Upload the export to a private Storage bucket imports in production. Turn on wms_loader's login in production with a new password you make, keep it in the password manager, type it into the Actions secret WMS_LOADER_PASSWORD and name it in docs/KEYS.md.
https://supabase.com/dashboard/project/abcdefghijklmnopqrst/storage/buckets
Production Storage: a private bucket named imports; upload the final export.
On a new branch wms/import-production, add a section "Production" to docs/imports/wms-approved.md: each file's name, sha256 and expected counts (read, to load, refused, from the dry run I paste below), the mode and the cut-off time. Open a pull request titled "WMS: approve production export".
<paste the shasum lines and the dry run's counts>Owner two reviews and approves; merge. Run the workflow from main with target production, dry run first, then for real.
https://github.com/acme-ops/acme-platform/actions/workflows/import-wms.yml
Run workflow from main: target production, dry_run true; check the counts equal the approved file; then dry_run false.
Read-only, through the app as inventory control on production: the same reconciliation as the rehearsal, against docs/imports/wms-approved.md and the old tool's on-hand report I paste below; write the results into docs/cutover.md on a new branch wms/cutover. Do not change any data. Old report: <paste>You will see recreated screen
| File | Read | Loaded | Refused |
|---|---|---|---|
| locations.csv | 412 | 412 | 0 |
| onhand.csv | 1,906 | 1,906 | 0 (3 split since) |
- Same fingerprints and counts as the approved file, or the run stops.
- Read = loaded + refused, file by file.
Check it worked
The production run's summary matches docs/imports/wms-approved.md; docs/cutover.md shows every row of the final export accounted for and on-hand agreeing three ways (or each difference proven), on production.
If it goes wrong
The run fails: counts differ from the approved file
Stop. Find why (a move after the cut-off, a re-export), and approve the right file through a new pull request. Never edit the counts to fit.
Someone suggests a GitHub environment with required reviewers
Not available on the Team plan for private repositories. The reviewed pull request that merges docs/imports/wms-approved.md is the approval.
Production reports a table or column missing
The pipeline did not apply a migration. Open the deploy run on GitHub's Actions tab; do not apply anything by hand.
Someone suggests typing the opening balances straight into the balance table
No. Opening stock is ledger history posted through inventory-post by import-wms.yml, so check-balances can prove it.
Session 6: A week side by side, a wall-to-wall count, close the loader, cut over, cancel
60 minutes, after a weekWhy
A week with every move entered in both systems, the four measures compared against the Session 1 baselines, and a blind wall-to-wall count approved by someone who did not count, is the evidence that the new book matches the shelf. Removing the loader and cancelling only after the final export is stored keep the book closed and the history safe.
Do this
For one week every receipt, put-away, pick, pack, shipment and count in the pilot area is entered in both systems by the same people. Then count wall to wall: block the pilot area, plan a count of method wall_to_wall, count blind in pick-sequence order, recount, approve by someone who did not count, unblock.
On branch wms/cutover, add to docs/cutover.md from numbers I give and read-only queries as inventory control on production:
1. Each day of the week: on-hand by location, open orders and open ASNs compared, every difference with its cause.
2. The four measures for the week, old tool against module, beside the Session 1 baselines, with the note that the two pick-accuracy figures measure different things.
3. The module checks: check-wms and check-balances pass; a held lot is not offered; the GS1 tests pass; the access tests pass, including that a counter cannot approve their own line.
4. The wall-to-wall count: lines counted, recounted, posted, and who approved.
5. The cut-over date, the rollback plan, the last transaction time in the old tool, who tells the floor, and where the final export of locations, on-hand, history, users and reports is stored.
6. The saving: the old annual cost from the invoice I paste, minus what the module costs on services we already pay for, plus any scanners or printers bought, arithmetic shown; leased devices as their own line.
Then a migration that sets wms_loader NOLOGIN at cut-over, its rights removed from docs/matrix.json and regenerated, and a test that wms_loader can no longer sign in or insert. Open "WMS cut-over", wait for every check, report.
<paste the week's numbers and the invoice lines>Delete the WMS_LOADER_PASSWORD secrets from GitHub Actions and note the date in docs/KEYS.md. On the cut-over date make the old WMS read-only and watch the first day. Cancel on the vendor's own account page within its notice period, only after the final export is stored and you have checked it opens.
You will see recreated screen
| Measure | Baseline | Old tool (week) | Module (week) |
|---|---|---|---|
| Dock-to-stock | 6.5 h | 6.1 h | 2.4 h |
| Pick accuracy | 98.1% | 98.4% | 99.6% (refused scans counted) |
| Record accuracy | not recorded | 97.8% |
- Each measure beside its Session 1 baseline, with what it measures.
- The book cannot be loaded again by accident.
Check it worked
docs/cutover.md is merged with the daily comparison, the four measures, the module checks, the wall-to-wall count, the cut-over plan and the saving from invoices; wms_loader is set NOLOGIN with a test proving it; the loader secrets are deleted; the old WMS is read-only or cancelled after the export was stored.
If it goes wrong
The module's pick accuracy is lower than the old tool's
Look at the SCAN-REFUSED comments: the module counts mistakes the old tool never saw. Explain each miss before deciding; a difference you cannot explain means you are not ready.
Finance asks for the saving before the export is stored
Cancel last. Once the subscription ends, history may be unreachable; store the export in the company's storage and check it opens first.
Knowledge check
The loader is run twice by mistake. Why does it not double the stock?
Knowledge check
Where does real stock data go first?
References
- Solutions Review: 2023 Magic Quadrant for WMS, key takeaways. https://solutionsreview.com/enterprise-resource-planning/?p=5624
- Supabase Docs: Database migrations. https://supabase.com/docs/guides/deployment/database-migrations
- GitHub Docs: Manually running a workflow. https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/manually-running-a-workflow
Chapter 5 · 12 questions · 80% passes
Final assessment
Twelve questions across the element. 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
Your result
CivOps AI Academy
Warehouse (WMS): Scan-Verified Moves Posted to the Ledger
Element M13 complete · Learner
Your LMS records this completion. For the CivOps Foundation certificate, finish the Foundation Course at https://civops.io/learn.