fairbrief-commingling 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 +5 -0
- package/LICENSE +21 -0
- package/README.md +187 -2
- package/bin/fairbrief-commingling.js +7 -0
- package/evals/cases.json +351 -0
- package/evals/own.json +20 -0
- package/fixtures/README.md +9 -0
- package/fixtures/accuracy.json +46 -0
- package/fixtures/client-canaries.json +4 -0
- package/fixtures/commingling-settings-typo.json +1 -0
- package/fixtures/commingling-settings.json +4 -0
- package/fixtures/intl/README.md +8 -0
- package/fixtures/intl/de/operating-2026-10.csv +7 -0
- package/fixtures/intl/de/trust-journal.csv +7 -0
- package/fixtures/intl/ja/operating-2026-10.csv +7 -0
- package/fixtures/intl/ja/trust-journal.csv +7 -0
- package/fixtures/operating-2026-10.csv +7 -0
- package/fixtures/trust-journal.csv +7 -0
- package/package.json +56 -4
- package/server.json +37 -0
- package/src/demo.js +13 -0
- package/src/index.js +2 -0
- package/src/logic.js +70 -0
- package/src/manifest.js +51 -0
package/CHANGELOG.md
ADDED
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,188 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Fairbrief Commingling (`fairbrief-commingling`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Looks for commingling between the operating account and trust: credits to operating that read like client money, firm money in trust beyond the allowance you set, firm expenses paid from trust, and money that left trust for the firm and came straight back. Never moves money. Client names are masked before results reach the model.
|
|
4
|
+
|
|
5
|
+
**Fairbrief Commingling never moves money between accounts. It never moves money out of the operating account. It never reports to a bar or bank.**
|
|
6
|
+
|
|
7
|
+
MIT · Node 20 or newer · local files only · client names masked before results reach the model · built on [`fairbrief-core`](../fairbrief-core)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx -y fairbrief-commingling demo
|
|
11
|
+
npx -y fairbrief-commingling mcp --root ./firm-exports
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## What it checks
|
|
15
|
+
|
|
16
|
+
| Check | Severity | What it means | What a person does |
|
|
17
|
+
|---|---|---|---|
|
|
18
|
+
| `client_money_in_operating` | error | A credit to the operating account reads like client money (settlement, retainer, escrow, cost advance). | Find out whose money it is. If it is client money, the responsible lawyer decides how it is moved to trust and recorded under your rules. |
|
|
19
|
+
| `firm_money_in_trust` | error | Firm money paid into trust takes the firm's total above the allowance in your settings. | Ask why it was paid in; firm money beyond what your rules allow for bank charges should go back to operating. |
|
|
20
|
+
| `firm_expense_from_trust` | error | A payment out of trust reads like a firm expense (rent, payroll, software, office costs). | Trust money is not for firm bills. The responsible lawyer reviews it and restores the funds as your rules require. |
|
|
21
|
+
| `round_trip` | warning | Money left trust for the firm and the same amount came back from the firm within a few days. | Check whether fees were taken early and returned, or trust money was used as a short loan. |
|
|
22
|
+
|
|
23
|
+
<!-- generated:start -->
|
|
24
|
+
|
|
25
|
+
## A demo run
|
|
26
|
+
|
|
27
|
+
`npx -y fairbrief-commingling demo` runs the agent on the fictional files in [`fixtures/`](fixtures) in a temporary folder. Captured output:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
Fairbrief Commingling demo (fictional firm and clients) in <demo folder>
|
|
31
|
+
|
|
32
|
+
▶ Read October operating and trust lines
|
|
33
|
+
status: executed decision: allow
|
|
34
|
+
6 operating line(s) and 6 trust entr(ies) read: 2 credit(s) to operating that look like client money, 1 firm deposit(s) to trust over the allowance, 1 firm expense(s) paid from trust, 1 round trip(s).
|
|
35
|
+
O-0002 operating 2026-10-06 45000 client_money_in_operating
|
|
36
|
+
O-0004 operating 2026-10-12 3000 client_money_in_operating
|
|
37
|
+
J-0004 trust 2026-10-15 5000 firm_money_in_trust, round_trip
|
|
38
|
+
J-0005 trust 2026-10-22 -299 firm_expense_from_trust
|
|
39
|
+
|
|
40
|
+
▶ Write the worklist
|
|
41
|
+
status: executed decision: allow
|
|
42
|
+
Worklist written: 6 operating line(s) and 6 trust entr(ies) read: 2 credit(s) to operating that look like client money, 1 firm deposit(s) to trust over the allowance, 1 firm expense(s) paid from trust, 1 round trip(s). Files: fairbrief-out/commingling/commingling.csv, fairbrief-out/commingling/commingling.html.
|
|
43
|
+
|
|
44
|
+
▶ Agent tries to move the money itself
|
|
45
|
+
status: blocked decision: block
|
|
46
|
+
reason: Fairbrief Commingling never moves money between accounts.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Tools
|
|
50
|
+
|
|
51
|
+
| Tool | What it does | Policy |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| `commingling_check` | Read the operating account and the trust journal and return every line that looks like client money in operating, firm money in trust, a firm expense paid from trust or a round trip, with the words that matched. | runs |
|
|
54
|
+
| `commingling_explain` | Show one line from commingling_check with every finding and the figures it was checked against. | runs |
|
|
55
|
+
| `commingling_checks` | List every check commingling runs, what it looks for and what a person does about it. | runs |
|
|
56
|
+
| `commingling_write_report` | Write commingling.csv (one row per item, with blank owner, decision and notes columns) and commingling.html into out_dir (default fairbrief-out/commingling). | runs |
|
|
57
|
+
| `trust_transfer` | Fairbrief Commingling never moves money between accounts. | refused |
|
|
58
|
+
| `operating_transfer` | Fairbrief Commingling never moves money out of the operating account. | refused |
|
|
59
|
+
| `bar_report_submit` | Fairbrief Commingling never reports to a bar or bank. | refused |
|
|
60
|
+
|
|
61
|
+
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.
|
|
62
|
+
|
|
63
|
+
## Columns it reads
|
|
64
|
+
|
|
65
|
+
Table inputs can be CSV, TSV, semicolon- or pipe-separated text, Excel `.xlsx`, JSON or JSONL; invoice lines can also be LEDES 1998B files. 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 client or party data: the model sees a pseudonym or nothing (see Client data).
|
|
66
|
+
|
|
67
|
+
### Operating account lines (`operating`)
|
|
68
|
+
|
|
69
|
+
| Column | Type | Also read as | For example, in other languages |
|
|
70
|
+
|---|---|---|---|
|
|
71
|
+
| `date` | date | Date, Posting Date, Posted Date, Transaction Date, Value Date, Booking Date | Datum, Date, 日付, 日期 |
|
|
72
|
+
| `description` | text | Description, Details, Memo, Narrative, Transaction Description, Payee | Beschreibung, Description, 摘要, 摘要 |
|
|
73
|
+
| `amount` | amount | Amount, Transaction Amount, Net Amount | Betrag, Montant, 金額, 金额 |
|
|
74
|
+
| `debit` | amount | Debit, Debits, Withdrawal, Withdrawals, Paid Out, Money Out | Ausgang, Débit, 出金, 支出 |
|
|
75
|
+
| `credit` | amount | Credit, Credits, Deposit, Deposits, Paid In, Money In | Eingang, Crédit, 入金, 收入 |
|
|
76
|
+
| `reference` | text | Reference, Check Number, Check #, Check No, Cheque Number, Ref | Referenz, Référence, 参照番号, 参考号 |
|
|
77
|
+
| `balance` | amount | Balance, Running Balance, Ledger Balance, Available Balance, Closing Balance | Saldo, Solde, 残高, 余额 |
|
|
78
|
+
| `type` | text | Type, Transaction Type, Details Type | Typ, Type, 種類, 类型 |
|
|
79
|
+
|
|
80
|
+
Named exports recognised by their column names:
|
|
81
|
+
|
|
82
|
+
| System | Export | Recognised by | Layout checked against vendor docs |
|
|
83
|
+
|---|---|---|---|
|
|
84
|
+
| Bank | Account activity download with debit and credit columns (CSV) | Posting Date, Description, Debit, Credit | no |
|
|
85
|
+
| QuickBooks Desktop | Bank register (CSV) | Num, Payee, Payment, Deposit | no |
|
|
86
|
+
|
|
87
|
+
Every named layout (Clio, PracticePanther, MyCase, Smokeball, CosmoLex, PCLaw, Tabs3, Aderant, Elite 3E, QuickBooks, bank downloads, Outlook) was written from knowledge of the export and was not checked against the vendor documentation or a live account. A file whose headers differ still maps by each column's other names; inspect shows what matched.
|
|
88
|
+
|
|
89
|
+
### Trust journal (transactions by matter) (`journal`)
|
|
90
|
+
|
|
91
|
+
| Column | Type | Also read as | For example, in other languages |
|
|
92
|
+
|---|---|---|---|
|
|
93
|
+
| `date` | date | Date, Transaction Date, Entry Date, Posted, Posting Date, Trans Date | Datum, Date, 日付, 日期 |
|
|
94
|
+
| `matter` | text | Matter, Matter Number, Matter ID, Matter No, Matter #, Display Number | Mandat, Dossier, 案件番号, 案件编号 |
|
|
95
|
+
| `client` | text (masked) | Client, Client Name, Client Full Name, Billing Client, Contact, Client/Company | Mandant, Nom du client, 依頼者, 客户名称 |
|
|
96
|
+
| `type` | text | Type, Transaction Type, Trans Type, Entry Type, Kind | Typ, Type, 種類, 类型 |
|
|
97
|
+
| `description` | text | Description, Memo, Note, Narrative, Explanation, Details | Beschreibung, Description, 摘要, 摘要 |
|
|
98
|
+
| `amount` | amount | Amount, Transaction Amount, Net, Net Amount | Betrag, Montant, 金額, 金额 |
|
|
99
|
+
| `deposit` | amount | Deposit, Deposits, Receipt, Receipts, Funds In, Money In | Eingang, Crédit, 入金, 收入 |
|
|
100
|
+
| `disbursement` | amount | Disbursement, Disbursements, Payment, Payments, Withdrawal, Funds Out | Ausgang, Débit, 出金, 支出 |
|
|
101
|
+
| `payee` | text (masked) | Payee, Paid To, Payor/Payee, Received From/Paid To, Received From, Name | - |
|
|
102
|
+
| `reference` | text | Reference, Ref, Check Number, Check #, Check No, Cheque Number | Referenz, Référence, 参照番号, 参考号 |
|
|
103
|
+
| `invoice_number` | text | Invoice, Invoice Number, Invoice #, Bill Number, Bill #, Applied To Invoice | Rechnungsnummer, N° de facture, 請求書番号, 发票号 |
|
|
104
|
+
| `trust_account` | text | Trust Account, Bank Account, Account, Account Name, Ledger | Kontobezeichnung, Libellé du compte, 勘定科目名, 科目名称 |
|
|
105
|
+
| `cleared` | text | Cleared, Reconciled, Cleared?, Cleared Date | - |
|
|
106
|
+
| `balance` | amount | Balance, Running Balance, Client Balance, Ledger Balance, Trust Balance | Saldo, Solde, 残高, 余额 |
|
|
107
|
+
|
|
108
|
+
Named exports recognised by their column names:
|
|
109
|
+
|
|
110
|
+
| System | Export | Recognised by | Layout checked against vendor docs |
|
|
111
|
+
|---|---|---|---|
|
|
112
|
+
| Clio Manage | Client trust ledger report (CSV) | Matter, Funds In, Funds Out | no |
|
|
113
|
+
| CosmoLex | Trust transaction report (CSV) | Ref #, Payee, Deposit, Disbursement | no |
|
|
114
|
+
| QuickBooks Online | Transaction detail by account (CSV) | Transaction Type, Num, Memo/Description, Account | no |
|
|
115
|
+
|
|
116
|
+
Every named layout (Clio, PracticePanther, MyCase, Smokeball, CosmoLex, PCLaw, Tabs3, Aderant, Elite 3E, QuickBooks, bank downloads, Outlook) was written from knowledge of the export and was not checked against the vendor documentation or a live account. A file whose headers differ still maps by each column's other names; inspect shows what matched.
|
|
117
|
+
|
|
118
|
+
### Files from other countries
|
|
119
|
+
|
|
120
|
+
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 fairbrief-commingling inspect <file>` (names and shapes only, never values) and name them in `fairbrief-sources.json`:
|
|
121
|
+
|
|
122
|
+
```json
|
|
123
|
+
{ "files": { "exports/time.csv": { "columns": { "matter": "Aktenzeichen" }, "date_order": "dmy" } } }
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Install
|
|
127
|
+
|
|
128
|
+
Node 20 or newer. No other dependencies.
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
npx -y fairbrief-commingling demo
|
|
132
|
+
npx -y fairbrief-commingling mcp --root /path/to/your/files
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Claude Desktop, Cursor and other MCP hosts:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"mcpServers": {
|
|
140
|
+
"fairbrief-commingling": {
|
|
141
|
+
"command": "npx",
|
|
142
|
+
"args": [
|
|
143
|
+
"-y",
|
|
144
|
+
"fairbrief-commingling",
|
|
145
|
+
"mcp",
|
|
146
|
+
"--root",
|
|
147
|
+
"/path/to/your/files"
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Claude Code: `claude mcp add fairbrief-commingling -- npx -y fairbrief-commingling mcp --root .`, or install the `fairbrief-commingling` plugin from this repository's marketplace (`fairbrief-law-firm`).
|
|
155
|
+
|
|
156
|
+
## Modes and approvals
|
|
157
|
+
|
|
158
|
+
- **Review** (`--mode review`): reads and reports only.
|
|
159
|
+
- **Assist** (default): the policy above. A tool that asks returns an `approval_id`; a person approves it once with `fairbrief-commingling approve <id> --as "Your Name"` (or on the local approvals page, `fairbrief-commingling approvals`), and the same call is repeated.
|
|
160
|
+
- **Auto** (`--mode auto --auto <tool,...>`): opt-in per tool, with step caps and a kill switch (`fairbrief-commingling 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.
|
|
161
|
+
|
|
162
|
+
## CLI
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
fairbrief-commingling tools # every tool, its policy and arguments
|
|
166
|
+
fairbrief-commingling sources # the columns each input is read from
|
|
167
|
+
fairbrief-commingling inspect <file> # how a file would be read (names and shapes, never values)
|
|
168
|
+
fairbrief-commingling call commingling_check '{"operating":"<operating>","journal":"<journal>"}'
|
|
169
|
+
fairbrief-commingling eval # the private eval cases on the fictional fixtures
|
|
170
|
+
fairbrief-commingling demo
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Client data
|
|
174
|
+
|
|
175
|
+
Results go to an AI model, so client data is masked before it leaves the agent (`--mask mask`, the default): client, party, payee and referral-source names, matter names and bank account numbers become stable pseudonyms such as `CL-3f9a1c2e`; addresses, phones, e-mails and tax ids are removed, also inside free text. `--mask strict` also hides matter numbers and ZIP codes. Tools still take a pseudonym back as an argument. Report files written to disk keep real names, because people at the firm work from them: keep them in a folder only your staff can open. `--mask off` is possible and is recorded in the audit log. The shared tests check that no fictional client name from the fixtures reaches any eval result. Masking keeps client names away from the model; whether your firm may use an AI model with client data at all is the firm's decision under its confidentiality duties.
|
|
176
|
+
|
|
177
|
+
## Audit log and data
|
|
178
|
+
|
|
179
|
+
Every call is written to `.fairbrief/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.
|
|
180
|
+
|
|
181
|
+
<!-- generated:end -->
|
|
182
|
+
|
|
183
|
+
## Limits
|
|
184
|
+
|
|
185
|
+
- It checks only what is in the files and settings you load. Trust-accounting rules, billing guidelines, CLE requirements and limits differ by state, client and firm: they live in your settings, and every result says when nobody at the firm has confirmed them. The example settings in `fixtures/` are not any state's or client's rules.
|
|
186
|
+
- It is not legal, ethics, tax or accounting advice. A person at the firm reviews every result; the agent never moves trust money, files with a court, sends anything or changes your practice-management system.
|
|
187
|
+
- 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.
|
|
188
|
+
- Masking keeps client names away from the model; it does not decide whether your firm may use an AI model with client data. That is a decision for the firm under its confidentiality duties.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { main } from 'fairbrief-core';
|
|
4
|
+
import { manifest } from '../src/manifest.js';
|
|
5
|
+
import { demo } from '../src/demo.js';
|
|
6
|
+
|
|
7
|
+
main(manifest, { bin: 'fairbrief-commingling', demo, evalFile: fileURLToPath(new URL('../evals/cases.json', import.meta.url)) });
|
package/evals/cases.json
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
{
|
|
2
|
+
"suite": "fairbrief-commingling",
|
|
3
|
+
"root": "..",
|
|
4
|
+
"data_note": "Fictional fixtures in ../fixtures. Deterministic checks; no model is called.",
|
|
5
|
+
"cases": [
|
|
6
|
+
{
|
|
7
|
+
"id": "october-lines",
|
|
8
|
+
"tool": "commingling_check",
|
|
9
|
+
"args": {
|
|
10
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
11
|
+
"journal": "fixtures/trust-journal.csv",
|
|
12
|
+
"settings": "fixtures/commingling-settings.json"
|
|
13
|
+
},
|
|
14
|
+
"expect": {
|
|
15
|
+
"status": "executed",
|
|
16
|
+
"equals": {
|
|
17
|
+
"result.flagged": 4,
|
|
18
|
+
"result.firm_funds_in_trust": 5100,
|
|
19
|
+
"result.by_check.client_money_in_operating": 2,
|
|
20
|
+
"result.by_check.firm_money_in_trust": 1,
|
|
21
|
+
"result.by_check.round_trip": 1,
|
|
22
|
+
"result.by_check.firm_expense_from_trust": 1
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"id": "reasons-name-the-words",
|
|
28
|
+
"tool": "commingling_check",
|
|
29
|
+
"args": {
|
|
30
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
31
|
+
"journal": "fixtures/trust-journal.csv",
|
|
32
|
+
"settings": "fixtures/commingling-settings.json"
|
|
33
|
+
},
|
|
34
|
+
"expect": {
|
|
35
|
+
"contains": [
|
|
36
|
+
"reads like client money",
|
|
37
|
+
"settlement",
|
|
38
|
+
"firm money in trust now 5100, allowance 100",
|
|
39
|
+
"took 5000 out of trust on 2026-10-14",
|
|
40
|
+
"reads like a firm expense"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "no-allowance-flags-the-bank-charge-deposit",
|
|
46
|
+
"tool": "commingling_check",
|
|
47
|
+
"args": {
|
|
48
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
49
|
+
"journal": "fixtures/trust-journal.csv"
|
|
50
|
+
},
|
|
51
|
+
"expect": {
|
|
52
|
+
"status": "executed",
|
|
53
|
+
"equals": {
|
|
54
|
+
"result.by_check.firm_money_in_trust": 2,
|
|
55
|
+
"result.allowed_firm_funds": 0
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "payroll-and-rent-in-operating-are-fine",
|
|
61
|
+
"tool": "commingling_check",
|
|
62
|
+
"args": {
|
|
63
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
64
|
+
"journal": "fixtures/trust-journal.csv",
|
|
65
|
+
"settings": "fixtures/commingling-settings.json"
|
|
66
|
+
},
|
|
67
|
+
"expect": {
|
|
68
|
+
"not_contains": [
|
|
69
|
+
"O-0003",
|
|
70
|
+
"O-0006",
|
|
71
|
+
"J-0006"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "round-trip-explained",
|
|
77
|
+
"tool": "commingling_explain",
|
|
78
|
+
"args": {
|
|
79
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
80
|
+
"journal": "fixtures/trust-journal.csv",
|
|
81
|
+
"settings": "fixtures/commingling-settings.json",
|
|
82
|
+
"line_id": "J-0004"
|
|
83
|
+
},
|
|
84
|
+
"expect": {
|
|
85
|
+
"status": "executed",
|
|
86
|
+
"contains": [
|
|
87
|
+
"round_trip",
|
|
88
|
+
"matter 1601"
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": "before-the-round-trip",
|
|
94
|
+
"tool": "commingling_check",
|
|
95
|
+
"args": {
|
|
96
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
97
|
+
"journal": "fixtures/trust-journal.csv",
|
|
98
|
+
"settings": "fixtures/commingling-settings.json",
|
|
99
|
+
"as_of": "2026-10-14"
|
|
100
|
+
},
|
|
101
|
+
"expect": {
|
|
102
|
+
"status": "executed",
|
|
103
|
+
"equals": {
|
|
104
|
+
"result.flagged": 2
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"id": "std-check-in-review-mode",
|
|
110
|
+
"tool": "commingling_check",
|
|
111
|
+
"mode": "review",
|
|
112
|
+
"args": {
|
|
113
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
114
|
+
"journal": "fixtures/trust-journal.csv",
|
|
115
|
+
"settings": "fixtures/commingling-settings.json"
|
|
116
|
+
},
|
|
117
|
+
"expect": {
|
|
118
|
+
"status": "executed"
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"id": "std-limit-one",
|
|
123
|
+
"tool": "commingling_check",
|
|
124
|
+
"args": {
|
|
125
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
126
|
+
"journal": "fixtures/trust-journal.csv",
|
|
127
|
+
"settings": "fixtures/commingling-settings.json",
|
|
128
|
+
"limit": 1
|
|
129
|
+
},
|
|
130
|
+
"expect": {
|
|
131
|
+
"status": "executed",
|
|
132
|
+
"max": {
|
|
133
|
+
"result.items.length": 1
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": "std-masked",
|
|
139
|
+
"tool": "commingling_check",
|
|
140
|
+
"args": {
|
|
141
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
142
|
+
"journal": "fixtures/trust-journal.csv",
|
|
143
|
+
"settings": "fixtures/commingling-settings.json"
|
|
144
|
+
},
|
|
145
|
+
"expect": {
|
|
146
|
+
"status": "executed",
|
|
147
|
+
"not_contains": [
|
|
148
|
+
"Bram Holloway",
|
|
149
|
+
"Holloway, Bram",
|
|
150
|
+
"Example Holdings LLC",
|
|
151
|
+
"Demo Software Co"
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"id": "std-report",
|
|
157
|
+
"tool": "commingling_write_report",
|
|
158
|
+
"args": {
|
|
159
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
160
|
+
"journal": "fixtures/trust-journal.csv",
|
|
161
|
+
"settings": "fixtures/commingling-settings.json"
|
|
162
|
+
},
|
|
163
|
+
"expect": {
|
|
164
|
+
"status": "executed",
|
|
165
|
+
"contains": [
|
|
166
|
+
".csv",
|
|
167
|
+
".html"
|
|
168
|
+
],
|
|
169
|
+
"not_contains": [
|
|
170
|
+
"Bram Holloway",
|
|
171
|
+
"Holloway, Bram"
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"id": "std-report-german",
|
|
177
|
+
"tool": "commingling_write_report",
|
|
178
|
+
"args": {
|
|
179
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
180
|
+
"journal": "fixtures/trust-journal.csv",
|
|
181
|
+
"settings": "fixtures/commingling-settings.json",
|
|
182
|
+
"language": "de"
|
|
183
|
+
},
|
|
184
|
+
"expect": {
|
|
185
|
+
"status": "executed",
|
|
186
|
+
"equals": {
|
|
187
|
+
"result.lang": "de"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"id": "std-checks-list",
|
|
193
|
+
"tool": "commingling_checks",
|
|
194
|
+
"args": {},
|
|
195
|
+
"expect": {
|
|
196
|
+
"status": "executed"
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"id": "std-explain",
|
|
201
|
+
"tool": "commingling_explain",
|
|
202
|
+
"args": {
|
|
203
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
204
|
+
"journal": "fixtures/trust-journal.csv",
|
|
205
|
+
"settings": "fixtures/commingling-settings.json",
|
|
206
|
+
"line_id": "J-0004"
|
|
207
|
+
},
|
|
208
|
+
"expect": {
|
|
209
|
+
"status": "executed",
|
|
210
|
+
"contains": [
|
|
211
|
+
"J-0004"
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"id": "std-explain-unknown",
|
|
217
|
+
"tool": "commingling_explain",
|
|
218
|
+
"args": {
|
|
219
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
220
|
+
"journal": "fixtures/trust-journal.csv",
|
|
221
|
+
"settings": "fixtures/commingling-settings.json",
|
|
222
|
+
"line_id": "NO-SUCH-ITEM"
|
|
223
|
+
},
|
|
224
|
+
"expect": {
|
|
225
|
+
"status": "error",
|
|
226
|
+
"contains": [
|
|
227
|
+
"not found"
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"id": "std-missing-file",
|
|
233
|
+
"tool": "commingling_check",
|
|
234
|
+
"args": {
|
|
235
|
+
"operating": "fixtures/no-such-file.csv",
|
|
236
|
+
"journal": "fixtures/trust-journal.csv",
|
|
237
|
+
"settings": "fixtures/commingling-settings.json"
|
|
238
|
+
},
|
|
239
|
+
"expect": {
|
|
240
|
+
"status": "error",
|
|
241
|
+
"contains": [
|
|
242
|
+
"file not found"
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"id": "std-outside-root",
|
|
248
|
+
"tool": "commingling_check",
|
|
249
|
+
"args": {
|
|
250
|
+
"operating": "../../../../etc/passwd",
|
|
251
|
+
"journal": "fixtures/trust-journal.csv",
|
|
252
|
+
"settings": "fixtures/commingling-settings.json"
|
|
253
|
+
},
|
|
254
|
+
"expect": {
|
|
255
|
+
"status": "error",
|
|
256
|
+
"matches": [
|
|
257
|
+
"outside|leaves the allowed root"
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"id": "std-settings-typo",
|
|
263
|
+
"tool": "commingling_check",
|
|
264
|
+
"args": {
|
|
265
|
+
"operating": "fixtures/operating-2026-10.csv",
|
|
266
|
+
"journal": "fixtures/trust-journal.csv",
|
|
267
|
+
"settings": "fixtures/commingling-settings-typo.json"
|
|
268
|
+
},
|
|
269
|
+
"expect": {
|
|
270
|
+
"status": "error",
|
|
271
|
+
"contains": [
|
|
272
|
+
"is not a valid"
|
|
273
|
+
]
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
"id": "std-unknown-tool",
|
|
278
|
+
"tool": "shell_exec",
|
|
279
|
+
"args": {
|
|
280
|
+
"cmd": "whoami"
|
|
281
|
+
},
|
|
282
|
+
"expect": {
|
|
283
|
+
"status": "blocked"
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"id": "std-refused-trust_transfer",
|
|
288
|
+
"tool": "trust_transfer",
|
|
289
|
+
"args": {},
|
|
290
|
+
"expect": {
|
|
291
|
+
"status": "blocked"
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"id": "std-refused-operating_transfer",
|
|
296
|
+
"tool": "operating_transfer",
|
|
297
|
+
"args": {},
|
|
298
|
+
"expect": {
|
|
299
|
+
"status": "blocked"
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"id": "std-refused-bar_report_submit",
|
|
304
|
+
"tool": "bar_report_submit",
|
|
305
|
+
"args": {},
|
|
306
|
+
"expect": {
|
|
307
|
+
"status": "blocked"
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"id": "intl-de-october-lines",
|
|
312
|
+
"tool": "commingling_check",
|
|
313
|
+
"args": {
|
|
314
|
+
"operating": "fixtures/intl/de/operating-2026-10.csv",
|
|
315
|
+
"journal": "fixtures/intl/de/trust-journal.csv",
|
|
316
|
+
"settings": "fixtures/commingling-settings.json"
|
|
317
|
+
},
|
|
318
|
+
"expect": {
|
|
319
|
+
"status": "executed",
|
|
320
|
+
"equals": {
|
|
321
|
+
"result.flagged": 4,
|
|
322
|
+
"result.firm_funds_in_trust": 5100,
|
|
323
|
+
"result.by_check.client_money_in_operating": 2,
|
|
324
|
+
"result.by_check.firm_money_in_trust": 1,
|
|
325
|
+
"result.by_check.round_trip": 1,
|
|
326
|
+
"result.by_check.firm_expense_from_trust": 1
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"id": "intl-ja-october-lines",
|
|
332
|
+
"tool": "commingling_check",
|
|
333
|
+
"args": {
|
|
334
|
+
"operating": "fixtures/intl/ja/operating-2026-10.csv",
|
|
335
|
+
"journal": "fixtures/intl/ja/trust-journal.csv",
|
|
336
|
+
"settings": "fixtures/commingling-settings.json"
|
|
337
|
+
},
|
|
338
|
+
"expect": {
|
|
339
|
+
"status": "executed",
|
|
340
|
+
"equals": {
|
|
341
|
+
"result.flagged": 4,
|
|
342
|
+
"result.firm_funds_in_trust": 5100,
|
|
343
|
+
"result.by_check.client_money_in_operating": 2,
|
|
344
|
+
"result.by_check.firm_money_in_trust": 1,
|
|
345
|
+
"result.by_check.round_trip": 1,
|
|
346
|
+
"result.by_check.firm_expense_from_trust": 1
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
]
|
|
351
|
+
}
|
package/evals/own.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": "..",
|
|
3
|
+
"base": { "operating": "fixtures/operating-2026-10.csv", "journal": "fixtures/trust-journal.csv", "settings": "fixtures/commingling-settings.json" },
|
|
4
|
+
"item": "J-0004",
|
|
5
|
+
"settings_typo": "fixtures/commingling-settings-typo.json",
|
|
6
|
+
"cases": [
|
|
7
|
+
{ "id": "october-lines", "tool": "commingling_check", "args": { "operating": "fixtures/operating-2026-10.csv", "journal": "fixtures/trust-journal.csv", "settings": "fixtures/commingling-settings.json" },
|
|
8
|
+
"expect": { "status": "executed", "equals": { "result.flagged": 4, "result.firm_funds_in_trust": 5100, "result.by_check.client_money_in_operating": 2, "result.by_check.firm_money_in_trust": 1, "result.by_check.round_trip": 1, "result.by_check.firm_expense_from_trust": 1 } } },
|
|
9
|
+
{ "id": "reasons-name-the-words", "tool": "commingling_check", "args": { "operating": "fixtures/operating-2026-10.csv", "journal": "fixtures/trust-journal.csv", "settings": "fixtures/commingling-settings.json" },
|
|
10
|
+
"expect": { "contains": ["reads like client money", "settlement", "firm money in trust now 5100, allowance 100", "took 5000 out of trust on 2026-10-14", "reads like a firm expense"] } },
|
|
11
|
+
{ "id": "no-allowance-flags-the-bank-charge-deposit", "tool": "commingling_check", "args": { "operating": "fixtures/operating-2026-10.csv", "journal": "fixtures/trust-journal.csv" },
|
|
12
|
+
"expect": { "status": "executed", "equals": { "result.by_check.firm_money_in_trust": 2, "result.allowed_firm_funds": 0 } } },
|
|
13
|
+
{ "id": "payroll-and-rent-in-operating-are-fine", "tool": "commingling_check", "args": { "operating": "fixtures/operating-2026-10.csv", "journal": "fixtures/trust-journal.csv", "settings": "fixtures/commingling-settings.json" },
|
|
14
|
+
"expect": { "not_contains": ["O-0003", "O-0006", "J-0006"] } },
|
|
15
|
+
{ "id": "round-trip-explained", "tool": "commingling_explain", "args": { "operating": "fixtures/operating-2026-10.csv", "journal": "fixtures/trust-journal.csv", "settings": "fixtures/commingling-settings.json", "line_id": "J-0004" },
|
|
16
|
+
"expect": { "status": "executed", "contains": ["round_trip", "matter 1601"] } },
|
|
17
|
+
{ "id": "before-the-round-trip", "tool": "commingling_check", "args": { "operating": "fixtures/operating-2026-10.csv", "journal": "fixtures/trust-journal.csv", "settings": "fixtures/commingling-settings.json", "as_of": "2026-10-14" },
|
|
18
|
+
"expect": { "status": "executed", "equals": { "result.flagged": 2 } } }
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Fairbrief Commingling fixtures
|
|
2
|
+
|
|
3
|
+
Everything here is fictional: the firm (Example Ridge Law LLP), clients, payees and amounts.
|
|
4
|
+
|
|
5
|
+
- `operating-2026-10.csv`: six October lines on the operating account (signed amounts).
|
|
6
|
+
- `trust-journal.csv`: six October trust entries.
|
|
7
|
+
- `commingling-settings.json`: a 100.00 firm-funds allowance and a 5-day round-trip window (examples, not confirmed). `commingling-settings-typo.json` has a misspelt key.
|
|
8
|
+
|
|
9
|
+
Planted: settlement proceeds (45,000) and a new-client retainer (3,000) credited to operating; 5,000 taken from matter 1601 as fees on 14 October and paid back from the firm on 15 October (over the 100.00 allowance, and a round trip); a 299.00 software subscription paid from trust. The 100.00 for bank charges is within the allowance.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"note": "Accuracy recipe for scripts/accuracy.mjs. \"planted\" was checked by hand against the Planted paragraph of README.md in this folder (19 Nov 2026).",
|
|
3
|
+
"case": "october-lines",
|
|
4
|
+
"planted": [
|
|
5
|
+
[
|
|
6
|
+
"O-0002",
|
|
7
|
+
"client_money_in_operating"
|
|
8
|
+
],
|
|
9
|
+
[
|
|
10
|
+
"O-0004",
|
|
11
|
+
"client_money_in_operating"
|
|
12
|
+
],
|
|
13
|
+
[
|
|
14
|
+
"J-0004",
|
|
15
|
+
"firm_money_in_trust"
|
|
16
|
+
],
|
|
17
|
+
[
|
|
18
|
+
"J-0004",
|
|
19
|
+
"round_trip"
|
|
20
|
+
],
|
|
21
|
+
[
|
|
22
|
+
"J-0005",
|
|
23
|
+
"firm_expense_from_trust"
|
|
24
|
+
]
|
|
25
|
+
],
|
|
26
|
+
"clean": {
|
|
27
|
+
"edits": [
|
|
28
|
+
{
|
|
29
|
+
"arg": "operating",
|
|
30
|
+
"dropRows": [
|
|
31
|
+
2,
|
|
32
|
+
4
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"arg": "journal",
|
|
37
|
+
"dropRows": [
|
|
38
|
+
3,
|
|
39
|
+
4,
|
|
40
|
+
5
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"mutations": []
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "allowed_firm_fund": 100 }
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Fixtures from other countries
|
|
2
|
+
|
|
3
|
+
Written by `node scripts/make-evals.mjs` from the English fixtures one folder up: the same fictional data the way a local export writes it.
|
|
4
|
+
|
|
5
|
+
- `de/`: German column names, Windows-1252 text, semicolons, comma decimals (1.234,56), day-first dotted dates (31.10.2026).
|
|
6
|
+
- `ja/`: Japanese column names, Shift_JIS text, year-first dates (2026/10/31).
|
|
7
|
+
|
|
8
|
+
Values (names, codes, descriptions) stay in English. The eval cases `intl-de-*` and `intl-ja-*` expect exactly the same results as the English case.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Datum;Beschreibung;Betrag;Referenz
|
|
2
|
+
02.10.2026;Client payment invoice INV-8001;2.400,00;P1
|
|
3
|
+
06.10.2026;Settlement proceeds Varga matter;45.000,00;P2
|
|
4
|
+
09.10.2026;Payroll October;-38.000,00;PR-10
|
|
5
|
+
12.10.2026;Retainer deposit new client Ashdown;3.000,00;P3
|
|
6
|
+
15.10.2026;Transfer to trust account;-5.000,00;T1
|
|
7
|
+
20.10.2026;Office rent;-6.000,00;R-10
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Datum;Mandat;Mandant;Typ;Beschreibung;Eingang;Ausgang;payee;Referenz
|
|
2
|
+
01.10.2026;1601;Example Holdings LLC;Deposit;Retainer received;8.000,00;;Example Holdings LLC;DEP-6001
|
|
3
|
+
03.10.2026;;;Deposit;Firm funds to cover bank charges;100,00;;Example Ridge Law LLP;DEP-6002
|
|
4
|
+
14.10.2026;1601;Example Holdings LLC;Transfer to operating;Earned fees;;5.000,00;Example Ridge Law LLP operating;TRF-6003
|
|
5
|
+
15.10.2026;;;Deposit;Transfer from operating;5.000,00;;Example Ridge Law LLP;DEP-6004
|
|
6
|
+
22.10.2026;;;Disbursement;Office software subscription;;299,00;Demo Software Co;CHK-6005
|
|
7
|
+
25.10.2026;1602;Bram Holloway;Deposit;Escrow deposit for closing;12.000,00;;Bram Holloway;DEP-6006
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
���t,�E�v,���z,�Q�Ɣԍ�
|
|
2
|
+
2026/10/02,Client payment invoice INV-8001,"2,400.00",P1
|
|
3
|
+
2026/10/06,Settlement proceeds Varga matter,"45,000.00",P2
|
|
4
|
+
2026/10/09,Payroll October,"-38,000.00",PR-10
|
|
5
|
+
2026/10/12,Retainer deposit new client Ashdown,"3,000.00",P3
|
|
6
|
+
2026/10/15,Transfer to trust account,"-5,000.00",T1
|
|
7
|
+
2026/10/20,Office rent,"-6,000.00",R-10
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
���t,�Č��ԍ�,�˗���,���,�E�v,����,�o��,payee,�Q�Ɣԍ�
|
|
2
|
+
2026/10/01,1601,Example Holdings LLC,Deposit,Retainer received,"8,000.00",,Example Holdings LLC,DEP-6001
|
|
3
|
+
2026/10/03,,,Deposit,Firm funds to cover bank charges,100.00,,Example Ridge Law LLP,DEP-6002
|
|
4
|
+
2026/10/14,1601,Example Holdings LLC,Transfer to operating,Earned fees,,"5,000.00",Example Ridge Law LLP operating,TRF-6003
|
|
5
|
+
2026/10/15,,,Deposit,Transfer from operating,"5,000.00",,Example Ridge Law LLP,DEP-6004
|
|
6
|
+
2026/10/22,,,Disbursement,Office software subscription,,299.00,Demo Software Co,CHK-6005
|
|
7
|
+
2026/10/25,1602,Bram Holloway,Deposit,Escrow deposit for closing,"12,000.00",,Bram Holloway,DEP-6006
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
date,description,amount,reference
|
|
2
|
+
2026-10-02,Client payment invoice INV-8001,2400.00,P1
|
|
3
|
+
2026-10-06,Settlement proceeds Varga matter,45000.00,P2
|
|
4
|
+
2026-10-09,Payroll October,-38000.00,PR-10
|
|
5
|
+
2026-10-12,Retainer deposit new client Ashdown,3000.00,P3
|
|
6
|
+
2026-10-15,Transfer to trust account,-5000.00,T1
|
|
7
|
+
2026-10-20,Office rent,-6000.00,R-10
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
date,matter,client,type,description,deposit,disbursement,payee,reference
|
|
2
|
+
2026-10-01,1601,Example Holdings LLC,Deposit,Retainer received,8000.00,,Example Holdings LLC,DEP-6001
|
|
3
|
+
2026-10-03,,,Deposit,Firm funds to cover bank charges,100.00,,Example Ridge Law LLP,DEP-6002
|
|
4
|
+
2026-10-14,1601,Example Holdings LLC,Transfer to operating,Earned fees,,5000.00,Example Ridge Law LLP operating,TRF-6003
|
|
5
|
+
2026-10-15,,,Deposit,Transfer from operating,5000.00,,Example Ridge Law LLP,DEP-6004
|
|
6
|
+
2026-10-22,,,Disbursement,Office software subscription,,299.00,Demo Software Co,CHK-6005
|
|
7
|
+
2026-10-25,1602,Bram Holloway,Deposit,Escrow deposit for closing,12000.00,,Bram Holloway,DEP-6006
|
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fairbrief-commingling",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"mcpName": "io.github.fpavia111-creator/fairbrief-commingling",
|
|
5
|
+
"description": "Fairbrief Commingling: looks for client money in the operating account, firm money in trust beyond the allowance, firm expenses paid from trust and round trips between the two accounts. Never moves money.",
|
|
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
|
+
"fairbrief-commingling": "bin/fairbrief-commingling.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/fairbrief-commingling.js demo",
|
|
33
|
+
"eval": "node bin/fairbrief-commingling.js eval"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"fairbrief-core": "^0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/fpavia111-creator/fairbrief-agents.git",
|
|
41
|
+
"directory": "packages/fairbrief-commingling"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/fpavia111-creator/fairbrief-agents/tree/master/packages/fairbrief-commingling#readme",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/fpavia111-creator/fairbrief-agents/issues"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"mcp",
|
|
49
|
+
"mcp-server",
|
|
50
|
+
"law-firm",
|
|
51
|
+
"legal",
|
|
52
|
+
"law-practice",
|
|
53
|
+
"fairbrief",
|
|
54
|
+
"trust-accounting",
|
|
55
|
+
"commingling",
|
|
56
|
+
"iolta"
|
|
57
|
+
]
|
|
58
|
+
}
|
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/fairbrief-commingling",
|
|
4
|
+
"title": "Fairbrief Commingling",
|
|
5
|
+
"description": "Fairbrief Commingling: looks for client money in the operating account, firm money in trust beyond…",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"url": "https://github.com/fpavia111-creator/fairbrief-agents",
|
|
9
|
+
"source": "github",
|
|
10
|
+
"subfolder": "packages/fairbrief-commingling"
|
|
11
|
+
},
|
|
12
|
+
"websiteUrl": "https://fair-agents.com/fairbrief.html",
|
|
13
|
+
"packages": [
|
|
14
|
+
{
|
|
15
|
+
"registryType": "npm",
|
|
16
|
+
"identifier": "fairbrief-commingling",
|
|
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,13 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { demoRuntime, printStep } from 'fairbrief-core';
|
|
3
|
+
|
|
4
|
+
export async function demo(manifest) {
|
|
5
|
+
const rt = demoRuntime(manifest, fileURLToPath(new URL('../fixtures', import.meta.url)));
|
|
6
|
+
process.stdout.write(`Fairbrief Commingling demo (fictional firm and clients) in ${rt.root}\n`);
|
|
7
|
+
const f = { operating: 'operating-2026-10.csv', journal: 'trust-journal.csv', settings: 'commingling-settings.json' };
|
|
8
|
+
const c = await rt.call('commingling_check', f);
|
|
9
|
+
printStep('Read October operating and trust lines', c);
|
|
10
|
+
for (const i of c.result.items) process.stdout.write(` ${i.id} ${i.account.padEnd(9)} ${i.date} ${String(i.amount).padStart(9)} ${i.findings.map((x) => x.code).join(', ')}\n`);
|
|
11
|
+
printStep('Write the worklist', await rt.call('commingling_write_report', f));
|
|
12
|
+
printStep('Agent tries to move the money itself', await rt.call('trust_transfer', {}));
|
|
13
|
+
}
|
package/src/index.js
ADDED
package/src/logic.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Commingling. Client money belongs in trust and firm money mostly does not. Fairbrief Commingling
|
|
2
|
+
// reads the operating account and the trust journal and lists credits to operating
|
|
3
|
+
// that read like client money, firm money paid into trust beyond the small allowance
|
|
4
|
+
// your settings give (for bank charges, where your rules allow it), firm expenses paid
|
|
5
|
+
// from trust, and money that left trust for the firm and came straight back.
|
|
6
|
+
import { str, num, round2, isoDate, daysBetween, trustRows, signedAmount, confirmedNote } from 'fairbrief-core';
|
|
7
|
+
|
|
8
|
+
export const CHECKS = Object.freeze({
|
|
9
|
+
client_money_in_operating: { severity: 'error', what: 'A credit to the operating account reads like client money (settlement, retainer, escrow, cost advance).', fix: 'Find out whose money it is. If it is client money, the responsible lawyer decides how it is moved to trust and recorded under your rules.' },
|
|
10
|
+
firm_money_in_trust: { severity: 'error', what: 'Firm money paid into trust takes the firm\'s total above the allowance in your settings.', fix: 'Ask why it was paid in; firm money beyond what your rules allow for bank charges should go back to operating.' },
|
|
11
|
+
firm_expense_from_trust: { severity: 'error', what: 'A payment out of trust reads like a firm expense (rent, payroll, software, office costs).', fix: 'Trust money is not for firm bills. The responsible lawyer reviews it and restores the funds as your rules require.' },
|
|
12
|
+
round_trip: { severity: 'warning', what: 'Money left trust for the firm and the same amount came back from the firm within a few days.', fix: 'Check whether fees were taken early and returned, or trust money was used as a short loan.' },
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const SETTINGS_SCHEMA = {
|
|
16
|
+
type: 'object', additionalProperties: false,
|
|
17
|
+
properties: {
|
|
18
|
+
client_money_words: { type: 'array', maxItems: 50, items: { type: 'string', minLength: 3, maxLength: 60 }, description: 'Words in an operating credit that mark client money (defaults: settlement, retainer, escrow, advance, deposit for costs, cost advance, proceeds)' },
|
|
19
|
+
firm_funds_words: { type: 'array', maxItems: 50, items: { type: 'string', minLength: 3, maxLength: 60 }, description: 'Words in a trust deposit that mark firm money (defaults: from operating, firm funds, firm money, operating account, bank charge, cover)' },
|
|
20
|
+
firm_expense_words: { type: 'array', maxItems: 50, items: { type: 'string', minLength: 3, maxLength: 60 }, description: 'Words in a trust payment that mark a firm expense (defaults: rent, payroll, salary, software, subscription, office, utilities, premium, marketing, advertising)' },
|
|
21
|
+
allowed_firm_funds: { type: 'number', minimum: 0, maximum: 1000000, description: 'Firm money your rules let you keep in trust, for example for bank charges (example default 0)' },
|
|
22
|
+
round_trip_days: { type: 'integer', minimum: 0, maximum: 60, description: 'Days within which money leaving trust and coming back counts as a round trip (example default 5)' },
|
|
23
|
+
confirmed_by: { type: 'string', maxLength: 120, description: 'Person at the firm who checked these settings' },
|
|
24
|
+
confirmed_on: { type: 'string', format: 'date', description: 'When they checked them' },
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const CLIENT = ['settlement', 'retainer', 'escrow', 'advance', 'deposit for costs', 'cost advance', 'proceeds'];
|
|
29
|
+
const FIRM = ['from operating', 'firm funds', 'firm money', 'operating account', 'bank charge', 'cover'];
|
|
30
|
+
const EXPENSE = ['rent', 'payroll', 'salary', 'software', 'subscription', 'office', 'utilities', 'premium', 'marketing', 'advertising'];
|
|
31
|
+
const words = (list, def) => (list && list.length ? list : def).map((w) => w.toLowerCase());
|
|
32
|
+
// Each word list compiled once; returns the first word (in list order) found at a word start.
|
|
33
|
+
const hitter = (list) => { const res = list.map((w) => [w, new RegExp(`\\b${w.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`)]); return (text) => (res.find(([, re]) => re.test(text)) || [])[0]; };
|
|
34
|
+
|
|
35
|
+
/** Returns { items, summary, by_check, firm_funds_in_trust }. */
|
|
36
|
+
export function findCommingling(operating = [], journal = [], settings = {}, asOf = null) {
|
|
37
|
+
const cw = words(settings.client_money_words, CLIENT), fw = words(settings.firm_funds_words, FIRM), ew = words(settings.firm_expense_words, EXPENSE);
|
|
38
|
+
const allowed = settings.allowed_firm_funds ?? 0; const rtDays = settings.round_trip_days ?? 5;
|
|
39
|
+
const hitCw = hitter(cw), hitFw = hitter(fw), hitEw = hitter(ew);
|
|
40
|
+
const items = [];
|
|
41
|
+
operating.forEach((r, i) => {
|
|
42
|
+
const d = isoDate(r.date); if (!d || (asOf && d > asOf)) return;
|
|
43
|
+
const amt = round2(signedAmount(r, { inFields: ['credit'], outFields: ['debit'] }));
|
|
44
|
+
const text = `${str(r.description)} ${str(r.type)}`.toLowerCase(); const w = amt > 0 && hitCw(text);
|
|
45
|
+
if (w) items.push({ id: `O-${String(i + 1).padStart(4, '0')}`, account: 'operating', date: d, matter: '', client: '', amount: amt, description: str(r.description), status: 'error', findings: [{ code: 'client_money_in_operating', amount: amt, detail: `Operating credit on ${d} for ${amt} ("${str(r.description)}") reads like client money ("${w}").` }] });
|
|
46
|
+
});
|
|
47
|
+
const rows = trustRows(journal).filter((r) => r.date && (!asOf || r.date <= asOf)).sort((a, b) => a.date.localeCompare(b.date) || a.id.localeCompare(b.id));
|
|
48
|
+
let firm = 0;
|
|
49
|
+
// Transfers out of trust to the firm, indexed by amount in cents (in row order), so each
|
|
50
|
+
// firm deposit looks only at transfers of the same amount.
|
|
51
|
+
const outs = new Map();
|
|
52
|
+
rows.forEach((o, i) => { if (o.amount < 0 && /operating|transfer|earned/.test(`${o.type} ${o.description} ${o.payee}`.toLowerCase())) { const c = Math.round(-o.amount * 100); if (!outs.has(c)) outs.set(c, []); outs.get(c).push([i, o]); } });
|
|
53
|
+
const roundTrip = (r) => { const c = Math.round(r.amount * 100); return [...(outs.get(c - 1) || []), ...(outs.get(c) || []), ...(outs.get(c + 1) || [])].sort((a, b) => a[0] - b[0]).map(([, o]) => o).find((o) => Math.abs(o.amount + r.amount) < 0.005 && daysBetween(o.date, r.date) >= 0 && daysBetween(o.date, r.date) <= rtDays); };
|
|
54
|
+
for (const r of rows) {
|
|
55
|
+
const text = `${r.type} ${r.description} ${r.payee}`.toLowerCase(); const findings = [];
|
|
56
|
+
if (r.amount > 0 && hitFw(text)) {
|
|
57
|
+
firm = round2(firm + r.amount);
|
|
58
|
+
if (firm > allowed + 0.004) findings.push({ code: 'firm_money_in_trust', amount: r.amount, detail: `Firm money paid into trust on ${r.date}: ${r.amount} ("${r.description}"); firm money in trust now ${firm}, allowance ${allowed}.` });
|
|
59
|
+
const out = roundTrip(r);
|
|
60
|
+
if (out) findings.push({ code: 'round_trip', amount: r.amount, detail: `${out.id} took ${-out.amount} out of trust on ${out.date} (matter ${out.matter || 'none'}) and ${r.amount} came back from the firm on ${r.date}.` });
|
|
61
|
+
}
|
|
62
|
+
const e = r.amount < 0 && hitEw(text);
|
|
63
|
+
if (e) findings.push({ code: 'firm_expense_from_trust', amount: -r.amount, detail: `Trust payment on ${r.date} of ${-r.amount} to ${r.payee || 'a payee'} ("${r.description}") reads like a firm expense ("${e}").` });
|
|
64
|
+
if (findings.length) items.push({ id: r.id, account: 'trust', date: r.date, matter: r.matter, client: r.client, amount: r.amount, description: r.description, status: findings.some((f) => CHECKS[f.code].severity === 'error') ? 'error' : 'warning', findings });
|
|
65
|
+
}
|
|
66
|
+
items.sort((a, b) => a.date.localeCompare(b.date) || a.id.localeCompare(b.id));
|
|
67
|
+
const by_check = {}; for (const x of items) for (const f of x.findings) by_check[f.code] = (by_check[f.code] || 0) + 1;
|
|
68
|
+
const note = confirmedNote(settings);
|
|
69
|
+
return { summary: `${operating.length} operating line(s) and ${rows.length} trust entr(ies) read: ${by_check.client_money_in_operating || 0} credit(s) to operating that look like client money, ${by_check.firm_money_in_trust || 0} firm deposit(s) to trust over the allowance, ${by_check.firm_expense_from_trust || 0} firm expense(s) paid from trust, ${by_check.round_trip || 0} round trip(s).`, flagged: items.length, firm_funds_in_trust: firm, allowed_firm_funds: allowed, by_check, ...(note ? { settings_note: note } : {}), items };
|
|
70
|
+
}
|
package/src/manifest.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { familyAgent, TRUST_FIELDS, TRUST_PROFILES, BANK_FIELDS, BANK_PROFILES, LIMITS, sectionTitle } from 'fairbrief-core';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { findCommingling, CHECKS, SETTINGS_SCHEMA } from './logic.js';
|
|
4
|
+
|
|
5
|
+
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
6
|
+
const args = {
|
|
7
|
+
operating: { type: 'string', description: 'Operating account statement or register under --root (date, description, amount or debit/credit)' },
|
|
8
|
+
journal: { type: 'string', description: 'Trust journal export (transactions by matter)' },
|
|
9
|
+
settings: { type: 'string', description: 'Optional commingling_settings JSON: the words that mark client money, firm funds and firm expenses, the firm-funds allowance, round-trip days, who confirmed them' },
|
|
10
|
+
};
|
|
11
|
+
const run = (a, ctx) => findCommingling(ctx.records(a.operating), ctx.records(a.journal), a.settings ? ctx.readJson(a.settings, 'commingling_settings') : {}, a.as_of || null);
|
|
12
|
+
|
|
13
|
+
export const manifest = familyAgent({
|
|
14
|
+
name: 'fairbrief-commingling', prefix: 'commingling', version: pkg.version,
|
|
15
|
+
description: 'Looks for commingling between the operating account and trust: credits to operating that read like client money, firm money in trust beyond the allowance you set, firm expenses paid from trust, and money that left trust for the firm and came straight back. Never moves money. Client names are masked before results reach the model.',
|
|
16
|
+
checkTitle: 'Look for commingling',
|
|
17
|
+
checkDescription: 'Read the operating account and the trust journal and return every line that looks like client money in operating, firm money in trust, a firm expense paid from trust or a round trip, with the words that matched.',
|
|
18
|
+
sources: {
|
|
19
|
+
operating: { label: 'Operating account lines', args: ['operating'], fields: BANK_FIELDS, profiles: BANK_PROFILES },
|
|
20
|
+
journal: { label: 'Trust journal (transactions by matter)', args: ['journal'], fields: TRUST_FIELDS, profiles: TRUST_PROFILES },
|
|
21
|
+
},
|
|
22
|
+
configSchemas: { commingling_settings: SETTINGS_SCHEMA },
|
|
23
|
+
args, required: ['operating', 'journal'], run, checks: CHECKS,
|
|
24
|
+
item: { key: 'id', label: 'line', arg: 'line_id', kind: 'item' },
|
|
25
|
+
argDocs: { line_id: 'Line id from commingling_check (O-0002 is the second operating line, J-0004 the fourth trust journal row)' },
|
|
26
|
+
report: {
|
|
27
|
+
base: 'commingling',
|
|
28
|
+
title: { en: 'Commingling review', de: 'Prüfung auf Vermischung von Geldern', fr: 'Contrôle du mélange des fonds', es: 'Revisión de mezcla de fondos', pt: 'Revisão de mistura de recursos', it: 'Verifica della commistione dei fondi', ja: '資金混同の点検', zh: '资金混同检查', ko: '자금 혼합 점검' },
|
|
29
|
+
rows: (r) => r.items.map((i) => ({ id: i.id, account: i.account, date: i.date, matter: i.matter, client: i.client, amount: i.amount, description: i.description, status: i.status, findings: i.findings.map((f) => f.code).join(' '), reasons: i.findings.map((f) => f.detail).join(' '), owner: '', decision: '', notes: '' })),
|
|
30
|
+
htmlColumns: ['id', 'account', 'date', 'matter', 'amount', 'description', 'reasons'],
|
|
31
|
+
sections: (r) => [{ title: sectionTitle('by_rule'), rows: Object.entries(r.by_check).map(([rule, count]) => ({ rule, severity: CHECKS[rule].severity, count })), columns: ['rule', 'severity', 'count'] }],
|
|
32
|
+
limits: [LIMITS.files, LIMITS.rules, 'Lines are found by the words in your settings. A client payment described only as "deposit" is not caught; read the operating credits yourself as well.', LIMITS.trust, LIMITS.advice, LIMITS.phi],
|
|
33
|
+
},
|
|
34
|
+
refused: [
|
|
35
|
+
{ name: 'trust_transfer', category: 'move_money', description: 'Fairbrief Commingling never moves money between accounts.' },
|
|
36
|
+
{ name: 'operating_transfer', category: 'move_money', description: 'Fairbrief Commingling never moves money out of the operating account.' },
|
|
37
|
+
{ name: 'bar_report_submit', category: 'binding_send', description: 'Fairbrief Commingling never reports to a bar or bank.' },
|
|
38
|
+
],
|
|
39
|
+
prompt: {
|
|
40
|
+
name: 'commingling_review', title: 'Look for commingling',
|
|
41
|
+
description: 'Walks the host model through a commingling review with Fairbrief Commingling.',
|
|
42
|
+
arguments: [{ name: 'operating', description: 'Operating account lines under --root', required: true }, { name: 'journal', description: 'Trust journal', required: true }],
|
|
43
|
+
text: `You are helping a law firm keep client and firm money apart with fairbrief-commingling. Operating: {{operating}}. Journal: {{journal}}.
|
|
44
|
+
|
|
45
|
+
Rules: Fairbrief Commingling never moves money or reports to anyone; trust_transfer, operating_transfer and bar_report_submit are blocked. Lines are found by words, so say that a line described differently is not caught. Client names are pseudonyms.
|
|
46
|
+
|
|
47
|
+
1. Call commingling_check and list each finding with its amount.
|
|
48
|
+
2. Explain the errors with commingling_explain.
|
|
49
|
+
3. Call commingling_write_report.`,
|
|
50
|
+
},
|
|
51
|
+
});
|