Skip to content

fix(verify): one strict evidence matcher and an adversarial corpus - #2784

Merged
abrichr merged 9 commits into
mainfrom
claude/evidence-matcher-corpus-f04cf8
Nov 30, 2026
Merged

abrichr merged 9 commits into
mainfrom
claude/evidence-matcher-corpus-f04cf8

Conversation

@abrichr

@abrichr abrichr commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Behavior change: what earns VERIFIED

  • Sentence and toast read-backs no longer verify. In the wrapped transducer, a read-back such as Saved CLM-3 and REF-20. or CLM-1234 saved, total $1,250.00 used to give VERIFIED. It now ends unverified, with a hold or COMPLETED_UNVERIFIED. Such text reports that a save was claimed, not the saved record. A read-back needs each value as a field's value (Claim ID: CLM-1234).
  • Words beside a value, or before its label, refuse it. Claim ID: CLM-1234 not found, Dose: 5 mg (rejected), Balance: 250.00 CR, Previous Patient ID: MRN-104, Error: Claim ID: CLM-1234 and Name: Jane Doe Previous MRN: MRN-1 no longer verify.
  • Several fields on one line need a separator. A label binds only at the start of a line or after |, ; or a tab. A single-line Patient: John Smith DOB: 1990-01-01 binds Patient but not DOB, so the date stays unverified. This fails closed: the text can't tell the end of one value from a modifier on the next label.
  • A prompt value needs a page label that names it. Charge: $250.00 verifies a $250.00 charge; Copay:, Balance due:, Requested: and Unable to post: don't. A true label the list doesn't hold (Supporting reference, Submitted) leaves the value unverified.
  • Benchmark numbers will move. This changes what earns VERIFIED in the wrapped benchmark arms, so the published HealthAdminBench wrapped-arm numbers will change when they're rerun.

What this changes

Several verifiers decided whether text on a screen proves a write, each with its own matcher. Most were substring or loose token checks. This adds one strict matcher, moves the callers nobody else is editing onto it, and lists the rest with tests that fail when they're fixed.

openadapt_types.evidence is stdlib only and based on Flow's readback_values.compare_value. It doesn't import Flow.

  • match_field(expected, observed_text, *, label=None, kind="auto") returns MATCH, MISMATCH or AMBIGUOUS. Only MATCH passes.
    • A value bound to its label is tried first. Without a binding, the whole text must equal the value.
    • A label binds only at the start of a line or after |, ; or a tab (or a JSON key's { or ",), with only punctuation between. Any word before it (Previous, Former, Error:, an earlier field's value) may name another record. The cell before a |, ; or tab must be empty or a whole field (Name: Jane | MRN:); a bare word or a value-less heading (Previous | MRN:, Previous: | MRN:) refuses.
    • The bound value must be the value and nothing more, except unit words after a number (5 mg, 5 mmol/L, 250.00 USD). A status, a comparator (<, >, ~, ≤, ≥, a + suffix), a trailing sign, CR/DR, or an aside gives AMBIGUOUS.
    • A value merely found inside longer text is AMBIGUOUS.
    • A token never ends at joining punctuation (-, ,, ., / or @ before a letter or digit), so 2026-11 is not in 2026-11-29 and John Smith is not in John Smith-Jones.
    • Numbers compare as whole numeric tokens by value, with sign and currency. 250 never matches $1,250.00, and 5 never matches 50 mg.
    • One label with two values is AMBIGUOUS.
  • phrase_affirmed(before, after, phrase) checks a commit confirmation. The phrase must be absent before and present after. A question, a modal, future or conditional form, or a negation or failure word on its line or the lines next to it, a control label (Confirm, Cancel, OK, Sign) next to it, or a failure word (Error, rolled back, draft, 0 records, by another user, undo, previously, before, outbox, queued) on any line new since the first frame gives AMBIGUOUS.
  • has_negation_or_modal(text) exposes the word check. No. meaning number doesn't count.

Corpus. packages/types/tests/evidence_corpus.json has 129 cases with pinned verdicts: every repro from three review rounds, more adversarial cases, and 29 true positives. Two of those are deliberate: a code matches with or without its separators when one side has none (E119 and E11.9).

Copies, not a new dependency. The launcher installs openadapt-types from PyPI, and only below Python 3.13. The kernel depends only on cryptography. So both carry byte-identical copies (openadapt/_evidence.py, openadapt_kernel/_evidence.py) instead of depending on openadapt-types, which would add pydantic to the kernel. Drift fails tests in all three packages.

Verdict folds. The module and the transducer fold verdicts as set comparisons ({verdict} == {MATCH}), which an empty list can't pass, so check_verdict_folds.py passes without a baseline change. A @verdict_site isn't possible here: the launcher copy can't import openadapt_flow.verdict on Python 3.13 and newer, where Flow isn't installed.

