Skip to content

fix(flow): tutorial --break-it demonstrates a partial save, not a lying banner - #2905

Open
abrichr wants to merge 3 commits into
mainfrom
fix/quickstart-break-it-real-fault
Open

abrichr wants to merge 3 commits into
mainfrom
fix/quickstart-break-it-real-fault

Conversation

@abrichr

@abrichr abrichr commented Dec 3, 2026

Copy link
Copy Markdown
Member

What changes

openadapt-flow tutorial --break-it (and openadapt-flow demo, which runs the same pair) used MockMed's optimistic fault: the backend rejected the write after the app painted its success banner. That failure was made up for the demo. This PR switches the rerun to MockMed's existing partial fault, the same one #2883 uses for the launcher quickstart:

  • The backend stores the encounter but drops the typed note.
  • The app still closes the form and shows "Encounter saved" with the note.
  • Reading the record back shows the encounter with a blank note, which is what a careful person sees when they reopen it.

The engine refutes the mined field_equals contract on the note and HALTs with RECONCILIATION_REQUIRED. No engine, gate, policy or verifier code changed. Only the injected fault and the words describing it changed.

Files

  • tutorial.py: TUTORIAL_BREAK_FAULT = "partial". BreakItResult gains notes_as_typed: the number of stored rows whose note equals the typed note, read from the store. Docstrings and the [break-it] lines are rewritten. _run_break_it, --break-it and every other public name are unchanged.
  • __main__.py, cli/try_and_measure.py: the narrative and the --break-it help text describe the dropped note. The closing sentence is picked from the evidence (encounter present and 0 notes as typed → "note blank").
  • demo_proof.py: the page used to tell the two runs apart by records == 0. That count is now 1 for both runs, so the run card counts typed notes found instead (1, then 0), and "records in the store" in Technical details shows the raw row count. The Run 2 title changes from "Stopped: the note never reached the record" to "Stopped: the record is missing the typed note". The new title has no apostrophe because the page HTML-escapes text.
  • tests/fixtures/cli_surface.json: regenerated with OPENADAPT_WRITE_CLI_SURFACE=1 on Python 3.12. Only the --break-it help text changed. No flag was added or removed.
  • Tests: test_cli_tutorial_break_it.py, test_cli_tutorial_next_steps.py, test_demo_proof.py and e2e/test_tutorial_break_it_e2e.py now expect fault="partial", 1 encounter row, 0 notes as typed, and field_equals in the halt reason. A new unit test checks that notes_as_typed is counted from the stored rows rather than assumed from the fault. The CLI test asserts that "rejects the write" and "believ…" no longer appear.
  • docs/TUTORIAL.md: new description and real output.
  • packages/desktop/.../flow_bridge.py: one docstring line, in a separate docs(desktop) commit.

Left unchanged on purpose

  • The qualify accept oracle gate's unchanged_store break-it fixture (qualification_oracle_gate.py and its schema surface). It is a separate feature. Its tests pass unchanged.
  • The benchmark packs (fault_model, effect_e2e, agent_guard, effectbench) that use optimistic as one scenario among many.

Before (origin/main, real run)

--- break-it: the same certified bundle, with the save set to fail ---

  Injected fault:      'optimistic' -- the server rejects the write
  On screen:           every on-screen check passed, including the saved message
                       (observed on screen: "Encountersaved-")
  The verifier found:  1/2 declared effect(s) REFUTED by an independent
                       read of the system of record, which holds 0 record(s)
  The engine did:      HALTED at the consequential step instead of claiming
                       success (transaction: RECONCILIATION_REQUIRED, billable: no)
  Result:              Check the record. A save may have gone through. A person checks the record before anything is retried.

  The screen looked the same as a good save. The record check found no new note,
  so the engine stopped instead of reporting done.

  Engine's own words:  System-of-record effect verification HALTED step 'step_005' (click 'Save Encounter'): record_written refuted against the rest system of record and could not be reconciled (escalated) — [rest] record_written: 0 records match the target selector, expected 1 (missing / phantom / rejected write -- the screen may show success but nothing landed) -- no compensator available for an irreversible refuted effect -- durably halt and escalate — run aborted

After (this branch, real run)

--- break-it: the same certified bundle, with a save that drops the note ---

  Injected fault:      'partial' -- the app saves the encounter but drops the typed note
  On screen:           every on-screen check passed, including the saved message
                       (observed on screen: "Encountersaved-")
  The verifier found:  1/2 declared effect(s) REFUTED by reading the record
                       back: 1 encounter(s), 0 with the note as typed
  The engine did:      HALTED at the consequential step instead of claiming
                       success (transaction: RECONCILIATION_REQUIRED, billable: no)
  Result:              Check the record. A save may have gone through. A person checks the record before anything is retried.

  The screen looked the same as a good save. The record read back held
  the encounter with its note blank, so the engine stopped instead of reporting done.

  Engine's own words:  System-of-record effect verification HALTED step 'step_005' (click 'Save Encounter'): field_equals refuted against the rest system of record and could not be reconciled (escalated) — [rest] field_equals: field 'note' is '', expected 'Synthetic follow-up in two weeks' (the system of record contradicts the declared outcome) -- no compensator available for an irreversible refuted effect -- durably halt and escalate — run aborted

Tests

