Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ print(safe_save.last_receipt["outcome"], safe_save.last_receipt["checked_how"])

### Try It in 30 Seconds

Run the local smoke test against a bundled demo server (no account or API key required), or trigger a deliberate drift to inspect a halted run and its signed receipt:
Run the quickstart against a bundled demo app (no account or API key required). It shows a task once, runs the compiled program and checks the save in the app's database, then stops the runner partway through a batch and restarts it: the restart skips the note that was already saved and saves only the next one.

```bash
uvx --python 3.12 openadapt@latest quickstart --break-it
uvx --python 3.12 openadapt@latest quickstart
```

### Wrap an Agent or Serve Compiled Workflows over MCP
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
| See a crash and a restart in the quickstart: on MockMed, Act 3 runs a batch of two new notes in a separate worker process, stops it with SIGKILL after note 1's save is checked, and restarts the batch with the same on-disk write ledger (`IdempotencyLedger`); the replayer finds note 1's key and sends no save for it (its report: idempotent replay, 0 actions), then saves note 2; each note's database is read afterwards. Each note has its own copy of the clinic's database, as in Act 2 | On main ([#2840](https://github.com/OpenAdaptAI/OpenAdapt/pull/2840)) | Synthetic (MockMed; real headless runs on macOS, unit tests with fakes) | `openadapt quickstart`; [restart.py](openadapt/quickstart/restart.py) |
17 changes: 9 additions & 8 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ installed `openadapt-flow` engine.
Run `<task> --help` to see its arguments or related operations. For example:

```bash
openadapt quickstart --break-it
openadapt quickstart
openadapt verify effect --help
openadapt inspect lint bundle
openadapt run --replay bundle --run-dir run
Expand Down Expand Up @@ -57,13 +57,14 @@ uv fetches Python 3.12 for the run. With `openadapt` installed, run

`openadapt demo tutorial` is the command that writes a `VERIFIED` receipt. It
runs the bundled synthetic MockMed workflow from recording through an
independently verified Standard-profile result. `openadapt quickstart --break-it`
(also `openadapt demo quickstart --break-it`; with uv, `uvx --python 3.12
openadapt@latest quickstart --break-it`) is the halt demo. It reruns the same certified bundle against a backend that
rejects the write after the app shows success. The independent read finds no
saved record, and the run halts with transaction outcome
`RECONCILIATION_REQUIRED`, so nothing is retried until a person checks the
record.
independently verified Standard-profile result. `openadapt quickstart`
(also `openadapt demo quickstart`; with uv, `uvx --python 3.12
openadapt@latest quickstart`) runs the same tutorial program, then a batch of
two notes in a separate worker process. It stops that process with SIGKILL
after note 1 is saved and checked, and restarts the batch with the same write
ledger on disk. The restart finds note 1 in the ledger, sends no save for it,
and saves note 2. The quickstart then reads each note's database and shows the
note there once.

The engine runs on Python 3.11 and 3.12. On Python 3.13 or newer, pip
installs only the launcher and every engine command prints the fix:
Expand Down
13 changes: 8 additions & 5 deletions docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ openadapt flow visualize <out>/bundle --out graph.html
openadapt flow lint <out>/bundle
```

Run the same certified bundle against a fault-injecting backend:
See what a crash does to a batch:

```bash
openadapt quickstart --break-it --out openadapt-quickstart-broken
openadapt quickstart --out openadapt-quickstart-restart
```

The application displays success, but the backend does not save the record.
The independent effect verifier detects the mismatch and returns `HALTED`.
After the tutorial run, the quickstart starts a batch of two notes in a
separate worker process and stops that process with SIGKILL after note 1 is
saved and checked. It restarts the batch with the same write ledger on disk.
The restart finds note 1 in the ledger and sends no save for it, then saves
note 2. Each note is in its database once.

## Run the manual demo lifecycle

Expand All @@ -58,7 +61,7 @@ an unarmed irreversible click. The permissive certification is only a smoke
gate. The Demo replay returns `COMPLETED_UNVERIFIED`, not `VERIFIED`.

Use `openadapt flow tutorial` for the effect-verified first run.
`openadapt quickstart --break-it` is the halt demo. For a real workflow, add
`openadapt quickstart` shows the crash and restart. For a real workflow, add
the application boundary, action risks, identity requirements, effect verifier,
fault cases, and deployment policy before production use.

Expand Down
37 changes: 31 additions & 6 deletions docs/quickstart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,36 @@
Re-record with `python scripts/record_quickstart.py --out
docs/quickstart/story`. `quickstart.gif` predates the five-step story and
needs a fresh `vhs` take.
- `inline-screenshot.png`: the third act on a terminal that draws images
(WezTerm), with the halted run's screenshot beside the database's answer.
- `inline-screenshot.png`: an earlier third act, which MockMed no longer
runs, on a terminal that draws images (WezTerm).
- `timing-2026-10-20.json`: the engine tutorial with `--break-it` (what
`openadapt quickstart --break-it` ran before) against the new quickstart,
three rounds each, interleaved, from `scripts/quickstart_timing.py`.
the quickstart ran before) against the new quickstart, three rounds each,
interleaved, from `scripts/quickstart_timing.py`.

## The three acts on MockMed

```bash
uvx --python 3.12 openadapt@latest quickstart
```

- **Act 1, show it once.** A demonstration in MockMed, a synthetic clinic
app, compiled into a program.
- **Act 2, run it.** The program on a new note, checked in the app's
database.
- **Act 3, stop it mid-batch, then restart.** A batch of two new notes runs
in a separate worker process. Each note's run reserves its key in the
engine's write ledger (`IdempotencyLedger`, in `restart/ledger/` under the
output folder) before its first action and records the outcome after the
record check. When note 1 is saved and checked, the quickstart stops the
worker with SIGKILL, before note 2 starts. It then runs the batch again in
its own process with the same ledger: the replayer finds note 1's key and
sends no save for it (its report shows an idempotent replay with 0
actions), and note 2 runs and saves. Last, it reads each note's database
and counts the note there. That count alone would not catch a resend:
MockMed's demo save carries a fixed key the app de-duplicates on. The
evidence that no second save was sent is note 1's restart report. Each note has its own copy of the
clinic's database, as in Act 2, because the tutorial program writes one
record per patient. `--no-restart` skips this act.

