Clears the way for a synthetic replacement fixture corpus to be tracked -
a blanket fixtures/ ignore would have hidden it too.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Several committed fixture/doc files (fixtures/*, docs/HSBC-USD-Sep2026.pdf,
docs/RBC-CAD-Aug26.pdf, docs/scanned_statement*.pdf, docs/scan_test_page-1.png,
docs/bank_statement_categorizer/description_rules.csv) contained a real bank
account number, a real organization name, and real transaction data - not
synthetic test data. Before pushing this repo to a remote for the first
time, these were stripped from the entire git history (git-filter-repo) and
restored to disk as untracked, gitignored files, so measure.py and manual
testing keep working locally but this data never reaches the remote.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The actual request was simple (store exports in R2 like source files,
pending a retention-duration decision), but investigating where
exports were written surfaced something worse: /api/process built and
saved a full workbook to disk on EVERY extraction, and nothing in the
frontend ever called /api/download/<filename> to retrieve it (confirmed
by grep - no reference anywhere). Every extraction was silently
orphaning an .xlsx file for no reason; 91 had already accumulated
locally from this session's own testing alone.
Removed the dead work entirely: /api/process no longer builds or saves
a workbook at all. /api/download/<filename>, file_repository.
save_workbook/resolve_output_path, and OUTPUT_FOLDER (env var, volume,
directory) are all gone - confirmed nothing else referenced any of
them before removing. outputs/ deleted, including its 91 accumulated
files.
/api/export (the only path actually used - Download Excel/All) now
builds the workbook into an in-memory BytesIO and streams it straight
from there - never touches disk, not even temporarily. The frontend
persists it long-term instead: documentsService.saveExportFile uploads
the same Blob the browser download already used to a new exportFile
field (pb_migrations/3_add_export_file.js), stored in R2 same as
sourceFile. Overwrites the previous export rather than keeping a
history - no retention policy has been decided yet, and keeping every
version would just relocate the same unbounded-growth problem from the
VPS to R2 instead of fixing it. Best-effort from ResultCard.vue - a
save failure is reported but never blocks the browser download itself.
Verified for real: /api/process's response no longer has `filename`
(title still does); /api/export still streams a valid, correctly-typed
.xlsx; /app/outputs no longer exists in the rebuilt container; the old
/api/download URL now falls through to the ordinary SPA catch-all, not
a leftover route. documentsService.saveExportFile run against the REAL
bytes /api/export produced, fetched back through the R2-backed URL,
confirmed byte-for-byte - and confirmed a second export overwrites
rather than creating a second record. measure.py unaffected; npm run
build passes.
New third service alongside app/docling - a deliberate, revisited
decision from the documented "no DB" architecture, not an oversight.
pocketbase/Dockerfile - official minimal pattern (no official image
exists), pinned binary, migrations+hooks copied in and run on startup.
pb_migrations/1_create_collections.js - schema as code: users (auth,
self-registration open), projects (owner-scoped), documents (owner-
AND project-scoped - project is REQUIRED, not optional, since a
planned future per-project category-mapping feature needs every
document scoped from day one), with a sourceFile field for the
original PDF/image (stored in R2 once configured).
pb_hooks/ensure_default_project.pb.js - auto-creates each new user's
"General" project (isDefault:true) the moment their account exists -
covers password and Google signup uniformly, guarantees the required
documents.project relation always has somewhere to point.
configure-secrets.sh - the only place R2/Google secrets are handled,
reading from a gitignored .env and PATCHing PocketBase's own REST API.
Never in a migration (those are committed to git).
Frontend: pocketbaseRepository.js (the one SDK instance),
authService.js (login/signup/Google/logout), authStore.js (Pinia,
synced to the SDK's own authStore), LoginView.vue, and App.vue's new
auth gate - talks to PocketBase directly, not proxied through Flask.
Verified via real REST API calls against the running container (not
just read): migrations create the expected collections/rules; a fresh
signup gets exactly one auto-created "General" project; a second
user's token can't see the first user's data; a document created with
no project correctly fails validation (confirming the frontend must
resolve one itself); authService's actual functions exercised via a
live Node script against the real container (signup, hook-created
project visible, logout, re-login). npm run build passes. measure.py
unaffected (no backend code touched).
Not yet verified - needs real R2/Google credentials this session
doesn't have: configure-secrets.sh itself, and the Google OAuth popup
flow (needs a real browser + real Google Cloud OAuth client, both
outside this repo's control - documented as setup prerequisites in
README.md).
This is Stage B.1 of 3 (schema + auth gate). B.2 (document persistence
moves from localStorage to PocketBase) and B.3 (the project sidebar
UI) are not started yet.
The pipeline previously had no OCR path at all - pdfplumber has zero OCR
capability (confirmed by building an image-only PDF from a real statement
page and watching extract_text() return nothing), and the only guard
against that case raised a misleading error ("could not recognize this
statement's column layout") written for a different problem entirely.
reconcile._needs_ocr() now distinguishes "no text layer at all" (a scan
or phone photo - routes to _run_ocr_only(), Docling's OCR as the sole
canonical source) from "has text, but this extractor doesn't recognize
the bank's layout" (unchanged, same error as before). docling_client's
new ocr_table_to_rows()/ocr_extract_pdf() reshape Docling's OCR'd table
into the identical row format table_extract.extract_page() produces, so
rows_to_transactions/extract_statement_facts run completely unchanged on
OCR'd data rather than duplicating that logic for a second engine.
Column-role resolution (_resolve_columns, shared with the existing
cross-check path) is now collision-aware instead of first-match-wins:
excludes a field when a header cell's text genuinely contains vocabulary
from two different fields at once (caught a real Docling mis-segmentation
bug this way, on an RBC page), while still correctly resolving two
separately-clean columns that both legitimately match the same field
(HSBC has two real date columns) and not confusing "amount" nested inside
"credit amount" for contamination. Took two iterations against the real
fixture corpus to get both cases right at once.
An OCR-sourced extraction can never reach "Verified" (checks.py's new
check_ocr_source, always needs_review) - there's no second engine to
cross-check Docling's OCR against, so the safety property every other
check rests on doesn't hold here.
The upload UI now accepts .jpg/.png in addition to .pdf.
Real-world reliability is honestly unresolved, not assumed solved - see
CLAUDE.md's new "OCR / scanned statements" section for four real test
renders this session and exactly what did and didn't work. The routing
and reshaping logic itself is verified correct (confirmed through the
real running app, both a text-PDF upload and a raw-image upload); whether
a given scan or photo actually extracts anything depends on Docling's
own, inconsistent table-structure recognition on that specific image.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Bettersight Statement Extractor as of Phase 1 build: bank-agnostic pdfplumber
extraction, Docling cross-check, the 6+1 checks, Excel export, and the
minimal web UI - all built and working.
Adds the measurement harness (measure.py) from the plan's step 10: runs
every fixtures/*.pdf with a matching *_ground_truth.xlsx against the real
pipeline, diffs date/description/amount/balance per transaction, and logs
a dated JSON result under results/. Also adds hand-verified ground truth
for the HSBC Sep statement and a new RBC fixture (RBC-CAD-Aug26.pdf, sourced
from docs/) with its own hand-verified ground truth - RBC extraction now has
regression coverage it previously lacked.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>