Chapter 1 · Sessions 1–2
What the old tool shows, and the registry every number comes from
First you list the reports people actually use in your BI tool, who reads them, what the seats cost, and where a figure is calculated inside a chart. Then Claude Code adds a small metric registry and the eight dash_ tables, with database rules that make a panel without a registered metric impossible, and you try them on the development project.
30 min3 stepsAbout 7 hours hands-on across six sessions
By the end of this chapter you can
- Inventory the BI tool's most-used reports, readers, seats and costs, and find every figure defined inside a chart.
- Have Claude Code write the registry and the eight dash_ tables with the rules that keep numbers honest, and their tests.
- Seed practice metrics shifted onto today, keep the hand-worked fortnight as a test fixture, and try them on the development project yourself.
One definition, read everywhere
A BI tool lets anyone write a formula inside a chart. After a year there are three scrap rates, and the morning meeting argues about which is right instead of about the scrap. The module replaces Power BI, Tableau, Looker, Metabase, Grafana, Domo, Qlik Sense or Klipfolio with dashboards whose every panel names a metric defined once, in a registry. The specification's founding rule: a displayed number may come only from the registry, and an absent value is shown as "no data", never as zero. Manufacturing figures are defined with ISO 22400-2 where it has one [1].
| Built in this module | Not in this module |
|---|---|
| Dashboards and panels bound to registered metrics, with drafts and immutable published versions | Ad-hoc SQL against operational tables: refused |
| Sharing by role through the role matrix, with row-level security on every panel query | A data warehouse or ETL |
| Filters, drill to the records, lineage to the definition and its version | Typed-in numbers of any kind |
| Scheduled PDF or CSV reports with a delivery log; threshold and anomaly alerts with acknowledgement | Email by default: reports are shown in the app until you choose to send mail |
Session 1: Inventory the old tool's reports, readers and seats
40 minutesWhy
Most BI tools hold hundreds of reports and a handful that people really use. Rebuilding the wrong ones wastes the module; missing one that the plant manager reads every Monday loses trust on the first Monday. Reading usage, seats and costs from the tool's own admin pages and invoice, and noting every figure calculated inside a chart, gives you the list to rebuild and compare in Sessions 5 and 6, and a saving you can prove.
Do this
Open the old tool's usage or activity report (most have one in the admin area), its seat or licence list, and the latest invoice. Ask two regular readers which reports they would miss.
cd ~/code/acme-platform && git switch main && git pull && claudeRead docs/measures.md. On a new branch dash/inventory, write docs/bi-inventory.md for me to fill in by hand. Do not invent any number, name or price: leave every value cell as "—".
Sections:
1. Tools: tool, owner (a job, not a name), seats paid, seats used in the last 90 days, bill per year as printed on the invoice, renewal date, notice period, what it exports, how long we can export after cancelling.
2. The top reports by use: one row each with report name, who reads it (jobs), how often, views in the last 90 days, the figures on it, and for each figure: where it is calculated (in the chart, in the tool's data model, or in the source system), its formula as written there, and its source table or file.
3. Figures defined more than once: any figure that appears with different formulas in different reports.
4. Figures already in docs/measures.md: which of the figures above match a measure there, and which are new.
5. Workarounds: one numbered line per thing people do around the tool (exports to spreadsheets, screenshots in emails).
6. The five reports to rebuild first, and why.
Open a pull request titled "BI inventory" and show me the link.Fill the cells from the tool's own pages and the invoice. Choose the five reports with the readers.
You will see recreated screen
- "Calculated in the chart" marks a figure that will drift. Each one becomes a single registered metric.
Check it worked
docs/bi-inventory.md is merged with the tools, seats and bills from the invoice, the most-used reports from the usage report, every figure with where it is calculated, the figures defined more than once, and five reports chosen with their readers.
Fastest path
Most BI tools sort reports by views in their admin or usage page; the top ten there are usually the whole story.
If it goes wrong
The usage report is a paid add-on
Ask the two or three regular readers which reports they open each week, and write "from readers, not measured" beside each. Never invent view counts.
Claude Code "helpfully" filled in formulas from what scrap rate usually means
Say: Remove every formula I did not copy from the tool. The point is to find out what your charts really calculate, which is often not what anyone thinks.
The tables: a small registry, and eight dash_ tables
The Foundation describes the data fabric but does not build its tables, so this module adds the smallest registry it needs, then its own eight tables. Every table has the spine's standard columns. Practice values come from the module's own seed file, shifted onto today, which Supabase loads after the migrations in CI and on the development project [2], pushed there by you, not Claude Code [3]; the hand-worked fortnight with fixed dates is a test fixture.
| Table | One row is | Key columns and rules |
|---|---|---|
| fab_metric | One registered figure | code unique; name; definition; formula; standard_ref; grain (day, week …); direction (higher_better, lower_better, on_target); target; owner_module; status (draft, approved, deprecated); ext.aggregation sum or ratio_percent. Its version is row_version; a change of meaning writes fab.metric.version_published |
| fab_dimension, fab_entity_registry, fab_metric_input | A dimension (site, line, product); a source table; which source a metric reads | Codes unique; every panel filter must use a registered dimension |
| fab_metric_value | One computed value for one day and one dimension key | value, numerator, denominator (numeric, exact), computed_at. Append-only: a correction is a new row with a later computed_at |
| dash_dashboard and dash_dashboard_version | A dashboard for a surface; one published layout | key unique; surface operator, supervisor or manager; status draft, published, archived. A version is never changed or deleted |
| dash_panel | A question: which metric, which filter, which chart | metric_key must be a registered, approved metric (a trigger refuses anything else); chart number, line, bar, table, gauge, heatmap, pareto; default_period an ISO 8601 duration such as P7D |
| dash_dashboard_share | Who may open a dashboard | Exactly one of job role, org unit or person |
| dash_report_schedule and dash_report_delivery | A scheduled snapshot; one delivery | cron, format pdf or csv, recipients (people, never typed addresses); delivery status sent, failed, skipped_no_data; one delivery per due time |
| dash_alert_rule and dash_alert_event | A threshold or anomaly rule; one alert raised | kind threshold or anomaly; operator gt, lt, outside_band; severity; event status open, acknowledged, resolved; once per rule per day; action_item_id |
Session 2: Check the spine, then write the registry and the dash_ tables with their rules
40 minutesWhy
The rule "every number comes from the registry" only holds if the database itself refuses a panel that names anything else; a rule in a screen protects one screen. Writing the registry, the tables, the refusals and their tests in one pull request means the two pitfalls the specification names (a KPI calculated in the chart, and zero shown for no data) are designed out before any screen exists.
Do this
Read docs/SCHEMA-PLAN.md, docs/naming-standard.md, docs/measures.md, docs/bi-inventory.md and supabase/migrations. Do not connect to any Supabase project.
On a new branch dash/tables:
1. The spine. The module needs core_site, core_org_unit, core_job_role, core_person, core_uom, core_attachment, core_action_item, core_notification, core_event_outbox, core_audit_log with core_audit_row(), core_current_tenant(), core_touch_row() and a trigger function core_block_mutation() that refuses update and delete. For each: exists, exists under another name (record it in the shared docs/spine-map.md, in its own section "M23 Dashboards", never a separate spine-map file, and use it), or missing. Module rows that belong to a site carry site_id in place of the specification's tenant_id, so core_current_tenant() is not created; the dashboards and metric definitions themselves are company-wide, and the section says so. Create only what is missing, in its own migration (npx supabase migration new spine_for_dash).
2. A fabric migration (npx supabase migration new fabric_registry): fab_entity_registry, fab_dimension, fab_metric, fab_metric_input and fab_metric_value with the columns in element M23 chapter 1; fab_metric_value append-only through core_block_mutation(); numerator, denominator and value numeric, never floating point; a trigger on fab_metric that writes fab.metric.version_published to core_event_outbox when definition, formula, target, grain, direction or status changes.
3. The module migration (npx supabase migration new dash_tables): the eight dash_ tables with the standard columns (site_id in place of tenant_id where a row belongs to a site), check constraints for every allowed value, foreign keys only to core_ tables and each other, and these rules: a dash_panel insert or a change of metric_key or target_metric_key is refused unless the code is an approved fab_metric (security-definer check, set search_path = ''); a version whose layout names an unregistered metric is refused; a version is never updated or deleted and is unique per dashboard and version_no; a share names exactly one of role, org unit or person; one alert event per rule per day; one delivery per schedule and due time unless failed.
4. Write docs/dash-rules.md with the shape of every json column (dimensions, layout, recipients, filters).
5. Row-level security on every table, no policies yet. pgTAP tests in supabase/tests/dash.test.sql proving every refusal above, plus: editing a metric value is refused.
Push, open a pull request titled "Dashboard tables", wait for every check, and tell me the result and the spine findings in plain words. If a check fails, fix it and wait again before reporting.You will see recreated screen
- Mapped, not duplicated.
- The definition-of-done test: a panel cannot be saved without a registered metric.
Check it worked
Pull request Dashboard tables is green, and the tests include a panel with an unregistered metric refused, a metric value edit refused and a published version change refused.
If it goes wrong
Claude Code adds a value or formula column to dash_panel "for flexibility"
Say: Remove it. A panel holds a question, never a number or a formula; numbers come only from fab_metric_value through the registry. This is the first pitfall the specification names.
CI fails with "function core_block_mutation() does not exist" on a fresh database
A spine piece was made by clicking or is in a later migration. Say: Make spine_for_dash earlier than fabric_registry and dash_tables and create everything they need; rebuild from nothing. We merged a change once that worked on one machine and failed everywhere else.
It reports success and a check on GitHub is red
Say: The check is red. Read the failed log, fix it and wait for green before you report. Trust the check, never the summary.
Session 2: Seed two practice metrics and try it on the development project
35 minutesWhy
Every check in this module is a number you can work out by hand: 31 scrapped of 950 made is 3.3%. The hand-worked fortnight has fixed dates, so it is a test fixture that never changes; the seed gives the development project the same small fortnight shifted onto today, with one site that has no data on purpose, so the preview always shows the numbers you worked by hand. Trying the migrations and seed on the development project, from your own terminal, shows you the tables before the deploy workflow applies the migrations to production on merge, and keeps practice numbers out of production.
Do this
On the branch dash/tables, add supabase/seeds/dash.sql and list it under [db.seed] sql_paths in supabase/config.toml after the existing seeds. Never append it to supabase/seed.sql. Check .github/workflows/deploy.yml never uses --include-seed and tell me.
Practice rows marked SYNTHETIC, safe to run twice (fixed ids; values replaced only for the seed's own rows), every person "SYNTHETIC · ...", addresses @example.com:
- sites S1 and S2; org units Production S1 and S2; roles operator, supervisor, manager plus new dashboard_builder and metric_steward; people Builder One, Steward One, Operator One (S1), Supervisor One (S1), Supervisor Two (S2), Manager One (S1, manager of both org units), each with a demo login;
- dimensions site (S1, S2), line (L1, L2), product (P1); two approved metrics, grain day: units_produced (sum, higher_better) and scrap_rate (ratio_percent, lower_better, target 3, a practice value);
- 48 fab_metric_value rows, dates shifted onto today: line L1 at S1 every day of the 14 days ending yesterday, 100 made, 2 scrapped, except the day four days before today with 9 scrapped; line L2 at S1 on the ten weekdays of those 14 days only, 50 made, 1 scrapped the first week and 2 the second; no rows at all for S2. Loaded on 16 March 2026 it makes exactly the fixture's rows below;
- three published dashboards with version 1: line-1-operator (operator surface; scrap rate and units, L1, P7D), site-supervisor (supervisor; scrap by line, scrap by day for L1 over P14D, units by line) and plant-manager (manager; scrap S1, scrap S2, units all sites); shares to the matching roles.
Separately, as a test fixture and not seed rows: tests/fixtures/dash-practice-fortnight.json, the hand-worked fortnight with fixed dates (L1 every day 2026-03-02 to 2026-03-15 with 9 scrapped on 2026-03-12, L2 on the weekdays, nothing for S2) and the answers as of 2026-03-16: S1 scrap P7D 31 of 950 (3.263), previous period 19 of 950 (2.0), L2 4.0 on 5 of 7 days, S2 no data. The tests in Sessions 3 to 5 load it.
A pgTAP test counts each seeded kind, and that running the seed twice leaves the same counts. Push, wait for the checks, and tell me.When it is green, you load it into the development project, with its password from the password manager:
cd ~/code/acme-platform && git fetch && git switch dash/tables && git pullnpx supabase link --project-ref tsrqponmlkjihgfedcbanpx supabase projects listnpx supabase db push --include-seedhttps://supabase.com/dashboard/project/tsrqponmlkjihgfedcba/editor
The development project's Table Editor: fab_metric_value with the 48 practice rows.
Push the seed with the migrations only this first time. After that, to bring the practice fortnight back up to yesterday, you run npm run seed:dev yourself (Claude Code may not).
Owner two approves and you merge. The deploy workflow applies the migrations to the live project, without the seed.
You will see recreated screen
- Linked to acme-platform-dev. If the dot is on acme-platform-prod, stop.
- Only this module's three migrations.
You will see recreated screen
| period_start | dimension_key | numerator | denominator | value |
|---|---|---|---|---|
| 2026-03-11 | S1 · L1 | 2 | 100 | 2.0 |
| 2026-03-12 | S1 · L1 | 9 | 100 | 9.0 |
| 2026-03-12 | S1 · L2 | 2 | 50 | 4.0 |
- The spike four days before today (here 12 March) is what the alert in Session 5 will catch.
Check it worked
The development project holds 2 metrics, 48 values ending yesterday, 3 dashboards and 8 panels, every person marked SYNTHETIC, and no value for S2; tests/fixtures/dash-practice-fortnight.json is in the pull request; after merge, the deploy workflow run is green and the live project has the tables but none of the practice rows.
If it goes wrong
The dot is on the live project
Do not push. Link acme-platform-dev again. Practice values in production would appear on real dashboards.
A later hand count does not match
Fix the seed, not the check. Reviews of five Academy modules found steps written against counts the seed never made.
Weeks later the practice panels on the preview are empty
The seed's fortnight has aged. Run npm run seed:dev yourself: the seed works its dates out from today. The hand counts never move, because the tests read tests/fixtures/dash-practice-fortnight.json with as-of 2026-03-16. We hit this once: seeded data aged and every "last 8 hours" panel went blank.
Knowledge check
Where may a number on a dashboard panel come from?
References
- ISO 22400-2:2014 Key performance indicators for manufacturing operations management. https://www.iso.org/standard/54497.html
- 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–4
Who sees which dashboard, and panels that cannot lie
Sharing decides which dashboards a person can open; row-level security decides which rows every panel query returns. Both come from the role matrix. Then the role dashboards on the three surfaces, a panel builder that cannot save a panel without a registered metric, immutable published versions, "no data" instead of zero, and a drill from any number to its definition and source.
40 min4 steps3 definition-of-done tests
By the end of this chapter you can
- Add the module's roles, tables and screens to docs/matrix.json and write the one read function every screen uses.
- Build the role dashboards on the operator, supervisor and manager surfaces.
- Prove three things: a panel cannot be saved without a registered metric, no data shows "no data", and every number links to its definition.
Two locks on every number
A row in dash_dashboard_share decides whether you can open a dashboard. Row-level security decides which rows its panels can read, because every panel runs through one read function with the reader's rights [3]. A supervisor at site S2 can open the site-supervisor dashboard and still see "no data" on every panel that asks for site S1.
| Table | Operator / supervisor / manager | Dashboard builder (new) | Metric steward (new) |
|---|---|---|---|
| fab_metric, fab_dimension | Read approved metrics (for the definition page) | Read | Write: register, approve, change, deprecate |
| fab_metric_value | Read, through read_metric only, own site (manager: every site) | Read, through read_metric | Read |
| dash_dashboard, dash_panel, dash_dashboard_version | Read what is shared with them | Write drafts; publish (insert a version) | Read |
| dash_dashboard_share | No right | Write | No right |
| dash_report_schedule, dash_report_delivery | Read deliveries addressed to them (manager: all) | Write schedules | No right |
| dash_alert_rule, dash_alert_event | Supervisor and manager: read and acknowledge for their site | Write rules | No right |
No role deletes. A published version is never changed. The report and alert services run as security-definer functions called by the scheduler, never with the service_role key from a page.
Session 3: Add the module to the role matrix and write the one read function
35 minutesWhy
If each screen fetched its own numbers, each would also make its own mistakes: a missing site filter, an average of averages, a zero for no data. One read function that runs with the reader's rights, combines rows by the metric's own rule and says "no data" with the reason makes those mistakes impossible everywhere at once. Generating the rights from docs/matrix.json gives each cell an allowed and a refused test.
Do this
Read docs/matrix.json, scripts/gen-policies.mjs, the M23 section of docs/spine-map.md and docs/dash-rules.md.
On a new branch dash/access:
1. Add roles dashboard_builder and metric_steward to docs/matrix.json and one cell per role and fab_/dash_ table exactly as in this table (element M23, chapter 2), and nothing more. No delete for anyone.
<paste the matrix table from element M23, chapter 2 here>
2. Screens with their roles: /dashboards and /dashboards/view/[key] (every signed-in role, filtered by shares), /dashboards/number/[key]/[panel] (drill and lineage, same), /dashboards/metric/[code] (every signed-in role, read only), /dashboards/alerts (supervisor, manager), /dashboards/reports (every signed-in role, own deliveries), /dashboards/health (manager), /dashboards/build (dashboard_builder), /fabric/metrics (metric_steward); /api/dash/ routes with the same roles.
3. Run node scripts/gen-policies.mjs, and node scripts/gen-routes.mjs for lib/access/routes.ts.
4. One read function, read_metric(code, from, to, filter, group_by), security invoker so row-level security applies: for each day and dimension key it keeps the row with the latest computed_at, combines by ext.aggregation (sum; or ratio_percent = 100 x sum of numerators / sum of denominators, never an average of averages), and returns value, numerator, denominator, days with data, days in the period, the previous period of the same length, and the metric's target, owner and version. No rows returns no value with the reason "no data", never 0. Periods are ISO 8601: P7D is the 7 whole days ending the day before the as-of date; one clock function gives the as-of date so tests can fix it.
5. Tests that load tests/fixtures/dash-practice-fortnight.json: with as-of 2026-03-16, scrap_rate for S1 over P7D is 31 of 950 (3.263), previous period 19 of 950 (2.0); as Supervisor Two (S2), the same call returns no data; as each role, a refused cell is refused; a read through any route other than read_metric is refused.
Push, open "Dashboard access", wait for every check, and tell me the two scrap rates in plain words.You will see recreated screen
- Ratio of sums, not the average of 3.0 and 4.0 (which would be 3.5).
Check it worked
Pull request Dashboard access is green; the tests prove 3.263 and 2.0 for the practice weeks and "no data" for Supervisor Two; the generated tests include a refusal for each refused cell.
If it goes wrong
The plant's scrap rate comes out as 3.5
That is the average of the two lines' rates. Say: A ratio_percent metric is 100 x the sum of numerators / the sum of denominators. Fix read_metric; do not change the test.
Claude Code makes read_metric security definer "so it can read everything"
Say: read_metric must run with the caller's rights, so row-level security applies to every panel query. A function with its owner's rights would show every site to everyone.
The supervisor's acknowledge says success and the alert stays open
The read rule does not cover the row after the change. Say: Check each updating role's read policy covers the row before and after, and add a test that the status really changed. We hit this in three modules.
Session 3: Role dashboards on the three surfaces
40 minutesWhy
An operator at a press reads a phone; a manager reads a desk screen. Building the dashboard viewer once, used by all three surfaces from the Foundation, means one set of rules for numbers, empty states and accessibility, tested at phone width before any real figure appears. Seeing Supervisor Two's "no data" on screen is the proof that the two locks work together.
Do this
Before writing any route or page, read the guide in node_modules/next/dist/docs/ for this version of Next.js (request middleware lives in proxy.ts). Read docs/matrix.json, lib/access/routes.ts and docs/dash-rules.md.
On a new branch dash/screens, using the surface components from Sessions 12 and 13:
1. /dashboards lists the dashboards shared with the signed-in person; /dashboards/view/[key] shows the published version's panels, each read through read_metric only. The browser never calculates a number.
2. Every panel: the value rounded once at display to one decimal (exact halves up); "n of m days" when days are missing; "No data" with the reason when there is no value, never 0; the target with its owner; above or below target written as a word, not colour alone; the numbers also available as a table (WCAG 1.1.1); text contrast at least 4.5:1, chart marks at least 3:1; filters and links usable by keyboard.
3. The operator dashboard works at 360 and 390 px with no sideways scroll and 44 px targets.
Tests: signed out, every /dashboards address lands on sign-in; Supervisor Two sees site-supervisor with "No data" on every panel; Operator One cannot open plant-manager; each panel with no rows renders "No data" and never "0".
Push, open "Dashboard screens", wait for the checks, and give me the preview address.On the preview, sign in as Operator One on a phone, then as Supervisor Two, then as Manager One. The preview's as-of date is today and the seed's fortnight ends yesterday, so you see the numbers you worked by hand. (The screens here show a preview opened on 16 March 2026.)
You will see recreated screen
- "above target" in words as well as colour, with the target's owner one tap away.
- Not 0. Site S2 made nothing that was recorded, which is a different fact.
Check it worked
On the preview the plant-manager dashboard shows 3.3% for S1 and "No data" for S2; Supervisor Two sees "No data" on site-supervisor; Operator One's phone view has no sideways scroll; signed out, /dashboards lands on sign-in.
Fastest path
Open the preview on a real phone first. Chart labels that fit on a laptop often collide at 390 px, and the table view is the quickest fix.
If it goes wrong
A panel shows 0 where there is no data
Say: No value is No data with the reason, never 0. Add a test per panel kind that renders it with no rows. We found a control chart that said "In control" on 87 screens from twelve hard-coded points, and an unreadable sensor shown as 0.
The screen works out the percentage from two numbers it fetched
Say: The browser never calculates. Show only what read_metric returns. A calculation in the page is a second definition.
A dashboard link opens a blank page for one role
Say: Sign in as each role on the preview, open every dashboard and link, and list every 404 or error. A link that compiles is not a link that works.
Knowledge check
Line L1 scrapped 21 of 700 and line L2 10 of 250 in the same week. What is the plant's scrap rate?
Panels, versions, drill and lineage
A panel is a question: which registered metric, which filter, which chart, which period. Drafts change freely; publishing inserts a new immutable version and moves the dashboard's pointer to it, so a number someone saw last month can always be shown again on the layout they saw. Charts follow WCAG 2.2 for contrast, text alternatives and keyboard use [1], and IBCS for consistent notation of actual, previous and target [2]. Dates and periods in filters and exports follow ISO 8601 [4].
Session 4: The panel builder, drafts and immutable versions
35 minutesWhy
This is where the old tool let people type formulas, so it is where the module must be strictest. A builder whose metric box offers only approved registry codes, backed by the database refusal from Session 2, makes a chart-level KPI impossible rather than discouraged. Immutable versions mean a published dashboard can always be explained later.
Do this
On a new branch dash/builder, build /dashboards/build for dashboard_builder:
1. Create a draft dashboard (key, title, surface) and add panels: metric chosen from approved fab_metric codes only (no free text), dimensions from fab_dimension only, chart, default_period as an ISO 8601 duration (PnD or PnW), optional target metric. No field anywhere accepts a number or formula for display.
2. Publish: buildLayout(panels) in lib/dash/layout.ts makes the layout; insert dash_dashboard_version with the next version_no, published_at, published_by; move published_version_id. Editing after publish edits the draft; viewers keep reading the published version until the next publish.
3. Share to a role, org unit or person.
Tests: saving a panel with a free-text metric, an unregistered code or a deprecated metric is refused by the database with a clear message on screen; publishing twice makes versions 1 and 2 and version 1 is unchanged; a viewer sees version 1 while version 2 is a draft. For each test, show it failing with its rule removed. Push, open "Dashboard builder", wait for the checks, and tell me.On the preview, as Builder One, try to add a panel for scrap_pct through the API or the browser's developer tools (not offered in the list). It must be refused. Then publish a second version of line-1-operator with a new panel order.
You will see recreated screen
- Only approved codes are offered.
- The database's own message when anything else is sent. This is definition-of-done test one.
Check it worked
On the preview a panel with an unregistered metric is refused with the database's message; line-1-operator has versions 1 and 2, version 1 unchanged; the tests show red without each rule.
If it goes wrong
A builder asks for "just a quick calculated field"
Register the figure instead: the metric steward adds it to fab_metric with its definition, formula and owner, approves it, and it appears in the list. That is the whole point of the module.
Claude Code lets an existing version be updated "to fix a typo"
Say: A version is never changed. Fix the draft and publish the next version.
Session 4: Filters, drill and lineage, checked by hand
30 minutesWhy
A number nobody can trace is a number nobody trusts in an argument. Three taps from any value to the rows behind it, the definition and version it was computed on, and its source tables, settles the argument with evidence. Checking the practice numbers by hand first proves the screen shows what the data says, not what looks plausible.
Do this
| Practice question (the fixture as of 2026-03-16; the preview as of today) | By hand | The screen must show |
|---|---|---|
| Scrap rate S1, P7D (9–15 Mar) | L1 21 of 700 + L2 10 of 250 = 31 of 950 | 3.3% |
| Previous period (2–8 Mar) | 14 of 700 + 5 of 250 = 19 of 950 | 2.0%, variance up 1.3 points |
| Line L2, P7D | Weekdays only | 4.0%, 5 of 7 days |
| Site S2, any period | No rows | No data |
On a new branch dash/drill:
1. Filters for site, line, product and period on /dashboards/view/[key], intersected with the panel's own filter and the reader's row-level scope; never changing what the panel holds.
2. Every number is a link to /dashboards/number/[key]/[panel]: the value rows behind it (period, dimension, numerator, denominator, computed_at, metric version), then the metric's page /dashboards/metric/[code] (definition, formula, standard reference, grain, direction, target and owner, status, version), then its source entities from fab_metric_input.
3. When fab.metric.version_published arrives, give each owner of a published dashboard that names the metric one core_action_item; published versions do not change.
4. Tests that load tests/fixtures/dash-practice-fortnight.json for the four practice answers in element M23 chapter 2 with as-of 2026-03-16, and a test that every number on every published practice dashboard links to its metric page.
Push, open "Dashboard drill and lineage", wait for the checks, and tell me the four answers.You will see recreated screen
| Day | Line | Scrap | Made | Computed | Version |
|---|---|---|---|---|---|
| 2026-03-12 | L1 | 9 | 100 | 03-13 06:00 | 1 |
| 2026-03-12 | L2 | 2 | 50 | 03-13 06:00 | 1 |
| … | 31 | 950 |
- The rows add up to the number on the dashboard: 31 of 950.
- The definition and version the number was computed on. This is definition-of-done test three.
Check it worked
On the preview the four practice answers match your hand counts, and from any number you reach its rows, its metric page and its sources in three taps.
If it goes wrong
The weekday-only line shows 7 of 7 days
Missing days are being filled. Say: Days without rows are missing, not zero; report n of m days.
The drill page shows numbers that do not add up to the panel
The drill reads differently from read_metric (often it keeps every computed_at instead of the latest). Say: The drill must use the same rows read_metric used. Add a test that the drill's sums equal the panel.
Claude Code says the test "verifies the link exists" by searching the page source
Say: Test the behaviour: follow the link and check the metric page names the right code and version. We had tests that checked a word was present and passed while the feature was broken.
Knowledge check
A panel's site has no recorded values for the period. What does it show?
Knowledge check
A published dashboard needs a different panel order. What happens to version 1?
References
- W3C: Web Content Accessibility Guidelines (WCAG) 2.2. https://www.w3.org/TR/WCAG22/
- International Business Communication Standards (IBCS). https://www.ibcs.com/standards/
- Supabase Docs: Row Level Security. https://supabase.com/docs/guides/database/postgres/row-level-security
- ISO 8601 date and time format. https://www.iso.org/iso-8601-date-and-time-format.html
Chapter 3 · Sessions 5–6
Reports, alerts, the rebuilt reports and the cut-over
Scheduled reports with a delivery log and alerts that someone must acknowledge, both built on the same read function. Then the old tool's most-used reports rebuilt on registered metrics, tried on the development project, registered in production through the pipeline, compared number by number side by side, and the seats cancelled only when every difference is explained.
35 min5 stepsEnds with the module gate
By the end of this chapter you can
- Schedule a report whose delivery log says sent, failed or skipped_no_data, and an alert that is raised once and acknowledged.
- Rebuild the first of the five reports on registered metrics and try it on the development project.
- Register the real metrics in production through the pipeline, compare every number side by side, cut over and retire the seats.
Reports and alerts read numbers through the same function as the screens, so a PDF can never disagree with the dashboard. The registrations that rebuild the old reports are migrations, applied to production by the deploy workflow on merge [3]; figures follow ISO 22400-2 where it defines them [1] and charts keep IBCS notation [2].
Session 5: A scheduled report with a delivery log
25 minutesWhy
A report that silently stops arriving is worse than no report: people assume the numbers were fine. A delivery log with one row per due time, saying sent, failed or skipped because there was no data, makes every miss visible. The report uses the same read function as the screen, so a PDF can never disagree with the dashboard.
Do this
On a new branch dash/reports:
1. On /dashboards/build, a schedule for a published dashboard: five-field cron, format pdf or csv, recipients chosen from people (never typed addresses) who can read the dashboard and the filtered rows (refuse anyone else), filters.
2. A report service, run by the scheduler as a security-definer function, that for each due time in the last 24 hours with no delivery yet builds the file through read_metric, stores it in core_attachment readable by the recipients only, and writes one dash_report_delivery: sent; skipped_no_data with no file when every panel has no data; or failed with the error, retried next run as a new row.
3. Recipients see their deliveries on /dashboards/reports and get an in-app core_notification. No email: if I later choose email, I will add the mail provider's key myself and list it in docs/KEYS.md.
4. Report delivery success on /dashboards/health: due times with a sent delivery / due times.
Tests on tests/fixtures/dash-practice-fortnight.json with a fixed clock: a weekly site-supervisor report on Monday 2026-03-16 06:00 is sent once even if the service runs twice; a plant-manager report filtered to S2 is skipped_no_data with no file; a failure is logged and retried. Push, open "Dashboard reports", wait for the checks, and tell me.You will see recreated screen
| Due | Report | Status | File |
|---|---|---|---|
| 2026-03-16 06:00 | site-supervisor weekly (CSV) | sent | site-supervisor-2026-03-16.csv |
| 2026-03-16 06:00 | plant-manager S2 weekly (PDF) | skipped_no_data | — |
- An empty report is recorded as skipped, not sent as a page of zeros.
- The free way first: nothing emails anyone until you choose.
Check it worked
On the preview, with a schedule due a few minutes from now, one site-supervisor delivery is sent with a file the recipient can open, the S2 report is skipped_no_data with no file, and running the service again adds nothing.
If it goes wrong
The log says sent but no file can be opened
A stand-in is claiming success. Say: A delivery is sent only when its core_attachment exists and the recipient can read it; add a test. We had a button that marked messages sent while nothing left the building.
Claude Code asks for an email key to finish the feature
Do not paste any key. Email is a later choice: the owner adds it in the host's environment settings and lists it in docs/KEYS.md. For now, deliveries are in the app.
Session 5: A threshold alert, acknowledged and linked to an action
25 minutesWhy
An alert nobody has to acknowledge becomes noise in a week. Raising one event per breach per day, requiring a person to acknowledge it, and linking it to an action item turns a red number into owned work, and the acknowledgement time becomes a measure of whether alerts are being read.
Do this
On a new branch dash/alerts:
1. Alert rules on /dashboards/build: metric (approved only), dimensions, kind threshold (gt or lt a value) or anomaly (outside_band: further from the mean of the previous 7 daily values than value x their standard deviation; with fewer than 7, "not enough history" and no event), severity, owner, ext.escalate_after_minutes.
2. An alert service, run by the scheduler as a security-definer function, that evaluates each rule's day through read_metric, inserts one dash_alert_event per rule per day (the unique index refuses a second), notifies the owner in the app, and escalates an open event once, after the rule's minutes, to the manager of the owner's org unit.
3. /dashboards/alerts for supervisor and manager: acknowledge (acknowledged_by, acknowledged_at) and optionally create a core_action_item linked through action_item_id.
4. Alert acknowledgement time on /dashboards/health: the median minutes from raised to acknowledged.
Tests on tests/fixtures/dash-practice-fortnight.json with a fixed clock: a rule scrap_rate gt 5 for S1 line L1 raises one event for 2026-03-12 (value 9.0) and none for other days, even when evaluated twice; Supervisor One acknowledges it and creates an action; Supervisor Two cannot see it. Push, open "Dashboard alerts", wait for the checks, and tell me.On the preview, as Supervisor One, acknowledge the alert for the seed's spike day (four days before today) and create an action for it.
You will see recreated screen
- One event for the breach, however many times the service runs.
- The acknowledgement time (60 minutes here) feeds the health page.
Check it worked
On the preview exactly one alert exists for the seed's spike day, Supervisor One has acknowledged it with an action, Supervisor Two cannot see it, and the health page shows its acknowledgement time.
If it goes wrong
The same alert appears every time the service runs
The once-per-day rule is missing. Say: Use the unique index on rule and observed day, insert on conflict do nothing, and add a test that runs the service twice.
An anomaly rule fires on every small wobble
A flat history makes the band nearly zero wide. Write the smallest band you will accept into the rule's notes, and agree it with the figure's owner.
Session 5: Rebuild the first of the five reports and try it on the development project
30 minutesWhy
The cut-over succeeds or fails on whether the most-used reports show the same numbers as before, or a difference someone can explain. Registering each figure once, with the formula copied from the old tool and agreed with its owner, and rebuilding the first report on the development project, finds the definition disagreements before any reader sees them. The other four follow the same prompt as homework.
Do this
Take the first report from docs/bi-inventory.md. With the figure's owner, agree each figure's definition: the old tool's formula as written, or a correction. Write each in docs/measures.md if it is not there.
On a new branch dash/report-1, for "<name of report 1 from docs/bi-inventory.md>":
1. For each figure on it, a migration that registers it in fab_metric (status draft) with code, name, definition, formula, grain, direction, target and owner exactly as in docs/measures.md, its inputs in fab_metric_input and its source tables in fab_entity_registry. The metric steward approves each one on /fabric/metrics.
2. A metric job, run by the scheduler as a security-definer function, that computes daily fab_metric_value rows for those metrics from our own tables (never from the old BI tool), appending, never editing.
3. A draft dashboard that rebuilds the report on those metrics, panel for panel.
4. Tests on the seed: the job computes the expected values for a fixed day and a re-run appends nothing new.
Push, open "Rebuild report 1", wait for the checks, and tell me.When it is green, try it on the development project as before (link tsrqponmlkjihgfedcba, check the dot, npx supabase db push), approve the metrics as Steward One on the preview, and look at the rebuilt dashboard on made-up data.
npx supabase link --project-ref tsrqponmlkjihgfedcba && npx supabase projects listnpx supabase db pushYou will see recreated screen
- Registered as draft: a person approves it, not the migration.
- The disagreement found in Session 1, settled once in the registry.
Check it worked
On the development project the rebuilt report shows each figure from registered, approved metrics, with no number typed or calculated in a chart.
If it goes wrong
Claude Code proposes reading the old BI tool's database to fill the values
Say: Values come only from our own tables through the metric job. The old tool is only for comparison in Session 6.
The figure's owner and the old report disagree on the formula
Register the one the owner agrees, and write the old one beside it in docs/bi-cutover.md: it will explain the difference you see in Session 6.
Session 6: Into production through the pipeline, then every number side by side
35 minutes, then the comparison periodWhy
Production is where the real figures are. Merging the registrations and the metric job lets the deploy workflow apply them, reviewed by owner two like any change, with nothing loaded from a laptop. A side-by-side period with every number written next to its old value, and every difference explained, is the only evidence that readers can stop using the old tool.
Do this
Owner two approves the five rebuilt reports' pull requests; merge them. The deploy workflow applies the registrations and the job to production; the metric steward approves each metric on https://acme-platform.vercel.app/fabric/metrics, and the builder publishes each dashboard.
https://github.com/acme-ops/acme-platform/actions
GitHub Actions: the deploy runs that applied the registrations.
On a new branch dash/cutover, write docs/bi-cutover.md for me to fill in, with no number invented:
1. The comparison period as an ISO 8601 interval.
2. For each of the five reports, one row per figure: old value as printed, new value, difference, explanation, decided with (job). Leave the values as — for me to type from the old tool's export and the new dashboard.
3. The three module proofs, each with its test and result: a panel cannot be saved without a registered metric; a panel with no data shows No data, never 0; every number on a published dashboard links to its metric definition. Run them now and write the results.
4. The workarounds from docs/bi-inventory.md, each covered, not needed, or open.
5. Cut-over: the date, who tells the readers, the date after which old reports are not used for decisions, who keeps the old tool read-only, the rollback plan.
6. Retired BI seats: seats before (from the vendor's seat list) and after; the saving from invoices.
Open "BI cutover" and show me the link.For the comparison period, fill in every row: old values from the old tool's own export (kept in a private folder, never in the repository or Claude Code), new values from the published dashboards.
You will see recreated screen
| Figure | Old | New | Explanation |
|---|---|---|---|
| First-piece pass rate | 97.8 | 97.6 | Old chart averaged the daily rates; registry uses ratio of sums |
| Holds per shift | 0 | No data | Night shift L2 recorded nothing; old tool showed 0 |
| Units produced | 18,240 | 18,240 | — |
- Each explanation is one of the known causes: formula, day boundary, filter, rounding, refresh time, or zero for no data.
Check it worked
The registrations are in production through the deploy workflow, the five dashboards are published there, and docs/bi-cutover.md has every figure of the five reports compared for the period with every difference explained and the three proofs passing.
If it goes wrong
A difference cannot be explained
You are not ready. Drill into the new number to its rows and compare with the old tool's detail for one day; most differences are a formula, a day boundary or a filter.
The old tool shows 0 where the platform shows No data
That is a finding about the old tool, not a bug in the new one. Write it in the explanation; it is one of the two pitfalls the specification names.
Someone fixes a difference by editing the new chart
Not possible by design, and not wanted: if the old formula is right, the metric steward changes the definition in the registry once, through a pull request, which publishes a new version.
Session 6: Cut over and retire the seats
20 minutesWhy
Seats are the saving, but only after readers have moved. Writing the cut-over date, who tells the readers and the rollback first, then cancelling against the vendor's own seat list and invoice, means the saving is real and anyone can check it.
Do this
On the cut-over date: tell the readers, replace the old report links with the new dashboard links, and set the old tool to read-only for the people who keep it. Read the vendor's cancellation terms (notice period, renewal date, export window) on your own account page. Export what you must keep, then cancel the seats (or the subscription) and record the seats before and after from the vendor's seat list and the saving from the invoice in docs/bi-cutover.md.
Read docs/bi-cutover.md and docs/bi-inventory.md. Check that every one of the five reports has a published dashboard, every figure row has an explanation or no difference, the three proofs are recorded, and the cut-over section and the Retired BI seats section are filled in. List anything missing. Then update docs/bi-inventory.md: mark each report as rebuilt, retired or still on the old tool, with the date. Push to the same branch and tell me what is missing, if anything.Owner two approves; merge.
You will see recreated screen
- Claude Code checks your file; it does not supply the numbers. Seats and saving come from the vendor's list and invoice.
Check it worked
docs/bi-cutover.md is on main with the cut-over date, rollback plan, seats before and after from the vendor's list and the saving from the invoice; docs/bi-inventory.md marks every report; the old seats are cancelled or their end date recorded.
If it goes wrong
Cancelling early gives no refund
Keep the old tool read-only until the paid period ends, and record that date.
A reader still opens the old tool after cut-over
Ask what they could not find. If it is a figure, register it and add a panel; if it is a habit, the old links are still somewhere: find and replace them.
Knowledge check
Every panel on a scheduled report has no data. What does the delivery record?
Knowledge check
During the side-by-side period a figure differs and the old formula turns out to be right. Where is it fixed?
References
- ISO 22400-2:2014 Key performance indicators for manufacturing operations management. https://www.iso.org/standard/54497.html
- International Business Communication Standards (IBCS). https://www.ibcs.com/standards/
- Supabase Docs: Database migrations. https://supabase.com/docs/guides/deployment/database-migrations
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
Dashboards and Reporting: Every Number from One Metric Registry
Element M23 complete · Learner
Your LMS records this completion. For the CivOps Foundation certificate, finish the Foundation Course at https://civops.io/learn.