Staple methods manual

Every formula, rule, prompt, query and check behind the report.

Build 31 · 2 Nov 2026 · 1d18e26 · results last changed 2 Nov 2026

  1. Design principles
  2. The invented world
  3. The predictor
  4. The back-test
  5. The truck-load replay
  6. Availability and the back-order flag
  7. The fleet back-order list
  8. The AI step
  9. The dispatch replay
  10. The week's plan
  11. The metric queries
  12. The checks and their controls
  13. Corners cut on purpose

Design principles

A known truth, planted on purpose. The history is generated, so the true problem behind every booking and the noise in it are known. That lets each method be scored against the truth as well as against what a real history would record. A real history records only the booked code.

A temporal hold-out. The last 92 days are held back. Every count, share and rate a method uses is read from the earlier days (split = 'train'), and the method is then scored on the held-back days. No held-back fact reaches a method.

A control for every gain. Each claimed gain has a control that breaks the link the gain should come from: shuffled history, shuffled technician skills, shuffled AI answers, random follow-up replies. A gain counts only when its control falls back. Where a check could pass without looking, it also runs a planted input that must make it fail.

One seed, one source. Seed 2026 reproduces every row. Every figure on the report is read from the result of a SQL query in sql/metrics/, and every constant in these manuals is read from the code at build time.

The invented world

Source: staple/world.py. Values set inside a function are quoted here with that function's name.

Calendar and volume

160,000 jobs, each on a day drawn uniformly from 1,096 days starting 1 Nov 2023. Jobs on the last 92 days form the test split.

Appliances, problems and parts

6 appliance types, each with 5 to 6 problem codes and 21 to 25 parts. Each part carries a cost, a size in truck space units, and a lock flag; a locked part may ride only with a certified technician. Each problem carries customer phrasings and a weight for each part it can need. Furnace calls follow the seasons (_season_pick): weight 3.0 from November to February, 0.3 from June to August, 1.0 otherwise, against 1.0 for every other type.

Model families

10 families per type. The 2 newest of each type enter the field recently, so their history is thin on purpose. Each family has a weak part, drawn four times as often wherever the problem can need it (pick_parts).

Parts a job needs

Per job (pick_parts): with probability 0.07 no part (an adjustment); with probability 0.73 one part drawn from the problem's weights; otherwise two, the second drawn from the remaining parts' weights.

Planted noise

Technicians and trucks

30 technicians (_build_techs). Level is junior, mid or senior with weights 25, 45 and 30, setting a base first-visit success rate of 0.78, 0.86 or 0.92 and a repair-time multiplier of 1.20, 1.00 or 0.90. Forty per cent are specialists covering two or three appliance types, with 0.05 added to the rate and 0.8 times the repair time; the rest cover every type. Each type then varies the rate by up to ±0.03 and the time by up to ±5%, and no rate passes 0.98. Every senior is certified, and each mid with probability 0.5.

Each technician drives one truck of 90 space units. Today's stock fills it to 90% with the nationally most-used parts of each type the technician covers, taken one rank at a time across those types. A locked part is skipped on an uncertified truck.

Geography

12 zones on a 4 by 3 grid, 15 km apart. Drive time (travel_minutes) is 12 minutes inside a zone, and between zones 10 minutes plus 1.2 minutes per kilometer between zone centers.

What history recorded

The technician who took each historical job (_history_tech) covers its appliance, chosen with weight 1 / (1 + drive minutes from home). The job was fixed on the first visit only when every needed part was on that technician's truck and a uniform draw fell below the technician's rate.

Distribution centers

Two centers restock trucks between workdays (_build_centres). Each part is on back-order with probability 0.08, with a ship date 3 to 14 days out.

The predictor

Source: staple/predict.py. For a booking with appliance a, model family f and booked problem q, it estimates for each part p of a the probability that the job needs p. Training jobs only; problems are the booked codes, because real history records nothing else.

