loopgrid-claude-agent 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.
- loopgrid_claude_agent-0.1.0/CHANGELOG.md +5 -0
- loopgrid_claude_agent-0.1.0/INTEGRATION-CONTRACT.md +17 -0
- loopgrid_claude_agent-0.1.0/LICENSE +202 -0
- loopgrid_claude_agent-0.1.0/MANIFEST.in +4 -0
- loopgrid_claude_agent-0.1.0/NOTICE.md +6 -0
- loopgrid_claude_agent-0.1.0/OFFLINE-EXTENDED-VALIDATION.md +32 -0
- loopgrid_claude_agent-0.1.0/PKG-INFO +207 -0
- loopgrid_claude_agent-0.1.0/RC2-LIVE-RUNTIME-DIAGNOSTICS.md +20 -0
- loopgrid_claude_agent-0.1.0/README.md +179 -0
- loopgrid_claude_agent-0.1.0/RELEASE-CHECKLIST.md +47 -0
- loopgrid_claude_agent-0.1.0/SECURITY.md +19 -0
- loopgrid_claude_agent-0.1.0/VALIDATION.md +43 -0
- loopgrid_claude_agent-0.1.0/WINDOWS-VALIDATION.md +52 -0
- loopgrid_claude_agent-0.1.0/examples/native_claude_runtime_e2e.py +181 -0
- loopgrid_claude_agent-0.1.0/examples/native_core_hook_e2e.py +95 -0
- loopgrid_claude_agent-0.1.0/examples/native_core_recovery_e2e.py +61 -0
- loopgrid_claude_agent-0.1.0/examples/native_core_security_e2e.py +87 -0
- loopgrid_claude_agent-0.1.0/examples/offline_core_durability_e2e.py +171 -0
- loopgrid_claude_agent-0.1.0/pyproject.toml +37 -0
- loopgrid_claude_agent-0.1.0/setup.cfg +4 -0
- loopgrid_claude_agent-0.1.0/src/loopgrid_claude_agent/__init__.py +12 -0
- loopgrid_claude_agent-0.1.0/src/loopgrid_claude_agent/authorization.py +195 -0
- loopgrid_claude_agent-0.1.0/src/loopgrid_claude_agent/claims.py +153 -0
- loopgrid_claude_agent-0.1.0/src/loopgrid_claude_agent/integration.py +430 -0
- loopgrid_claude_agent-0.1.0/src/loopgrid_claude_agent.egg-info/PKG-INFO +207 -0
- loopgrid_claude_agent-0.1.0/src/loopgrid_claude_agent.egg-info/SOURCES.txt +31 -0
- loopgrid_claude_agent-0.1.0/src/loopgrid_claude_agent.egg-info/dependency_links.txt +1 -0
- loopgrid_claude_agent-0.1.0/src/loopgrid_claude_agent.egg-info/requires.txt +7 -0
- loopgrid_claude_agent-0.1.0/src/loopgrid_claude_agent.egg-info/top_level.txt +1 -0
- loopgrid_claude_agent-0.1.0/tests/conftest.py +71 -0
- loopgrid_claude_agent-0.1.0/tests/test_extended_offline.py +216 -0
- loopgrid_claude_agent-0.1.0/tests/test_integration.py +348 -0
- loopgrid_claude_agent-0.1.0/tests/test_native_sdk.py +23 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 — Initial release
|
|
4
|
+
|
|
5
|
+
Initial native Python integration for Claude Agent SDK, covering `PreToolUse`, `PostToolUse`, `PostToolUseFailure`, agent model-response commitments, application policy and reviewer records, atomic authorizations, SQLite/local replay safety, downstream receipts, and reconciliation of uncertain external actions.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# LoopGrid Claude Agent SDK — integration contract v0.1.0
|
|
2
|
+
|
|
3
|
+
**Decision:** an authenticated host starts a scoped decision bound to exactly one tool name and exact canonical arguments, with an invocation limit (default one).
|
|
4
|
+
|
|
5
|
+
**Policy:** only a persisted `auto_allowed` verdict, or `human_approval_required` plus authenticated persisted approval, can proceed. `blocked` always denies.
|
|
6
|
+
|
|
7
|
+
**PreToolUse:** universal SDK wildcard hook checks name + args, persists `tool_requested`, claims call ID, consumes invocation authorization, and returns allow; otherwise returns SDK deny. The SDK and application must keep these hooks installed.
|
|
8
|
+
|
|
9
|
+
**PostToolUse:** only a previously reserved, matching call ID/name/args can write `tool_executed` with result commitment. No external outcome is inferred.
|
|
10
|
+
|
|
11
|
+
**PostToolUseFailure:** stops the run; records an uncertain failed/reserved claim and requests reconciliation. No successful execution asserted.
|
|
12
|
+
|
|
13
|
+
**Model response:** host wraps `client.receive_response()` in `hooks.observe_messages()`, capturing AssistantMessage commitments (with model metadata).
|
|
14
|
+
|
|
15
|
+
**Outcome:** independent host verifies receipt and then explicitly calls `record_observed_outcome`. Core handles signed evidence and verification.
|
|
16
|
+
|
|
17
|
+
**Transport:** `loopgrid>=0.8,<0.9`; LoopGrid Core validation target `0.8.1-design-partner`; no Core modifications or alternative signer.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
LoopGrid Claude Agent SDK integration
|
|
2
|
+
Copyright 2026 LoopGrid contributors.
|
|
3
|
+
Licensed under the Apache License, Version 2.0.
|
|
4
|
+
|
|
5
|
+
Claude Agent SDK is developed by Anthropic. This package is an independently
|
|
6
|
+
maintained LoopGrid integration, not an Anthropic-published SDK or endorsement.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Claude Agent SDK — extended offline validation (RC2.1)
|
|
2
|
+
|
|
3
|
+
The RC2.1 candidate adds adversarial hook, replay, concurrency and persistence tests along with a narrow authorization-ledger correctness fix. No Anthropic API calls are required.
|
|
4
|
+
|
|
5
|
+
**Confirmed on Windows:** 59/59 automated tests with `claude-agent-sdk==0.2.165`, plus four real-Core scenarios, a clean isolated source/wheel build, passing Twine checks and clean-wheel import.
|
|
6
|
+
|
|
7
|
+
## Security-ledger fix
|
|
8
|
+
|
|
9
|
+
An over-limit second tool call was denied by `PreToolUse`, but could previously leave an unnecessary pending-reconciliation entry. RC2.1 cancels **only the newly created pre-execution claim** when the authorization counter rejects that attempt. A tool call already authorized or executed retains the claim to prevent blind retries.
|
|
10
|
+
|
|
11
|
+
## Extended coverage
|
|
12
|
+
|
|
13
|
+
- Exact tool and argument commitment matching; wrong-input rejection.
|
|
14
|
+
- Policy blocked, missing approval, host approval and rejection.
|
|
15
|
+
- Replay detection, duplicate callback denial and forged post-tool callback rejection.
|
|
16
|
+
- Cross-workspace authorization separation and concurrent invocation limits.
|
|
17
|
+
- SQLite authorization state surviving process restarts.
|
|
18
|
+
- Tool result persistence failures and durable reconciliation instead of false completion.
|
|
19
|
+
- SDK-native options construction; guard-controlled options cannot be silently overridden by caller kwargs.
|
|
20
|
+
|
|
21
|
+
## Reproduce on Windows
|
|
22
|
+
|
|
23
|
+
```powershell
|
|
24
|
+
.\.venv\Scripts\python.exe -m pytest -q
|
|
25
|
+
.\.venv\Scripts\python.exe examples\offline_core_durability_e2e.py
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The durability example needs a running LoopGrid Core at `http://127.0.0.1:8000`. It uses a fresh workspace and disposable SQLite state; no real money moves.
|
|
29
|
+
|
|
30
|
+
**Independent local offline run:** 57 passed and 2 SDK-dependent tests skipped because that environment lacks the official SDK package. Windows installed-SDK run: **59 passed** with no skips.
|
|
31
|
+
|
|
32
|
+
**Next gate:** Actual Claude model-to-MCP tool invocation, currently deferred due to Anthropic API credits. See [`VALIDATION.md`](VALIDATION.md).
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: loopgrid-claude-agent
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Signed decision, policy, approval and tool-action evidence for Claude Agent SDK
|
|
5
|
+
Author: LoopGrid contributors
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://loopgrid.io
|
|
8
|
+
Project-URL: Repository, https://github.com/loopgridio/loopgrid-claude-agent
|
|
9
|
+
Project-URL: Documentation, https://loopgrid.io/integrations/
|
|
10
|
+
Keywords: claude-agent-sdk,anthropic,agent-governance,action-evidence,ed25519,audit-trail
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
License-File: NOTICE.md
|
|
21
|
+
Requires-Dist: loopgrid<0.9,>=0.8.0
|
|
22
|
+
Requires-Dist: claude-agent-sdk<0.3,>=0.2.165
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
25
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
26
|
+
Requires-Dist: twine>=6; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
# LoopGrid × Claude Agent SDK
|
|
30
|
+
|
|
31
|
+
**Verifiable decision evidence and policy enforcement for consequential Claude agent actions.**
|
|
32
|
+
|
|
33
|
+
Give Claude agents the freedom to use real tools—and give your application an independently checkable record of *what was authorized, what ran, and what happened afterward*.
|
|
34
|
+
|
|
35
|
+
**LoopGrid adds a decision-level evidence layer to the native Claude Agent SDK lifecycle:**
|
|
36
|
+
|
|
37
|
+
**Authority → Policy → Human review (when required) → Tool request → Tool execution → Observed outcome → Signed verification**
|
|
38
|
+
|
|
39
|
+
It works with the Claude Agent SDK's built-in and MCP tools, uses native tool hooks, and keeps the Claude model and existing tool implementations in place. LoopGrid Core signs and chains the resulting evidence for independent verification.
|
|
40
|
+
|
|
41
|
+
## Why LoopGrid
|
|
42
|
+
|
|
43
|
+
A conventional agent trace can describe an interaction. LoopGrid links consequential actions to their authorization and outcome evidence, so an operator or auditor can independently verify the captured record.
|
|
44
|
+
|
|
45
|
+
| Capability | What you get |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| **Native Claude hooks** | `PreToolUse`, `PostToolUse`, and `PostToolUseFailure` lifecycle integration |
|
|
48
|
+
| **Decision-scoped authorization** | Exact tool-name and canonical-argument matching; fail-closed policy checks before execution |
|
|
49
|
+
| **Human-in-the-loop evidence** | Host-authenticated approval and rejection records when a decision requires review |
|
|
50
|
+
| **Execution provenance** | Correlation by tool-use ID, response commitments, failure reporting, and model-output commitments |
|
|
51
|
+
| **Durable action safety** | One-use authorizations, replay/concurrency protection, optional SQLite persistence across local process restarts |
|
|
52
|
+
| **Outcome evidence** | Separately recorded, host-verified receipts rather than treating model text as a completed action |
|
|
53
|
+
| **Independent verification** | Ed25519 signatures and SHA-256-linked evidence from LoopGrid Core |
|
|
54
|
+
| **Reconciliation** | Explicit handling of uncertain actions when evidence cannot be persisted after tool execution |
|
|
55
|
+
|
|
56
|
+
Designed for teams building Claude agents that act through business APIs, internal tools, MCP servers, and automated workflows—especially where policy, review, and proof matter as much as the model's answer.
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
|
|
60
|
+
**From the current source checkout:**
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
python -m pip install -e ".[dev]"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**After the public v0.1.0 release:**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install loopgrid-claude-agent==0.1.0
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Requires Python 3.11+, the official `claude-agent-sdk` Python package, the `loopgrid` Python SDK, and a reachable LoopGrid Core instance. The SDK dependencies are declared in `pyproject.toml`.
|
|
73
|
+
|
|
74
|
+
## Integrate in four steps
|
|
75
|
+
|
|
76
|
+
**1. Create a decision with exact action authority and a policy verdict.** Your trusted application—not the model—chooses the tool, arguments, scope, and policy.
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from loopgrid import LoopGrid
|
|
80
|
+
from loopgrid_claude_agent import LoopGridClaudeAgent
|
|
81
|
+
|
|
82
|
+
workspace_id = "YOUR_EXISTING_WORKSPACE_ID"
|
|
83
|
+
core = LoopGrid(base_url="http://127.0.0.1:8000", workspace_id=workspace_id)
|
|
84
|
+
bridge = LoopGridClaudeAgent(client=core, workspace_id=workspace_id, agent_id="refund-agent")
|
|
85
|
+
|
|
86
|
+
decision_id = bridge.start_decision(
|
|
87
|
+
decision_type="refund_simulation",
|
|
88
|
+
agent={"id": "refund-agent", "version": "1"},
|
|
89
|
+
authority={"acting_for": "sandbox", "scope": ["refund:simulate"]},
|
|
90
|
+
model={"provider": "anthropic", "name": "claude-agent-sdk"},
|
|
91
|
+
context={"prompt_version": "refund-v1"},
|
|
92
|
+
proposed_action={
|
|
93
|
+
"tool": "mcp__loopgrid_sandbox__sandbox_refund",
|
|
94
|
+
"arguments": {"amount": 25},
|
|
95
|
+
},
|
|
96
|
+
policy={"policy_id": "refund-policy", "version": "1", "decision": "auto_allowed"},
|
|
97
|
+
)["decision_id"]
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**2. Attach the native enforcement hooks to the Claude session.**
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from claude_agent_sdk import ClaudeSDKClient
|
|
104
|
+
|
|
105
|
+
hooks = bridge.hooks(decision_id)
|
|
106
|
+
options = hooks.options(mcp_servers={"loopgrid_sandbox": your_mcp_server})
|
|
107
|
+
|
|
108
|
+
async with ClaudeSDKClient(options=options) as agent:
|
|
109
|
+
await agent.query("Simulate the authorized refund once using the sandbox tool.")
|
|
110
|
+
async for message in hooks.observe_messages(agent.receive_response()):
|
|
111
|
+
pass
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Here, `your_mcp_server` is the SDK MCP server object your application supplies. The hooks deny other tool names, unexpected arguments, and unauthorized repeat calls.
|
|
115
|
+
|
|
116
|
+
**3. Add genuine downstream outcome evidence.**
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
# Host application validates a receipt from the actual downstream system.
|
|
120
|
+
bridge.record_observed_outcome(
|
|
121
|
+
decision_id,
|
|
122
|
+
observer="sandbox-ledger",
|
|
123
|
+
receipt_id=verified_receipt["id"],
|
|
124
|
+
outcome=verified_receipt,
|
|
125
|
+
)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
`verified_receipt` is supplied by your application after verification—not generated from Claude's summary.
|
|
129
|
+
|
|
130
|
+
**4. Inspect the signed decision record.**
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
record = bridge.get_decision(decision_id)
|
|
134
|
+
evidence = bridge.export_evidence(decision_id)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
For a **complete runnable example**, including creation of the in-process MCP sandbox tool, workspace setup, lifecycle assertions, and signed verification, use [`examples/native_claude_runtime_e2e.py`](examples/native_claude_runtime_e2e.py).
|
|
138
|
+
|
|
139
|
+
## Human approval and durable authorization
|
|
140
|
+
|
|
141
|
+
For sensitive actions, record a real host-authenticated approval before execution:
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
bridge.record_human_review(
|
|
145
|
+
decision_id,
|
|
146
|
+
reviewer="authenticated-user-123",
|
|
147
|
+
approved=True,
|
|
148
|
+
reason="approved support ticket 123",
|
|
149
|
+
)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Use a decision policy of `human_approval_required` for this path, or pass a host-owned asynchronous `approval_handler` to `bridge.hooks(...)` returning a `ReviewVerdict`. A Claude-generated statement is never accepted as a reviewer identity.
|
|
153
|
+
|
|
154
|
+
For persistence across local worker restarts:
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
bridge = LoopGridClaudeAgent.with_sqlite(
|
|
158
|
+
client=core,
|
|
159
|
+
workspace_id=workspace_id,
|
|
160
|
+
agent_id="refund-agent",
|
|
161
|
+
sqlite_path="./loopgrid-claude-authorizations.db",
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
pending = bridge.pending_reconciliations()
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Keep the SQLite file secure and reuse the same file across restarted workers. The integration prevents blind re-execution when an action's downstream outcome needs reconciliation.
|
|
168
|
+
|
|
169
|
+
## See the evidence lifecycle in action
|
|
170
|
+
|
|
171
|
+
### Offline and real-Core validation — no Claude API credits
|
|
172
|
+
|
|
173
|
+
With LoopGrid Core running at `http://127.0.0.1:8000`:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
python -m pytest -q
|
|
177
|
+
python examples/native_core_hook_e2e.py
|
|
178
|
+
python examples/native_core_security_e2e.py
|
|
179
|
+
python examples/native_core_recovery_e2e.py
|
|
180
|
+
python examples/offline_core_durability_e2e.py
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
These exercise native SDK hook construction, deterministic SDK-hook inputs, the real LoopGrid Core, authorization, security scenarios, durability, signed verification, and failure recovery. They do **not** run a Claude model.
|
|
184
|
+
|
|
185
|
+
### Full Claude model and MCP sandbox example
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
python examples/native_claude_runtime_e2e.py
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
This exercises an actual Claude SDK session with a harmless in-process MCP refund simulator and real Core. It requires an authenticated Anthropic API account with available credits. The sandbox moves **no real money**.
|
|
192
|
+
|
|
193
|
+
## Validation status
|
|
194
|
+
|
|
195
|
+
**Validated on Windows with Python 3.12 and Claude Agent SDK 0.2.165:** 59/59 automated tests, six real-Core security scenarios, native hook/Core verification, restart and replay durability, post-execution reconciliation, dependency checks, and wheel/sdist builds with both distributions passing `twine check`.
|
|
196
|
+
|
|
197
|
+
**Live-runtime validation:** The authenticated, model-driven Claude → MCP tool → signed Core verification scenario has not yet been completed because Anthropic API credits were unavailable. The offline, SDK-compatibility, and Core-backed tests above passed. See [`VALIDATION.md`](VALIDATION.md) for the full validation record.
|
|
198
|
+
|
|
199
|
+
## Documentation
|
|
200
|
+
|
|
201
|
+
- [Integration contract](INTEGRATION-CONTRACT.md) — evidence events, authorization, and hook mapping
|
|
202
|
+
- [Security and trust model](SECURITY.md) — operator-owned approval, tool boundaries, and recovery
|
|
203
|
+
- [Windows validation and clean-wheel check](WINDOWS-VALIDATION.md)
|
|
204
|
+
- [Extended offline validation](OFFLINE-EXTENDED-VALIDATION.md)
|
|
205
|
+
- [LoopGrid](https://loopgrid.io) · [Claude Agent SDK for Python](https://github.com/anthropics/claude-agent-sdk-python) · [Claude SDK hooks](https://code.claude.com/docs/en/agent-sdk/hooks)
|
|
206
|
+
|
|
207
|
+
This is an independently maintained LoopGrid integration for the Claude Agent SDK.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# RC2: Claude runtime diagnosis after Windows Step 3
|
|
2
|
+
|
|
3
|
+
The original RC1 live example raised `AssertionError: {receipts: [], gateError: None, postError: None}` but silently dropped all SDK response messages. That output does **not** establish that an SDK tool call was attempted or that the LoopGrid gate was involved.
|
|
4
|
+
|
|
5
|
+
RC2 modifies **only the live sandbox example and its test instructions**. No security/authorization Core adapter, test, or dependency changes.
|
|
6
|
+
|
|
7
|
+
Run once with a working authenticated Claude SDK session and LoopGrid Core:
|
|
8
|
+
|
|
9
|
+
```powershell
|
|
10
|
+
.\.venv\Scripts\python.exe examples\native_claude_runtime_e2e.py
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Look for:
|
|
14
|
+
|
|
15
|
+
- `MCP connection status`: `loopgrid_sandbox` should be connected and expose `sandbox_refund`.
|
|
16
|
+
- `SDK message: ... ResultMessage`: `is_error`, `subtype`, and bounded error/result previews reveal model/CLI problems that RC1 concealed.
|
|
17
|
+
- `SDK message: ... AssistantMessage`: a `ToolUseBlock` should name `mcp__loopgrid_sandbox__sandbox_refund`.
|
|
18
|
+
- `gateError` / `postError`: if set, identify a LoopGrid hook rejection/failure (not simply a missing model tool call).
|
|
19
|
+
|
|
20
|
+
The exact next fix depends on the *observed* cause. Never disable the PreToolUse gate, weaken tool argument commitments, enable `bypassPermissions`, or claim an executed tool based on a model text response. The initial v0.1.0 release may be distributed with this model-driven scenario recorded as unverified; do not claim the scenario passed until real tool invocation, post-tool evidence, and Core verification succeed.
|