OCR diagnosability: surface per-remark reader + confidence in the import report #9
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
daniel/obsidian-remarkable-round-trip!9
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/ocr-diagnostics"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part of #4 (which is Part of #2). This is work item 1 of 3 — the clean, independent, "do first" piece that unblocks calibration tuning. See #4 for the full picture.
Goal
Make every reading attributable: show, per import run, which reader produced the text (
builtin/writepad/endpoint) and how confident it was, behind a debug/verbose toggle. Today the WritePad fallback fires invisibly insidebuiltinmode, so neither the user nor a tuner can tell builtin-junk from WritePad-junk. Without this surface, the recalibration work (sibling MR) cannot be targeted.What exists today
recognizeLocally()insrc/main.ts:1688already computesscored = { score?: number; by?: ReaderName }for each remark (by∈builtin/writepad; the endpoint path sets its own) and passes it torememberReading()→rememberRemark()insrc/ocr/samples.ts, which storesreadBy/readScoreper record. The data already exists in the sample store; it is just never surfaced.src/incoming/report.ts) is rendered fromPullResult/DocumentScan(src/incoming/pull.ts:29).DocumentScan.inkalready holds{ erasedWords, movedWords, partialWords, ownStrokes, transcribed }. The report printsscan.ink.transcribedbut nothing about who read or how well.transcribedependency is typed(request) => Promise<string | null>(src/incoming/pull.ts:184), called inpictureOf()(src/incoming/inkpull.ts:244) which incrementsscan.ink.transcribed.What to change (recommended shape — adjust if you find cleaner)
transcribedep return type fromstring | nullto{ text: string; by?: ReaderName; score?: number } | null(importReaderNamefromsrc/ocr/samples.ts). Update:recognizeLocally()(main.ts:1688) to return{ text, by, score }instead of a bare string (it already hastextandscoredlocally — just return them together).scorehere is the normalisedscoreAbove(confidence, cutoff)value already computed (0 = just passed, 1 = certain); surface that.transcribeStrokes,main.ts:1926) to return{ text, by: "endpoint" }(no numeric confidence — endpoints have none; leavescoreundefined).pictureOf()(inkpull.ts:236) to read.textwhere it currently uses the string, and to feed the reader/score into the scan aggregate.DocumentScan.inkareaders?: Record<ReaderName, { count: number; scoreSum: number }>(or similar) and accumulate inpictureOf. Keep it optional so older/empty scans stay valid. Average =scoreSum / countat render time.ocrDiagnostics(defaultfalse) toRoundTripSettings(src/settingsmodel.ts:102area) +DEFAULT_SETTINGS, and a schema entry insrc/settingschema.ts(in the OCR section around line 406,visibleWhen: { key: "ocrMode", in: ["builtin", "endpoint"] }, control{ type: "toggle" }, with help text like "Show which reader produced each remark and how confident it was, in the import report"). Thread it intoImportReportInput(src/incoming/report.ts:12) asocrDiagnostics?: booleanand set it where the report input is built (search forrenderImportReport(/ImportReportInputconstruction inmain.ts).report.ts, whenocrDiagnosticsis true andscan.ink.readershas entries, add a line under the existinghandwriting:line, e.g.:readers: builtin 7 (avg 0.42), writepad 3 (avg 0.08), endpoint 0— only listing readers with count > 0. Keep the existing non-diagnostic output byte-identical when the toggle is off.Scope boundary
· read by writepad (0.08)to the remark callout whenocrDiagnosticsis on. If it adds any complexity to callout generation, skip it and leave it to a follow-up — the report surface is the required deliverable.Validation contract
nix develop -c npx vitest run src/__tests__/report.test.ts→ PASS. Add a case: a scan whoseink.readershas{ builtin: {count:2, scoreSum:1.0}, writepad: {count:1, scoreSum:0.1} }renders the readers line only whenocrDiagnostics: true, and renders byte-identically to before when it isfalse(guard against the "scope mismatch / silent" false-pass: assert the line is absent with the toggle off, using a positive control that it is present with the toggle on).nix develop -c npx vitest run src/__tests__/settingschema.test.ts→ PASS (new setting present, default false).nix develop -c npm test→ PASS (no regressions). Build check:nix develop -c npm run build.Note: this repo has no
flake.nix—nix developwill fail. Run tests directly:npm cithennpx vitest run <files>(Node 24 is on PATH). I verified this during investigation.Closes nothing on its own; part of #4.
✅ Agent run completed
4s · 1 turns · $3.61 · pushed
agent/ocr-diagnostics· session saved — new comments resume this runclaude referenced this pull request2026-10-20 15:22:09 +02:00
claude referenced this pull request2026-10-20 15:22:46 +02:00
claude referenced this pull request2026-10-20 15:22:46 +02:00
What changed
recognizeLocally/transcribeStrokes({ text, by, score }instead of a bare string);pictureOfaggregates this into a new optionalDocumentScan.ink.readers(count/scoreSumper reader).ocrDiagnosticssetting (default false) in the model,DEFAULT_SETTINGS, and the settings schema (OCR section,visibleWhenbuiltin/endpoint, toggle).readers: builtin N (avg …), writepad N (avg …), endpoint Nline underhandwriting:only when the toggle is on and at least one reader has a reading. Endpoints carry no confidence, so they show a count with no avg. Output is byte-identical when the toggle is off.Verify
npx vitest run src/__tests__/report.test.ts src/__tests__/settingschema.test.ts→ PASS. The report case uses a positive control (the readers line is present withocrDiagnostics: true) and asserts the off-toggle report is byte-identical to a no-reader render. Fullnpm test→ 654 passed;npm run build(tsc + esbuild + bundle check) → clean. No pipeline has run for headefff397(the only recent CI run is a pre-existing failure onmain, unrelated to this diff).Follow-ups
· read by writepad (0.08)to the remark callout when diagnostics is on.claude referenced this pull request2026-10-20 15:29:42 +02:00
claude referenced this pull request2026-10-20 15:29:42 +02:00
claude referenced this pull request2026-10-20 16:34:09 +02:00
claude referenced this pull request2026-10-20 16:34:09 +02:00
claude referenced this pull request2026-10-20 18:57:33 +02:00
claude referenced this pull request2026-10-20 18:59:19 +02:00