receipt-gate 0.2.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.
- receipt_gate-0.2.0/LICENSE +21 -0
- receipt_gate-0.2.0/PKG-INFO +244 -0
- receipt_gate-0.2.0/README.md +197 -0
- receipt_gate-0.2.0/pyproject.toml +42 -0
- receipt_gate-0.2.0/receipt_gate/__init__.py +59 -0
- receipt_gate-0.2.0/receipt_gate/adapters.py +213 -0
- receipt_gate-0.2.0/receipt_gate/capability.py +125 -0
- receipt_gate-0.2.0/receipt_gate/ledger.py +97 -0
- receipt_gate-0.2.0/receipt_gate/mcp_server.py +848 -0
- receipt_gate-0.2.0/receipt_gate/promise.py +92 -0
- receipt_gate-0.2.0/receipt_gate/settler.py +137 -0
- receipt_gate-0.2.0/receipt_gate/speech_gate.py +143 -0
- receipt_gate-0.2.0/receipt_gate.egg-info/PKG-INFO +244 -0
- receipt_gate-0.2.0/receipt_gate.egg-info/SOURCES.txt +19 -0
- receipt_gate-0.2.0/receipt_gate.egg-info/dependency_links.txt +1 -0
- receipt_gate-0.2.0/receipt_gate.egg-info/entry_points.txt +2 -0
- receipt_gate-0.2.0/receipt_gate.egg-info/requires.txt +3 -0
- receipt_gate-0.2.0/receipt_gate.egg-info/top_level.txt +1 -0
- receipt_gate-0.2.0/setup.cfg +4 -0
- receipt_gate-0.2.0/tests/test_mcp_server.py +366 -0
- receipt_gate-0.2.0/tests/test_receipt_gate.py +282 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shcherbina Vadim
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: receipt-gate
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Agents say done. This checks: a promise names its own receipt before acting, and the claim is held until an independent adapter answers.
|
|
5
|
+
Author-email: Shcherbina Vadim <adekvatologiy@icloud.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Shcherbina Vadim
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/adekvatologiy/receipt-gate
|
|
29
|
+
Project-URL: Specification, https://github.com/adekvatologiy/receipt-gate/blob/main/SPEC.md
|
|
30
|
+
Keywords: agents,llm,verification,receipts,promises,audit,mcp
|
|
31
|
+
Classifier: Development Status :: 3 - Alpha
|
|
32
|
+
Classifier: Intended Audience :: Developers
|
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
39
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
40
|
+
Classifier: Typing :: Typed
|
|
41
|
+
Requires-Python: >=3.10
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
License-File: LICENSE
|
|
44
|
+
Provides-Extra: test
|
|
45
|
+
Requires-Dist: pytest>=7; extra == "test"
|
|
46
|
+
Dynamic: license-file
|
|
47
|
+
|
|
48
|
+
# receipt-gate
|
|
49
|
+
|
|
50
|
+
<!-- mcp-name: io.github.adekvatologiy/receipt-gate -->
|
|
51
|
+
|
|
52
|
+
Agents say "done". This checks.
|
|
53
|
+
|
|
54
|
+
An agent reporting completion is not evidence of completion. `receipt-gate`
|
|
55
|
+
sits between the claim and the record: the claim is held until an
|
|
56
|
+
independent adapter observes the promised state in reality.
|
|
57
|
+
|
|
58
|
+
**Why this exists.** Per-step reliability multiplies. At 85% per step, a
|
|
59
|
+
10-step workflow finishes end to end about 20% of the time. The usual
|
|
60
|
+
answer is retries, checkpoints and idempotency keys. Those protect you
|
|
61
|
+
from doing a thing twice. They do not establish that the thing happened at
|
|
62
|
+
all.
|
|
63
|
+
|
|
64
|
+
The gate is on the sentence, not on the action.
|
|
65
|
+
|
|
66
|
+
## What it does
|
|
67
|
+
|
|
68
|
+
- A **promise** names one observable future state, a deadline, a damage
|
|
69
|
+
ceiling, and which adapter will check it.
|
|
70
|
+
- A **capability proxy** opens only the actions that promise authorises,
|
|
71
|
+
one call at a time, and returns the exact boundary when it refuses.
|
|
72
|
+
- A **receipt adapter** observes that state again, from a source that is
|
|
73
|
+
not the agent's own report.
|
|
74
|
+
- The **speech gate** holds `done` — and any unrelated new promise —
|
|
75
|
+
until the open promise is settled.
|
|
76
|
+
- What does not match is kept as a **remainder**: the exact gap, what can
|
|
77
|
+
no longer be treated as finished, what authority is left, and who may
|
|
78
|
+
accept, cancel or reassign it.
|
|
79
|
+
|
|
80
|
+
Four terminal states, and they do not mix: `fulfilled`,
|
|
81
|
+
`cancelled_by_owner`, `impossible_in_scope`, `handed_over`. Handed over is
|
|
82
|
+
not fulfilled.
|
|
83
|
+
|
|
84
|
+
## What it does not do
|
|
85
|
+
|
|
86
|
+
It gives the agent no goal, no legitimacy and no authority. It does not
|
|
87
|
+
make a bad promise good — if the owner picked the wrong target, the gap
|
|
88
|
+
will be measured against the wrong target. It only refuses to let the
|
|
89
|
+
distance between stated and happened stay invisible.
|
|
90
|
+
|
|
91
|
+
No scoring, no leaderboard, no model in the loop. An adapter re-reads
|
|
92
|
+
state; it does not have an opinion.
|
|
93
|
+
|
|
94
|
+
## Install
|
|
95
|
+
|
|
96
|
+
Python 3.10+, standard library only, no dependencies.
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
git clone https://github.com/adekvatologiy/receipt-gate
|
|
100
|
+
cd receipt-gate
|
|
101
|
+
python -m examples.first_ride
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Thirty lines
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from receipt_gate import Ledger, Promise, SpeechGate, ManifestAdapter, Held
|
|
108
|
+
|
|
109
|
+
ledger = Ledger("ledger.jsonl") # append-only, hash-chained
|
|
110
|
+
gate = SpeechGate(ledger)
|
|
111
|
+
|
|
112
|
+
promise = Promise(
|
|
113
|
+
deal_id="D-1",
|
|
114
|
+
promise_id="P-1",
|
|
115
|
+
holder="agent-1",
|
|
116
|
+
promised_state="manifest.json matches a fresh read of the sources",
|
|
117
|
+
receipt_adapter="manifest+sha256", # named before acting
|
|
118
|
+
authority=["read:sources", "write:manifest.json"],
|
|
119
|
+
damage_ceiling=["write:sources/*", "delete:*", "rename:*"],
|
|
120
|
+
owner="result-owner",
|
|
121
|
+
)
|
|
122
|
+
gate.open_promise(promise)
|
|
123
|
+
|
|
124
|
+
# ... the agent works, then says it finished ...
|
|
125
|
+
|
|
126
|
+
try:
|
|
127
|
+
gate.claim_done("P-1")
|
|
128
|
+
except Held as exc:
|
|
129
|
+
print(exc) # 'done' needs a fresh receipt from 'manifest+sha256';
|
|
130
|
+
# a report by the holder is not one
|
|
131
|
+
|
|
132
|
+
adapter = ManifestAdapter("manifest.json", sources)
|
|
133
|
+
adapter.before = adapter.snapshot() # taken before the ride
|
|
134
|
+
|
|
135
|
+
settlement = gate.claim_done("P-1", adapter.observe())
|
|
136
|
+
print(settlement.state) # fulfilled — or a remainder is written
|
|
137
|
+
if settlement.remainder:
|
|
138
|
+
print(settlement.remainder.gap) # the exact fact that did not match
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## The first ride
|
|
142
|
+
|
|
143
|
+
The example is deliberately boring and completely checkable: build a
|
|
144
|
+
manifest of seven immutable source files with size and SHA-256, under a
|
|
145
|
+
damage ceiling of "no source may be written, renamed or deleted". A
|
|
146
|
+
separate validator re-reads all seven afterwards and compares.
|
|
147
|
+
|
|
148
|
+
Four agents run against the same promise:
|
|
149
|
+
|
|
150
|
+
| agent | what happens |
|
|
151
|
+
| --- | --- |
|
|
152
|
+
| honest | writes a correct manifest, receipt matches, promise settles |
|
|
153
|
+
| claiming | writes nothing, says it finished — held, no receipt |
|
|
154
|
+
| sloppy | one stale digest — remainder with the exact mismatch, debt stays open |
|
|
155
|
+
| reckless | tries to touch a protected source — refused with the ceiling that refused it |
|
|
156
|
+
|
|
157
|
+
A manifest can also be internally consistent and still fail: the adapter
|
|
158
|
+
compares against the state recorded *before* the ride, so a source edited
|
|
159
|
+
behind the gate is seen even when the manifest agrees with the new bytes.
|
|
160
|
+
|
|
161
|
+
## As an MCP server
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
RECEIPT_GATE_LEDGER=./ledger.jsonl RECEIPT_GATE_ROOT=. receipt-gate
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Ten tools over stdio, and the surface is the construction rather than a way
|
|
168
|
+
around it. `claim_done` is held every time, because a tool call by the
|
|
169
|
+
holder is a report by the holder; the reply names the adapter that can
|
|
170
|
+
answer instead. `settle` runs that adapter and returns what it saw.
|
|
171
|
+
|
|
172
|
+
| tool | what it does |
|
|
173
|
+
| --- | --- |
|
|
174
|
+
| `open_promise` | records one observable state, the authority, the ceiling, and the adapter with its own parameters |
|
|
175
|
+
| `request_capability` | one action, for one call — or the exact boundary that refused it |
|
|
176
|
+
| `record_action` | spends a grant; a second use is refused against the ledger |
|
|
177
|
+
| `claim_done` | held, every time, with the adapter named |
|
|
178
|
+
| `settle` | runs the adapter; returns `fulfilled` or a remainder with four facts |
|
|
179
|
+
| `cancel_by_owner` · `impossible_in_scope` · `hand_over` | the other three terminal states |
|
|
180
|
+
| `open_debts` · `verify_ledger` | what the deal still holds; whether the chain is intact |
|
|
181
|
+
|
|
182
|
+
Two things differ here from the in-process library, and both follow from
|
|
183
|
+
the protocol:
|
|
184
|
+
|
|
185
|
+
- **The adapter's own parameters are fixed when the promise is opened** and
|
|
186
|
+
written to the ledger, so a later call cannot redirect the reading. In
|
|
187
|
+
the library the caller builds the adapter at settlement time. This is
|
|
188
|
+
stricter than `SPEC.md` 0.1 requires and is a candidate for 0.2.
|
|
189
|
+
- **Grants live on the ledger, not in memory.** MCP 2026-07-28 is
|
|
190
|
+
stateless and restarts the process between calls; a right that
|
|
191
|
+
evaporates with a process is not a right. Open promises are read back
|
|
192
|
+
from the ledger for the same reason, so the debts survive a restart.
|
|
193
|
+
|
|
194
|
+
Protocol: MCP `2026-07-28` — `server/discover`, per-request `_meta`,
|
|
195
|
+
`resultType`, `ttlMs`/`cacheScope` — with the legacy `initialize`
|
|
196
|
+
handshake answered for clients still on `2025-11-25` or `2025-06-18`.
|
|
197
|
+
`server.json` is ready for the official registry.
|
|
198
|
+
|
|
199
|
+
## Adapters
|
|
200
|
+
|
|
201
|
+
Three are included, and each attests only what its own source observes.
|
|
202
|
+
|
|
203
|
+
| adapter | attests |
|
|
204
|
+
| --- | --- |
|
|
205
|
+
| `manifest+sha256` | a manifest parses, matches a fresh read, protected sources unchanged |
|
|
206
|
+
| `command+exit_code` | a command ran in a clean directory, its exit code, optionally a string in the output |
|
|
207
|
+
| `owner_acceptance` | the result owner accepted one named version digest |
|
|
208
|
+
|
|
209
|
+
Writing an adapter is work. A promise no adapter can answer is the failure
|
|
210
|
+
this is built to make visible.
|
|
211
|
+
|
|
212
|
+
## Specification
|
|
213
|
+
|
|
214
|
+
[`SPEC.md`](SPEC.md) is versioned separately — five records, four terminal
|
|
215
|
+
states, three escrowed rights, and the rule about what an adapter may
|
|
216
|
+
attest. It can be reimplemented in another language without reading this
|
|
217
|
+
code.
|
|
218
|
+
|
|
219
|
+
## Status
|
|
220
|
+
|
|
221
|
+
Version 0.2. Spec 0.1 — the code and the specification carry their own
|
|
222
|
+
numbers, and 0.2 added the MCP server without changing the specification.
|
|
223
|
+
The five parts and the server work, and 43 tests cover them. Not yet: a durable-execution adapter, and language
|
|
224
|
+
bindings beyond Python.
|
|
225
|
+
|
|
226
|
+
Three things worth breaking:
|
|
227
|
+
|
|
228
|
+
1. Is there a case where "the adapter re-reads state" collapses back into
|
|
229
|
+
trusting the agent?
|
|
230
|
+
2. Composite promises currently split or carry several receipts. Is there a
|
|
231
|
+
cleaner rule?
|
|
232
|
+
3. The failure mode expected but not yet produced: agents learning to
|
|
233
|
+
write narrow, easily-settled promises. What would catch that early?
|
|
234
|
+
|
|
235
|
+
## Provenance
|
|
236
|
+
|
|
237
|
+
[`PROVENANCE.md`](PROVENANCE.md) says where the construction came from, what
|
|
238
|
+
is owed to whom, and the three things asked of anyone who carries it
|
|
239
|
+
further. None of it is enforceable; it is there because a technical record
|
|
240
|
+
that hides its own origin is worth less than one that states it.
|
|
241
|
+
|
|
242
|
+
## Licence
|
|
243
|
+
|
|
244
|
+
MIT for the code. See `LICENSE`. Copyright Shcherbina Vadim, 2026.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# receipt-gate
|
|
2
|
+
|
|
3
|
+
<!-- mcp-name: io.github.adekvatologiy/receipt-gate -->
|
|
4
|
+
|
|
5
|
+
Agents say "done". This checks.
|
|
6
|
+
|
|
7
|
+
An agent reporting completion is not evidence of completion. `receipt-gate`
|
|
8
|
+
sits between the claim and the record: the claim is held until an
|
|
9
|
+
independent adapter observes the promised state in reality.
|
|
10
|
+
|
|
11
|
+
**Why this exists.** Per-step reliability multiplies. At 85% per step, a
|
|
12
|
+
10-step workflow finishes end to end about 20% of the time. The usual
|
|
13
|
+
answer is retries, checkpoints and idempotency keys. Those protect you
|
|
14
|
+
from doing a thing twice. They do not establish that the thing happened at
|
|
15
|
+
all.
|
|
16
|
+
|
|
17
|
+
The gate is on the sentence, not on the action.
|
|
18
|
+
|
|
19
|
+
## What it does
|
|
20
|
+
|
|
21
|
+
- A **promise** names one observable future state, a deadline, a damage
|
|
22
|
+
ceiling, and which adapter will check it.
|
|
23
|
+
- A **capability proxy** opens only the actions that promise authorises,
|
|
24
|
+
one call at a time, and returns the exact boundary when it refuses.
|
|
25
|
+
- A **receipt adapter** observes that state again, from a source that is
|
|
26
|
+
not the agent's own report.
|
|
27
|
+
- The **speech gate** holds `done` — and any unrelated new promise —
|
|
28
|
+
until the open promise is settled.
|
|
29
|
+
- What does not match is kept as a **remainder**: the exact gap, what can
|
|
30
|
+
no longer be treated as finished, what authority is left, and who may
|
|
31
|
+
accept, cancel or reassign it.
|
|
32
|
+
|
|
33
|
+
Four terminal states, and they do not mix: `fulfilled`,
|
|
34
|
+
`cancelled_by_owner`, `impossible_in_scope`, `handed_over`. Handed over is
|
|
35
|
+
not fulfilled.
|
|
36
|
+
|
|
37
|
+
## What it does not do
|
|
38
|
+
|
|
39
|
+
It gives the agent no goal, no legitimacy and no authority. It does not
|
|
40
|
+
make a bad promise good — if the owner picked the wrong target, the gap
|
|
41
|
+
will be measured against the wrong target. It only refuses to let the
|
|
42
|
+
distance between stated and happened stay invisible.
|
|
43
|
+
|
|
44
|
+
No scoring, no leaderboard, no model in the loop. An adapter re-reads
|
|
45
|
+
state; it does not have an opinion.
|
|
46
|
+
|
|
47
|
+
## Install
|
|
48
|
+
|
|
49
|
+
Python 3.10+, standard library only, no dependencies.
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
git clone https://github.com/adekvatologiy/receipt-gate
|
|
53
|
+
cd receipt-gate
|
|
54
|
+
python -m examples.first_ride
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Thirty lines
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from receipt_gate import Ledger, Promise, SpeechGate, ManifestAdapter, Held
|
|
61
|
+
|
|
62
|
+
ledger = Ledger("ledger.jsonl") # append-only, hash-chained
|
|
63
|
+
gate = SpeechGate(ledger)
|
|
64
|
+
|
|
65
|
+
promise = Promise(
|
|
66
|
+
deal_id="D-1",
|
|
67
|
+
promise_id="P-1",
|
|
68
|
+
holder="agent-1",
|
|
69
|
+
promised_state="manifest.json matches a fresh read of the sources",
|
|
70
|
+
receipt_adapter="manifest+sha256", # named before acting
|
|
71
|
+
authority=["read:sources", "write:manifest.json"],
|
|
72
|
+
damage_ceiling=["write:sources/*", "delete:*", "rename:*"],
|
|
73
|
+
owner="result-owner",
|
|
74
|
+
)
|
|
75
|
+
gate.open_promise(promise)
|
|
76
|
+
|
|
77
|
+
# ... the agent works, then says it finished ...
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
gate.claim_done("P-1")
|
|
81
|
+
except Held as exc:
|
|
82
|
+
print(exc) # 'done' needs a fresh receipt from 'manifest+sha256';
|
|
83
|
+
# a report by the holder is not one
|
|
84
|
+
|
|
85
|
+
adapter = ManifestAdapter("manifest.json", sources)
|
|
86
|
+
adapter.before = adapter.snapshot() # taken before the ride
|
|
87
|
+
|
|
88
|
+
settlement = gate.claim_done("P-1", adapter.observe())
|
|
89
|
+
print(settlement.state) # fulfilled — or a remainder is written
|
|
90
|
+
if settlement.remainder:
|
|
91
|
+
print(settlement.remainder.gap) # the exact fact that did not match
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## The first ride
|
|
95
|
+
|
|
96
|
+
The example is deliberately boring and completely checkable: build a
|
|
97
|
+
manifest of seven immutable source files with size and SHA-256, under a
|
|
98
|
+
damage ceiling of "no source may be written, renamed or deleted". A
|
|
99
|
+
separate validator re-reads all seven afterwards and compares.
|
|
100
|
+
|
|
101
|
+
Four agents run against the same promise:
|
|
102
|
+
|
|
103
|
+
| agent | what happens |
|
|
104
|
+
| --- | --- |
|
|
105
|
+
| honest | writes a correct manifest, receipt matches, promise settles |
|
|
106
|
+
| claiming | writes nothing, says it finished — held, no receipt |
|
|
107
|
+
| sloppy | one stale digest — remainder with the exact mismatch, debt stays open |
|
|
108
|
+
| reckless | tries to touch a protected source — refused with the ceiling that refused it |
|
|
109
|
+
|
|
110
|
+
A manifest can also be internally consistent and still fail: the adapter
|
|
111
|
+
compares against the state recorded *before* the ride, so a source edited
|
|
112
|
+
behind the gate is seen even when the manifest agrees with the new bytes.
|
|
113
|
+
|
|
114
|
+
## As an MCP server
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
RECEIPT_GATE_LEDGER=./ledger.jsonl RECEIPT_GATE_ROOT=. receipt-gate
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Ten tools over stdio, and the surface is the construction rather than a way
|
|
121
|
+
around it. `claim_done` is held every time, because a tool call by the
|
|
122
|
+
holder is a report by the holder; the reply names the adapter that can
|
|
123
|
+
answer instead. `settle` runs that adapter and returns what it saw.
|
|
124
|
+
|
|
125
|
+
| tool | what it does |
|
|
126
|
+
| --- | --- |
|
|
127
|
+
| `open_promise` | records one observable state, the authority, the ceiling, and the adapter with its own parameters |
|
|
128
|
+
| `request_capability` | one action, for one call — or the exact boundary that refused it |
|
|
129
|
+
| `record_action` | spends a grant; a second use is refused against the ledger |
|
|
130
|
+
| `claim_done` | held, every time, with the adapter named |
|
|
131
|
+
| `settle` | runs the adapter; returns `fulfilled` or a remainder with four facts |
|
|
132
|
+
| `cancel_by_owner` · `impossible_in_scope` · `hand_over` | the other three terminal states |
|
|
133
|
+
| `open_debts` · `verify_ledger` | what the deal still holds; whether the chain is intact |
|
|
134
|
+
|
|
135
|
+
Two things differ here from the in-process library, and both follow from
|
|
136
|
+
the protocol:
|
|
137
|
+
|
|
138
|
+
- **The adapter's own parameters are fixed when the promise is opened** and
|
|
139
|
+
written to the ledger, so a later call cannot redirect the reading. In
|
|
140
|
+
the library the caller builds the adapter at settlement time. This is
|
|
141
|
+
stricter than `SPEC.md` 0.1 requires and is a candidate for 0.2.
|
|
142
|
+
- **Grants live on the ledger, not in memory.** MCP 2026-07-28 is
|
|
143
|
+
stateless and restarts the process between calls; a right that
|
|
144
|
+
evaporates with a process is not a right. Open promises are read back
|
|
145
|
+
from the ledger for the same reason, so the debts survive a restart.
|
|
146
|
+
|
|
147
|
+
Protocol: MCP `2026-07-28` — `server/discover`, per-request `_meta`,
|
|
148
|
+
`resultType`, `ttlMs`/`cacheScope` — with the legacy `initialize`
|
|
149
|
+
handshake answered for clients still on `2025-11-25` or `2025-06-18`.
|
|
150
|
+
`server.json` is ready for the official registry.
|
|
151
|
+
|
|
152
|
+
## Adapters
|
|
153
|
+
|
|
154
|
+
Three are included, and each attests only what its own source observes.
|
|
155
|
+
|
|
156
|
+
| adapter | attests |
|
|
157
|
+
| --- | --- |
|
|
158
|
+
| `manifest+sha256` | a manifest parses, matches a fresh read, protected sources unchanged |
|
|
159
|
+
| `command+exit_code` | a command ran in a clean directory, its exit code, optionally a string in the output |
|
|
160
|
+
| `owner_acceptance` | the result owner accepted one named version digest |
|
|
161
|
+
|
|
162
|
+
Writing an adapter is work. A promise no adapter can answer is the failure
|
|
163
|
+
this is built to make visible.
|
|
164
|
+
|
|
165
|
+
## Specification
|
|
166
|
+
|
|
167
|
+
[`SPEC.md`](SPEC.md) is versioned separately — five records, four terminal
|
|
168
|
+
states, three escrowed rights, and the rule about what an adapter may
|
|
169
|
+
attest. It can be reimplemented in another language without reading this
|
|
170
|
+
code.
|
|
171
|
+
|
|
172
|
+
## Status
|
|
173
|
+
|
|
174
|
+
Version 0.2. Spec 0.1 — the code and the specification carry their own
|
|
175
|
+
numbers, and 0.2 added the MCP server without changing the specification.
|
|
176
|
+
The five parts and the server work, and 43 tests cover them. Not yet: a durable-execution adapter, and language
|
|
177
|
+
bindings beyond Python.
|
|
178
|
+
|
|
179
|
+
Three things worth breaking:
|
|
180
|
+
|
|
181
|
+
1. Is there a case where "the adapter re-reads state" collapses back into
|
|
182
|
+
trusting the agent?
|
|
183
|
+
2. Composite promises currently split or carry several receipts. Is there a
|
|
184
|
+
cleaner rule?
|
|
185
|
+
3. The failure mode expected but not yet produced: agents learning to
|
|
186
|
+
write narrow, easily-settled promises. What would catch that early?
|
|
187
|
+
|
|
188
|
+
## Provenance
|
|
189
|
+
|
|
190
|
+
[`PROVENANCE.md`](PROVENANCE.md) says where the construction came from, what
|
|
191
|
+
is owed to whom, and the three things asked of anyone who carries it
|
|
192
|
+
further. None of it is enforceable; it is there because a technical record
|
|
193
|
+
that hides its own origin is worth less than one that states it.
|
|
194
|
+
|
|
195
|
+
## Licence
|
|
196
|
+
|
|
197
|
+
MIT for the code. See `LICENSE`. Copyright Shcherbina Vadim, 2026.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "receipt-gate"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Agents say done. This checks: a promise names its own receipt before acting, and the claim is held until an independent adapter answers."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { file = "LICENSE" }
|
|
12
|
+
authors = [{ name = "Shcherbina Vadim", email = "adekvatologiy@icloud.com" }]
|
|
13
|
+
keywords = ["agents", "llm", "verification", "receipts", "promises", "audit", "mcp"]
|
|
14
|
+
dependencies = []
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Software Development :: Quality Assurance",
|
|
25
|
+
"Typing :: Typed",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
test = ["pytest>=7"]
|
|
30
|
+
|
|
31
|
+
[project.scripts]
|
|
32
|
+
receipt-gate = "receipt_gate.mcp_server:main"
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/adekvatologiy/receipt-gate"
|
|
36
|
+
Specification = "https://github.com/adekvatologiy/receipt-gate/blob/main/SPEC.md"
|
|
37
|
+
|
|
38
|
+
[tool.setuptools]
|
|
39
|
+
packages = ["receipt_gate"]
|
|
40
|
+
|
|
41
|
+
[tool.pytest.ini_options]
|
|
42
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""receipt-gate — an agent cannot log "done" without an independent receipt.
|
|
2
|
+
|
|
3
|
+
Five parts:
|
|
4
|
+
Ledger append-only records with a hash chain
|
|
5
|
+
CapabilityProxy capabilities that belong to a promise, one call at a time
|
|
6
|
+
adapters readers of reality that are not the holder's report
|
|
7
|
+
Settler promise beside observation: settlement or remainder
|
|
8
|
+
SpeechGate holds "done" and unrelated new work while a debt is open
|
|
9
|
+
|
|
10
|
+
And one way in from outside:
|
|
11
|
+
Server an MCP server over stdio, where the tool surface is the
|
|
12
|
+
construction rather than a way around it
|
|
13
|
+
|
|
14
|
+
The gate is on the sentence, not on the action.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from .ledger import Ledger, canon, digest
|
|
18
|
+
from .promise import (
|
|
19
|
+
CANCELLED_BY_OWNER,
|
|
20
|
+
CLAIM_DONE,
|
|
21
|
+
FULFILLED,
|
|
22
|
+
HANDED_OVER,
|
|
23
|
+
IMPOSSIBLE_IN_SCOPE,
|
|
24
|
+
OPEN,
|
|
25
|
+
OPEN_UNRELATED_PROMISE,
|
|
26
|
+
SILENT_HANDOFF,
|
|
27
|
+
TERMINAL,
|
|
28
|
+
InadmissiblePromise,
|
|
29
|
+
Observation,
|
|
30
|
+
Promise,
|
|
31
|
+
Remainder,
|
|
32
|
+
)
|
|
33
|
+
from .capability import CapabilityProxy, Grant, Refused
|
|
34
|
+
from .adapters import (
|
|
35
|
+
CommandAdapter,
|
|
36
|
+
ManifestAdapter,
|
|
37
|
+
OwnerAcceptanceAdapter,
|
|
38
|
+
sha256_file,
|
|
39
|
+
)
|
|
40
|
+
from .settler import Settlement, Settler
|
|
41
|
+
from .speech_gate import Held, SpeechGate
|
|
42
|
+
from .mcp_server import GateService, PathOutsideRoot, Server, tool_specs
|
|
43
|
+
|
|
44
|
+
__version__ = "0.2.0"
|
|
45
|
+
__spec_version__ = "0.1"
|
|
46
|
+
|
|
47
|
+
__all__ = [
|
|
48
|
+
"Ledger", "canon", "digest",
|
|
49
|
+
"Promise", "Observation", "Remainder", "InadmissiblePromise",
|
|
50
|
+
"OPEN", "FULFILLED", "CANCELLED_BY_OWNER", "IMPOSSIBLE_IN_SCOPE",
|
|
51
|
+
"HANDED_OVER", "TERMINAL",
|
|
52
|
+
"CLAIM_DONE", "OPEN_UNRELATED_PROMISE", "SILENT_HANDOFF",
|
|
53
|
+
"CapabilityProxy", "Grant", "Refused",
|
|
54
|
+
"ManifestAdapter", "CommandAdapter", "OwnerAcceptanceAdapter", "sha256_file",
|
|
55
|
+
"Settler", "Settlement",
|
|
56
|
+
"SpeechGate", "Held",
|
|
57
|
+
"Server", "GateService", "PathOutsideRoot", "tool_specs",
|
|
58
|
+
"__version__", "__spec_version__",
|
|
59
|
+
]
|