Skip to content

feat(flow): effect-location record and evaluator - #2500

Merged
abrichr merged 5 commits into
mainfrom
claude/effect-location-record
Nov 22, 2026
Merged

abrichr merged 5 commits into
mainfrom
claude/effect-location-record

Conversation

@abrichr

@abrichr abrichr commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What this adds

A general record of where an intended value shows after an action, and one evaluator for it. It is step 1 of moving form_tx's checks into the shared verifier layer.

An effect location (openadapt.effect-location/v1) is pack data compiled from a demonstration. For each intended value it holds:

  • the path from the demonstration and a start condition (same_screen, fresh_navigation, new_session or other_channel);
  • a locator (label, row_key or region);
  • the expected value;
  • a codec, including template (one summary row such as "Name (DOB)" read as two values), split_date, unit, money, date, bool and enum;
  • the expected count (required, usually 1);
  • an optional baseline.

evaluate_all(plan, locations, readings, run_id=...) judges every planned value as held, refuted or not_checked. These are the verdict kernel's three statuses.

  • not_checked. The value is not_checked when:
    • no location shows it, or its location was not read or not found;
    • the location was found a different number of times than expected;
    • the read failed, came from another run or didn't meet the start condition;
    • a kind is unknown, or the text can't be read;
    • the read was partial and showed no conflict;
    • the expected value equals the baseline, so the read can't tell the change from what was already there.
  • refuted. A read shows a different value. A partial read can refute.
  • held. Every location for the value was read in full and showed exactly the expected value, the expected number of times.
  • Passing. The run passes only when every planned value held and no reading is left over. An empty plan never passes.

The codecs read the whole displayed text, so a prefix or a longer text never matches (C5). The engine holds no default words: month names, yes and no tokens, currency signs, units and lookup tables come from the pack. check_engine_generality.py passes.

