fairmake-calibration-due 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (unreleased)
4
+
5
+ - First version (Fairmake ver 1).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kurt Francisco
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,203 @@
1
- # Temporary Holding Version
1
+ # Fairmake Calibration Due
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `fairmake-calibration-due` · MCP server and CLI · MIT
4
+
5
+ Gauges overdue or due soon, never calibrated, and work orders measured with a gauge that was overdue or had failed calibration, with a due-date calendar. Releases no hold.
6
+
7
+ Part of **Fairmake**, the back-office agents for small and mid-size manufacturers and distributors by Mythos Machines. The software is free (MIT); the paid part is a fixed-price setup on your own files. Every result is computed from your files with plain arithmetic, on your computer; no AI model is called by the tools.
8
+
9
+ ## What it checks
10
+
11
+ Work out each gauge's next calibration date from the last one and its interval. Flags overdue gauges, gauges used after a failed calibration and gauges used past their due date (naming the work orders); lists gauges due soon; reviews gauges never calibrated or with no interval. Out-of-service gauges are not chased for dates.
12
+
13
+ | Finding | Example from the fictional demo data |
14
+ |---|---|
15
+ | `due_soon` | HG-004 is due for calibration 2026-12-06 (in 18 days). |
16
+ | `failed_then_used` | MIC-002 failed its calibration on 2026-10-20 and was used afterwards on WO-301 (2026-11-02), WO-305 (2026-11-05). Review that product. |
17
+ | `never_calibrated` | PG-005 has no calibration on record. |
18
+ | `no_interval` | TW-006 has no calibration interval. |
19
+ | `overdue` | CAL-003 was due for calibration 2026-11-01 (17 days ago). |
20
+ | `used_while_overdue` | CAL-003 was used past its due date 2026-11-01 on WO-310 (2026-11-10). |
21
+
22
+ Each item gets the most serious level of its findings: **flag** (act on it), **review** (data is missing or unclear; a person looks), **watch** (worth knowing) or **ok**. Every finding names the numbers it was worked out from.
23
+
24
+ ## What it needs, and what stays with a person
25
+
26
+ - `gauges` (required): Gauge or instrument register under --root: id, last calibration, interval in days, last result and status
27
+ - `usage` (optional): gauge use log under --root: gauge, work order or lot, and date used
28
+ - `as_of` (optional): Date to measure from, YYYY-MM-DD (default today)
29
+ - `settings` (optional): settings JSON under --root; anything left out uses the defaults listed in the result as settings_used
30
+
31
+ It never does these, and any other tool name is blocked:
32
+
33
+ - Never places or releases a quality hold in the QMS or ERP.
34
+ - Never notifies a customer about suspect product.
35
+
36
+ `calibration_draft_suspect_product_notice` writes a draft marked DRAFT; nothing goes out from it. Approving it (`calibration_request_send`) takes one click by a named person, even in Auto, and only records the approval: the agent itself sends, posts, files and pays nothing. What to change, send or pay is a person's decision.
37
+
38
+ ## Settings
39
+
40
+ Put the ones you want to change in a JSON file and pass it as `settings`; anything left out uses the default. The result lists the settings it used under `settings_used`.
41
+
42
+ | Setting | Default | Meaning |
43
+ |---|---|---|
44
+ | `due_soon_days` | `30` | A gauge due within this many days is listed as due soon |
45
+
46
+ <!-- generated:start -->
47
+
48
+ ## A demo run
49
+
50
+ `npx -y fairmake-calibration-due demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
51
+
52
+ ```text
53
+ Fairmake Calibration Due demo: nine fictional gauges and a month of gauge use, as of 2026-11-18. Auto mode is on for drafts only.
54
+
55
+ ▶ Run the check on the exported files
56
+ status: executed decision: allow
57
+ 9 gauge(s) as of 2026-11-18: 1 overdue, 3 measurement(s) with a suspect gauge, 2 to review, 2 due soon, 3 in calibration.
58
+ flag CAL-003 overdue, used_while_overdue
59
+ watch HG-004 due_soon
60
+ flag MIC-002 failed_then_used
61
+ review PG-005 never_calibrated
62
+ watch THR-009 due_soon
63
+ review TW-006 no_interval
64
+
65
+ ▶ Explain MIC-002
66
+ status: executed decision: allow
67
+ MIC-002: flag. MIC-002 failed its calibration on 2026-10-20 and was used afterwards on WO-301 (2026-11-02), WO-305 (2026-11-05). Review that product.
68
+
69
+ ▶ Write the report (CSV worklist and HTML page)
70
+ status: executed decision: allow
71
+ Calibration due dates as of 2026-11-18 written: 9 gauge(s) as of 2026-11-18: 1 overdue, 3 measurement(s) with a suspect gauge, 2 to review, 2 due soon, 3 in calibration.
72
+
73
+ ▶ Write the draft (Auto is opted in for drafts)
74
+ status: executed decision: allow (auto)
75
+ suspect product notice open drafted with 1 open marker(s) ([TO CONFIRM quality manager]). Nothing was sent.
76
+
77
+ ▶ Auto: approving the draft stays one named click
78
+ status: needs_approval decision: ask
79
+ reason: binding_send stays one-click, even in Auto
80
+
81
+ ▶ Same call after the named click (recorded; a person acts on it)
82
+ status: executed decision: ask approved by: Pat Planner (fictional)
83
+ suspect product notice open approved and recorded. Nothing was sent or paid by the agent.
84
+
85
+ ▶ The agent tries qms_release_hold itself
86
+ status: blocked decision: block
87
+ reason: Never places or releases a quality hold in the QMS or ERP.
88
+ ```
89
+
90
+ ## Tools
91
+
92
+ | Tool | What it does | Policy |
93
+ |---|---|---|
94
+ | `calibration_check` | Work out each gauge's next calibration date from the last one and its interval. | runs |
95
+ | `calibration_explain` | Show one gauge's figures and findings, from the same files as calibration_check. | runs |
96
+ | `calibration_write_report` | Write calibration-due.csv (one row per gauge, with a blank decision column for people to fill in) and calibration-due.html, plus a calendar (.ics) of the due dates into out_dir (default fairmake-out/calibration). | runs |
97
+ | `calibration_draft_suspect_product_notice` | Write drafts/suspect_product_notice-open.md: every work order measured with a gauge that had failed calibration or was overdue, for the quality manager to decide on re-inspection. | asks first (Auto can be opted in) |
98
+ | `calibration_request_send` | After one named human click (even in Auto), record that the reviewed suspect product notice draft is approved in suspect_product_notice-requests.csv. | one named click, even in Auto (`binding_send`) |
99
+ | `qms_release_hold` | Never places or releases a quality hold in the QMS or ERP. | refused |
100
+ | `customer_notice_send` | Never notifies a customer about suspect product. | refused |
101
+
102
+ Any tool name not in this table is blocked, including names a model invents. `refused` tools are listed so a model can see they exist and are refused.
103
+
104
+ ## Columns it reads
105
+
106
+ Table inputs can be CSV, TSV, semicolon- or pipe-separated text, Excel `.xlsx`, JSON or JSONL. Columns are matched by the agent's own name, then by the English names below, then by their names in German, French, Spanish, Portuguese, Italian, Japanese, Chinese and Korean. Dates become `YYYY-MM-DD`; amounts are read with either decimal mark; weights, distances and dimensions are converted when the column says it holds kilograms, kilometres or centimetres. Every result lists under `sources` how each file was read.
107
+
108
+ ### Gauge register (`gauges`)
109
+
110
+ | Column | Type | Also read as | For example, in other languages |
111
+ |---|---|---|---|
112
+ | `gauge` (required) | text | Gauge, Gauge ID, Instrument, Instrument ID, Asset | Prüfmittel, Instrument, 計測器, 量具 |
113
+ | `description` | text | Description, Gauge Description, Type | Beschreibung, Description, 摘要, 摘要 |
114
+ | `location` | text | Location, Area, Department | Lagerort, Emplacement, 保管場所, 库位 |
115
+ | `last_cal` | date | Last Calibration, Last Cal, Calibrated On, Last Calibrated | Zuletzt durchgeführt, Dernière réalisation, 前回実施日, 上次执行日期 |
116
+ | `interval_days` | number | Interval Days, Calibration Interval, Frequency (days), Cal Interval | Intervall (Tage), Périodicité (jours), 周期(日), 周期(天) |
117
+ | `cal_result` | text | Result, Cal Result, As Found, Last Result | - |
118
+ | `gauge_status` | text | Status, Gauge Status, State | - |
119
+
120
+ Named exports recognised by their column names:
121
+
122
+ | System | Export | Recognised by | Layout checked |
123
+ |---|---|---|---|
124
+ | Calibration software (generic) | Gauge register export | Gauge ID, Last Calibration, Calibration Interval, Result | no |
125
+
126
+ Where a layout says "checked", its column names were compared with the vendor's documentation on that date; where it says "tested", an agent was run on a real published file in that layout. The other layouts were written from knowledge of the export and were not checked. None was tested against a customer's live account.
127
+
128
+ ### Gauge use log (`usage`)
129
+
130
+ | Column | Type | Also read as | For example, in other languages |
131
+ |---|---|---|---|
132
+ | `gauge` (required) | text | Gauge, Gauge ID, Instrument | Prüfmittel, Instrument, 計測器, 量具 |
133
+ | `work_order` | text | Work Order, Job, Lot, Inspection Lot | Fertigungsauftrag, Ordre de fabrication, 製造指図, 生产工单 |
134
+ | `used_date` | date | Used Date, Date, Inspection Date, Measured On | - |
135
+
136
+ ### Files from other countries
137
+
138
+ A German export in Windows-1252 with semicolons, `1.234,56` and `03.11.2026`, or a Japanese one in Shift_JIS with `2026/11/03`, is read the same way as the English file. [`fixtures/intl/`](fixtures/intl) has both versions of the demo data, and the eval cases `intl-de-*` and `intl-ja-*` require the same results as the English case. A weight, distance or dimension column found by its translated name with no unit in it is read as metric and converted, and the result says so. Columns named differently? Run `npx fairmake-calibration-due inspect <file>` (names and shapes only, never values) and name them in `fairmake-sources.json`:
139
+
140
+ ```json
141
+ { "files": { "exports/bills.csv": { "columns": { "invoice_number": "Beleg" }, "date_order": "dmy", "units": { "weight": "kg" } } } }
142
+ ```
143
+
144
+ ## Install
145
+
146
+ Node 20 or newer. No other dependencies.
147
+
148
+ ```bash
149
+ npx -y fairmake-calibration-due demo
150
+ npx -y fairmake-calibration-due mcp --root /path/to/your/files
151
+ ```
152
+
153
+ Claude Desktop, Cursor and other MCP hosts:
154
+
155
+ ```json
156
+ {
157
+ "mcpServers": {
158
+ "fairmake-calibration-due": {
159
+ "command": "npx",
160
+ "args": [
161
+ "-y",
162
+ "fairmake-calibration-due",
163
+ "mcp",
164
+ "--root",
165
+ "/path/to/your/files"
166
+ ]
167
+ }
168
+ }
169
+ }
170
+ ```
171
+
172
+ Claude Code: `claude mcp add fairmake-calibration-due -- npx -y fairmake-calibration-due mcp --root .`, or install the `fairmake-calibration-due` plugin from this repository's marketplace.
173
+
174
+ ## Modes and approvals
175
+
176
+ - **Review** (`--mode review`): reads and reports only.
177
+ - **Assist** (default): the policy above. A tool that asks returns an `approval_id`; a person approves it once with `fairmake-calibration-due approve <id> --as "Your Name"` (or on the local approvals page, `fairmake-calibration-due approvals`), and the same call is repeated.
178
+ - **Auto** (`--mode auto --auto <tool,...>`): opt-in per tool, with step caps and a kill switch (`fairmake-calibration-due kill`). Paying, sending, posting to a ledger or a live system and accepting a learned fact stay **one named click even in Auto**; an approval is tied to the sha256 of the reviewed draft, so a changed draft needs a new click.
179
+
180
+ ## CLI
181
+
182
+ ```bash
183
+ fairmake-calibration-due tools # every tool, its policy and arguments
184
+ fairmake-calibration-due sources # the columns each input is read from
185
+ fairmake-calibration-due inspect <file> # how a file would be read (names and shapes, never values)
186
+ fairmake-calibration-due call calibration_check '{"gauges":"<gauges>"}'
187
+ fairmake-calibration-due eval # the private eval cases on the fictional fixtures
188
+ fairmake-calibration-due demo
189
+ ```
190
+
191
+ ## Audit log and data
192
+
193
+ Every call is written to `.fairmake/audit.jsonl` under the root: hash-chained JSON lines, with arguments stored as a hash, signed with an Ed25519 key when you configure one. Everything runs on your machine on files you choose. No network calls, no telemetry, no credentials. The bundled fixtures are fictional.
194
+
195
+ <!-- generated:end -->
196
+
197
+ ## Limits
198
+
199
+ - Reads only the files you give it. It does not log in to an ERP, MES, CMMS, QMS, EDI network, bank, supplier or customer portal, and changes nothing in them.
200
+ - Thresholds and rules are settings in your own file, with working defaults listed in the result as settings_used. They are not a costing, quality or safety standard; check them against your own policies and contracts.
201
+ - Not legal, tax, customs, safety or accounting advice. A person decides what to change, post, send or pay.
202
+ - Column names for the named exports were written from knowledge of those systems and not checked against a live account; `inspect` shows how a file was read and `fairmake-sources.json` names columns by hand.
203
+ - The bundled fixtures are fictional. Version 0.1.0.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { fileURLToPath } from 'node:url';
3
+ import { main } from 'fairmake-core';
4
+ import { manifest } from '../src/manifest.js';
5
+ import { demo } from '../src/demo.js';
6
+
7
+ main(manifest, { bin: 'fairmake-calibration-due', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
@@ -0,0 +1,360 @@
1
+ {
2
+ "suite": "fairmake-calibration-due",
3
+ "root": "..",
4
+ "data_note": "Fictional gauges and gauge use in ../fixtures, as of 2026-11-18. No model is called.",
5
+ "cases": [
6
+ {
7
+ "id": "check-totals",
8
+ "tool": "calibration_check",
9
+ "args": {
10
+ "gauges": "fixtures/gauges.csv",
11
+ "usage": "fixtures/usage.csv",
12
+ "settings": "fixtures/settings.json",
13
+ "as_of": "2026-11-18"
14
+ },
15
+ "expect": {
16
+ "equals": {
17
+ "result.gauges": 9,
18
+ "result.overdue": 1,
19
+ "result.suspect_work_orders": 3,
20
+ "result.flag": 2,
21
+ "result.review": 2,
22
+ "result.watch": 2,
23
+ "result.ok": 3
24
+ }
25
+ }
26
+ },
27
+ {
28
+ "id": "every-planted-finding",
29
+ "tool": "calibration_check",
30
+ "args": {
31
+ "gauges": "fixtures/gauges.csv",
32
+ "usage": "fixtures/usage.csv",
33
+ "as_of": "2026-11-18"
34
+ },
35
+ "expect": {
36
+ "contains": [
37
+ "overdue",
38
+ "due_soon",
39
+ "failed_then_used",
40
+ "used_while_overdue",
41
+ "never_calibrated",
42
+ "no_interval",
43
+ "WO-301 (2026-11-02), WO-305 (2026-11-05)"
44
+ ],
45
+ "not_contains": [
46
+ "WO-290",
47
+ "WO-299"
48
+ ]
49
+ }
50
+ },
51
+ {
52
+ "id": "explain-failed-gauge",
53
+ "tool": "calibration_explain",
54
+ "args": {
55
+ "gauges": "fixtures/gauges.csv",
56
+ "usage": "fixtures/usage.csv",
57
+ "as_of": "2026-11-18",
58
+ "gauge": "mic-002"
59
+ },
60
+ "expect": {
61
+ "status": "executed",
62
+ "contains": [
63
+ "failed its calibration on 2026-10-20 and was used afterwards"
64
+ ]
65
+ }
66
+ },
67
+ {
68
+ "id": "one-week-look-ahead",
69
+ "tool": "calibration_check",
70
+ "args": {
71
+ "gauges": "fixtures/gauges.csv",
72
+ "usage": "fixtures/usage.csv",
73
+ "settings": "fixtures/settings-week.json",
74
+ "as_of": "2026-11-18"
75
+ },
76
+ "expect": {
77
+ "equals": {
78
+ "result.watch": 1,
79
+ "result.ok": 4,
80
+ "result.settings_used.due_soon_days": 7
81
+ }
82
+ }
83
+ },
84
+ {
85
+ "id": "calibration-register-export",
86
+ "tool": "calibration_check",
87
+ "args": {
88
+ "gauges": "fixtures/exports/calibration-register.csv",
89
+ "as_of": "2026-11-18"
90
+ },
91
+ "expect": {
92
+ "equals": {
93
+ "result.gauges": 2,
94
+ "result.flag": 1,
95
+ "result.watch": 1,
96
+ "result.suspect_work_orders": 0
97
+ }
98
+ }
99
+ },
100
+ {
101
+ "id": "draft-suspect-product-notice-after-approval",
102
+ "tool": "calibration_draft_suspect_product_notice",
103
+ "args": {
104
+ "gauges": "fixtures/gauges.csv",
105
+ "usage": "fixtures/usage.csv",
106
+ "as_of": "2026-11-18",
107
+ "from": "Quinn Quality (fictional)"
108
+ },
109
+ "approve": "Pat Example",
110
+ "expect": {
111
+ "status": "executed",
112
+ "equals": {
113
+ "result.open_markers": 1
114
+ },
115
+ "contains": [
116
+ "suspect product notice open drafted"
117
+ ]
118
+ }
119
+ },
120
+ {
121
+ "id": "missing-argument-named",
122
+ "tool": "calibration_check",
123
+ "args": {},
124
+ "expect": {
125
+ "status": "error",
126
+ "contains": [
127
+ "gauges"
128
+ ]
129
+ },
130
+ "generated": true
131
+ },
132
+ {
133
+ "id": "file-outside-root-refused",
134
+ "tool": "calibration_check",
135
+ "args": {
136
+ "gauges": "../../../outside.csv",
137
+ "usage": "fixtures/usage.csv",
138
+ "settings": "fixtures/settings.json",
139
+ "as_of": "2026-11-18"
140
+ },
141
+ "expect": {
142
+ "status": "error",
143
+ "contains": [
144
+ "outside"
145
+ ]
146
+ },
147
+ "generated": true
148
+ },
149
+ {
150
+ "id": "invented-tool-name-refused",
151
+ "tool": "calibration_pay_everything_now",
152
+ "args": {},
153
+ "expect": {
154
+ "status": "blocked"
155
+ },
156
+ "generated": true
157
+ },
158
+ {
159
+ "id": "review-mode-still-reads",
160
+ "tool": "calibration_check",
161
+ "mode": "review",
162
+ "args": {
163
+ "gauges": "fixtures/gauges.csv",
164
+ "usage": "fixtures/usage.csv",
165
+ "settings": "fixtures/settings.json",
166
+ "as_of": "2026-11-18"
167
+ },
168
+ "expect": {
169
+ "status": "executed",
170
+ "equals": {
171
+ "result.gauges": 9,
172
+ "result.overdue": 1,
173
+ "result.suspect_work_orders": 3,
174
+ "result.flag": 2,
175
+ "result.review": 2,
176
+ "result.watch": 2,
177
+ "result.ok": 3
178
+ }
179
+ },
180
+ "generated": true
181
+ },
182
+ {
183
+ "id": "status-filter-keeps-totals",
184
+ "tool": "calibration_check",
185
+ "args": {
186
+ "gauges": "fixtures/gauges.csv",
187
+ "usage": "fixtures/usage.csv",
188
+ "settings": "fixtures/settings.json",
189
+ "as_of": "2026-11-18",
190
+ "status": "ok",
191
+ "limit": 1
192
+ },
193
+ "expect": {
194
+ "status": "executed",
195
+ "max": {
196
+ "result.items_shown": 1
197
+ },
198
+ "equals": {
199
+ "result.gauges": 9,
200
+ "result.overdue": 1,
201
+ "result.suspect_work_orders": 3,
202
+ "result.flag": 2,
203
+ "result.review": 2,
204
+ "result.watch": 2,
205
+ "result.ok": 3
206
+ }
207
+ },
208
+ "generated": true
209
+ },
210
+ {
211
+ "id": "explain-unknown-item-is-a-readable-error",
212
+ "tool": "calibration_explain",
213
+ "args": {
214
+ "gauges": "fixtures/gauges.csv",
215
+ "usage": "fixtures/usage.csv",
216
+ "settings": "fixtures/settings.json",
217
+ "as_of": "2026-11-18",
218
+ "gauge": "No Such Thing Zz"
219
+ },
220
+ "expect": {
221
+ "status": "error",
222
+ "contains": [
223
+ "not found"
224
+ ]
225
+ },
226
+ "generated": true
227
+ },
228
+ {
229
+ "id": "report-writes-its-files",
230
+ "tool": "calibration_write_report",
231
+ "args": {
232
+ "gauges": "fixtures/gauges.csv",
233
+ "usage": "fixtures/usage.csv",
234
+ "settings": "fixtures/settings.json",
235
+ "as_of": "2026-11-18"
236
+ },
237
+ "expect": {
238
+ "status": "executed",
239
+ "min": {
240
+ "result.files.length": 2
241
+ },
242
+ "matches": [
243
+ "[0-9a-f]{64}"
244
+ ]
245
+ },
246
+ "generated": true
247
+ },
248
+ {
249
+ "id": "draft-waits-for-a-person",
250
+ "tool": "calibration_draft_suspect_product_notice",
251
+ "args": {
252
+ "gauges": "fixtures/gauges.csv",
253
+ "usage": "fixtures/usage.csv",
254
+ "as_of": "2026-11-18",
255
+ "from": "Quinn Quality (fictional)"
256
+ },
257
+ "expect": {
258
+ "status": "needs_approval",
259
+ "decision": "ask"
260
+ },
261
+ "generated": true
262
+ },
263
+ {
264
+ "id": "review-mode-drafts-nothing",
265
+ "tool": "calibration_draft_suspect_product_notice",
266
+ "mode": "review",
267
+ "args": {
268
+ "gauges": "fixtures/gauges.csv",
269
+ "usage": "fixtures/usage.csv",
270
+ "as_of": "2026-11-18",
271
+ "from": "Quinn Quality (fictional)"
272
+ },
273
+ "expect": {
274
+ "status": "blocked"
275
+ },
276
+ "generated": true
277
+ },
278
+ {
279
+ "id": "request-stays-one-click-in-auto",
280
+ "tool": "calibration_request_send",
281
+ "mode": "auto",
282
+ "auto_actions": [
283
+ "calibration_draft_suspect_product_notice"
284
+ ],
285
+ "args": {
286
+ "draft": "fairmake-out/calibration/drafts/none.md",
287
+ "draft_sha256": "0000000000000000000000000000000000000000000000000000000000000000"
288
+ },
289
+ "expect": {
290
+ "status": "needs_approval",
291
+ "decision": "ask"
292
+ },
293
+ "generated": true
294
+ },
295
+ {
296
+ "id": "refuses-qms-release-hold",
297
+ "tool": "qms_release_hold",
298
+ "mode": "auto",
299
+ "args": {},
300
+ "expect": {
301
+ "status": "blocked"
302
+ },
303
+ "generated": true
304
+ },
305
+ {
306
+ "id": "refuses-customer-notice-send",
307
+ "tool": "customer_notice_send",
308
+ "mode": "auto",
309
+ "args": {},
310
+ "expect": {
311
+ "status": "blocked"
312
+ },
313
+ "generated": true
314
+ },
315
+ {
316
+ "id": "intl-de-check-totals",
317
+ "tool": "calibration_check",
318
+ "args": {
319
+ "gauges": "fixtures/intl/de/gauges.csv",
320
+ "usage": "fixtures/intl/de/usage.csv",
321
+ "settings": "fixtures/settings.json",
322
+ "as_of": "2026-11-18"
323
+ },
324
+ "expect": {
325
+ "equals": {
326
+ "result.gauges": 9,
327
+ "result.overdue": 1,
328
+ "result.suspect_work_orders": 3,
329
+ "result.flag": 2,
330
+ "result.review": 2,
331
+ "result.watch": 2,
332
+ "result.ok": 3
333
+ }
334
+ },
335
+ "note": "German export of the same data (fixtures/intl/de); must match the English case \"check-totals\"."
336
+ },
337
+ {
338
+ "id": "intl-ja-check-totals",
339
+ "tool": "calibration_check",
340
+ "args": {
341
+ "gauges": "fixtures/intl/ja/gauges.csv",
342
+ "usage": "fixtures/intl/ja/usage.csv",
343
+ "settings": "fixtures/settings.json",
344
+ "as_of": "2026-11-18"
345
+ },
346
+ "expect": {
347
+ "equals": {
348
+ "result.gauges": 9,
349
+ "result.overdue": 1,
350
+ "result.suspect_work_orders": 3,
351
+ "result.flag": 2,
352
+ "result.review": 2,
353
+ "result.watch": 2,
354
+ "result.ok": 3
355
+ }
356
+ },
357
+ "note": "Japanese export of the same data (fixtures/intl/ja); must match the English case \"check-totals\"."
358
+ }
359
+ ]
360
+ }
@@ -0,0 +1,7 @@
1
+ # Fairmake Calibration Due fixtures
2
+
3
+ Fictional gauges and gauge use, as of 2026-11-18.
4
+
5
+ - `gauges.csv`, `usage.csv`: a micrometer that failed calibration and was used twice afterwards (MIC-002); a caliper overdue and used past its due date (CAL-003); two gauges due soon; one never calibrated; one with no interval; an out-of-service CMM that is not chased; and gauges in calibration. Use before a failed calibration or before the due date is not suspect.
6
+ - `settings.json`, `settings-week.json`: thirty and seven days of look-ahead.
7
+ - `exports/calibration-register.csv`: generic calibration register columns. Written from knowledge of such exports, not checked against a live system.
@@ -0,0 +1,3 @@
1
+ # Clean set
2
+
3
+ The demo files with every planted problem in [../README.md](../README.md) removed and nothing else changed, made by `scripts/accuracy.mjs` from `scripts/accuracy-specs.mjs` in the repository. The check must report no findings on these files (settings and other JSON inputs: `../settings.json`). Fictional data.
@@ -0,0 +1,10 @@
1
+ gauge,description,location,last_cal,interval_days,cal_result,gauge_status
2
+ MIC-001,0-1 in micrometer,QC Lab,2026-06-01,365,Pass,Active
3
+ MIC-002,Outside micrometer,Cell 2,2026-10-20,180,Pass,Active
4
+ CAL-003,Caliper 6 in,Cell 1,2026-01-01,365,Pass,Active
5
+ HG-004,Height gauge,QC Lab,2026-03-01,330,Pass,Active
6
+ PG-005,Pin gauge set,Cell 3,2026-06-01,365,Pass,Active
7
+ TW-006,Torque wrench,Assembly,2026-08-01,365,Pass,Active
8
+ CMM-007,Coordinate measuring machine,QC Lab,2025-09-01,365,Pass,Out of service
9
+ MIC-008,Micrometer 1-2 in,Cell 1,2026-09-01,180,Pass,Active
10
+ THR-009,Thread ring gauge,Cell 2,2026-08-01,180,Pass,Active
@@ -0,0 +1,7 @@
1
+ gauge,work_order,used_date
2
+ MIC-002,WO-301,2026-11-02
3
+ MIC-002,WO-305,2026-11-05
4
+ MIC-002,WO-290,2026-10-15
5
+ CAL-003,WO-310,2026-11-10
6
+ CAL-003,WO-299,2026-10-25
7
+ MIC-008,WO-320,2026-11-12
@@ -0,0 +1,3 @@
1
+ Gauge ID,Description,Location,Last Calibration,Calibration Interval,Result,Status,Cert No
2
+ CAL-003,Caliper 6 in,Cell 1,11/01/2025,365,Pass,Active,C-1
3
+ HG-004,Height gauge,QC Lab,01/10/2026,330,Pass,Active,C-2
@@ -0,0 +1,10 @@
1
+ gauge,description,location,last_cal,interval_days,cal_result,gauge_status
2
+ MIC-001,0-1 in micrometer,QC Lab,2026-06-01,365,Pass,Active
3
+ MIC-002,Outside micrometer,Cell 2,2026-10-20,180,Fail,Active
4
+ CAL-003,Caliper 6 in,Cell 1,2025-11-01,365,Pass,Active
5
+ HG-004,Height gauge,QC Lab,2026-01-10,330,Pass,Active
6
+ PG-005,Pin gauge set,Cell 3,,365,,Active
7
+ TW-006,Torque wrench,Assembly,2026-08-01,,Pass,Active
8
+ CMM-007,Coordinate measuring machine,QC Lab,2025-09-01,365,Pass,Out of service
9
+ MIC-008,Micrometer 1-2 in,Cell 1,2026-09-01,180,Pass,Active
10
+ THR-009,Thread ring gauge,Cell 2,2026-05-25,180,Pass,Active
@@ -0,0 +1,12 @@
1
+ # Fixtures from other countries
2
+
3
+ Generated by `node scripts/make-intl-fixtures.mjs` from the English fixtures one
4
+ folder up. The same fictional data, written the way a local export writes it:
5
+
6
+ - `de/`: German column names, Windows-1252 text, semicolons, comma decimals
7
+ (1.234,56), day-first dotted dates (03.11.2026), kilograms and kilometres.
8
+ - `ja/`: Japanese column names, Shift_JIS text, year-first dates (2026/11/03),
9
+ kilograms and kilometres.
10
+
11
+ Values (names, codes, charge wording) stay in English. The eval cases
12
+ `intl-de-*` and `intl-ja-*` expect exactly the same results as the English case.
@@ -0,0 +1,10 @@
1
+ Pr�fmittel;Beschreibung;Lagerort;Zuletzt durchgef�hrt;Intervall (Tage);cal_result;gauge_status
2
+ MIC-001;0-1 in micrometer;QC Lab;01.06.2026;365;Pass;Active
3
+ MIC-002;Outside micrometer;Cell 2;20.10.2026;180;Fail;Active
4
+ CAL-003;Caliper 6 in;Cell 1;01.11.2025;365;Pass;Active
5
+ HG-004;Height gauge;QC Lab;10.01.2026;330;Pass;Active
6
+ PG-005;Pin gauge set;Cell 3;;365;;Active
7
+ TW-006;Torque wrench;Assembly;01.08.2026;;Pass;Active
8
+ CMM-007;Coordinate measuring machine;QC Lab;01.09.2025;365;Pass;Out of service
9
+ MIC-008;Micrometer 1-2 in;Cell 1;01.09.2026;180;Pass;Active
10
+ THR-009;Thread ring gauge;Cell 2;25.05.2026;180;Pass;Active
@@ -0,0 +1,7 @@
1
+ Pr�fmittel;Fertigungsauftrag;used_date
2
+ MIC-002;WO-301;02.11.2026
3
+ MIC-002;WO-305;05.11.2026
4
+ MIC-002;WO-290;15.10.2026
5
+ CAL-003;WO-310;10.11.2026
6
+ CAL-003;WO-299;25.10.2026
7
+ MIC-008;WO-320;12.11.2026
@@ -0,0 +1,10 @@
1
+ �v����,�E�v,�ۊǏꏊ,�O����{��,�����i���j,cal_result,gauge_status
2
+ MIC-001,0-1 in micrometer,QC Lab,2026/06/01,365,Pass,Active
3
+ MIC-002,Outside micrometer,Cell 2,2026/10/20,180,Fail,Active
4
+ CAL-003,Caliper 6 in,Cell 1,2025/11/01,365,Pass,Active
5
+ HG-004,Height gauge,QC Lab,2026/01/10,330,Pass,Active
6
+ PG-005,Pin gauge set,Cell 3,,365,,Active
7
+ TW-006,Torque wrench,Assembly,2026/08/01,,Pass,Active
8
+ CMM-007,Coordinate measuring machine,QC Lab,2025/09/01,365,Pass,Out of service
9
+ MIC-008,Micrometer 1-2 in,Cell 1,2026/09/01,180,Pass,Active
10
+ THR-009,Thread ring gauge,Cell 2,2026/05/25,180,Pass,Active
@@ -0,0 +1,7 @@
1
+ �v����,�����w�},used_date
2
+ MIC-002,WO-301,2026/11/02
3
+ MIC-002,WO-305,2026/11/05
4
+ MIC-002,WO-290,2026/10/15
5
+ CAL-003,WO-310,2026/11/10
6
+ CAL-003,WO-299,2026/10/25
7
+ MIC-008,WO-320,2026/11/12
@@ -0,0 +1 @@
1
+ { "note": "One week of look-ahead.", "due_soon_days": 7 }
@@ -0,0 +1 @@
1
+ { "note": "Fictional calibration settings.", "due_soon_days": 30 }
@@ -0,0 +1,7 @@
1
+ gauge,work_order,used_date
2
+ MIC-002,WO-301,2026-11-02
3
+ MIC-002,WO-305,2026-11-05
4
+ MIC-002,WO-290,2026-10-15
5
+ CAL-003,WO-310,2026-11-10
6
+ CAL-003,WO-299,2026-10-25
7
+ MIC-008,WO-320,2026-11-12
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "fairmake-calibration-due",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "mcpName": "io.github.fpavia111-creator/fairmake-calibration-due",
5
+ "description": "Fairmake Calibration Due: gauges overdue or due soon, never calibrated, and work orders measured with a gauge that was overdue or had failed calibration, with a due-date calendar. Releases no hold.",
6
+ "type": "module",
7
+ "license": "MIT",
8
+ "author": "Kurt Francisco",
9
+ "engines": {
10
+ "node": ">=20"
11
+ },
12
+ "main": "src/index.js",
13
+ "exports": {
14
+ ".": "./src/index.js",
15
+ "./package.json": "./package.json"
16
+ },
17
+ "bin": {
18
+ "fairmake-calibration-due": "bin/fairmake-calibration-due.js"
19
+ },
20
+ "files": [
21
+ "src",
22
+ "bin",
23
+ "fixtures",
24
+ "evals",
25
+ "README.md",
26
+ "CHANGELOG.md",
27
+ "LICENSE",
28
+ "server.json"
29
+ ],
30
+ "scripts": {
31
+ "test": "node scripts/run-tests.cjs",
32
+ "demo": "node bin/fairmake-calibration-due.js demo",
33
+ "eval": "node bin/fairmake-calibration-due.js eval"
34
+ },
35
+ "dependencies": {
36
+ "fairmake-core": "^0.1.0"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/fpavia111-creator/fairmake-agents.git",
41
+ "directory": "packages/fairmake-calibration-due"
42
+ },
43
+ "homepage": "https://github.com/fpavia111-creator/fairmake-agents/tree/master/packages/fairmake-calibration-due#readme",
44
+ "bugs": {
45
+ "url": "https://github.com/fpavia111-creator/fairmake-agents/issues"
46
+ },
47
+ "keywords": [
48
+ "mcp",
49
+ "mcp-server",
50
+ "manufacturing",
51
+ "distribution",
52
+ "erp",
53
+ "fairmake",
54
+ "calibration",
55
+ "gauges",
56
+ "quality",
57
+ "iso-9001",
58
+ "instruments"
59
+ ]
60
+ }
package/server.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.fpavia111-creator/fairmake-calibration-due",
4
+ "title": "Fairmake Calibration Due",
5
+ "description": "Fairmake Calibration Due: gauges overdue or due soon, never calibrated, and work orders measured…",
6
+ "version": "0.1.0",
7
+ "repository": {
8
+ "url": "https://github.com/fpavia111-creator/fairmake-agents",
9
+ "source": "github",
10
+ "subfolder": "packages/fairmake-calibration-due"
11
+ },
12
+ "websiteUrl": "https://fair-agents.com/fairmake.html",
13
+ "packages": [
14
+ {
15
+ "registryType": "npm",
16
+ "identifier": "fairmake-calibration-due",
17
+ "version": "0.1.0",
18
+ "transport": {
19
+ "type": "stdio"
20
+ },
21
+ "packageArguments": [
22
+ {
23
+ "type": "positional",
24
+ "value": "mcp"
25
+ },
26
+ {
27
+ "type": "named",
28
+ "name": "--root",
29
+ "description": "Folder holding the exports this agent may read and write (it cannot reach outside it)",
30
+ "isRequired": true,
31
+ "format": "filepath",
32
+ "valueHint": "exports_folder"
33
+ }
34
+ ]
35
+ }
36
+ ]
37
+ }
@@ -0,0 +1,69 @@
1
+ // Calibration due dates: gauges overdue or due soon, never calibrated, and work orders measured with a gauge
2
+ // that was overdue or had failed its last calibration (suspect product).
3
+ import { exportProfile, finding, statusOf, tallyFindings, countBy, str, itemKey, groupBy, daysBetween, addDays, asOfDate } from 'fairmake-core';
4
+
5
+ const t = (aliases, extra = {}) => ({ aliases, ...extra });
6
+ export const GAUGE_FIELDS = Object.freeze({
7
+ gauge: t(['Gauge', 'Gauge ID', 'Instrument', 'Instrument ID', 'Asset'], { required: true }),
8
+ description: t(['Description', 'Gauge Description', 'Type']),
9
+ location: t(['Location', 'Area', 'Department']),
10
+ last_cal: t(['Last Calibration', 'Last Cal', 'Calibrated On', 'Last Calibrated'], { type: 'date' }),
11
+ interval_days: t(['Interval Days', 'Calibration Interval', 'Frequency (days)', 'Cal Interval'], { type: 'number' }),
12
+ cal_result: t(['Result', 'Cal Result', 'As Found', 'Last Result']),
13
+ gauge_status: t(['Status', 'Gauge Status', 'State']),
14
+ });
15
+ export const USAGE_FIELDS = Object.freeze({
16
+ gauge: t(['Gauge', 'Gauge ID', 'Instrument'], { required: true }),
17
+ work_order: t(['Work Order', 'Job', 'Lot', 'Inspection Lot']),
18
+ used_date: t(['Used Date', 'Date', 'Inspection Date', 'Measured On'], { type: 'date' }),
19
+ });
20
+ /** Generic calibration register. Written from knowledge of such exports; not checked against a live system. */
21
+ export const GAUGE_PROFILES = Object.freeze([
22
+ exportProfile('calibration_register', { gauge: 'Gauge ID', description: 'Description', location: 'Location', last_cal: 'Last Calibration', interval_days: 'Calibration Interval', cal_result: 'Result', gauge_status: 'Status' }, { note: 'Calibration register: one row per gauge with its last calibration and interval.' }),
23
+ ]);
24
+
25
+ export const DEFAULTS = Object.freeze({ due_soon_days: 30 });
26
+ export const SETTINGS_SCHEMA = Object.freeze({
27
+ type: 'object', additionalProperties: false,
28
+ properties: {
29
+ note: { type: 'string', description: 'Free text for your own records' },
30
+ due_soon_days: { type: 'integer', minimum: 1, maximum: 365, description: 'A gauge due within this many days is listed as due soon' },
31
+ },
32
+ });
33
+ const FAILED = /fail|out of tol|oot|reject|nok|^no$/i;
34
+ const RETIRED = /out of service|retired|scrapped|lost|inactive/i;
35
+
36
+ /** Gauge status. Finding codes: overdue, due_soon, failed_then_used, used_while_overdue, never_calibrated, no_interval. */
37
+ export function calibrationStatus({ gauges, usage }, s = DEFAULTS, asOf) {
38
+ const today = asOfDate(asOf);
39
+ const U = groupBy(usage.filter((u) => str(u.gauge)), (u) => itemKey(u.gauge));
40
+ const suspect = [];
41
+ const items = [...groupBy(gauges.filter((g) => str(g.gauge)), (g) => itemKey(g.gauge)).values()].map((gs) => {
42
+ const g = gs[0]; const id = str(g.gauge); const retired = RETIRED.test(str(g.gauge_status)); const failed = FAILED.test(str(g.cal_result));
43
+ const due = g.last_cal && g.interval_days ? addDays(g.last_cal, g.interval_days) : null; const days = due ? daysBetween(today, due) : null; const f = [];
44
+ const uses = (U.get(itemKey(id)) || []).filter((u) => u.used_date).sort((a, b) => (a.used_date < b.used_date ? -1 : a.used_date > b.used_date ? 1 : (str(a.work_order) < str(b.work_order) ? -1 : 1)));
45
+ if (!retired) {
46
+ if (!g.last_cal) f.push(finding('never_calibrated', null, `${id} has no calibration on record.`, 'review'));
47
+ if (!g.interval_days) f.push(finding('no_interval', null, `${id} has no calibration interval.`, 'review'));
48
+ if (days !== null && days < 0) f.push(finding('overdue', null, `${id} was due for calibration ${due} (${-days} days ago).`));
49
+ else if (days !== null && days <= s.due_soon_days) f.push(finding('due_soon', null, `${id} is due for calibration ${due} (in ${days} days).`, 'watch'));
50
+ }
51
+ const afterFail = failed && g.last_cal ? uses.filter((u) => u.used_date >= g.last_cal) : [];
52
+ if (afterFail.length) { f.push(finding('failed_then_used', null, `${id} failed its calibration on ${g.last_cal} and was used afterwards on ${afterFail.map((u) => `${str(u.work_order) || '?'} (${u.used_date})`).join(', ')}. Review that product.`)); for (const u of afterFail) suspect.push({ gauge: id, work_order: str(u.work_order), used_date: u.used_date, why: 'used after a failed calibration' }); }
53
+ const afterDue = due ? uses.filter((u) => u.used_date > due && !afterFail.includes(u)) : [];
54
+ if (afterDue.length) { f.push(finding('used_while_overdue', null, `${id} was used past its due date ${due} on ${afterDue.map((u) => `${str(u.work_order) || '?'} (${u.used_date})`).join(', ')}.`)); for (const u of afterDue) suspect.push({ gauge: id, work_order: str(u.work_order), used_date: u.used_date, why: 'used while overdue' }); }
55
+ return { gauge: id, description: str(g.description), location: str(g.location), last_cal: g.last_cal, cal_result: str(g.cal_result), due_date: due, days_to_due: days, gauge_status: str(g.gauge_status), uses: uses.length, status: statusOf(f), findings: f };
56
+ }).sort((a, b) => (itemKey(a.gauge) < itemKey(b.gauge) ? -1 : 1));
57
+ suspect.sort((a, b) => (`${a.gauge}|${a.used_date}|${a.work_order}` < `${b.gauge}|${b.used_date}|${b.work_order}` ? -1 : 1));
58
+ return {
59
+ as_of: today, gauges: items.length, overdue: items.filter((i) => i.findings.some((f) => f.code === 'overdue')).length, suspect_work_orders: suspect.length,
60
+ flag: items.filter((i) => i.status === 'flag').length, review: items.filter((i) => i.status === 'review').length, watch: items.filter((i) => i.status === 'watch').length, ok: items.filter((i) => i.status === 'ok').length,
61
+ suspect, by_finding: tallyFindings(items), by_status: countBy(items), items,
62
+ };
63
+ }
64
+
65
+ export function suspectNoticeText(r, { from } = {}) {
66
+ return ['# Product measured with a suspect gauge', '', '**To:** [TO CONFIRM quality manager]', `**From:** ${from || '[TO CONFIRM your name]'}`, '',
67
+ `${r.suspect_work_orders} measurement(s) were made with a gauge that had failed calibration or was overdue. Please decide for each work order whether the product needs re-inspection, and whether any customer must be told. This note tells no customer anything.`, '',
68
+ '| Gauge | Work order | Used on | Why |', '| --- | --- | --- | --- |', ...r.suspect.map((x) => `| ${x.gauge} | ${x.work_order} | ${x.used_date} | ${x.why} |`)].join('\n');
69
+ }
package/src/demo.js ADDED
@@ -0,0 +1,4 @@
1
+ import { fairmakeDemo } from 'fairmake-core';
2
+ import { manifest, DEMO } from './manifest.js';
3
+
4
+ export const demo = fairmakeDemo(manifest, new URL('../fixtures/', import.meta.url), DEMO);
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { manifest } from './manifest.js';
2
+ export * from './calibration.js';
@@ -0,0 +1,48 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { defineFairmakeAgent, findingRows } from 'fairmake-core';
3
+ import { GAUGE_FIELDS, USAGE_FIELDS, GAUGE_PROFILES, DEFAULTS, SETTINGS_SCHEMA, calibrationStatus, suspectNoticeText } from './calibration.js';
4
+
5
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
6
+ const args = {
7
+ gauges: { type: 'string', description: 'Gauge or instrument register under --root: id, last calibration, interval in days, last result and status' },
8
+ usage: { type: 'string', description: 'Optional gauge use log under --root: gauge, work order or lot, and date used' },
9
+ as_of: { type: 'string', format: 'date', description: 'Date to measure from, YYYY-MM-DD (default today)' },
10
+ };
11
+
12
+ export const manifest = defineFairmakeAgent({
13
+ name: pkg.name, version: pkg.version, prefix: 'calibration',
14
+ description: 'Checks every gauge and instrument against its calibration interval: flags overdue gauges, lists those due soon, reviews gauges never calibrated or with no interval, and, from a use log, names the work orders measured with a gauge that was overdue or had failed calibration. Writes a due-date calendar and drafts a suspect-product note for quality. Releases no hold and tells no customer.',
15
+ args, required: ['gauges'],
16
+ sources: { gauges: { label: 'Gauge register', args: ['gauges'], fields: GAUGE_FIELDS, profiles: GAUGE_PROFILES }, usage: { label: 'Gauge use log', args: ['usage'], fields: USAGE_FIELDS } },
17
+ settings: { schema: SETTINGS_SCHEMA, defaults: DEFAULTS },
18
+ run: ({ a, read, s }) => calibrationStatus({ gauges: read('gauges'), usage: read('usage') }, s, a.as_of),
19
+ line: (r) => `${r.gauges} gauge(s) as of ${r.as_of}: ${r.overdue} overdue, ${r.suspect_work_orders} measurement(s) with a suspect gauge, ${r.review} to review, ${r.watch} due soon, ${r.ok} in calibration.`,
20
+ item: { key: 'gauge', arg: 'gauge', label: 'gauge' },
21
+ check: { title: 'Check calibration due dates', description: 'Work out each gauge\'s next calibration date from the last one and its interval. Flags overdue gauges, gauges used after a failed calibration and gauges used past their due date (naming the work orders); lists gauges due soon; reviews gauges never calibrated or with no interval. Out-of-service gauges are not chased for dates.' },
22
+ report: {
23
+ base: 'calibration-due', title: (r) => `Calibration due dates as of ${r.as_of}`,
24
+ rows: (r) => r.items.map((i) => ({ gauge: i.gauge, description: i.description, location: i.location, last_cal: i.last_cal, cal_result: i.cal_result, due_date: i.due_date, days: i.days_to_due, status: i.status, findings: i.findings.map((f) => f.code).join(' '), reasons: i.findings.map((f) => f.detail).join(' ') })),
25
+ htmlColumns: ['gauge', 'description', 'location', 'last_cal', 'due_date', 'days', 'status', 'reasons'],
26
+ sections: (r) => [{ title: 'Suspect work orders', rows: r.suspect, columns: ['gauge', 'work_order', 'used_date', 'why'] }, { title: 'By finding', rows: findingRows(r.by_finding), columns: ['code', 'count'] }],
27
+ limits: ['Whether product measured with a suspect gauge must be re-inspected or reported is a quality decision; the agent only lists it.'],
28
+ ics: (r) => ({ calName: 'Calibration due', events: r.items.filter((i) => i.due_date && !/out of service|retired|scrapped|lost|inactive/i.test(i.gauge_status)).map((i) => ({ uid: `cal-${i.gauge}-${i.due_date}@fairmake`, date: i.due_date < r.as_of ? r.as_of : i.due_date, summary: `Calibration ${i.due_date < r.as_of ? 'overdue' : 'due'}: ${i.gauge} ${i.description}`.trim(), description: `Written by fairmake-calibration-due. Due ${i.due_date}.`, reminders: [7] })) }),
29
+ },
30
+ draft: {
31
+ noun: 'suspect_product_notice', verb: 'send', category: 'binding_send', actor: 'the quality manager',
32
+ description: 'Write drafts/suspect_product_notice-open.md: every work order measured with a gauge that had failed calibration or was overdue, for the quality manager to decide on re-inspection. Marked DRAFT. Sending goes through calibration_request_send (one click).',
33
+ args: { from: { type: 'string', description: 'Your name' } },
34
+ build: (r, a) => { if (!r.suspect.length) throw new Error('no measurement was made with a suspect gauge'); return { id: 'open', text: suspectNoticeText(r, a) }; },
35
+ },
36
+ refused: [
37
+ { name: 'qms_release_hold', category: 'production_deploy', description: 'Never places or releases a quality hold in the QMS or ERP.' },
38
+ { name: 'customer_notice_send', category: 'binding_send', description: 'Never notifies a customer about suspect product.' },
39
+ ],
40
+ prompt: { name: 'calibration_review', title: 'Review calibration due dates', text: 'You are helping a quality manager with fairmake-calibration-due. Call calibration_check with the gauge register and, if available, the gauge use log. Lead with suspect work orders (gauges used after a failed calibration or while overdue), then overdue gauges. Offer calibration_write_report (with a calendar) and calibration_draft_suspect_product_notice.' },
41
+ });
42
+
43
+ export const DEMO = {
44
+ intro: 'Fairmake Calibration Due demo: nine fictional gauges and a month of gauge use, as of 2026-11-18.',
45
+ files: { gauges: 'gauges.csv', usage: 'usage.csv', settings: 'settings.json', as_of: '2026-11-18' },
46
+ explain: { gauge: 'MIC-002' },
47
+ draft: { from: 'Quinn Quality (fictional)' },
48
+ };