probity-effects 0.2.0__tar.gz → 0.2.2__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.
- {probity_effects-0.2.0 → probity_effects-0.2.2}/PKG-INFO +8 -6
- {probity_effects-0.2.0 → probity_effects-0.2.2}/README.md +6 -4
- {probity_effects-0.2.0 → probity_effects-0.2.2}/pyproject.toml +3 -3
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects/guard.py +29 -13
- probity_effects-0.2.2/src/probity_effects/identifiers.py +56 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects/journal.py +24 -7
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects/record.py +3 -1
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects.egg-info/PKG-INFO +8 -6
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects.egg-info/SOURCES.txt +2 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects.egg-info/requires.txt +1 -1
- {probity_effects-0.2.0 → probity_effects-0.2.2}/tests/test_ag2.py +35 -13
- probity_effects-0.2.2/tests/test_effects_identifiers_copy.py +24 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/tests/test_guard.py +63 -5
- {probity_effects-0.2.0 → probity_effects-0.2.2}/tests/test_openai_agents.py +35 -13
- {probity_effects-0.2.0 → probity_effects-0.2.2}/tests/test_scenarios.py +16 -3
- {probity_effects-0.2.0 → probity_effects-0.2.2}/LICENSE +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/setup.cfg +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects/__init__.py +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects/_tool.py +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects/ag2.py +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects/langgraph.py +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects/openai_agents.py +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects/owner.py +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects/pytest_plugin.py +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects/testing.py +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects.egg-info/dependency_links.txt +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects.egg-info/entry_points.txt +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects.egg-info/top_level.txt +0 -0
- {probity_effects-0.2.0 → probity_effects-0.2.2}/tests/test_readme.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: probity-effects
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Keep one effect per agent tool call when its reply is lost: reconcile before resend, record the trail, test it in CI
|
|
5
5
|
Author: Sankalp Gilda
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -22,7 +22,7 @@ License-File: LICENSE
|
|
|
22
22
|
Requires-Dist: jcs-admit~=0.1.1
|
|
23
23
|
Provides-Extra: testing
|
|
24
24
|
Requires-Dist: pytest<10,>=8; extra == "testing"
|
|
25
|
-
Requires-Dist: agent-evidence-vectors
|
|
25
|
+
Requires-Dist: agent-evidence-vectors<1,>=0.32.1; extra == "testing"
|
|
26
26
|
Dynamic: license-file
|
|
27
27
|
|
|
28
28
|
# probity-effects
|
|
@@ -31,12 +31,12 @@ Dynamic: license-file
|
|
|
31
31
|
|
|
32
32
|
Keep one effect per agent tool call when its reply is lost: the guard asks the service that owns
|
|
33
33
|
the effect before anything is sent again, records each operation as an `uncertain-effect/v1`
|
|
34
|
-
record, and tests your tools against
|
|
34
|
+
record, and tests your tools against the lost-reply scenarios agent-evidence-vectors ships, in CI.
|
|
35
35
|
|
|
36
36
|
It's for teams whose LangGraph, OpenAI Agents SDK or AG2 agents create orders, move money or open
|
|
37
37
|
tickets, and who cannot afford a retry policy, a resumed thread or a model calling again to repeat the write.
|
|
38
38
|
|
|
39
|
-
Install the released package: `pip install probity-effects
|
|
39
|
+
Install the released package: `pip install probity-effects`.
|
|
40
40
|
|
|
41
41
|
## Quick start
|
|
42
42
|
|
|
@@ -148,9 +148,11 @@ Agents SDK use `OPENAI_AGENTS_VARIANTS` and `run_openai_agents_scenario`, and fo
|
|
|
148
148
|
|
|
149
149
|
## Status
|
|
150
150
|
|
|
151
|
-
Version 0.2.
|
|
151
|
+
Version 0.2.2, alpha, with adapters for LangGraph, the OpenAI Agents SDK and AG2. Version 0.1.0 told a
|
|
152
152
|
second caller with the same arguments that a write was committed when it was never sent, if the
|
|
153
|
-
tool had no thread and no `key_from`; 0.2.0 refuses such a call, so upgrade.
|
|
153
|
+
tool had no thread and no `key_from`; 0.2.0 refuses such a call, so upgrade. Before 0.2.1, an event appended after a
|
|
154
|
+
stop mid-write was glued onto the torn line and could be lost or leave the file journal unreadable; 0.2.1 cuts the
|
|
155
|
+
torn line first. Version 0.2.2 widens the `agent-evidence-vectors` requirement of the `testing` extra from `~=0.32.1` to `>=0.32.1,<1`, so the extra installs beside the current vectors release. It also asks a deduplicating owner before sending a key again: an owner that has forgotten the key and cannot say finally whether it holds the effect is no longer sent it twice, and the outcome is unknown.
|
|
154
156
|
|
|
155
157
|
## Documentation
|
|
156
158
|
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
Keep one effect per agent tool call when its reply is lost: the guard asks the service that owns
|
|
6
6
|
the effect before anything is sent again, records each operation as an `uncertain-effect/v1`
|
|
7
|
-
record, and tests your tools against
|
|
7
|
+
record, and tests your tools against the lost-reply scenarios agent-evidence-vectors ships, in CI.
|
|
8
8
|
|
|
9
9
|
It's for teams whose LangGraph, OpenAI Agents SDK or AG2 agents create orders, move money or open
|
|
10
10
|
tickets, and who cannot afford a retry policy, a resumed thread or a model calling again to repeat the write.
|
|
11
11
|
|
|
12
|
-
Install the released package: `pip install probity-effects
|
|
12
|
+
Install the released package: `pip install probity-effects`.
|
|
13
13
|
|
|
14
14
|
## Quick start
|
|
15
15
|
|
|
@@ -121,9 +121,11 @@ Agents SDK use `OPENAI_AGENTS_VARIANTS` and `run_openai_agents_scenario`, and fo
|
|
|
121
121
|
|
|
122
122
|
## Status
|
|
123
123
|
|
|
124
|
-
Version 0.2.
|
|
124
|
+
Version 0.2.2, alpha, with adapters for LangGraph, the OpenAI Agents SDK and AG2. Version 0.1.0 told a
|
|
125
125
|
second caller with the same arguments that a write was committed when it was never sent, if the
|
|
126
|
-
tool had no thread and no `key_from`; 0.2.0 refuses such a call, so upgrade.
|
|
126
|
+
tool had no thread and no `key_from`; 0.2.0 refuses such a call, so upgrade. Before 0.2.1, an event appended after a
|
|
127
|
+
stop mid-write was glued onto the torn line and could be lost or leave the file journal unreadable; 0.2.1 cuts the
|
|
128
|
+
torn line first. Version 0.2.2 widens the `agent-evidence-vectors` requirement of the `testing` extra from `~=0.32.1` to `>=0.32.1,<1`, so the extra installs beside the current vectors release. It also asks a deduplicating owner before sending a key again: an owner that has forgotten the key and cannot say finally whether it holds the effect is no longer sent it twice, and the outcome is unknown.
|
|
127
129
|
|
|
128
130
|
## Documentation
|
|
129
131
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "probity-effects"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.2"
|
|
8
8
|
description = "Keep one effect per agent tool call when its reply is lost: reconcile before resend, record the trail, test it in CI"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -31,7 +31,7 @@ Issues = "https://github.com/probityai/probity/issues"
|
|
|
31
31
|
|
|
32
32
|
[project.optional-dependencies]
|
|
33
33
|
# What a user installs to run the lost-reply scenarios against their own tools.
|
|
34
|
-
testing = ["pytest>=8,<10", "agent-evidence-vectors
|
|
34
|
+
testing = ["pytest>=8,<10", "agent-evidence-vectors>=0.32.1,<1"]
|
|
35
35
|
|
|
36
36
|
[project.entry-points.pytest11]
|
|
37
37
|
probity_effects = "probity_effects.pytest_plugin"
|
|
@@ -42,7 +42,7 @@ probity_effects = "probity_effects.pytest_plugin"
|
|
|
42
42
|
# This member's own tests: the frameworks the adapters drive, pinned to the versions measured.
|
|
43
43
|
dev = [
|
|
44
44
|
"pytest>=9.2.0,<10",
|
|
45
|
-
"agent-evidence-vectors
|
|
45
|
+
"agent-evidence-vectors>=0.32.1,<1",
|
|
46
46
|
"langgraph==1.2.19",
|
|
47
47
|
"openai-agents==0.24.0",
|
|
48
48
|
"ag2==1.2.2",
|
|
@@ -44,6 +44,9 @@ class EffectOutcomeUnknown(RuntimeError):
|
|
|
44
44
|
self.outcome = outcome
|
|
45
45
|
|
|
46
46
|
|
|
47
|
+
# What the owner's lookups settled about one key.
|
|
48
|
+
PRESENT, ABSENT, OPEN = "present", "absent", "open"
|
|
49
|
+
|
|
47
50
|
# What the policy asks its driver to do.
|
|
48
51
|
Request = tuple[str, Any]
|
|
49
52
|
Plan = Generator[Request, Any, Outcome]
|
|
@@ -170,9 +173,9 @@ class EffectGuard:
|
|
|
170
173
|
if history.committed:
|
|
171
174
|
return self._report(key, "committed", "the owner already holds this effect, so it was not sent again")
|
|
172
175
|
pending = history.unresolved()
|
|
173
|
-
if pending is not None
|
|
176
|
+
if pending is not None:
|
|
174
177
|
answer = yield from self._settle(key)
|
|
175
|
-
if answer
|
|
178
|
+
if not self._may_resend(answer, pending):
|
|
176
179
|
return self._settled(key, answer, "an earlier reply was lost")
|
|
177
180
|
sent = 0
|
|
178
181
|
while True:
|
|
@@ -199,10 +202,8 @@ class EffectGuard:
|
|
|
199
202
|
if reply is Reply.NO_EFFECT:
|
|
200
203
|
return self._report(key, "not_run", f"the owner answered that the effect did not happen ({error})",
|
|
201
204
|
sent=sent, error=error)
|
|
202
|
-
if self._deduplicated(journal.history(key).unresolved()):
|
|
203
|
-
continue
|
|
204
205
|
answer = yield from self._settle(key)
|
|
205
|
-
if answer
|
|
206
|
+
if not self._may_resend(answer, journal.history(key).unresolved()):
|
|
206
207
|
return self._settled(key, answer, "the reply was lost", sent=sent, error=error)
|
|
207
208
|
|
|
208
209
|
def _lease_lost(self, key: str, history: Any, sent: int) -> Plan:
|
|
@@ -210,12 +211,17 @@ class EffectGuard:
|
|
|
210
211
|
return self._report(key, history.settled(), "this worker no longer holds the lease, so nothing was sent",
|
|
211
212
|
sent=sent)
|
|
212
213
|
answer = yield from self._settle(key)
|
|
213
|
-
if answer
|
|
214
|
+
if answer == ABSENT:
|
|
214
215
|
return self._report(key, "not_run", "the lease moved and the owner holds no effect", sent=sent)
|
|
215
216
|
return self._settled(key, answer, "the lease moved after a lost reply", sent=sent)
|
|
216
217
|
|
|
217
|
-
def _settle(self, key: str) -> Generator[Request, Any,
|
|
218
|
-
"""Ask the owner until it answers finally
|
|
218
|
+
def _settle(self, key: str) -> Generator[Request, Any, str | None]:
|
|
219
|
+
"""Ask the owner until it answers finally.
|
|
220
|
+
|
|
221
|
+
Returns PRESENT, ABSENT (final), OPEN (the owner answered, but only that it does not hold the key now,
|
|
222
|
+
without saying so finally) or None (the owner gave no answer at all).
|
|
223
|
+
"""
|
|
224
|
+
seen: str | None = None
|
|
219
225
|
for number in range(self.owner.lookups):
|
|
220
226
|
if number:
|
|
221
227
|
yield ("sleep", self.owner.lookup_interval)
|
|
@@ -227,10 +233,20 @@ class EffectGuard:
|
|
|
227
233
|
self.journal.append({"event": "lookup", "key": key, "answered": True,
|
|
228
234
|
"result": "present" if answer.present else "absent", "final": final})
|
|
229
235
|
if answer.present:
|
|
230
|
-
return
|
|
236
|
+
return PRESENT
|
|
231
237
|
if final:
|
|
232
|
-
return
|
|
233
|
-
|
|
238
|
+
return ABSENT
|
|
239
|
+
seen = OPEN
|
|
240
|
+
return seen
|
|
241
|
+
|
|
242
|
+
def _may_resend(self, answer: str | None, pending: Attempt | None) -> bool:
|
|
243
|
+
"""Whether the owner's answers permit sending the same key again.
|
|
244
|
+
|
|
245
|
+
A final absent does. Deduplication does only when the owner gave no answer at all: an owner that
|
|
246
|
+
answers it does not hold the key now, without saying so finally, may have forgotten the key, and a
|
|
247
|
+
second send would then be applied again.
|
|
248
|
+
"""
|
|
249
|
+
return answer == ABSENT or (answer is None and self._deduplicated(pending))
|
|
234
250
|
|
|
235
251
|
def _deduplicated(self, pending: Attempt | None) -> bool:
|
|
236
252
|
"""Whether the owner's deduplication covers sending the same key again now."""
|
|
@@ -242,8 +258,8 @@ class EffectGuard:
|
|
|
242
258
|
age = (datetime.now(UTC) - parse(pending.dispatched_at)).total_seconds()
|
|
243
259
|
return age <= owner.key_retention_seconds
|
|
244
260
|
|
|
245
|
-
def _settled(self, key: str, answer:
|
|
246
|
-
if answer
|
|
261
|
+
def _settled(self, key: str, answer: str | None, why: str, *, sent: int = 0, error: str | None = None) -> Outcome:
|
|
262
|
+
if answer == PRESENT:
|
|
247
263
|
return self._report(key, "committed", f"{why}, and the owner holds the effect", sent=sent, error=error)
|
|
248
264
|
return self._report(key, "unknown", f"{why}, and the owner could not confirm what it holds",
|
|
249
265
|
sent=sent, error=error)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""The host every identifier we publish is written under, and the hosts read as ours.
|
|
2
|
+
|
|
3
|
+
An identifier here is a URI we define and a record carries: a ``predicateType``, a ``contractId``,
|
|
4
|
+
a ``claim_type``, a schema or verifier id, a registry key. Each is written as
|
|
5
|
+
``https://<IDENTIFIER_HOST>/<path>`` and built with :func:`identifier`, so moving the host is a
|
|
6
|
+
change to one line.
|
|
7
|
+
|
|
8
|
+
A signed record cannot be edited without breaking its signature, so every record already issued
|
|
9
|
+
keeps the identifiers it was signed with, under ``https://probityai.github.io/``, forever. From the
|
|
10
|
+
release that changes ``IDENTIFIER_HOST``, new records carry ``https://probityai.org/``. Both hosts
|
|
11
|
+
are ours: GitHub serves the old one for the probityai organisation and forwards every path on it
|
|
12
|
+
to the same path on the new one, which is verified for that organisation. So the two spellings
|
|
13
|
+
name one type, and a verifier that accepted only one would reject either every record already
|
|
14
|
+
issued or every record issued from then on. Accepting both widens nothing an attacker controls:
|
|
15
|
+
an identifier is a label, not a credential, and trust comes from the signature and the key, which
|
|
16
|
+
this module does not touch. The match is byte-exact on the scheme and the host; no other spelling
|
|
17
|
+
is recognised.
|
|
18
|
+
|
|
19
|
+
So a reader compares ``canonical_identifier(<value from the record>)`` with its constant, or calls
|
|
20
|
+
:func:`same_identifier`, and reports the record's own bytes. Signed bytes are never rewritten: a
|
|
21
|
+
DSSE pre-authentication encoding is computed over the payload as received.
|
|
22
|
+
|
|
23
|
+
This file has no imports and is copied byte for byte into the packages that do not depend on
|
|
24
|
+
agent-evidence-verify; each copy has a test that it equals this file.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
IDENTIFIER_HOST = "probityai.github.io"
|
|
28
|
+
RECOGNISED_HOSTS = ("probityai.github.io", "probityai.org")
|
|
29
|
+
|
|
30
|
+
_WRITTEN = "https://" + IDENTIFIER_HOST + "/"
|
|
31
|
+
_READ = tuple("https://" + host + "/" for host in RECOGNISED_HOSTS)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def identifier(path: str) -> str:
|
|
35
|
+
"""``https://<IDENTIFIER_HOST>/<path>``: the identifier this release writes for ``path``."""
|
|
36
|
+
return _WRITTEN + path
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def canonical_identifier(value):
|
|
40
|
+
"""``value`` with a recognised host replaced by ``IDENTIFIER_HOST``; anything else unchanged.
|
|
41
|
+
|
|
42
|
+
Only a string that starts with exactly ``https://<host>/`` for a host in ``RECOGNISED_HOSTS``
|
|
43
|
+
is rewritten, and only that prefix. ``http://``, ``www.``, a port, a trailing dot, upper case,
|
|
44
|
+
userinfo and every longer host keep their bytes, so they fail every comparison they fail
|
|
45
|
+
today. A value that is not a string is returned as it is.
|
|
46
|
+
"""
|
|
47
|
+
if isinstance(value, str):
|
|
48
|
+
for prefix in _READ:
|
|
49
|
+
if value.startswith(prefix):
|
|
50
|
+
return _WRITTEN + value[len(prefix):]
|
|
51
|
+
return value
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def same_identifier(a, b) -> bool:
|
|
55
|
+
"""Whether ``a`` and ``b`` name the same identifier under the recognised hosts."""
|
|
56
|
+
return canonical_identifier(a) == canonical_identifier(b)
|
|
@@ -62,6 +62,17 @@ class History:
|
|
|
62
62
|
return "unknown" if self.unresolved() is not None else "not_run"
|
|
63
63
|
|
|
64
64
|
|
|
65
|
+
def _cut_torn_tail(fd: int) -> None:
|
|
66
|
+
"""Cut a torn last line (no newline) left by a stop mid-write, durably, before the next line is appended:
|
|
67
|
+
written after it, the next event would be glued onto it and the journal could no longer be read."""
|
|
68
|
+
size = os.fstat(fd).st_size
|
|
69
|
+
if size == 0 or os.pread(fd, 1, size - 1) == b"\n":
|
|
70
|
+
return
|
|
71
|
+
end = os.pread(fd, size, 0).rfind(b"\n") + 1
|
|
72
|
+
os.ftruncate(fd, end)
|
|
73
|
+
os.fsync(fd)
|
|
74
|
+
|
|
75
|
+
|
|
65
76
|
class Journal:
|
|
66
77
|
"""Append-only events per idempotency key, in memory or in a JSON-lines file.
|
|
67
78
|
|
|
@@ -88,15 +99,17 @@ class Journal:
|
|
|
88
99
|
return self._path
|
|
89
100
|
|
|
90
101
|
def _load(self, path: Path) -> None:
|
|
91
|
-
lines
|
|
102
|
+
# Only whole lines are events: bytes after the last newline are a write a stop cut short, and the guard
|
|
103
|
+
# acts on an event only after its line is written, so nothing acted on them. A whole line that is not an
|
|
104
|
+
# event is a damaged journal and is refused.
|
|
105
|
+
data = path.read_bytes()
|
|
106
|
+
lines = data[: data.rfind(b"\n") + 1].decode("utf-8").split("\n")[:-1]
|
|
92
107
|
for number, line in enumerate(lines, start=1):
|
|
93
108
|
if not line.strip():
|
|
94
109
|
continue
|
|
95
110
|
try:
|
|
96
111
|
event = json.loads(line)
|
|
97
112
|
except ValueError:
|
|
98
|
-
if number == len(lines):
|
|
99
|
-
break # a line torn by a stop mid-write; nothing after it was acted on
|
|
100
113
|
raise ValueError(f"{path}:{number}: not a journal event") from None
|
|
101
114
|
self._events.append(event)
|
|
102
115
|
self.clock.advance_to(parse(event["at"]))
|
|
@@ -105,11 +118,15 @@ class Journal:
|
|
|
105
118
|
with self._lock:
|
|
106
119
|
entry = {**event, "at": stamp(self.clock.now())}
|
|
107
120
|
if self._path is not None:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
121
|
+
line = (json.dumps(entry, sort_keys=True, separators=(",", ":")) + "\n").encode("utf-8")
|
|
122
|
+
fd = os.open(self._path, os.O_RDWR | os.O_APPEND | os.O_CREAT, 0o644)
|
|
123
|
+
try:
|
|
124
|
+
_cut_torn_tail(fd)
|
|
125
|
+
os.write(fd, line)
|
|
111
126
|
if self._fsync:
|
|
112
|
-
os.fsync(
|
|
127
|
+
os.fsync(fd)
|
|
128
|
+
finally:
|
|
129
|
+
os.close(fd)
|
|
113
130
|
self._events.append(entry)
|
|
114
131
|
return entry
|
|
115
132
|
|
|
@@ -13,8 +13,10 @@ from typing import Any
|
|
|
13
13
|
|
|
14
14
|
import jcs_admit
|
|
15
15
|
|
|
16
|
+
from probity_effects.identifiers import identifier
|
|
17
|
+
|
|
16
18
|
#: The contract a record names, and the predicate type a producer writes when it signs one.
|
|
17
|
-
CONTRACT_ID = "
|
|
19
|
+
CONTRACT_ID = identifier("agent-evidence-vectors/predicate/v1/uncertain-effect")
|
|
18
20
|
OUTCOMES = ("committed", "not_run", "unknown")
|
|
19
21
|
|
|
20
22
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: probity-effects
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Keep one effect per agent tool call when its reply is lost: reconcile before resend, record the trail, test it in CI
|
|
5
5
|
Author: Sankalp Gilda
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -22,7 +22,7 @@ License-File: LICENSE
|
|
|
22
22
|
Requires-Dist: jcs-admit~=0.1.1
|
|
23
23
|
Provides-Extra: testing
|
|
24
24
|
Requires-Dist: pytest<10,>=8; extra == "testing"
|
|
25
|
-
Requires-Dist: agent-evidence-vectors
|
|
25
|
+
Requires-Dist: agent-evidence-vectors<1,>=0.32.1; extra == "testing"
|
|
26
26
|
Dynamic: license-file
|
|
27
27
|
|
|
28
28
|
# probity-effects
|
|
@@ -31,12 +31,12 @@ Dynamic: license-file
|
|
|
31
31
|
|
|
32
32
|
Keep one effect per agent tool call when its reply is lost: the guard asks the service that owns
|
|
33
33
|
the effect before anything is sent again, records each operation as an `uncertain-effect/v1`
|
|
34
|
-
record, and tests your tools against
|
|
34
|
+
record, and tests your tools against the lost-reply scenarios agent-evidence-vectors ships, in CI.
|
|
35
35
|
|
|
36
36
|
It's for teams whose LangGraph, OpenAI Agents SDK or AG2 agents create orders, move money or open
|
|
37
37
|
tickets, and who cannot afford a retry policy, a resumed thread or a model calling again to repeat the write.
|
|
38
38
|
|
|
39
|
-
Install the released package: `pip install probity-effects
|
|
39
|
+
Install the released package: `pip install probity-effects`.
|
|
40
40
|
|
|
41
41
|
## Quick start
|
|
42
42
|
|
|
@@ -148,9 +148,11 @@ Agents SDK use `OPENAI_AGENTS_VARIANTS` and `run_openai_agents_scenario`, and fo
|
|
|
148
148
|
|
|
149
149
|
## Status
|
|
150
150
|
|
|
151
|
-
Version 0.2.
|
|
151
|
+
Version 0.2.2, alpha, with adapters for LangGraph, the OpenAI Agents SDK and AG2. Version 0.1.0 told a
|
|
152
152
|
second caller with the same arguments that a write was committed when it was never sent, if the
|
|
153
|
-
tool had no thread and no `key_from`; 0.2.0 refuses such a call, so upgrade.
|
|
153
|
+
tool had no thread and no `key_from`; 0.2.0 refuses such a call, so upgrade. Before 0.2.1, an event appended after a
|
|
154
|
+
stop mid-write was glued onto the torn line and could be lost or leave the file journal unreadable; 0.2.1 cuts the
|
|
155
|
+
torn line first. Version 0.2.2 widens the `agent-evidence-vectors` requirement of the `testing` extra from `~=0.32.1` to `>=0.32.1,<1`, so the extra installs beside the current vectors release. It also asks a deduplicating owner before sending a key again: an owner that has forgotten the key and cannot say finally whether it holds the effect is no longer sent it twice, and the outcome is unknown.
|
|
154
156
|
|
|
155
157
|
## Documentation
|
|
156
158
|
|
|
@@ -5,6 +5,7 @@ src/probity_effects/__init__.py
|
|
|
5
5
|
src/probity_effects/_tool.py
|
|
6
6
|
src/probity_effects/ag2.py
|
|
7
7
|
src/probity_effects/guard.py
|
|
8
|
+
src/probity_effects/identifiers.py
|
|
8
9
|
src/probity_effects/journal.py
|
|
9
10
|
src/probity_effects/langgraph.py
|
|
10
11
|
src/probity_effects/openai_agents.py
|
|
@@ -19,6 +20,7 @@ src/probity_effects.egg-info/entry_points.txt
|
|
|
19
20
|
src/probity_effects.egg-info/requires.txt
|
|
20
21
|
src/probity_effects.egg-info/top_level.txt
|
|
21
22
|
tests/test_ag2.py
|
|
23
|
+
tests/test_effects_identifiers_copy.py
|
|
22
24
|
tests/test_guard.py
|
|
23
25
|
tests/test_openai_agents.py
|
|
24
26
|
tests/test_readme.py
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""The AG2 adapter: the
|
|
1
|
+
"""The AG2 adapter: the shipped scenarios on each AG2 path, with a plain tool as the control."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
@@ -70,31 +70,53 @@ def plain_tools(run):
|
|
|
70
70
|
return [create_order]
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
def plain_runs(variant: str) -> tuple[dict[str, int],
|
|
73
|
+
def plain_runs(variant: str) -> tuple[dict[str, int], set[str]]:
|
|
74
74
|
"""Effects per scenario, and the scenarios passed when a run ending in an error reports nothing happened."""
|
|
75
|
-
counts,
|
|
75
|
+
counts: dict[str, int] = {}
|
|
76
|
+
passed: set[str] = set()
|
|
76
77
|
for scenario in lost_reply_scenarios():
|
|
77
78
|
with scenario_owner(scenario) as run:
|
|
78
79
|
error = drive_ag2(lambda owner, journal: plain_tools(run), run, None, variant=variant)
|
|
79
80
|
counts[scenario["id"]] = run.state.effects
|
|
80
|
-
|
|
81
|
+
if not uncertaineffect_runtime.judge(scenario, run.state, "not_run" if error else "committed"):
|
|
82
|
+
passed.add(scenario["id"])
|
|
81
83
|
return counts, passed
|
|
82
84
|
|
|
83
85
|
|
|
86
|
+
# What the plain tool does in each scenario these tables name, and which of them it passes. A scenario a later
|
|
87
|
+
# corpus adds is driven and judged too, and stays out of these pins until it is named here.
|
|
84
88
|
PLAIN_ONE_ASK = {"confirmed": 1, "commit-then-lost-reply": 1, "commit-then-lost-reply-deduplicating": 1,
|
|
85
89
|
"owner-unreachable-after-lost-reply": 1, "lost-before-commit": 0,
|
|
86
|
-
"late-commit-after-missed-lookup": 0, "definite-no-effect": 0, "lease-lost-after-lost-reply": 1
|
|
90
|
+
"late-commit-after-missed-lookup": 0, "definite-no-effect": 0, "lease-lost-after-lost-reply": 1,
|
|
91
|
+
"crash-mid-step-checkpoint-kept": 1, "crash-mid-step-checkpoint-lost": 1,
|
|
92
|
+
"redelivery-new-task-id": 1, "rewind-replay-after-confirmed": 1, "duplicate-human-completion": 1,
|
|
93
|
+
"key-forgotten-by-owner-then-replay": 1}
|
|
87
94
|
PLAIN_CALLED_AGAIN = {"confirmed": 1, "commit-then-lost-reply": 2, "commit-then-lost-reply-deduplicating": 1,
|
|
88
95
|
"owner-unreachable-after-lost-reply": 2, "lost-before-commit": 1,
|
|
89
96
|
"late-commit-after-missed-lookup": 2, "definite-no-effect": 1,
|
|
90
|
-
"lease-lost-after-lost-reply": 2
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
"lease-lost-after-lost-reply": 2, "crash-mid-step-checkpoint-kept": 2,
|
|
98
|
+
"crash-mid-step-checkpoint-lost": 1, "redelivery-new-task-id": 1,
|
|
99
|
+
"rewind-replay-after-confirmed": 1, "duplicate-human-completion": 1,
|
|
100
|
+
"key-forgotten-by-owner-then-replay": 1}
|
|
101
|
+
# A committed write whose reply arrives passes; so does nothing sent, where nothing is acceptable.
|
|
102
|
+
PASSES_ONE = {"confirmed", "lost-before-commit", "definite-no-effect", "rewind-replay-after-confirmed",
|
|
103
|
+
"duplicate-human-completion", "key-forgotten-by-owner-then-replay"}
|
|
104
|
+
# Called again, the second send lands on a deduplicating owner, on an owner with nothing yet, or after a confirm.
|
|
105
|
+
PASSES_AGAIN = {"confirmed", "commit-then-lost-reply-deduplicating", "lost-before-commit", "definite-no-effect",
|
|
106
|
+
"crash-mid-step-checkpoint-lost", "redelivery-new-task-id", "rewind-replay-after-confirmed",
|
|
107
|
+
"duplicate-human-completion", "key-forgotten-by-owner-then-replay"}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@pytest.mark.parametrize(("variant", "effects", "passes"), [("default", PLAIN_ONE_ASK, PASSES_ONE),
|
|
111
|
+
("reask", PLAIN_CALLED_AGAIN, PASSES_AGAIN),
|
|
112
|
+
("model-retry", PLAIN_CALLED_AGAIN, PASSES_AGAIN)])
|
|
113
|
+
def test_control_plain_tool(variant, effects, passes):
|
|
114
|
+
counts, passed = plain_runs(variant)
|
|
115
|
+
assert set(effects) <= set(counts), "a scenario these pins name is no longer shipped"
|
|
116
|
+
assert {name: counts[name] for name in effects} == effects
|
|
117
|
+
assert passed & set(effects) == passes
|
|
118
|
+
# The control fails somewhere the guarded tool passes, or it shows nothing.
|
|
119
|
+
assert passed != set(counts)
|
|
98
120
|
|
|
99
121
|
|
|
100
122
|
class Orders:
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""This package's copy of the identifier host rule is the agent-evidence-verify module, byte for byte.
|
|
2
|
+
|
|
3
|
+
The package does not depend on agent-evidence-verify at a release that carries the module, so it
|
|
4
|
+
ships its own copy; this test keeps the two from drifting apart.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import probity_effects.identifiers as copy
|
|
10
|
+
|
|
11
|
+
SOURCE = (Path(__file__).resolve().parents[2]
|
|
12
|
+
/ "agent-evidence-verify" / "src" / "agent_evidence_verify" / "identifiers.py")
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_the_copy_is_the_source_file():
|
|
16
|
+
assert Path(copy.__file__).read_bytes() == SOURCE.read_bytes()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def test_the_copy_recognises_both_hosts():
|
|
20
|
+
old = "https://probityai.github.io/agent-evidence-vectors/predicate/v1/uncertain-effect"
|
|
21
|
+
new = "https://probityai.org/agent-evidence-vectors/predicate/v1/uncertain-effect"
|
|
22
|
+
assert copy.canonical_identifier(new) == old
|
|
23
|
+
assert copy.same_identifier(old, new)
|
|
24
|
+
assert not copy.same_identifier("http://probityai.org/agent-evidence-vectors/predicate/v1/uncertain-effect", old)
|
|
@@ -28,20 +28,24 @@ ARGS = {"quantity": 1, "sku": "A-1"}
|
|
|
28
28
|
class Owner:
|
|
29
29
|
"""Holds effects by key; each send behaves as the next scripted step."""
|
|
30
30
|
|
|
31
|
-
def __init__(self, steps=(), *, answers=None, dedup=False, token=None):
|
|
31
|
+
def __init__(self, steps=(), *, answers=None, dedup=False, forgets=False, token=None):
|
|
32
32
|
self.steps = list(steps)
|
|
33
33
|
self.answers = answers # None: answer from the ledger, finally
|
|
34
34
|
self.effects: dict[str, int] = {}
|
|
35
|
+
self.remembered: set[str] = set() # the keys a deduplicating owner still holds
|
|
35
36
|
self.sends = 0
|
|
36
37
|
self.lookups = 0
|
|
37
38
|
self.dedup = dedup
|
|
39
|
+
self.forgets = forgets # forget each key once its effect is applied, as an expired retention window does
|
|
38
40
|
self.token = token
|
|
39
41
|
|
|
40
42
|
def send(self, call):
|
|
41
43
|
self.sends += 1
|
|
42
44
|
step = self.steps.pop(0) if self.steps else "commit"
|
|
43
|
-
if step in ("commit", "commit_lost") and not (self.dedup and call.key in self.
|
|
45
|
+
if step in ("commit", "commit_lost") and not (self.dedup and call.key in self.remembered):
|
|
44
46
|
self.effects[call.key] = self.effects.get(call.key, 0) + 1
|
|
47
|
+
if not self.forgets:
|
|
48
|
+
self.remembered.add(call.key)
|
|
45
49
|
if step == "commit":
|
|
46
50
|
return {"order": call.key}
|
|
47
51
|
if step == "refuse":
|
|
@@ -94,10 +98,41 @@ def test_lookup_that_is_not_final_settles_nothing():
|
|
|
94
98
|
assert (outcome.outcome, owner.sends, owner.lookups) == ("unknown", 1, 5)
|
|
95
99
|
|
|
96
100
|
|
|
97
|
-
def
|
|
98
|
-
owner = Owner(["commit_lost"
|
|
101
|
+
def test_deduplicating_owner_is_asked_before_the_same_key_is_sent_again():
|
|
102
|
+
owner = Owner(["commit_lost"], dedup=True)
|
|
99
103
|
outcome = EffectGuard(owner.port()).perform("create_order", ARGS, send=owner.send)
|
|
100
|
-
assert (outcome.outcome, owner.sends, owner.lookups, sum(owner.effects.values())) == ("committed",
|
|
104
|
+
assert (outcome.outcome, owner.sends, owner.lookups, sum(owner.effects.values())) == ("committed", 1, 1, 1)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def test_deduplicating_owner_that_cannot_answer_gets_the_same_key_again():
|
|
108
|
+
owner = Owner(["commit_lost", "commit"], answers=[], dedup=True)
|
|
109
|
+
outcome = EffectGuard(owner.port()).perform("create_order", ARGS, send=owner.send)
|
|
110
|
+
assert (outcome.outcome, owner.sends, owner.lookups, sum(owner.effects.values())) == ("committed", 2, 5, 1)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def test_deduplicating_owner_that_forgot_the_key_is_not_sent_it_again():
|
|
114
|
+
owner = Owner(["commit_lost"], answers=[Lookup(False, final=False)] * 5, dedup=True, forgets=True)
|
|
115
|
+
outcome = EffectGuard(owner.port()).perform("create_order", ARGS, send=owner.send)
|
|
116
|
+
assert (outcome.outcome, owner.sends, owner.lookups, sum(owner.effects.values())) == ("unknown", 1, 5, 1)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def test_a_replay_after_the_owner_forgot_the_key_is_not_sent_again(tmp_path):
|
|
120
|
+
# The confirmed reply is lost with the process; the owner has since forgotten the key and cannot say
|
|
121
|
+
# finally whether it holds the effect, so its deduplication no longer covers a second send.
|
|
122
|
+
owner = Owner(["commit"], answers=[Lookup(False, final=False)] * 5, dedup=True, forgets=True)
|
|
123
|
+
path = tmp_path / "journal.jsonl"
|
|
124
|
+
|
|
125
|
+
class Stop(BaseException):
|
|
126
|
+
pass
|
|
127
|
+
|
|
128
|
+
def stopping_send(call):
|
|
129
|
+
owner.send(call)
|
|
130
|
+
raise Stop()
|
|
131
|
+
|
|
132
|
+
with pytest.raises(Stop):
|
|
133
|
+
EffectGuard(owner.port(), Journal.open(path)).perform("create_order", ARGS, send=stopping_send)
|
|
134
|
+
outcome = EffectGuard(owner.port(), Journal.open(path)).perform("create_order", ARGS, send=owner.send)
|
|
135
|
+
assert (outcome.outcome, outcome.sent, owner.sends, sum(owner.effects.values())) == ("unknown", 0, 1, 1)
|
|
101
136
|
|
|
102
137
|
|
|
103
138
|
def test_definite_no_effect_is_not_run():
|
|
@@ -160,6 +195,29 @@ def test_torn_last_line_is_ignored_and_earlier_lines_are_kept(tmp_path):
|
|
|
160
195
|
assert len(Journal.open(path).keys()) == 1
|
|
161
196
|
|
|
162
197
|
|
|
198
|
+
@pytest.mark.parametrize("torn", ['{"event": "dis', '{"event":"note","at":"2026-01-01T00:00:00Z","key":"x"}'])
|
|
199
|
+
def test_the_next_append_cuts_a_torn_last_line_so_the_journal_stays_readable(tmp_path, torn):
|
|
200
|
+
path = tmp_path / "journal.jsonl"
|
|
201
|
+
owner = Owner(["commit", "commit"])
|
|
202
|
+
EffectGuard(owner.port(), Journal.open(path)).perform("create_order", ARGS, send=owner.send)
|
|
203
|
+
events = len(Journal.open(path).events())
|
|
204
|
+
path.write_text(path.read_text() + torn, encoding="utf-8") # a stop mid-write: no newline, never acted on
|
|
205
|
+
assert len(Journal.open(path).events()) == events
|
|
206
|
+
EffectGuard(owner.port(), Journal.open(path)).perform("create_order", {**ARGS, "n": 2}, send=owner.send)
|
|
207
|
+
lines = path.read_bytes().split(b"\n")
|
|
208
|
+
assert lines[-1] == b"" and torn.encode() not in path.read_bytes()
|
|
209
|
+
assert len(Journal.open(path).keys()) == 2
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def test_a_whole_line_that_is_not_an_event_is_refused_not_skipped(tmp_path):
|
|
213
|
+
path = tmp_path / "journal.jsonl"
|
|
214
|
+
owner = Owner(["commit"])
|
|
215
|
+
EffectGuard(owner.port(), Journal.open(path)).perform("create_order", ARGS, send=owner.send)
|
|
216
|
+
path.write_text(path.read_text() + '{"event": "dis{"event":"dispatch"}\n', encoding="utf-8")
|
|
217
|
+
with pytest.raises(ValueError, match="not a journal event"):
|
|
218
|
+
Journal.open(path)
|
|
219
|
+
|
|
220
|
+
|
|
163
221
|
def test_record_is_the_uncertain_effect_contract():
|
|
164
222
|
owner = Owner(["commit_lost"])
|
|
165
223
|
journal = Journal()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""The Agents SDK adapter: the
|
|
1
|
+
"""The Agents SDK adapter: the shipped scenarios on each SDK path, with a plain function tool as the control."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
@@ -76,31 +76,53 @@ def plain_tools(run):
|
|
|
76
76
|
return [create_order]
|
|
77
77
|
|
|
78
78
|
|
|
79
|
-
def plain_runs(variant: str) -> tuple[dict[str, int],
|
|
79
|
+
def plain_runs(variant: str) -> tuple[dict[str, int], set[str]]:
|
|
80
80
|
"""Effects per scenario, and the scenarios passed when a run ending in an error reports nothing happened."""
|
|
81
|
-
counts,
|
|
81
|
+
counts: dict[str, int] = {}
|
|
82
|
+
passed: set[str] = set()
|
|
82
83
|
for scenario in lost_reply_scenarios():
|
|
83
84
|
with scenario_owner(scenario) as run:
|
|
84
85
|
error = drive_openai_agents(lambda owner, journal: plain_tools(run), run, None, variant=variant)
|
|
85
86
|
counts[scenario["id"]] = run.state.effects
|
|
86
|
-
|
|
87
|
+
if not uncertaineffect_runtime.judge(scenario, run.state, "not_run" if error else "committed"):
|
|
88
|
+
passed.add(scenario["id"])
|
|
87
89
|
return counts, passed
|
|
88
90
|
|
|
89
91
|
|
|
92
|
+
# What the plain tool does in each scenario these tables name, and which of them it passes. A scenario a later
|
|
93
|
+
# corpus adds is driven and judged too, and stays out of these pins until it is named here.
|
|
90
94
|
PLAIN_ONE_RUN = {"confirmed": 1, "commit-then-lost-reply": 1, "commit-then-lost-reply-deduplicating": 1,
|
|
91
95
|
"owner-unreachable-after-lost-reply": 1, "lost-before-commit": 0,
|
|
92
|
-
"late-commit-after-missed-lookup": 0, "definite-no-effect": 0, "lease-lost-after-lost-reply": 1
|
|
96
|
+
"late-commit-after-missed-lookup": 0, "definite-no-effect": 0, "lease-lost-after-lost-reply": 1,
|
|
97
|
+
"crash-mid-step-checkpoint-kept": 1, "crash-mid-step-checkpoint-lost": 1,
|
|
98
|
+
"redelivery-new-task-id": 1, "rewind-replay-after-confirmed": 1, "duplicate-human-completion": 1,
|
|
99
|
+
"key-forgotten-by-owner-then-replay": 1}
|
|
93
100
|
PLAIN_CALLED_AGAIN = {"confirmed": 1, "commit-then-lost-reply": 2, "commit-then-lost-reply-deduplicating": 1,
|
|
94
101
|
"owner-unreachable-after-lost-reply": 2, "lost-before-commit": 1,
|
|
95
102
|
"late-commit-after-missed-lookup": 2, "definite-no-effect": 1,
|
|
96
|
-
"lease-lost-after-lost-reply": 2
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
"lease-lost-after-lost-reply": 2, "crash-mid-step-checkpoint-kept": 2,
|
|
104
|
+
"crash-mid-step-checkpoint-lost": 1, "redelivery-new-task-id": 1,
|
|
105
|
+
"rewind-replay-after-confirmed": 1, "duplicate-human-completion": 1,
|
|
106
|
+
"key-forgotten-by-owner-then-replay": 1}
|
|
107
|
+
# A committed write whose reply arrives passes; so does nothing sent, where nothing is acceptable.
|
|
108
|
+
PASSES_ONE = {"confirmed", "lost-before-commit", "definite-no-effect", "rewind-replay-after-confirmed",
|
|
109
|
+
"duplicate-human-completion", "key-forgotten-by-owner-then-replay"}
|
|
110
|
+
# Called again, the second send lands on a deduplicating owner, on an owner with nothing yet, or after a confirm.
|
|
111
|
+
PASSES_AGAIN = {"confirmed", "commit-then-lost-reply-deduplicating", "lost-before-commit", "definite-no-effect",
|
|
112
|
+
"crash-mid-step-checkpoint-lost", "redelivery-new-task-id", "rewind-replay-after-confirmed",
|
|
113
|
+
"duplicate-human-completion", "key-forgotten-by-owner-then-replay"}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@pytest.mark.parametrize(("variant", "effects", "passes"), [("default", PLAIN_ONE_RUN, PASSES_ONE),
|
|
117
|
+
("session-resume", PLAIN_CALLED_AGAIN, PASSES_AGAIN),
|
|
118
|
+
("model-retry", PLAIN_CALLED_AGAIN, PASSES_AGAIN)])
|
|
119
|
+
def test_control_plain_tool(variant, effects, passes):
|
|
120
|
+
counts, passed = plain_runs(variant)
|
|
121
|
+
assert set(effects) <= set(counts), "a scenario these pins name is no longer shipped"
|
|
122
|
+
assert {name: counts[name] for name in effects} == effects
|
|
123
|
+
assert passed & set(effects) == passes
|
|
124
|
+
# The control fails somewhere the guarded tool passes, or it shows nothing.
|
|
125
|
+
assert passed != set(counts)
|
|
104
126
|
|
|
105
127
|
|
|
106
128
|
class Orders:
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
"""The
|
|
1
|
+
"""The shipped lost-reply scenarios: the guard alone, through LangGraph, and a plain tool as the control."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import json
|
|
5
6
|
from typing import Any
|
|
6
7
|
|
|
7
8
|
import pytest
|
|
@@ -23,9 +24,21 @@ from probity_effects.testing import (
|
|
|
23
24
|
scenario_owner,
|
|
24
25
|
)
|
|
25
26
|
|
|
27
|
+
#: The scenarios the first corpus shipped; a later corpus may add scenarios, never drop these.
|
|
28
|
+
FIRST_EIGHT = {"confirmed", "commit-then-lost-reply", "commit-then-lost-reply-deduplicating",
|
|
29
|
+
"owner-unreachable-after-lost-reply", "lost-before-commit", "late-commit-after-missed-lookup",
|
|
30
|
+
"definite-no-effect", "lease-lost-after-lost-reply"}
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
|
|
33
|
+
def test_every_scenario_the_corpus_pairs_with_a_case_is_driven():
|
|
34
|
+
from agent_evidence_vectors import uncertaineffect
|
|
35
|
+
|
|
36
|
+
manifest = json.loads((uncertaineffect.ROOT / "MANIFEST.json").read_text(encoding="utf-8"))
|
|
37
|
+
paired = {entry["runtime"]["scenario"]["id"] for entry in manifest["vectors"]}
|
|
38
|
+
driven = [scenario["id"] for scenario in lost_reply_scenarios()]
|
|
39
|
+
assert len(driven) == len(set(driven))
|
|
40
|
+
assert set(driven) == paired
|
|
41
|
+
assert FIRST_EIGHT <= paired
|
|
29
42
|
|
|
30
43
|
|
|
31
44
|
def test_guard_alone_passes(lost_reply_scenario):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{probity_effects-0.2.0 → probity_effects-0.2.2}/src/probity_effects.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|