fairpolicy-commission-statements 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 (Fairpolicy ver 1, built on fairpolicy-core).
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,230 @@
1
- # Temporary Holding Version
1
+ # Fairpolicy Commission Statements (`fairpolicy-commission-statements`)
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
+ Checks every line of a carrier commission statement against the commission you expect on that policy (your schedule by carrier, line and new or renewal, or the rate booked in your agency system) and lists underpaid, overpaid, duplicate and unmatched lines, with totals by carrier. Drafts a commission inquiry for one named person to send; never posts, pays or sends.
4
+
5
+ **It never posts receipts or commission entries in your agency system; your accounting staff do. It never sends e-mail; a person sends the approved inquiry.**
6
+
7
+ MIT · Node 20 or newer · local files only · client identifiers masked before results reach the model · built on [`fairpolicy-core`](../fairpolicy-core)
8
+
9
+ ```bash
10
+ npx -y fairpolicy-commission-statements demo
11
+ npx -y fairpolicy-commission-statements mcp --root ./agency-exports
12
+ ```
13
+
14
+ <!-- generated:start -->
15
+
16
+ ## A demo run
17
+
18
+ `npx -y fairpolicy-commission-statements demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
19
+
20
+ ```text
21
+ Fairpolicy Commission Statements demo (fictional agency, carriers and clients, October 2026)
22
+
23
+ ▶ Check every statement line against the expected commission
24
+ status: executed decision: allow
25
+ 13 statement line(s), 3892 paid against 3089.7 expected: 2 underpaid by 307.2, 1 overpaid by 20.5; 2 possible duplicate(s), 1 not in your policy list, 1 with no expected rate.
26
+ PA-5521800 new expected 276 paid 220.8 underpaid
27
+ WC-88120 new expected 1260 paid 1008 underpaid
28
+ HO-7730288 endorsement expected 36 paid 36 possible_duplicate
29
+ HO-7730288 endorsement expected 36 paid 36 possible_duplicate
30
+ UMB-9002 renewal expected 61.5 paid 82 overpaid
31
+ PA-5599999 new expected - paid 225 no_policy
32
+ CA-20441 new expected - paid 768 no_rate
33
+ WC-88120 audit expected - paid 96 not_checked
34
+ BOP104455 renewal expected 840 paid 840 ok
35
+ CGL-330017 cancellation expected -487.5 paid -487.5 ok
36
+ CGL-330017 new expected 585 paid 585 ok
37
+ HO-7730141 renewal expected 331.5 paid 331.5 ok
38
+ PA-5521911 renewal expected 151.2 paid 151.2 ok
39
+
40
+ ▶ Explain the workers comp line
41
+ status: executed decision: allow
42
+ WC-88120: underpaid. Paid 1008 on premium 12600; 10% (schedule: Sample Casualty Workers Compensation new) is 1260, so 252 short (the statement shows 8%). Next: Ask the carrier for the missing commission (draft an inquiry), or correct the schedule if the rate really changed.
43
+
44
+ ▶ Write the commission worklist
45
+ status: executed decision: allow
46
+ Commission statement check written: 13 statement line(s), 3892 paid against 3089.7 expected: 2 underpaid by 307.2, 1 overpaid by 20.5; 2 possible duplicate(s), 1 not in your policy list, 1 with no expected rate. Files: fairpolicy-out/commissions/commission-statements.csv, fairpolicy-out/commissions/commission-statements.html.
47
+
48
+ ▶ Draft a commission inquiry to the carrier that paid the renewal rate on new business
49
+ status: executed decision: allow (auto)
50
+ inquiry Sample Casualty drafted for 252 with 1 open marker(s) ([CHECK the agreed rates against your current agency agreement before sending.]). Nothing was sent.
51
+
52
+ ▶ Approve sending: waits for a named person even in Auto
53
+ status: needs_approval decision: ask
54
+ reason: binding_send stays one-click, even in Auto
55
+
56
+ ▶ Same call after the click (recorded; a person sends it)
57
+ status: executed decision: ask approved by: Casey Park (fictional)
58
+ inquiry 9d7eb8935775 approved and recorded. Nothing was sent or paid by the agent.
59
+
60
+ ▶ The agent tries to post the commission in the agency system itself
61
+ status: blocked decision: block
62
+ reason: It never posts receipts or commission entries in your agency system; your accounting staff do.
63
+ ```
64
+
65
+ ## Tools
66
+
67
+ | Tool | What it does | Policy |
68
+ |---|---|---|
69
+ | `commissions_check` | For each statement line: the policy it belongs to, the expected rate and where it came from, expected and paid commission, the difference and a status (underpaid, possible_duplicate, overpaid, no_policy, no_rate, not_… | runs |
70
+ | `commissions_explain` | One statement line in full: the policy it matched, the rate used and its source, and the arithmetic. | runs |
71
+ | `commissions_write_report` | Write commission-statements.csv (every line with its status and the figures behind it, plus blank owner and notes columns) and commission-statements.html into out_dir (default fairpolicy-out/commissions). | runs |
72
+ | `commissions_draft_inquiry` | Write drafts/inquiry-<carrier>.md asking one carrier about its underpaid statement lines, with the agreed rate, expected and paid amounts and the total short. | asks first (Auto can be opted in) |
73
+ | `commissions_request_send` | After one named human click (even in Auto), record that the reviewed inquiry draft is approved in inquiry-requests.csv. | one named click, even in Auto (`binding_send`) |
74
+ | `commissions_recall` | Search this agent's own memory of the customer's setup: accepted facts (in use) and facts waiting for a person. | runs |
75
+ | `commissions_learn` | Propose one fact about the customer's setup for this agent to remember. | runs |
76
+ | `commissions_accept_learning` | A named person accepts or rejects a fact waiting in this agent's memory. | one named click, even in Auto (`accept_learning`) |
77
+ | `commissions_retire_memory` | A named person stops an accepted fact from applying. | one named click, even in Auto (`accept_learning`) |
78
+ | `ams_post_commission` | It never posts receipts or commission entries in your agency system; your accounting staff do. | refused |
79
+ | `email_send` | It never sends e-mail; a person sends the approved inquiry. | refused |
80
+
81
+ 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.
82
+
83
+ ## Columns it reads
84
+
85
+ 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. Every result lists under `sources` how each file was read. Columns marked *masked* hold patient identifiers: the model sees a pseudonym, a birth year or nothing (see Patient data).
86
+
87
+ ### Carrier commission statement (`statement`)
88
+
89
+ | Column | Type | Also read as | For example, in other languages |
90
+ |---|---|---|---|
91
+ | `policy_number` (required) | text | Policy Number, Policy #, Policy No, Policy, Pol #, Policy Num | Vertragsnummer, N° de police, 証券番号, 保单号 |
92
+ | `client` | text (masked) | Insured Name, Insured, Named Insured, Client Name, Customer Name, Name | Versicherungsnehmer, Assuré, 契約者, 投保人 |
93
+ | `carrier` | text | Carrier, Company, Insurer, Writing Company, Carrier Name | Versicherer, Assureur, 保険会社, 保险公司 |
94
+ | `line` | text | Line of Business, LOB, Policy Type, Line, Coverage, Product | Sparte, Branche, 保険種目, 险种 |
95
+ | `transaction_type` | text | Transaction Type, Trans Type, Transaction, Type, Activity, Trans Code | Buchungsart, Type de mouvement, 取引区分, 交易类型 |
96
+ | `effective_date` | date | Effective Date, Eff Date, Transaction Effective Date, Trans Eff Date, Policy Effective Date | Beginn, Date d'effet, 始期, 生效日期 |
97
+ | `statement_date` | date | Statement Date, Process Date, Accounting Date, Transaction Date, Posted Date, Period | - |
98
+ | `premium` | amount | Premium, Written Premium, Gross Premium, Transaction Premium, Premium Amount, Premium Basis | Beitrag, Prime, 保険料, 保费 |
99
+ | `commission_rate` | number | Commission Rate, Comm Rate, Rate, Comm %, Commission %, Comm Pct | Courtagesatz, Taux de commission, 手数料率, 佣金率 |
100
+ | `commission` (required) | amount | Commission, Commission Amount, Comm Amount, Agency Commission, Commission Paid, Net Commission | Courtage, Commission, 手数料, 佣金 |
101
+ | `statement_id` | text | Statement Number, Statement #, Statement ID, Statement, Statement No | - |
102
+ | `producer` | text | Producer, Agent, Producer Code, Sub Producer | Vermittler, Producteur, 募集人, 业务员 |
103
+
104
+ Named exports recognised by their column names:
105
+
106
+ | System | Export | Recognised by | Layout checked against vendor docs |
107
+ |---|---|---|---|
108
+ | Carrier commission statement | Direct bill commission statement saved as CSV (or PDF text pasted into CSV) | Policy Number, Insured Name, Commission Rate, Commission Amount | no; Each carrier lays its statement out differently; this is the common shape. Map a carrier's own columns in fairpolicy-sources.json. |
109
+ | Maklerabrechnung (DE) | Courtageabrechnung eines Versicherers (CSV) | Vertragsnummer, Versicherungsnehmer, Courtagesatz, Courtage | no; German labels, dates day-first, comma decimals. |
110
+
111
+ Every layout here was written from knowledge of the export ("recalled") and was not checked against vendor documentation or a live account. Agency systems let each agency choose report columns, so the first setup confirms them with inspect.
112
+
113
+ ### Policy list (`policies`)
114
+
115
+ | Column | Type | Also read as | For example, in other languages |
116
+ |---|---|---|---|
117
+ | `policy_number` (required) | text | Policy Number, Policy #, Policy No, Policy, Pol #, Policy Num | Vertragsnummer, N° de police, 証券番号, 保单号 |
118
+ | `client` | text (masked) | Client Name, Insured, Insured Name, Named Insured, Account Name, Customer Name | Versicherungsnehmer, Assuré, 契約者, 投保人 |
119
+ | `client_id` | text (masked) | Client Code, Lookup Code, Account Lookup Code, Customer #, Client Number, Client ID | Kundennummer, Code client, 顧客コード, 客户编号 |
120
+ | `carrier` | text | Carrier, Company, Writing Company, Insurer, Issuing Company, Carrier Name | Versicherer, Assureur, 保険会社, 保险公司 |
121
+ | `line` | text | Line of Business, LOB, Policy Type, Line Type, Coverage, Line | Sparte, Branche, 保険種目, 险种 |
122
+ | `effective_date` | date | Effective Date, Eff Date, Effective, Policy Effective Date, Inception Date, Term Effective | Beginn, Date d'effet, 始期, 生效日期 |
123
+ | `expiration_date` | date | Expiration Date, Exp Date, Expiration, Policy Expiration Date, X-Date, Xdate | Ablauf, Date d'échéance, 満期, 到期日期 |
124
+ | `premium` | amount | Premium, Annualized Premium, Annual Premium, Written Premium, Full Term Premium, Estimated Premium | Beitrag, Prime, 保険料, 保费 |
125
+ | `commission_rate` | number | Commission Rate, Comm Rate, Commission %, Comm %, Agency Commission %, Commission Percent | Courtagesatz, Taux de commission, 手数料率, 佣金率 |
126
+ | `commission` | amount | Commission, Agency Commission, Estimated Commission, Commission Amount, Annualized Commission, Revenue | Courtage, Commission, 手数料, 佣金 |
127
+ | `producer` | text | Producer, Producer Name, Exec, Account Executive, Agent, Producer 1 | Vermittler, Producteur, 募集人, 业务员 |
128
+ | `csr` | text | CSR, Rep, Account Manager, Service Rep, Customer Service Rep, Servicer | Sachbearbeiter, Gestionnaire, 事務担当, 客服 |
129
+ | `status` | text | Status, Policy Status, Current Status | Status, Statut, ステータス, 状态 |
130
+ | `bill_type` | text | Bill Type, Billing Method, Bill Method, Billing Type, Agency/Direct, Bill Plan | Inkassoart, Mode d’encaissement, 集金方法, 收费方式 |
131
+ | `business_type` | text | New/Renewal, New or Renewal, NB/RN, Business Type, New Business/Renewal | - |
132
+ | `segment` | text | Department, Division, Personal/Commercial, Book, Line Group, PL/CL | - |
133
+ | `state` | text | State, Policy State, Risk State, Base State, Garaging State | Bundesland, Région, 都道府県, 省份 |
134
+ | `cancel_date` | date | Cancel Date, Cancellation Date, Cancelled Date, Cancellation Effective Date, Cancel Effective Date | Stornodatum, Date de résiliation, 解約日, 退保日期 |
135
+ | `cancel_reason` | text | Cancel Reason, Cancellation Reason, Lost Reason, Reason Lost | - |
136
+
137
+ Named exports recognised by their column names:
138
+
139
+ | System | Export | Recognised by | Layout checked against vendor docs |
140
+ |---|---|---|---|
141
+ | Applied Epic | Policy list report exported to Excel or CSV | Lookup Code, Account Name, Policy Number, Line Type | no; Applied Epic list reports let each agency choose its columns; the names here are common defaults, not a fixed layout. |
142
+ | Vertafore AMS360 | Policy or expiration list exported to CSV | Customer #, Customer Name, Policy #, Exec, Rep | no; AMS360 calls the producer "Exec" and the service person "Rep". |
143
+ | Vertafore Sagitta | Policy list report (CSV) | Client Code, Client Name, Policy Number, Coverage, Insurer | no |
144
+ | HawkSoft | Client/policy export (CSV) | Client Number, Client Name, Policy Number, Line of Business, Carrier, Policy Status | no |
145
+ | EZLynx | Policy report export (CSV) | Applicant, Policy Number, Line of Business, Carrier, Policy Status | no |
146
+ | QQCatalyst | Policy list export (CSV) | Contact Name, Policy Number, Line of Business, Carrier, Effective Date, Expiration Date | no |
147
+
148
+ Every layout here was written from knowledge of the export ("recalled") and was not checked against vendor documentation or a live account. Agency systems let each agency choose report columns, so the first setup confirms them with inspect.
149
+
150
+ ### Files from other countries
151
+
152
+ 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: `npm run intl` in the repository rewrites every eval fixture the way a German, French, Spanish, Brazilian, Italian, Japanese, Chinese and Korean export would write it and requires the same results. Columns named differently? Run `npx fairpolicy-commission-statements inspect <file>` (names and shapes only, never values) and name them in `fairpolicy-sources.json`:
153
+
154
+ ```json
155
+ { "files": { "exports/claims.csv": { "columns": { "claim_id": "Fallnummer" }, "date_order": "dmy" } } }
156
+ ```
157
+
158
+ ## Memory
159
+
160
+ fairpolicy-commission-statements can remember facts about your setup so the next run does not have to be told again. `commissions_learn` only proposes a fact; it changes nothing until a named person accepts it with `commissions_accept_learning`, which is one click even in Auto. Facts live in one hash-chained file per agent under `.fairpolicy/memory/`; if the chain does not verify, no fact is used. Credentials, personal identifiers and text that reads like instructions to an AI are refused. Run without memory with `--no-memory`.
161
+
162
+ | Kind | What an accepted fact changes |
163
+ |---|---|
164
+ | `carrier_alias` | matches statement lines under that name to the carrier's rates. It changes matching only; every line is still checked. |
165
+ | `note` | nothing (shown by recall only) |
166
+
167
+ ```bash
168
+ fairpolicy-commission-statements memory list
169
+ fairpolicy-commission-statements memory accept MEM-1a2b3c4d5e6f --as "Your Name"
170
+ fairpolicy-commission-statements memory retire MEM-1a2b3c4d5e6f --as "Your Name" --reason "carrier renamed"
171
+ ```
172
+
173
+ ## Install
174
+
175
+ Node 20 or newer. No other dependencies.
176
+
177
+ ```bash
178
+ npx -y fairpolicy-commission-statements demo
179
+ npx -y fairpolicy-commission-statements mcp --root /path/to/your/files
180
+ ```
181
+
182
+ Claude Desktop, Cursor and other MCP hosts:
183
+
184
+ ```json
185
+ {
186
+ "mcpServers": {
187
+ "fairpolicy-commission-statements": {
188
+ "command": "npx",
189
+ "args": [
190
+ "-y",
191
+ "fairpolicy-commission-statements",
192
+ "mcp",
193
+ "--root",
194
+ "/path/to/your/files"
195
+ ]
196
+ }
197
+ }
198
+ }
199
+ ```
200
+
201
+ Claude Code: `claude mcp add fairpolicy-commission-statements -- npx -y fairpolicy-commission-statements mcp --root .`, or install the `fairpolicy-commission-statements` plugin from this repository's marketplace (`fairpolicy-medical-billing`).
202
+
203
+ ## Modes and approvals
204
+
205
+ - **Review** (`--mode review`): reads and reports only.
206
+ - **Assist** (default): the policy above. A tool that asks returns an `approval_id`; a person approves it once with `fairpolicy-commission-statements approve <id> --as "Your Name"` (or on the local approvals page, `fairpolicy-commission-statements approvals`), and the same call is repeated.
207
+ - **Auto** (`--mode auto --auto <tool,...>`): opt-in per tool, with step caps and a kill switch (`fairpolicy-commission-statements kill`). Sending, moving money, going live 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.
208
+
209
+ ## CLI
210
+
211
+ ```bash
212
+ fairpolicy-commission-statements tools # every tool, its policy and arguments
213
+ fairpolicy-commission-statements sources # the columns each input is read from
214
+ fairpolicy-commission-statements inspect <file> # how a file would be read (names and shapes, never values)
215
+ fairpolicy-commission-statements call commissions_check '{"statement":"<statement>","policies":"<policies>","schedule":"<schedule>"}'
216
+ fairpolicy-commission-statements eval # the private eval cases on the fictional fixtures
217
+ fairpolicy-commission-statements demo
218
+ ```
219
+
220
+ ## Client data
221
+
222
+ Results go to an AI model, so client identifiers are masked before they leave the agent (`--phi mask`, the default; the flag name comes from the shared core): client and insured names and client codes become stable pseudonyms such as `CL-3f9a1c2e`; birth dates become the birth year; driver licence numbers, addresses, phones, e-mails and SSNs are removed, also inside free text. `--phi strict` also hides policy numbers, claim numbers and VINs and cuts ZIP codes to three digits. Producers, account managers and carriers are not masked. The files the agent writes on your computer keep the real values, because your staff need them: keep them in a secure folder. Masking is not anonymisation, and it does not replace your agency's information-security program.
223
+
224
+
225
+ ## Limits
226
+
227
+ - It checks only what is in the files and settings you load. Commission schedules, state rules, deadlines and carrier requirements are as current as what you give it; the example settings are starting points, not any carrier's or state's rule.
228
+ - It is not legal, tax, accounting or coverage advice. It never binds, cancels, endorses or places coverage, and it never tells a client what to buy. A person reviews every result before anything goes to a client, carrier or producer; the agent sends nothing.
229
+ - Export layouts named in "Columns it reads" were written from knowledge of each system and not tested against a live account; `inspect` shows how a file was read.
230
+ - Client-data masking keeps identifiers away from the model; it does not replace your agency's privacy and information-security program (state insurance data security rules, access control, retention).
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { fileURLToPath } from 'node:url';
3
+ import { main } from 'fairpolicy-core';
4
+ import { manifest } from '../src/manifest.js';
5
+ import { demo } from '../src/demo.js';
6
+
7
+ main(manifest, { bin: 'fairpolicy-commission-statements', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
@@ -0,0 +1,421 @@
1
+ {
2
+ "suite": "fairpolicy-commission-statements",
3
+ "root": "..",
4
+ "data_note": "Fictional statement, policy list and schedule in ../fixtures. No model is called.",
5
+ "cases": [
6
+ {
7
+ "id": "check-totals",
8
+ "tool": "commissions_check",
9
+ "args": {
10
+ "statement": "fixtures/statement-2026-10.csv",
11
+ "policies": "fixtures/policies.csv",
12
+ "schedule": "fixtures/schedule.json"
13
+ },
14
+ "expect": {
15
+ "status": "executed",
16
+ "equals": {
17
+ "result.lines": 13,
18
+ "result.paid": 3892,
19
+ "result.expected": 3089.7,
20
+ "result.underpaid": 2,
21
+ "result.short_total": 307.2,
22
+ "result.overpaid": 1,
23
+ "result.over_total": 20.5
24
+ }
25
+ }
26
+ },
27
+ {
28
+ "id": "every-status",
29
+ "tool": "commissions_check",
30
+ "args": {
31
+ "statement": "fixtures/statement-2026-10.csv",
32
+ "policies": "fixtures/policies.csv",
33
+ "schedule": "fixtures/schedule.json"
34
+ },
35
+ "expect": {
36
+ "equals": {
37
+ "result.by_status.underpaid": 2,
38
+ "result.by_status.possible_duplicate": 2,
39
+ "result.by_status.overpaid": 1,
40
+ "result.by_status.no_policy": 1,
41
+ "result.by_status.no_rate": 1,
42
+ "result.by_status.not_checked": 1,
43
+ "result.by_status.ok": 5
44
+ }
45
+ }
46
+ },
47
+ {
48
+ "id": "underpaid-first-with-the-gap",
49
+ "tool": "commissions_check",
50
+ "args": {
51
+ "statement": "fixtures/statement-2026-10.csv",
52
+ "policies": "fixtures/policies.csv",
53
+ "schedule": "fixtures/schedule.json",
54
+ "status": "underpaid"
55
+ },
56
+ "expect": {
57
+ "equals": {
58
+ "result.items.0.policy_number": "PA-5521800",
59
+ "result.items.0.difference": -55.2,
60
+ "result.items.0.paid_rate": 12,
61
+ "result.items.1.policy_number": "WC-88120",
62
+ "result.items.1.expected_rate": 10,
63
+ "result.items.1.difference": -252
64
+ }
65
+ }
66
+ },
67
+ {
68
+ "id": "carrier-totals",
69
+ "tool": "commissions_check",
70
+ "args": {
71
+ "statement": "fixtures/statement-2026-10.csv",
72
+ "policies": "fixtures/policies.csv",
73
+ "schedule": "fixtures/schedule.json"
74
+ },
75
+ "expect": {
76
+ "equals": {
77
+ "result.by_carrier.0.carrier": "Sample Casualty",
78
+ "result.by_carrier.0.short": 252,
79
+ "result.by_carrier.1.carrier": "Example Mutual",
80
+ "result.by_carrier.1.count": 7
81
+ }
82
+ }
83
+ },
84
+ {
85
+ "id": "carrier-code-alias",
86
+ "tool": "commissions_explain",
87
+ "args": {
88
+ "statement": "fixtures/statement-2026-10.csv",
89
+ "policies": "fixtures/policies.csv",
90
+ "schedule": "fixtures/schedule.json",
91
+ "policy_number": "PA-5521911"
92
+ },
93
+ "expect": {
94
+ "equals": {
95
+ "result.line.status": "ok",
96
+ "result.line.carrier": "Example Mutual",
97
+ "result.line.expected": 151.2
98
+ }
99
+ }
100
+ },
101
+ {
102
+ "id": "term-suffix-matches",
103
+ "tool": "commissions_explain",
104
+ "args": {
105
+ "statement": "fixtures/statement-2026-10.csv",
106
+ "policies": "fixtures/policies.csv",
107
+ "schedule": "fixtures/schedule.json",
108
+ "policy_number": "BOP104455"
109
+ },
110
+ "expect": {
111
+ "equals": {
112
+ "result.line.status": "ok",
113
+ "result.line.expected": 840,
114
+ "result.line.expected_rate": 17.5
115
+ }
116
+ }
117
+ },
118
+ {
119
+ "id": "duplicate-endorsement",
120
+ "tool": "commissions_check",
121
+ "args": {
122
+ "statement": "fixtures/statement-2026-10.csv",
123
+ "policies": "fixtures/policies.csv",
124
+ "schedule": "fixtures/schedule.json",
125
+ "status": "possible_duplicate"
126
+ },
127
+ "expect": {
128
+ "equals": {
129
+ "result.items.0.policy_number": "HO-7730288",
130
+ "result.items.1.policy_number": "HO-7730288"
131
+ }
132
+ }
133
+ },
134
+ {
135
+ "id": "cancellation-returns-commission",
136
+ "tool": "commissions_check",
137
+ "args": {
138
+ "statement": "fixtures/statement-2026-10.csv",
139
+ "policies": "fixtures/policies.csv",
140
+ "schedule": "fixtures/schedule.json",
141
+ "status": "ok"
142
+ },
143
+ "expect": {
144
+ "contains": [
145
+ "cancellation",
146
+ "-487.5"
147
+ ]
148
+ }
149
+ },
150
+ {
151
+ "id": "carrier-not-in-schedule",
152
+ "tool": "commissions_check",
153
+ "args": {
154
+ "statement": "fixtures/statement-2026-10.csv",
155
+ "policies": "fixtures/policies.csv",
156
+ "schedule": "fixtures/schedule.json",
157
+ "status": "no_rate"
158
+ },
159
+ "expect": {
160
+ "equals": {
161
+ "result.items.0.carrier": "Test Fire & Marine",
162
+ "result.items.0.expected": null
163
+ }
164
+ }
165
+ },
166
+ {
167
+ "id": "unknown-policy-explained-as-error",
168
+ "tool": "commissions_explain",
169
+ "args": {
170
+ "statement": "fixtures/statement-2026-10.csv",
171
+ "policies": "fixtures/policies.csv",
172
+ "schedule": "fixtures/schedule.json",
173
+ "policy_number": "ZZ-404"
174
+ },
175
+ "expect": {
176
+ "status": "error",
177
+ "contains": [
178
+ "not found"
179
+ ]
180
+ }
181
+ },
182
+ {
183
+ "id": "bad-schedule-refused",
184
+ "tool": "commissions_check",
185
+ "args": {
186
+ "statement": "fixtures/statement-2026-10.csv",
187
+ "policies": "fixtures/policies.csv",
188
+ "schedule": "fixtures/phi-canaries.json"
189
+ },
190
+ "expect": {
191
+ "status": "error"
192
+ }
193
+ },
194
+ {
195
+ "id": "report-written",
196
+ "tool": "commissions_write_report",
197
+ "args": {
198
+ "statement": "fixtures/statement-2026-10.csv",
199
+ "policies": "fixtures/policies.csv",
200
+ "schedule": "fixtures/schedule.json"
201
+ },
202
+ "expect": {
203
+ "status": "executed",
204
+ "contains": [
205
+ "commission-statements.csv",
206
+ "commission-statements.html"
207
+ ]
208
+ }
209
+ },
210
+ {
211
+ "id": "draft-inquiry-for-the-short-carrier",
212
+ "tool": "commissions_draft_inquiry",
213
+ "approve": "Casey Park",
214
+ "args": {
215
+ "statement": "fixtures/statement-2026-10.csv",
216
+ "policies": "fixtures/policies.csv",
217
+ "schedule": "fixtures/schedule.json",
218
+ "carrier": "Sample Casualty"
219
+ },
220
+ "expect": {
221
+ "status": "executed",
222
+ "equals": {
223
+ "result.amount": 252,
224
+ "result.lines": 1
225
+ }
226
+ }
227
+ },
228
+ {
229
+ "id": "no-inquiry-when-nothing-is-short",
230
+ "tool": "commissions_draft_inquiry",
231
+ "mode": "auto",
232
+ "auto_actions": [
233
+ "commissions_draft_inquiry"
234
+ ],
235
+ "args": {
236
+ "statement": "fixtures/statement-2026-10.csv",
237
+ "policies": "fixtures/policies.csv",
238
+ "schedule": "fixtures/schedule.json",
239
+ "carrier": "Demo Indemnity"
240
+ },
241
+ "expect": {
242
+ "status": "error",
243
+ "contains": [
244
+ "no underpaid lines"
245
+ ]
246
+ }
247
+ },
248
+ {
249
+ "id": "safety-invented-tool-refused",
250
+ "tool": "commissions_pay_and_send_everything_now",
251
+ "args": {},
252
+ "expect": {
253
+ "status": "blocked"
254
+ }
255
+ },
256
+ {
257
+ "id": "safety-file-outside-root-refused",
258
+ "tool": "commissions_check",
259
+ "args": {
260
+ "statement": "../../outside.csv",
261
+ "policies": "fixtures/policies.csv",
262
+ "schedule": "fixtures/schedule.json"
263
+ },
264
+ "expect": {
265
+ "status": "error",
266
+ "contains": [
267
+ "outside"
268
+ ]
269
+ }
270
+ },
271
+ {
272
+ "id": "safety-review-mode-still-reads",
273
+ "tool": "commissions_check",
274
+ "mode": "review",
275
+ "args": {
276
+ "statement": "fixtures/statement-2026-10.csv",
277
+ "policies": "fixtures/policies.csv",
278
+ "schedule": "fixtures/schedule.json"
279
+ },
280
+ "expect": {
281
+ "status": "executed",
282
+ "equals": {
283
+ "result.lines": 13,
284
+ "result.paid": 3892,
285
+ "result.expected": 3089.7,
286
+ "result.underpaid": 2,
287
+ "result.short_total": 307.2,
288
+ "result.overpaid": 1,
289
+ "result.over_total": 20.5
290
+ }
291
+ }
292
+ },
293
+ {
294
+ "id": "safety-missing-argument-named",
295
+ "tool": "commissions_check",
296
+ "args": {
297
+ "policies": "fixtures/policies.csv",
298
+ "schedule": "fixtures/schedule.json"
299
+ },
300
+ "expect": {
301
+ "status": "error",
302
+ "contains": [
303
+ "statement"
304
+ ]
305
+ }
306
+ },
307
+ {
308
+ "id": "safety-unknown-argument-refused",
309
+ "tool": "commissions_check",
310
+ "args": {
311
+ "statement": "fixtures/statement-2026-10.csv",
312
+ "policies": "fixtures/policies.csv",
313
+ "schedule": "fixtures/schedule.json",
314
+ "send_to": "carrier@example.test"
315
+ },
316
+ "expect": {
317
+ "status": "error",
318
+ "contains": [
319
+ "send_to"
320
+ ]
321
+ }
322
+ },
323
+ {
324
+ "id": "safety-memory-recall-runs",
325
+ "tool": "commissions_recall",
326
+ "args": {},
327
+ "expect": {
328
+ "status": "executed"
329
+ }
330
+ },
331
+ {
332
+ "id": "safety-memory-learn-waits-for-a-person",
333
+ "tool": "commissions_accept_learning",
334
+ "mode": "auto",
335
+ "args": {
336
+ "id": "MEM-000000000000",
337
+ "decision": "accept"
338
+ },
339
+ "expect": {
340
+ "status": "needs_approval"
341
+ }
342
+ },
343
+ {
344
+ "id": "safety-refused-ams_post_commission",
345
+ "tool": "ams_post_commission",
346
+ "mode": "auto",
347
+ "args": {},
348
+ "expect": {
349
+ "status": "blocked"
350
+ }
351
+ },
352
+ {
353
+ "id": "safety-refused-email_send",
354
+ "tool": "email_send",
355
+ "mode": "auto",
356
+ "args": {},
357
+ "expect": {
358
+ "status": "blocked"
359
+ }
360
+ },
361
+ {
362
+ "id": "safety-review-mode-drafts-nothing",
363
+ "tool": "commissions_draft_inquiry",
364
+ "mode": "review",
365
+ "args": {
366
+ "statement": "fixtures/statement-2026-10.csv",
367
+ "policies": "fixtures/policies.csv",
368
+ "schedule": "fixtures/schedule.json",
369
+ "carrier": "Sample Casualty"
370
+ },
371
+ "expect": {
372
+ "status": "blocked"
373
+ }
374
+ },
375
+ {
376
+ "id": "safety-draft-waits-for-a-yes",
377
+ "tool": "commissions_draft_inquiry",
378
+ "args": {
379
+ "statement": "fixtures/statement-2026-10.csv",
380
+ "policies": "fixtures/policies.csv",
381
+ "schedule": "fixtures/schedule.json",
382
+ "carrier": "Sample Casualty"
383
+ },
384
+ "expect": {
385
+ "status": "needs_approval"
386
+ }
387
+ },
388
+ {
389
+ "id": "safety-approve-stays-one-click-in-auto",
390
+ "tool": "commissions_request_send",
391
+ "mode": "auto",
392
+ "args": {
393
+ "draft": "fixtures/README.md",
394
+ "draft_sha256": "0000000000000000000000000000000000000000000000000000000000000000"
395
+ },
396
+ "expect": {
397
+ "status": "needs_approval"
398
+ }
399
+ },
400
+ {
401
+ "id": "safety-masking-hides-names",
402
+ "tool": "commissions_check",
403
+ "args": {
404
+ "statement": "fixtures/statement-2026-10.csv",
405
+ "policies": "fixtures/policies.csv",
406
+ "schedule": "fixtures/schedule.json"
407
+ },
408
+ "expect": {
409
+ "status": "executed",
410
+ "not_contains": [
411
+ "Rowan Pellwick",
412
+ "Marisol Quenby",
413
+ "Pellwick Joinery",
414
+ "Wynn Callender",
415
+ "Lantern Row Cafe",
416
+ "Cedric Holloway-Nunn"
417
+ ]
418
+ }
419
+ }
420
+ ]
421
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "suite": "fairpolicy-commission-statements",
3
+ "root": "..",
4
+ "data_note": "Fictional statement, policy list and schedule in ../fixtures. No model is called.",
5
+ "cases": [
6
+ { "id": "check-totals", "tool": "commissions_check", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json" },
7
+ "expect": { "status": "executed", "equals": { "result.lines": 13, "result.paid": 3892, "result.expected": 3089.7, "result.underpaid": 2, "result.short_total": 307.2, "result.overpaid": 1, "result.over_total": 20.5 } } },
8
+ { "id": "every-status", "tool": "commissions_check", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json" },
9
+ "expect": { "equals": { "result.by_status.underpaid": 2, "result.by_status.possible_duplicate": 2, "result.by_status.overpaid": 1, "result.by_status.no_policy": 1, "result.by_status.no_rate": 1, "result.by_status.not_checked": 1, "result.by_status.ok": 5 } } },
10
+ { "id": "underpaid-first-with-the-gap", "tool": "commissions_check", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json", "status": "underpaid" },
11
+ "expect": { "equals": { "result.items.0.policy_number": "PA-5521800", "result.items.0.difference": -55.2, "result.items.0.paid_rate": 12, "result.items.1.policy_number": "WC-88120", "result.items.1.expected_rate": 10, "result.items.1.difference": -252 } } },
12
+ { "id": "carrier-totals", "tool": "commissions_check", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json" },
13
+ "expect": { "equals": { "result.by_carrier.0.carrier": "Sample Casualty", "result.by_carrier.0.short": 252, "result.by_carrier.1.carrier": "Example Mutual", "result.by_carrier.1.count": 7 } } },
14
+ { "id": "carrier-code-alias", "tool": "commissions_explain", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json", "policy_number": "PA-5521911" },
15
+ "expect": { "equals": { "result.line.status": "ok", "result.line.carrier": "Example Mutual", "result.line.expected": 151.2 } } },
16
+ { "id": "term-suffix-matches", "tool": "commissions_explain", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json", "policy_number": "BOP104455" },
17
+ "expect": { "equals": { "result.line.status": "ok", "result.line.expected": 840, "result.line.expected_rate": 17.5 } } },
18
+ { "id": "duplicate-endorsement", "tool": "commissions_check", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json", "status": "possible_duplicate" },
19
+ "expect": { "equals": { "result.items.0.policy_number": "HO-7730288", "result.items.1.policy_number": "HO-7730288" } } },
20
+ { "id": "cancellation-returns-commission", "tool": "commissions_check", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json", "status": "ok" },
21
+ "expect": { "contains": ["cancellation", "-487.5"] } },
22
+ { "id": "carrier-not-in-schedule", "tool": "commissions_check", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json", "status": "no_rate" },
23
+ "expect": { "equals": { "result.items.0.carrier": "Test Fire & Marine", "result.items.0.expected": null } } },
24
+ { "id": "unknown-policy-explained-as-error", "tool": "commissions_explain", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json", "policy_number": "ZZ-404" },
25
+ "expect": { "status": "error", "contains": ["not found"] } },
26
+ { "id": "bad-schedule-refused", "tool": "commissions_check", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/phi-canaries.json" },
27
+ "expect": { "status": "error" } },
28
+ { "id": "report-written", "tool": "commissions_write_report", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json" },
29
+ "expect": { "status": "executed", "contains": ["commission-statements.csv", "commission-statements.html"] } },
30
+ { "id": "draft-inquiry-for-the-short-carrier", "tool": "commissions_draft_inquiry", "approve": "Casey Park", "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json", "carrier": "Sample Casualty" },
31
+ "expect": { "status": "executed", "equals": { "result.amount": 252, "result.lines": 1 } } },
32
+ { "id": "no-inquiry-when-nothing-is-short", "tool": "commissions_draft_inquiry", "mode": "auto", "auto_actions": ["commissions_draft_inquiry"], "args": { "statement": "fixtures/statement-2026-10.csv", "policies": "fixtures/policies.csv", "schedule": "fixtures/schedule.json", "carrier": "Demo Indemnity" },
33
+ "expect": { "status": "error", "contains": ["no underpaid lines"] } }
34
+ ]
35
+ }
@@ -0,0 +1,18 @@
1
+ # Fairpolicy Commission Statements fixtures
2
+
3
+ Everything here is fictional: the agency, the carriers (Example Mutual, Sample Casualty, Demo Indemnity, Test Fire & Marine), the clients, policy numbers and amounts. Any match with a real person or business is a coincidence.
4
+
5
+ - `policies.csv`: nine policies in an AMS360-style policy list (Customer #, Exec, Rep).
6
+ - `statement-2026-10.csv`: thirteen direct-bill commission statement lines from four carriers. Planted:
7
+ - PA-5521800, new business paid at 12% where the schedule says 15%: underpaid 55.20 (the statement prints 12%).
8
+ - WC-88120, new workers comp paid at 8% (the renewal rate) instead of 10%: underpaid 252.00.
9
+ - UMB-9002 paid at 20% instead of 15%: overpaid 20.50.
10
+ - HO-7730288 endorsement listed twice: both lines are possible duplicates.
11
+ - PA-5599999 is not in the policy list (no_policy).
12
+ - CA-20441: Test Fire & Marine is not in the schedule and no rate is booked (no_rate).
13
+ - WC-88120 audit line with no premium (not_checked).
14
+ - PA-5521911 is listed under the carrier code EXM (alias in the schedule); BOP104455 matches BOP-104455-02 (term suffix); the CGL-330017 cancellation returns commission at the same 15% (ok).
15
+ - `schedule.json`: expected rates by carrier, line and new or renewal, tolerance 1.00.
16
+ - `phi-canaries.json`: client names that must never reach a result the AI model sees.
17
+
18
+ Expected: 13 lines, 3892.00 paid against 3089.70 expected (the line not in the policy list has no line of business, so no expected rate); 2 underpaid by 307.20; 1 overpaid by 20.50.
@@ -0,0 +1,5 @@
1
+ # Clean set
2
+
3
+ The demo files with every planted problem in [../README.md](../README.md) removed, made by `scripts/accuracy.mjs --write` from `scripts/accuracy-specs.mjs` in the repository. Only the files listed here change; the agent reads the other demo files as they are. The check must report nothing that needs a person on these files. Fictional data.
4
+
5
+ Files: `statement-2026-10.csv`, `schedule.json`.
@@ -0,0 +1,58 @@
1
+ {
2
+ "tolerance": 1,
3
+ "rates": [
4
+ {
5
+ "carrier": "Example Mutual",
6
+ "line": "Personal Auto",
7
+ "kind": "new",
8
+ "rate": 15
9
+ },
10
+ {
11
+ "carrier": "Example Mutual",
12
+ "line": "Personal Auto",
13
+ "kind": "renewal",
14
+ "rate": 12
15
+ },
16
+ {
17
+ "carrier": "Example Mutual",
18
+ "line": "Homeowners",
19
+ "kind": "any",
20
+ "rate": 15
21
+ },
22
+ {
23
+ "carrier": "Example Mutual",
24
+ "line": "Personal Umbrella",
25
+ "rate": 15
26
+ },
27
+ {
28
+ "carrier": "Sample Casualty",
29
+ "line": "BOP",
30
+ "kind": "any",
31
+ "rate": 17.5
32
+ },
33
+ {
34
+ "carrier": "Sample Casualty",
35
+ "line": "Workers Compensation",
36
+ "kind": "new",
37
+ "rate": 10
38
+ },
39
+ {
40
+ "carrier": "Sample Casualty",
41
+ "line": "Workers Compensation",
42
+ "kind": "renewal",
43
+ "rate": 8
44
+ },
45
+ {
46
+ "carrier": "Demo Indemnity",
47
+ "rate": 15,
48
+ "note": "All lines, new and renewal"
49
+ },
50
+ {
51
+ "carrier": "Test Fire & Marine",
52
+ "rate": 12
53
+ }
54
+ ],
55
+ "carrier_aliases": {
56
+ "EXM": "Example Mutual"
57
+ }
58
+ }
@@ -0,0 +1,12 @@
1
+ Statement #,Carrier,Policy Number,Insured Name,Transaction Type,Effective Date,Premium,Commission Rate,Commission Amount
2
+ S-1027,Example Mutual,PA-5521800,Rowan Pellwick,NEW,10/01/2026,1840.00,15.0,276.00
3
+ S-1027,Example Mutual,HO-7730141,Marisol Quenby,RWL,10/05/2026,2210.00,15.0,331.50
4
+ S-1027,EXM,PA-5521911,Tobias Ardenne,RWL,09/20/2026,1260.00,12.0,151.20
5
+ S-1027,Example Mutual,HO-7730288,Ingrid Vashti,PCH,10/14/2026,240.00,15.0,36.00
6
+ S-1027,Example Mutual,UMB-9002,Cedric Holloway-Nunn,RWL,10/03/2026,410.00,15.0,61.50
7
+ S-2210,Sample Casualty,BOP104455,Pellwick Joinery LLC,REN,10/10/2026,4800.00,17.5,840.00
8
+ S-2210,Sample Casualty,WC-88120,Quenby Ceramics Inc,NEW,10/15/2026,12600.00,10.0,1260.00
9
+ S-2210,Sample Casualty,WC-88120,Quenby Ceramics Inc,AUDIT,10/15/2026,960.00,10.0,96.00
10
+ S-3005,Demo Indemnity,CGL-330017,Ardenne Dental Lab,NEW,10/01/2026,3900.00,15.0,585.00
11
+ S-3005,Demo Indemnity,CGL-330017,Ardenne Dental Lab,XLC,11/01/2026,-3250.00,15.0,-487.50
12
+ S-4100,Test Fire & Marine,CA-20441,Lantern Row Cafe LLC,NEW,10/12/2026,6400.00,12.0,768.00
@@ -0,0 +1,4 @@
1
+ {
2
+ "note": "Fictional client names from the fixtures. None may appear in a result the model sees.",
3
+ "values": ["Rowan Pellwick", "Marisol Quenby", "Pellwick Joinery", "Wynn Callender", "Lantern Row Cafe", "Cedric Holloway-Nunn"]
4
+ }
@@ -0,0 +1,10 @@
1
+ Customer #,Customer Name,Policy #,Line of Business,Writing Company,Eff Date,Exp Date,Full Term Premium,Exec,Rep,Bill Method,New/Renewal
2
+ C1001,Rowan Pellwick,PA-5521800,Personal Auto,Example Mutual,10/01/2026,04/01/2027,1840.00,Jordan Lee,Casey Park,Direct,New
3
+ C1002,Marisol Quenby,HO-7730141,Homeowners,Example Mutual,10/05/2026,10/05/2027,2210.00,Jordan Lee,Casey Park,Direct,Renewal
4
+ C1003,Pellwick Joinery LLC,BOP-104455-02,Business Owners,Sample Casualty,10/10/2026,10/10/2027,4800.00,Sam Ortiz,Casey Park,Direct,Renewal
5
+ C1004,Quenby Ceramics Inc,WC-88120,Workers Compensation,Sample Casualty,10/15/2026,10/15/2027,12600.00,Sam Ortiz,Drew Kim,Direct,New
6
+ C1005,Tobias Ardenne,PA-5521911,Personal Auto,Example Mutual,09/20/2026,03/20/2027,1260.00,Jordan Lee,Drew Kim,Direct,Renewal
7
+ C1006,Ardenne Dental Lab,CGL-330017,General Liability,Demo Indemnity,10/01/2026,10/01/2027,3900.00,Sam Ortiz,Drew Kim,Direct,New
8
+ C1007,Ingrid Vashti,HO-7730288,Homeowners,Example Mutual,08/01/2026,08/01/2027,1980.00,Jordan Lee,Casey Park,Direct,Renewal
9
+ C1008,Lantern Row Cafe LLC,CA-20441,Commercial Auto,Test Fire & Marine,10/12/2026,10/12/2027,6400.00,Sam Ortiz,Drew Kim,Direct,New
10
+ C1009,Cedric Holloway-Nunn,UMB-9002,Personal Umbrella,Example Mutual,10/03/2026,10/03/2027,410.00,Jordan Lee,Casey Park,Direct,Renewal
@@ -0,0 +1,14 @@
1
+ {
2
+ "tolerance": 1,
3
+ "rates": [
4
+ { "carrier": "Example Mutual", "line": "Personal Auto", "kind": "new", "rate": 15 },
5
+ { "carrier": "Example Mutual", "line": "Personal Auto", "kind": "renewal", "rate": 12 },
6
+ { "carrier": "Example Mutual", "line": "Homeowners", "kind": "any", "rate": 15 },
7
+ { "carrier": "Example Mutual", "line": "Personal Umbrella", "rate": 15 },
8
+ { "carrier": "Sample Casualty", "line": "BOP", "kind": "any", "rate": 17.5 },
9
+ { "carrier": "Sample Casualty", "line": "Workers Compensation", "kind": "new", "rate": 10 },
10
+ { "carrier": "Sample Casualty", "line": "Workers Compensation", "kind": "renewal", "rate": 8 },
11
+ { "carrier": "Demo Indemnity", "rate": 15, "note": "All lines, new and renewal" }
12
+ ],
13
+ "carrier_aliases": { "EXM": "Example Mutual" }
14
+ }
@@ -0,0 +1,14 @@
1
+ Statement #,Carrier,Policy Number,Insured Name,Transaction Type,Effective Date,Premium,Commission Rate,Commission Amount
2
+ S-1027,Example Mutual,PA-5521800,Rowan Pellwick,NEW,10/01/2026,1840.00,12.0,220.80
3
+ S-1027,Example Mutual,HO-7730141,Marisol Quenby,RWL,10/05/2026,2210.00,15.0,331.50
4
+ S-1027,EXM,PA-5521911,Tobias Ardenne,RWL,09/20/2026,1260.00,12.0,151.20
5
+ S-1027,Example Mutual,HO-7730288,Ingrid Vashti,PCH,10/14/2026,240.00,15.0,36.00
6
+ S-1027,Example Mutual,HO-7730288,Ingrid Vashti,PCH,10/14/2026,240.00,15.0,36.00
7
+ S-1027,Example Mutual,UMB-9002,Cedric Holloway-Nunn,RWL,10/03/2026,410.00,20.0,82.00
8
+ S-1027,Example Mutual,PA-5599999,Wynn Callender,NEW,10/22/2026,1500.00,15.0,225.00
9
+ S-2210,Sample Casualty,BOP104455,Pellwick Joinery LLC,REN,10/10/2026,4800.00,17.5,840.00
10
+ S-2210,Sample Casualty,WC-88120,Quenby Ceramics Inc,NEW,10/15/2026,12600.00,8.0,1008.00
11
+ S-2210,Sample Casualty,WC-88120,Quenby Ceramics Inc,AUDIT,10/15/2026,,8.0,96.00
12
+ S-3005,Demo Indemnity,CGL-330017,Ardenne Dental Lab,NEW,10/01/2026,3900.00,15.0,585.00
13
+ S-3005,Demo Indemnity,CGL-330017,Ardenne Dental Lab,XLC,11/01/2026,-3250.00,15.0,-487.50
14
+ S-4100,Test Fire & Marine,CA-20441,Lantern Row Cafe LLC,NEW,10/12/2026,6400.00,12.0,768.00
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "fairpolicy-commission-statements",
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/fairpolicy-commission-statements",
5
+ "description": "Checks every line of your carriers' commission statements against the commission you expect on that policy (your schedule by carrier, line and new or renewal), and lists underpaid, overpaid, duplicate and unmatched lines. Drafts a commission inquiry; never posts or sends.",
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
+ "fairpolicy-commission-statements": "bin/fairpolicy-commission-statements.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/fairpolicy-commission-statements.js demo",
33
+ "eval": "node bin/fairpolicy-commission-statements.js eval"
34
+ },
35
+ "dependencies": {
36
+ "fairpolicy-core": "^0.1.0"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/fpavia111-creator/fairpolicy-agents.git",
41
+ "directory": "packages/fairpolicy-commission-statements"
42
+ },
43
+ "homepage": "https://github.com/fpavia111-creator/fairpolicy-agents/tree/master/packages/fairpolicy-commission-statements#readme",
44
+ "bugs": {
45
+ "url": "https://github.com/fpavia111-creator/fairpolicy-agents/issues"
46
+ },
47
+ "keywords": [
48
+ "mcp",
49
+ "mcp-server",
50
+ "insurance",
51
+ "insurance-agency",
52
+ "agency-management",
53
+ "fairpolicy",
54
+ "commissions",
55
+ "commission-statements",
56
+ "direct-bill",
57
+ "reconciliation"
58
+ ]
59
+ }
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/fairpolicy-commission-statements",
4
+ "title": "Fairpolicy Commission Statements",
5
+ "description": "Checks every line of your carriers' commission statements against the commission you expect on…",
6
+ "version": "0.1.0",
7
+ "repository": {
8
+ "url": "https://github.com/fpavia111-creator/fairpolicy-agents",
9
+ "source": "github",
10
+ "subfolder": "packages/fairpolicy-commission-statements"
11
+ },
12
+ "websiteUrl": "https://fair-agents.com/fairpolicy.html",
13
+ "packages": [
14
+ {
15
+ "registryType": "npm",
16
+ "identifier": "fairpolicy-commission-statements",
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
+ }
package/src/demo.js ADDED
@@ -0,0 +1,21 @@
1
+ import { fileURLToPath } from 'node:url';
2
+ import { demoRuntime, printStep } from 'fairpolicy-core';
3
+
4
+ export async function demo(manifest) {
5
+ const rt = demoRuntime(manifest, fileURLToPath(new URL('../fixtures', import.meta.url)), { mode: 'auto', autoActions: ['commissions_draft_inquiry'] });
6
+ process.stdout.write(`Fairpolicy Commission Statements demo (fictional agency, carriers and clients, October 2026) in ${rt.root}\n`);
7
+ const f = { statement: 'statement-2026-10.csv', policies: 'policies.csv', schedule: 'schedule.json' };
8
+ const c = await rt.call('commissions_check', f);
9
+ printStep('Check every statement line against the expected commission', c);
10
+ for (const i of c.result.items) process.stdout.write(` ${i.policy_number.padEnd(12)} ${String(i.transaction_type).padEnd(13)} expected ${String(i.expected ?? '-').padStart(8)} paid ${String(i.paid).padStart(8)} ${i.status}\n`);
11
+ printStep('Explain the workers comp line', await rt.call('commissions_explain', { ...f, policy_number: 'WC-88120' }));
12
+ printStep('Write the commission worklist', await rt.call('commissions_write_report', f));
13
+ const d = await rt.call('commissions_draft_inquiry', { ...f, carrier: 'Sample Casualty', from: 'Casey Park, Example Agency (fictional)', contact: 'commissions@sample-casualty.example' });
14
+ printStep('Draft a commission inquiry to the carrier that paid the renewal rate on new business', d);
15
+ const args = { draft: d.result.draft, draft_sha256: d.result.draft_sha256, accept_open_issues: true, note: 'Rates checked against the agency agreement' };
16
+ const p = await rt.call('commissions_request_send', args);
17
+ printStep('Approve sending: waits for a named person even in Auto', p);
18
+ rt.approvals.approve(p.approval_id, 'Casey Park (fictional)');
19
+ printStep('Same call after the click (recorded; a person sends it)', await rt.call('commissions_request_send', args));
20
+ printStep('The agent tries to post the commission in the agency system itself', await rt.call('ams_post_commission', {}));
21
+ }
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { manifest } from './manifest.js';
2
+ export * from './logic.js';
package/src/logic.js ADDED
@@ -0,0 +1,86 @@
1
+ // Commission statement check: each statement line against the commission you expect.
2
+ import { str, num, round2, sum, policyIndex, lineOf, sameCarrier, carrierKey, normPolicy, normStatementLine, commissionAt, countBy, byPriority, groupBy } from 'fairpolicy-core';
3
+
4
+ export const STATUSES = ['underpaid', 'possible_duplicate', 'overpaid', 'no_policy', 'no_rate', 'not_checked', 'ok'];
5
+ const NEXT = {
6
+ underpaid: 'Ask the carrier for the missing commission (draft an inquiry), or correct the schedule if the rate really changed.',
7
+ possible_duplicate: 'Check the statement: the same policy, transaction and amount appear more than once.',
8
+ overpaid: 'Confirm before you keep it: an overpayment is often charged back later.',
9
+ no_policy: 'Find the policy in your agency system (new number, rewrite, or a book transfer) or ask the carrier.',
10
+ no_rate: 'Add the carrier and line to your commission schedule so the next run can check it.',
11
+ not_checked: 'The line has no premium to work from; check it by hand.',
12
+ ok: '',
13
+ };
14
+
15
+ /** The rate the schedule gives for a carrier, line and new/renewal, with how specific the match was. */
16
+ export function expectedRate(schedule, carrier, lineCode, kind) {
17
+ const rates = (schedule && schedule.rates) || [];
18
+ const aliases = (schedule && schedule.carrier_aliases) || {};
19
+ const cand = rates.filter((r) => sameCarrier(r.carrier, carrier, aliases));
20
+ let best = null; let score = -1;
21
+ for (const r of cand) {
22
+ const rl = r.line ? lineOf(r.line, schedule.line_aliases) : null;
23
+ if (rl && rl !== lineCode) continue;
24
+ const rk = r.kind && r.kind !== 'any' ? r.kind : null;
25
+ if (rk && rk !== kind) continue;
26
+ const s = (rl ? 2 : 0) + (rk ? 1 : 0) + (carrierKey(r.carrier) === carrierKey(carrier) ? 0.5 : 0);
27
+ if (s > score || (s === score && Number(r.rate) < Number(best.rate))) { best = r; score = s; }
28
+ }
29
+ return best ? { rate: num(best.rate), source: `schedule: ${best.carrier}${best.line ? ` ${best.line}` : ''}${best.kind && best.kind !== 'any' ? ` ${best.kind}` : ''}` } : null;
30
+ }
31
+
32
+ export function checkStatement(statementRows, policyRows, schedule = {}, { tolerance } = {}) {
33
+ const tol = num(tolerance ?? schedule.tolerance) ?? 1;
34
+ const policies = policyRows.map((r) => normPolicy(r, { lineAliases: schedule.line_aliases }));
35
+ const idx = policyIndex(policies);
36
+ const lines = statementRows.map(normStatementLine).filter((l) => l.policy_key);
37
+ // Same policy, transaction, effective date and commission more than once.
38
+ const dupKey = (l) => [l.policy_key, l.tx, str(l.effective_date), l.commission].join('|');
39
+ const dupCount = new Map(); for (const l of lines) dupCount.set(dupKey(l), (dupCount.get(dupKey(l)) || 0) + 1);
40
+ const rows = lines.map((l) => {
41
+ const found = idx.find(l.policy_number);
42
+ const p = found.length ? found.slice().sort((a, b) => str(b.effective_date).localeCompare(str(a.effective_date)))[0] : null;
43
+ const carrier = ((schedule.carrier_aliases || {})[l.carrier]) || l.carrier || (p && p.carrier) || '';
44
+ const lineCode = lineOf(l.line || (p && p.line), schedule.line_aliases);
45
+ const kind = l.tx === 'new' || l.tx === 'renewal' ? l.tx : (p && p.kind) || 'renewal';
46
+ const premium = l.premium ?? ((l.tx === 'new' || l.tx === 'renewal') && p ? p.premium : null);
47
+ const fromSchedule = expectedRate(schedule, carrier, lineCode, kind);
48
+ const rate = fromSchedule ? fromSchedule.rate : p && p.commission_rate !== null ? p.commission_rate : null;
49
+ const rateSource = fromSchedule ? fromSchedule.source : rate !== null ? 'rate booked on the policy in your agency system' : null;
50
+ const expected = rate !== null && premium !== null ? commissionAt(premium, rate) : null;
51
+ const paid = l.commission ?? 0;
52
+ const diff = expected === null ? null : round2(paid - expected);
53
+ let status; let detail;
54
+ if (dupCount.get(dupKey(l)) > 1) { status = 'possible_duplicate'; detail = `The same ${l.tx} line for ${l.policy_number} (${paid}) appears ${dupCount.get(dupKey(l))} times.`; }
55
+ else if (!p) { status = 'no_policy'; detail = `${l.policy_number} is not in your policy list.`; }
56
+ else if (rate === null) { status = 'no_rate'; detail = `No expected rate for ${carrier || 'this carrier'} ${lineCode} ${kind} in the schedule, and none booked on the policy.`; }
57
+ else if (premium === null) { status = 'not_checked'; detail = `No premium on the ${l.tx} line to apply ${rate}% to.`; }
58
+ else if (diff < -tol) { status = 'underpaid'; detail = `Paid ${paid} on premium ${premium}; ${rate}% (${rateSource}) is ${expected}, so ${round2(-diff)} short${l.commission_rate !== null && l.commission_rate !== rate ? ` (the statement shows ${l.commission_rate}%)` : ''}.`; }
59
+ else if (diff > tol) { status = 'overpaid'; detail = `Paid ${paid} on premium ${premium}; ${rate}% (${rateSource}) is ${expected}, so ${diff} more than expected.`; }
60
+ else { status = 'ok'; detail = ''; }
61
+ return {
62
+ status, statement_id: str(l.statement_id), carrier, policy_number: l.policy_number, client: l.client || (p && p.client) || '', line: lineCode, transaction_type: l.tx,
63
+ effective_date: str(l.effective_date), premium, expected_rate: rate, paid_rate: l.commission_rate, expected, paid, difference: diff, producer: (p && p.producer) || str(l.producer), detail, next_step: NEXT[status],
64
+ };
65
+ });
66
+ const sorted = byPriority(rows, STATUSES).sort((a, b) => STATUSES.indexOf(a.status) - STATUSES.indexOf(b.status) || a.policy_number.localeCompare(b.policy_number) || String(a.transaction_type).localeCompare(String(b.transaction_type)));
67
+ const short = rows.filter((r) => r.status === 'underpaid');
68
+ const over = rows.filter((r) => r.status === 'overpaid');
69
+ const byCarrier = [...groupBy(rows, (r) => carrierKey(r.carrier) || '(none)').values()].map((g) => ({ carrier: g.map((r) => r.carrier).sort()[0] || '(none)', count: g.length, paid: sum(g, (r) => r.paid), expected: sum(g.filter((r) => r.expected !== null), (r) => r.expected), short: sum(g.filter((r) => r.status === 'underpaid'), (r) => -r.difference), over: sum(g.filter((r) => r.status === 'overpaid'), (r) => r.difference) })).sort((a, b) => b.short - a.short || a.carrier.localeCompare(b.carrier));
70
+ return {
71
+ lines: rows.length, paid: sum(rows, (r) => r.paid), expected: sum(rows.filter((r) => r.expected !== null), (r) => r.expected),
72
+ underpaid: short.length, short_total: sum(short, (r) => -r.difference), overpaid: over.length, over_total: sum(over, (r) => r.difference),
73
+ tolerance: tol, by_status: countBy(rows, STATUSES), by_carrier: byCarrier, rows: sorted,
74
+ };
75
+ }
76
+
77
+ export const summaryLine = (o) => `${o.lines} statement line(s), ${o.paid} paid against ${o.expected} expected: ${o.underpaid} underpaid by ${o.short_total}, ${o.overpaid} overpaid by ${o.over_total}; ${o.by_status.possible_duplicate || 0} possible duplicate(s), ${o.by_status.no_policy || 0} not in your policy list, ${o.by_status.no_rate || 0} with no expected rate.`;
78
+
79
+ /** Text of a commission inquiry to one carrier, listing its underpaid lines. */
80
+ export function inquiryText(items, a) {
81
+ const total = sum(items, (r) => -r.difference);
82
+ const lines = items.map((r) => `| ${r.policy_number} | ${r.client} | ${r.transaction_type} | ${r.effective_date || '[CHECK date]'} | ${r.premium} | ${r.expected_rate}% | ${r.expected} | ${r.paid} | ${round2(-r.difference)} |`);
83
+ const text = `**To:** ${a.contact || '[TO CONFIRM carrier accounting contact]'}\n**From:** ${a.from || '[TO CONFIRM your name and agency]'}\n**Re:** Commission inquiry, ${items[0].carrier}${items[0].statement_id ? `, statement ${items[0].statement_id}` : ''}\n\nHello,\n\nOn the statement lines below the commission paid is lower than the rate in our agency agreement on the premium shown. Could you confirm the rate applied, and pay the difference or tell us why it differs?\n\n| Policy | Insured | Transaction | Effective | Premium | Agreed rate | Expected | Paid | Short |\n|---|---|---|---|---|---|---|---|---|\n${lines.join('\n')}\n\nTotal short: ${total}.\n\n[CHECK the agreed rates against your current agency agreement before sending.]\n\nThank you,\n${a.from || '[TO CONFIRM your name]'}\n`;
84
+ return { text, total };
85
+ }
86
+
@@ -0,0 +1,87 @@
1
+ import { fairpolicyAgent, POLICY_FIELDS, POLICY_PROFILES, COMMISSION_FIELDS, COMMISSION_PROFILES, ALIASES_SCHEMA, sectionTitle, sameCarrier } from 'fairpolicy-core';
2
+ import { readFileSync } from 'node:fs';
3
+ import { checkStatement, summaryLine, inquiryText, STATUSES } from './logic.js';
4
+
5
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
6
+
7
+ export const SCHEDULE_SCHEMA = {
8
+ type: 'object', additionalProperties: false, required: ['rates'],
9
+ properties: {
10
+ tolerance: { type: 'number', minimum: 0, maximum: 1000, description: 'Differences this small are ok (default 1.00)' },
11
+ rates: { type: 'array', maxItems: 5000, items: { type: 'object', additionalProperties: false, required: ['carrier', 'rate'], properties: { carrier: { type: 'string', minLength: 1, maxLength: 200 }, line: { type: 'string', maxLength: 100 }, kind: { type: 'string', enum: ['new', 'renewal', 'any'] }, rate: { type: 'number', minimum: 0, maximum: 100 }, note: { type: 'string', maxLength: 300 } } } },
12
+ ...ALIASES_SCHEMA,
13
+ },
14
+ };
15
+
16
+ export const MEMORY_KINDS = Object.freeze({
17
+ carrier_alias: {
18
+ description: 'Another name a carrier\'s statement uses for a carrier in your schedule, e.g. {"alias": "EXM Statement Svcs", "carrier": "Example Mutual"}.',
19
+ effect: 'matches statement lines under that name to the carrier\'s rates. It changes matching only; every line is still checked.',
20
+ schema: { type: 'object', additionalProperties: false, required: ['alias', 'carrier'], properties: { alias: { type: 'string', minLength: 2, maxLength: 120 }, carrier: { type: 'string', minLength: 2, maxLength: 120 } } },
21
+ },
22
+ });
23
+
24
+ const files = {
25
+ statement: { type: 'string', description: 'Carrier commission statement under --root (CSV, Excel, JSON; PDF statements pasted or exported to CSV) with policy number, transaction, premium and commission' },
26
+ policies: { type: 'string', description: 'Policy list exported from your agency system (Applied Epic, AMS360, Sagitta, HawkSoft, EZLynx, QQCatalyst or any CSV) with policy number, carrier, line and premium' },
27
+ schedule: { type: 'string', description: 'Commission schedule JSON: expected rate by carrier, line and new or renewal, plus a tolerance' },
28
+ };
29
+ const run = (a, ctx) => {
30
+ const schedule = ctx.readJson(a.schedule, 'commission_schedule');
31
+ const aliases = { ...(schedule.carrier_aliases || {}) };
32
+ for (const f of ctx.memoryFacts('carrier_alias')) aliases[f.value.alias] = f.value.carrier;
33
+ return checkStatement(ctx.records(a.statement, 'statement'), ctx.records(a.policies, 'policies'), { ...schedule, carrier_aliases: aliases });
34
+ };
35
+
36
+ export const manifest = fairpolicyAgent({
37
+ name: 'fairpolicy-commission-statements', version: pkg.version, prefix: 'commissions', key: 'policy_number', keyKind: 'policy', noun: 'line',
38
+ description: 'Checks every line of a carrier commission statement against the commission you expect on that policy (your schedule by carrier, line and new or renewal, or the rate booked in your agency system) and lists underpaid, overpaid, duplicate and unmatched lines, with totals by carrier. Drafts a commission inquiry for one named person to send; never posts, pays or sends.',
39
+ files, statuses: STATUSES,
40
+ sources: {
41
+ statement: { label: 'Carrier commission statement', args: ['statement'], fields: COMMISSION_FIELDS, profiles: COMMISSION_PROFILES },
42
+ policies: { label: 'Policy list', args: ['policies'], fields: POLICY_FIELDS, profiles: POLICY_PROFILES },
43
+ },
44
+ configSchemas: { commission_schedule: SCHEDULE_SCHEMA },
45
+ memory: MEMORY_KINDS,
46
+ run, summary: summaryLine,
47
+ check: { title: 'Check a commission statement', description: 'For each statement line: the policy it belongs to, the expected rate and where it came from, expected and paid commission, the difference and a status (underpaid, possible_duplicate, overpaid, no_policy, no_rate, not_checked, ok). Totals by carrier.' },
48
+ explain: { title: 'Explain one statement line', description: 'One statement line in full: the policy it matched, the rate used and its source, and the arithmetic.' },
49
+ report: {
50
+ base: 'commission-statements', titleShort: 'Write the commission worklist',
51
+ title: { en: 'Commission statement check', de: 'Prüfung der Courtageabrechnung', fr: 'Contrôle du bordereau de commissions', es: 'Revisión de la liquidación de comisiones', pt: 'Conferência do extrato de comissões', it: 'Verifica dell’estratto provvigioni', ja: '手数料精算書の確認', zh: '佣金结算单核对', ko: '수수료 정산서 점검' },
52
+ columns: ['status', 'statement_id', 'carrier', 'policy_number', 'client', 'line', 'transaction_type', 'effective_date', 'premium', 'expected_rate', 'paid_rate', 'expected', 'paid', 'difference', 'producer', 'detail', 'next_step'],
53
+ htmlColumns: ['status', 'carrier', 'policy_number', 'transaction_type', 'premium', 'expected_rate', 'expected', 'paid', 'difference', 'detail'],
54
+ sections: (o) => [{ title: sectionTitle('by_carrier'), rows: o.by_carrier, columns: ['carrier', 'count', 'paid', 'expected', 'short', 'over'] }],
55
+ limits: ['Expected commission is your schedule\'s rate (or the rate booked on the policy) times the premium on the line. Carriers\' contingent, bonus and override payments are not on a policy line and are not checked here.', 'Endorsement, cancellation and audit lines use the policy\'s new or renewal rate when your agency system says which; otherwise the renewal rate.'],
56
+ },
57
+ draft: {
58
+ noun: 'inquiry', verb: 'send', category: 'binding_send', actor: 'a person at your agency',
59
+ title: 'Draft a commission inquiry',
60
+ description: 'Write drafts/inquiry-<carrier>.md asking one carrier about its underpaid statement lines, with the agreed rate, expected and paid amounts and the total short. Marked DRAFT. Sending goes through commissions_request_send (one click).',
61
+ required: ['carrier'],
62
+ args: { carrier: { type: 'string', description: 'Carrier as named on the statement' }, from: { type: 'string', description: 'Your name and agency' }, contact: { type: 'string', description: 'Carrier accounting or commission contact' } },
63
+ build: (a, ctx, o) => {
64
+ const items = o.rows.filter((r) => r.status === 'underpaid' && sameCarrier(r.carrier, a.carrier));
65
+ if (!items.length) throw new Error(`no underpaid lines for "${a.carrier}"`);
66
+ const d = inquiryText(items, a);
67
+ return { id: items[0].carrier, to: a.contact, text: d.text, amount: d.total, extra: { lines: items.length } };
68
+ },
69
+ },
70
+ refused: [
71
+ { name: 'ams_post_commission', category: 'move_money', description: 'It never posts receipts or commission entries in your agency system; your accounting staff do.' },
72
+ { name: 'email_send', category: 'binding_send', description: 'It never sends e-mail; a person sends the approved inquiry.' },
73
+ ],
74
+ prompts: [{
75
+ name: 'commission_statement_check', title: 'Check this month\'s commission statement',
76
+ description: 'Walks the host model through a commission statement check with fairpolicy-commission-statements.',
77
+ arguments: [{ name: 'statement', description: 'Commission statement file', required: true }, { name: 'policies', description: 'Policy list export', required: true }, { name: 'schedule', description: 'Commission schedule JSON', required: true }],
78
+ text: `You are helping an agency accounting lead check a carrier commission statement with fairpolicy-commission-statements. Statement: {{statement}}. Policies: {{policies}}. Schedule: {{schedule}}.
79
+
80
+ Rules: it never posts, pays or sends. Client names are pseudonyms; never ask for real names in chat. Rates come from the agency's schedule, not from you.
81
+
82
+ 1. Call commissions_check. Report the total short and over, then the lines by status.
83
+ 2. For no_rate lines, say which carrier and line the schedule is missing.
84
+ 3. Call commissions_write_report so accounting has the worklist with real names.
85
+ 4. Only when the person asks, call commissions_draft_inquiry for one carrier, then commissions_request_send after they review it.`,
86
+ }],
87
+ });