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
11 changes: 11 additions & 0 deletions packages/desktop/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
# CHANGELOG


## v0.31.2 (2026-11-22)

### Bug Fixes

- **desktop**: omit initial UI policy argument and forward inspected policy on certification
- **desktop**: distinguish omitted policy from explicit selection in dispatcher and qualification
- **types,desktop**: align certification policy readback, strict bool catalog slots, and canonical v1 outcome bytes
- **types,desktop**: preserve v1 wire compat, tighten managed catalog schema, and support bundled Flow policy fallback



## v0.31.1 (2026-11-22)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/openadapt_desktop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
+-- backends/ Storage backend plugins
"""

__version__ = "0.31.1"
__version__ = "0.31.2"
37 changes: 19 additions & 18 deletions packages/desktop/openadapt_desktop/approval_mode.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
"""Only ask a person about problems: the Desktop side of the switch.

The switch lets a clinic stop approving routine items one by one. With it on,
an item saves without a person only when every check before and after the
save passes, and the record read back from the records system shows exactly
the values it was given. Everything else goes to a person in Needs you.
The switch lets an organization stop approving routine items one by one. With
it on, an item saves without a person only when every check before and after
the save passes, and the record read back from the records system shows
exactly the values it was given. Everything else goes to a person in Needs
you.

Who decides what:

* A clinic owner or admin turns the switch on in OpenAdapt Cloud, and the
clinic's privacy contact confirms. Desktop never turns it on. No IPC command
writes a switch record; :func:`accept_switch` exists for the Cloud status
client and for tests.
* An organization owner or admin turns the switch on in OpenAdapt Cloud, and
the organization's privacy contact confirms. Desktop never turns it on. No
IPC command writes a switch record; :func:`accept_switch` exists for the
Cloud status client and for tests.
* Anyone at this computer can turn it off, offline too. The switch-off goes
into Flow's hash-chained switch log, which Flow's pre-save gate reads before
every save, so it applies before the next save and Cloud can't undo it.
* Flow decides each item: the pre-save checks (P1 to P5), the post-run checks
(R1 and R2) and the switch-off rules. Desktop reads Flow's PHI-free
``approval`` block from the run report and never upgrades it. An item counts
as saved without a person only when that block says so, both post-run checks
passed, and the item's transaction outcome is a consistent ``VERIFIED``.
Desktop also checks the block against its own records before it lets the
item close without a person (:func:`confirm_no_person`); a block it can't
confirm needs a person.
(R1 and R2) and the switch-off rules. Desktop reads Flow's
sensitive-data-free ``approval`` block from the run report and never
upgrades it. An item counts as saved without a person only when that block
says so, both post-run checks passed, and the item's transaction outcome is
a consistent ``VERIFIED``. Desktop also checks the block against its own
records before it lets the item close without a person
(:func:`confirm_no_person`); a block it can't confirm needs a person.

What is local, per task version (local bundle id)::

Expand All @@ -30,8 +31,8 @@
<data_dir>/approval_mode/<bundle_id>/turned_off.json a switch-off made here

Nothing here holds an input value, screen content or free text. The names of
the clinic staff who turned the switch on and confirmed it are kept on this
computer only, to show who is accountable.
the staff who turned the switch on and confirmed it are kept on this computer
only, to show who is accountable.

The switch can't take effect on this computer yet. :func:`blockers` names
every missing piece, and while any is missing Desktop shows the switch as not
Expand Down Expand Up @@ -117,7 +118,7 @@ class SwitchEnvelope(BaseModel):

``record`` is Flow's switch record, validated with Flow's own model. The
two people are the accountable admin and the privacy contact. Their names
are display names from the clinic's own Cloud organization.
are display names from the organization's own Cloud account.
"""

model_config = ConfigDict(extra="forbid", frozen=True)
Expand Down
10 changes: 5 additions & 5 deletions packages/desktop/openadapt_desktop/check_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def learn_record_check(
}
constants = dict(sorted(surface.constants.items()))
# A fixed key the app sends with the save to stop a double save. Flow's
# clinical-write policy wants it on the record check; it is the app's
# record-write policy wants it on the record check; it is the app's
# own value, so it is checked as sent, never invented.
key_field = next((field for field in constants if _is_idempotency_field(field)), None)
idempotency_literal = constants.pop(key_field) if key_field else None
Expand Down Expand Up @@ -403,7 +403,7 @@ def answer_entry(answered_by: str, **extra: Any) -> dict[str, Any]:
# ---------------------------------------------------------------------------

_WRITE_CLASSES = frozenset({"state_changing", "consequential", "irreversible"})
POLICY = "clinical-write"
POLICY = "record-write"


def _plan(qualification: Mapping[str, Any]) -> dict[str, list[dict[str, Any]]]:
Expand Down Expand Up @@ -471,7 +471,7 @@ def get_check_setup(dispatcher: Any, workflow_id: str) -> dict[str, Any]:
inputs = dispatcher._task_inputs(workflow_id)
secrets = frozenset(str(item["name"]) for item in inputs if item.get("secret"))
recording = _recording_dir(dispatcher, workflow_id)
qualification = dispatcher.get_qualification(workflow_id=workflow_id, policy=POLICY)
qualification = dispatcher.get_qualification(workflow_id=workflow_id)
plan = _plan(qualification) if qualification.get("ok") else {"writes": [], "unproven": []}

if recording is None:
Expand Down Expand Up @@ -611,10 +611,10 @@ def accept_record_check(dispatcher: Any, workflow_id: str, *, answered_by: str)
"OpenAdapt has no record check to propose for this workflow. "
"Answer the questions in Check it."
)
current = dispatcher.get_qualification(workflow_id=workflow_id, policy=POLICY)
current = dispatcher.get_qualification(workflow_id=workflow_id)
if not current.get("project") or current.get("draft_environment"):
_start_project(dispatcher, workflow_id)
current = dispatcher.get_qualification(workflow_id=workflow_id, policy=POLICY)
current = dispatcher.get_qualification(workflow_id=workflow_id)
plan = _plan(current)
quiet = setup.get("quiet_steps")
if quiet:
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/openadapt_desktop/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def settings_customise_sources(
default="",
description=(
"The exact https origin your reverse proxy or VPN publishes for this "
"runner, e.g. https://openadapt.clinic.example. Required for "
"runner, e.g. https://openadapt.runner.example. Required for "
"'customer_ingress'; must not be set for 'loopback'."
),
)
Expand Down
8 changes: 4 additions & 4 deletions packages/desktop/openadapt_desktop/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2749,13 +2749,13 @@ def get_qualification(self, **params: Any) -> dict:
"""Inspect Flow's canonical graph, coverage, and certification contract."""

