Repository navigation
feat(sdk): add 2-line openadapt.wrap Python SDK - #2732
Merged
Merged
Conversation
Add openadapt.wrap_sdk (lazy-exported as openadapt.wrap, WrapResult, WrapBlockedError, WrapVerificationError, WrapReceipt, and WrapLedger) using only the Python standard library at import time: - Wrap sync functions, async coroutines, callable instances, and agent objects exposing .run or .step while preserving signatures via functools.wraps. - Enforce operator-pinned keys and required identity_keys before executing wrapped callables. - Track in-memory or file-backed uncertain writes and idempotent request_id replays with explicit .release(key) recovery. - Verify post-action outcomes via same_screen callables by default or openadapt.verify.Contract when supplied, attaching SHA-256 and optional Ed25519 receipts.
abrichr
enabled auto-merge
November 28, 2026 00:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
openadapt/wrap_sdk.py, lazy-exported fromopenadapt(openadapt.wrap,WrapResult,WrapBlockedError,WrapVerificationError,WrapReceipt,WrapLedger,verify_wrap_receipt), so developers can add commit-boundary protections to any Python function, coroutine, Playwright helper, MCP tool, or agent object in 2 lines with zero YAML files required:openadapt.wrap(fn, ...),@openadapt.wrap, and@openadapt.wrap(...)across sync functions,async defcoroutines, callable instances, and agent objects exposing.runor.step(viaWrappedAgentProxywithout mutating the underlying object). Preserves__name__,__doc__, and__signature__viafunctools.wrapsfor tool schema inspection.pinned={...}) and blankidentity_keysbefore executing the wrapped callable (WrapBlockedErroror structured refusal dict whenon_block="return").WrapLedger(in-memory or file-backed JSON) to block blind duplicate retries untilwrapped.release(key)is called, and replays confirmedrequest_id/idempotent=Truecalls without double execution.same_screenpost-action callables (check=...orexpect=...) with zero reload or API requirement, or routes throughopenadapt.verify.Contract(begin_write/verify_write) whencontract=is passed. Attacheswrapped.last_receiptwithoutcome,checked_how,sha256digest, and optional Ed25519 signature (signing_key=).openadapt/wrap_sdk.pyimports only the Python standard library at module load time;openadapt_flowandcryptographyload lazily only whencontract=orsigning_key=is supplied.README.md(stacked cleanly on#2730).Verification
Ran via
~/oa/scratch/cpu-slots/run.sh:pytest tests/test_openadapt_wrap.py tests/test_shipped_only_copy.py tests/test_readme_replay_warning.py tests/test_pypi_description.py -q->22 passedpython3 scripts/check_file_size_ratchet.py --base origin/main-> exit0python3 packages/flow/scripts/check_verdict_folds.py->Verdict folds OK (2615 baseline folds left)ruff check openadapt tests/test_openadapt_wrap.py->All checks passed!ruff format --check openadapt tests/test_openadapt_wrap.py->27 files already formattedGenerality & Durability
openadapt/wrap_sdk.pycontains zero application-specific names, selectors, or branches..run/.stepentry points.request_idreplay, Ed25519 receipt verification, and SQLiteContractread-back; not yet measured on an external held-out live portal campaign.