All runs on macOS, Python 3.12.7, through the shared CPU-slot runner.

pytest tests/test_cli_tutorial_break_it.py tests/test_cli_tutorial_next_steps.py \
  tests/test_cli_surface.py tests/test_qualification_oracle_gate.py tests/test_demo_proof.py \
  tests/test_tutorial_presentation.py tests/test_tutorial_demo_app_replay.py \
  tests/test_outcome_epilogues.py tests/test_schema_surface.py
90 passed, 2 skipped in 60.97s

pytest tests/e2e/test_tutorial_break_it_e2e.py   # real headless browser, both runs
6 passed in 207.17s

ruff check (all touched files): All checks passed

Follow-ups (not in this PR)

  • packages/seal-view/src/lib/sealSummary.mjs maps halt reasons to plain words and has no pattern for field_equals … field 'note' is ''. A halted tutorial run emits no receipt, so this code path can't be reached today.
  • feat(quickstart): check each save the way a person would #2883 (the launcher quickstart's ?fault=partial beat) is still open. openadapt quickstart --break-it delegates to this tutorial for the engine half.

…ng banner

The --break-it rerun used the MockMed `optimistic` fault: the backend
rejected the write after the app painted its success banner. That is a
fabricated failure and does not match how the quickstart now frames a
caught save (#2883, `?fault=partial`).

Switch the rerun to the existing `partial` fault: the backend stores the
encounter but drops the typed note, the app still closes the form and
shows its saved message, and reading the record back shows a blank note.
The engine refutes the mined `field_equals` contract on the note and
HALTs (RECONCILIATION_REQUIRED), same as before.

- tutorial.py: TUTORIAL_BREAK_FAULT = "partial"; BreakItResult gains
  notes_as_typed (rows whose stored note equals the typed note), read
  from the store; docstrings and [break-it] lines rewritten.
- __main__.py / cli/try_and_measure.py: narrative and --break-it help
  describe the dropped note; the closing sentence follows the evidence.
- demo_proof.py: the run card counts typed notes found, so the pair
  still shows the difference when the encounter row exists; the Run 2
  title is "Stopped: the record is missing the typed note".
- tests and cli_surface.json updated (OPENADAPT_WRITE_CLI_SURFACE=1);
  e2e now asserts 1 encounter row, 0 notes as typed, field_equals in the
  halt reason. docs/TUTORIAL.md shows the new output.

The qualify-accept oracle gate's own unchanged-store fixture is a
separate feature and is untouched.
The break-it rewording grew __main__.py 10 lines past its size budget, which
failed the smoke job. The narrative now lives in break_it_narrative.py;
__main__.py keeps a thin _print_break_it_narrative for the call site and the
import surface, and its budget drops to 10346.
@abrichr

abrichr commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 8d026b1

The switch of tutorial --break-it (and demo) from MockMed's optimistic fault to the existing partial fault is the right demonstration: the backend keeps the encounter and drops the typed note, the screen still looks saved, notes_as_typed is counted from the store (record.get("note") == typed_note), and the engine has to HALT or run_tutorial raises. I did not find engine, gate, policy or verifier changes.

_run_break_it records system_of_record_records=len(records) and notes_as_typed separately. The proof page now counts typed notes on the run card and still shows raw "records in the store" under Technical details. The Run 2 title "Stopped: the record is missing the typed note" is gated on a halted stop, a success screen, and notes_as_typed == 0, and the explanation says the encounter was found when rows_in_store is set. The previous "rejects the write" / "believ…" wording is gone from the tutorial surface I read.

Commit 8d026b1a fixes the earlier smoke failure at 638ad8fc: _print_break_it_narrative is now a one-call wrapper, the body lives in break_it_narrative.py, and the __main__.py budget in DECOMPOSITION.md is lowered 10395 → 10346 (the file is 10346 lines). Smoke passed at this head.

Generality gate. No engine behavior changed. The new wording lives in tutorial.py, demo_proof.py, break_it_narrative.py, docs and the tutorial CLI help — not in identity, resolution, or halt logic. The new module does not name a denylisted application. I did not run check_engine_generality.py at this head.

Limitations. RunEvidence.records means row count on the clean run and notes_as_typed on the broken run. The comments say why, and showed_the_difference plus the cards work on the intended path (a VERIFIED clean run with the note present). A clean run that was not actually note-checked could still be described as "N typed notes found". The printed fault blurb is still hardcoded to the partial-note story; the closing "note blank" sentence is taken from the evidence. I did not re-run the author's local 90 unit + 6 e2e tests (macOS, Python 3.12.7), which were reported against the earlier commits.

CI at 8d026b1a14cbc36f52da5bd6f1becb204f65174d. Smoke (https://github.com/OpenAdaptAI/OpenAdapt/actions/runs/47109765858/job/144265077313), launcher / run-ci, flow core lint, flow agent frameworks, desktop Frontend behavior and build, gitleaks, dependency-review, and review-verdict (no protected paths) have passed. At the time I posted, packages default-at-rest, flow core unit, flow core critical, on-prem offline install, verify facade / clean install, and some desktop test jobs were still running (https://github.com/OpenAdaptAI/OpenAdapt/actions/runs/47109765858). I will not merge this PR.

This branch has not been deployed

No deployments
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