The ladder (#2495) and the harness (#2476)

Neither is on main yet. effect_location/_compat.py codes against their interfaces, and goes away once both merge:

  • The check level is openadapt_types.check_level.CheckLevel, which is on main:
    • same_screen is level 1;
    • fresh_navigation is level 2 (reopened);
    • new_session is level 3 with basis separate_session;
    • other_channel is level 4, and only with a basis that level_for_basis says reaches level 4.
  • The receipt word is check_level.outcome_word when it exists. Until then the word is None. This package never decides what VERIFIED means.
  • verdict_site is feat(flow): one verdict kernel, a fail-open harness and a fold ratchet #2476's decorator when it exists. Until then a no-op records the id.

evaluate_all is registered as effect_location.evaluate_all. Its spec is tests/failopen/sites/effect_location.py. That file isn't collected on main, because it isn't a test_ file.

Open question for the ladder. The generality ruling says a proven fresh reload is VERIFIED. #2495's outcome_word makes level 2 SHOWN and has no basis for a reload. This PR follows #2495, so fresh_navigation is SHOWN. If the ruling should stand, #2495 needs a reload basis. Nothing here would change except the table.

Tests

All synthetic. No real-app run.

  • tests/test_effect_location.py on this branch (based on main): 48 passed, 9 skipped. The 9 are the receipt-word tests and the mutant test, which need feat(ladder): one check-level ladder and evidence-scope receipts on every path #2495.
  • A local merge of this branch with claude/fail-open-general and claude/nodb-ladder:
    • tests/test_effect_location.py, tests/test_effect_location_mutants.py and tests/failopen/: 176 passed, 1 skipped. The skip is the "no ladder" test.
    • The new spec passes all 445 generated mutations over 7 seeds.
    • test_registry_complete.py finds the decorated site and its spec.
    • check_verdict_folds.py counts no new fold in effect_location/. That isn't the same as building on settle. The status words are a Literal type, which the ratchet doesn't count. _judge and _combine produce held outside the decorated function, and only evaluate_all is registered. Once feat(flow): one verdict kernel, a fail-open harness and a fold ratchet #2476 merges, a follow-up should rebuild the fold on verdict.settle.
  • Planted mutants, each killed by the harness. They are committed as tests/test_effect_location_mutants.py, which skips until the harness is on the branch:
    • treating a partial read as complete (M5, M10, M15);
    • ignoring the run binding (M5, M8);
    • keeping only the first of several matches (the found-twice seed);
    • ignoring a read error (M4).
  • KeyResult.code gives each result a reason from a fixed set (CODES), so a caller can tell "not found" from "found but unreadable" without parsing the English reason.
  • ruff check, ruff format --check and mypy openadapt_flow/effect_location are clean. test_capabilities_map.py, test_shipped_only_copy.py and test_import_direction.py pass.

Not in this PR

No runner uses the record yet. The next PRs, each small and based on #2461, port these form_tx checks onto it:

  1. the review-page check;
  2. the combined summary row;
  3. the lookup-table row.

After those, the domain presets move out of the engine into pack JSON.

Since opening

An effect location is pack data for one place a careful person would look
again to see an intended value: the demonstration path and start condition,
a locator, the expected value, a codec (including a template codec for one
summary row that shows two values, and a split-date codec), the expected
count and an optional baseline.

evaluate_all judges every planned value as held, refuted or not_checked.
A location that can't be reached, found or read is not_checked. The check
level follows the start condition, and the receipt word comes from
check_level.outcome_word when it is available. It is registered as a
verdict site for the fail-open harness (#2476) through a small compat
module, so it works on main today and picks up the real decorator and
ladder when they merge.
…ncy signs

The branch's first commit was cut against a newer main than its tree, so it
reverted the GOLD crop and veto guard work from #2485. This puts those files
back as they are on main. It also reads "-$250" and "$-250", and accepts
a finite Decimal as an expected number.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Gemini (gemini-3.1-pro-preview), round 1
Reviewed-Head: c72222a

Sent the full diff and every changed file in full.

This is an excellently designed package. The evaluation logic is robust, strictly fail-closed, and perfectly adheres to the generality rule by keeping all application-specific vocabulary (month names, currency signs, yes/no tokens) in the pack data. The fail-open harness spec is also comprehensive.

However, there is a severe issue with the PR's diff that must be fixed before merging.

BLOCKER

Accidental revert of GOLD cropping and Veto VLM Guard
The PR accidentally deletes the GOLD ROI cropping and Veto VLM Guard features that were recently added to the runtime. This is a massive behaviour change that the PR description does not claim, likely caused by a bad git rebase or merge conflict resolution.

  • packages/flow/openadapt_flow/runtime/identity_vlm.py: Deletes VetoVerdict, VetoDecision, and VetoOnlyVLMGuard.
  • packages/flow/openadapt_flow/runtime/remote_vlm.py: Deletes extract_roi_crop, GoldCropResult, gold_crop_for_model, and removes the roi parameter from RemoteGrounder.locate and RemoteStateVerifier.verify.
  • packages/flow/tests/test_local_vlm_gold_crop.py: Deleted entirely.
  • packages/flow/tests/test_remote_vlm.py & test_wire_remote_vlm.py: Modified to remove the reverted features' tests.

Please restore these files to their state on main.

NIT

Negative currency with leading signs
In packages/flow/openadapt_flow/effect_location/codecs.py (lines 55-61), _number strips affixes before checking for a negative sign. If a negative currency is formatted as -$250 and the affix is $, the $ will not be stripped because the string starts with -, not $. The subsequent re.match will fail and raise a CodecError. While this is safely fail-closed (results in not_checked), it might cause valid negative currency readings to fail if they are formatted this way.

Decimal objects in the plan
In packages/flow/openadapt_flow/effect_location/codecs.py (lines 182-187), canonical for number and unit accepts int and str, but if a plan passes a Decimal object directly, it will fall through and raise CodecError("the expected value is not a number"). This is safely fail-closed and plans are usually JSON-serializable types anyway, but it might be worth noting or supporting if Decimal plans are ever expected.


REQUEST CHANGES

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Gemini (gemini-3.1-pro-preview), round 2
Reviewed-Head: 9d563a0

Sent the full diff, every changed file in full and the round 1 findings.

This is an excellently designed package. The evaluation logic is robust, strictly fail-closed, and perfectly adheres to the generality rule by keeping all application-specific vocabulary in the pack data. The fail-open harness spec is also comprehensive.

Thank you for addressing the earlier findings. The accidental revert of the GOLD cropping and Veto VLM Guard features has been fixed, and the diff is now clean. The nits regarding negative currency with leading signs and Decimal objects in the plan have also been perfectly addressed.

I have reviewed the rest of the PR for correctness bugs, fail-open paths, API problems, and test gaps, and found no issues. The evaluation logic correctly handles partial reads, unexpected readings, baseline comparisons, and start condition hierarchies in a strictly fail-closed manner.

Great work!

APPROVE

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 9d563a0

Author declaration. I wrote this change and checked it at the head above.

…t test

KeyResult.code says why, from a fixed set (CODES), so a caller can tell
"not found" from "found but unreadable" without matching English text.
The planted-mutant check of the fail-open spec is now a test; it skips
until the harness from #2476 is on the branch.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Gemini (gemini-3.1-pro-preview), round 3 (delta since 9d563a0)
Reviewed-Head: 52a0a7b

Sent the diff since the round-2 head, the changed files in full and the round-2 findings.

This is a clean and well-executed delta. The addition of KeyResult.code provides a robust, machine-readable way for callers to branch on evaluation outcomes without relying on human-readable reason strings. The CODES set is comprehensive and perfectly matches the implementations in _judge, _combine, and evaluate_all.

The planted-mutant tests are an excellent addition to ensure the fail-closed properties of the evaluator remain intact against regressions.

I have reviewed the diff for correctness bugs, fail-open paths, API problems, and test gaps, and found no issues. The evaluation logic remains strictly fail-closed and adheres perfectly to the generality rule.

Great work!

APPROVE

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 52a0a7b

Author declaration at the current head. The delta since the previous declared head (9d563a06f) is one commit:

Tests at this head, synthetic only:

Gemini reviewed the delta in round 3, at this head. The PR body now has these numbers. It also drops a sentence that said #2508 depends on code; #2508 reads only .passes.

@abrichr
abrichr marked this pull request as ready for review November 22, 2026 03:38
…valuator

Following the coordinator's ruling: a fresh navigation whose adapter names
the fresh_reload basis (#2509: cache bypassed, the request kept as evidence)
is a level 3 check, which the ladder words VERIFIED. Without that basis it
stays level 2 (reopened), SHOWN. The claim never satisfies a location that
requires a new session.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Gemini (gemini-3.1-pro-preview), round 4 (delta since 52a0a7b)
Reviewed-Head: 6e741bf

Sent the full diff of this PR's own files, those files in full, and any earlier findings.

This is a clean, well-executed delta that correctly introduces the fresh_reload basis for fresh_navigation readings.

The implementation in _level_and_basis is precise and safe. By evaluating the start condition requirement (LEVEL_OF_START[got] < LEVEL_OF_START[wanted]) before applying the basis elevation, the engine correctly ensures that a location demanding a new_session (to verify isolation from session state) will reject a fresh_navigation reading, even if it carries a fresh_reload proof. The explicit test for this (test_a_reload_claim_never_meets_a_new_session_requirement) proves this fail-closed property is preserved.

I have reviewed the diff for correctness bugs, fail-open paths, API problems, test gaps, and generality violations. The logic is strictly fail-closed, the tests are comprehensive, and the documentation clearly explains the burden of proof on the adapter.

Great work!

APPROVE

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 6e741bf

Author declaration at the head above. Synthetic tests only; no real app was run.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 6e741bf

Independent cross-vendor adversarial review of 6e741bf7cab37a16d8776c03ef33f873db6587a4 (Claude-authored; I authored none of this PR).

Findings & fail-closed verification

  • Fail-closed evaluation (evaluator.py): evaluate_all requires a non-empty plan, rejects duplicate location IDs (duplicate_location), unread locations (not_read), stale location expectations (stale_record), conflicting plan values (plan_conflict), and unexpected extra readings (unexpected). _judge rejects empty/mismatched run_id, read errors, non-boolean complete, unmet start conditions, missing or wrong-count matches, CodecErrors, partial reads without conflict, invalid baselines, and values equal to baseline (same_as_baseline), while allowing partial reads to refute (mismatch). Exact type equality (_same) prevents True == 1 / "1" == 1 coercion. _combine enforces weakest-level-wins across locations and readings.
  • Start condition & fresh_reload boundary (_level_and_basis, _compat.py): LEVEL_OF_START[got] < LEVEL_OF_START[wanted] is enforced before basis promotion, so a fresh_navigation reading with fresh_reload never satisfies a new_session requirement, and promotes to CheckLevel.SEPARATE_SESSION only when _compat.reaches("fresh_reload", CheckLevel.SEPARATE_SESSION) confirms the ladder lists it. Until #2495/#2509 land on main, _compat.word returns None and _compat.reaches returns False, keeping the module strictly fail-closed without inventing receipt words.
  • Whole-text codecs & schema strictness (codecs.py, record.py): All scalar, split_date, and template codecs match the entire displayed text (^...$ / re.fullmatch), reject stray match keys, reject bool/float where integers/decimals are required, and require explicit expected_count and all Reading fields in from_dict.

Generality gate

  1. No per-app code in engine: Verified; zero app, domain, or language-specific defaults in openadapt_flow/effect_location/ (month names, yes/no tokens, currency signs, units, and lookup tables are supplied by pack Codec data).
  2. Fix the class, not the instance: Verified; one typed openadapt.effect-location/v1 record schema, codec layer, and fail-closed evaluator replace ad-hoc UI/channel value checks across applications.
  3. Held-out evidence: Honestly disclosed as synthetic unit tests and fail-open mutation specs only; no real-app run was executed in this PR.

@abrichr
abrichr merged commit 4bd15d1 into main Nov 22, 2026
57 of 59 checks passed
@abrichr
abrichr deleted the claude/effect-location-record branch November 22, 2026 14:49
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