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
2 changes: 1 addition & 1 deletion .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ jobs:
python - <<'PY'
import xml.etree.ElementTree as ET
cases = ET.parse("tests.xml").getroot().findall(".//testcase")
assert len(cases) == 161, f"expected 161 independent-store, surgical-heal, portal-readback, and mcpify controls, got {len(cases)}"
assert len(cases) == 168, f"expected 168 independent-store, surgical-heal, portal-readback, mcpify, and commit-firewall controls, got {len(cases)}"
# The PostgreSQL and MySQL quickstart controls need the database
# services of verify-clean-install, which runs them; nothing else skips.
skipped = {c.get("name") for c in cases if c.find("skipped") is not None}
Expand Down
60 changes: 60 additions & 0 deletions examples/playwright_commit_firewall.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
"""Minimal UI commit check example with an explicit Ed25519 signing key."""

from pathlib import Path

from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from openadapt_verify import CommitBlockedError, ui_commit_check


class DemoPage:
"""Minimal duck-typed page object exposing input_value() and screenshot()."""

def __init__(self, fields: dict[str, str]) -> None:
self._fields = dict(fields)

def input_value(self, selector: str) -> str:
return self._fields[selector]

def screenshot(self) -> bytes:
return b"\x89PNG\r\n\x1a\ndemo"


def main() -> None:
expected = {"Policy Holder": "Alice Novak", "Coverage Limit": "$250,000"}
out = Path("/tmp/openadapt-ui-commit-check-demo")
signing_key = Ed25519PrivateKey.generate()

# 1. Clean commit -> verified via distinct independent read-back + signed Ed25519 receipt.
with ui_commit_check(
DemoPage(expected),
intent="Bind Policy",
expected=expected,
record_id="quote-2026-0001",
independent_page=DemoPage(expected),
receipt_dir=out,
signing_key=signing_key,
) as check:
pass
assert check.result is not None and check.result.receipt_id is not None
print(
f"VERIFIED | receipt_id={check.result.receipt_id[:16]} | path={check.result.receipt_path}"
)

# 2. Silent homoglyph + unbound control -> blocked & logged to Exception Inbox.
corrupted = DemoPage({"Policy Holder": "\u0410lice Novak", "Coverage Limit": ""})
try:
with ui_commit_check(
corrupted,
intent="Bind Policy",
expected=expected,
inbox=out / "inbox.jsonl",
):
pass
except CommitBlockedError as err:
print(
f"{err.result.status} | verdict={err.result.verdict} | reason={err.reason}"
)


if __name__ == "__main__":
main()
14 changes: 14 additions & 0 deletions packages/verify/src/openadapt_verify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
from openadapt_flow.write_receipt import Verification as PortableReceiptVerification
from openadapt_flow.write_receipt import verify as verify_receipt

from openadapt_verify.commit_firewall import (
CommitBlockedError,
CommitResult,
UiCommitCheck,
async_verify_commit,
ui_commit_check,
verify_commit,
)
from openadapt_verify.guard import checked_write, verified
from openadapt_verify.mcpify import (
McpifyServer,
Expand All @@ -51,6 +59,8 @@
__all__ = [
"Actor",
"AlreadyWritten",
"CommitBlockedError",
"CommitResult",
"ConfirmationPdfOracle",
"Contract",
"FieldCheck",
Expand All @@ -66,10 +76,12 @@
"SafetyPolicy",
"Scope",
"SignedReceipt",
"UiCommitCheck",
"WorkflowToolSpec",
"WriteBlocked",
"WriteGuard",
"WriteResult",
"async_verify_commit",
"begin_write",
"checked_write",
"generate_mcp_client_config",
Expand All @@ -78,6 +90,8 @@
"load_workflow_spec",
"load_workflow_specs",
"recheck",
"ui_commit_check",
"verify_commit",
"verify_local_seal",
"verify_mcpify_receipt",
"verified",
Expand Down
Loading