New backend/services/suggested_fixes_service.py, wired into
pipeline_service.py's run()/recheck() (both now return a suggestions
list alongside status/checks - no new endpoint needed).
Three patterns, tried in order so a row already explained by a sign
flip isn't also offered a digit-level fix: debit/credit swapped,
transposed digits, OCR digit misread. Each is tested empirically -
apply the candidate value to a copy of the real transactions and
re-run the actual check_running_balance - rather than hand-derived
from that check's own bridging/direction math, which is both safer
and simpler than tracing which row a bridged, auto-direction-detected
mismatch is "really" about.
"Date format swapped" was investigated and found not to apply to this
pipeline's data at all, documented directly in the new module's own
docstring rather than silently skipped: by the time a transaction
reaches this module its date is already normalized to "DD Mon YYYY"
(month already a name, not a number), so the raw numeric day/month
ambiguity that pattern addresses was already resolved upstream at
extraction time.
A real bug, found by the first end-to-end test and not by reading the
code: the running-balance check's own bridging logic means a mismatch
recorded at row i can be caused by row i or row i-1's amount - the
backend already tried both as fix candidates, but the frontend matched
a suggestion to a row by the fix target's own index, while the flag
icon only ever appears on the row the mismatch itself is reported
against. Confirmed for real: corrupting row 5 surfaced the mismatch on
row 6, so the correct suggestion (fix row 5) was completely unreachable
from the UI. Fixed by adding flag_index (the row shown flagged)
alongside index (the row the fix applies to) - TransactionRow.vue now
looks up by flag_index and always applies to suggestion.index.
TransactionRow.vue's suggestion UI lives in R.2's same flag-detail
panel; "Apply fix" runs the same save->persist->recheck pipeline a
manual edit already uses. extractionStore.applyCheckResults now
re-applies suggestions on every recheck, not just once, so a stale one
a manual edit already resolved disappears on its own.
Verified: three corruption patterns run through the real container via
curl against a known-good fixture, each detected and correctly
reverse-fixed at the right index. The real HSBC-Aug Cancelled-wire
mismatch (a genuine non-error case) correctly produces zero
suggestions. The full apply->persist->recheck->restore round trip
executed directly against real Pinia plus the real running PocketBase,
confirming the persisted record (not just local state) reflects the
fix. measure.py unaffected.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>