actentra 0.1.0a0__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 (53) hide show
  1. actentra-0.1.0a0/LICENSE +158 -0
  2. actentra-0.1.0a0/PKG-INFO +191 -0
  3. actentra-0.1.0a0/README.md +170 -0
  4. actentra-0.1.0a0/actentra.egg-info/PKG-INFO +191 -0
  5. actentra-0.1.0a0/actentra.egg-info/SOURCES.txt +51 -0
  6. actentra-0.1.0a0/actentra.egg-info/dependency_links.txt +1 -0
  7. actentra-0.1.0a0/actentra.egg-info/entry_points.txt +2 -0
  8. actentra-0.1.0a0/actentra.egg-info/requires.txt +12 -0
  9. actentra-0.1.0a0/actentra.egg-info/top_level.txt +5 -0
  10. actentra-0.1.0a0/cli/actentra_cli/__init__.py +1 -0
  11. actentra-0.1.0a0/cli/actentra_cli/main.py +1856 -0
  12. actentra-0.1.0a0/core/actentra_core/__init__.py +312 -0
  13. actentra-0.1.0a0/core/actentra_core/budgets.py +345 -0
  14. actentra-0.1.0a0/core/actentra_core/canary.py +293 -0
  15. actentra-0.1.0a0/core/actentra_core/canonicalize.py +332 -0
  16. actentra-0.1.0a0/core/actentra_core/causal.py +650 -0
  17. actentra-0.1.0a0/core/actentra_core/checkpoints.py +1262 -0
  18. actentra-0.1.0a0/core/actentra_core/claims.py +122 -0
  19. actentra-0.1.0a0/core/actentra_core/context.py +316 -0
  20. actentra-0.1.0a0/core/actentra_core/coordination.py +249 -0
  21. actentra-0.1.0a0/core/actentra_core/envelope.py +255 -0
  22. actentra-0.1.0a0/core/actentra_core/evidence.py +180 -0
  23. actentra-0.1.0a0/core/actentra_core/handoffs.py +302 -0
  24. actentra-0.1.0a0/core/actentra_core/identity.py +1907 -0
  25. actentra-0.1.0a0/core/actentra_core/lifecycle.py +260 -0
  26. actentra-0.1.0a0/core/actentra_core/observability.py +153 -0
  27. actentra-0.1.0a0/core/actentra_core/observations.py +624 -0
  28. actentra-0.1.0a0/core/actentra_core/policy.py +567 -0
  29. actentra-0.1.0a0/core/actentra_core/receipts.py +4747 -0
  30. actentra-0.1.0a0/core/actentra_core/reporting.py +416 -0
  31. actentra-0.1.0a0/core/actentra_core/risk.py +75 -0
  32. actentra-0.1.0a0/core/actentra_core/verdict.py +63 -0
  33. actentra-0.1.0a0/core/actentra_core/warrants.py +377 -0
  34. actentra-0.1.0a0/executors/actentra_executors/__init__.py +18 -0
  35. actentra-0.1.0a0/executors/actentra_executors/fs.py +855 -0
  36. actentra-0.1.0a0/executors/actentra_executors/http.py +668 -0
  37. actentra-0.1.0a0/executors/actentra_executors/sqlite.py +432 -0
  38. actentra-0.1.0a0/executors/actentra_executors/verifiers.py +293 -0
  39. actentra-0.1.0a0/gateway/actentra_gateway/__init__.py +29 -0
  40. actentra-0.1.0a0/gateway/actentra_gateway/console.html +1016 -0
  41. actentra-0.1.0a0/gateway/actentra_gateway/demo.py +664 -0
  42. actentra-0.1.0a0/gateway/actentra_gateway/http_service.py +2506 -0
  43. actentra-0.1.0a0/gateway/actentra_gateway/mcp_proxy.py +365 -0
  44. actentra-0.1.0a0/gateway/actentra_gateway/multi_agent_realtime_sim.py +426 -0
  45. actentra-0.1.0a0/gateway/actentra_gateway/services.py +3646 -0
  46. actentra-0.1.0a0/pyproject.toml +79 -0
  47. actentra-0.1.0a0/sdk/python/actentra/__init__.py +84 -0
  48. actentra-0.1.0a0/sdk/python/actentra/adapters/__init__.py +11 -0
  49. actentra-0.1.0a0/sdk/python/actentra/adapters/function_calling.py +195 -0
  50. actentra-0.1.0a0/sdk/python/actentra/adapters/langchain.py +151 -0
  51. actentra-0.1.0a0/sdk/python/actentra/boundary.py +1992 -0
  52. actentra-0.1.0a0/sdk/python/actentra/secrets.py +177 -0
  53. actentra-0.1.0a0/setup.cfg +4 -0