## On a real app: `--app openemr`

Expand All @@ -25,7 +50,7 @@ openadapt quickstart --app openemr

The same three acts on OpenEMR 8.0.0.3, a real open-source EHR, instead of the
bundled MockMed. The default stays MockMed: it needs no Docker and finishes in
about 22 seconds.
about 30 seconds.

- **Needs** Docker (Docker Desktop, or Podman with `DOCKER_HOST` pointed at
its socket) and a clone of this repository, because the OpenEMR fixture is
Expand Down Expand Up @@ -57,7 +82,7 @@ about 22 seconds.
account and browser. Each runs through the certified run path (the Standard
run gate, then the REST record check) and is read back from OpenEMR's
database with SQL: "✓ checked in OpenEMR's record".
- **Act 3, break it.** The quickstart adds an existing chart (Rosa Delgado,
- **Act 3, a referral that matches a chart.** The quickstart adds an existing chart (Rosa Delgado,
born 1958-03-27), then runs a referral for a Rosa Delgado born 1958-03-22.
OpenEMR's duplicate check lists the match, and the program stops before
saving ("Stopped before saving: possible duplicate"). SQL finds 0 new charts.
Expand Down
38 changes: 26 additions & 12 deletions openadapt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ def _is_externally_managed_error(error: BaseException) -> bool:
"--watch",
"--open",
"--headless",
"--no-restart",
"--no-break",
"--verbose",
"--headed",
Expand Down Expand Up @@ -823,7 +824,7 @@ def ask(prompt: str) -> str:
default="mockmed",
show_default=True,
help=(
"The app to run it in. mockmed is bundled (about 22 seconds, no Docker). "
"The app to run it in. mockmed is bundled (about 30 seconds, no Docker). "
"openemr runs OpenEMR 8.0.0.3 in Docker from a clone of the repository; "
"the first run downloads and installs it, later runs reuse it."
),
Expand All @@ -846,11 +847,16 @@ def ask(prompt: str) -> str:
),
)
@click.option(
"--no-break",
"no_break",
"--no-restart",
"no_restart",
is_flag=True,
help="Skip the last part, where one save fails silently.",
help=(
"Skip the last part, where the runner is stopped partway through a "
"batch and restarted."
),
)
# The old name of --no-restart, kept so existing scripts still work.
@click.option("--no-break", "no_break", is_flag=True, hidden=True)
@click.option(
"--verbose",
is_flag=True,
Expand Down Expand Up @@ -963,6 +969,7 @@ def quickstart(
app: str,
watch: bool,
open_seal: bool,
no_restart: bool,
no_break: bool,
verbose: bool,
more: bool,
Expand All @@ -982,13 +989,15 @@ def quickstart(
headless: bool,
break_it: bool,
) -> None:
"""Show a task once, run it, then watch it catch a save that didn't happen.
"""Show a task once, run it, then stop it mid-batch and restart it.

About 25 seconds, in a synthetic clinic app on this computer. OpenAdapt
About 30 seconds, in a synthetic clinic app on this computer. OpenAdapt
turns one demonstration into a program, runs it on a new note and checks
the save in the app's database, then makes one save fail silently: the
screen says saved, the database has nothing, and OpenAdapt stops. The
program makes no AI calls. Nothing in the output directory is overwritten.
the save in the app's database. Then it starts a batch of two notes,
stops the runner process hard after note 1 saves, and starts it again:
the restart reads the write ledger on disk, skips note 1, and saves only
note 2. The program makes no AI calls. Nothing in the output directory is
overwritten.

With --app openemr, the same three acts run on OpenEMR 8.0.0.3 in Docker,
with the certified referral program: referrals registered at once and
Expand Down Expand Up @@ -1092,7 +1101,7 @@ def quickstart(
outcome = run_quickstart(
root,
visible=visible,
break_it=not no_break,
last_act=not (no_restart or no_break),
verbose=verbose,
steps=steps,
interactive=False if yes else None,
Expand All @@ -1115,8 +1124,13 @@ def quickstart(
f"The quickstart stopped: {error}\nAnything it wrote is in {root}"
) from error
raise
if outcome.checked != len(outcome.runs) or (
outcome.broken is not None and not outcome.broken.stopped
restart = outcome.restart
if (
outcome.checked != len(outcome.runs)
or (outcome.broken is not None and not outcome.broken.stopped)
# A restart that ran and went another way; one that couldn't start
# (no second process) was skipped, not failed.
or (restart is not None and not restart.error and not restart.held)
):
raise click.exceptions.Exit(1)

Expand Down
14 changes: 7 additions & 7 deletions openadapt/quickstart/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""``openadapt quickstart``: show a task once, run it, break it.
"""``openadapt quickstart``: show a task once, run it, stop and restart it.

The first command anyone runs. It demonstrates one task in a synthetic clinic
app (MockMed), compiles it into a program, runs the program on a new note and
checks the save in the app's database, then makes one save fail
silently: the screen says saved, the database has nothing, and
OpenAdapt stops instead of reporting success.
checks the save in the app's database. Then it starts a batch of two notes,
stops the runner process hard after note 1 saves, and restarts it: the
restart reads the write ledger on disk, skips note 1, and saves only note 2.
"""

from __future__ import annotations
Expand Down Expand Up @@ -41,7 +41,7 @@ def next_steps(
check (run once, at the finale) for an older ``openadapt`` on PATH.
``offer_publish`` is given only in a terminal outside CI, with an engine
that can build public Seals. At the finale it asks once whether to put
the checked and stopped runs' Seals online. The offer appears only
the checked run's Seal online. The offer appears only
when Cloud accepts hosted Seals.
"""

Expand Down Expand Up @@ -72,7 +72,7 @@ def run_quickstart(
root: Path,
*,
visible: bool,
break_it: bool,
last_act: bool,
verbose: bool,
steps: Callable[[Outcome], NextSteps],
stream: Optional[IO[str]] = None,
Expand Down Expand Up @@ -115,7 +115,7 @@ def run_quickstart(
engine,
view,
next_steps=steps,
break_it=break_it,
last_act=last_act,
interactive=interactive,
verbose=verbose,
# Only on request (--open), and only when this output is the
Expand Down
Loading