runledger 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.
Files changed (52) hide show
  1. runledger-0.1.0/LICENSE +21 -0
  2. runledger-0.1.0/PKG-INFO +406 -0
  3. runledger-0.1.0/README.md +362 -0
  4. runledger-0.1.0/pyproject.toml +57 -0
  5. runledger-0.1.0/setup.cfg +4 -0
  6. runledger-0.1.0/src/runledger/__init__.py +3 -0
  7. runledger-0.1.0/src/runledger/__main__.py +11 -0
  8. runledger-0.1.0/src/runledger/artifacts/__init__.py +13 -0
  9. runledger-0.1.0/src/runledger/artifacts/junit.py +51 -0
  10. runledger-0.1.0/src/runledger/artifacts/report.py +424 -0
  11. runledger-0.1.0/src/runledger/artifacts/run_log.py +24 -0
  12. runledger-0.1.0/src/runledger/artifacts/summary.py +205 -0
  13. runledger-0.1.0/src/runledger/assertions/__init__.py +14 -0
  14. runledger-0.1.0/src/runledger/assertions/base.py +11 -0
  15. runledger-0.1.0/src/runledger/assertions/engine.py +116 -0
  16. runledger-0.1.0/src/runledger/assertions/json_schema.py +51 -0
  17. runledger-0.1.0/src/runledger/assertions/required_fields.py +19 -0
  18. runledger-0.1.0/src/runledger/assertions/tool_contract.py +69 -0
  19. runledger-0.1.0/src/runledger/baseline/__init__.py +4 -0
  20. runledger-0.1.0/src/runledger/baseline/io.py +26 -0
  21. runledger-0.1.0/src/runledger/baseline/models.py +77 -0
  22. runledger-0.1.0/src/runledger/cassette/__init__.py +6 -0
  23. runledger-0.1.0/src/runledger/cassette/loader.py +53 -0
  24. runledger-0.1.0/src/runledger/cassette/match.py +61 -0
  25. runledger-0.1.0/src/runledger/cassette/models.py +13 -0
  26. runledger-0.1.0/src/runledger/cassette/writer.py +22 -0
  27. runledger-0.1.0/src/runledger/cli.py +487 -0
  28. runledger-0.1.0/src/runledger/config/__init__.py +3 -0
  29. runledger-0.1.0/src/runledger/config/loader.py +85 -0
  30. runledger-0.1.0/src/runledger/config/models.py +65 -0
  31. runledger-0.1.0/src/runledger/protocol/__init__.py +25 -0
  32. runledger-0.1.0/src/runledger/protocol/jsonl.py +50 -0
  33. runledger-0.1.0/src/runledger/protocol/messages.py +87 -0
  34. runledger-0.1.0/src/runledger/regression/__init__.py +3 -0
  35. runledger-0.1.0/src/runledger/regression/engine.py +197 -0
  36. runledger-0.1.0/src/runledger/runner/__init__.py +16 -0
  37. runledger-0.1.0/src/runledger/runner/budgets.py +35 -0
  38. runledger-0.1.0/src/runledger/runner/engine.py +340 -0
  39. runledger-0.1.0/src/runledger/runner/models.py +47 -0
  40. runledger-0.1.0/src/runledger/runner/subprocess.py +161 -0
  41. runledger-0.1.0/src/runledger/tools/__init__.py +3 -0
  42. runledger-0.1.0/src/runledger/tools/builtin.py +21 -0
  43. runledger-0.1.0/src/runledger/tools/registry.py +58 -0
  44. runledger-0.1.0/src/runledger/util/__init__.py +4 -0
  45. runledger-0.1.0/src/runledger/util/canonical_json.py +21 -0
  46. runledger-0.1.0/src/runledger/util/redaction.py +63 -0
  47. runledger-0.1.0/src/runledger.egg-info/PKG-INFO +406 -0
  48. runledger-0.1.0/src/runledger.egg-info/SOURCES.txt +50 -0
  49. runledger-0.1.0/src/runledger.egg-info/dependency_links.txt +1 -0
  50. runledger-0.1.0/src/runledger.egg-info/entry_points.txt +2 -0
  51. runledger-0.1.0/src/runledger.egg-info/requires.txt +12 -0
  52. runledger-0.1.0/src/runledger.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 RunLedger
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,406 @@
1
+ Metadata-Version: 2.4
2
+ Name: runledger
3
+ Version: 0.1.0
4
+ Summary: CI for tool-using agents: deterministic eval suites with record/replay, hard assertions, budgets, and PR regression gates.
5
+ Author: RunLedger
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 RunLedger
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
+ Keywords: llm,agents,evaluation,ci,github-actions,replay,testing,junit,jsonschema
29
+ Requires-Python: >=3.9
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Requires-Dist: typer>=0.9.0
33
+ Requires-Dist: rich>=13.0.0
34
+ Requires-Dist: pydantic>=2.0.0
35
+ Requires-Dist: pyyaml>=6.0.0
36
+ Requires-Dist: jsonschema>=4.0.0
37
+ Requires-Dist: jinja2>=3.1.0
38
+ Provides-Extra: dev
39
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
40
+ Requires-Dist: pytest-timeout>=2.1.0; extra == "dev"
41
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
42
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
43
+ Dynamic: license-file
44
+
45
+ # RunLedger
46
+
47
+ [![CI](https://github.com/runledger/Runledger/actions/workflows/ci.yml/badge.svg)](https://github.com/runledger/Runledger/actions/workflows/ci.yml)
48
+ [![PyPI](https://img.shields.io/pypi/v/runledger)](https://pypi.org/project/runledger/)
49
+ [![License](https://img.shields.io/github/license/runledger/Runledger)](LICENSE)
50
+
51
+ **CI for tool-using agents.** Deterministic eval suites with record/replay tool calls, hard assertions, budgets, and PR regression gates.
52
+
53
+ RunLedger is a **CI harness**, not an "eval metrics framework":
54
+ - **DeepEval-style tools** help you *score* behavior.
55
+ - **RunLedger** helps you *ship safely* by making agent tests deterministic and merge-gated.
56
+
57
+ ---
58
+
59
+ ## Why RunLedger (in one minute)
60
+
61
+ Agents regress silently:
62
+ - prompt changes
63
+ - tool signature drift
64
+ - model updates
65
+ - external APIs / web volatility
66
+
67
+ RunLedger stops that by:
68
+ - **recording tool calls once** and **replaying in CI**
69
+ - enforcing **contracts** (schema, tool allowlist/order, budgets)
70
+ - gating PRs via **baselines + diffs** (exit codes + JUnit + HTML report)
71
+
72
+ ---
73
+
74
+ ## Quickstart (5 minutes)
75
+
76
+ ```bash
77
+ pipx install runledger
78
+ runledger init
79
+ runledger run ./evals/demo --mode record
80
+ runledger baseline promote --from <RUN_DIR> --to baselines/demo.json
81
+ runledger run ./evals/demo --mode replay --baseline baselines/demo.json
82
+ ```
83
+
84
+ Artifacts are written to `runledger_out/<suite>/<run_id>/`:
85
+
86
+ - `report.html`, `summary.json`, `junit.xml`, `run.jsonl`
87
+
88
+ ---
89
+
90
+ ## FAQ: Why not just use DeepEval?
91
+
92
+ DeepEval is excellent for *evaluation metrics* and benchmarking.
93
+ RunLedger is focused on *CI determinism for tool-using agents*:
94
+
95
+ - Record tool calls once -> replay in CI (stable, fast, no flaky external dependencies)
96
+ - Merge gates based on hard contracts (schema/tool/budgets), not "LLM-judge vibes"
97
+ - Baselines-as-code (diffs + promotions) that fit cleanly into PR workflows
98
+
99
+ If you already use DeepEval, keep it - RunLedger can be the harness that makes agent tests CI-grade.
100
+
101
+ ---
102
+
103
+ ## When to use RunLedger vs DeepEval
104
+
105
+ Use **RunLedger** when you need:
106
+
107
+ - deterministic CI for tool-using agents (web/APIs/DBs)
108
+ - hard pass/fail contracts (schema/tool order/budgets)
109
+ - baselines + PR regression gates
110
+
111
+ Use **DeepEval** when you need:
112
+
113
+ - rich evaluation metrics / model-graded scoring / benchmarking workflows
114
+
115
+ Use **both** if you want DeepEval scoring inside a deterministic CI harness.
116
+
117
+ ---
118
+
119
+ ## How it works
120
+
121
+ 1. You define a **suite** (`suite.yaml`) and **cases** (`cases/*.yaml`).
122
+ 2. The runner launches your **agent under test** as a subprocess (any language).
123
+ 3. The agent requests tools via a **stdio JSON protocol**.
124
+ 4. The runner either:
125
+
126
+ * **records** tool results to a cassette (local/dev), or
127
+ * **replays** tool results from a cassette (CI/deterministic).
128
+ 5. The agent emits a **final JSON output**.
129
+ 6. The runner applies **assertions** + **budgets**, compares to a **baseline**, writes artifacts, and exits non-zero on regressions.
130
+
131
+ ---
132
+
133
+ ## Agent-under-test protocol (language-agnostic)
134
+
135
+ **Transport:** newline-delimited JSON messages over stdin/stdout.
136
+
137
+ **Hard rule:** agent must write **protocol JSON only to stdout**.
138
+ Any human logs must go to **stderr** (stdout must stay parseable).
139
+
140
+ ### Runner -> Agent
141
+
142
+ `task_start`
143
+
144
+ ```json
145
+ { "type": "task_start", "task_id": "t1", "input": { "...": "..." } }
146
+ ```
147
+
148
+ `tool_result`
149
+
150
+ ```json
151
+ { "type": "tool_result", "call_id": "c1", "ok": true, "result": { "...": "..." } }
152
+ ```
153
+
154
+ ### Agent -> Runner
155
+
156
+ `tool_call`
157
+
158
+ ```json
159
+ { "type": "tool_call", "name": "search_docs", "call_id": "c1", "args": { "q": "..." } }
160
+ ```
161
+
162
+ `final_output` (must be JSON)
163
+
164
+ ```json
165
+ { "type": "final_output", "output": { "category": "billing", "reply": "..." } }
166
+ ```
167
+
168
+ Optional:
169
+
170
+ * `log` (structured debug)
171
+ * `task_error` (explicit failure)
172
+
173
+ ---
174
+
175
+ ## Eval suite format
176
+
177
+ ### `evals/<suite>/suite.yaml` (example)
178
+
179
+ ```yaml
180
+ suite_name: support-triage
181
+ agent_command: ["python", "agent.py"]
182
+ mode: replay # replay | record | live
183
+ cases_path: cases
184
+ tool_registry:
185
+ - search_docs
186
+ - create_issue
187
+
188
+ assertions:
189
+ - type: json_schema
190
+ schema_path: schema.json
191
+
192
+ budgets:
193
+ max_wall_ms: 20000
194
+ max_tool_calls: 10
195
+ max_tool_errors: 0
196
+
197
+ baseline_path: baselines/support-triage.json
198
+ ```
199
+
200
+ ### `evals/<suite>/cases/t1.yaml` (example)
201
+
202
+ ```yaml
203
+ id: t1
204
+ description: "triage a login ticket"
205
+ input:
206
+ ticket: "User cannot login"
207
+ context:
208
+ plan: "pro"
209
+ cassette: cassettes/t1.jsonl
210
+
211
+ assertions:
212
+ - type: required_fields
213
+ fields: ["category", "reply"]
214
+
215
+ budgets:
216
+ max_wall_ms: 5000
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Record/replay tool calls (cassettes)
222
+
223
+ ### Why record/replay?
224
+
225
+ Agents often depend on external tools (search, DB, HTTP). Live calls in CI are:
226
+
227
+ * slow
228
+ * flaky
229
+ * non-deterministic
230
+ * expensive
231
+
232
+ Instead:
233
+
234
+ * **record once** (live tools) -> write cassette
235
+ * **replay in CI** (deterministic) -> stable and fast
236
+
237
+ ### Cassette format (JSONL example)
238
+
239
+ Each line is one tool invocation:
240
+
241
+ ```json
242
+ {"tool":"search_docs","args":{"q":"reset password"},"ok":true,"result":{"hits":[...]}}
243
+ {"tool":"create_issue","args":{"title":"Login issue","priority":"p2"},"ok":true,"result":{"id":"ISSUE-123"}}
244
+ ```
245
+
246
+ **Replay matching (MVP):**
247
+
248
+ * exact match on `tool` + canonicalized `args`
249
+ * if not found: the case fails with a clear "cassette mismatch" error
250
+
251
+ ---
252
+
253
+ ## Assertions (deterministic)
254
+
255
+ MVP assertions:
256
+
257
+ * `json_schema` (validate final output with JSON Schema)
258
+ * `required_fields` (keys exist / basic typing)
259
+ * `regex` / `contains` (for specific fields)
260
+ * `tool_contract`:
261
+
262
+ * must call tool X
263
+ * must not call tool Y
264
+ * X before Y (ordering)
265
+
266
+ Not default-gating (optional later):
267
+
268
+ * LLM-judge scoring
269
+ * semantic similarity scoring
270
+
271
+ ---
272
+
273
+ ## Budgets (merge gates)
274
+
275
+ MVP budgets:
276
+
277
+ * `max_wall_ms`
278
+ * `max_tool_calls`
279
+ * `max_tool_errors`
280
+
281
+ Optional budgets when agents report metrics:
282
+
283
+ * `max_tokens_out`
284
+ * `max_cost_usd`
285
+
286
+ ---
287
+
288
+ ## Baselines + regression checks
289
+
290
+ On each run, you can compare against a baseline and fail CI if:
291
+
292
+ * success rate drops below threshold
293
+ * costs spike beyond allowed delta
294
+ * latency p95 increases beyond allowed delta
295
+
296
+ Typical workflow:
297
+
298
+ * record cassettes locally
299
+ * establish a baseline from a known-good run
300
+ * run replay mode on every PR and gate merges on regressions
301
+
302
+ ```bash
303
+ runledger baseline promote --from runledger_out/<suite>/<run_id> --to baselines/<suite>.json
304
+ runledger run ./evals/<suite> --mode replay --baseline baselines/<suite>.json
305
+ ```
306
+
307
+ ---
308
+
309
+ ## Output artifacts
310
+
311
+ A run produces:
312
+
313
+ * `run.jsonl` -- append-only event log (steps, tool calls/results, outputs)
314
+ * `summary.json` -- suite + case metrics, pass/fail, regression summary
315
+ * `junit.xml` -- CI-native pass/fail (each case maps to a test)
316
+ * `report.html` -- static shareable report (no server required)
317
+
318
+ These files are intentionally stable so they can be:
319
+
320
+ * diffed in PRs
321
+ * uploaded as CI artifacts
322
+ * ingested by a future hosted add-on
323
+
324
+ ---
325
+
326
+ ## GitHub Actions (example)
327
+
328
+ ```yaml
329
+ name: agent-evals
330
+ on:
331
+ pull_request:
332
+
333
+ jobs:
334
+ evals:
335
+ runs-on: ubuntu-latest
336
+ steps:
337
+ - uses: actions/checkout@v4
338
+
339
+ - name: Run deterministic evals (replay)
340
+ uses: runledger/Runledger@v0.1.0
341
+ with:
342
+ path: ./evals/demo
343
+ mode: replay
344
+
345
+ - name: Upload eval artifacts
346
+ uses: actions/upload-artifact@v4
347
+ with:
348
+ name: agent-eval-artifacts
349
+ path: runledger_out/**
350
+ ```
351
+
352
+ ---
353
+
354
+ ## Determinism guide (rules of the road)
355
+
356
+ * Prefer `--mode replay` in CI.
357
+ * Ensure agent writes **only JSONL protocol messages** to stdout; logs go to stderr.
358
+ * Canonicalize tool call args (stable key ordering, avoid volatile fields).
359
+ * Avoid timestamps/randomness in final output; if needed, exclude or normalize before assertions.
360
+ * Keep cassettes safe to commit: redact secrets by default.
361
+
362
+ ---
363
+
364
+ ## Docs
365
+
366
+ - `docs/quickstart.md` -- install + first run
367
+ - `docs/assertions.md` -- assertions, tool contracts, budgets
368
+ - `docs/baselines.md` -- baselines, diffing, promotion
369
+ - `docs/ci.md` -- CI setup with GitHub Actions
370
+ - `docs/contracts.md` -- public contracts (YAML, protocol, artifacts)
371
+ - `docs/troubleshooting.md` -- common errors and fixes
372
+
373
+ ---
374
+
375
+ ## Roadmap
376
+
377
+ * `init` templates for Python (OpenAI SDK), LangGraph/LangChain, and Node/TS
378
+ * richer budgets (tokens/cost) via optional `task_metrics`
379
+ * PR comments bot for regression summaries
380
+ * plugin system for custom assertions
381
+ * HTML report trace viewer improvements
382
+
383
+ ---
384
+
385
+ ## Commercial Support
386
+
387
+ RunLedger is MIT-licensed and free to self-host. For teams that want done-for-you implementation or ongoing maintenance, we offer:
388
+
389
+ - Hardening Sprint (fixed-scope implementation to get deterministic CI running fast)
390
+ - Assurance (monthly retainer for cassette and case updates, budget tuning, and incident response)
391
+
392
+ Contact: [runleder.io/community.html#contact](https://runleder.io/community.html#contact)
393
+
394
+ ---
395
+
396
+ ## Contributing
397
+
398
+ * Issues and PRs welcome.
399
+ * See `CONTRIBUTING.md` for development setup, style, and testing.
400
+ * Security issues: see `SECURITY.md`.
401
+
402
+ ---
403
+
404
+ ## License
405
+
406
+ MIT