Files
CatoandClaude 380a31be95 Quick check reads PDFs; a scored deadline eval set; docs truth (#183)
* feat(intake): PDF on the quick check, and a deadline eval set

- /api/extract-pdf reads a PDF's text layer on the server (unpdf, %PDF magic
  check, 10 MB, 10 pages, text capped at MAX_TEXT). Nothing stored or logged.
  Scans answer scanned_pdf; the page then offers the photo picker.
- One file input takes a PDF or photos; the text flows into the letter box and
  the existing redaction and analyze path. Messages in en, de, fr, it.
- eval/letters: 17 synthetic Swiss letters (de, fr, en) with expected
  deadlines; eval/pdf: text and image-only PDFs; `pnpm eval:deadlines` scores
  stored replies offline, or live with --url on the free chain.
- Docs: README quick-check/matter line, ROADMAP ticks, CHANGELOG 2026-12-02,
  .env.example host path.

Co-Authored-By: Claude <noreply@anthropic.com>

* feat(eval): optional private letter set, scored separately

--private <dir> / CAUSIUS_EVAL_PRIVATE_DIR (default
/opt/causius/shared/eval-private). Absent: "private set: not present,
skipped". Present: "private: N/M (x%)" and pass/fail by position only; no ids,
names, quotes or dates are printed. eval-private/ and eval/private/ ignored.

Co-Authored-By: Claude <noreply@anthropic.com>

* feat(eval): precision, recall and false-invention rate; answer key for the private set

Most letters correctly have no deadline, so each is scored true negative,
false invention, true positive, miss or wrong date. Ranges accept any date in
them. Private set reads answers.json and letters/*.txt and prints only counts,
metrics and pass/fail by position. Four more synthetic traps: open-ended
suspension risk, amount with no date, spend-cap reset, 2-3 working days.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-12-03 01:55:56 +01:00
..

Deadline eval

How often does Causius read the right deadline from a letter, and how often does it invent one? Synthetic Swiss letters only (German, French, English): every name, address and number in letters/ is made up.

pnpm eval:deadlines                      # offline: scores eval/replies/, calls no model
pnpm eval:deadlines --url <base> --save  # opt-in, live: <base>/api/analyze on the free chain, ~2 hours
pnpm eval:deadlines --private <dir>      # also scores a private set (or CAUSIUS_EVAL_PRIVATE_DIR)

The stored replies that ship are hand-written fixtures, marked as such in each file: the offline score checks the scorer, not a model. Never in verify or CI with --url.

What is scored

Most letters correctly have no dated deadline, so each letter is one of:

expected predicted result
none none correct
none a date false invention
a date that date true positive
a date nothing miss
a date another date miss, and a false positive

A date that is not a legal duty (a spend-cap or quota reset, a billing cycle) is not a deadline: expected is none. A range ("within 2-3 working days") accepts any date in it, ends included. A reply that is not a case is a miss.

Reported, for the public and the private set alike:

  • deadline accuracy N/M: letters answered correctly, of all letters
  • dated-deadline precision: true positives / (true positives + false positives)
  • dated-deadline recall: true positives / letters that have a date
  • false-invention rate: inventions / letters that have no deadline

Public set

letters/cases.json: expected is an ISO date, an inclusive ["from","to"] range, or null; today is the reference date for relative wording. Add a letter, its line in cases.json and a reply in replies/<id>.json ({"id", "source", "reply"}, reply being the model's raw text). pdf/ holds a text-layer and an image-only PDF for the intake tests (node eval/make-pdfs.mjs rebuilds them).

Private set (optional)

Real letters never go in this repository. Put them in a folder, default /opt/causius/shared/eval-private, laid out as:

<dir>/letters/*.txt        the letters
<dir>/answers.json         {"items":[{"letter":"letters/01.txt","today":"YYYY-MM-DD",
                             "deadline": null | "YYYY-MM-DD" | ["YYYY-MM-DD","YYYY-MM-DD"]}]}
<dir>/replies/*.json       stored replies: {"id":"letters/01.txt" (or "01"),"reply":"..."}

An array means any date in that inclusive range is correct; today is the reference date for relative wording. Without the folder it prints private set: not present, skipped; without answers.json, private set: answers.json missing, skipped; the run goes on either way.

Only counts, the metrics above and pass/fail by position (private #3) are printed: never a filename, quote or date. eval-private/ and eval/private/ are git-ignored.