Chapter 1 · Sessions 1 and 2
What the old tool does, and the tables that replace it
Session 1 inventories your field service tool from its own reports and bills, and tests its two classic failures on your own data. Session 2 adds the module's thirteen tables to your Foundation schema, with the rules the database holds itself and a small made-up service business you can count by hand, tried first on the development project.
35 minSteps 1–5About 2 hours 15 minutes hands-on in these two sessionsAbout 7 hours hands-on across six sessions
By the end of this chapter you can
- Inventory the old tool from its own reports and invoices, without estimating anything and without copying customers' personal data.
- Test the two pitfalls on real data: installed assets not tied to shipped serials, and schedules that ignore driving time.
- Have Claude Code add the missing spine tables, then the thirteen fsm_ tables with their rules and tests.
- Seed the lab service business, count it by hand, and try the migrations and the seed on the development project yourself.
What the module does, and what it leaves alone
Field service management (FSM) services the equipment you delivered and still look after at customer sites: installed assets and warranties, service contracts and their service level agreements (SLAs: the promised time to respond and to resolve), work orders from cases or preventive plans, dispatch by skill, territory and travel, an offline technician phone, van stock and the hand-off of billable lines. It replaces tools such as Salesforce Field Service, Microsoft Dynamics 365 Field Service, ServiceTitan, PTC ServiceMax, IFS FSM, Jobber, Housecall Pro and FieldEdge [3].
| Standard | What it asks | Where the module meets it |
|---|---|---|
| ISO 9001:2015, clause 8.5.5 | Meet the requirements for post-delivery activities, such as warranty and maintenance service [1] | Installed assets with warranty dates, contracts, work orders, signed service reports |
| ISO 10002:2018 | Guidelines for handling complaints [2] | A job keeps its link to the case that caused it (case_ref) |
| ITIL 4 service level management | Define service levels with the customer, then measure them | Response and resolution hours on the contract; SLA attainment from the job's own times |
| Capability | Tier | Built in this course |
|---|---|---|
| Installed base from shipped serials | MVP | Yes (Sessions 2 and 4) |
| Work orders from cases and preventive plans | MVP | Yes (Session 4) |
| Scheduling and dispatch by skills, territory and travel | MVP | Yes, one job at a time (Session 4) |
| Technician phone, offline | MVP | Yes (Sessions 3 and 4) |
| Contracts, entitlements and SLAs | STD | Yes (Session 4) |
| Van stock and parts requests | STD | Yes, through the inventory ledger (Session 4) |
| Billing hand-off and analytics | STD | CSV export and four measures (Session 4) |
| Customer messages, warranty recovery, schedule optimisation | STD and BIC | Later: nothing in this course texts or emails a customer |
Session 1: Inventory the tool you pay for today, from its own reports
40 minutesWhy
The module has to replace real things, not guesses. Counting what the old tool holds from its own reports, and reading every bill from an invoice, tells you exactly what must come across and makes the saving at the end arithmetic anyone can check. Writing only counts, serials and job numbers keeps customers' personal data out of the repository from the first day.
Do this
From the tool's own reports: count customers, service sites, installed assets, contracts (active, ended in the last 90 days, with no end date), work orders open and closed, appointments, technicians, van stock locations and billing lines. Copy its own figures for the last four full weeks: jobs completed, first-time fix, SLA attainment, utilisation, repeat visits, each with its report name and definition (or "not reported"). List every tool around it (a routing app, a texting service, a contract spreadsheet, a whiteboard) with its bill from the invoice. Ask a technician to put a phone in airplane mode and open a job: note what still works. Then:
cd ~/code/acme-platform && git switch main && git pull && claudeI am inventorying the field service tool Acme Bottling rents today, so a module on our platform can replace it. I will paste counts and figures I read from the tool's own reports and from our invoices. Never estimate or fill in a figure I have not given you: write "not yet read" and who can read it. No customer names, addresses or signatures go in this file: counts, serials and job numbers only.
On a new branch fsm/inventory, write docs/fsm-inventory.md with:
1. Records: a table of each kind (customers, service sites, installed assets, contracts by state, work orders open and closed, appointments, technicians, van stock locations, billing lines), its count, the report it came from and the date.
2. Tools: each tool and helper (name, owner as a job, seats, bill per year, renewal date, notice period, export route), from invoices.
3. Who signs in: dispatchers, technicians, service managers and customers (is there a portal?), and on which devices.
4. Offline: what a technician's phone still does in airplane mode (job details, history, parts, time, photos, signature).
5. The tool's own figures for the last four full weeks: jobs completed, first-time fix, SLA attainment, utilisation, repeat visits, mean time to repair, each with its report and definition, or "not reported".
6. Van stock and billing: where van counts live, whether a used part comes off the van by itself, how warranty parts are claimed from suppliers, how billable lines reach accounting.
7. Workarounds, in the dispatcher's and technicians' own words.
My figures:
<paste what you read, section by section>
Open a pull request titled "Field service inventory" and show me the link.You will see recreated screen
- "Not yet read" is an honest answer. An estimate would become the saving you claim in Session 6.
- Each figure with its definition. Two tools can both say first-time fix and mean different things.
Check it worked
The pull request has one file, docs/fsm-inventory.md, with all seven sections; every figure names its source; no customer name, address or signature appears.
If it goes wrong
Claude Code filled in a price, a count or a figure you never gave it
Say: Remove every figure I did not give you and mark it not yet read. On our own platform a screen showed savings nobody had measured, labelled as the ledger. A number nobody read is the same mistake, made earlier.
You pasted a report with customers' names in it
Say: Remove every customer name, address, phone number and access note from the branch, and keep counts only. If it was pushed, delete the branch on GitHub and open a fresh one: a later commit does not remove it from history.
The tool does not report first-time fix or SLA attainment
Write "not reported". Session 6 then uses the module's own figure as the baseline. Never back-fill a figure from memory.
Session 1: Test the two pitfalls on your own data
20 minutesWhy
Field service fails in two classic ways: an installed base typed in by hand, so warranty cannot be proved and nobody knows which unit shipped, and schedules that ignore driving time, so a technician is promised in two towns at once. Testing both on ten real assets and one real day tells you how much the module will fix, and gives the dispatcher and the service manager numbers they recognise.
Do this
Pick 10 installed assets in the tool. For each, look up its serial in your own shipping records (packing lists, sales orders or your ERP) and write exact, near (a typo, a dash) or no match, and whether the tool's asset carries the order that shipped it. Then take one technician's day with five or more appointments: for each back-to-back pair, the gap the schedule allows and the driving time from a map you already use. Then:
Add to docs/fsm-inventory.md on the same branch:
8. Pitfall 1, installed base and shipped serials: 10 assets checked on <date>; exact <n>, near <n>, no match <n>; matched share <n>/10; assets carrying the shipping order <n>/10.
9. Pitfall 2, travel time: technician <job title>, <date>, <n> appointments; pairs where the gap is shorter than the drive: <n> of <n>; the worst: gap <minutes> against a drive of <minutes>.
10. Baseline: 10 recently closed jobs (job numbers only), first visit fixed <n>/10; another job on the same asset within 30 days <n>/10.
Push to the same pull request.The dispatcher and the service manager read it; owner two approves; it merges.
You will see recreated screen
- Six of ten provable is the case for creating assets from shipments.
- The day the dispatcher already knows goes wrong, now in numbers.
Check it worked
docs/fsm-inventory.md is on main with both pitfalls counted and a ten-job baseline, read by the dispatcher and the service manager.
If it goes wrong
You have no shipping records to compare with
Write which system would hold them (the ERP, the accounts package, packing lists in a drawer) and who owns it. Session 5 matches assets to shipped serials; it needs that source.
The dispatcher says travel is "in their head"
That is the finding. Write it down as it was said, with the one day you measured.
Knowledge check
Why does an installed asset keep serial_unit_id and sales_order_ref as well as the serial text?
The installed base starts at the shipment
An installed asset is a customer-owned product in service, created from the shipment of its serial: the serial unit, the order that shipped it, the service site, optionally a parent (a drive module hangs under its pump), and warranty dates from the shipping date. A contract lists the assets it covers, with response and resolution hours and the business hours its clock counts. When a job is booked, the entitlement check decides whether it is covered.
Thirteen tables on the shared spine
The module keeps no customer list, parts list, people table or stock location of its own. It points at spine tables (core_party, core_address with latitude and longitude, core_site, core_person, core_item, core_serial_unit, core_storage_location, core_calendar, core_shift_definition, core_attachment, core_number_sequence, core_event_outbox), and parts move through the inventory ledger of module M12 (inv_sales_order, inv_inventory_transaction, inv_inventory_balance). Every table also has the spine's standard columns, not repeated below, with site_id in place of the specification's tenant_id, so each table keeps one simple access rule. An arrow (→) is a foreign key; req means required; a list after a colon is the only values allowed; a soft link is a uuid with no foreign key, because that module may not be installed.
| Table | One row is | Columns |
|---|---|---|
| fsm_territory | A service territory | name req, unique; geo_polygon json; base_site_id → core_site; manager_id → core_person |
| fsm_service_site | A customer location served | party_id → core_party req; address_id → core_address req; name req; access_notes; timezone; territory_id → fsm_territory |
| fsm_installed_asset | A customer-owned product in service | party_id → core_party req; service_site_id → fsm_service_site; item_id → core_item req; serial_no; serial_unit_id → core_serial_unit; parent_installed_asset_id → fsm_installed_asset; installed_at date; warranty_start date; warranty_end date; status req: active, inactive, decommissioned, returned; sales_order_ref uuid (soft link) |
| fsm_service_contract | A contract with its SLA and entitlements | contract_no req, unique; party_id → core_party req; contract_type req: warranty, maintenance, full_service, time_and_materials, subscription; start_at date req; end_at date req; sla_response_hours num; sla_resolution_hours num; entitlements json; billing_terms; status req: draft, active, expired, cancelled |
| fsm_contract_asset | An asset a contract covers | service_contract_id → fsm_service_contract req; installed_asset_id → fsm_installed_asset req |
| fsm_technician | A field technician's profile | person_id → core_person req, unique; territory_id → fsm_territory; home_lat num; home_lon num; vehicle_location_id → core_storage_location; calendar_id → core_calendar; active bool req |
| fsm_service_work_order | A field service job | swo_no req, unique; party_id → core_party req; service_site_id → fsm_service_site req; installed_asset_id → fsm_installed_asset; service_contract_id → fsm_service_contract; case_ref uuid (soft link to M19); swo_type req: install, repair, preventive, inspection, warranty, upgrade, decommission; priority req: p1, p2, p3, p4; status req: new, scheduled, dispatched, en_route, on_site, completed, incomplete, cancelled, ready_to_bill, billed; problem_description; resolution; billable bool req; sla_due_at ts; first_time_fix bool |
| fsm_appointment | One scheduled visit | service_work_order_id → fsm_service_work_order req; technician_id → fsm_technician req; window_start ts; window_end ts; scheduled_start ts req; scheduled_end ts req; actual_arrival ts; actual_departure ts; travel_minutes num; status req: scheduled, dispatched, en_route, on_site, completed, cancelled, no_access |
| fsm_service_line | A labour, part, travel or expense line | service_work_order_id → fsm_service_work_order req; line_type req: labor, part, travel, expense; item_id → core_item; description; qty req; unit_price money; billable bool req; warranty_covered bool req; storage_location_id → core_storage_location |
| fsm_customer_signoff | The customer's signature and the report | appointment_id → fsm_appointment req; signer_name req; signed_at ts req; signature_attachment_id → core_attachment; report_attachment_id → core_attachment; satisfaction int |
| fsm_parts_request | A technician's parts request | technician_id → fsm_technician req; item_id → core_item req; qty req; needed_by ts; service_work_order_id → fsm_service_work_order; status req: requested, picked, shipped, received, cancelled; fulfil_from_location_id → core_storage_location |
| fsm_warranty_claim | A claim on a supplier for a failed part | claim_no req, unique; service_work_order_id → fsm_service_work_order req; installed_asset_id → fsm_installed_asset; supplier_party_id → core_party req; failed_item_id → core_item; amount_claimed money; amount_recovered money; status req: draft, submitted, approved, rejected, paid |
| fsm_service_pm_plan | A preventive plan for an asset | installed_asset_id → fsm_installed_asset req; service_contract_id → fsm_service_contract; interval_months int req; checklist_template_ref uuid (soft link to M01); next_due_at date; active bool req |
Session 2: Check the spine and the ledger, and add only what is missing
20 minutesWhy
The fsm_ tables point at shared spine tables and at the inventory ledger. If one is missing the module's migration fails; if the module makes its own copy, the business has two customer lists and two stock counts that drift apart. Checking first, and adding only what is missing in its own migration, keeps one of everything and lets other modules reuse it.
Do this
Read docs/SCHEMA-PLAN.md, docs/naming-standard.md and every file in supabase/migrations. Change nothing yet.
The field service module needs:
- spine tables: core_party (party_type), core_address (with lat and lon), core_site, core_person (person_type, job_role_id, ext), core_job_role, core_item (item_type, ext), core_serial_unit, core_storage_location (location_type: warehouse, vehicle, customer_site), core_calendar, core_shift_definition (start, end, paid_break_min), core_attachment (with sha256), core_comment, core_notification, core_number_sequence, core_event_outbox, core_audit_log; and core_current_tenant(), core_touch_row(), core_audit_row() and a security definer number function;
- the inventory ledger of module M12: inv_sales_order, inv_inventory_transaction (txn_no unique per tenant; at least one of from_location_id and to_location_id; append-only, a reversal is a new row naming reversal_of_id; a unique partial index on ref_type, ref_id, txn_type where reversal_of_id is null and ref_type starts with fsm_) and inv_inventory_balance, kept only by a security definer trigger on the ledger that ignores customer_site locations.
Show me a table: each one exists, exists under another name, or is missing. If an existing table overlaps, propose how they relate and wait for my answer.
When I answer, on a new branch fsm/spine, add a section "## M18 Field service" 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), holding that table and my answers, and saying that the fsm_ tables carry site_id in place of the specification's tenant_id. Then write ONE migration (npx supabase migration new fsm_spine) that adds only what is missing, following the naming standard, with row-level security on and no policies, every function security definer with set search_path = '', and pgTAP tests in supabase/tests/fsm_spine.test.sql, including that a ledger row cannot be updated or deleted. Do not alter any existing table and do not connect to any Supabase project. Push, open a pull request titled "Spine and ledger for field service" with the map and the migration, wait for the schema check and tell me the result in plain words.You will see recreated screen
- Tables another module already made are reused, not copied.
- The ledger is append-only from its first day: a mistake is a reversing row.
Check it worked
Pull request Spine and ledger for field service is green, adds the M18 section to docs/spine-map.md, one migration and one test file, and changes no existing table.
If it goes wrong
It put the spine or the ledger inside an fsm_ migration
Say: Move them into their own migration, fsm_spine, merged first. Other modules use them; they must not depend on field service being installed.
It wants a stock column on the technician or the van
Say: Stock moves only through the ledger. No fsm_ table holds a count. A number someone can edit is a number nobody can trust.
The check is red: a function is used before it is created
Say: Order the migration so functions come before the tables and triggers that use them, and run the check again.
Session 2: The thirteen tables and the rules the database holds
30 minutesWhy
Writing the tables, the rules and the tests that prove each rule in one pull request means the proof arrives with the change. Rules in the database (one asset per serial, one open job per preventive plan, a sign-off that can never be changed) hold for every screen, the importer and any agent, including ones not built yet. A rule nobody tests is a rule a later change can quietly remove.
Do this
Read docs/naming-standard.md, docs/matrix.json and the spine migration on main.
On a new branch fsm/tables, add the tables below under "### Tables" in the M18 section of docs/spine-map.md (never a separate tables file), then ONE migration (npx supabase migration new fsm_tables). Every table: id uuid primary key; site_id -> core_site req (in place of the specification's tenant_id), indexed; created_at, created_by, updated_at, updated_by, row_version, archived_at, ext jsonb; row-level security on, no policies; the core_touch_row() and core_audit_row() triggers. req = not null; a list after a colon = a check; qty = numeric(18,6); money = numeric(18,4); num = numeric; ts = timestamptz.
fsm_territory: name req, unique per site; geo_polygon jsonb; base_site_id -> core_site; manager_id -> core_person.
fsm_service_site: party_id -> core_party req; address_id -> core_address req; name req; access_notes; timezone; territory_id -> fsm_territory.
fsm_installed_asset: party_id -> core_party req; service_site_id -> fsm_service_site; item_id -> core_item req; serial_no; serial_unit_id -> core_serial_unit; parent_installed_asset_id -> fsm_installed_asset; installed_at date; warranty_start date; warranty_end date; status req: active, inactive, decommissioned, returned; sales_order_ref uuid (no foreign key).
fsm_service_contract: contract_no req, unique per site; party_id -> core_party req; contract_type req: warranty, maintenance, full_service, time_and_materials, subscription; start_at date req; end_at date req; sla_response_hours num; sla_resolution_hours num; entitlements jsonb; billing_terms; status req: draft, active, expired, cancelled.
fsm_contract_asset: service_contract_id -> fsm_service_contract req; installed_asset_id -> fsm_installed_asset req.
fsm_technician: person_id -> core_person req, unique; territory_id -> fsm_territory; home_lat num; home_lon num; vehicle_location_id -> core_storage_location; calendar_id -> core_calendar; active bool req.
fsm_service_work_order: swo_no req, unique per site; party_id -> core_party req; service_site_id -> fsm_service_site req; installed_asset_id -> fsm_installed_asset; service_contract_id -> fsm_service_contract; case_ref uuid (no foreign key); swo_type req: install, repair, preventive, inspection, warranty, upgrade, decommission; priority req: p1, p2, p3, p4; status req: new, scheduled, dispatched, en_route, on_site, completed, incomplete, cancelled, ready_to_bill, billed; problem_description; resolution; billable bool req; sla_due_at ts; first_time_fix bool.
fsm_appointment: service_work_order_id -> fsm_service_work_order req; technician_id -> fsm_technician req; window_start ts; window_end ts; scheduled_start ts req; scheduled_end ts req; actual_arrival ts; actual_departure ts; travel_minutes num; status req: scheduled, dispatched, en_route, on_site, completed, cancelled, no_access.
fsm_service_line: service_work_order_id -> fsm_service_work_order req; line_type req: labor, part, travel, expense; item_id -> core_item; description; qty req; unit_price money; billable bool req; warranty_covered bool req; storage_location_id -> core_storage_location.
fsm_customer_signoff: appointment_id -> fsm_appointment req; signer_name req; signed_at ts req; signature_attachment_id -> core_attachment; report_attachment_id -> core_attachment; satisfaction int.
fsm_parts_request: technician_id -> fsm_technician req; item_id -> core_item req; qty req; needed_by ts; service_work_order_id -> fsm_service_work_order; status req: requested, picked, shipped, received, cancelled; fulfil_from_location_id -> core_storage_location.
fsm_warranty_claim: claim_no req, unique per site; service_work_order_id -> fsm_service_work_order req; installed_asset_id -> fsm_installed_asset; supplier_party_id -> core_party req; failed_item_id -> core_item; amount_claimed money; amount_recovered money; status req: draft, submitted, approved, rejected, paid.
fsm_service_pm_plan: installed_asset_id -> fsm_installed_asset req; service_contract_id -> fsm_service_contract; interval_months int req; checklist_template_ref uuid (no foreign key); next_due_at date; active bool req.
Rules the database holds:
1. One asset per item and serial (partial unique index where serial_no is not null); an asset is never its own parent.
2. swo_no and claim_no come from core_number_sequence through the security definer number function; sequences SWO- and WC- padded to 4.
3. A contract's end_at is not before start_at; an appointment's scheduled_end is after scheduled_start.
4. One open job per preventive plan: a partial unique index on ext->>'pm_plan_id' while status is new, scheduled, dispatched, en_route, on_site or incomplete.
5. fsm_customer_signoff refuses any update or delete.
6. Delete is refused on every fsm_ table.
Also write docs/fsm-rules.md with the two JSON shapes the rules will read: the contract's entitlements (covers: a list of line types; business_hours: timezone, a weekly schedule of opening periods, holidays) and the technician's ext (skills, van_min per item, replenish_from).
pgTAP tests in supabase/tests/fsm_tables.test.sql: every table exists with row-level security on; and the database refuses: an asset with status broken; a work order with swo_type visit; a second asset with the same item and serial; a contract ending before it starts; an appointment ending before it starts; two open jobs with the same pm_plan_id (in a rolled-back transaction); an update of a sign-off. Add the thirteen tables to docs/matrix.json with no rights yet. Do not connect to any Supabase project.
Push, open a pull request titled "Field service tables", wait for the schema check, and tell me the result in plain words. If it fails, fix it and try again before reporting.You will see recreated screen
- A repeated run of the preventive engine can never make a second open job for one plan.
- Every refusal is a test that passes only if the database says no.
Check it worked
Pull request Field service tables is green; the summary names the seven refusals; the M18 section of docs/spine-map.md, docs/fsm-rules.md and the matrix rows are in the same pull request.
Fastest path
One prompt with the tables, the rules, the tests and "wait for the check and fix it before reporting" replaces half a dozen rounds of adding one rule at a time.
If it goes wrong
The duplicate-serial test passes when it should fail
A unique rule on a column that can be empty needs care: Postgres treats two empty values as different. Say: Show me the duplicate test failing with the index removed and passing with it.
After merging main into the branch, a rule or its test has gone
We hit this: undoing a batch on main silently removed another branch's schema change, with no conflict reported. Say: I merged main. List every table, rule and test this branch adds and confirm each is still there.
Claude Code reports green but the check on GitHub is red
Say: The schema check is red. Run gh pr checks, read the failed log, fix the cause and wait for green before you report.
The seed: a small service business you can count by hand
Every number the later steps check comes from one fixed, made-up worked example, kept as a test fixture (the development project's seed holds the same rows shifted onto today), on one line of longitude so distances can be done by hand: two territories (North and South), three customer sites (Site A at latitude 41.10 and Site B at 41.30 for Customer One, Site C at 40.60 for Customer Two), five installed assets (SN-1001 to SN-1004, with SN-1001-D a child of SN-1001; SN-1005 is shipped but not yet installed), three contracts (C-100 active with business hours, C-200 expired, C-300 a draft), three technicians, three preventive plans, eight completed jobs and two dispatched ones.
| Asset and date | Entitlement result | Why |
|---|---|---|
| SN-1001 on 2026-06-18 | Warranty, contract C-100, not billable | Warranty runs 2025-09-01 to 2026-08-31; C-100 is active and lists it |
| SN-1002 on 2026-06-18 | Contract C-100, not billable | Warranty ended 2025-01-14; the contract covers it |
| SN-1003 on 2026-06-11 | Warranty, not billable | The last day of its warranty counts: both ends are included |
| SN-1003 on 2026-06-12 | Not covered, billable | Warranty over, and C-200 has expired |
| SN-1004 on 2026-06-18 | Not covered, billable | No warranty dates, and C-300 is only a draft |
Session 2: Seed the lab business, then try it all on the development project
25 minutesWhy
A fixed, made-up worked example makes every later number checkable by hand, and a test that asserts its counts from the fixture stops the seed and the later steps drifting apart. Trying the migrations and the seed on the development project yourself, before merge, means production only ever receives what has run cleanly on a real Supabase project. Seed rows never reach production: the pipeline applies migrations, not seeds.
Do this
On a new branch fsm/seed, write the worked example below in two places. tests/fixtures/fsm-worked.json holds it with its fixed dates in one time zone (write it in docs/fsm-rules.md); every test with a date, an SLA clock or a measure loads it, never the seed. supabase/seeds/fsm.sql holds the same rows shifted onto today (every date moved by the same whole number of weeks, so weekdays stay weekdays, the holiday moves with them and the two dispatched jobs fall on the coming Monday), listed under [db.seed] sql_paths in supabase/config.toml so CI and scripts/seed-dev load it, never appended to supabase/seed.sql; the deploy workflow never seeds production. Made-up names only, marked SYNTHETIC (a header saying so, and ext synthetic true on every row), every insert skipping a row that already exists, so it is safe to run twice. Money figures are lab values.
- Sites North depot and South depot. Customer One, Customer Two (customer), Supplier One (supplier). Addresses on longitude -81.50: Site A 41.10 and Site B 41.30 (Customer One), Site C 40.60 (Customer Two). Territories North (Sites A, B) and South (Site C), managed by the service manager.
- Items: PUMP-UNIT (serial controlled, skills pump, warranty_months 12), DRIVE-MODULE (serial controlled, skills controls, warranty_months 12), PUMP-SEAL (list_price 40), FILTER (20), LABOR-HOUR (100), TRAVEL-HOUR (50). Serial units SN-1001, SN-1001-D, SN-1002, SN-1003, SN-1004, SN-1005.
- Locations WH-1 (warehouse), VAN-1, VAN-2, VAN-3 (vehicle), CUSTOMERS (customer_site). Calendar FIELD with shift DAY 07:00 to 17:00, paid_break_min 60 (540 available minutes).
- People: Technician One (North, home 41.00, VAN-1, skills pump and controls), Technician Two (North, home 41.40, VAN-2, skills pump), Technician Three (South, home 40.50, VAN-3, skills pump and controls), a dispatcher, a service manager, a customer contact of Customer One. Every technician: van_min PUMP-SEAL 2 and FILTER 2, replenish_from WH-1.
- Sequences: SWO- next 11, WC- next 1, TXN- (padding 6) next 1.
- Sales orders: SO-1 (Customer One, 2025-09-01, Site A: SN-1001, SN-1001-D), SO-2 (2024-01-15, Site A: SN-1002), SO-3 (2025-06-12, Site B: SN-1003), SO-4 (Customer Two, 2024-03-01, Site C: SN-1004), SO-5 (2026-06-10, Site C: SN-1005). Six shipment ledger rows to CUSTOMERS, and eight opening adjustments: VAN-1 3 seals 2 filters, VAN-2 1 seal 2 filters, VAN-3 2 seals 2 filters, WH-1 20 of each (14 ledger rows, 8 balance rows).
- Installed assets: SN-1001 Site A, warranty 2025-09-01 to 2026-08-31; SN-1001-D its child, same dates; SN-1002 Site A, 2024-01-15 to 2025-01-14; SN-1003 Site B, 2025-06-12 to 2026-06-11; SN-1004 Site C, no warranty dates. Each with its serial unit and order. None for SN-1005.
- Contracts: C-100 (Customer One, maintenance, active, 2026-01-01 to 2026-12-31, response 4 h, resolution 24 h, covers labor and travel, Mon to Fri 08:00 to 17:00, holiday 2026-06-19) covering SN-1001 and SN-1002; C-200 (Customer One, maintenance, expired, 2025, response 8, resolution 48, covers labor, no business hours) covering SN-1003; C-300 (Customer Two, full_service, draft, 2026-07-01 to 2027-06-30, covers labor, travel, part, same hours as C-100) covering SN-1004. PM plans: PM-A on SN-1002 under C-100, every 6 months, next 2026-06-22, active; PM-B on SN-1003, 12 months, next 2026-09-01, active; PM-C on SN-1004 under C-300, 6 months, next 2026-05-01, not active.
- Eight completed jobs with their visits, sign-offs on the last visit, and ext.response_due_at and sla_due_at from C-100's hours:
SWO-0001 repair p2 SN-1002 C-100, booked Fri 2026-05-29 14:00, due Mon 06-01 09:00 / Wed 06-03 11:00; Technician One Mon 06-01, scheduled 08:30-10:30, on site 08:45-10:25, travel 30; fixed first time.
SWO-0002 preventive p3 SN-1002 C-100, no SLA; Technician One Tue 06-02 13:00-15:00, on site 13:00-14:30, travel 25; first time.
SWO-0003 repair p2 SN-1002 C-100, booked Fri 06-05 16:00, due Mon 06-08 11:00 / Wed 06-10 13:00; Technician Two Mon 06-08 10:00-12:00, on site 10:05-12:00, travel 35, not fixed; Tue 06-09 14:00-16:00, on site 14:00-15:30, travel 35, fixed; not first time.
SWO-0004 repair p1 SN-1002 C-100, booked Mon 04-27 08:30, due 04-27 12:30 / Wed 04-29 14:30; Technician Two Wed 04-29 15:00-17:00, on site 15:00-16:30, travel 30; first time; SLA missed.
SWO-0005 inspection p4 SN-1002 C-100, no SLA; Technician One Thu 06-04 08:00-09:00, on site 08:00-08:50, travel 15; first time.
SWO-0006 warranty p2 SN-1001 (covered_by warranty, under C-100), booked Tue 06-02 08:00, due 12:00 / Thu 06-04 14:00; Technician One Tue 06-02 10:00-12:00, on site 10:00-11:45, travel 30, not fixed; Fri 06-05 10:00-11:30, on site 10:10-11:20, travel 30, fixed; not first time; resolution missed.
SWO-0007 warranty p3 SN-1003, no contract, no SLA; Technician Two Mon 06-08 13:00-14:00, on site 13:05-13:55, travel 20; first time.
SWO-0008 repair p3 SN-1004, covered_by none, billable, no SLA; Technician Three Tue 06-09 09:00-10:00, on site 09:00-09:50, travel 60; first time.
- Nine service lines, ext history true, prices from list_price: SWO-0001 labor 2 and travel 0.5 (not billable) and one PUMP-SEAL from VAN-1 (billable); SWO-0006 labor 3, travel 1, one PUMP-SEAL, all warranty_covered; SWO-0008 labor 1, travel 1, one FILTER from VAN-3, all billable.
- Two dispatched jobs for Mon 2026-06-22 07:00 to 09:00: SWO-0009 repair p3 SN-1003 Site B, Technician One, billable, booked Thu 06-18 09:00; SWO-0010 repair p2 SN-1002 Site A, Technician Two, C-100, booked Thu 06-18 16:00, due Mon 06-22 11:00 / Wed 06-24 13:00.
Put the hand counts in tests/fixtures/fsm-counts.json and a test supabase/tests/fsm_seed.test.sql asserting, on the fixture and on the seed run twice: 2 territories, 3 sites, 5 assets, 3 contracts, 4 contract-asset links, 3 technicians, 3 PM plans, 10 work orders (8 completed, 2 dispatched), 12 appointments, 9 service lines, 8 sign-offs, 5 sales orders, 14 ledger rows, 8 balance rows. Push, open a pull request titled "Field service seed", wait for the checks, and tell me the result.When it is green, apply the migrations and the seed to the development project yourself, in a terminal (not inside Claude Code): db push --include-seed loads the new seed file the first time; after that, npm run seed:dev reloads it. Never reset the database. The password is in the password manager as Supabase: acme-platform-dev database password.
cd ~/code/acme-platform && git switch fsm/seed && git pullnpx supabase link --project-ref tsrqponmlkjihgfedcbanpx supabase db push --include-seedhttps://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/editor
The development project's Table Editor: open fsm_service_work_order.
You will see recreated screen
- Check the reference is tsrqponmlkjihgfedcba. If it shows abcdefghijklmnopqrst, stop: that is production.
- Only the field service migrations should be listed. Anything else, answer n and ask why.
You will see recreated screen
| swo_no | swo_type | status | billable | first_time_fix |
|---|---|---|---|---|
| SWO-0001 | repair | completed | false | true |
| SWO-0003 | repair | completed | false | false |
| SWO-0008 | repair | completed | true | true |
| SWO-0010 | repair | dispatched | false |
- Ten rows: eight completed, two dispatched for the coming Monday (2026-06-22 in the fixture).
Check it worked
The pull request is green; the development project shows the counts in tests/fixtures/fsm-counts.json; running the push again adds no rows. Then owner two approves, it merges, and the pipeline applies the migrations (not the seed) to production.
If it goes wrong
The terminal shows the production reference abcdefghijklmnopqrst
Answer n. Run npx supabase link --project-ref tsrqponmlkjihgfedcba again and read the reference before pushing. In this module only the pipeline changes production.
A later step expects a number the seed never made
We hit this in five Academy modules: exercises written against counts the seed did not create. Say: List every count tests/fixtures/fsm-counts.json promises and the seed line that creates each. Fix the seed, not the check.
Seed rows appear twice in the development project
Say: The seed added duplicates on a second run. Make every insert skip a row that already exists, on its natural key, and add a test that runs the seed twice.
Knowledge check
An asset's warranty ended yesterday, and the only contract that listed it has expired. A job is booked today. What does the entitlement check return?
Knowledge check
Where do you first apply a new field service migration and the seed?
References
- ISO 9001:2015, Quality management systems: requirements (clause 8.5.5, post-delivery activities). https://www.iso.org/standard/62085.html
- ISO 10002:2018, Customer satisfaction: guidelines for complaints handling in organizations. https://www.iso.org/standard/71580.html
- Salesforce Trailhead: Field Service basics. https://trailhead.salesforce.com/content/learn/modules/field_service_basics/field_service_basics_intro
- Supabase Docs: Seeding your database. https://supabase.com/docs/guides/local-development/seeding-your-database
- Supabase CLI reference: supabase db push. https://supabase.com/docs/reference/cli/supabase-db-push
Chapter 2 · Sessions 3 and 4
Who may do what, the screens, and a job from booking to billing
Session 3 writes the four field service roles into your role matrix, generates the access rules and builds four screens, including a phone screen that works with no signal. Session 4 builds the rules a job runs on (cover, the service clock, dispatch with travel time), completes a job offline with parts reaching the van's stock once, hands billable lines to accounting, and checks the measures against a hand count.
40 minSteps 6–11About 3 hours 15 minutes hands-on in these two sessions
By the end of this chapter you can
- Add the four roles, their scopes and four machine accounts to docs/matrix.json, and test the generated rules both ways.
- Build the dispatch board, the offline phone screen, the customer sign-off and the manager's desk, and pass the phone check.
- Prove the entitlement check, the service clock and dispatch with travel time against tables worked by hand.
- Complete a job offline so parts, time and the signature arrive once, hand billable lines on, and match the four measures.
Four roles, four machine accounts, three scopes
| Role | What it does | Screen | Scope |
|---|---|---|---|
| dispatcher | Books and schedules jobs; never releases to billing or changes billable | /service/dispatch | Whole site |
| technician | Does the work on a phone, often offline; reads past jobs on its own jobs' assets | /service/work | Own jobs, own van |
| service_manager | Contracts, territories, billing release and waivers, warranty claims, measures | /service/manage, /service/dispatch | Whole site |
| customer | A customer's contact: sees and signs off only its own company's jobs; never prices | /service/signoff | Own party |
| fsm_install_route, fsm_pm_engine, fsm_stock_route | Machine accounts: assets from shipments; preventive jobs and the SLA watch; parts to the ledger and replenishment | None | Narrow, per job |
| fsm_import | The importer, only through import-fsm.yml (Sessions 5 and 6), its password set by a person and named in docs/KEYS.md; set NOLOGIN at cut-over | None | Insert only |
Remember how Postgres applies a right: an update only finds rows the role can read, and the changed row must still pass the read rule; an insert that hands its new row back needs the read right too [1]. So each role reads every status of what it updates, and the narrower conditions (which status moves are allowed) live in the Session 4 status trigger.
Session 3: The roles into the matrix, the scopes in the generator, tested both ways
35 minutesWhy
Every access rule is generated from docs/matrix.json, so a right written there is enforced by the database for every screen, route and import, and a right missing there stops a technician in the middle of a job. The three scopes (own jobs, own van, own party) are what keep a technician out of other technicians' work and a customer out of another company's jobs and your prices; testing them both ways proves it.
Do this
Read docs/matrix.json, scripts/gen-policies.mjs, supabase/tests/access.test.sql and the M18 section of docs/spine-map.md.
On a new branch fsm/access:
1. Add three scopes to the generator, each with tests: own jobs (work orders with an appointment held by the signed-in technician), own van (the storage location on the technician's row), own party (rows whose party_id is the party in the signed-in contact's core_person.ext; appointments, sign-offs and attachments follow their work order).
2. Add the roles to docs/matrix.json, following how it already names roles and rights. Nobody gets delete.
- dispatcher (whole site): read the fsm_ tables except claims, sites, people (names only), items, van balances; insert work orders (status new, through the booking route) and appointments; update work orders (new to scheduled to dispatched, incomplete back to scheduled, cancel, priority, problem, required skills before on site), appointments, and parts requests to picked, shipped or cancelled.
- technician (own jobs, own van): read its jobs, their sites, assets, contracts, plans, lines and sign-offs, and past jobs on those assets (read only); its van's balance; insert service lines, sign-offs, parts requests (requested), attachments and comments on own jobs; update its appointments (arrival, departure, travel, the moves to en_route, on_site, completed, no_access) and its jobs (en_route, on_site, completed, incomplete, resolution, first_time_fix).
- service_manager (whole site): read everything in the module and the ledger; insert and update territories, sites, assets, contracts and their assets, technicians, PM plans, warranty claims, lines before billing, parts requests; on work orders also billable, service_contract_id, sla_due_at, ext.billing_waived (with a core_comment) and completed to ready_to_bill to billed.
- customer (own party): read its work orders, appointments, sites, assets, contracts, sign-offs and its reports; insert a sign-off for its own completed appointment with a typed name. Nothing on service lines or technicians.
- machine accounts: fsm_install_route (read shipments and serial units, insert installed assets); fsm_pm_engine (read plans and jobs, update next_due_at, insert work orders); fsm_stock_route (read lines, jobs, appointments, technicians, requests, calendars, balances and ledger; insert ledger rows and parts requests; update only a line's ext.inventory_txn_id and requests to received); fsm_import (insert only: the module's tables, a stand-in technician; read what it matches; never update or delete). Every machine account signs in with its own password, set by a person and listed by name in docs/KEYS.md, never the service key.
- core_event_outbox, core_audit_log, inv_inventory_balance and core_number_sequence: no role gets any right; triggers and security definer functions write them.
3. Run node scripts/gen-policies.mjs (Session 8). Add supabase/tests/fsm_access.test.sql with one allowed and one refused case per role and table, and these refusals: a technician reading another technician's job; the Customer One contact reading Customer Two's jobs or any service line; a dispatcher moving a job to ready_to_bill; a technician whose membership has ended reading anything. For an update, check the row really changed.
4. Write docs/fsm-rights-check.md: one line per action of Sessions 4 to 6 (book, generate preventive jobs, dispatch, complete offline, post parts, release and export billing, replenish, import), who does it, the table, the action and the matrix cell; and a test that fails if a line has no cell, skipping lines marked retired.
If the matrix cannot express a rule, stop and tell me which before writing anything around it. Push, open a pull request titled "Field service access rules", wait for the checks and tell me the result.You will see recreated screen
- The customer has no right at all on service lines, so a customer never reads your prices.
- Allowed and refused are both tested. A test that only checks refusals passes even when nothing works.
Check it worked
Pull request Field service access rules is green, including the four named refusals and the rights-check test.
If it goes wrong
A technician's Complete reports success but the job does not change
We hit this in three Academy modules: an update only finds rows the role can read, and the changed row must still pass the read rule. Say: Make the technician's read rule cover the job before and after the move, and add a test that the row really changed.
The "policies" or "rights-check" check fails though your change looks right
It compares a generated list with the code. Say: Open the failing check's log, regenerate the list it compares against, commit it, and show me what changed.
Claude Code loosened a test to make it pass
Say: Never edit, skip or loosen a test or a check to get to green. Put it back, and explain why you think it is wrong; I will decide.
Session 3: Four screens, and a phone screen that works with no signal
40 minutesWhy
A technician is often where there is no signal, and a job recorded on paper and typed later loses parts, times and signatures. Reusing the Foundation offline outbox, with an id made on the phone for every entry, means a job completed in a basement arrives once, however many times the phone retries. Building every screen behind the default-deny sign-in and testing it at phone width, with gloves in mind, is what makes it usable on the van.
Do this
Read node_modules/next/dist/docs/ first: this Next.js version differs from older guides, and request middleware lives in proxy.ts. Then read proxy.ts, lib/access/routes.ts, docs/matrix.json and the operator screens and offline outbox from Foundation Session 12.
On a new branch fsm/screens, add four screens, each listed in docs/matrix.json with its roles and regenerated into lib/access/routes.ts with scripts/gen-routes.mjs:
1. /service/dispatch (dispatcher, service_manager): each technician's day in time order, and jobs waiting; on a desktop drag a job onto a technician; on a phone the same move is two taps.
2. /service/work (technician): today's and the next days' jobs; one job with site, asset, history, problem; buttons On my way, Arrived, Add part, Add time, Photo, Resolution, Customer signs, Complete. Save the jobs, sites, assets, history and the van's parts to IndexedDB at sign-in with a "last updated" time, and put every action in the Session 12 outbox with an id from crypto.randomUUID(), so a repeat send adds nothing. Main buttons 64 px for gloves.
3. /service/signoff (customer; and the same component inside /service/work, handed to the customer): its own completed jobs, the report, a typed name and a satisfaction score.
4. /service/manage (service_manager): contracts, billing release, claims and measures.
Every read and write uses the signed-in person's session, never the secret key; authors and times come from the session and the server. Customer names and addresses never go to the logs. If a value is not stored, show "No data".
Add screen tests at 360 and 390 px (no sideways scroll, 44 px targets, 16 px fields), per screen a signed-out request landing on sign-in and a refused role, and a test with the browser offline that queues an action and sends it once on reconnect. Push, open a pull request titled "Field service screens", wait for the checks, and give me the preview link.Open the preview on your phone, sign in as yourself, and put the phone in airplane mode on /service/work: the screen must still open. Then sit a dispatcher at the board and a technician at the phone screen, and do not explain. Write down where each stops.
You will see recreated screen
- Actions queue on the phone with their own ids and send once when the signal returns.
- The customer signs on the technician's phone; the image is uploaded with the entry.
You will see recreated screen
- One offline queue for the whole platform. Two would mean two ways for data to be lost.
Check it worked
The pull request is green with the phone, refused-role and offline-once tests; the preview's phone screen opens in airplane mode; you have the dispatcher's and technician's notes.
If it goes wrong
Claude Code creates middleware.ts
Say: Read node_modules/next/dist/docs/ for this version. Request middleware is proxy.ts here; use the existing one.
The phone screen is blank in airplane mode
The data was never saved to the phone. Say: Save the next days' jobs and the van's parts to IndexedDB at sign-in, show the last updated time, and add a test that opens the screen with the network off.
A link on the new screens opens a blank 404
We hit this: a link that compiles is not a link that resolves. Say: Open every page and every link on the four screens as each role and list every 404 or error.
The preview asks you to sign in to Vercel
That is Vercel's deployment protection on previews, not your code. Sign in with your team account.
Knowledge check
A phone sends the same completed-job entry twice because the first confirmation was lost. What must the server do?
The rules a job runs on
The service clock counts only hours inside the contract's opening periods on days that are not holidays; a booking outside opening hours starts counting at the next opening; a contract with no business hours counts every hour. Only repair and warranty jobs under a contract carry an SLA due time.
| Contract | Starts | Target | Due |
|---|---|---|---|
| C-100 | Fri 12 Jun 16:00 | 4 hours | Mon 15 Jun 11:00 |
| C-100 | Fri 12 Jun 16:00 | 24 hours | Wed 17 Jun 13:00 |
| C-100, Fri 19 Jun a holiday | Thu 18 Jun 16:00 | 4 and 24 hours | Mon 22 Jun 11:00 and Wed 24 Jun 13:00 |
| C-200 (no business hours) | Fri 12 Jun 16:00 | 8 hours | Sat 13 Jun 00:00 |
Dispatch offers a technician only if active, in the job's territory and holding every skill the job needs, ordered by earliest arrival: the later of the window start and the previous appointment's end (or the shift start) plus the travel time. Travel is the straight-line distance at 111.2 km per degree of latitude and 60 km/h, rounded to minutes: lab values, so measure your own speed, and use a great-circle distance for real sites. Nothing in this course needs a paid routing service.
Session 4: Cover, the service clock and booking, proven against the tables
25 minutesWhy
Booking is where money is decided: a job for an asset out of warranty and out of contract must be billable, and a job under a contract must carry the due times its business hours give. These are pure rules with known answers, so checking every row of the tables above before any screen uses them is the cheapest place to find a wrong one. Every function takes the time as a parameter, so no test ever depends on today's date.
Do this
Read docs/fsm-rules.md, tests/fixtures/fsm-worked.json, tests/fixtures/fsm-counts.json and docs/matrix.json. Every test below with a fixed date runs on the fixture, never on the shifted seed.
On a new branch fsm/rules, a migration (npx supabase migration new fsm_rules) and tests in supabase/tests/fsm_rules.test.sql:
1. fsm_create_installed_base(sales_order_id), behind /api/fsm/install (fsm_install_route): one active asset per serial-carrying shipment row of the order, with party, site (the customer's site at the order's ship-to address), serial unit, order, and warranty from the shipping date for the item's warranty_months less one day; a serial-controlled shipment with no serial is refused and listed, never guessed; a repeat run adds nothing. Test: SO-5 gives SN-1005 at Site C, warranty 2026-06-10 to 2027-06-09; a second run still 6 assets.
2. fsm_check_entitlement(installed_asset_id, as_of date) returning covered_by, contract_id, billable: warranty if both dates are set and include the date (both ends included); else contract if an active contract lists the asset and its dates include the date; else none and billable. Test: SN-1001 2026-06-18 warranty with C-100; SN-1001-D warranty; SN-1002 contract C-100; SN-1003 2026-06-11 warranty, 2026-06-12 none and billable; SN-1004 2026-06-18 and 2026-07-01 none and billable; SN-1005 2026-06-18 warranty.
3. fsm_sla_due(contract_id, from_ts, hours) reading entitlements.business_hours. Test every row: C-100 from Fri 2026-06-12 16:00: 4 h Mon 06-15 11:00, 24 h Wed 06-17 13:00; from Thu 06-18 16:00: Mon 06-22 11:00 and Wed 06-24 13:00; from Fri 06-19 09:00 (the holiday): Mon 06-22 12:00 and Wed 06-24 14:00; C-200 from Fri 06-12 16:00, 8 h: Sat 06-13 00:00. SWO-0010 in the seed carries the Thursday answers.
4. fsm_book_job and /api/fsm/book (dispatcher, service_manager): party and site from the asset; the entitlement check at booked_at; billable, contract and ext.covered_by; ext.required_skills from the item; swo_no from the sequence; status new; ext.response_due_at and sla_due_at only for repair and warranty jobs under a contract; case_ref kept when given. Only the service_manager may later change billable, service_contract_id, sla_due_at or ext.billing_waived, with a core_comment. Test: SN-1004 repair p3 at Thu 06-18 10:00 gives SWO-0011, billable, no SLA; SN-1001-D repair p2 at Thu 06-18 16:30 gives SWO-0012, warranty, skill controls, no SLA; SN-1002 repair p2 at Fri 06-19 09:00 gives SWO-0013, C-100, due Mon 06-22 12:00 and Wed 06-24 14:00; the dispatcher changing billable is refused.
Show each test failing once with its function deliberately broken, then passing. Push, open a pull request titled "Field service rules", wait for the checks, and tell me the result.You will see recreated screen
- Red first, on purpose: proof the test can fail.
- The first item of the module's definition of done: out of warranty and out of contract means billable.
Check it worked
The pull request is green; every entitlement row and every service-clock answer matches the tables; booking SN-1004 gave a billable SWO-0011; you have applied it to the development project by the routine after Step 5.
If it goes wrong
SN-1003 on its last warranty day comes out as not covered
The function leaves out the end date. Say: Both ends of the warranty dates are included. Keep the test; fix the function.
The 4-hour answer for Thursday 16:00 is Thursday 20:00
The clock counts calendar hours. Say: Count only hours inside the contract's opening periods on days that are not holidays, starting at the next opening. This is the third item of the definition of done.
A test depends on today's date and fails tomorrow
Say: Every function takes the time as a parameter. No test may read the clock.
Session 4: Preventive jobs, dispatch with travel time, and no double booking
30 minutesWhy
A board that only checks who is free puts a technician in two towns at once; counting the drive between jobs is what makes a promise to a customer keepable. Preventive jobs must come from the plan by themselves, once, so a repeated run never floods the board. The status trigger and the overlap rule make the board's mistakes impossible to save, whoever makes them.
Do this
On a new branch fsm/dispatch, a migration (npx supabase migration new fsm_dispatch) and tests in supabase/tests/fsm_dispatch.test.sql:
1. fsm_generate_pm(as_of timestamptz), run by fsm_pm_engine: for each active plan due on or before the date with no open job carrying its pm_plan_id, book a preventive job through fsm_book_job (no SLA) and move next_due_at forward from the previous due date by interval_months. Test: as_of 2026-06-22 06:00 gives exactly one job, SWO-0014, SN-1002, C-100, not billable; PM-A next due 2026-12-22; a second run makes nothing; a second open job for PM-A inserted by hand is refused.
2. fsm_suggest_technicians(work_order_id, window_start, window_end, ignore_travel): active, same territory, every required skill; ETA = the later of window_start and (previous appointment's end, or the shift start, plus travel); travel = straight-line distance from core_address at 111.2 km per degree of latitude and 60 km/h, rounded to minutes; ordered by ETA then travel. Write the rules in docs/fsm-rules.md. Test, Mon 2026-06-22, window 09:00 to 12:00: SWO-0014 offers Technician Two at 09:00 (0 min) then Technician One at 09:22 (22 min), not Technician Three; with travel ignored both show 09:00; SWO-0012 offers only Technician One at 09:22; SWO-0011 offers only Technician Three at 09:00.
3. A status trigger: new, scheduled, dispatched, en_route, on_site, then completed or incomplete; incomplete back to scheduled; completed to ready_to_bill to billed only by the service_manager; any open status to cancelled.
4. An exclusion constraint (btree_gist) so one technician cannot hold overlapping appointments, on tstzrange(scheduled_start, scheduled_end, '[)'), ignoring cancelled and imported rows.
5. When an appointment moves to dispatched, a security definer trigger writes fsm.appointment.dispatched to core_event_outbox and an in-app core_notification for the technician. Nothing is texted or emailed.
Test: assign SWO-0014 to Technician Two 09:00 to 10:00 and SWO-0012 to Technician One 09:22 to 10:22, dispatch both: 14 appointments, 2 notifications, 2 events; a second Technician Two appointment 09:30 to 10:30 is refused.
Show each test failing once with its rule removed. Push, open a pull request titled "Field service dispatch", wait for the checks, and tell me the result.You will see recreated screen
| Technician | 07:00 | 09:00 | 09:22 |
|---|---|---|---|
| Technician One | SWO-0009 Site B | SWO-0012 Site A | |
| Technician Two | SWO-0010 Site A | SWO-0014 Site A |
- Without the drive, both technicians would show 09:00.
- Each day in time order, with the drive between jobs.
- The database refuses the overlap, whoever drags the job.
Check it worked
The pull request is green; the suggestions come in the order and at the times above; one preventive job and no second; the overlap is refused; you have applied it to the development project.
If it goes wrong
Technician Three is offered at 09:11, not 09:00
The drive was added to the window start. Say: Add the travel time to the previous end or the shift start only, then take the later of that and the window start.
Two visits back to back at 09:00 are refused
The range includes its end. Say: Use a half-open range, [scheduled_start, scheduled_end), so a visit ending at 09:00 and one starting at 09:00 do not clash.
The preventive engine made a second job on a second run
Say: Show me the partial unique index refusing a second open job for one plan, and move next_due_at forward from the previous due date.
Completed offline, parts on the ledger, lines to accounting
| Line | Billable? | Rule |
|---|---|---|
| Any line on a job covered by warranty | No | warranty_covered is true |
| A line whose type is in the contract's covers | No | Covered by contract |
| Any line on a job the manager waived | No | ext.billing_waived true, with the reason in a core_comment |
| Any other line | Yes | Priced by the server from the item's list price |
Session 4: Complete a job offline, post the parts once, and hand billing on
35 minutesWhy
This is the module's second promise: a job completed with no signal syncs parts usage to the van's stock without losing parts, time or the signature, and without counting anything twice. The server, never the phone, sets prices and billable, so a phone cannot change what a customer pays. A CSV export of the billable lines is the free hand-off accounting can import and re-check.
Do this
Read node_modules/next/dist/docs/ for route handlers in this Next.js version, then docs/fsm-rules.md and docs/matrix.json.
On a new branch fsm/complete:
1. Extend the sync route for /service/work: each entry applied once by its id; an entry for a job cancelled meanwhile is refused with a conflict, kept in the queue and shown to the technician; the phone's arrival and departure kept, with the server's synced_at. The server sets each line's unit_price from list_price and billable and warranty_covered by the table in docs/fsm-rules.md (warranty: none billable; contract: types in covers not billable; waived: none billable; otherwise billable). Attachments (photo, signature, report) are core_attachment owned by the appointment, in a private bucket that allows insert and read only.
2. /api/fsm/parts (fsm_stock_route): for each part line of the caller's own van and job with no ext.inventory_txn_id, one ledger row from the van (ref_type fsm_service_line), and the ledger id written back on the line, in one transaction. A used part is never refused for lack of stock.
3. On completion: the service report as an HTML page with its sha256, first_time_fix true when the job had one visit, fsm.work_order.completed from a security definer trigger.
4. /api/fsm/signoff for the customer's typed sign-off, with the server clock and the existing report.
5. A security invoker view fsm_v_billable_lines; the service_manager's Release to billing (completed to ready_to_bill only with a billable line, a sign-off, and a ledger id on every part line, history lines exempt); /api/fsm/billing-export returning the lines as CSV and moving those jobs to billed.
Then a journey test, signing in the seed people the way the Session 19 journeys sign in test users, with the browser offline for the technician:
- Technician Two completes SWO-0010 offline (arrived 07:10, labour 1.5 h, travel 30 min, one PUMP-SEAL, a photo, a made-up signer, satisfaction 5, left 08:45), then reconnects: 3 lines (labour and travel not billable, the seal billable at 40), VAN-2 seal balance 1 to 0, one sign-off, 3 attachments, one completed event. Sending the same entry and part line again changes nothing; updating the sign-off is refused.
- Technician Two completes SWO-0014 with no customer present; the Customer One contact signs it off on /service/signoff and sees none of Customer Two's jobs (no SWO-0008 or SWO-0011).
- The service manager releases SWO-0001, SWO-0008 and SWO-0010; the export has 5 lines totalling 250 (40 + 100 + 50 + 20 + 40); the three jobs are billed; a second export is empty; releasing SWO-0014 or SWO-0011, or a dispatcher's release, is refused.
Print a short summary of each check. Push, open a pull request titled "Field service completion and billing", wait for the checks, and tell me the result.You will see recreated screen
- The second promise of the module, proven: parts reach the van's stock once.
- The numbers you can check by hand: 5 lines, 250.
You will see recreated screen
- The signed-off report is stored with its fingerprint and can never be changed.
Check it worked
The journey is green and its summary shows SWO-0010's lines, VAN-2 at 0, nothing changed on a second send, the sign-off refused on update, Customer Two's jobs hidden and the export of 5 lines totalling 250. You have applied it to the development project.
Fastest path
One journey test replaces a morning of switching between four sign-ins and a phone in airplane mode, and it runs again on every pull request from now on.
If it goes wrong
The van's balance went down twice for one part
Say: Skip a line whose ext.inventory_txn_id is set, and add the unique index on ref_type, ref_id and txn_type to the ledger, with a test that posts the same line twice.
The phone sends a price and the server keeps it
Say: Ignore any price or billable flag from the phone; set them on the server from the item and the job.
The summary says passed but the check on GitHub is red
Say: Show me the exact command, its exit code and the last 20 lines of its output. We recorded a run that printed npm: not found and, minutes later, reported 1,326 tests passing.
Session 4: Vans, the SLA watch and the four measures, against a hand count
30 minutesWhy
A measure without its definition, or one never checked against a count you did yourself, is a number on a screen. Writing each definition down and matching the views to the seed's hand count means the figures you compare with the old tool in Session 6 are real. Replenishment and the SLA watch turn the van's shortfall and a job close to its due time into something someone sees, without a message being sent.
Do this
On a new branch fsm/measures, a migration (npx supabase migration new fsm_measures) and tests:
1. fsm_replenish_vans(), behind /api/fsm/replenish (fsm_stock_route): for each active technician and item in ext.van_min, when the van is below the minimum and no request is open, one parts request for the difference, needed by the start of the next shift. Receiving posts two ledger rows in one transaction (out of WH-1, into the van). Test after SWO-0010: one request, Technician Two, 2 seals; a second run still one; received: VAN-2 2, WH-1 18, 17 ledger rows.
2. fsm_sla_watch(as_of), security definer, run by fsm_pm_engine: one fsm.sla.breach_risk event per open job due within 2 hours (a lab value). Test: 2026-06-24 11:30 none; 12:30 exactly one, for SWO-0013; again, still one.
3. fsm_kpi(period_from, period_to), security invoker, with definitions written in docs/fsm-rules.md: first-time fix (jobs that reached completed, ready_to_bill or billed, with first_time_fix true, over those with it filled in); SLA attainment (first arrival not after ext.response_due_at and last departure not after sla_due_at, over jobs with sla_due_at); utilisation (on-site plus travel minutes of completed visits over 540 minutes a day); repeat visits (repair and warranty jobs starting within 30 days after an earlier one on the same asset, over repair and warranty jobs). Test for 2026-04-01 to 2026-06-11: first-time fix 6 of 8, 75.0%; SLA attainment 2 of 4, 50.0%; repeat visits 1 of 6, 16.7%; Technician One on 2026-06-02: 250 of 540 minutes, 46.3%.
4. The measures on /service/manage, each with its definition beside it, and "No data" where a measure has nothing to count.
Show each test failing once with its rule broken. Push, open a pull request titled "Field service measures", wait for the checks, and tell me the result.You will see recreated screen
| Measure | Value | Count | Definition |
|---|---|---|---|
| First-time fix | 75.0% | 6 of 8 | completed jobs fixed on the first visit |
| SLA attainment | 50.0% | 2 of 4 | jobs under SLA meeting both targets |
| Repeat visits | 16.7% | 1 of 6 | repair or warranty within 30 days on the same asset |
| Utilisation, Technician One, 2 Jun | 46.3% | 250 of 540 min | on-site plus travel over available |
- Your hand count from the seed, exactly. If they differ, fix the query, not the count.
- Nothing is texted or emailed; the free way comes first.
Check it worked
The pull request is green; the four measures match 75.0%, 50.0%, 16.7% and 46.3% exactly; replenishment gives one request and the right balances; the SLA watch writes its one event once; you have applied it to the development project.
If it goes wrong
First-time fix drops after billing
The query counts status completed only. Say: Count jobs that reached completed: status completed, ready_to_bill or billed.
Repeat visits says 2 of 6
SWO-0004 is 33 days before SWO-0001, outside the 30 days. Say: Measure from the earlier job's last departure to the later job's first arrival, and keep the test at 1 of 6.
A measure shows 0% where nothing was measured
Say: Show No data when the denominator is zero. On our platform a chart graded twelve made-up points "In control"; a zero that means nothing is the same mistake.
Knowledge check
Contract C-100 counts Monday to Friday, 08:00 to 17:00, with no holiday that week. A 4-hour response starts on Friday at 16:00. When is it due?
Knowledge check
Who sets the unit price and the billable flag on a service line?
References
- Supabase Docs: Row Level Security. https://supabase.com/docs/guides/database/postgres/row-level-security
- ISO 9001:2015, Quality management systems: requirements. https://www.iso.org/standard/62085.html
- W3C: Indexed Database API (the browser database used for offline work). https://www.w3.org/TR/IndexedDB/
- PostgreSQL Documentation: Exclusion constraints. https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-EXCLUSION
- ServiceTitan: field service dispatch app. https://servicetitan.com/blog/field-service-dispatch-app
Chapter 3 · Sessions 5 and 6
Move the real data, cut over and switch the old tool off
Session 5 builds the importer and the pre-cut-over checks and rehearses them on the development project with a copy IT has approved. Session 6 imports the real records into production through the import workflow, started by a person from main with an export owner two approved, checks the counts, runs both tools side by side for a week, completes a real job on a real phone in airplane mode, cuts over, closes the importer and cancels the old tool with the saving written down.
30 minSteps 12–14About 2 hours 15 minutes hands-on in these two sessions, plus a side-by-side week
By the end of this chapter you can
- Build an import that is a dry run by default, adds nothing on a second run, and accounts for every row.
- Rehearse on the development project with an IT-approved copy, then import into production through import-fsm.yml from main with an approved export, never from a laptop.
- Check before cut-over that every asset has a site and every active contract an end date in the future.
- Cut over, close the importer, and cancel the old tool with the saving taken from invoices.
Six imports, in order
- Every row keeps where it came from (the old tool's name and old id in ext), and the importer finds rows by them, so a re-run or a resumed import adds nothing twice.
- Assets are matched to shipped serials: matched (unit and order taken from the shipment), near match (a person decides), no match (imported with the serial as text, and listed). Write the matched share: this is pitfall 1 on real data.
- Every contract needs an end date. One the old tool rolls over with none gets its next renewal date and is listed for the service manager; one whose end is past is imported as expired.
- Open jobs keep the old number as OLD- followed by it, so it never clashes with the sequence; the entitlement check is re-run as of each booking date and every difference from the old billable flag is listed and decided.
- Closed jobs arrive as history in their final state: nothing fires, nothing posts to the ledger, nothing is billed again. Import at least 30 days before the period you measure, for repeat visits.
- Counts reconcile: for each kind, rows in the export = imported + matched + skipped, with every skipped row explained.
| Check before cut-over | Must be |
|---|---|
| Installed assets with no service site | 0 |
| Active contracts whose end date is past | 0 |
| Assets of serial-controlled items with no serial unit | Each has a written decision |
| Open jobs with no site; scheduled or dispatched jobs with no appointment | 0 |
| Two assets with one item and serial | 0 |
Session 5: The importer and the checks, rehearsed on the development project
45 minutesWhy
An import is the one time a large amount of data enters at once, so it must be repeatable, honest about every row it could not place, and impossible to run from a laptop by accident. Customer sites and contacts are personal data, so even a rehearsal needs IT's written yes. A dry run, a second run that adds nothing and counts that reconcile prove the importer before any real record moves; the development project is where a mapping error costs nothing.
Do this
Real records include customers' sites, contacts and signatures. Before they go anywhere but the old tool, get IT's written yes:
To: IT
Subject: Rehearsing the field service import on our development project
We are replacing <old tool> with the field service module on the Acme Bottling platform. Before importing into production, we want to rehearse once on our development Supabase project (acme-platform-dev) with a copy of the export: customers and sites (names, addresses, access notes), installed assets and serials, contracts, preventive plans, open jobs and closed jobs. This includes personal data, which would be redacted first (contact names, phone numbers and access notes replaced). No signature images.
The copy would be uploaded by me to a private storage bucket in that project, used for one rehearsal, and removed from the project the same day, with the date recorded in docs/imports/fsm-approved.md. Logs and reports show counts and job numbers only.
Please reply "approved", or tell us what to change.Read docs/fsm-inventory.md, the M18 section of docs/spine-map.md, docs/fsm-rules.md, docs/matrix.json and the deploy workflow from Session 11.
On a new branch fsm/import:
1. docs/fsm-import-plan.md: for each of the six kinds (customers and sites, assets, contracts, preventive plans, open jobs, closed jobs) the old fields beside the new columns, and the fields the export lacks; the old statuses mapped to the ten; the old contract types mapped to the five; what stays in the final export.
2. scripts/fsm-import.mjs, running as the fsm_import database role, which is insert-only (no update, no delete; created NOLOGIN by a migration, its login turned on by a person with a password they set and name in docs/KEYS.md): a dry run by default that writes nothing; --apply to write; the six kinds in order, parents before children; ext.imported_from and ext.old_id on every row, used to find rows on a re-run; assets matched to shipped serials (matched, near, none); contracts with no end date given the next renewal date and listed; open jobs as OLD-<number>, technicians matched by work email, the entitlement check re-run and every difference listed; closed jobs as history (lines ext.history true, nothing to the ledger, no events). Every row ends imported, matched or skipped with a reason; counts per kind reconcile.
3. scripts/fsm-precheck.sql, read only, as the service_manager: the five checks before cut-over.
4. .github/workflows/import-fsm.yml, run by hand only (workflow_dispatch) from main, refusing any other branch, inputs target (development or production) and mode (dry-run or apply). It fetches the export from the private Storage bucket imports in the target project; refuses it unless every file's sha256 and expected counts are listed in docs/imports/fsm-approved.md on main; runs the importer in one transaction and then the pre-checks; fails, keeping nothing, on any count that differs from the approved file; and writes counts, job numbers of exceptions and the matched-serial share to the job summary: never names, addresses or notes. It signs in as fsm_import with that target's password secret (FSM_IMPORT_PASSWORD_DEV or FSM_IMPORT_PASSWORD), which I add; tell me if it needs any other secret. No GitHub environment with required reviewers (the Team plan does not offer them for private repositories): the reviewed pull request that merges the approved file is the approval.
5. Tests with a small synthetic export: dry run writes nothing; apply then apply again adds nothing; an asset with no site is caught by the pre-check; counts reconcile; a file whose sha256 is not approved is refused; a count mismatch fails and keeps nothing; fsm_import cannot update or delete.
Push, open a pull request titled "Field service importer", wait for the checks, and tell me the result.When IT has approved and the pull request has merged: in the development project's SQL editor turn on fsm_import's login with a password you make (alter role fsm_import login password '…'), keep it in the password manager, add it as the Actions secret FSM_IMPORT_PASSWORD_DEV and name it in docs/KEYS.md. Upload the redacted copy to the bucket imports in the development project and record its fingerprints.
https://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/storage/buckets
Create a private bucket named imports (Public off) and upload the export copy.
shasum -a 256 *On a new branch fsm/import-approval, write docs/imports/fsm-approved.md with a section "Rehearsal (development project only)": each file's name, sha256 and expected rows per kind (I paste them below), the date taken, what was redacted, and IT's written approval (date and role). File names, fingerprints and counts only: no customer data. Open a pull request titled "Field service: approve rehearsal export".
<paste the shasum lines and the counts>Owner two reviews and approves; merge. Then run the workflow on the development project as a dry run, then apply, then apply again.
https://github.com/acme-ops/acme-platform/actions/workflows/import-fsm.yml
Run workflow: target development, mode dry-run. Read the summary. Then apply, then apply once more.
You will see recreated screen
| Kind | Export | Imported | Matched | Skipped |
|---|---|---|---|---|
| Sites | 412 | 398 | 12 | 2 |
| Assets | 1,286 | 1,251 | 0 | 35 |
| Contracts | 251 | 251 | 0 | 0 |
| Open jobs | 64 | 64 | 0 | 0 |
| Closed jobs | 3,904 | 3,904 | 0 | 0 |
- Export = imported + matched + skipped, for every kind.
- Pitfall 1 on your real data, as a number.
- Zero before anything goes to production.
Check it worked
The dry run wrote nothing; apply reconciled every kind with every skipped row explained; the second apply added nothing; the pre-checks are at zero. Then remove the copy from the development project the same day (its imported rows and the file in the bucket) and record the date in docs/imports/fsm-approved.md.
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.
The workflow fails with Invalid URL, or the address is refused
We hit this: a database address pasted with quotes, a NAME= prefix, a space or an unencoded character in the password. Re-enter the secret with the value only. Say: Report which problem the address has without printing it.
The job summary shows a customer's name or address
Stop. Say: Remove every name, address and note from the summary and the logs; counts and job numbers only. Then delete the run's logs on GitHub.
The second apply added rows
Say: The importer is not idempotent. Find each kind where a second run inserts, match on ext.old_id, and add the test.
IT has not answered
Wait. Rehearse with the synthetic export only. Real records do not move without the written yes.
Knowledge check
Why are closed jobs from the old tool imported as history?
Four measures, written next to their numbers
| Measure | How the module counts it |
|---|---|
| First-time fix rate | Jobs that reached completed with first_time_fix true, over those where it is filled in |
| SLA attainment | Jobs whose first arrival met the response due and last departure met sla_due_at, over jobs with an SLA |
| Technician utilisation | On-site plus travel minutes of completed visits, over the shift less the paid break (a lab choice: write yours) |
| Repeat visit rate | Repair and warranty jobs within 30 days after an earlier one on the same asset, over repair and warranty jobs |
Session 6: Import into production through the pipeline, and check the counts
30 minutesWhy
Production changes only through reviewed code run by the pipeline, never from a laptop: a deploy from a laptop once sent local settings to our production and broke three pages. Running the same workflow that passed the rehearsal, started by you from main, on an export whose fingerprints and counts owner two approved in a reviewed pull request, means the import that reaches production is exactly the one you checked, and the counts prove nothing was lost or added twice.
Do this
Take the final export. Upload it to a private bucket imports in the production project. Turn on fsm_import's login in production with a new password you make, keep it in the password manager, add it as the Actions secret FSM_IMPORT_PASSWORD and name it in docs/KEYS.md.
https://supabase.com/dashboard/project/abcdefghijklmnopqrst/storage/buckets
Production project storage: a private bucket imports, Public off. Upload the export.
On a new branch fsm/import-production, add a section "Production" to docs/imports/fsm-approved.md: each file's name, sha256 and expected rows per kind, and the date taken. Open a pull request titled "Field service: approve production export".
<paste the shasum lines and the counts>Owner two reviews and approves; merge. Then run the workflow, first as a dry run.
https://github.com/acme-ops/acme-platform/actions/workflows/import-fsm.yml
Run workflow from main: target production, mode dry-run. Compare with the rehearsal and the approved file. Then mode apply.
Then record the result and the baseline:
The production import has run (run <paste the run link>). On a new branch fsm/import-report, add to docs/fsm-import-plan.md from its job summary: the date, who ran it and who watched, the counts per kind, every skipped row's reason, the matched-serial share, the pre-checks, and the date the development copy was removed (from docs/imports/fsm-approved.md). Then run fsm_kpi over the imported closed jobs for the four weeks in docs/fsm-inventory.md section 5, and put the four measures beside the old tool's own figures, explaining every difference by definition. No customer names or addresses. Open a pull request titled "Field service import report".You will see recreated screen
- Always main: the code that ran in the rehearsal, reviewed and merged.
- Owner two approved these fingerprints and counts in a reviewed pull request; any other file is refused.
You will see recreated screen
- A difference explained by definition is not a defect. One you cannot explain means you are not ready.
Check it worked
Production's counts match docs/imports/fsm-approved.md with the same explained skips as the rehearsal, the pre-checks are at zero, and the import report with the baseline is merged.
If it goes wrong
The run fails: a count differs from the approved file
Nothing was kept: the import runs in one transaction. Find why (a re-export, a filter in the old tool) 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/fsm-approved.md is the approval.
A count differs from the rehearsal
Stop before cut-over. Say: Compare the production and rehearsal summaries and list every count that differs, with the job numbers behind it.
Someone suggests running the importer from a laptop to save time
Do not. Production comes only from main through the pipeline. A laptop run uses whatever is on that laptop.
The module's first-time fix is far from the old tool's
Read both definitions first: business against calendar hours, incomplete visits left in or out, travel counted as work. Write the cause beside the number; never adjust the query to match.
Session 6: Side by side, a real phone offline, cut over, and cancel
60 minutes, after a side-by-side weekWhy
A week in which every job of one pilot territory is booked and completed in both tools shows whether the module does the same work before anyone depends on it alone. A real job completed on a real phone in airplane mode is the test the journey cannot be. Closing the importer, and cancelling the old tool only after the final export is stored, turns the saving into a fact with a date.
Do this
For one week, the dispatcher books every job of one pilot territory in both tools, and the technicians complete it in both. During the week, one technician completes a real job on the phone screen with the phone in airplane mode, then reconnects. Then:
On a new branch fsm/cutover, write docs/fsm-cutover.md:
1. The side-by-side week: jobs booked, completed and open, first-time fix, SLA attainment, utilisation, repeat visits, and billable lines with their total, from the old tool's report (I will paste it) beside fsm_kpi and the billing view; every difference explained.
2. The module's promises, each with one query run as the right role on production: (a) every job booked this week for an asset out of warranty and out of contract is billable, or has the service manager's comment saying why; (b) every completed part line has a ledger id, and each van's balance equals its ledger; (c) three SLA due times worked out by hand match the stored ones; (d) every completed job has a sign-off or a written reason, and a sign-off update is refused; (e) every asset has a site.
3. The real-phone test: the job number, the counts before and after reconnecting, and that a second send changed nothing.
4. The cut-over: the date, who tells the technicians and the customers (any texts the old tool sent will stop, because this module sends none), the delta import through the same workflow (its export's sha256 and counts approved in docs/imports/fsm-approved.md first), who keeps the final export and where, and the rollback plan.
Then close the importer: remove fsm_import from docs/matrix.json, regenerate the access rules, add a migration that sets the fsm_import role to NOLOGIN (I delete its password secrets and note the date in docs/KEYS.md), mark its lines in docs/fsm-rights-check.md retired with the date, and add a test that an import is now refused.
My figures:
<paste the old tool's report for the week>
Push, open a pull request titled "Field service cut-over", wait for the checks and tell me the result.On the cut-over date, before the cut-over pull request merges and sets fsm_import NOLOGIN: stop booking in the old tool, approve the delta export's sha256 and counts in docs/imports/fsm-approved.md through a pull request owner two approves, run the delta import through the workflow from main (it adds nothing twice), take the old tool's final full export into company storage, and set the old tool read-only. Read the cancellation terms on your own account page, cancel, and record it:
On a new branch fsm/retired, update docs/fsm-inventory.md: each kind of record and each tool marked replaced, retired or still in use, with the date; the workarounds from Session 1 the module removed; the cancellation (date, notice period, last invoice amount as I give it); and the saving as arithmetic: the old yearly cost plus the helper tools dropped, minus what the module adds to services we already pay for, from our own bills. My figures: <paste from the invoices>. Open a pull request titled "Field service tool retired".You will see recreated screen
- The test that matters most: a real job, a real phone, no signal.
- After cut-over nothing can bulk-write service data again.
Check it worked
docs/fsm-cutover.md is merged with every difference explained, the five checks and the real-phone test recorded; the importer is refused; the final export is stored; the old tool is read-only or cancelled, with the saving as arithmetic from invoices in docs/fsm-inventory.md.
If it goes wrong
A job exists in only one tool
That is a finding, not noise. Find who booked it and why it skipped the other tool, and fix the habit before cut-over.
The real phone lost an action after reconnecting
Do not cut over. Say: Show me the outbox entries for that job on the phone and on the server, with their ids, and find where the entry was dropped.
The vendor's notice period has passed for this year
Write the date the plan ends and a reminder for the next notice date. Keep the old tool read-only until then.
Knowledge check
In a period 10 jobs were completed; 4 carried an SLA and 3 of those met both targets. What is SLA attainment?
References
- FieldProxy: seven must-have features in modern field service management software. https://www.fieldproxy.ai/resources/blog/7-must-have-features-in-modern-field-service-management-software-d1-38
- ERP Research: Salesforce Field Service overview. https://erpresearch.com/erp-add-ons/field-service/salesforce-field-service
- GitHub Docs: Events that trigger workflows (workflow_dispatch). https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
- GitHub Docs: Using secrets in GitHub Actions. https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions
Chapter 4 · 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
Field Service: the Installed Base, Contracts and SLAs, Dispatch, Offline Technicians and Van Stock
Element M18 complete · Learner
Your LMS records this completion. For the CivOps Foundation certificate, finish the Foundation Course at https://civops.io/learn.