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
49 changes: 49 additions & 0 deletions llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2426,9 +2426,20 @@ automation into an independently certified transaction system.
registered that admitter key (`GET /api/v1/org/{org}/admitter-keys`) and
otherwise refuses with `ADMITTER_KEY_UNREGISTERED`, naming the principal id
and public key an owner or admin must register.
- `openadapt login` with no token signs in through the browser: a PKCE
loopback grant on `127.0.0.1` that stores the same credential `push` and
`report-run` use. `--token`, `OPENADAPT_INGEST_TOKEN` and a stored token keep
the old path (#2379).

### Fixes

- A headed browser window that draws no frames (on macOS, one covered by a
full-size terminal window) no longer halts a run at its first step. The
page settle waited for two animation frames after the last change, which
such a window never draws, so the readiness gate timed out after 10 s with
"starting state not ready". When every other page signal is quiet and the
page has drawn no frame for a second, or the page is hidden, the settle now
falls back to two identical screenshots.
- Choice labels, values, shape metadata and browser-dialog messages are
checked against declared secrets before capture. A matching or opaque
secret boundary stops recording before that text reaches its artifacts.
Expand Down Expand Up @@ -2458,3 +2469,41 @@ automation into an independently certified transaction system.
derived from its explicit key for its own lifetime. Without that, each
checkpoint read ran scrypt again, and the MockMed quickstart run took 28 s
instead of 3.5 s (131 derivations, now 1).
- In reverse-proxy mode the wire tap relays a redirect to a path on the
upstream origin, rebuilt on the tap's own origin, instead of answering 502,
so it can front a form app that answers a save with Post/Redirect/Get. The
client's next request comes back through the tap. Browser route mode still
refuses every redirect, and the tap never follows one itself (#2392).
- Guarded native keyboard delivery on a Windows agent that advertises
`native_keyboard_lease_v1` uses a one-shot focus lease over the authorized
control and frame. #2313 describes when it applies and what it checks.
- A repair candidate id that would leave the repair store is refused (#2369).
- `wrap publish` no longer refuses programs whose identity templates carry
`punctuation_body_keys`. These values are salted token hashes, the same
generated shape as the `c` and `r` keys, but the sanitizer sent them to
the PHI recognizer. It sometimes read one as an organization or a group
name and rewrote it, so publish stopped with `SANITIZATION_CHANGED_PROGRAM`.
Only an index key with a hex hash of 16 or more characters is kept. Free
text in that slot is still scrubbed.
- An admitted managed run, and its resume, keep the policy the local Standard
gate chose when neither the CLI nor the deployment names one, instead of
exiting with code 2 (#2401).
- Lens route induction can use a trace's observed effects, not only HTTP
methods, to assign route roles (#2393).
- Generated verify contracts stop fewer correct writes: five generator causes
of false stops are fixed, each by one schema-independent rule (#2418).
- `import openadapt_flow` loads its `ir` re-exports on first use, and the
qualification models and several replayer helpers moved into their own
modules. Names still import explicitly from their old modules;
`from openadapt_flow.qualification import *` no longer includes
`AUTOMATED_GUI_ACTUATIONS` or `build_outcome_envelope` (#2439, #2451, #2454,
#2455, #2456, #2459).

### Requirements

- The `privacy` extra needs `openadapt-privacy[presidio]>=1.1.4`, the first
release with `sanitization_config()`, which sanitized reuse and approval bind
to.
- On Python 3.11 and newer, the lock moves Pillow, filelock and other
dependencies to a release that fixes an open security advisory. The
Python 3.10 lock keeps Pillow 12.3.0 and filelock 3.29.7 (#2383).
70 changes: 50 additions & 20 deletions packages/flow/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,7 @@

<!-- version list -->

## Unreleased

### Fixes

- A headed browser window that draws no frames (on macOS, one covered by a
full-size terminal window) no longer halts a run at its first step. The
page settle waited for two animation frames after the last change, which
such a window never draws, so the readiness gate timed out after 10 s with
"starting state not ready". When every other page signal is quiet and the
page has drawn no frame for a second, or the page is hidden, the settle now
falls back to two identical screenshots.
- `wrap publish` no longer refuses programs whose identity templates carry
`punctuation_body_keys`. These values are salted token hashes, the same
generated shape as the `c` and `r` keys, but the sanitizer sent them to
the PHI recognizer. It sometimes read one as an organization or a group
name and rewrote it, so publish stopped with `SANITIZATION_CHANGED_PROGRAM`.
Only an index key with a hex hash of 16 or more characters is kept. Free
text in that slot is still scrubbed.

## v3.4.0 (held until PyPI serves openadapt-privacy 1.1.4)
## v3.4.0 (2026-11-21)

### Features

Expand Down Expand Up @@ -83,9 +64,20 @@
registered that admitter key (`GET /api/v1/org/{org}/admitter-keys`) and
otherwise refuses with `ADMITTER_KEY_UNREGISTERED`, naming the principal id
and public key an owner or admin must register.
- `openadapt login` with no token signs in through the browser: a PKCE
loopback grant on `127.0.0.1` that stores the same credential `push` and
`report-run` use. `--token`, `OPENADAPT_INGEST_TOKEN` and a stored token keep
the old path (#2379).

### Fixes

- A headed browser window that draws no frames (on macOS, one covered by a
full-size terminal window) no longer halts a run at its first step. The
page settle waited for two animation frames after the last change, which
such a window never draws, so the readiness gate timed out after 10 s with
"starting state not ready". When every other page signal is quiet and the
page has drawn no frame for a second, or the page is hidden, the settle now
falls back to two identical screenshots.
- Choice labels, values, shape metadata and browser-dialog messages are
checked against declared secrets before capture. A matching or opaque
secret boundary stops recording before that text reaches its artifacts.
Expand Down Expand Up @@ -115,6 +107,44 @@
derived from its explicit key for its own lifetime. Without that, each
checkpoint read ran scrypt again, and the MockMed quickstart run took 28 s
instead of 3.5 s (131 derivations, now 1).
- In reverse-proxy mode the wire tap relays a redirect to a path on the
upstream origin, rebuilt on the tap's own origin, instead of answering 502,
so it can front a form app that answers a save with Post/Redirect/Get. The
client's next request comes back through the tap. Browser route mode still
refuses every redirect, and the tap never follows one itself (#2392).
- Guarded native keyboard delivery on a Windows agent that advertises
`native_keyboard_lease_v1` uses a one-shot focus lease over the authorized
control and frame. #2313 describes when it applies and what it checks.
- A repair candidate id that would leave the repair store is refused (#2369).
- `wrap publish` no longer refuses programs whose identity templates carry
`punctuation_body_keys`. These values are salted token hashes, the same
generated shape as the `c` and `r` keys, but the sanitizer sent them to
the PHI recognizer. It sometimes read one as an organization or a group
name and rewrote it, so publish stopped with `SANITIZATION_CHANGED_PROGRAM`.
Only an index key with a hex hash of 16 or more characters is kept. Free
text in that slot is still scrubbed.
- An admitted managed run, and its resume, keep the policy the local Standard
gate chose when neither the CLI nor the deployment names one, instead of
exiting with code 2 (#2401).
- Lens route induction can use a trace's observed effects, not only HTTP
methods, to assign route roles (#2393).
- Generated verify contracts stop fewer correct writes: five generator causes
of false stops are fixed, each by one schema-independent rule (#2418).
- `import openadapt_flow` loads its `ir` re-exports on first use, and the
qualification models and several replayer helpers moved into their own
modules. Names still import explicitly from their old modules;
`from openadapt_flow.qualification import *` no longer includes
`AUTOMATED_GUI_ACTUATIONS` or `build_outcome_envelope` (#2439, #2451, #2454,
#2455, #2456, #2459).

### Requirements

- The `privacy` extra needs `openadapt-privacy[presidio]>=1.1.4`, the first
release with `sanitization_config()`, which sanitized reuse and approval bind
to.
- On Python 3.11 and newer, the lock moves Pillow, filelock and other
dependencies to a release that fixes an open security advisory. The
Python 3.10 lock keeps Pillow 12.3.0 and filelock 3.29.7 (#2383).

## v3.3.0 (2026-11-19)

Expand Down
88 changes: 49 additions & 39 deletions packages/flow/openadapt_flow/tx/wire_tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,19 @@ def _utc_now_iso() -> str:


def _normalize_origin(url_or_origin: str) -> str:
parts = urlsplit(url_or_origin.strip())
if not parts.scheme or not parts.netloc:
try:
parts = urlsplit(url_or_origin.strip())
if not parts.scheme or not parts.netloc:
return ""
scheme = parts.scheme.lower()
host = (parts.hostname or "").lower()
port = parts.port
except ValueError:
# A malformed port or bracketed host is no origin at all.
return ""
scheme = parts.scheme.lower()
host = (parts.hostname or "").lower()
port = parts.port
if ":" in host:
# Keep IPv6 brackets so a port can never read as part of the address.
host = f"[{host}]"
if (
port is None
or (scheme == "http" and port == 80)
Expand All @@ -114,36 +121,47 @@ def relay_redirect_location(
) -> Optional[str]:
"""Return the ``Location`` to relay for a same-origin redirect, else ``None``.

Reverse-proxy mode only: the client's next request comes back through the
tap, so every hop is checked again. Browser route mode refuses redirects.

The tap never follows a redirect itself. It hands a redirect back to the
client only when the target, resolved against the request URL, stays on an
allowed origin, so the next request passes through the tap again. A
protocol-relative or absolute target on any other origin is refused.
``rewrite_from_origin``/``rewrite_to_origin`` map an absolute upstream
target onto the tap's own origin in reverse-proxy mode.
"""
raw = (location or "").strip()
# Browsers read a backslash as a slash, so ``/\\host`` leaves the origin
# even though URL parsers here treat it as a relative path.
if not raw or any(ch in raw for ch in "\r\n\\"):
raw = location or ""
# Validate the header exactly as received. Browsers drop tabs and newlines
# inside a URL and read a backslash as a slash, so refuse any space,
# control character or backslash rather than guess how a client reads it.
if not raw or any(ord(ch) <= 0x20 or ord(ch) == 0x7F or ch == "\\" for ch in raw):
return None
try:
resolved = urljoin(request_url, raw)
origin = _normalize_origin(resolved)
parts = urlsplit(raw)
except ValueError:
return None
resolved = urljoin(request_url, raw)
origin = _normalize_origin(resolved)
if not origin or origin not in allowed_origins:
return None
parts = urlsplit(raw)
if not parts.scheme and not parts.netloc:
# Only a plain path relays as written. Anything with a scheme or an
# authority, including ``///host`` that urlsplit reads as a path but a
# browser reads as a host, is relayed only as the URL checked here,
# rebuilt on the tap's own origin.
if not parts.scheme and not parts.netloc and not raw.startswith("//"):
return raw
if rewrite_from_origin is not None and rewrite_to_origin is not None:
if origin != rewrite_from_origin:
return None
target = urlsplit(resolved)
rewritten = rewrite_to_origin.rstrip("/") + (target.path or "/")
if target.query:
rewritten += "?" + target.query
if target.fragment:
rewritten += "#" + target.fragment
return rewritten
return raw
if rewrite_from_origin is None or rewrite_to_origin is None:
return None
if origin != rewrite_from_origin:
return None
target = urlsplit(resolved)
rewritten = rewrite_to_origin.rstrip("/") + (target.path or "/")
if target.query:
rewritten += "?" + target.query
if target.fragment:
rewritten += "#" + target.fragment
return rewritten


class _ResolvedTarget(NamedTuple):
Expand Down Expand Up @@ -1250,7 +1268,9 @@ def _evaluate_policy_locked(
):
return "secret_in_url"

if target_origin and target_origin not in self._allowed_origins:
# A target with no parseable origin (for example an invalid port) is
# never forwarded: an empty origin must not skip the allowlist.
if not target_origin or target_origin not in self._allowed_origins:
return "disallowed_origin"

if not is_mutation:
Expand Down Expand Up @@ -1826,20 +1846,10 @@ def _handle_route(route: Any) -> None:
if callable(fetch_fn) and callable(fulfill_fn):
fetched = fetch_fn(max_redirects=0)
resp_status, resp_headers, resp_body = _extract_route_response(fetched)
relayed_location = (
relay_redirect_location(
_get_header(resp_headers, "location"),
request_url=req_url,
allowed_origins=self._allowed_origins,
)
if resp_status is not None and 300 <= resp_status < 400
else None
)
if (
resp_status is not None
and 300 <= resp_status < 400
and relayed_location is None
):
# Playwright runs this handler only for the first URL of a
# redirect chain, so a relayed redirect would leave later hops
# unchecked. Refuse every redirect in this mode.
if resp_status is not None and 300 <= resp_status < 400:
self._finalize_request(
ticket,
request_headers=req_headers,
Expand Down
2 changes: 1 addition & 1 deletion packages/flow/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ registry = ["sigstore>=4.5,<5; python_version >= '3.11'"]
# deployment installs this and sets OPENADAPT_FLOW_SCRUB=on to fail closed.
# After install: python -m spacy download en_core_web_sm
privacy = [
"openadapt-privacy[presidio]>=1.0.0",
"openadapt-privacy[presidio]>=1.1.4",
# spaCy imports Click directly from its CLI package but does not declare it;
# Typer 0.27 stopped supplying Click transitively. Keep regulated-mode
# compilation importable under fresh, unconstrained PyPI resolution.
Expand Down
31 changes: 27 additions & 4 deletions packages/flow/tests/test_agent_write_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,26 +199,49 @@ def _saturate_pool() -> threading.Event:
from openadapt_flow.integrations.agents import _POOL

release = threading.Event()
started = threading.Barrier(_POOL._max_workers + 1)

def _hold() -> None:
started.wait(timeout=10)
release.wait(30)

for _ in range(_POOL._max_workers):
_POOL.submit(release.wait, 30)
_POOL.submit(_hold)
started.wait(timeout=10)
return release


def test_a_read_back_queued_behind_a_full_pool_survives_a_timeout(
portal: Portal, tmp_path: Path
portal: Portal, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
from openadapt_flow.integrations.agents import _POOL

guard = _guard(portal, tmp_path)
blockers: list[threading.Event] = []
queued = asyncio.Event()
loop_ref: list[asyncio.AbstractEventLoop] = []
real_submit = _POOL.submit

def _tracking_submit(fn, /, *args, **kwargs):
fut = real_submit(fn, *args, **kwargs)
if blockers and fn == guard._finish:
loop_ref[0].call_soon_threadsafe(queued.set)
return fut

monkeypatch.setattr(_POOL, "submit", _tracking_submit)

async def write():
out = await asyncio.to_thread(portal.save_order, **ORDER)
blockers.append(_saturate_pool()) # the read-back will queue
return out

async def timed_out():
loop_ref.append(asyncio.get_running_loop())
task = asyncio.create_task(guard.arun(ORDER, write))
await asyncio.wait_for(queued.wait(), timeout=10.0)
with pytest.raises(TimeoutError):
async with asyncio.timeout(0.5):
await guard.arun(ORDER, write)
async with asyncio.timeout(0.05):
await task

try:
asyncio.run(timed_out())
Expand Down
Loading
Loading