from openadapt_desktop.qualification import (
DEFAULT_QUALIFICATION_POLICY,
first_replay_review_is_draft,
inspect_bundle,
)

workflow_id = str(params.get("workflow_id") or "")
policy = str(params.get("policy") or DEFAULT_QUALIFICATION_POLICY)
raw_policy = params.get("policy")
policy = str(raw_policy).strip() or None if raw_policy is not None else None
try:
bundle = self._qualification_bundle_dir(workflow_id)
result = inspect_bundle(
Expand Down Expand Up @@ -3694,13 +3694,13 @@ def certify_qualification(self, **params: Any) -> dict:
"""Persist a pass/fail policy attempt into the resealed local bundle."""

from openadapt_desktop.qualification import (
DEFAULT_QUALIFICATION_POLICY,
certify_bundle,
first_replay_review_is_draft,
)

workflow_id = str(params.get("workflow_id") or "")
policy = str(params.get("policy") or DEFAULT_QUALIFICATION_POLICY)
raw_policy = params.get("policy")
policy = str(raw_policy).strip() or None if raw_policy is not None else None
try:
bundle = self._qualification_bundle_dir(workflow_id)
bundle_key = self._qualification_bundle_key(workflow_id)
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/openadapt_desktop/portal/ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def _validated_public_origin(raw: str) -> str:
):
raise IngressError(
"The portal ingress origin must be a bare https origin such as "
"https://openadapt.clinic.example, with no path, query, or credentials."
"https://openadapt.runner.example, with no path, query, or credentials."
)
if parsed.hostname.endswith("."):
raise IngressError("The portal ingress origin has an invalid hostname")
Expand Down
65 changes: 58 additions & 7 deletions packages/desktop/openadapt_desktop/qualification.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
QualificationEffectKind = Literal["record_written", "field_equals"]
QualificationIdentityEnforcement = Literal["canonical_ladder", "signal_quorum"]
QualificationTargetKind = Literal["web", "windows", "macos", "linux", "rdp", "citrix"]
DEFAULT_QUALIFICATION_POLICY = "clinical-write"
DEFAULT_QUALIFICATION_POLICY = "record-write"
LEGACY_FALLBACK_QUALIFICATION_POLICY = "clinical-write"
ENVIRONMENT_IDENTIFIER_DERIVATION = "sha256(trimmed UTF-8 operator identifier)"
FIRST_REPLAY_DRAFT_APPLICATION_VERSION = (
"openadapt-desktop-first-replay-draft/v1"
Expand Down Expand Up @@ -157,10 +158,60 @@ def _load(bundle_dir: Path, *, key: str | None = None):
raise QualificationError(f"Cannot open the sealed workflow bundle: {exc}") from exc


def _policy(source: str):
def _recorded_policy_name(workflow: Any) -> str | None:
"""Return the policy name recorded on an already-certified bundle, if any."""

project = getattr(workflow, "qualification", None)
last_cert = getattr(project, "last_certification", None) if project is not None else None
recorded = getattr(last_cert, "policy_name", None) if last_cert is not None else None
if isinstance(recorded, str) and recorded.strip():
return recorded.strip()
manifest = getattr(workflow, "manifest", None)
provenance = getattr(manifest, "provenance", None) if manifest is not None else None
prov_policy = getattr(provenance, "policy_name", None) if provenance is not None else None
if isinstance(prov_policy, str) and prov_policy.strip():
return prov_policy.strip()
return None


def _policy(source: str | None, *, workflow: Any = None):
"""Load an explicit policy or resolve the default for a bundle.

When ``source`` is ``None`` (omitted), reuse the bundle's recorded policy
if present; otherwise load ``DEFAULT_QUALIFICATION_POLICY`` (falling back
to ``LEGACY_FALLBACK_QUALIFICATION_POLICY`` only on older bundled Flow
versions that do not ship ``record-write``).

When ``source`` is explicitly provided, evaluate that exact selection
rather than overriding it with a previously recorded policy.
"""

load_policy = _flow_api()["load_policy"]
if source is None:
if workflow is not None:
recorded = _recorded_policy_name(workflow)
if recorded:
try:
return load_policy(recorded)
except (FileNotFoundError, ValueError):
pass
try:
return load_policy(DEFAULT_QUALIFICATION_POLICY)
except (FileNotFoundError, ValueError) as exc:
try:
return load_policy(LEGACY_FALLBACK_QUALIFICATION_POLICY)
except (FileNotFoundError, ValueError):
raise QualificationError(str(exc)) from exc
try:
return _flow_api()["load_policy"](source)
return load_policy(source)
except (FileNotFoundError, ValueError) as exc:
# Older bundled Flow versions (e.g. 2.4.x) ship clinical-write and permissive
# without the domain-neutral record-write alias. Fall back only for that alias.
if source == DEFAULT_QUALIFICATION_POLICY:
try:
return load_policy(LEGACY_FALLBACK_QUALIFICATION_POLICY)
except (FileNotFoundError, ValueError):
pass
raise QualificationError(str(exc)) from exc


Expand Down Expand Up @@ -835,14 +886,14 @@ def inspect_bundle(
bundle_dir: Path,
*,
workflow_id: str,
policy_source: str = DEFAULT_QUALIFICATION_POLICY,
policy_source: str | None = None,
bundle_key: str | None = None,
) -> dict:
"""Return graph, canonical project/report, controls, and exact refusals."""

api = _flow_api()
workflow = _load(bundle_dir, key=bundle_key)
policy = _policy(policy_source)
policy = _policy(policy_source, workflow=workflow)
graph_payload = program_graph(bundle_dir, workflow)
lint = api["lint_workflow"](workflow)
runtime_policy = api["evaluate_policy"](workflow, policy)
Expand Down Expand Up @@ -2235,7 +2286,7 @@ def certify_bundle(
bundle_dir: Path,
*,
workflow_id: str,
policy_source: str = DEFAULT_QUALIFICATION_POLICY,
policy_source: str | None = None,
bundle_key: str | None = None,
) -> dict:
"""Run Flow's canonical certification and persist the versioned report."""
Expand All @@ -2246,7 +2297,7 @@ def certify_bundle(
raise QualificationError(
"Initialize the qualification boundary before running certification."
)
policy = _policy(policy_source)
policy = _policy(policy_source, workflow=workflow)
workflow_contract = api["workflow_contract_sha256"](workflow)
capability_coverage = _capability_coverage(
bundle_dir,
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openadapt-desktop",
"version": "0.31.1",
"version": "0.31.2",
"description": "Installed companion for OpenAdapt authoring, teaching, and local pairing",
"private": true,
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "openadapt-desktop"
version = "0.31.1"
version = "0.31.2"
description = "The OpenAdapt desktop app and local engine: record a data-entry task, run it on a list, and check each saved record"
readme = "README.md"
requires-python = ">=3.11"
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "openadapt-desktop"
version = "0.31.1"
version = "0.31.2"
description = "Installed companion for OpenAdapt authoring, teaching, and local pairing"
authors = ["OpenAdapt AI"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/nicoverbruggen/tauri-v2-schema/main/schema.json",
"productName": "OpenAdapt Desktop",
"version": "0.31.1",
"version": "0.31.2",
"identifier": "ai.openadapt.desktop",
"build": {
"frontendDist": "../dist",
Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/src/lib/checkPlan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function subTaskSave({ withCallNode = true, withReportCount = true } = {}) {
return {
ok: true,
workflow_id: "wf-1",
policy: "clinical-write",
policy: "record-write",
qualification_schema: "openadapt.qualification-project/v1",
migration_required: false,
draft_environment: false,
Expand Down
8 changes: 4 additions & 4 deletions packages/desktop/src/lib/outcomes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,13 @@ export function plainResultForReport(report: {

const INPUT_WORDS: Record<string, string> = {
id: "ID",
mrn: "MRN",
dob: "date of birth",
npi: "NPI",
url: "URL",
api: "API",
sku: "SKU",
};

// Whole names that EMR patient tables abbreviate or write in database word
// Whole names that database tables abbreviate or write in database word
// order, so "fname" reads "first name" and "phone_home" reads "home phone".
const INPUT_PHRASES: Record<string, string> = {
fname: "first name",
Expand All @@ -256,7 +256,7 @@ const INPUT_PHRASES: Record<string, string> = {
"phone biz": "work phone",
};

/** "member_id" -> "member ID", "patientName" -> "patient name". */
/** "member_id" -> "member ID", "accountName" -> "account name". */
export function humanizeInput(name: string): string {
const words = name
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
Expand Down
Loading
Loading