Document the real-fixture removal and synthetic replacement corpus
Records, in CLAUDE.md's own established voice/discipline, why the real HSBC/RBC fixtures (and a handful of docs/ files) were stripped from git history before this repo's first remote push, and how fixtures/generate_synthetic_fixtures.py replaces measure.py's now-empty regression corpus with two fully-synthetic statements - what was built, why, and what running python3 backend/measure.py actually confirmed. Also updates the stale "Outstanding before Phase 1" checklist bullet that still described the real fixtures as currently committed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
18494a0f19
commit
41c42690ab
83
CLAUDE.md
83
CLAUDE.md
|
|
@ -5314,6 +5314,83 @@ decision. If that turns out to matter in practice (e.g. the same new bank layout
|
|||
showing up for two of one bookkeeper's own clients), it's a new, separate feature
|
||||
request to design later, not something this decision already covers.
|
||||
|
||||
**Real fixtures removed from git history, replaced with a synthetic corpus,
|
||||
2026-11-24 - ahead of this repo's first push to a remote.** Before this repo had
|
||||
ever been pushed anywhere, a check of what it actually tracks found that
|
||||
`fixtures/HSBC-USD-Sep2026.pdf`/`HSBC-USD-August2026.pdf`/`RBC-CAD-Aug26.pdf` (plus
|
||||
their own `_ground_truth.xlsx` siblings) and a handful of `docs/` files
|
||||
(`docs/HSBC-USD-Sep2026.pdf`, `docs/RBC-CAD-Aug26.pdf`, `docs/scanned_statement.pdf`,
|
||||
`docs/scanned_statement_2page.pdf`, `docs/scan_test_page-1.png`,
|
||||
`docs/bank_statement_categorizer/description_rules.csv`) all contain REAL financial
|
||||
data, not synthetic test material - a real account name ("PLANETERRA INTERNATIONAL
|
||||
FOUNDATION"), a real account number, and a real Royal Bank of Canada business
|
||||
account statement, confirmed by actually reading the PDFs' own extracted text
|
||||
(`pdftotext`), not assumed from the filenames. These had been sitting in this
|
||||
repo's git history since the very first commits this file documents, entirely
|
||||
unflagged at the time - this repo's own "no DB, no PII" framing never actually
|
||||
applied to its own test fixtures.
|
||||
|
||||
Fixed in two parts, both completed BEFORE the first push: all of those files were
|
||||
removed from EVERY commit in git history (not just the latest) via `git-filter-repo
|
||||
--invert-paths`, confirmed clean afterward (`git log --all -- <path>` returns
|
||||
nothing for any of them); the real files themselves were then restored to disk from
|
||||
a backup and re-added to `.gitignore` by EXACT filename (not a blanket `fixtures/`
|
||||
ignore, which would have hidden a future synthetic replacement fixture too) -
|
||||
`measure.py` and manual local testing keep working off the real files, they just
|
||||
never reach the remote.
|
||||
|
||||
**This left `backend/measure.py`'s whole regression corpus empty from a fresh
|
||||
clone** - `fixtures/` had nothing else in it, so removing those three pairs left
|
||||
nothing committed for `measure.py` to discover at all; a clone on another machine
|
||||
(or a different environment, like the one that built the fix below) would see zero
|
||||
fixtures. Fixed the same day with `fixtures/generate_synthetic_fixtures.py`
|
||||
(reportlab + openpyxl) - two invented bank statements (fake org names, fake account
|
||||
numbers), each built from one shared Python list of transaction data used to write
|
||||
BOTH the PDF and its own `_ground_truth.xlsx`, so the two can never drift apart by a
|
||||
transcription mistake the way a hand-verified real fixture's ground truth could.
|
||||
Deliberately keeps every description on a single line with its amount on the same
|
||||
line - no attempt to replicate HSBC's trailing-"Narrative"-label convention or
|
||||
RBC's leading-wrap convention; that row-grouping complexity is already proven
|
||||
elsewhere in this file's own history and isn't this corpus's job to re-prove, and
|
||||
skipping it is what makes the ground truth exactly derivable from the generator's
|
||||
own data rather than needing a human to re-verify it page by page the way the real
|
||||
fixtures' own ground truth was built.
|
||||
|
||||
Two genuinely different column shapes, still exercising the "bank-agnostic" claim
|
||||
this harness exists to prove: `Fake-Bank-A-Synthetic` (split Debit/Credit columns,
|
||||
newest-first order, no in-table opening/closing balance - HSBC-style, debit printed
|
||||
as a plain positive magnitude rather than self-signed) and `Fake-Bank-B-Synthetic`
|
||||
(a single signed Amount column, oldest-first order, WITH in-table Opening
|
||||
balance/Closing balance rows - RBC-style). Column x-positions were tuned against
|
||||
real `reportlab.pdfbase.pdfmetrics.stringWidth` measurements and a real
|
||||
`_find_zones()` debug run, not hand-calculated and trusted blind - a first draft's
|
||||
description column sat close enough to the date zone's own computed upper bound
|
||||
that every row's description bled its own first word into the date field (and, for
|
||||
Fixture B specifically, broke the exact-phrase match its Opening/Closing balance
|
||||
rows depend on) - caught by actually running the real extractor against the
|
||||
generated PDF before ever treating it as finished, the same discipline this file's
|
||||
own history already insists on everywhere else.
|
||||
|
||||
**Verified, all real:** `python3 backend/measure.py` against the full 5-fixture
|
||||
corpus (the two new ones alongside the three real, still-local ones) - both new
|
||||
fixtures report `field_accuracy=1.0`, zero count mismatches, and correct
|
||||
opening/closing balance matches (`None`/`None` for Fixture A, matching
|
||||
`extract_statement_facts`' own real behavior for a layout with no in-table balance;
|
||||
the real printed figures for Fixture B). Neither reaches "Verified" in THIS
|
||||
environment specifically because the Docling container isn't running here - every
|
||||
page degrades to pdfplumber-only (`engine_agreement` = `needs_review`), which is
|
||||
`measure.py`'s own already-documented degraded mode ("Works with or without the
|
||||
Docling container up... same behavior as the live app"), not a defect in either
|
||||
fixture - confirmed by running every other check directly and seeing
|
||||
`statement_balance`/`running_balance`/`date_sanity`/`structure_sanity`/
|
||||
`page_coverage`/`narrative_direction` all pass cleanly for both. The three real
|
||||
fixtures were re-measured in the same run and are unaffected (same field accuracy,
|
||||
same statuses modulo the one expected Docling-unavailability difference: RBC reads
|
||||
"Needs review" here rather than its documented "Failed", since reproducing that
|
||||
real page-4 engine MISMATCH needs Docling to actually respond and disagree, not
|
||||
just be unreachable - HSBC-Aug's own "Failed" is untouched, since that one comes
|
||||
from a real running-balance break, not engine agreement at all).
|
||||
|
||||
## Frontend / UI state (as of 2026-10-13)
|
||||
|
||||
**Theme is enterprise-light, not the Bettersight brand default.** `UI_DESIGN_THEME.md`
|
||||
|
|
@ -5610,6 +5687,12 @@ restructure; the behavior itself predates it and is unchanged:
|
|||
(see below) the same way — all 31 transactions visually confirmed page-by-page,
|
||||
including the two blank-balance rows and the Cancelled wire around the
|
||||
`running_balance` flag (also `None`/`None` opening/closing, same reason as Sep).
|
||||
**These three real fixtures were removed from git history outright on
|
||||
2026-11-24 and replaced with a fully-synthetic corpus** - see "Real fixtures
|
||||
removed from git history, replaced with a synthetic corpus" under Key
|
||||
decisions & lessons. This bullet is kept as the accurate historical record of
|
||||
what was originally built and verified, not as a description of what
|
||||
`fixtures/` currently holds in git.
|
||||
- [x] `git init` this repo — done 2026-10-11, initial commit `16f74f7`.
|
||||
- [x] Decide whether a `README.md` is wanted — yes; added 2026-10-12. Short: what the
|
||||
product is, `docker compose up`, project layout, `measure.py` usage, and a pointer
|
||||
|
|
|
|||
Loading…
Reference in New Issue