Migrated

  • Transducer read-back (openadapt/transducer_obligations.py). _value_in_text needs MATCH.
    • An obligation whose label came from the prompt (date, CPT code, an ID's own prefix) must be the whole value of a Label: value field on the page.
    • Every word of that page label must name the obligation's kind (Charge, Total, Amount; Visit date, Date of service; Diagnosis, ICD-10 code), or for an ID be its prefix, a listed name for it, or a generic ID word (Claim ID and Claim No. for CLM-…, Medical Record Number for MRN-…). Shared letters or initials don't count: Claimant ID:, Maternal MRN: and Mother Record Number: refuse. This replaces the refusing-word list.
    • The label's line must hold no negation, failure or modal word.
    • An ID whose only label is its prefix (CLM) verifies only as the value of the one field on the page that holds an ID with that prefix. A worklist with two CLM IDs doesn't verify. An ID next to another ID with the same prefix never verifies.
    • Drafting only locates values, on whole tokens.
  • SOP tokens (transducer_form_batch._rule_satisfied) match whole tokens, so signed no longer matches unsigned.
  • Kernel token_boundary_check, and through it every read-back oracle and the non-DOM adapter, cites a value only on MATCH.
    • Of the DOM bindings, only those that name the key best count. A binding key names a key only when its words are the key's words, so Previous Member ID, member_id_old and Member ID (previous) are not member_id, while State still names state_code. An input's name, id, test id and label are scored apart.
    • A select's option text is a separate candidate.
    • SQLite rows bind by column.

Parity with Flow

packages/flow/tests/test_evidence_parity.py runs the corpus through compare_value and fails when Flow passes a case the shared module refuses, unless the case is listed.

  • Flow is looser on 20 cases, each listed in the test. Its first-token rule for short values passes 5 in Dose: 5 mg then 10 mg, Dose: 5 mg was not saved and Dose: 5 mg (rejected). Its label extraction binds after other words in the field or the cell before (Previous Patient ID:, Error: Claim ID:, Name: Jane Doe Previous MRN:, Previous | MRN:). These need a Flow follow-up.
  • Flow is stricter on seven cases. Those are false refusals, listed in the test.

The file also holds Hypothesis properties of the shared module.

Not migrated (listed for later)

packages/types/docs/evidence-migration.md lists each remaining caller, with file, line and the corpus cases it gets wrong. packages/flow/tests/test_evidence_pending_callers.py and tests/test_evidence_pending_callers.py run those cases as xfail(strict=True), so a fix turns them into failures until the marker is removed.

Tests changed because they relied on loose matching

  • Launcher.
    • tests/test_transducer_v3_runtime.py and tests/test_simplex_transducer.py expected VERIFIED from sentence read-backs (Saved CLM-3 and REF-20.). They now use labelled record views. A new test per old sentence asserts that it no longer verifies. No transducer runtime file is changed.
    • Two fixture labels the kind list doesn't hold were renamed (Supporting reference: to Reference:, Submitted: to Encounter date:).
    • A new test runs 36 screens from the second and third reviews (failure context around the label, labels that don't name the obligation or share only an ID's letters, modifiers after an earlier field, status words in the value). None verifies.
  • Kernel.
    • The PDF and portal fixtures now label their values (Member: MEM-442, POSTAL_CODE=, data-field).
    • The PDF fixture puts Approved before the record instead of in the Code: field, and separates its fields with |. The portal fixture separates REF=, POLICY= and POSTAL_CODE= with ;.
    • New assertions check that the unlabelled PDF, Previous Member ID, member_id_old, Member ID (previous) and Member Previous ID are refused.

Release

There is no version bump. Merging a bumped pyproject.toml with a dated CHANGELOG heading publishes the package to PyPI, so the entry sits under ## Unreleased. When it ships, 0.24.3 fits within the <0.25.0 range that Flow and the launcher accept.

Tests

  • packages/types: 1078 passed.
  • packages/kernel: 363 passed. ruff and mypy are clean.
  • Flow evidence tests: 122 passed and 80 xfailed.
  • Launcher: 3349 passed, 31 xfailed, 13 failed. The 13 are CLI help, distribution metadata, launcher-on-PATH and release-artifact tests. The same 13 fail on a clean origin/main in this environment.
  • check_verdict_folds.py: "Verdict folds OK", baseline unchanged.
  • ruff and ruff format --check openadapt/ are clean.

Left for later (non-blocking from review)

  • A failure on the line after the field (Claim ID: CLM-1234 then Status: rejected) isn't checked. The transducer checks only the label's own line, because a neighbouring field's No (Smoker: No) would refuse true record views.
  • Total: and a bare Date: still name an amount and a date.

Several verifiers decided whether text on a screen proves a write with their
own matcher. Most were bare substring or loose token checks, so "250" was
found in "Total $1,250.00", "John Smith" in "John Smith-Jones", and "Note
will be signed by Dr A" counted as signed.

openadapt_types.evidence is one stdlib-only matcher, based on Flow's
readback_values.compare_value. match_field returns MATCH, MISMATCH or
AMBIGUOUS, and only MATCH may pass. A value bound to its label is tried
first; otherwise the whole text must equal the value. A value merely found
in longer text is AMBIGUOUS. Tokens never end at joining punctuation,
numbers compare as whole numeric tokens by value, and a label with two
values is AMBIGUOUS. phrase_affirmed checks a commit phrase across two
frames.

- packages/types/tests/evidence_corpus.json: adversarial cases with pinned
  verdicts, plus true positives.
- The launcher (openadapt/_evidence.py) and the kernel
  (openadapt_kernel/_evidence.py) carry byte-identical copies, checked by
  tests, so neither needs openadapt-types from PyPI or pydantic.
- Migrated: transducer obligation read-back and SOP tokens, and the kernel's
  token_boundary_check with every oracle built on it.
- Flow parity test: compare_value never passes a corpus case the shared
  module refuses, except one listed Flow follow-up. Hypothesis properties
  cover the shared module.
- Callers not migrated yet have strict expected-failure tests and are listed
  in packages/types/docs/evidence-migration.md.
…labels

- A code bound to its label with a second code after it (Diagnosis: E11.9
  I10) is ambiguous, not a match.
- phrase_affirmed treats must, can, may, need, if, once, when, required and
  similar forms as not done, and error, missing and invalid as negations.
- Transducer page labels that say Error, Not, Missing, Required, Previous,
  Worklist and the like no longer verify a prompt obligation.
- The launcher checks its own copy of the matcher for drift.
- xfail reasons say which caller has no fix yet; the guard branch fixes 15
  of its 21 loose cases.
…read-backs stay unverified

A prefix-labelled ID obligation (CLM) verifies only as the value of the one
page field holding an ID with that prefix. Two such fields, as on a
worklist, or the same ID in two fields, don't verify. New tests pin that
the old sentence read-backs ("Saved CLM-3 and REF-20.", "CLM-1234 saved,
total $1,250.00") now end unverified.
@abrichr

abrichr commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: 050334d

This is a real improvement. On main, all 30 of my transducer probes below verify. At this head, the sentence read-backs, 250 against $1,250.00, and two values for one label are refused, as the corpus pins. But the matcher still returns MATCH for read-backs that a careful person would reject, and the refusing-word list answers question 2 with a no. The smoke check also fails on this head.

Blocking

  1. A bound value can carry a failure or negation and still MATCH.
    • _compare_bound (packages/types/openadapt_types/evidence.py:483-512) takes the single numeric token of a bound number or currency (:485) and ignores the words around it.
    • For a code it takes the first token, and fails only when a later token has a digit (:498).
    • Each of these gives MATCH with basis label:
      • Dose: 5 mg was not saved (5)
      • Dose: 5 mg (rejected) (5)
      • Amount: $250.00 failed to post ($250.00)
      • Amount: 250.00 USD (pending) (250.00)
      • Claim: CLM-1 not found (CLM-1)
      • Claim: CLM-1 (void) (CLM-1)
      • Diagnosis: E11.9 ruled out (E11.9)
    • Comparators and accounting signs also pass:
      • Dose: <5, >5, ~5, 5+ and ≤5 all match 5.
      • Balance: 250.00- and Balance: 250.00 CR both match 250.00.
    • The text aside rule (seen.startswith(want + " (")) passes Name: Jane Sample (not this patient).
    • Fix: the remainder of a bound value may hold only unit-like words. Any _NEGATION or _MODAL word in it, a comparator, or a trailing sign or CR/DR should give AMBIGUOUS. Add each case to the corpus.
  2. A label binds after a modifier word.
    • _label_pattern (:445-458) only requires that no \w or - comes before the label.
    • So the label Patient ID binds Previous Patient ID: MRN-104, and Name binds Former Name: Jane Sample and Previous Name: Smith. All three give MATCH.
    • The kernel has the same problem in another form. _binding_key_score (packages/kernel/src/openadapt_kernel/oracles.py:100) scores any binding key that contains the key as 2.0. field_verdict("member_id", "MEM-442", "", field_bindings=[{"key": "Previous Member ID", "val": "MEM-442"}]) returns match, and so does field_verdict on the text Previous Member ID: MEM-442.
    • Fix: bind a label only at the start of a field (line start, or after a separator _VALUE_END recognises), or refuse when a word comes before it in the same field. Apply the same rule to binding keys.
  3. The page-label rule's refusing-word list is not enough. This answers question 2 directly. _labelled_by_page (openadapt/transducer_obligations.py:152-189) checks only the words of the label that binds (:182), and only against _REFUSING_LABEL_WORDS (:141). Through compile_obligations_from_spec and diff_readback_against_obligations, every one of these gives all_verified=True at this head:
    • Failure context before the label on the same line:
      • Error: Claim ID: CLM-1234 already exists
      • Error - Claim ID: CLM-1234
    • Failure words after the value:
      • Claim ID: CLM-1234 not found
      • Claim ID: CLM-1234 rejected by payer
      • Charge: $250.00 failed
      • Copay: $250.00 not posted
    • Labels missing from the list:
      • Unable to post: $250.00. unable is in the matcher's own _NEGATION but not in this list.
      • Warning:
      • Filter:, Find:, Expected: and Task:. These echo the input, not the saved record.
      • Prev claim:, Earlier claim:, Superseded by:, Excluded: E11.9, Locked: and Undo:.
      • Due: 2026-11-29 and Today: 2026-11-29 for a visit date, and Balance due: $250.00 or Requested: $250.00 for a charge.
    • A word list will keep losing to new labels. Two changes would cover this class:
      • Treat any _NEGATION or _MODAL word anywhere on the label's line, or in the bound value, as refusal.
      • Accept a prompt-label value only when the page label names the obligation (a label-to-kind mapping, such as charge/amount/total for an amount), not any label.
    • If the looser rule stays, the PR should say that a page label is evidence of position, not of meaning.
  4. CI: smoke (every package installs, imports and starts) fails in check_verdict_folds.py. I reproduced it locally at this head, and main passes it ("Verdict folds OK").
    • The PR adds hand-written verdict folds in openadapt/_evidence.py (1) and openadapt/transducer_obligations.py (2).
    • The same output also lists qualify_local.py, compiler/compile.py, qualify/record_oracle.py, api_tier.py and confirming.py, which this PR doesn't touch. That looks like baseline drift against current main, but it fails this head either way.

Non-blocking

  1. phrase_affirmed gaps. No production caller uses it at this head, but it is the shared API the pending callers will move to. Each of these gives MATCH:
    • Saved\nError: record locked. Negation on the line below isn't checked.
    • Not\n\nSaved. Only the line directly above is checked.
    • Nothing saved, None saved, Saved 0 of 3 and SAVED: 0 records.
    • Saved — rolled back and Saved. Reverted.
    • Saved as draft and Note saved by another user.
    • Add these to the corpus before the phrase callers migrate.
  2. The code rule matches E119 to E11.9 and AB12 to A-B12 when one side has no separators. This is documented, and I agree it's fine for ICD-10. Note it in the corpus as a deliberate case.

Tests at this head (Linux, Python 3.12, clean venv from the locks)

  • packages/types: 1021 passed.
  • packages/kernel: 246 passed, 1 skipped (macOS AX live test).
  • Flow tests/test_evidence_parity.py tests/test_evidence_pending_callers.py: 79 passed, 31 xfailed.
  • Full launcher pytest tests: 3228 passed, 6 failed, 12 skipped, 17 xfailed. Main at b13f96a1 fails the same 6 in my environment (test_cli_surface snapshot, three test_quickstart terminal-view tests, two test_quickstart_robust width tests).
  • check_verdict_folds.py: fails at this head and passes on main (item 4).
  • My probes: 47 direct evaluate_field cases, 21 phrase_affirmed cases, 30 transducer read-backs and 4 kernel field_verdict cases. The findings above are their results. The same 30 transducer read-backs all verify on main.

Generality gate:

  1. Pass. check_engine_generality.py: "Engine generality OK (7 baseline hits left)". The matcher is app-agnostic.
  2. Partial. One explicit model with a corpus and parity tests is the right shape. But items 1–3 are one class: context around a bound value that negates it or points to another record. The model doesn't cover it yet, and the page-label rule is a per-word patch over it.
  3. Held-out evidence: the corpus is built from review repros. The PR says honestly that the benchmark numbers haven't been rerun.

Not run: the Flow compare_value follow-up, Playwright or OCR callers (documented only in the PR), and a benchmark rerun.

CI at this head (when I checked):

  • Failing: smoke (item 4) and windows replay (Patient Notes, WindowsBackend). The Windows replay check has also failed on other branches recently.
  • Still pending: 9 checks, including the flow core unit and default-at-rest shards.
  • 19 pass and 18 skipped.

I didn't push to this branch, and I won't merge it.

…lue refuse it

- A label binds only at the start of its field. "Previous Patient ID:",
  "Former Name:" and "Error: Claim ID:" no longer bind.
- A bound value may hold only unit words beside a number. A status, a
  comparator, a trailing sign, CR/DR or an aside gives AMBIGUOUS.
- Kernel binding keys must start with the key's words. An input's name, id,
  test id and label are scored apart.
- Transducer page labels must name the obligation's kind, or for an ID its
  prefix, on a line with no negation, failure or modal word. This replaces
  the refusing-word list.
- phrase_affirmed also refuses a negation on the line below, a failure word
  on any new line, and nothing/none/rolled back/draft/0 records.
- Folds are set comparisons, so check_verdict_folds passes without a
  baseline change.
- The corpus grows to 112 cases. The Flow parity and pending-caller lists
  are remeasured; the guard list now names #2786.
…er-corpus-f04cf8

# Conflicts:
#	packages/kernel/CHANGELOG.md
@abrichr

abrichr commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: 21b2ed9

Big progress. All 30 transducer read-backs and all 47 matcher cases from my last review now give the answer the corpus pins, and smoke's verdict-fold check passes. The merge commit only touches the kernel CHANGELOG: git show --remerge-diff shows the one conflict, resolved by keeping both entries. Two of the questions you asked get a "yes": the earlier-field allowance lets a modifier through, and the prefix-letter rule for IDs is too loose. Both are fail-open paths in the same class as prior blockers 2 and 3.

Prior blockers

  1. Words around a bound value: fixed. All 14 cases are now AMBIGUOUS: 5 mg was not saved, (rejected), $250.00 failed to post, 250.00 USD (pending), 250.00-, 250.00 CR, CLM-1 not found / rejected / (void), E11.9 ruled out, <5, >5, ~5, 5+, ≤5 and Jane Sample (not this patient). A unit after the number is still compared: 5 mg against Dose: 5 mcg, 5 g, 5 units or 5 mg/kg is MISMATCH, and $250.00 against 250.00 EUR is MISMATCH.
  2. A modifier before a label: partly fixed (blocking, item A). Previous Patient ID:, Previous Name: and Former Name: now refuse when they start the field. The kernel binding key Previous Member ID no longer binds. Two allowances still let a modifier through (see A).
  3. Page labels: the 30 earlier cases are fixed, but the replacement rule is loose (blocking, item B). Every one of the 30 read-backs now refuses, including Error: Claim ID:, Filter:, Prev claim:, Balance due:, Due: and Unable to post:.
  4. smoke / check_verdict_folds.py: fixed. It prints "Verdict folds OK (2615 baseline folds left)". The new folds are set comparisons, so an empty list can't pass them.
  5. phrase_affirmed: fixed. All the cases I listed are AMBIGUOUS (Saved\nError: record locked, Not\n\nSaved, Nothing saved, Saved 0 of 3, Saved — rolled back, Saved as draft, by another user, and the rest).
  6. Code separators: pinned as deliberate. Agreed.

Blocking

A. A modifier still binds a label after an earlier field, or after a column gap.

  • The _PRIOR_FIELD allowance in _field_start (packages/types/openadapt_types/evidence.py:479-500, the same in both copies) accepts any segment that ends in Label: value plus a space. So the words between that value and the label are never checked. Each of these is MATCH with basis label:
    • Name: Jane Doe Previous MRN: MRN-1 (label MRN, value MRN-1)
    • Patient: Jane Doe Old Claim ID: CLM-1 (label Claim ID)
    • Status: superseded Claim ID: CLM-1
    • Patient: Jane Former Name: Joan (your example)
    • Patient: Baby Boy Mother Name: Jane Doe (label Name)
  • The text can't tell Former apart from the end of the earlier value. That ambiguity is what this rule needs to report.
  • A hard separator restarts the segment, so Previous MRN: MRN-1 (two spaces), Previous | MRN:, Previous; MRN:, Previous\tMRN: and Previous: MRN: all bind. The | and tab cases are arguably separate cells. Two spaces inside one OCR'd cell are common, though, and Previous: MRN: is a heading, not a field.
  • The kernel has the same problem with words that come after the key. _binding_key_score (packages/kernel/src/openadapt_kernel/oracles.py:106) scores 2.0 for any binding key that starts with the key's words. Its share rule (:109) only checks the first word. field_verdict("member_id", "MEM-442", "", field_bindings=[...]) gives MATCH for the keys member_id_old, Member ID (previous) and Member Previous ID. Through the text path, field_verdict on Name: Jane Doe Previous Member ID: MEM-442 is also MATCH.
  • Simplest fix: drop the _PRIOR_FIELD allowance and bind only at a hard separator. A single-line Patient: X DOB: Y then gives AMBIGUOUS, which fails closed. Or keep the allowance but cap the bound verdict at AMBIGUOUS when it was used. In the kernel, a binding key whose words go beyond the key's words should score less than 2.0. Add the cases above to the corpus.

B. The prefix-letter and initials rules accept labels that name another record.

  • _names_prefix (openadapt/transducer_obligations.py:190-200) accepts any word that starts with the prefix's first letter and contains its other letters in order. The initials rule (:211) accepts any words whose first letters spell the prefix.
  • Through compile_obligations_from_spec and diff_readback_against_obligations, each of these gives all_verified=True at this head:
    • Maternal MRN: MRN-104 for Open chart MRN-104.: maternal contains m…r…n. On a newborn's chart this is the mother's identifier.
    • Mother Record Number: MRN-104, through the initials rule.
    • Claimant ID: CLM-1234 for File claim CLM-1234.
  • Merged MRN: is refused, but only because merged happens to lack an n after the r. The rule decides by spelling, not meaning. That answers your question about prev for PRV, too.
  • Fix: accept the prefix itself, words of the obligation's own label, and the per-kind words. Add an explicit expansion such as claim for CLM as a listed entry, not a letter test. The initials rule should still require every word to be in an allowed list (medical, record, number). Pin Maternal MRN:, Mother Record Number: and Claimant ID: as refusals.

Non-blocking

  • A failure on the line after the field isn't checked. Claim ID: CLM-1234\nStatus: rejected verifies, because _labelled_by_page only checks the label's own line (:262-274). phrase_affirmed already checks neighbouring lines. Doing the same here would be consistent.
  • Generic per-kind words: Total: $250.00 verifies a charge, and Date: 2026-11-29 verifies a visit date. Date of birth: is now refused, which is good. Total and bare Date are often a sum or a print date. Consider requiring a second word for them.
  • phrase_affirmed still matches Saved\nUndo, Saved to outbox, Saved previously and Was saved before. No production caller uses it yet.

Tests at this head (Linux, Python 3.12, editable venv from the locks)

  • packages/types: 1061 passed.
  • packages/kernel: 332 passed, 1 skipped (the macOS AX live test).
  • Flow tests/test_evidence_parity.py tests/test_evidence_pending_callers.py: 109 passed, 64 xfailed.
  • tests/test_transducer_obligations.py tests/test_transducer_v3_runtime.py: 99 passed.
  • Full launcher pytest tests -n 8: 3324 passed, 6 failed, 12 skipped, 27 xfailed. The 6 failures are test_cli_surface and five quickstart terminal-width tests. They fail the same way on main at b25faad85 in this environment.
  • check_verdict_folds.py: OK. check_engine_generality.py: "Engine generality OK (7 baseline hits left)". ruff check on the changed evidence, transducer and kernel files: clean.
  • The three copies of the matcher (types, launcher, kernel) are identical below their headers.
  • Probes: the 47 matcher, 21 phrase and 30 transducer cases from my last review, plus 25 new matcher cases, 20 new transducer cases and 10 kernel field_verdict cases. The results are above. Every new transducer case that verifies here also verifies on main, so none of them is a regression. They are what's left of the class this PR closes.

Generality gate:

  1. Pass. No app-specific code; the generality check passes.
  2. Partial. Leading modifiers, words in a bound value and the failure-label list are now handled as a class. Items A and B are the same class, "context that points to another record", reached through the two allowances this round added.
  3. Held-out evidence: the corpus is built from review repros, and the benchmark hasn't been rerun, as the PR says.

Not run: macOS-only tests, Playwright and OCR callers, a benchmark rerun, and kernel mypy.

CI at this head (when I checked):

  • 13 pass and 18 skipped, with 17 pending (the flow core unit and default-at-rest shards, lint and types, among others).
  • Failing: windows replay (Patient Notes, WindowsBackend), in the native keyboard lease step. The same Desktop replay job fails on several unrelated branches tonight, so it isn't caused by this PR.

I didn't push to this branch, and I won't merge it.

…isted words

- A label binds only at the start of a line or after |, ; or a tab, with
  only punctuation between. "Name: Jane Doe Previous MRN:", "Status:
  superseded Claim ID:" and "Previous  MRN:" no longer bind. A bare word or
  a value-less heading in the cell before ("Previous | MRN:", "Previous: |
  MRN:") refuses too. A single-line "Patient: X DOB: Y" no longer binds DOB.
- Kernel: a binding key scores 2.0 only when its words are the key's words,
  and the share rule needs every word to be one of the key's.
  member_id_old, "Member ID (previous)" and "Member Previous ID" are not
  member_id.
- Transducer: an ID's page label must use its prefix, a listed name for it,
  or the generic ID words. The letter-order and initials tests are gone, so
  "Maternal MRN:", "Mother Record Number:" and "Claimant ID:" refuse.
- phrase_affirmed also refuses undo, previously, before, outbox and queued.
- Two kernel fixtures put their single-line fields behind | and ; separators.
- The corpus grows to 129 cases. The Flow lists are remeasured against
  #2786 at 1ee554d.
@abrichr

abrichr commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 46f0398

Both blocking items from my last review are fixed, and the replacement rules are strict rather than tuned to my examples. I could not make a modifier-before-label or a loose ID label verify with any new phrasing I tried.

Prior blockers

  • A. Modifier after an earlier field or a separator: fixed. Name: Jane Doe Previous MRN: MRN-1, Patient: Jane Doe Old Claim ID: CLM-1, Patient: Jane Former Name: Joan, Patient: Baby Boy Mother Name: Jane Doe, Previous | MRN:, Previous: MRN: and the two-space case are all AMBIGUOUS. A single-line Patient: X DOB: Y now fails closed (pinned). In the kernel, member_id_old, Member ID (previous), Member Previous ID, Previous Member ID and the text Name: Jane Doe Previous Member ID: … no longer verify member_id; State still names state_code.
  • B. Loose ID labels: fixed. Maternal MRN:, Mother Record Number:, Claimant ID:, Merged MRN: refuse. The rule is now a listed vocabulary (kind words, the obligation's own label, the ID prefix, _PREFIX_WORDS), not letter order or initials.
  • Non-blocking items: phrase_affirmed now refuses undo, previously, before, outbox, queued; the PR body states what it leaves open.

Verification at this head (Linux, Python 3.12)

  • packages/types: 1078 passed.
  • packages/kernel: 362 passed, 1 skipped.
  • Flow test_evidence_parity.py and test_evidence_pending_callers.py: 122 passed, 80 xfailed.
  • Root tests/test_transducer_obligations.py, test_transducer_v3_runtime.py, test_transducer_form_batch.py, test_simplex_transducer.py, test_evidence_vendored.py, test_evidence_pending_callers.py: 309 passed, 31 xfailed.
  • check_verdict_folds.py: "Verdict folds OK (2615 baseline folds left)". check_engine_generality.py: OK. ruff check on the changed evidence, transducer and kernel files: clean. mypy src in packages/kernel: clean. The launcher and types copies of the matcher are identical below their headers.

New adversarial probes (throwaway, not committed)

  • Matcher, about 45 cases. Modifier before the label with each separator I could think of (newline, comma, dash, slash, bullet, bare cell, non-breaking spaces, zero-width space, Prev., Old-MRN, Ex-MRN, (Previous), = instead of :, uppercase, Mother's, list-item prefixes, JSON keys previous_mrn, mrn_old, "previous mrn") all AMBIGUOUS. A legitimate multi-field row (Name: … | MRN: … | DOB: …, empty cell before the label, ||) still MATCH. Previous MRN: MRN-9 | MRN: MRN-1 verifies MRN-1 and, for an expected MRN-9, correctly does not verify the previous value.
  • Transducer, about 60 cases (compile_obligations_from_spec plus diff_readback_against_obligations). Refused as expected: Mother's MRN, Mother MRN, Newborn MRN, Spouse MRN, MRN (mother), MRN-mother, Old MRN, Original/Orig./Related/Parent Claim ID, Claim ID (original), Insurance Charge, Previous Charge, Refund Amount, Discount, Amount Paid, dates labelled Death, Birth, Last, Next, Admission, Discharge and Billing Date of Service, and Secondary, Rule-out, Family History, Excluded diagnoses. Verified as expected: Medical Record Number, MRN, Claim ID, Claim Number, Claim No., Charge Amount, Total Charge, Visit Date, Date of Service, Service Date, Diagnosis Code, Dx, ICD-10 Code. Claim #: refuses (a safe false refusal).
  • Kernel bindings. Qualified keys score as the PR states.

Limitations I found (non-blocking; none is a regression and each is the nature of text matching)

  1. A heading on the line before a label still binds it: Mother\nMRN: MRN-1 verifies MRN-1, as does {"old": {"mrn": "MRN-1"}}. This is the cross-line case the PR already declines to check; refusing it would refuse ordinary multi-line record views. Worth a line in the PR's limits.
  2. Claim ID: CLM-1234\nStatus: rejected verifies, as does MRN: MRN-104\nRelationship: mother (also in the PR body). Total: and a bare Date: still name their kinds (also in the PR body).
  3. In the kernel, an unqualified binding or label can name a qualified key: a binding or text label Name verifies mother_name and last_name, Number verifies phone_number, Code verifies state_code, and a bare ID binding verifies member_id. This comes from the existing key-alias rule that main already had and the PR deliberately keeps (State for state_code); it is not new here. If an agent writes the mother's name into the patient Name field, the read-back would verify. Consider requiring the qualifier word when a key has one, in a follow-up.

Generality gate

  1. No per-app code: pass. The rules are generic text structure plus listed vocabularies; no application names appear.
  2. Fix the class: pass. A label binds only at a hard separator, and ID labels are an allowlist, so unseen modifiers refuse by default instead of needing to be listed.
  3. Held-out evidence: the corpus (129 cases) and 36-screen launcher test come from the review, but my ~105 independent phrasings, including separators and vocabulary the PR does not list, all fail closed.

CI at this head

When checked: 12 pass, 18 skipped by the path filter, 18 pending (the flow core unit, flow default at rest, types, verify, agent shim and lint shards among them), 1 failing: windows replay (Patient Notes, WindowsBackend), which fails on unrelated branches and also failed at the previous head. No other failures.

Not run

macOS-only tests, Playwright and OCR callers, a benchmark rerun. The 13 launcher failures the author reports (CLI surface, metadata, PATH) were not re-run here; I ran only the evidence- and transducer-related launcher tests listed above.

I did not push to this branch and will not merge it.

@abrichr
abrichr added this pull request to the merge queue Nov 30, 2026
@abrichr
abrichr removed this pull request from the merge queue due to a manual request Nov 30, 2026
#2786 merged after this branch was written, so the 21 cases it refuses
now pass and their strict xfail markers failed the merge queue. The 36
cases check_identity still verifies keep their markers.
@abrichr

abrichr commented Nov 30, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: f153b7d

This is a test-only follow-up to my APPROVE at 46f039865, plus a clean merge of origin/main. The matcher, corpus and types tests are unchanged from that head. I did not re-run the earlier throwaway probes, because those files are identical.

What changed since 46f039865

  • 1b57783c9 merges origin/main (at 504c91450). git show --remerge-diff is empty: no conflict resolutions. This PR's files and main's files since the merge-base do not overlap.
  • f153b7d9d is 6 insertions and 38 deletions in packages/flow/tests/test_evidence_pending_callers.py and packages/types/docs/evidence-migration.md. It deletes GUARD_FIXED_ON_BRANCH and GUARD_REASON, keeps the 36 GUARD_STILL_LOOSE strict markers, and rewords two comments plus the migration doc from "PR fix(flow): identity gate refuses lookalike values before a guarded write #2786 at 1ee554d" to "merged". No assertion changed.

Why the markers should come off

#2786 is on main, so check_identity now refuses the 21 field cases that used to be xfail(strict=True). I ran all 68 corpus field-refusal cases through check_identity at this head: all 21 named cases return mismatch, all 36 GUARD_STILL_LOOSE cases still return verified, and the 11 cases that already refused still refuse. Leaving the 21 markers would fail the merge queue with XPASS(strict), which is what the test's docstring says to fix by deleting the marker.

Verification at this head (Linux, Python 3.12)

  • packages/types: 1078 passed. The test_evidence*.py pair: 162 passed.
  • Flow test_evidence_pending_callers.py: 40 passed, 59 xfailed, no XPASS. Together with test_evidence_parity.py: 143 passed, 59 xfailed (21 more passes and 21 fewer xfails than at 46f039865).
  • Root tests/test_evidence_pending_callers.py: 31 xfailed, no XPASS.
  • packages/kernel/tests/test_evidence_vendored.py: 213 passed.
  • packages/flow/scripts/check_verdict_folds.py: "Verdict folds OK (2615 baseline folds left)". packages/flow/scripts/check_engine_generality.py: "Engine generality OK (7 baseline hits left)". ruff check on the two changed files: clean.

Generality gate

  1. No per-app code: pass. The delta is test markers and docs; the matcher is unchanged.
  2. Fix the class: pass. Deleting the strict markers after the fix landed is the process the test documents. The 36 cases check_identity still verifies stay marked.
  3. Held-out evidence: I independently classified all 68 corpus refusal cases, including the 11 that were never in either guard list. I did not re-run the ~105 earlier throwaway phrasings, because the matcher and corpus are identical to the approved head.

CI at this head

When checked: packages / types, kernel, flow core unit (4/4), flow default at rest (4/4), flow core lint, flow core critical, flow agent frameworks, agent shim, eligibility connector, verify (facade and clean install), smoke, packages-gate, install weight, on-prem offline, launcher / run-ci, dependency-review, gitleaks and validate-platform-manifest all succeeded. Path-filter skips are unchanged.

Two failures:

  • Evaluate review verdict / review-verdict: expected, because there was no review comment at this head yet.
  • windows replay (Patient Notes, WindowsBackend): QualifyError on fault-stale-identity (qualification case requires exactly one fault_receipt evidence artifact). This job also failed at the previous approved head. This PR does not change the qualification campaign.

Limitations

The 36 still-loose check_identity cases remain, as the migration doc lists. The matcher limitations from my review at 46f039865 still apply; the matcher did not change.

Not run

macOS-only tests, Playwright and OCR callers, a benchmark rerun, and the earlier throwaway matcher probes.

I did not push to this branch and will not merge it.

@abrichr
abrichr added this pull request to the merge queue Nov 30, 2026
Merged via the queue into main with commit 5264b10 Nov 30, 2026
53 of 55 checks passed
@abrichr
abrichr deleted the claude/evidence-matcher-corpus-f04cf8 branch November 30, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant