Commit Graph

29 Commits

Author SHA1 Message Date
JasonFraser 87b978f837 Add the Google logo to the Continue with Google button
Same official 4-color "G" logomark PocketBase itself serves (the exact
SVG confirmed from the live /api/collections/users/auth-methods
response while verifying the OAuth2 setup) - same button on both the
sign-in and sign-up views, since they're the same form with a mode
toggle, not separate pages.
2026-10-13 01:24:16 -04:00
JasonFraser c1df28fb78 Verify real R2/Google credentials; document the placeholder-password catch
configure-secrets.sh run for real against the user's actual R2 bucket
and Google OAuth client, confirmed via /api/settings, /api/collections/
users, and /api/collections/users/auth-methods (the exact endpoint the
frontend SDK calls). Round-tripped an actual file through R2 end to
end - created a document with a real multipart upload, fetched it back
via PocketBase's own file URL, confirmed the exact bytes.

Caught before any of this ran: the superuser email/password in .env
were still .env.example's literal placeholders even after R2/Google
values were filled in - flagged and confirmed with the user before
upserting a well-known default credential on an account with full
admin access to every user's data.
2026-10-13 01:22:25 -04:00
JasonFraser 35b378751f Fix oversized gap between login form fields
.fields > div's flex:1 1 180px is a WIDTH basis meant for the
horizontal balance-fields row - in LoginView's column layout that same
180px became a HEIGHT basis instead, stretching each email/password
wrapper to ~180px tall. Not padding/margin, a flex-basis axis mismatch.
2026-10-13 00:33:04 -04:00
JasonFraser 94096554e9 Add PocketBase: accounts (password + Google) + schema for R2-backed docs
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.
2026-10-13 00:26:41 -04:00
JasonFraser 84261c25ef Move document nav into the transactions card; raise panel height 25%
DocumentNavBar no longer sits in its own standalone div above both
panels - it's now rendered inside TransactionsTable.vue, across the
top of the transactions card, above the Hide/Show Source Doc row, with
no border/background box of its own (already inside the card's). Still
disappears via the same v-if once there's nothing to navigate between.

.pdf-col/.txn-col height raised from 82vh to 102.5vh (25% more), both
panels still matching each other exactly.
2026-10-12 21:19:54 -04:00
JasonFraser ec58a956e9 Accumulate staged files across picks instead of replacing them
Picking/dropping a file replaced whatever was already staged (reported:
"I select one document and start again to select another, the first
one is replaced"). setFiles now appends instead, deduping exact
name+size repeats, so a batch can be built up across several separate
picks/drops, not just one multi-select dialog.

Each staged file gets an x to remove it before Extract is clicked.
The staging list is cleared the moment Extract runs (not after it
resolves), so an already-handed-off file can't linger and get
re-processed - and duplicated, since extractionStore.documents has no
dedup of its own - by a later click.

Also resets the native file input after each pick so re-selecting the
same file (e.g. after removing it) still fires a change event.
2026-10-12 21:06:53 -04:00
JasonFraser 2081bc574b Multi-file upload, sequential extraction, prev/next navigation, Download All
extractionStore restructured from a single currentResult into a list
of documents + activeIndex, so a batch of files can be extracted
sequentially (useBatchExtraction.js replaces useExtraction.js) with
"Extracting N/M: filename" progress, and browsed afterward via
DocumentNavBar's prev/next. currentResult/currentDocKey/
flaggedIndexes/effectiveOpeningBalance/effectiveClosingBalance stay
getters with their exact old names (now derived from activeDocument),
so ResultCard.vue and most of TransactionsTable.vue needed no changes
beyond the balance-input v-model bindings.

Two choices from the plan were revised after user review before any
code was written: focus never moves on its own except to show the
very first result (a later file finishing mid-batch never yanks the
user away from whatever they're reviewing or editing), and a Download
All button sits beside Download Excel, shown once a multi-file batch
has actually finished.

Restore-on-reload generalized from one document to a whole batch
(lastBatchKeys/appendToLastBatch replace lastDocKey; persistResult now
saves {fileName, result} with a backward-compatible fallback for the
old bare-result shape).

Two real bugs caught in review before ever reaching a browser:
TransactionRow was keyed only by row index (could reuse a stale
component's draft across documents sharing an index - fixed by keying
on docKey+index too), and addDocument called recomputeFlags() which
only ever targets the active document (a document added while focus
stayed elsewhere would never get its own flaggedIndexes computed -
fixed by computing flags directly for whichever document was just
added, not just the active one).

Verified: npm run build; every new/changed store action and getter
executed directly against real Pinia with synthetic multi-document
scenarios; the real Docker container rebuilt and hit with sequential
/api/process calls confirming identical results to the pre-change
baseline; measure.py unaffected (no backend code touched). No backend
changes anywhere - /api/process|recheck|export already each take
exactly one file/document per call.
2026-10-12 21:00:07 -04:00
JasonFraser 5cc1fe1ca7 Close the three Phase-1 loose ends: README, stray fixture, check findings
Add README.md - what the product is, docker compose up, project
layout, measure.py usage, pointer to CLAUDE.md for the deeper record.

Delete fixtures/ground_truth_sep_reference.xlsx - a bank-description
to accounting-category mapping from the separate bank_statement_
categorizer tool, not this product's own extraction ground truth, and
referenced nowhere in this repo. Nothing to repurpose it into, since
this product deliberately doesn't categorize transactions at all.

Investigate HSBC-Aug's running_balance failure and both fixtures'
engine_agreement findings - confirmed not extraction bugs. Built and
hand-verified fixtures/HSBC-USD-August2026_ground_truth.xlsx (all 31
transactions checked against the rendered PDF, including the Cancelled
wire and its two blank-balance rows) to prove it: 1.0 field accuracy.
The running_balance break is the Cancelled wire's -22,386.00 genuinely
not applying to the real balance chain - the check correctly flagging
that, not smoothing it over. engine_agreement on both fixtures is
Docling missing a table and pdfplumber's result being used instead,
exactly as designed, correctly flagged for lower confidence rather
than silently trusted.
2026-10-12 19:54:03 -04:00
JasonFraser da1b8b325e Fix RBC's last transaction absorbing the Account Fees footer line
RBC prints "Account Fees: $48.75" directly under "Closing balance" on
the statement's last page - not a money token this module recognizes
("$48.75", not "48.75"), no reference-number prefix, no page-number
pattern, so it fell through to plain narrative text and landed on the
last real transaction's description via the trailing-leftover-buffer
rule (correct behavior for a GENUINE trailing narrative line, wrong
for this one).

Fixed by treating the closing-balance line as a position-based
boundary, the same way the header row already is: once extract_page()
recognizes it, every subsequent line on that page is skipped outright
rather than reaching money/narrative classification at all. A no-op
for HSBC, which never emits a closing_balance row in the first place.

measure.py: RBC field accuracy 0.9977 -> 1.0, HSBC unaffected. RBC's
overall status is still "Failed" after this - a separate, pre-existing
engine_agreement disagreement on page 4, not touched by this fix.
2026-10-12 19:31:54 -04:00
JasonFraser 16da683551 Remove the seam between the header row and the filter row
Both sticky rows kept their own border-bottom (inherited from the
base th rule), which read as a thin visible gap between them. The
header row no longer draws one - the filter row's own border is the
single line that should separate the whole sticky header block from
the scrolling data beneath it.
2026-10-12 18:13:11 -04:00
JasonFraser 94864273c8 Fix resizer-narrowed transactions column: overflow, not a viewport bug
Dragging the resizer narrow on a wide screen never triggered the
existing @media(max-width:640px) stacked layout, since that only
watches the viewport, not the column itself - so the balance fields
and Recheck Balance button just overflowed the column's right edge
instead. Gave .txn-col container-type:inline-size and replaced that
media query with an equivalent @container rule, which also covers
the genuine-mobile case the old rule handled (the column is just as
narrow as the viewport there too).

Same root cause was squeezing the transactions table's Description
column unreadable: table-layout:fixed + width:100% shrinks every
column proportionally to fit, fixed-pixel ones included. Gave the
table a min-width (fixed columns' sum + a legible floor for
Description) so .table-wrap's overflow-x:auto takes over with a
horizontal scrollbar instead of compressing Description further.
2026-10-12 18:09:16 -04:00
JasonFraser 7af1749887 Fix sticky header/filter-row stacking collision; drop dead-space note
Header row and filter row both stuck to top:0 via one shared rule,
so the filter row (later in the DOM) visually covered the header row
on scroll instead of stacking beneath it. Gave the header row an
explicit height and offset the filter row's own sticky top by that
amount so they stack correctly.

Also removed the now-empty <div class="note"> left over after its
instructional text was deleted - it was still taking up margin-bottom
space above the table for no reason.
2026-10-12 08:07:12 -04:00
JasonFraser 534907626c Give the balance input and Recheck button equal explicit heights
Matching just the top edge (via the label-height spacer) wasn't
enough - the button's own padding made it naturally shorter than a
balance input, so the two boxes still looked slightly off-center
against each other. Both now get the same explicit height with the
button's text flex-centered inside it.
2026-10-12 07:58:03 -04:00
JasonFraser 12e18ae235 Align Recheck button with balance inputs; add table sort/filter/search
- Recheck Balance now lines up with the balance input fields on wide
  viewports via an invisible label-height spacer, instead of the row's
  top edge.
- Each transaction column gets its own up/down sort arrows, plus a
  filter row beneath the header (Description doubles as search, Status
  is a dropdown of values actually present). Sorting/filtering never
  disturbs row identity - edits and flags still target the original
  index, not the displayed position.
2026-10-12 07:53:36 -04:00
JasonFraser 37fdd0f235 Surface the "not_available" balance-check reason too, not just "fail"
The mismatch note only handled outcome === 'fail'. A statement with no
typed or auto-detected balance at all returns "not_available" instead,
which was left just as silently grey as "fail" used to be before the
last fix.
2026-10-12 07:41:48 -04:00
JasonFraser 92979f7de7 Show why the balance doesn't match, not just a grey readout
Grey (vs green) on the calc-readouts said something was wrong but never
what - the actual explanation (the statement_balance check's own detail
text, with the full math and "off by \$X") only existed in the checks
list, which starts collapsed by default, with no visible link back to
the readouts near the balance fields.

Surfaces that same detail text directly under the balance fields/Recheck
button when the check outcome is "fail" - no new backend call or logic,
just showing what was already being computed and returned, in the place
the user is actually looking.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 07:21:52 -04:00
JasonFraser 15e163267e Add explicit Recheck Balance button for post-extraction balance entry
Typing opening/closing balance AFTER extraction (e.g. the user forgot to
fill it in before clicking Extract) never did anything on its own - the
fields were only ever read by some OTHER trigger (a row Save, or
Download). Confirmed this gap predates the Vue rewrite - the original
vanilla-JS version had the identical behavior.

Adds a "Recheck Balance" button (TransactionsTable.vue) that re-runs the
same recheck-only (no re-extraction) call a row Save already makes,
using whatever's currently in the balance fields - an explicit,
deliberate trigger rather than auto-firing on blur, matching the
existing per-row Save pattern (edits/entries only take effect when
confirmed). Positioned at the row's own right edge, aligned under the
Hide/Show Source Doc toggle above it; drops below the closing-balance
field at mobile widths (a new 640px breakpoint, separate from the
860px one the overall layout already used).

Verified end-to-end against the real backend: uploaded a statement with
no balance supplied (statement_balance: not_available), then called
/api/recheck with balances added afterward - the check correctly
recalculated and reported the result, the same request shape and
endpoint the new button uses.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 07:17:51 -04:00
JasonFraser 1ab3d1bb42 Actually fix the height mismatch - .pdf-col itself had no fixed height
The previous commit fixed .txn-col but missed the real asymmetry: only
.pdf-col's CHILD (iframe/img-preview-wrap/empty-panel-source) was pinned
to 82vh - the .pdf-col CARD itself had no height of its own, so its real
total height was 82vh plus pdf-col-head's own height plus the card's
padding, taller than .txn-col's flat 82vh. Visually this is exactly
"transactions panel is shorter."

Applied the identical fixed-height-flex-column pattern to .pdf-col that
.txn-col already had: height:82vh on the card itself, pdf-col-head
flex-shrink:0, and the child (iframe/img-preview-wrap/empty-panel-source)
changed from height:82vh to flex:1 1 auto; min-height:0 so it fills
whatever space remains under the head - both columns are now driven by
the same fixed value through the same structural pattern, which is what
actually guarantees matching heights (one side being content-driven and
the other fixed can't reliably match, regardless of what the fixed value is).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 06:55:14 -04:00
JasonFraser 0ec44dd28a Match Transactions panel height to Source Document panel
.pdf-col's height came from its child (iframe/img-preview-wrap/
empty-panel-source, all fixed at 82vh); .txn-col had no height of its
own, just whatever its header+fields+notes+table content needed - the
two columns drifted apart whenever txn-col's content was taller than
82vh on its own.

.txn-col is now flex-column with a fixed height:82vh, matching its
sibling exactly; the table area (table-wrap, or empty-panel-table when
there's no result yet) is the one piece that absorbs whatever space is
left after the header/fields/notes above it (flex:1, min-height:0 so its
own overflow-y:auto scroll still works within that constrained space),
rather than the whole column growing taller than 82vh.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 06:53:00 -04:00
JasonFraser bcebc50466 Show Source Document and Transactions panels before upload
The opening/closing balance fields live in TransactionsTable, which was
only rendered after a successful extraction - so there was no way to
type a balance before clicking Extract, even though both fields are
submitted as part of that same request. Confirmed this wasn't introduced
by the Vue rewrite - the original vanilla-JS version had the identical
behavior (#resultSection stayed display:none until renderResult ran).

Both panels are now always visible. Each shows an empty-state message
("No Source Document to Display..."/"No Transactions to Display...")
until there's something real to show instead - SourceDocumentPanel until
a file is chosen, TransactionsTable's table (not the balance fields
above it) until an extraction result exists.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 06:50:04 -04:00
JasonFraser 6e4da3f385 Restructure frontend to Vue 3 + Vite (Stage 2 of 2)
Rebuilds templates/index.html (896 lines of vanilla JS, no framework, no
build step) as frontend/, a Vue 3 app per ENTERPRISE_STANDARDS.md's
frontend layering (views -> components -> composables -> services ->
repositories, Pinia for stores) - same agreed scope as Stage 1 (backend):
structure + commenting, not the full SaaS-shaped doc.

The full original file was read in full before starting (every function
enumerated against the plan, not re-derived from memory) to make sure
nothing documented in CLAUDE.md's "Frontend / UI state" section got
simplified away: sticky side-by-side layout with a draggable resizer,
Hide/Show Source Doc, collapsible Result card, per-row pencil-to-edit,
comma-formatted numbers, localStorage persistence with a restore banner,
image zoom controls, the pencil-icon-color and description-autogrow
fixes from earlier this session.

The original ask that started this whole detour - processing-phase text
with an animated ellipsis during /api/process - lands here as the one
genuinely new feature (useProcessingPhases.js + ProcessingIndicator.vue),
honestly simulated rather than claiming real progress (the backend is
one synchronous request with no streaming signal).

backend/app.py now serves frontend/dist (built via a new Dockerfile
multi-stage build: a node stage runs npm ci && npm run build, the Python
stage copies backend/ + that dist/ output) instead of rendering a Jinja
template - a manual SPA-fallback route serves a real static asset if one
exists at the requested path, else index.html. One real bug caught and
fixed before this ever ran: the first version also left Flask's own
automatic static route enabled, registering a duplicate/conflicting rule
against the same /<path:...> pattern as the manual catch-all - fixed by
disabling Flask's own static handling (static_folder=None) entirely.

Verified without a browser (the extension could not connect, tried
repeatedly): npm run build succeeds, formatService.js's pure functions
tested directly in Node, every prop/emit/store reference cross-checked
by hand across all ~20 new files, and full regression through the real
Docker container (SPA serving, static assets, /health, /api/* routing,
dual-engine extraction, measure.py - all unaffected or identical to
baseline). Actual interactive behavior - upload, drag/drop, the
processing-phase animation, editing, zoom, the resizer, persistence/
restore, download - was verified by the user in their own browser, not
by Claude. templates/index.html was kept in place as a fallback until
that confirmation came back, then deleted.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-12 06:32:49 -04:00
JasonFraser 081ab6ac50 Fix OCR-sourced detection in pipeline_service.recheck()
ocr_only detection only matched page_reports status "ocr_only", not
"ocr_raw_words" - if every page of a recheck needed the per-page
raw-OCR-words fallback (Docling failed on all of them), this incorrectly
treated the recheck as non-OCR-sourced, letting it reach "Verified" when
there was no second engine to earn that on. Now checks membership in
("ocr_only", "ocr_raw_words").

Verified directly (not just via measure.py, which never exercises
recheck()): an all-ocr_raw_words page_reports now correctly surfaces the
ocr_source check and stays below Verified; a mixed ocr_only/ocr_raw_words
case does the same; a normal dual-engine case is unaffected - confirmed
both as a direct function call and through /api/recheck on the real
running app. measure.py confirms zero regression elsewhere.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-11 23:49:44 -04:00
JasonFraser 01cd607728 Fix edit-icon color, description autogrow, and add image zoom controls
Three small UI fixes from earlier testing, never committed:

- Pencil edit icon now uses the same blue accent token the Save button
  already does (.row-btn.edit), instead of the default muted gray.
- Description textarea boxes left stale blank space after hiding the
  Source Document panel - the drag-resizer already re-measures box
  height on resize (autoGrowAll()), but the Hide/Show toggle never did,
  so widening the transactions column left every description box at its
  old height until something else happened to trigger a re-measure.
  Added the missing call.
- Images shown in the Source Document panel had no zoom controls at all
  (unlike PDFs, which get the browser's native viewer toolbar for free).
  Added a dedicated zoomable/scrollable image panel with -/+/Fit
  controls, width-based zoom (not CSS transform, so the panel's
  overflow:auto actually produces real scrollbars when zoomed in),
  opening at fit-width by default.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-11 23:44:06 -04:00
JasonFraser 054e2a1b60 Add raw-OCR-word-box fallback for Docling table-structure failures
Docling's own OCR engine swaps (tesseract, rapidocr) and table_mode
(fast vs accurate) were all benchmarked against the same problem page
and made no difference - confirmed the table-structure model itself
(TableFormer), not the OCR engine, is the bottleneck (see CLAUDE.md).

app/raw_ocr_extract.py sidesteps TableFormer entirely: runs OCR
directly (tesserocr) for raw per-word text+position, then reuses
table_extract.py's own column-geometry logic (_find_zones/_classify_
money/etc) to derive columns from word positions, the same way it
already does for native PDFs. Two real adaptations: pixel-to-point
scaling (exact for a scanned PDF via its own known point dimensions,
heuristic for a bare photo), and cross-page zone sharing (a page with
one-sided data, e.g. zero debits, can't reliably resolve its own
columns alone - confirmed for real on HSBC page 1 - so zones resolve
from whichever page is most complete and apply across the whole
document, deterministically fixing the sign-assignment bug a single
page alone can't).

Wired into reconcile._run_ocr_only as a PER-PAGE fallback, not
document-level - confirmed necessary for real: Docling succeeded on
one page and silently missed another's table in the same conversion
call, which a document-level "did any page work" check would have
missed entirely (10 real transactions, including debits, would have
vanished with no error).

Verified end-to-end through the real running app on a genuine 2-page
scanned test file (docs/scanned_statement_2page.pdf, built from real
HSBC pages 1+2): 17/17 transactions, correct signs and balances,
date_sanity correctly flagged the one real OCR misread. measure.py
confirms zero regression on the existing text-PDF corpus.

New dependencies: tesserocr, pypdfium2, pillow (Python) plus
tesseract-ocr/libtesseract-dev/libleptonica-dev (OS, Dockerfile).
TESSDATA_PREFIX must be set explicitly - tesserocr doesn't reliably
auto-discover Debian's tessdata path on its own.

Known limitation, documented not hidden: the one-sided-data edge case
is only reliably fixed with a second page to borrow zones from - a
true single-page photo upload has no such fallback and stays a close
geometric call.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-11 17:22:34 -04:00
JasonFraser 9bfe0a6252 Scrap the PaddleOCR benchmark implementation
PaddleOCR (PP-StructureV3) performed worse than Docling on the same test
image - see the prior commit's findings, condensed into a short historical
note in CLAUDE.md rather than kept as unused code. Also removed the local
.venv_paddle environment (1.1GB, was gitignored, never tracked).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-11 16:13:17 -04:00
JasonFraser 8ade2d3c5b Add standalone PaddleOCR benchmark - loses to Docling on the same image
app/paddleocr_client.py is a self-contained adapter (own column-resolution
logic, not imported from docling_client.py) that reshapes PP-StructureV3's
table output into the same canonical row format Docling's OCR path uses,
so it plugs into the real table_extract.rows_to_transactions/checks.run_all
pipeline unchanged - not just a raw-OCR-text comparison. Not wired into
reconcile.py or added to requirements.txt/Dockerfile; needs its own Python
3.11 venv (paddlepaddle has no wheel for the main app's Python version).

Run against docs/scan_test_page-1.png - the exact image Docling struggled
with - PP-StructureV3 did worse: its table HTML was more severely corrupted
(mismatched colspans, cell content from different rows jumbled together),
and while its best header-row candidate recovered status/date/credit/debit
correctly, the "Balance" column header was lost entirely with no recoverable
cell anywhere, one field short of usable. 0 transactions extracted, verified
through the real pipeline functions. See CLAUDE.md's "OCR / scanned
statements" section for full detail.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-11 16:11:05 -04:00
JasonFraser e4e43618b7 Route scanned/photographed statements through Docling OCR
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>
2026-10-11 09:04:24 -04:00
JasonFraser 84302e28b3 Update CLAUDE.md to reflect measure.py, RBC fixture, and git init
Marks the three items done in the previous commit as complete in the
outstanding checklist, with detail on what was verified and how; flags
the two things that surfaced in the process but are still open: the
mismatched (categorization, not extraction) ground_truth_sep_reference.xlsx,
and the pre-existing HSBC-Aug/RBC check failures measure.py now makes visible.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-11 07:57:22 -04:00
JasonFraser 0b0960769b Initial commit: Phase 1 extraction, dual-engine checks, measurement harness
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>
2026-10-11 07:56:19 -04:00