@@ -0,0 +1,158 @@
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 Work, 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) alleging that the Work or a Contribution
84
+ incorporated within the Work constitutes direct or indirect patent
85
+ infringement, then any patent licenses granted to You under this
86
+ License for that Work shall terminate as of the date such litigation
87
+ 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
95
+ Derivative 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" file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the Work's NOTICE file, except
109
+ where such file does not include any notice regarding the
110
+ Work.
111
+
112
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
113
+ any Contribution intentionally submitted for inclusion in the Work
114
+ by You to the Licensor shall be under the terms and conditions of
115
+ this License, without any additional terms or conditions.
116
+ Notwithstanding the above, nothing herein shall supersede or modify
117
+ the terms of any separate license agreement you may have executed
118
+ with Licensor regarding such Contributions.
119
+
120
+ 6. Trademarks. This License does not grant permission to use the trade
121
+ names, trademarks, service marks, or product names of the Licensor,
122
+ except as required for reasonable and customary use in describing the
123
+ origin of the Work and reproducing the origin of the Work.
124
+
125
+ 7. Disclaimer of Warranty. Unless required by applicable law or
126
+ agreed to in writing, Licensor provides the Work (and each
127
+ Contributor provides its Contributions) on an "AS IS" BASIS,
128
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
129
+ implied, including, but not limited to, the warranties of
130
+ merchantability, fitness for a particular purpose, and
131
+ non-infringement. You are solely responsible for determining the
132
+ appropriateness of using or redistributing the Work and assume any
133
+ risks associated with Your exercise of permissions under this License.
134
+
135
+ 8. Limitation of Liability. In no event and under no legal theory,
136
+ whether in tort (including negligence), contract, or otherwise,
137
+ unless required by applicable law (such as deliberate representation
138
+ and gross negligence) or agreed to in writing, shall any Contributor be
139
+ liable to You for damages, including any direct, indirect, special,
140
+ incidental, or consequential damages of any character arising as a
141
+ result of this License or out of the use or inability to use the
142
+ Work (including but not limited to damages for loss of growth,
143
+ loss of goodwill, work stoppage, computer failure or malfunction, or
144
+ any and all other commercial damages or losses), even if such
145
+ Contributor has been advised of the possibility of such damages.
146
+
147
+ 9. Accepting Warranty or Additional Liability. While redistributing
148
+ the Work or Derivative Works thereof, You may choose to offer,
149
+ and charge a fee for, acceptance of support, warranty, or additional
150
+ liability obligations and/or rights consistent with this License. However,
151
+ in accepting such obligations, You may act only on Your own behalf
152
+ and on Your sole responsibility, not on behalf of any other Contributor,
153
+ and only if You agree to indemnify, defend, and hold each Contributor
154
+ harmless for any liability incurred by, or claims asserted against,
155
+ such Contributor by reason of your accepting any such warranty or
156
+ additional liability.
157
+
158
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: actentra
3
+ Version: 0.1.0a0
4
+ Summary: Lightweight, local-first deterministic execution boundary for AI agents.
5
+ License-Expression: Apache-2.0
6
+ Requires-Python: >=3.12
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: PyYAML<7.0,>=6.0
10
+ Requires-Dist: cryptography>=43.0
11
+ Requires-Dist: typer<1.0,>=0.12
12
+ Provides-Extra: dev
13
+ Requires-Dist: pytest>=8.0; extra == "dev"
14
+ Requires-Dist: hypothesis>=6.100; extra == "dev"
15
+ Requires-Dist: jsonschema>=4.20; extra == "dev"
16
+ Requires-Dist: mypy>=1.10; extra == "dev"
17
+ Requires-Dist: ruff>=0.6; extra == "dev"
18
+ Requires-Dist: psutil>=6.0; extra == "dev"
19
+ Requires-Dist: types-PyYAML>=6.0; extra == "dev"
20
+ Dynamic: license-file
21
+
22
+ <p align="center">
23
+ <img src="assets/actentra-logo-dark.svg" alt="Actentra" width="260" />
24
+ </p>
25
+
26
+ # Actentra
27
+
28
+ > *Intelligence proposes. Actentra decides.*
29
+
30
+ **Actentra** is a lightweight, local-first deterministic execution boundary for AI agents. It sits between any model or agent framework and real-world tools—canonicalizing each tool call, evaluating deterministic YAML policies and risk tags, binding human approvals to an exact action hash, and writing tamper-evident hash-chained receipts.
31
+
32
+ ---
33
+
34
+ ## Key Highlights
35
+
36
+ - **Persistent Pending Approvals:** Human approval requests (`ASK`) are durably stored in SQLite WAL, surviving process restarts and power cycles with strict single-use hash binding and TTL expiration.
37
+ - **Transactional Action Lifecycle State Machine:** Strict formal state transitions (`created` -> `authorized` -> `approved` -> `claimed` -> `executing` -> `verification_pending` -> `succeeded`/`failed`/`unknown`/`reconciliation_required`) with historical state transition auditing.
38
+ - **Durable Idempotency Engine:** Prevents replay side effects across process boundaries, returns cached results on exact replay without re-dispatching tools, and flags interrupted executions for reconciliation.
39
+ - **Typed Application Services:** Modular `AppServices` and `ExecutorRegistry` unifying CLI, SDK, and Web UI.
40
+ - **Unified Local Operator Console:** 7-tab embedded offline web application at `/ui` (Overview, Approvals Inbox, Policy Viewer & Linter, Dry-Run Simulator, Paginated Receipts Explorer, Integrations, Settings).
41
+ - **Bounded Paged Receipts & Offline Audit Bundles:** Paged queries, keyword search, and one-click JSON/JSONL export bundles with integrity verification.
42
+ - **Zero LLM in the Enforcement Path:** Policy evaluation is 100% deterministic, reproducible, and explainable in sub-millisecond time.
43
+ - **Strictly Fail-Closed & Local-Only Posture:** Loopback binding by default (`127.0.0.1`), strictly typed fail-closed approval API, origin isolation rejecting untrusted cross-origin browser requests, compulsory token auth for remote binding.
44
+ - **SSRF-Defended HTTP & Scoped Executors:** Built-in executors for Filesystem, SQLite, and HTTP with private IP / metadata blocking and parameter constraints.
45
+ - **DPAPI Secrets Broker & Credential Resolution:** Encrypts tool secrets with Windows DPAPI at rest, resolves credential references (`secret:<NAME>`) dynamically during HTTP execution, and scrubs secrets from logs, errors, and responses.
46
+ - **Dynamic Session Taint Tracking:** Automatically labels sessions tainted upon reading untrusted content (indirect prompt injection defense) and blocks untrusted network egress.
47
+ - **Cumulative Session Budgets:** Enforces caps on total actions, write bytes, and external calls across both gateway and external executions to prevent infinite loops and slow-drip exfiltration.
48
+ - **Cryptographic Capability Warrants:** Scoped, expiring Ed25519-signed delegation tokens for subagents with cryptographic signature verification, holder matching, scope enforcement, and use-quota tracking integrated into Boundary.
49
+ - **Bounded Streaming Audit Log & Archival:** Memory-bounded streaming log iteration, chunked export, envelope-integrity verification, and standalone SQLite archive partitioning.
50
+ - **Policy Canary Diff Engine:** Replays recorded agent traffic against proposed policies to detect regressions with context integrity, provenance, and temporal window modeling.
51
+ - **Standalone HTML Audit Reports:** Generates zero-external-CDN audit reports with SVG security badges and chronological timelines.
52
+ - **Operational Metrics & Telemetry:** Built-in latency percentiles (p50, p95, p99, max), failure counters, and secret scrubbing exposed via `GET /v1/metrics` and `actentra metrics`.
53
+ - **Agent Framework & MCP Adapters:** First-class adapters for LangChain, OpenAI function calling, and MCP stdio proxy with anti-rug-pull schema pinning (CVE-2025-54136) and caller context propagation.
54
+
55
+ ---
56
+
57
+ ## Repository Layout
58
+
59
+ - [`core/actentra_core/`](core/actentra_core/) — Pure, deterministic enforcement kernel:
60
+ - Envelope builder, Windows path, URL, SQL, and JSON canonicalizers
61
+ - Deterministic risk tagger (`destructive`, `external-egress`, `privilege-escalation`, `budget-exceeded`)
62
+ - Deny-overrides YAML policy engine with session rate limits and cumulative budgets
63
+ - Hash-chained SQLite WAL receipt store with outcome recovery
64
+ - Ed25519 signed checkpoints (`sign_checkpoint`, `verify_checkpoint`)
65
+ - Policy Canary diff engine (`run_policy_canary`)
66
+ - Standalone HTML audit report renderer (`render_html_report`)
67
+ - Cryptographic capability tokens (`Warrant`, `issue_warrant`, `verify_warrant`)
68
+ - [`executors/actentra_executors/`](executors/actentra_executors/) — Scoped, defended executors:
69
+ - `LocalFSExecutor` & `ScopedFSTools` (directory traversal rejection, ADS/8.3 rejection, constraints)
70
+ - `ScopedSQLiteExecutor` & `ScopedSQLiteTools` (single-statement SQL, parameterized queries, `read_only`, `max_rows`)
71
+ - `ScopedHTTPExecutor` & `ScopedHTTPTools` (SSRF defense, metadata & private IP blocking, wildcard host allowlists)
72
+ - [`gateway/actentra_gateway/`](gateway/actentra_gateway/) — Integration gateways:
73
+ - `MCPStdioProxy` & `serve_stdio` (anti-rug-pull schema pinning for CVE-2025-54136)
74
+ - `ActentraHTTPServer` & `serve_http` (`/v1/crossings` REST API + `/ui` Operator Console)
75
+ - [`sdk/python/actentra/`](sdk/python/actentra/) — Thin in-process Python SDK:
76
+ - `Boundary` & `@guard` decorator
77
+ - `SecretsBroker` (Windows DPAPI encryption + secret redaction)
78
+ - `FunctionCallAdapter` (OpenAI / Anthropic function calling format)
79
+ - `LangChainToolWrapper` (duck-typed wrapper for LangChain tools)
80
+ - [`cli/actentra_cli/`](cli/actentra_cli/) — Typer CLI commands:
81
+ - `init`, `policy check`, `policy canary`, `dry-run`, `serve`, `report`, `run`, `replay`, `mcp-proxy`, `checkpoint`, `warrant`, `verify-log`, `export-log`, `demo`, `lifecycle`, `metrics`
82
+ - [`spec/`](spec/) — Draft 2020-12 JSON Schemas for Envelope, Policy, and Receipt v1
83
+ - [`policies/examples/`](policies/examples/) — Starter policy packs
84
+ - [`corpus/`](corpus/) — Documented real-world agent incident corpus (32 incidents), red-team attacks, and benign actions
85
+ - [`docs/`](docs/) — [Quickstart Guide](docs/guides/quickstart.md), [Architecture & Design](docs/architecture/architecture.md), [Threat Model](docs/security/threat-model.md), [Guarantees & Limits](docs/security/guarantees-and-limits.md), [Product Status](docs/product-status.md), [Naming Clearance Checklist](docs/development/naming-clearance.md)
86
+ - [`scripts/windows/`](scripts/windows/) — Resilient background runner (`run_gateway.ps1`) for Windows Task Scheduler
87
+ - [`tests/`](tests/) — Complete test suite (unit, golden, chaos, replay, Hypothesis properties, performance)
88
+
89
+ ---
90
+
91
+ ## Quick Start (5 Minutes)
92
+
93
+ > **Installation Note:** Actentra (`0.1.0a0`) is not yet published on PyPI. Install from a local clone (`pip install -e .` or `uv sync`), directly from Git (`pip install "git+https://github.com/SiddardhaShayini/Actentra.git"`), or from a built wheel. See [docs/guides/quickstart.md](docs/guides/quickstart.md).
94
+
95
+ ### 1. Verification & Test Suite
96
+
97
+ ```powershell
98
+ # Run Ruff linting, Mypy strict type-checking, and full test suite
99
+ .venv\Scripts\ruff check core executors gateway sdk cli tests
100
+ .venv\Scripts\mypy
101
+ .venv\Scripts\pytest -v
102
+ ```
103
+
104
+ ### 2. Simulate Actions with Dry-Run Mode
105
+
106
+ ```powershell
107
+ # Allowed workspace read
108
+ .venv\Scripts\actentra dry-run -p policies/examples/starter.yaml -t fs.read -r "path:C:/work/notes.txt" -v read
109
+
110
+ # Blocked privilege escalation attempt (.env file)
111
+ .venv\Scripts\actentra dry-run -p policies/examples/starter.yaml -t fs.read -r "path:C:/work/.env" -v read
112
+ ```
113
+
114
+ ### 3. Run the Restart-Safe Action Demonstration
115
+
116
+ ```powershell
117
+ # Execute the complete end-to-end restart-safe lifecycle demonstration
118
+ # (Allowed read -> ASK delete -> process restart -> approval -> restart -> execution -> duplicate rejection -> verify)
119
+ .venv\Scripts\actentra demo --gateway
120
+ ```
121
+
122
+ ### 4. Launch the Local Operator Console
123
+
124
+ ```powershell
125
+ .venv\Scripts\actentra serve --policy policies/examples/starter.yaml --port 8080
126
+ ```
127
+ - Open `http://127.0.0.1:8080/ui` in your browser to view pending approvals, verify hash-chain integrity, and inspect active crossings.
128
+
129
+ ### 5. Generate an HTML Audit Report
130
+
131
+ ```powershell
132
+ .venv\Scripts\actentra report receipts.db --html audit_report.html
133
+ ```
134
+
135
+ ### 6. Replay 32 Documented Agent Incidents
136
+
137
+ ```powershell
138
+ .venv\Scripts\actentra replay corpus/incidents/agent_incidents.jsonl --policy policies/examples/starter.yaml
139
+ ```
140
+
141
+ ---
142
+
143
+ ## Python SDK Example
144
+
145
+ ```python
146
+ from pathlib import Path
147
+ from actentra import Boundary, path_resource
148
+
149
+ workspace = Path("./workspace").resolve()
150
+ workspace.mkdir(exist_ok=True)
151
+ ws = path_resource(workspace).removeprefix("path:")
152
+
153
+ policy_yaml = f"""
154
+ version: 1
155
+ policy_id: local-quickstart
156
+ mode: enforce
157
+ defaults:
158
+ verdict: deny
159
+ reason: "Denied by default policy"
160
+ rules:
161
+ - id: allow-workspace-reads
162
+ match:
163
+ tool: fs.read
164
+ verb: read
165
+ resource: "path:{ws}/**"
166
+ verdict: allow
167
+ reason: "Allow workspace reads"
168
+ """
169
+
170
+ boundary = Boundary.from_yaml(
171
+ policy_yaml=policy_yaml,
172
+ receipts_db="receipts.db",
173
+ workspace_root=workspace,
174
+ )
175
+
176
+ # Evaluate, execute through LocalFSExecutor, and inspect the durable receipt
177
+ res = boundary.run(
178
+ tool="fs.read",
179
+ verb="read",
180
+ resource=path_resource("notes.txt", workspace_root=workspace),
181
+ )
182
+ print(res.verdict.value, res.status, res.result)
183
+ ```
184
+
185
+ For runnable examples (file writes with postcondition verification, blocked actions, HTTP gateway, and AI-agent function-calling integration), see [`examples/`](examples/).
186
+
187
+ ---
188
+
189
+ ## Guarantees and Limits
190
+
191
+ Actentra is designed to **fail closed**, bind approvals to exact `sha256` action hashes, and persist durable decision records before execution. See [docs/security/guarantees-and-limits.md](docs/security/guarantees-and-limits.md) for explicit architectural boundaries and non-goals.
@@ -0,0 +1,170 @@
1
+ <p align="center">
2
+ <img src="assets/actentra-logo-dark.svg" alt="Actentra" width="260" />
3
+ </p>
4
+
5
+ # Actentra
6
+
7
+ > *Intelligence proposes. Actentra decides.*
8
+
9
+ **Actentra** is a lightweight, local-first deterministic execution boundary for AI agents. It sits between any model or agent framework and real-world tools—canonicalizing each tool call, evaluating deterministic YAML policies and risk tags, binding human approvals to an exact action hash, and writing tamper-evident hash-chained receipts.
10
+
11
+ ---
12
+
13
+ ## Key Highlights
14
+
15
+ - **Persistent Pending Approvals:** Human approval requests (`ASK`) are durably stored in SQLite WAL, surviving process restarts and power cycles with strict single-use hash binding and TTL expiration.
16
+ - **Transactional Action Lifecycle State Machine:** Strict formal state transitions (`created` -> `authorized` -> `approved` -> `claimed` -> `executing` -> `verification_pending` -> `succeeded`/`failed`/`unknown`/`reconciliation_required`) with historical state transition auditing.
17
+ - **Durable Idempotency Engine:** Prevents replay side effects across process boundaries, returns cached results on exact replay without re-dispatching tools, and flags interrupted executions for reconciliation.
18
+ - **Typed Application Services:** Modular `AppServices` and `ExecutorRegistry` unifying CLI, SDK, and Web UI.
19
+ - **Unified Local Operator Console:** 7-tab embedded offline web application at `/ui` (Overview, Approvals Inbox, Policy Viewer & Linter, Dry-Run Simulator, Paginated Receipts Explorer, Integrations, Settings).
20
+ - **Bounded Paged Receipts & Offline Audit Bundles:** Paged queries, keyword search, and one-click JSON/JSONL export bundles with integrity verification.
21
+ - **Zero LLM in the Enforcement Path:** Policy evaluation is 100% deterministic, reproducible, and explainable in sub-millisecond time.
22
+ - **Strictly Fail-Closed & Local-Only Posture:** Loopback binding by default (`127.0.0.1`), strictly typed fail-closed approval API, origin isolation rejecting untrusted cross-origin browser requests, compulsory token auth for remote binding.
23
+ - **SSRF-Defended HTTP & Scoped Executors:** Built-in executors for Filesystem, SQLite, and HTTP with private IP / metadata blocking and parameter constraints.
24
+ - **DPAPI Secrets Broker & Credential Resolution:** Encrypts tool secrets with Windows DPAPI at rest, resolves credential references (`secret:<NAME>`) dynamically during HTTP execution, and scrubs secrets from logs, errors, and responses.
25
+ - **Dynamic Session Taint Tracking:** Automatically labels sessions tainted upon reading untrusted content (indirect prompt injection defense) and blocks untrusted network egress.
26
+ - **Cumulative Session Budgets:** Enforces caps on total actions, write bytes, and external calls across both gateway and external executions to prevent infinite loops and slow-drip exfiltration.
27
+ - **Cryptographic Capability Warrants:** Scoped, expiring Ed25519-signed delegation tokens for subagents with cryptographic signature verification, holder matching, scope enforcement, and use-quota tracking integrated into Boundary.
28
+ - **Bounded Streaming Audit Log & Archival:** Memory-bounded streaming log iteration, chunked export, envelope-integrity verification, and standalone SQLite archive partitioning.
29
+ - **Policy Canary Diff Engine:** Replays recorded agent traffic against proposed policies to detect regressions with context integrity, provenance, and temporal window modeling.
30
+ - **Standalone HTML Audit Reports:** Generates zero-external-CDN audit reports with SVG security badges and chronological timelines.
31
+ - **Operational Metrics & Telemetry:** Built-in latency percentiles (p50, p95, p99, max), failure counters, and secret scrubbing exposed via `GET /v1/metrics` and `actentra metrics`.
32
+ - **Agent Framework & MCP Adapters:** First-class adapters for LangChain, OpenAI function calling, and MCP stdio proxy with anti-rug-pull schema pinning (CVE-2025-54136) and caller context propagation.
33
+
34
+ ---
35
+
36
+ ## Repository Layout
37
+
38
+ - [`core/actentra_core/`](core/actentra_core/) — Pure, deterministic enforcement kernel:
39
+ - Envelope builder, Windows path, URL, SQL, and JSON canonicalizers
40
+ - Deterministic risk tagger (`destructive`, `external-egress`, `privilege-escalation`, `budget-exceeded`)
41
+ - Deny-overrides YAML policy engine with session rate limits and cumulative budgets
42
+ - Hash-chained SQLite WAL receipt store with outcome recovery
43
+ - Ed25519 signed checkpoints (`sign_checkpoint`, `verify_checkpoint`)
44
+ - Policy Canary diff engine (`run_policy_canary`)
45
+ - Standalone HTML audit report renderer (`render_html_report`)
46
+ - Cryptographic capability tokens (`Warrant`, `issue_warrant`, `verify_warrant`)
47
+ - [`executors/actentra_executors/`](executors/actentra_executors/) — Scoped, defended executors:
48
+ - `LocalFSExecutor` & `ScopedFSTools` (directory traversal rejection, ADS/8.3 rejection, constraints)
49
+ - `ScopedSQLiteExecutor` & `ScopedSQLiteTools` (single-statement SQL, parameterized queries, `read_only`, `max_rows`)
50
+ - `ScopedHTTPExecutor` & `ScopedHTTPTools` (SSRF defense, metadata & private IP blocking, wildcard host allowlists)
51
+ - [`gateway/actentra_gateway/`](gateway/actentra_gateway/) — Integration gateways:
52
+ - `MCPStdioProxy` & `serve_stdio` (anti-rug-pull schema pinning for CVE-2025-54136)
53
+ - `ActentraHTTPServer` & `serve_http` (`/v1/crossings` REST API + `/ui` Operator Console)
54
+ - [`sdk/python/actentra/`](sdk/python/actentra/) — Thin in-process Python SDK:
55
+ - `Boundary` & `@guard` decorator
56
+ - `SecretsBroker` (Windows DPAPI encryption + secret redaction)
57
+ - `FunctionCallAdapter` (OpenAI / Anthropic function calling format)
58
+ - `LangChainToolWrapper` (duck-typed wrapper for LangChain tools)
59
+ - [`cli/actentra_cli/`](cli/actentra_cli/) — Typer CLI commands:
60
+ - `init`, `policy check`, `policy canary`, `dry-run`, `serve`, `report`, `run`, `replay`, `mcp-proxy`, `checkpoint`, `warrant`, `verify-log`, `export-log`, `demo`, `lifecycle`, `metrics`
61
+ - [`spec/`](spec/) — Draft 2020-12 JSON Schemas for Envelope, Policy, and Receipt v1
62
+ - [`policies/examples/`](policies/examples/) — Starter policy packs
63
+ - [`corpus/`](corpus/) — Documented real-world agent incident corpus (32 incidents), red-team attacks, and benign actions
64
+ - [`docs/`](docs/) — [Quickstart Guide](docs/guides/quickstart.md), [Architecture & Design](docs/architecture/architecture.md), [Threat Model](docs/security/threat-model.md), [Guarantees & Limits](docs/security/guarantees-and-limits.md), [Product Status](docs/product-status.md), [Naming Clearance Checklist](docs/development/naming-clearance.md)
65
+ - [`scripts/windows/`](scripts/windows/) — Resilient background runner (`run_gateway.ps1`) for Windows Task Scheduler
66
+ - [`tests/`](tests/) — Complete test suite (unit, golden, chaos, replay, Hypothesis properties, performance)
67
+
68
+ ---
69
+
70
+ ## Quick Start (5 Minutes)
71
+
72
+ > **Installation Note:** Actentra (`0.1.0a0`) is not yet published on PyPI. Install from a local clone (`pip install -e .` or `uv sync`), directly from Git (`pip install "git+https://github.com/SiddardhaShayini/Actentra.git"`), or from a built wheel. See [docs/guides/quickstart.md](docs/guides/quickstart.md).
73
+
74
+ ### 1. Verification & Test Suite
75
+
76
+ ```powershell
77
+ # Run Ruff linting, Mypy strict type-checking, and full test suite
78
+ .venv\Scripts\ruff check core executors gateway sdk cli tests
79
+ .venv\Scripts\mypy
80
+ .venv\Scripts\pytest -v
81
+ ```
82
+
83
+ ### 2. Simulate Actions with Dry-Run Mode
84
+
85
+ ```powershell
86
+ # Allowed workspace read
87
+ .venv\Scripts\actentra dry-run -p policies/examples/starter.yaml -t fs.read -r "path:C:/work/notes.txt" -v read
88
+
89
+ # Blocked privilege escalation attempt (.env file)
90
+ .venv\Scripts\actentra dry-run -p policies/examples/starter.yaml -t fs.read -r "path:C:/work/.env" -v read
91
+ ```
92
+
93
+ ### 3. Run the Restart-Safe Action Demonstration
94
+
95
+ ```powershell
96
+ # Execute the complete end-to-end restart-safe lifecycle demonstration
97
+ # (Allowed read -> ASK delete -> process restart -> approval -> restart -> execution -> duplicate rejection -> verify)
98
+ .venv\Scripts\actentra demo --gateway
99
+ ```
100
+
101
+ ### 4. Launch the Local Operator Console
102
+
103
+ ```powershell
104
+ .venv\Scripts\actentra serve --policy policies/examples/starter.yaml --port 8080
105
+ ```
106
+ - Open `http://127.0.0.1:8080/ui` in your browser to view pending approvals, verify hash-chain integrity, and inspect active crossings.
107
+
108
+ ### 5. Generate an HTML Audit Report
109
+
110
+ ```powershell
111
+ .venv\Scripts\actentra report receipts.db --html audit_report.html
112
+ ```
113
+
114
+ ### 6. Replay 32 Documented Agent Incidents
115
+
116
+ ```powershell
117
+ .venv\Scripts\actentra replay corpus/incidents/agent_incidents.jsonl --policy policies/examples/starter.yaml
118
+ ```
119
+
120
+ ---
121
+
122
+ ## Python SDK Example
123
+
124
+ ```python
125
+ from pathlib import Path
126
+ from actentra import Boundary, path_resource
127
+
128
+ workspace = Path("./workspace").resolve()
129
+ workspace.mkdir(exist_ok=True)
130
+ ws = path_resource(workspace).removeprefix("path:")
131
+
132
+ policy_yaml = f"""
133
+ version: 1
134
+ policy_id: local-quickstart
135
+ mode: enforce
136
+ defaults:
137
+ verdict: deny
138
+ reason: "Denied by default policy"
139
+ rules:
140
+ - id: allow-workspace-reads
141
+ match:
142
+ tool: fs.read
143
+ verb: read
144
+ resource: "path:{ws}/**"
145
+ verdict: allow
146
+ reason: "Allow workspace reads"
147
+ """
148
+
149
+ boundary = Boundary.from_yaml(
150
+ policy_yaml=policy_yaml,
151
+ receipts_db="receipts.db",
152
+ workspace_root=workspace,
153
+ )
154
+
155
+ # Evaluate, execute through LocalFSExecutor, and inspect the durable receipt
156
+ res = boundary.run(
157
+ tool="fs.read",
158
+ verb="read",
159
+ resource=path_resource("notes.txt", workspace_root=workspace),
160
+ )
161
+ print(res.verdict.value, res.status, res.result)
162
+ ```
163
+
164
+ For runnable examples (file writes with postcondition verification, blocked actions, HTTP gateway, and AI-agent function-calling integration), see [`examples/`](examples/).
165
+
166
+ ---
167
+
168
+ ## Guarantees and Limits
169
+
170
+ Actentra is designed to **fail closed**, bind approvals to exact `sha256` action hashes, and persist durable decision records before execution. See [docs/security/guarantees-and-limits.md](docs/security/guarantees-and-limits.md) for explicit architectural boundaries and non-goals.