llamaindex-ledgerproof 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.
- llamaindex_ledgerproof-0.1.0/LICENSE +201 -0
- llamaindex_ledgerproof-0.1.0/PKG-INFO +157 -0
- llamaindex_ledgerproof-0.1.0/README.md +120 -0
- llamaindex_ledgerproof-0.1.0/ledgerproof_llamaindex/__init__.py +38 -0
- llamaindex_ledgerproof-0.1.0/ledgerproof_llamaindex/callback_handler.py +326 -0
- llamaindex_ledgerproof-0.1.0/ledgerproof_llamaindex/canonical.py +81 -0
- llamaindex_ledgerproof-0.1.0/ledgerproof_llamaindex/emitter.py +127 -0
- llamaindex_ledgerproof-0.1.0/ledgerproof_llamaindex/schema.py +174 -0
- llamaindex_ledgerproof-0.1.0/ledgerproof_llamaindex/signer.py +102 -0
- llamaindex_ledgerproof-0.1.0/ledgerproof_llamaindex/version.py +3 -0
- llamaindex_ledgerproof-0.1.0/llamaindex_ledgerproof.egg-info/PKG-INFO +157 -0
- llamaindex_ledgerproof-0.1.0/llamaindex_ledgerproof.egg-info/SOURCES.txt +19 -0
- llamaindex_ledgerproof-0.1.0/llamaindex_ledgerproof.egg-info/dependency_links.txt +1 -0
- llamaindex_ledgerproof-0.1.0/llamaindex_ledgerproof.egg-info/requires.txt +13 -0
- llamaindex_ledgerproof-0.1.0/llamaindex_ledgerproof.egg-info/top_level.txt +1 -0
- llamaindex_ledgerproof-0.1.0/pyproject.toml +67 -0
- llamaindex_ledgerproof-0.1.0/setup.cfg +4 -0
- llamaindex_ledgerproof-0.1.0/tests/test_callback_handler.py +146 -0
- llamaindex_ledgerproof-0.1.0/tests/test_canonical.py +53 -0
- llamaindex_ledgerproof-0.1.0/tests/test_emitter.py +64 -0
- llamaindex_ledgerproof-0.1.0/tests/test_schema.py +113 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of tracking or improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
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" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 LedgerProof Foundation
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: llamaindex-ledgerproof
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: LedgerProof callback handler for LlamaIndex — Article 50 transparency receipts for RAG and agent workflows.
|
|
5
|
+
Author-email: LedgerProof Foundation <engineering@ledgerproof.org>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://ledgerproof.org
|
|
8
|
+
Project-URL: Documentation, https://docs.ledgerproof.org/adapters/llamaindex
|
|
9
|
+
Project-URL: Repository, https://github.com/ledgerproof/protocol
|
|
10
|
+
Project-URL: Issues, https://github.com/ledgerproof/protocol/issues
|
|
11
|
+
Keywords: llamaindex,rag,eu-ai-act,article-50,transparency,compliance,cryptography,ed25519
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Legal Industry
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Security :: Cryptography
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: llama-index-core>=0.11
|
|
26
|
+
Requires-Dist: cryptography>=41
|
|
27
|
+
Requires-Dist: cbor2>=5.0
|
|
28
|
+
Requires-Dist: pydantic>=2.0
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
32
|
+
Requires-Dist: ruff>=0.1; extra == "dev"
|
|
33
|
+
Provides-Extra: examples
|
|
34
|
+
Requires-Dist: llama-index>=0.11; extra == "examples"
|
|
35
|
+
Requires-Dist: llama-index-embeddings-huggingface>=0.2; extra == "examples"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# ledgerproof-llamaindex
|
|
39
|
+
|
|
40
|
+
LedgerProof callback handler for [LlamaIndex](https://www.llamaindex.ai/). Emits cryptographically signed, Bitcoin-anchorable **EU AI Act Article 50 transparency receipts** for RAG queries, chat sessions, and agent workflows — without modifying your LlamaIndex response payload.
|
|
41
|
+
|
|
42
|
+
> **Status:** v0.1.0 — MVP. APIs may change before v1.0.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## What this is
|
|
47
|
+
|
|
48
|
+
LedgerProof is an open cryptographic protocol that:
|
|
49
|
+
|
|
50
|
+
1. Emits a signed receipt for every AI-touched interaction.
|
|
51
|
+
2. Batches receipts into a Merkle tree.
|
|
52
|
+
3. Anchors the tree root to Bitcoin via OP_RETURN.
|
|
53
|
+
4. Verifies offline from Bitcoin chain + protocol public key + receipt alone.
|
|
54
|
+
|
|
55
|
+
This package wires LedgerProof into LlamaIndex via the standard `CallbackManager` interface. Receipts emit to a **side channel** (log, queue, or webhook) — your LLM/RAG response is byte-for-byte unchanged.
|
|
56
|
+
|
|
57
|
+
## What this is NOT
|
|
58
|
+
|
|
59
|
+
Read this carefully before deploying.
|
|
60
|
+
|
|
61
|
+
- **No claim of regulator endorsement.** Neither the EU AI Office, ENISA, nor any Member State authority has endorsed this adapter or the LedgerProof protocol.
|
|
62
|
+
- **No Article 40 presumption of conformity.** LedgerProof is not a harmonised standard. Use of this adapter does not create a presumption of conformity with the AI Act.
|
|
63
|
+
- **Scope is narrow.** This adapter provides an **evidence layer for Article 50** (transparency obligations for providers and deployers of certain AI systems). It does NOT cover:
|
|
64
|
+
- Article 9 (risk management system)
|
|
65
|
+
- Article 10 (data and data governance)
|
|
66
|
+
- Article 13 (transparency and provision of information to deployers)
|
|
67
|
+
- Article 15 (accuracy, robustness, cybersecurity)
|
|
68
|
+
- Article 72 (post-market monitoring)
|
|
69
|
+
- **No LlamaIndex Inc. affiliation.** This is an independent integration. LlamaIndex is a registered trademark of LlamaIndex, Inc.
|
|
70
|
+
|
|
71
|
+
## Install
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install ledgerproof-llamaindex
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For the RAG examples:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install "ledgerproof-llamaindex[examples]"
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## 5-minute quickstart (RAG)
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
|
|
87
|
+
from llama_index.core.callbacks import CallbackManager
|
|
88
|
+
|
|
89
|
+
from ledgerproof_llamaindex import LedgerProofCallbackHandler
|
|
90
|
+
from ledgerproof_llamaindex.emitter import LogEmitter
|
|
91
|
+
from ledgerproof_llamaindex.signer import Ed25519Signer
|
|
92
|
+
|
|
93
|
+
handler = LedgerProofCallbackHandler(
|
|
94
|
+
deployer_id="acme-bank-eu",
|
|
95
|
+
signer=Ed25519Signer.ephemeral(), # production: HSM-backed
|
|
96
|
+
emitter=LogEmitter(),
|
|
97
|
+
article="50(1)", # disclosure: user interacting with AI
|
|
98
|
+
)
|
|
99
|
+
Settings.callback_manager = CallbackManager([handler])
|
|
100
|
+
|
|
101
|
+
docs = SimpleDirectoryReader("./data").load_data()
|
|
102
|
+
index = VectorStoreIndex.from_documents(docs)
|
|
103
|
+
query_engine = index.as_query_engine()
|
|
104
|
+
|
|
105
|
+
response = query_engine.query("What is the refund policy?")
|
|
106
|
+
print(response) # response payload is UNCHANGED
|
|
107
|
+
# Receipt has been emitted to the configured side channel.
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## C1–C8 protocol discipline
|
|
111
|
+
|
|
112
|
+
This adapter respects the LedgerProof protocol invariants:
|
|
113
|
+
|
|
114
|
+
| Invariant | Enforcement here |
|
|
115
|
+
|---|---|
|
|
116
|
+
| **C1** No regulator-endorsement claims | Documented above; no marketing copy in code paths |
|
|
117
|
+
| **C4** Local verification only | Adapter never phones home to LedgerProof servers in normal operation |
|
|
118
|
+
| **C6** Stream-aware signing | Transcript hash committed on event-start, signed on event-end. Streaming bodies are not buffered |
|
|
119
|
+
| **C7** Side-channel emission | The LlamaIndex response object is never mutated. Receipts emit to log/queue/webhook only |
|
|
120
|
+
|
|
121
|
+
## Emitters
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from ledgerproof_llamaindex.emitter import LogEmitter, WebhookEmitter, QueueEmitter
|
|
125
|
+
|
|
126
|
+
LogEmitter() # writes JSON to a Python logger
|
|
127
|
+
WebhookEmitter("https://receipts.acme.eu/v1") # POSTs canonical CBOR
|
|
128
|
+
QueueEmitter(my_queue) # puts onto any queue.Queue
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Receipt schemas
|
|
132
|
+
|
|
133
|
+
- `rag_chatbot_session/v1` — Article 50(1) RAG chatbot disclosure with retrieval-context hash.
|
|
134
|
+
- `generated_content/v1` — Article 50(2) generated-content marking.
|
|
135
|
+
- `rag_synthesized_response/v1` — Article 50(1) synthesized response with source attribution.
|
|
136
|
+
|
|
137
|
+
See `ledgerproof_llamaindex/schema.py`.
|
|
138
|
+
|
|
139
|
+
## Production hardening checklist
|
|
140
|
+
|
|
141
|
+
The MVP ships with **ephemeral** signing keys. Before production:
|
|
142
|
+
|
|
143
|
+
- [ ] Replace `Ed25519Signer.ephemeral()` with HSM-backed key (AWS KMS / GCP Cloud HSM / on-prem Luna).
|
|
144
|
+
- [ ] Move from `LogEmitter` to `QueueEmitter` or `WebhookEmitter` with retry + dead-letter.
|
|
145
|
+
- [ ] Configure your Merkle-batcher + Bitcoin anchorer (separate service; not part of this adapter).
|
|
146
|
+
- [ ] Run GDPR DPIA on `deployer_id` and any `subject_pseudonym` fields.
|
|
147
|
+
- [ ] Pin `ledgerproof-llamaindex` and `llama-index-core` versions in your lockfile.
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
Apache License 2.0. See `LICENSE`.
|
|
152
|
+
|
|
153
|
+
## Foundation
|
|
154
|
+
|
|
155
|
+
LedgerProof is stewarded by the **LedgerProof Foundation** — a US 501(c)(3) Delaware non-profit (in formation) with a Dutch Stichting EU subsidiary (in formation). The protocol specification and reference adapters are open-source.
|
|
156
|
+
|
|
157
|
+
Contact: engineering@ledgerproof.org
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# ledgerproof-llamaindex
|
|
2
|
+
|
|
3
|
+
LedgerProof callback handler for [LlamaIndex](https://www.llamaindex.ai/). Emits cryptographically signed, Bitcoin-anchorable **EU AI Act Article 50 transparency receipts** for RAG queries, chat sessions, and agent workflows — without modifying your LlamaIndex response payload.
|
|
4
|
+
|
|
5
|
+
> **Status:** v0.1.0 — MVP. APIs may change before v1.0.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## What this is
|
|
10
|
+
|
|
11
|
+
LedgerProof is an open cryptographic protocol that:
|
|
12
|
+
|
|
13
|
+
1. Emits a signed receipt for every AI-touched interaction.
|
|
14
|
+
2. Batches receipts into a Merkle tree.
|
|
15
|
+
3. Anchors the tree root to Bitcoin via OP_RETURN.
|
|
16
|
+
4. Verifies offline from Bitcoin chain + protocol public key + receipt alone.
|
|
17
|
+
|
|
18
|
+
This package wires LedgerProof into LlamaIndex via the standard `CallbackManager` interface. Receipts emit to a **side channel** (log, queue, or webhook) — your LLM/RAG response is byte-for-byte unchanged.
|
|
19
|
+
|
|
20
|
+
## What this is NOT
|
|
21
|
+
|
|
22
|
+
Read this carefully before deploying.
|
|
23
|
+
|
|
24
|
+
- **No claim of regulator endorsement.** Neither the EU AI Office, ENISA, nor any Member State authority has endorsed this adapter or the LedgerProof protocol.
|
|
25
|
+
- **No Article 40 presumption of conformity.** LedgerProof is not a harmonised standard. Use of this adapter does not create a presumption of conformity with the AI Act.
|
|
26
|
+
- **Scope is narrow.** This adapter provides an **evidence layer for Article 50** (transparency obligations for providers and deployers of certain AI systems). It does NOT cover:
|
|
27
|
+
- Article 9 (risk management system)
|
|
28
|
+
- Article 10 (data and data governance)
|
|
29
|
+
- Article 13 (transparency and provision of information to deployers)
|
|
30
|
+
- Article 15 (accuracy, robustness, cybersecurity)
|
|
31
|
+
- Article 72 (post-market monitoring)
|
|
32
|
+
- **No LlamaIndex Inc. affiliation.** This is an independent integration. LlamaIndex is a registered trademark of LlamaIndex, Inc.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install ledgerproof-llamaindex
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For the RAG examples:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install "ledgerproof-llamaindex[examples]"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 5-minute quickstart (RAG)
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
|
|
50
|
+
from llama_index.core.callbacks import CallbackManager
|
|
51
|
+
|
|
52
|
+
from ledgerproof_llamaindex import LedgerProofCallbackHandler
|
|
53
|
+
from ledgerproof_llamaindex.emitter import LogEmitter
|
|
54
|
+
from ledgerproof_llamaindex.signer import Ed25519Signer
|
|
55
|
+
|
|
56
|
+
handler = LedgerProofCallbackHandler(
|
|
57
|
+
deployer_id="acme-bank-eu",
|
|
58
|
+
signer=Ed25519Signer.ephemeral(), # production: HSM-backed
|
|
59
|
+
emitter=LogEmitter(),
|
|
60
|
+
article="50(1)", # disclosure: user interacting with AI
|
|
61
|
+
)
|
|
62
|
+
Settings.callback_manager = CallbackManager([handler])
|
|
63
|
+
|
|
64
|
+
docs = SimpleDirectoryReader("./data").load_data()
|
|
65
|
+
index = VectorStoreIndex.from_documents(docs)
|
|
66
|
+
query_engine = index.as_query_engine()
|
|
67
|
+
|
|
68
|
+
response = query_engine.query("What is the refund policy?")
|
|
69
|
+
print(response) # response payload is UNCHANGED
|
|
70
|
+
# Receipt has been emitted to the configured side channel.
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## C1–C8 protocol discipline
|
|
74
|
+
|
|
75
|
+
This adapter respects the LedgerProof protocol invariants:
|
|
76
|
+
|
|
77
|
+
| Invariant | Enforcement here |
|
|
78
|
+
|---|---|
|
|
79
|
+
| **C1** No regulator-endorsement claims | Documented above; no marketing copy in code paths |
|
|
80
|
+
| **C4** Local verification only | Adapter never phones home to LedgerProof servers in normal operation |
|
|
81
|
+
| **C6** Stream-aware signing | Transcript hash committed on event-start, signed on event-end. Streaming bodies are not buffered |
|
|
82
|
+
| **C7** Side-channel emission | The LlamaIndex response object is never mutated. Receipts emit to log/queue/webhook only |
|
|
83
|
+
|
|
84
|
+
## Emitters
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from ledgerproof_llamaindex.emitter import LogEmitter, WebhookEmitter, QueueEmitter
|
|
88
|
+
|
|
89
|
+
LogEmitter() # writes JSON to a Python logger
|
|
90
|
+
WebhookEmitter("https://receipts.acme.eu/v1") # POSTs canonical CBOR
|
|
91
|
+
QueueEmitter(my_queue) # puts onto any queue.Queue
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Receipt schemas
|
|
95
|
+
|
|
96
|
+
- `rag_chatbot_session/v1` — Article 50(1) RAG chatbot disclosure with retrieval-context hash.
|
|
97
|
+
- `generated_content/v1` — Article 50(2) generated-content marking.
|
|
98
|
+
- `rag_synthesized_response/v1` — Article 50(1) synthesized response with source attribution.
|
|
99
|
+
|
|
100
|
+
See `ledgerproof_llamaindex/schema.py`.
|
|
101
|
+
|
|
102
|
+
## Production hardening checklist
|
|
103
|
+
|
|
104
|
+
The MVP ships with **ephemeral** signing keys. Before production:
|
|
105
|
+
|
|
106
|
+
- [ ] Replace `Ed25519Signer.ephemeral()` with HSM-backed key (AWS KMS / GCP Cloud HSM / on-prem Luna).
|
|
107
|
+
- [ ] Move from `LogEmitter` to `QueueEmitter` or `WebhookEmitter` with retry + dead-letter.
|
|
108
|
+
- [ ] Configure your Merkle-batcher + Bitcoin anchorer (separate service; not part of this adapter).
|
|
109
|
+
- [ ] Run GDPR DPIA on `deployer_id` and any `subject_pseudonym` fields.
|
|
110
|
+
- [ ] Pin `ledgerproof-llamaindex` and `llama-index-core` versions in your lockfile.
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
Apache License 2.0. See `LICENSE`.
|
|
115
|
+
|
|
116
|
+
## Foundation
|
|
117
|
+
|
|
118
|
+
LedgerProof is stewarded by the **LedgerProof Foundation** — a US 501(c)(3) Delaware non-profit (in formation) with a Dutch Stichting EU subsidiary (in formation). The protocol specification and reference adapters are open-source.
|
|
119
|
+
|
|
120
|
+
Contact: engineering@ledgerproof.org
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""ledgerproof-llamaindex — Article 50 transparency receipts for LlamaIndex.
|
|
2
|
+
|
|
3
|
+
Public API:
|
|
4
|
+
LedgerProofCallbackHandler — drop into llama_index.core.callbacks.CallbackManager.
|
|
5
|
+
Ed25519Signer — signing primitive (ephemeral; HSM-backed in production).
|
|
6
|
+
LogEmitter / WebhookEmitter / QueueEmitter — side-channel receipt sinks (C7).
|
|
7
|
+
RagChatbotSessionReceipt / GeneratedContentReceipt / RagSynthesizedResponseReceipt
|
|
8
|
+
— Pydantic v2 schemas for Article 50 evidence.
|
|
9
|
+
|
|
10
|
+
Discipline:
|
|
11
|
+
C1 — no claim of regulator endorsement or Article 40 presumption of conformity.
|
|
12
|
+
C4 — adapter does not phone home to LedgerProof servers in normal operation.
|
|
13
|
+
C6 — stream-aware signing; transcript hash committed on event start, signed on event end.
|
|
14
|
+
C7 — side-channel emission only; LlamaIndex response payload is never mutated.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from .callback_handler import LedgerProofCallbackHandler
|
|
18
|
+
from .emitter import Emitter, LogEmitter, QueueEmitter, WebhookEmitter
|
|
19
|
+
from .schema import (
|
|
20
|
+
GeneratedContentReceipt,
|
|
21
|
+
RagChatbotSessionReceipt,
|
|
22
|
+
RagSynthesizedResponseReceipt,
|
|
23
|
+
)
|
|
24
|
+
from .signer import Ed25519Signer
|
|
25
|
+
from .version import __version__
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"LedgerProofCallbackHandler",
|
|
29
|
+
"Ed25519Signer",
|
|
30
|
+
"Emitter",
|
|
31
|
+
"LogEmitter",
|
|
32
|
+
"WebhookEmitter",
|
|
33
|
+
"QueueEmitter",
|
|
34
|
+
"RagChatbotSessionReceipt",
|
|
35
|
+
"GeneratedContentReceipt",
|
|
36
|
+
"RagSynthesizedResponseReceipt",
|
|
37
|
+
"__version__",
|
|
38
|
+
]
|