Let n be the number of training jobs at a level and c(p) how many of them needed p. With pull P = 20:

p_type(p) = c_a(p) / n_a p_problem(p) = (c_q(p) + P · p_type(p)) / (n_q + P) p_family(p) = (c_f,q(p) + P · p_problem(p)) / (n_f,q + P)

The family estimate is the answer. Each level is a pseudo-count estimate whose prior is the wider level's estimate with strength P, which is the posterior mean under a Beta prior. With 3 real jobs the wider level dominates; with 3,000 the family's own history decides. The carry list of length k is the k parts with the highest estimate, ties broken by part name.

The national top-parts list, standing in for today's stocking logic, ranks the appliance's parts by c_a(p) alone, whatever the problem.

The back-test

Source: staple/backtest.py. For each held-back job j with needed set N(j) and carry list L_k(j):

coverage(k) = |{ j : N(j) ⊆ L_k(j) }| / |J_test|, k = 1 to 8

A job needing no part is covered by any list. Today's trucks are scored by the recorded flag of every needed part being on the truck. Variants scored at every k:

Coverage is also cut by planted noise (none, misdescribed, patternless) and by family age (newest against established) at k = 3.

The truck-load replay

Source: staple/load.py. A truck-day is one technician's held-back jobs on one day. Each truck's days are replayed in date order, and each night's load starts from the previous night's load. On the first night it starts from today's stock. Each held-back job is independently marked unplanned with probability 15% (seed 2026); an unplanned call is added or moved on the day, so no night-before list sees it.

Cost of a truck-day

With repeat-visit cost R = $165, handling M = $2 a part moved, and holding rate h = 25% a year:

repeat = (jobs not covered by the load) · R handling = |load △ before| · M holding = Σ_(p ∈ load) cost_p · h / 365 total = repeat + handling + holding

Every figure is averaged per truck-day. Stock value on board is reported, but it is money tied up, not spent; only its holding cost enters the total.

Filling a truck

Parts are taken in descending score. A part goes on when it is not already aboard, the truck may carry it, and it fits the space left. A truck may carry a locked part only if its technician is certified. It may carry a back-ordered part only if the part is already on that truck.

Policies

The balanced truck

For technician t, unplanned share U = 15%, and odds o_j(p) from the predictor for each booked call j on tomorrow's route:

s_t(p) = U · (training calls of type(p) for t / training days of t) · c_type(p) / n_type · R w_t(p) = s_t(p) + Σ_(booked j) o_j(p) · R net_t(p) = w_t(p) − cost_p · h / 365 + (M if p is aboard tonight, else −M) score(p) = net_t(p) / size_p, kept only where net_t(p) > 0

The truck is filled from empty in descending score. A part already aboard is worth one move more than one that must be loaded. So a part stays on the truck while it earns its space, and permanent stock emerges from demand rather than being set.

Choosing a list length and the break-even

For each list policy, the recommended length is the shortest whose total is within $2 a truck-day of that policy's cheapest. The repeat-visit cost at which the chosen top-up stops paying is:

R* = (Δhandling + Δholding) / (Δrepeat / R) (top-up against today's trucks)

A part is called permanent when it is aboard on at least 90% of a truck's days. Inventory ROI is covered jobs per truck-day times R times 365, divided by the stock value on board.

Controls

The top-up and the balanced truck are rerun with carry lists from the shuffled-history predictor. A second shuffle with another seed measures how far two shuffles differ by chance. The balanced truck's edge over its shuffled control must exceed three times that difference.

Availability and the back-order flag

Each carry-list part gets the first mark that applies, for the job's technician and zone:

  1. needs a certified technician: The part is locked and this technician is not certified.
  2. on this truck: The technician's own truck holds it.
  3. from a center overnight: A center can load it before the visit.
  4. on another truck nearby: A truck based within 30 minutes holds it.
  5. back-ordered: No center can ship it in time and no truck nearby holds it.

The back-order flag sums, over every part of the booking's ranked list, the odds of the parts marked back-ordered:

stuck(j) = Σ_(p : mark = back-ordered) o_j(p), flag when stuck(j) ≥ 10%

Because the sum is a probability, its total over all held-back bookings forecasts how many will in fact need a stuck part. The check compares that forecast with the count, and it fails when the forecast misses by more than a quarter of the count.

The fleet back-order list

Source: staple/backorders.py. Which booking will need a stuck part cannot be known in advance, but how many will can, so the action is fleet-wide. Today's back-orders are taken to start on the first held-back day, in month m. From training only:

calls_a(m) = training calls of appliance a in month m / training days in month m share(p) = training calls needing p / training calls of a expected(p) = share(p) · calls_a(m) · ETA_p open zones = zones with no holding truck based within 30 minutes stuck_share(p) = Σ_(z ∈ open) (calls_a,z − Σ_(holder t) calls_a,z,t) / calls_a stuck(p) = expected(p) · stuck_share(p), at_risk(p) = stuck(p) · R

Demand is seasonal, so the month matters: a furnace part on back-order in winter carries three times the exposure it would in spring. The list is ranked by dollars at risk. Its back-test counts the held-back calls that needed each part before it shipped, and how many of them were marked back-ordered. The check accepts the forecast when it sits within three Poisson spreads of what came. It also requires that a forecast three times too high fails.

The AI step

Source: staple/triage.py. Model claude-haiku-5-5 at effort low.

What Claude sees

One request per appliance type. It holds the appliance, its problem codes with their labels, and every distinct customer description of that type, numbered. Claude never sees the generator's phrasing table, the booked code or the true code. The system prompt and the request, verbatim:

You read appliance repair bookings and choose the problem code that best fits the customer's own words.
Appliance: {appliance}
Problem codes:
{codes}

For each numbered customer description below, choose the most likely problem code and your confidence
from 0 to 1 that it is right. When the words fit no single problem, say so with a low confidence.
Reply with only a JSON array, one object per description:
[{"i": <number>, "code": "<CODE>", "confidence": <0 to 1>}]

{lines}

The reply is a JSON array of objects with index, code and confidence. The whole reply is refused if any description is missing, any code is outside the appliance's list, or any confidence falls outside 0 to 1.

How answers are produced and cached

Answers ship in data/triage-cache.json, keyed by a prompt identity: the first 12 hex characters of SHA-256 over the model, effort, system prompt and template. A changed prompt cannot reuse an old cache. The cache was built with the Claude Code command line in its non-interactive mode, with no tools and no saved session, and with any API key removed from its environment so it runs on a subscription. python run.py --live sends the same requests to the Messages API over HTTPS with the reader's key, API version 2026-10-21.

From a reading to a carry list

A reading is a code q with confidence c. When c ≥ 0.7, the carry list is the predictor's list for q. When it is lower, the odds lean on the appliance's overall shares:

o'(p) = c · o_q(p) + (1 − c) · c_a(p) / n_a

A booking with no code gets the national top-parts list.

The follow-up question

For every description Claude is unsure of (confidence below 0.7), a second request asks for one question to put to the customer, verbatim:

You help call-takers book appliance repairs by asking the customer one short, plain question.
Appliance: {appliance}
Problem codes:
{codes}

Each numbered customer description below is too vague to pick one problem code. For each, write one
question to ask the customer, under 20 words, with two to four answers they can pick from. Each answer
must point to a different problem code.
Reply with only a JSON array, one object per description:
[{"i": <number>, "question": "<question>", "answers": [{"text": "<answer>", "code": "<CODE>"}]}]

{lines}

Questions ship in data/followup-cache.json, keyed the same way. In the replay, the simulated customer picks the offered answer whose code is the booked code. When no offered answer fits, the lean reading stands. The control replies at random, seeded by the job number, and must lower coverage.

The keyword rules it is compared with

Words are lowercased, cut to letters, stripped of the suffixes "ing", "er", "es", "ed" and "s" when at least three letters remain, and cleared of eight stop words. The code whose label shares the most words with the customer's wins, with ties going to the alphabetically first. No shared word means no code.

What is measured

Agreement with the booked code, the only target a real history allows, and agreement with the true code, known here only because the data is invented. The 3-part carry list's coverage is measured too, which is what the reading is for. A calibration split counts how often answers above and below 0.7 match the booked code. The control deals Claude's answers to other descriptions of the same appliance (seed 7). It falls toward chance, which shows the agreement comes from reading the words.

The dispatch replay

Source: staple/dispatch.py. A working day is 540 minutes, 08:00 to 17:00. Repair minutes for an average technician are refrigerator 75, washer 60, dryer 50, dishwasher 55, range 50, furnace 70, multiplied by the technician's own time multiplier for that appliance.

The day's surprises

Drawn once per held-back day from seed 2026 plus the day's index, and shared by every policy. Each technician is sick with probability 3%. Each truck breaks down with probability 2%, at a minute drawn uniformly from 120 to 360. Each call escalates to urgent with probability 5% or eases to low with probability 5%. Priority is 1 for furnace.NO_HEAT, furnace.NO_START, refrigerator.FF_WARM, refrigerator.NOT_COOLING, 3 for dryer.NOISE, furnace.NOISE, range.DOOR, refrigerator.NOISE, washer.NOISE_SHAKE, and 2 otherwise; the day's changes apply once the day starts.

The cost of sending technician t to call j

With drive minutes from the end of t's route so far, and believed rate r̂ and time multiplier v̂ for t on j's appliance:

minutes = drive + repair_a · v̂ nearest: cost = drive skills only: cost = minutes · $1 + (1 − r̂) · R skills and parts: cost = minutes · $1 + (1 − cover · r̂) · R cover = 1 − min(1, Σ_(p not available to t) o_j(p))

At night a part is available when t's truck may carry it, because the center loads overnight. During the day it is available only when it is on the truck now. A technician is a candidate only when they cover the appliance, are working, and their day still fits the call. Fit is always judged on the true repair times, so a wrong belief can never overbook a day. Only the choice between candidates uses the beliefs.

The night plan: regret insertion

Booked calls are planned in priority bands, urgent first. Within a band every call's cost is computed for every candidate. Its regret is the second-lowest cost minus the lowest, or infinite when only one candidate remains. The call with the highest regret is placed with its cheapest candidate first, ties going to the lower job number. Only that technician's costs are then recomputed. A call with no candidate rolls to tomorrow. Booking order would instead fill the best technicians' days with whichever calls came first.

The day as it happens

  1. Each route's truck is loaded overnight by the balanced rule from its planned calls, or keeps today's stock under the baseline.
  2. At 07:00 sick technicians drop out, and their calls are placed one by one with the daytime rule.
  3. Unplanned calls arrive in priority order and are placed one by one.
  4. A breakdown at minute τ takes the truck out, and every call on it starting at or after τ is placed again.
  5. At day's end, while a route runs past 540 minutes, its lowest-priority call, the latest first, rolls to tomorrow.

Scoring

covered(visit) = N(j) ⊆ truck(t) fix(visit) = covered · r_t,a (the true rate) fixes per call = Σ fix / all calls, a rolled call scoring 0 cost a call = Σ (drive + repair) · $1 / served + (1 − Σ fix / served) · R

Policies and controls

The checks also require zero rule breaks: no call served or rolled other than once, no sick technician working, no broken truck working after its breakdown, no route past 17:00. A control may roll at most one per cent more calls than Staple, so no control can win by overbooking.

The week's plan

Source: staple/plan.py. Nothing in it plans anything. Every route, load and move on the plan screen is what the dispatch replay decided, recorded as it decided it.

Which days

The most recent 7 held-back days. Unplanned calls are marked over the whole held-back period exactly as the 92-day run marks them, then the week is kept.

Claude's codes

Each booking's code is replaced by Claude's reading of its words, from the same saved answers the AI step scores. Where Claude's confidence is below 0.7 and a saved follow-up question exists, the simulated customer picks the offered answer whose code is the booked code, as in the AI step. Where no offered answer fits, Claude's top guess stands, and the call goes on the call center's list.

Two replays, with the 92-day run's surprises

The week is replayed twice: under Staple (skills and parts, balanced loads) and under the current way (the nearest technician, today's stock). Both use seed 2026 plus the index of the week's first day among all held-back days. So each day's sick calls, breakdowns and priority changes are the ones the 92-day run met on the same day, and the plan check recounts them to prove it. The week starts from today's truck stock rather than the 92-day run's last loads.

What is recorded

For each day: the night routes before 07:00, each truck's load and the load before it, each call's chosen technician with the runner-up and the cost gap, the 07:00 sick calls, the breakdowns, the priority changes, every visit as the day ran with its start, end and whether the truck covered it, and the rolled calls. Recording changes no figure, and the dispatch check proves it on every policy. The day's figures are counted from the recorded visits exactly as the replay counts them, and the plan check holds them equal.

The first-visit chance on the board

For call j on technician t's truck, with o_j(p) the carry list's odds and r_t,a the technician's rate on the appliance:

chance(j, t) = (1 − min(1, Σ_(p not aboard t) o_j(p))) · r_t,a

A moved call is scored on the truck that took it, so its chance before and after shows what the move cost.

Where each carry-list part stands

The first that holds of: needs a certified technician, aboard, on a truck nearby (based within 30 minutes), at a center but not loaded, back-ordered.

The load sheet

A part on tonight's load and not the last is put on; on the last and not tonight's, taken off; on both, kept. Its worth is the balanced rule's own sum, split out as load.worth: each planned call's chance of needing it times $165, plus its share of unplanned calls, less its holding cost, with a $2 move counted against it when it is not aboard and for it when it is. The calls behind a part are those at least 5% likely to need it, the three likeliest named.

The to-do rules

The day the page opens on

The most recent of the 7 days on which a sick call and a breakdown both moved at least one call to another truck. A breakdown after a truck's last call strands its stock but moves nothing, so it does not count.

The metric queries

Each file in sql/metrics/ opens with its definition, read here from the file itself. Each runs on its own against the database. The report reads only their results, plus the made-up values in the assumptions table, which is written from the code's constants.

ai_step

The AI step: how each reading of the customer's own words agrees with the booked code and with the true problem, and the first-visit coverage of the 3-part list it leads to. The true problem is known only because the data is made up; real history knows only the booked code.

-- The AI step: how each reading of the customer's own words agrees with the booked code and with the true
-- problem, and the first-visit coverage of the 3-part list it leads to. The true problem is known only
-- because the data is made up; real history knows only the booked code.
SELECT method,
       jobs,
       ROUND(100.0 * agree_booked, 1)  AS agrees_booked_pct,
       ROUND(100.0 * agree_true, 1)    AS agrees_true_pct,
       ROUND(100.0 * coverage, 1)      AS coverage_pct
FROM triage
ORDER BY rowid;

backorder_exposure

Back-order exposure: each back-ordered part, the calls expected to need it before it arrives, how many of those have no truck nearby holding one, and the repeat-visit dollars at risk. Forecasts use training only; the actual columns count what the held-back days then did.

-- Back-order exposure: each back-ordered part, the calls expected to need it before it arrives, how many of
-- those have no truck nearby holding one, and the repeat-visit dollars at risk. Forecasts use training only;
-- the actual columns count what the held-back days then did.
SELECT part,
       eta_days,
       CASE WHEN holders = '' THEN 0 ELSE length(holders) - length(replace(holders, ' ', '')) + 1 END
                                 AS trucks_holding,
       open_zones,
       ROUND(expected_calls, 1)  AS expected_calls,
       ROUND(expected_stuck, 1)  AS expected_stuck,
       ROUND(at_risk, 0)         AS dollars_at_risk,
       actual_calls,
       actual_stuck
FROM backorder_list
ORDER BY at_risk DESC, part;

carry_list_curve

First-visit coverage against carry-list length: the share of held-back jobs where every needed part was on a list of k parts, for the predictor, the national top-parts list and the shuffled-history control.

-- First-visit coverage against carry-list length: the share of held-back jobs where every needed part was on
-- a list of k parts, for the predictor, the national top-parts list and the shuffled-history control.
SELECT k,
       ROUND(100.0 * MAX(CASE WHEN method = 'predictor' THEN coverage END), 1)                AS predictor_pct,
       ROUND(100.0 * MAX(CASE WHEN method = 'national top parts' THEN coverage END), 1)       AS national_pct,
       ROUND(100.0 * MAX(CASE WHEN method = 'shuffled-history control' THEN coverage END), 1) AS shuffled_pct,
       ROUND(100.0 * (SELECT coverage FROM backtest WHERE method = 'today''s trucks'), 1)     AS todays_trucks_pct
FROM backtest
WHERE k > 0
GROUP BY k
ORDER BY k;

dispatch_scorecard

Dispatch scorecard: each way of handing out calls, replayed over the held-back days with the same made-up sick calls, breakdowns and priority changes. A call rolled to tomorrow counts as not fixed today.

-- Dispatch scorecard: each way of handing out calls, replayed over the held-back days with the same made-up
-- sick calls, breakdowns and priority changes. A call rolled to tomorrow counts as not fixed today.
SELECT policy,
       calls,
       rolled,
       ROUND(100.0 * fixes_per_call, 1)   AS first_visit_fix_pct,
       ROUND(100.0 * parts_missing, 1)    AS parts_missing_pct,
       ROUND(drive_per_call, 1)           AS drive_minutes,
       moved,
       ROUND(100.0 * moved_fix_rate, 1)   AS moved_fix_pct,
       ROUND(cost_per_call, 2)            AS cost_per_call
FROM dispatch
ORDER BY rowid;

first_time_fix

First-time fix by month: the share of repair jobs fixed on the first visit, from the made-up history. A job is fixed first time only when every part it needed was on the truck and the repair took.

-- First-time fix by month: the share of repair jobs fixed on the first visit, from the made-up history.
-- A job is fixed first time only when every part it needed was on the truck and the repair took.
SELECT substr(day, 1, 7)                       AS month,
       COUNT(*)                                AS jobs,
       ROUND(100.0 * AVG(first_visit_fix), 1)  AS first_time_fix_pct
FROM jobs
GROUP BY month
ORDER BY month;

inventory_roi

Inventory ROI by truck-load policy: repeat-visit dollars a year that a truck's stock avoids, per dollar of stock on board, over the held-back replay. Each covered job counts as one repeat visit avoided against an empty truck. Every dollar is made up; the assumptions table lists each one.

-- Inventory ROI by truck-load policy: repeat-visit dollars a year that a truck's stock avoids, per dollar of
-- stock on board, over the held-back replay. Each covered job counts as one repeat visit avoided against an
-- empty truck. Every dollar is made up; the assumptions table lists each one.
SELECT l.policy,
       l.k                                                   AS parts_per_job,
       ROUND(100.0 * l.coverage, 1)                          AS covered_pct,
       ROUND(l.parts, 1)                                     AS parts_aboard,
       ROUND(l.permanent, 1)                                 AS permanent_parts,
       ROUND(l.moves, 1)                                     AS moves_a_night,
       ROUND(l.value, 0)                                     AS stock_value,
       ROUND(l.repeat_cost, 2)                               AS repeat_cost,
       ROUND(l.handling, 2)                                  AS handling_cost,
       ROUND(l.holding, 2)                                   AS holding_cost,
       ROUND(l.total, 2)                                     AS cost_a_truck_day,
       ROUND(l.coverage * l.jobs * a.value * 365 / l.value, 2) AS roi
FROM load_policy l
JOIN assumptions a ON a.name = 'repeat_visit'
WHERE l.policy NOT LIKE '%shuffled%'
ORDER BY roi DESC;

parts_caused_reschedules

Parts-caused reschedules by appliance: repeat visits that happened because a needed part was not on the truck. A repeat with every part on board failed for another reason, such as the diagnosis or the technician's skill.

-- Parts-caused reschedules by appliance: repeat visits that happened because a needed part was not on the truck.
-- A repeat with every part on board failed for another reason, such as the diagnosis or the technician's skill.
SELECT type                                                              AS appliance,
       COUNT(*)                                                          AS jobs,
       SUM(first_visit_fix = 0)                                          AS repeat_visits,
       SUM(first_visit_fix = 0 AND parts_on_truck = 0)                   AS parts_caused,
       ROUND(100.0 * SUM(first_visit_fix = 0 AND parts_on_truck = 0) / COUNT(*), 1)
                                                                         AS parts_caused_per_100_jobs,
       ROUND(100.0 * SUM(first_visit_fix = 0 AND parts_on_truck = 0) / SUM(first_visit_fix = 0), 1)
                                                                         AS parts_share_of_repeats_pct
FROM jobs
GROUP BY type
ORDER BY parts_caused_per_100_jobs DESC;

slow_truck_stock

Slow truck stock: what each truck holds that its own technician's jobs did not need in the 12 months before the held-back months. Stock held is money tied up, not money spent.

-- Slow truck stock: what each truck holds that its own technician's jobs did not need in the 12 months
-- before the held-back months. Stock held is money tied up, not money spent.
WITH cutoff AS (
  SELECT MIN(day) AS test_from, date(MIN(day), '-365 days') AS year_before FROM jobs WHERE split = 'test'
),
used AS (
  SELECT DISTINCT j.tech, jp.part
  FROM job_parts jp JOIN jobs j USING (job) JOIN cutoff c
  WHERE j.day >= c.year_before AND j.day < c.test_from
)
SELECT t.truck,
       t.tech,
       COUNT(*)                                                          AS parts_on_board,
       ROUND(SUM(p.cost * s.qty), 0)                                     AS stock_value,
       SUM(u.part IS NULL)                                               AS parts_unused,
       ROUND(SUM(CASE WHEN u.part IS NULL THEN p.cost * s.qty ELSE 0 END), 0) AS unused_value,
       ROUND(100.0 * SUM(CASE WHEN u.part IS NULL THEN p.cost * s.qty ELSE 0 END) / SUM(p.cost * s.qty), 1)
                                                                         AS unused_value_pct
FROM truck_stock s
JOIN trucks t USING (truck)
JOIN parts p USING (part)
LEFT JOIN used u ON u.tech = t.tech AND u.part = s.part
GROUP BY t.truck
ORDER BY unused_value DESC, t.truck;

truck_fill_rate

Truck fill rate by appliance: of the parts jobs needed, the share already on the technician's truck. Line fill counts each needed part. Job fill counts a job only when all of its parts were there, so one missing line fails the whole job, the way one short line holds a whole order.

-- Truck fill rate by appliance: of the parts jobs needed, the share already on the technician's truck.
-- Line fill counts each needed part. Job fill counts a job only when all of its parts were there,
-- so one missing line fails the whole job, the way one short line holds a whole order.
WITH lines AS (
  SELECT j.job, j.type, s.part IS NOT NULL AS on_truck
  FROM job_parts jp
  JOIN jobs j USING (job)
  JOIN trucks t ON t.tech = j.tech
  LEFT JOIN truck_stock s ON s.truck = t.truck AND s.part = jp.part
),
by_job AS (
  SELECT type, MIN(on_truck) AS all_on_truck FROM lines GROUP BY job
)
SELECT l.type                                         AS appliance,
       COUNT(*)                                       AS part_lines,
       ROUND(100.0 * AVG(l.on_truck), 1)              AS line_fill_pct,
       (SELECT COUNT(*) FROM by_job b WHERE b.type = l.type) AS jobs_needing_parts,
       ROUND(100.0 * (SELECT AVG(all_on_truck) FROM by_job b WHERE b.type = l.type), 1) AS job_fill_pct
FROM lines l
GROUP BY l.type
ORDER BY line_fill_pct;

The checks and their controls

python check.py runs every check; python check.py <name> runs one. Each prints what it measured and fails the run on a broken rule. Where a check could pass without looking, it also feeds itself a planted input that must fail, because a check that cannot fail looks exactly like one that sees nothing. The checks, read from check.py:

guards
The code imports nothing outside Python's own library and names no private name in a public file. A planted import must trip the import check.
weight
Each published page stays under 2 MB, the most a phone should load for one page. A page padded past the limit must be refused.
banned-control
A name planted in a scratch file must be caught by the names scan, and a longer word containing a name must not be.
predictor
One well-populated and one thin cell are recomputed by hand from the three levels' counts. The thin cell must sit near the wider odds with the pull, and far from them without it.
backtest
Coverage on the held-back jobs. The predictor must beat the national list, and the lean must help the newest families.
control
The predictor trained on shuffled history must score no better than the national baseline.
dollars
Every load policy's costs, with planted loads recomputed by hand. No load may break the space, lock or back-order rules, and a planted bad load must show all three faults. The balanced truck must be the cheapest load, and the back-order flag must be calibrated.
backorders
The fleet back-order forecast against what the held-back days brought, within three Poisson spreads. A forecast three times too high must fail.
triage
The AI step on its cached answers, live mode against a local stand-in for the API, and its controls: shuffled answers and random replies must fall back.
dispatch
Every dispatch policy replayed. Staple must beat the nearest technician on fixes and on cost, and be cheapest on its own cost. Zero rule breaks, and a planted bad visit must show all four kinds.
dispatch-control
Shuffled skills must lose at least half the skill gain. Shuffled parts odds must stay within a point. No control may win by overbooking the day.
plan
The week's plan, coded by Claude and replayed. Every call carries Claude's code and every unsure call its question and answer; every booked call appears once; no route runs past 17:00; loads stay within space, locks and back-orders; day totals equal the replay's; each moved call names where it came from and went; and the sick calls and breakdowns equal the 92-day run's on the same days. Each rule has a planted fault that must be caught.
sql
Every metric query returns rows. The history metrics are recomputed in Python apart from the SQL, the ROI must match the replay, and planted changes in a copy must move each metric.
report
The pages carry the stamp, the results day, a made-up label and a table per chart, a hint on every element that needs one, and nothing from the network. Each page opens light with a switch to dark, and every selected mark stands out at least 3:1 from the page in both. Each page carries its tab icons and share card, the icons as drawn now and the card photographed from today's words. The published copy must match a fresh build, and planted faults must be refused.
data
Two builds from one seed must match. Planted noise sits at its rates; no part belongs to another appliance, no locked part rides uncertified, no truck runs part-empty, the newest families are thin, and furnace calls follow the seasons.
docs
The README carries the values the code holds (job count, held-back days, seed, model, live address), neither it nor the walkthrough types a computed figure, the walkthrough names every published file, and every relative link resolves. Three planted faults must be refused.
fresh-clone
The public repository is cloned as a stranger would clone it, at this commit. The one command and every check must pass there, and the live report must equal the clone's published copy. Damaging that copy must make the clone's own report check fail.

Corners cut on purpose

Each is marked in the code where it is cut, with the ceiling it sets and the upgrade that would lift it. Read from those markers at build time: