arclasp 0.1.0b1__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 (34) hide show
  1. arclasp-0.1.0b1/.gitattributes +12 -0
  2. arclasp-0.1.0b1/.gitignore +115 -0
  3. arclasp-0.1.0b1/CHANGELOG.md +147 -0
  4. arclasp-0.1.0b1/CONTRIBUTING.md +232 -0
  5. arclasp-0.1.0b1/LICENSE +201 -0
  6. arclasp-0.1.0b1/PKG-INFO +478 -0
  7. arclasp-0.1.0b1/PUBLIC_ROADMAP.md +49 -0
  8. arclasp-0.1.0b1/README.md +426 -0
  9. arclasp-0.1.0b1/SECURITY.md +126 -0
  10. arclasp-0.1.0b1/SECURITY_AND_TRUST.md +176 -0
  11. arclasp-0.1.0b1/arclasp/__init__.py +53 -0
  12. arclasp-0.1.0b1/arclasp/_constants.py +55 -0
  13. arclasp-0.1.0b1/arclasp/_utils.py +22 -0
  14. arclasp-0.1.0b1/arclasp/chain.py +951 -0
  15. arclasp-0.1.0b1/arclasp/client.py +790 -0
  16. arclasp-0.1.0b1/arclasp/crewai/README.md +163 -0
  17. arclasp-0.1.0b1/arclasp/crewai/__init__.py +19 -0
  18. arclasp-0.1.0b1/arclasp/crewai/adapter.py +486 -0
  19. arclasp-0.1.0b1/arclasp/crewai/callbacks.py +218 -0
  20. arclasp-0.1.0b1/arclasp/exceptions.py +272 -0
  21. arclasp-0.1.0b1/arclasp/langchain/__init__.py +19 -0
  22. arclasp-0.1.0b1/arclasp/langchain/adapter.py +253 -0
  23. arclasp-0.1.0b1/arclasp/langchain/callbacks.py +478 -0
  24. arclasp-0.1.0b1/arclasp/langgraph/README.md +114 -0
  25. arclasp-0.1.0b1/arclasp/langgraph/__init__.py +21 -0
  26. arclasp-0.1.0b1/arclasp/langgraph/adapter.py +421 -0
  27. arclasp-0.1.0b1/arclasp/langgraph/callbacks.py +347 -0
  28. arclasp-0.1.0b1/arclasp/langgraph/nodes.py +170 -0
  29. arclasp-0.1.0b1/arclasp/mcp/__init__.py +25 -0
  30. arclasp-0.1.0b1/arclasp/mcp/adapter.py +158 -0
  31. arclasp-0.1.0b1/arclasp/models.py +574 -0
  32. arclasp-0.1.0b1/arclasp/policies.py +737 -0
  33. arclasp-0.1.0b1/arclasp/sanitization.py +120 -0
  34. arclasp-0.1.0b1/pyproject.toml +110 -0
@@ -0,0 +1,12 @@
1
+ * text=auto
2
+ *.py text eol=lf
3
+ *.md text eol=lf
4
+ *.toml text eol=lf
5
+ *.yml text eol=lf
6
+ *.yaml text eol=lf
7
+
8
+ *.png binary
9
+ *.jpg binary
10
+ *.jpeg binary
11
+ *.gif binary
12
+ *.ico binary
@@ -0,0 +1,115 @@
1
+ # ─── Secrets & credentials (NEVER commit) ─────────────────────────────
2
+ # Environment files — covers .env, .env.local, .env.production, etc.
3
+ .env
4
+ .env.*
5
+ !.env.example
6
+ !.env.sample
7
+ !.env.template
8
+
9
+ # Private keys, certs, credentials
10
+ *.pem
11
+ *.key
12
+ *.cert
13
+ *.crt
14
+ *.pfx
15
+ *.p12
16
+ id_rsa
17
+ id_rsa.*
18
+ id_ecdsa
19
+ id_ecdsa.*
20
+ id_ed25519
21
+ id_ed25519.*
22
+
23
+ # Common credential directories
24
+ secrets/
25
+ secret/
26
+ credentials/
27
+ private/
28
+ .secrets/
29
+
30
+ # Backup files (often contain pre-edit copies of env files)
31
+ *.bak
32
+ *.backup
33
+ *.dump
34
+ *.old
35
+ *~
36
+
37
+ # ─── AI tool artifacts (project-local, never useful in public repo) ──
38
+ .claude/
39
+ .claire/
40
+ .cursor/
41
+ .aider*
42
+ .continue/
43
+ .codex/
44
+ CLAUDE.md
45
+ AGENTS.md
46
+
47
+ # ─── Python build artifacts ──────────────────────────────────────────
48
+ __pycache__/
49
+ *.py[cod]
50
+ *$py.class
51
+ *.egg-info/
52
+ *.egg
53
+ dist/
54
+ build/
55
+ .eggs/
56
+ *.so
57
+ *.whl
58
+ wheels/
59
+
60
+ # ─── Python tool caches ──────────────────────────────────────────────
61
+ .pytest_cache/
62
+ .coverage
63
+ .coverage.*
64
+ htmlcov/
65
+ coverage.xml
66
+ .tox/
67
+ .nox/
68
+ .mypy_cache/
69
+ .ruff_cache/
70
+ .pyre/
71
+ .pytype/
72
+ .hypothesis/
73
+
74
+ # ─── Virtual environments ────────────────────────────────────────────
75
+ venv/
76
+ .venv/
77
+ env/
78
+ ENV/
79
+ .python-version
80
+
81
+ # ─── Local databases & data dumps ────────────────────────────────────
82
+ *.sqlite
83
+ *.sqlite3
84
+ *.db
85
+ *.sql.gz
86
+ *.dump
87
+
88
+ # ─── IDE / editor ────────────────────────────────────────────────────
89
+ .vscode/
90
+ .idea/
91
+ *.swp
92
+ *.swo
93
+ *.swn
94
+ .DS_Store
95
+ *.sublime-workspace
96
+ *.sublime-project
97
+
98
+ # ─── OS ──────────────────────────────────────────────────────────────
99
+ Thumbs.db
100
+ ehthumbs.db
101
+ desktop.ini
102
+
103
+ # ─── Local dev scratch ───────────────────────────────────────────────
104
+ *.log
105
+ local_*
106
+ scratch/
107
+ tmp/
108
+ temp/
109
+ .notes/
110
+ NOTES.md
111
+ TODO.md
112
+
113
+ # ─── Process artifacts ───────────────────────────────────────────────
114
+ *.pid
115
+ *.sock
@@ -0,0 +1,147 @@
1
+ # Changelog
2
+
3
+ All notable changes to Arclasp (formerly ProofRail) will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0b1] - 2026-09-05
11
+
12
+ Public beta release candidate for the first public Arclasp SDK publication.
13
+
14
+ ### Changed
15
+
16
+ - **Breaking:** the Python import namespace is now `arclasp` (previously `proofrail`). `import arclasp`, `from arclasp import Chain`, `from arclasp.exceptions import ...` replace the old `proofrail` imports. The PyPI distribution name (`arclasp`) is unchanged from the prior prerelease. Exception classes `ProofRailPolicyError`, `ProofRailVerificationError`, and `ProofRailKillSwitchError` are renamed to `ArclaspPolicyError`, `ArclaspVerificationError`, and `ArclaspKillSwitchError`. There is no `proofrail` compatibility shim — the project has no external customers on the prior namespace yet.
17
+ - Governed SDK execution now requires backend authority for every public Chain action. The deprecated `enable_local_fast_path=True` setting no longer produces local allow decisions, and backend unavailability raises `BackendUnavailableError` even when legacy `fail_mode="allow"` compatibility settings are supplied.
18
+ - Finalized the first public Arclasp Python namespace before PyPI publication: removed dead local-governance compatibility APIs, exposed `ArclaspPolicyError` at top level, kept legacy receipt verification under `arclasp.client`, and kept backend/wire verification contracts unchanged.
19
+ - Updated package metadata, security contacts, and public documentation links for the Arclasp public beta.
20
+
21
+ ## [0.1.0a10] — 2026-08-19
22
+
23
+ Pre-release repository hygiene pass ahead of first public GitHub/PyPI release.
24
+
25
+ ### Changed
26
+
27
+ - Repository renamed to `TOAAiV/Arclasp`; all project URLs, issue templates,
28
+ and in-repo documentation links now point at the current repository instead
29
+ of the prior `proofrail` name.
30
+ - Fixed inconsistent documentation domain: exception remediation links now
31
+ consistently use `docs.proofrail.dev`.
32
+ - Removed internal engineering/audit working documents and a private-backend
33
+ end-to-end test from the public repository; they do not affect the public
34
+ SDK's behavior or test coverage.
35
+ - Removed a Windows-only development workaround from the production demo
36
+ scripts that disabled TLS certificate verification; production examples now
37
+ use normal certificate-verified HTTPS only.
38
+ - Demo scripts no longer hardcode a personal notification address; they read
39
+ the approver email from an `ARCLASP_APPROVER_EMAIL` environment variable.
40
+ - Package metadata classifier corrected to `Alpha` to match the `a10`
41
+ pre-release version string.
42
+
43
+ ## [0.1.0] — 2026-06-17
44
+
45
+ Initial public release.
46
+
47
+ ### Added
48
+
49
+ **Core governance**
50
+ - Chain-level governance with cumulative metrics across an entire agent workflow
51
+ (financial exposure, external communications, records modified, privileged actions,
52
+ tokens used, external domains contacted).
53
+ - Open-source reference policy engine in `proofrail/policies.py`, verified for parity
54
+ against the backend policy engine on every test run.
55
+ - Blocking human approval gate with configurable timeouts and fallback approvers.
56
+ Returns a fully-resolved `PolicyDecision` to the caller after the approver responds.
57
+ - Local fast-path evaluation for sub-5ms decisions on obviously-safe actions,
58
+ with asynchronous backend logging so the dashboard and audit trail stay accurate.
59
+ - Policy shadow mode for testing new policies against real traffic in observe-only
60
+ mode before flipping them to enforce.
61
+ - Per-action-class fail modes for backend-unreachable scenarios (e.g., deny financial
62
+ actions, allow reads).
63
+ - Time-boxed policy exceptions with explicit scope and expiration.
64
+ - Org-wide kill switch raising `ProofRailKillSwitchError` distinct from regular
65
+ policy denials.
66
+
67
+ **Audit and trust**
68
+ - HMAC-SHA256 signed audit receipts, hash-chained across an organization so
69
+ tampering with any single receipt breaks the chain publicly.
70
+ - Public receipt verification endpoint requiring no authentication.
71
+ - Append-only admin audit log capturing before/after diffs for every dashboard
72
+ mutation.
73
+ - Agent registry with risk tiers; unregistered agents are flagged but not blocked.
74
+
75
+ **Framework adapters**
76
+ - LangGraph adapter via `astream_events` (preferred) with `AsyncCallbackHandler`
77
+ fallback.
78
+ - LangChain adapter via `AsyncCallbackHandler` for tool calls and LLM invocations.
79
+ - CrewAI adapter with both native callback (Strategy A) and `execute_task`
80
+ monkey-patch (Strategy B) instrumentation paths.
81
+ - MCP adapter for instrumenting MCP server tool handlers.
82
+
83
+ **Reliability and safety**
84
+ - Payload sanitization with default patterns for API keys, passwords, credit cards,
85
+ SSNs, private keys, and common token formats (OpenAI, Stripe, GitHub,
86
+ Hugging Face, AWS, JWT). Raw payloads are never persisted.
87
+ - Offline buffer with idempotency keys to prevent duplicate audit events on
88
+ network retry.
89
+ - Cost tracking and monthly budgets: recorded LLM token usage and estimated
90
+ dollar cost, with dashboard-configured UTC calendar month budgets. A governed
91
+ chain requires approval only after a newly recorded total is greater than the
92
+ configured budget; unknown model pricing is not counted as zero.
93
+ - Cross-organization isolation enforced on every UUID-bearing endpoint, with a
94
+ dedicated test suite verifying one organization's API key cannot reach
95
+ another organization's data.
96
+
97
+ ### Security
98
+
99
+ This release ships after a 15-finding security audit of the SDK. All findings
100
+ have been resolved:
101
+
102
+ - Metadata sanitization applied at chain start to prevent unsanitized payloads
103
+ from reaching the backend.
104
+ - API keys stored as `pydantic.SecretStr` to prevent accidental logging.
105
+ - HTTP-to-production warnings switched to logger output and extended to all
106
+ non-localhost URLs.
107
+ - Additional sensitive-value patterns added (JWT prefixes, AWS access keys,
108
+ ProofRail API key prefix).
109
+ - Bytes-type payload handling added to the sanitizer.
110
+ - Action name truncation hardened against oversized inputs.
111
+ - Log sanitization helper applied across all framework adapter log sites.
112
+ - Fast-path cumulative metrics propagation fixed (the financial threshold gate
113
+ was previously not updating local metrics from fast-path decisions).
114
+ - Documented kill-switch limitation in fast-path; full enforcement is on the
115
+ post-launch backlog.
116
+ - Unused `cryptography` dependency removed.
117
+
118
+ Full security policy and disclosure process in [SECURITY.md](SECURITY.md).
119
+
120
+ ### Fixed
121
+
122
+ - **Audit event duplication on retry** — events sent during a network blip
123
+ could be recorded twice. Fixed via idempotency keys on every event POST
124
+ and deduplication on the backend.
125
+ - **Infinite retry on permanent errors** — the offline buffer drain treated
126
+ all HTTP errors as transient, looping forever on 4xx responses. Now
127
+ classifies 400, 401, 403, 404, 422 as permanent (discard and continue) and
128
+ 429, 5xx as transient.
129
+ - **Silent event loss on slow backends** — fixed-duration drain timeout could
130
+ abandon events when backend latency was high. Drain timeout now scales with
131
+ buffered event count.
132
+ - **Network errors propagated as bare exceptions** — `httpx.ReadError` and
133
+ `httpx.WriteError` (raised by load balancer terminations, backend crashes,
134
+ cellular handoffs) were not retried. Now caught alongside `ConnectError`.
135
+
136
+ ### Known limitations
137
+
138
+ - Single region. Backend runs in US-East. European and APAC users may see
139
+ 100-150ms additional latency. Multi-region is on the roadmap.
140
+ - CrewAI deny decisions cannot halt mid-task execution due to CrewAI's
141
+ synchronous task architecture. Governance events are still recorded; the
142
+ decision surfaces as `ActionDeniedError` on the next event loop cycle.
143
+ - Approval notifications are email-only. Slack and Teams integrations are
144
+ planned but not shipped.
145
+ - No SSO beyond what Clerk provides out of the box.
146
+
147
+ [0.1.0]: https://github.com/TOAAiV/Arclasp/releases/tag/v0.1.0
@@ -0,0 +1,232 @@
1
+ # Contributing to Arclasp
2
+
3
+ Thanks for considering a contribution to Arclasp.
4
+
5
+ This repository contains the public Python SDK, supported framework integrations, tests, examples, verification material, and release metadata for Arclasp. The hosted governance backend and dashboard are separate Arclasp infrastructure; opening an issue or pull request here does not imply that every server-side feature is implemented in this repository.
6
+
7
+ The best contributions are focused, reproducible, and easy to review.
8
+
9
+ ## Before you start
10
+
11
+ For a small bug fix, documentation correction, or test improvement, you can open a pull request directly.
12
+
13
+ For a large behavioral change, a new public API, a new framework integration, or anything that changes governance semantics, open an issue first. That gives us a chance to agree on the boundary before substantial implementation work begins.
14
+
15
+ Security vulnerabilities should **not** be discussed in a public issue. Follow `SECURITY.md` and report them privately to **security@arclasp.com**.
16
+
17
+ ## Development setup
18
+
19
+ Arclasp supports Python 3.10 and newer. Python 3.11 is a good default for local development because it is also used in release validation.
20
+
21
+ Clone the repository and create a virtual environment:
22
+
23
+ ```bash
24
+ python -m venv .venv
25
+ ```
26
+
27
+ Activate it.
28
+
29
+ On macOS or Linux:
30
+
31
+ ```bash
32
+ source .venv/bin/activate
33
+ ```
34
+
35
+ On Windows PowerShell:
36
+
37
+ ```powershell
38
+ .\.venv\Scripts\Activate.ps1
39
+ ```
40
+
41
+ Upgrade pip and install the SDK with development dependencies and the supported optional integrations:
42
+
43
+ ```bash
44
+ python -m pip install --upgrade pip
45
+ python -m pip install -e ".[dev,all]"
46
+ ```
47
+
48
+ If you are working only on the framework-agnostic SDK, you can install a smaller dependency set. If you modify a framework adapter, install the corresponding extra and run its integration tests.
49
+
50
+ ## Run the tests
51
+
52
+ Run the public test suite before submitting a pull request:
53
+
54
+ ```bash
55
+ python -m pytest -q
56
+ ```
57
+
58
+ Some tests are intentionally environment-dependent and may skip when an optional external runtime or private service is unavailable. A skip should be explainable; do not turn a failing regression test into a skip simply to make CI green.
59
+
60
+ Run lint checks as well:
61
+
62
+ ```bash
63
+ python -m ruff check .
64
+ ```
65
+
66
+ If your change affects packaging, release metadata, imports, or optional dependencies, also build the distributions locally:
67
+
68
+ ```bash
69
+ python -m pip install build twine
70
+ python -m build
71
+ python -m twine check --strict dist/*
72
+ ```
73
+
74
+ The release pipeline performs additional clean-environment and artifact checks before publication.
75
+
76
+ ## Keep changes narrow
77
+
78
+ A pull request should solve one understandable problem.
79
+
80
+ Please avoid mixing a behavior change with broad formatting, unrelated refactors, dependency churn, and documentation rewrites in the same PR. Narrow changes are easier to review and safer in a governance SDK where small control-flow differences can change runtime behavior.
81
+
82
+ If a refactor is necessary to support the change, explain why in the pull request.
83
+
84
+ ## Preserve the governance boundary
85
+
86
+ Arclasp is not a normal convenience wrapper. Some implementation choices are security and product semantics.
87
+
88
+ Changes must preserve these principles unless the project explicitly decides to change them:
89
+
90
+ **Backend authority.** A governed operation that requires backend authority must not silently acquire a local allow path.
91
+
92
+ **Fail-closed behavior.** Backend uncertainty must not quietly become permission for governed execution.
93
+
94
+ **Customer-side execution.** Arclasp governs configured actions; the customer application still performs the real tool call or side effect after governance permits it.
95
+
96
+ **Scoped evidence.** Do not broaden what public verification, logs, errors, examples, or artifacts expose without reviewing the privacy and security impact.
97
+
98
+ **Precise claims.** Do not change documentation to claim tamper-proof records, guaranteed compliance, legal admissibility, universal exactly-once execution, universal result capture, mature enterprise SSO/custom RBAC, mature self-hosting, or other capabilities that are not part of the current product contract.
99
+
100
+ ## Public API changes
101
+
102
+ The supported top-level API is intentionally small.
103
+
104
+ Before adding a new exported symbol, changing an exception contract, or altering the normal `init` / `Chain` / `record_agent_action` path, explain why the change belongs in the public API instead of an internal module or framework-specific surface.
105
+
106
+ Public API changes should include:
107
+
108
+ - tests covering the new behavior
109
+ - documentation updates
110
+ - changelog notes when user-visible
111
+ - compatibility analysis for existing integrations
112
+
113
+ Do not globally rename compatibility identifiers such as the current `prail_` API-key prefix without a deliberate migration plan.
114
+
115
+ ## Framework integrations
116
+
117
+ Arclasp currently supports custom Python workflows and integration surfaces for LangChain, LangGraph, CrewAI, and MCP.
118
+
119
+ When changing an adapter:
120
+
121
+ - test against the real framework dependency where the test is intended to verify real framework behavior
122
+ - preserve existing callbacks or configuration instead of replacing customer state unnecessarily
123
+ - make sure governance exceptions are not swallowed by framework callback machinery
124
+ - restore temporary monkey patches or hooks even when execution fails
125
+ - be explicit about whether the adapter observes invocation, result, error, or only a subset of those events
126
+ - do not claim universal tool-result capture where the adapter cannot provide it
127
+
128
+ A framework upgrade that changes callback or execution behavior should come with a regression test for the affected path.
129
+
130
+ ## Tests should prove behavior
131
+
132
+ Prefer tests that assert externally meaningful behavior rather than implementation details.
133
+
134
+ Good tests answer questions such as:
135
+
136
+ - Did the governed action stop on deny?
137
+ - Did a required approval block until resolution?
138
+ - Did backend unavailability fail closed?
139
+ - Did the Chain preserve cumulative state?
140
+ - Did the adapter let the governance exception escape?
141
+ - Did sanitization remove the supported sensitive value from a covered event-payload or chain-metadata path?
142
+ - Did the package expose only the intended public contract?
143
+
144
+ Avoid tests that depend on timing luck, real customer data, or mutable production state.
145
+
146
+ ## Documentation changes
147
+
148
+ Documentation is part of the product contract.
149
+
150
+ When editing public copy:
151
+
152
+ - use **Arclasp** as the current product name
153
+ - use canonical public domains such as `arclasp.com`, `docs.arclasp.com`, `app.arclasp.com`, and `api.arclasp.com`
154
+ - keep intentional compatibility identifiers when the product still uses them
155
+ - distinguish tamper-evident evidence from tamper-proof claims
156
+ - distinguish recorded LLM cost governance from provider billing
157
+ - state that customer applications execute their own tools
158
+ - keep public-beta limitations accurate
159
+
160
+ If behavior and documentation disagree, do not paper over the mismatch with wording. Fix the behavior, fix the documentation, or raise the discrepancy explicitly.
161
+
162
+ ## Examples and test data
163
+
164
+ Examples must use synthetic data.
165
+
166
+ Do not commit:
167
+
168
+ - real API keys or tokens
169
+ - private keys or certificates
170
+ - customer payloads
171
+ - personal email addresses used as live recipients
172
+ - production database URLs
173
+ - internal service credentials
174
+ - copied production logs containing identifiers or secrets
175
+
176
+ Use obviously synthetic values such as `finance@example.com` and test-only keys.
177
+
178
+ Before committing a new artifact or fixture, ask whether it is necessary for a public SDK repository and whether it reveals anything that a user needs in order to understand or verify the SDK.
179
+
180
+ ## Pull request checklist
181
+
182
+ Before opening a pull request, make sure:
183
+
184
+ - the change has a clear purpose
185
+ - relevant tests were added or updated
186
+ - `python -m pytest -q` passes in the intended development environment
187
+ - `python -m ruff check .` passes
188
+ - user-facing behavior is documented
189
+ - the changelog is updated when the change is release-noteworthy
190
+ - no secrets, customer data, or machine-specific paths were added
191
+ - new dependencies are justified and appropriately bounded
192
+ - public API changes are deliberate
193
+ - security-sensitive behavior has not been weakened accidentally
194
+
195
+ In the pull request description, explain **what changed, why it changed, and how you verified it**.
196
+
197
+ ## Bug reports
198
+
199
+ A useful bug report usually includes:
200
+
201
+ - Arclasp version
202
+ - Python version
203
+ - operating system
204
+ - framework and framework version, if relevant
205
+ - a minimal reproduction
206
+ - expected behavior
207
+ - actual behavior
208
+ - sanitized error output or traceback
209
+
210
+ Please remove API keys, tokens, customer data, and other secrets before posting.
211
+
212
+ ## Feature requests
213
+
214
+ Feature requests are welcome, especially when they describe the workflow problem rather than only a proposed API shape.
215
+
216
+ Useful context includes:
217
+
218
+ - what the agent is allowed to do
219
+ - where the consequential side effect occurs
220
+ - what decision should happen before execution
221
+ - what workflow state the decision depends on
222
+ - whether a human reviewer is involved
223
+ - what evidence needs to exist afterward
224
+ - which framework or runtime is involved
225
+
226
+ That context helps determine whether the request belongs in the SDK, the hosted governance service, an integration, or documentation.
227
+
228
+ ## License
229
+
230
+ Arclasp's public Python SDK is licensed under the Apache License 2.0.
231
+
232
+ By contributing code or documentation that is accepted into this repository, you agree that the contribution may be distributed under the repository's Apache-2.0 license.