Commit Graph

2 Commits

Author SHA1 Message Date
JasonFraser c18492bee4 Layout mapper L.8: superuser review screen (completes the L.1-L.8 plan)
New AdminLayoutReviewView.vue (/admin/layouts), rendered by App.vue
outside the normal authStore-gated shell entirely - a PocketBase
superuser is never a `users` record. Its own inline login against
pbAdmin's `_superusers` collection; lists every private mapping across
every owner (a superuser session bypasses collection rules); each row
expands into a read-only SourceDocumentPanel inspection (reusing L.7's
labeled-strip pattern) plus an Approve action that promotes straight to
shared, independent of the two-user confirmation hook.

adminLayoutsService.js gains getSourceDocument()/sourceFileUrl(), both
routed through pbAdmin since the mapping's sourceDocument belongs to its
owner, not the superuser.

Verified end to end against the real running stack (15 assertions via
the actual service files, not reimplementations): a fresh app user's
private mapping is visible to and approvable by the real superuser, its
source file round-trips byte-for-byte, and a completely independent
third-party user immediately resolves the now-shared mapping via
findByFingerprintHash. npm run build passes; app container rebuilt.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-15 05:30:14 -04:00
JasonFraser 92ba5f4386 Wire frontend fingerprint-lookup orchestration for the layout mapper (L.4)
useBatchExtraction.js now reacts to a needs_mapping:true response: looks up an
exact or near-match layout mapping (layoutMappingsService.js), applies it silently
on an exact match, asks for confirmation on a stale exact match or a near match via
a real ConfirmModal wired through ExtractorView.vue (not a placeholder), and falls
through to reason:'no_match' when nothing matches (the manual mapping screen's own
entry point, not built yet). A used mapping's usage is recorded for drift detection
and persisted onto the saved document record.

Found and fixed two real bugs in the near-match comparator by testing it against
the spec's own documented example (Debit/Credit renamed to Withdrawals/Deposits):
compute_fingerprint was building header_labels from whole header LINES instead of
per-field label text, making a two-word rename indistinguishable from a totally
different layout; added a field_labels map so the comparison is per-field. Even
after that, the first 70% overlap threshold still failed the documented example
itself (a 4-field rename of 2 fields is exactly 50%) - corrected to 50%, derived
from the example's own real numbers.

Verified: 18 assertions against the real layoutMappingsService/useLayoutMapping
(hard gates, the corrected per-field overlap, real PocketBase ownership/sharing
rules, stale-mapping decline/accept, no-match reporting); the real rebuilt
container's /api/process response now carries the fixed field_labels shape;
measure.py byte-identical throughout; npm run build passes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-14 19:51:42 -04:00