Grilled 2026-07-16 with the user; full decision record in
docs/expiry-tracking-plan.md. Core reframe: expiry is captured once per
batch at DO intake (staff-typed on the stock-entry confirmation page, from
the physical packs), so the cashier scan only MATCHES OCR fragments against
the 1-3 known in-stock batch dates instead of free-reading damaged
dot-matrix prints (proven model-capability ceiling, 2026-07-15). Fallback:
auto-FEFO + 'inferred' flag, zero cashier interaction. No cloud, ever.
- docs/expiry-tracking-plan.md: architecture, matching algorithm spec
(resolveExpiryFromEvidence), schema/API deltas, phases 1-3, testing plan
- backend plans §13 (13.1-13.4): matcher util + offline tuning, route
wiring + expiry_source provenance, multi-frame union, dot-matrix
recognizer fine-tune
- root plans §10 (10.1-10.3): cashier fast path, inferred badge +
end-of-day review, burst capture for mounted camera
- stock-feature-plan.md: extension note (batch dropdown becomes the
manual-override path)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q8TumxFDnyVnfsR3mxPXfX
Accuracy work on the 79-image product-scan validation set (user goal: 90%):
- classify_ocr_server.py: 0/90/180/270-degree expiry-date search (stops at
first hit, 0-degree fallback); classification decoupled onto the upright
image (rotated frames regressed DINOv2 -6pts until this); cross-line date
stitching; tiled full-res OCR pass (defeats the 4000px downscale that
killed small inkjet dates); VL-pipeline expiry fallback with
keyword-anchored anti-hallucination guard; VL text lines merged into
text_lines + VL SKU retry. Visualization endpoints removed entirely
(Visual/Spotting grids - unused by frontend, 3x per-scan GPU cost).
- product-scan.ts: coverage-normalized OCR-evidence re-ranking of DINOv2
top-K (tuned offline: +8/-0 on top-1 misses), re-ranked class mapped to
sku_master by SKU prefix; classifier timeout 90s->240s for fallback paths.
- Frozen benchmark: product-test-images-fixed/ (79 renamed images) +
freeze/seed/build-undetected/capture/experiment scripts; labels trimmed to
the 79 validation entries (training rows kept in .bak-with-training);
5 TRAINED-ON SKUs replaced with fresh held-out photos.
- manual-label-scan page: shows last batch-test AI prediction under every
field by default (new /api/product-scan-results); serves the fixed folder;
fixed total hydration failure via allowedDevOrigins 127.0.0.1.
- Measured (all-79, zero failures): sku/name 87.3%, expiry 64.6%, overall
79.7%. Tiles/VL-evidence/VL-SKU deployed but not yet batch-measured.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gr6HH7JrdsXX8AARejQboM
train_classifier.py's split_dataset() previously shuffled and split
individual image files, letting an augmented copy (photo_aug_2.jpeg) land
in validation while its near-duplicate source stayed in training -
inflating val accuracy with memorization rather than measuring real
generalization. Now groups by source photo (stripping _aug_N) before
shuffling and splitting 80/20.
Also records the in-progress effort to retrain the product classifier
against the full 81-class/2,493-photo foto-kemasan-v2 dataset (up from the
16 classes/118 photos the deployed model was actually trained on) - see
plans/next-enhancements.md task 2.5 and the accompanying iteration-log
entry for the real, currently-observed numbers (DINOv2 index rebuilt:
2493/2493 images; classifier training: in progress, ~32s/epoch observed).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xsxk4ZkDQVVaLUcixDcqb5
Fixes reported from APK field testing: DO/Product scan mode was inconsistent
between the camera drawer and documents screen (now one shared provider,
with an orange/green color cue); unconfirmed scans leaked into history with
placeholder data before the user tapped confirm (backend now gates
GET /documents on a new `confirmed` column, flipped only by PUT); and
Product Scan ran the GPU classifier twice, once at upload and again on
review (now a single pass at upload, persisted and read directly by the
editor). Also removes the unused "Hubungkan ke PO" field and fabricated
PO/SO/DO placeholder values from the Product Scan flow, closes out the
per-document-polling and save-recovery tasks (6.1/6.3), and splits several
touched files to stay under the repo's 256-line guideline.
Full detail in docs/iteration-log.md and backend/docs/iteration-log.md.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Backend (app-pfm-ocr-v2/backend):
- Product/SKU scan feature complete: trained DINOv2 index (118 reference
photos, 16 SKU classes) and YOLO classifier (83.3% top-1 val accuracy),
fixed scripts/install-pipeline.sh (was missing ultralytics/torch), fully
browser-verified end-to-end on /scan-pfm. Mobile m-scan-pfm page cancelled
(Flutter app handles mobile; web UI is desktop-only for pipeline testing).
- Fixed a real data-loss bug: Save Ground Truth (scan-pfm and the DO-flow's
manual-label) was silently writing into the pfm-web-app container's
ephemeral filesystem instead of the host, because /sources wasn't
bind-mounted in docker-compose.yml. Added the mount, recovered an
orphaned entry.
- accounts.password is now bcrypt-hashed (bcryptjs, idempotent migration
in db/init.ts) instead of plaintext; login route compares hashes.
- /api/v1/documents/* (list, PUT, upload) now enforces real 401 auth,
matching what the Flutter client already sends. The "classic" routes
deliberately stay open — they're dev-only web UI with no login flow and
won't exist in production.
- OCR accuracy investigated end-to-end: real baseline is 95.10% overall
(target met; accuracy_report.md was stale at 75.04%, now flagged). Fixed
one genuine parser.ts bug (SO/DO field duplication in the global fallback
regex); remaining gaps are OCR/layout-model limitations, not parser bugs.
- Adopted a standalone copy of the fhanyuh/agents-settings e/n workflow
scoped to backend/ (AGENTS.md Part A/B split, SKILLS.md, plans/, docs/),
independent of the root copy which now covers Flutter only.
- next-implementation.md deleted; content folded into
backend/plans/next-enhancements.md for traceability.
Root:
- Adopted fhanyuh/agents-settings kit (AGENTS.md, SKILLS.md, plans/,
docs/feature-list.md), scoped to the Flutter app only.
- Pending documents queue now persists to Hive (lib/core/storage) instead
of memory-only, surviving an app kill mid-upload.
Removed backend_backup/ (stale Express/Prisma prototype, superseded by
pfm-web-app) and the completed plans/next-enhancement-plan.md checklist.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>