gateledger 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.
- gateledger-0.1.0/.gitignore +7 -0
- gateledger-0.1.0/CHANGELOG.md +29 -0
- gateledger-0.1.0/LICENSE +21 -0
- gateledger-0.1.0/PKG-INFO +227 -0
- gateledger-0.1.0/README.ja.md +180 -0
- gateledger-0.1.0/README.md +194 -0
- gateledger-0.1.0/examples/diagnose.py +157 -0
- gateledger-0.1.0/examples/rubrics/supported.md +8 -0
- gateledger-0.1.0/pyproject.toml +58 -0
- gateledger-0.1.0/src/gateledger/__init__.py +38 -0
- gateledger-0.1.0/src/gateledger/calibration.py +123 -0
- gateledger-0.1.0/src/gateledger/cli.py +107 -0
- gateledger-0.1.0/src/gateledger/gate.py +64 -0
- gateledger-0.1.0/src/gateledger/judge.py +100 -0
- gateledger-0.1.0/src/gateledger/ledger.py +168 -0
- gateledger-0.1.0/src/gateledger/pipeline.py +391 -0
- gateledger-0.1.0/src/gateledger/price_tables/2026-11.toml +68 -0
- gateledger-0.1.0/src/gateledger/price_tables/__init__.py +1 -0
- gateledger-0.1.0/src/gateledger/prices.py +108 -0
- gateledger-0.1.0/src/gateledger/providers.py +105 -0
- gateledger-0.1.0/src/gateledger/py.typed +0 -0
- gateledger-0.1.0/src/gateledger/records.py +148 -0
- gateledger-0.1.0/src/gateledger/report.py +788 -0
- gateledger-0.1.0/src/gateledger/watch.py +416 -0
- gateledger-0.1.0/tests/conftest.py +22 -0
- gateledger-0.1.0/tests/test_judge.py +276 -0
- gateledger-0.1.0/tests/test_pipeline.py +201 -0
- gateledger-0.1.0/tests/test_prices.py +52 -0
- gateledger-0.1.0/tests/test_providers.py +49 -0
- gateledger-0.1.0/tests/test_readme.py +21 -0
- gateledger-0.1.0/tests/test_report.py +116 -0
- gateledger-0.1.0/tests/test_watch.py +159 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses [Semantic Versioning](https://semver.org/). Before 1.0, minor versions may change the record format.
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-11-28
|
|
8
|
+
|
|
9
|
+
First public release.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `Pipeline` with named stages. Every LLM call is recorded with the requested and the served model, token usage, cost, latency and a reason (`initial` / `repair` / `rejudge`).
|
|
14
|
+
- `Ledger`: append-only JSONL, one file per run (`run_start`, `call`, `stage`, `gate`, `run_end`).
|
|
15
|
+
- `PriceTable` with a bundled table (`2026-11`, Anthropic first-party prices). Models missing from the table raise `UnknownModelError` instead of being booked at $0.
|
|
16
|
+
- `Gate` with a required failure mode: `block`, `repair` (one retry with the findings) or `record`. `Pipeline.waive(stage, gate, reason)` is the only way past a gate and is always recorded. Mechanical gates run before judge gates.
|
|
17
|
+
- `Judge`: rubric files versioned by content hash, structured verdicts, and verdict reuse keyed by the fingerprint of what the judge was shown plus the rubric version.
|
|
18
|
+
- Calibration (`gateledger calibrate`): agreement, Cohen's κ with a bootstrap interval and a confusion matrix per (rubric version, served model). A judge may block only with κ ≥ 0.6 on at least 100 labels, and only when the served model is the requested one.
|
|
19
|
+
- Label source on calibrations (`human` / `model_panel`). A calibration from model-panel labels alone grants no blocking power unless `Pipeline(allow_panel_calibration=True)` is set.
|
|
20
|
+
- `gateledger report`: terminal table, SVG for a README and an HTML page.
|
|
21
|
+
- `gateledger watch` and `watch()`: compare recent runs with a baseline period. Facts (a new served model per stage or judge rubric, a stage, gate or rubric version on one side only) are flagged as is; shifts in cost per run, gate and judge fail rates, judged items per run and failed runs are tested with a permutation test over runs, Holm-adjusted. Exits with 1 when degradation is suspected.
|
|
22
|
+
- Providers: `FakeProvider` for tests and examples, `AnthropicProvider` (`pip install "gateledger[anthropic]"`).
|
|
23
|
+
|
|
24
|
+
### Known limitations
|
|
25
|
+
|
|
26
|
+
- Exception messages raised by the library are in Japanese. Reports, CLI output and the reasons recorded on judge verdicts (`advisory_reason`) are in English.
|
|
27
|
+
- Fallback calls are not yet recorded separately from the original call; the total uses the served model's price.
|
|
28
|
+
- Verdict reuse reads the JSONL ledger directly (no SQLite index yet).
|
|
29
|
+
- `watch` has been tried in one small experiment only (10 runs per side: 3 of 4 injected faults flagged, one unchanged rerun not flagged). Its false-alarm rate has not been measured.
|
gateledger-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hakari-labs
|
|
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,227 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: gateledger
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pass/fail and cost receipts for multi-stage LLM pipelines. Gates, judge calibration, no server.
|
|
5
|
+
Project-URL: Homepage, https://github.com/hakari-labs/gateledger
|
|
6
|
+
Project-URL: Repository, https://github.com/hakari-labs/gateledger
|
|
7
|
+
Project-URL: Issues, https://github.com/hakari-labs/gateledger/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/hakari-labs/gateledger/blob/main/CHANGELOG.md
|
|
9
|
+
Author: hakari-labs
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: cost-tracking,evaluation,guardrails,llm,llm-as-a-judge,pipeline
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Requires-Dist: pydantic>=2.7
|
|
25
|
+
Provides-Extra: anthropic
|
|
26
|
+
Requires-Dist: anthropic>=1.0; extra == 'anthropic'
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: anthropic>=1.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: mypy>=2.4; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.17; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# gateledger
|
|
35
|
+
|
|
36
|
+
Pass/fail and cost receipts for multi-stage LLM pipelines. No server, just JSONL files.
|
|
37
|
+
It records both the model you asked for and the model that answered, and a judge model that has not been checked against human labels never gets to stop the pipeline.
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
The image above comes from `examples/diagnose.py` run against a fake LLM, so its numbers are illustrative.
|
|
42
|
+
|
|
43
|
+
The numbers below were measured once on the held-out test set of the example app ([maint-agent](https://github.com/hakari-labs/maint-agent), an equipment-maintenance QA agent; 192 questions, 95% bootstrap CI). The questions were checked by a panel of two LLMs, not by people, and 10 of the original 202 that the panel flagged were not run:
|
|
44
|
+
|
|
45
|
+
| Fabricated quotes (before the check) | Unsupported claims (judge estimate) | Wrong answers to unanswerable questions | Cost per question | Share of cost spent on retries |
|
|
46
|
+
|---|---|---|---|---|
|
|
47
|
+
| 1.9% [0.9, 3.0] (all 18 affected answers recovered by one repair) | 69.0% [64.3, 73.4] (target 5%, missed) | 16.3% [6.1, 26.5] (target 10%, missed) | $0.174 [0.160, 0.188] at Bedrock list prices | 5.7% [3.2, 8.4] |
|
|
48
|
+
|
|
49
|
+
| Judge agreement (150 labels, dev set) | Cohen's κ [95% CI, resampling questions] |
|
|
50
|
+
|---|---|
|
|
51
|
+
| Judge vs. one other model that labelled without seeing the judge's verdicts (Fable 5.2, not human) | 0.37 [0.22, 0.53] |
|
|
52
|
+
| Judge vs. the earlier two-model panel (one of its two labellers was the judge's own model) | 0.85 [0.75, 0.93] |
|
|
53
|
+
| Judge vs. human | not measured |
|
|
54
|
+
|
|
55
|
+
The judge has no power to block: its labels are not human, and against the other model's labels κ is below the 0.6 bar. The first panel had cleared both numeric thresholds; the rule that model-made labels never grant blocking power is what kept the judge advisory. The 69.0% is therefore the rate under the judge's reading of the rubric. On the 150 dev-set claims the judge failed 68% and the other model 34%, and without human labels it is not known which reading is right. Either way the 5% target was missed. [Evaluation report](https://github.com/hakari-labs/maint-agent/blob/main/eval/test_report.md) · [Demo: 30 recorded runs replayed, no live LLM calls](https://hakari-labs.github.io/maint-agent/)
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install gateledger
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Minimal example
|
|
62
|
+
|
|
63
|
+
Runs as is: the replies come from a fake LLM, so no API key is needed. Pass `AnthropicProvider()` as `llm` for real calls.
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import json
|
|
67
|
+
|
|
68
|
+
from gateledger import FakeProvider, FakeReply, Gate, Ledger, Pipeline, PriceTable, Usage
|
|
69
|
+
from gateledger.report import render_text, summarize
|
|
70
|
+
|
|
71
|
+
SOURCE = "Probable cause: fuel filter clogged. Drain water and replace the element."
|
|
72
|
+
replies = [ # the 1st answer misquotes the source, the 2nd one fixes it
|
|
73
|
+
FakeReply('{"cause": "clogged fuel filter", "quote": "filter full of water"}', Usage(input=900, output=60)),
|
|
74
|
+
FakeReply('{"cause": "clogged fuel filter", "quote": "fuel filter clogged"}', Usage(input=1_000, output=60)),
|
|
75
|
+
]
|
|
76
|
+
llm = FakeProvider(replies)
|
|
77
|
+
pipe = Pipeline("diagnose", ledger=Ledger("runs"), prices=PriceTable.bundled("2026-11"), llm=llm)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@pipe.stage("answer", model="claude-opus-5-5") # a model missing from the price table fails here, not at run time
|
|
81
|
+
def answer(ctx, question):
|
|
82
|
+
fix = f"\nFix: {ctx.findings}" if ctx.findings else "" # findings of the failed gate, on the repair attempt
|
|
83
|
+
return json.loads(ctx.llm.complete([{"role": "user", "content": question + fix}]).text)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def quote_in_source(out, _input): # mechanical check: an empty list means pass
|
|
87
|
+
return [] if out["quote"] in SOURCE else [f"quote not in source: {out['quote']}"]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
pipe.gate("answer", Gate("quote_exists", check=quote_in_source, on_fail="repair"))
|
|
91
|
+
result = pipe.run("Engine cranks but will not start. Why?")
|
|
92
|
+
print(result.output, f"${result.cost:.4f}")
|
|
93
|
+
print(render_text(summarize(pipe.ledger.read(result.run_id)))) # stage, gate and cost table
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The run is written to `runs/<run_id>.jsonl`: two calls (`initial`, then `repair`), the failed and the passed gate, and the cost of each.
|
|
97
|
+
`gateledger report --dir runs --svg report.svg --html report.html` renders the latest run as above.
|
|
98
|
+
A longer example with a judge, a waived gate and a model mismatch is in [`examples/diagnose.py`](examples/diagnose.py).
|
|
99
|
+
|
|
100
|
+
## Rules
|
|
101
|
+
|
|
102
|
+
| Rule | What it means |
|
|
103
|
+
|---|---|
|
|
104
|
+
| No argument skips a gate | To go past a gate, call `pipe.waive(stage, gate, reason)`. Every run then records `waived` with the reason |
|
|
105
|
+
| The failure mode is required | `block` (stop), `repair` (pass the findings back and retry once; anything left is recorded and the run goes on) or `record` (record only) |
|
|
106
|
+
| Unknown models are an error | A stage's model is checked against the price table when the stage is added. If the model that answered is not in the table, the call is recorded with an empty cost and then raises. It is never booked as $0 |
|
|
107
|
+
| Every call has a reason | `initial` / `repair` / `rejudge`, so cost per reason is a plain aggregation (`fallback` is reserved and not written yet) |
|
|
108
|
+
| Requested and served model | Cost uses the served model's price. A mismatch shows up in the report. LiteLLM and Inspect AI also record both sides of a fallback; what gateledger adds is that the served model decides whether a judge's verdict may block (see the next section) |
|
|
109
|
+
| Fingerprints | Stage input and output are stored as the SHA-256 of normalized JSON |
|
|
110
|
+
| Mechanical checks first | Within a stage, mechanical gates run before judge gates regardless of the order they were added, so nothing a free check already rejected is sent to a paid judge |
|
|
111
|
+
| Verdict reuse | The key is the fingerprint of what the judge was shown (`view`) plus the rubric version. The model is recorded but not part of the key, so switching judges reuses earlier verdicts at no cost. A reused verdict keeps the original run id and the amount it saved. If `view` returns `None`, nothing is judged (no cost, treated as pass) |
|
|
112
|
+
| Rubric versions | The version comes from the SHA-256 of the rubric file (`supported@bf57b3922ae8`). Editing the file changes the version, and earlier verdicts and calibrations stop applying. The version cannot be forgotten |
|
|
113
|
+
|
|
114
|
+
## When a judge may stop the pipeline
|
|
115
|
+
|
|
116
|
+
Even on an `on_fail="block"` gate, a judge verdict stops the run only when all three conditions hold. Otherwise the verdict is recorded as advisory (with `advisory_reason`) and the run continues; the report shows why it did not stop (uncalibrated, below the bar, panel labels only, or a different model answered).
|
|
117
|
+
|
|
118
|
+
| Condition | Threshold | Why |
|
|
119
|
+
|---|---|---|
|
|
120
|
+
| Agreement with human labels | Cohen's κ ≥ 0.6 | The lower end of "substantial agreement" (0.61–0.80, Landis & Koch). Below that, the reason for stopping cannot be explained to a person |
|
|
121
|
+
| Number of labels | ≥ 100 | At 85% raw agreement and 50% chance agreement, the 95% interval of κ is about ±0.14 with 100 labels and about ±0.2 with 50, too wide to tell 0.6 from 0.4 |
|
|
122
|
+
| Served model | Same as requested | The calibrated judge is the one that was asked. A verdict from a model that stood in after a rate limit or outage does not inherit that authority, even if the stand-in has its own calibration |
|
|
123
|
+
|
|
124
|
+
- κ and the label count are tracked per (rubric version, served model), and each verdict records the values in force at the time.
|
|
125
|
+
- The thresholds cannot be lowered by an argument. They are `gateledger.MIN_KAPPA` and `MIN_LABELS`.
|
|
126
|
+
- On a block gate, if the only earlier verdict is advisory and the requested judge is calibrated, the item is judged again (reason `rejudge`).
|
|
127
|
+
- Limitation: with a single labeller, κ measures agreement with that one person. The bootstrap interval of κ is reported alongside the count. The interval resamples labels independently; when several labels come from the same question it is too narrow, so resample by question in your own code (the example app does).
|
|
128
|
+
- Label source: each calibration records where its labels came from, `human` or `model_panel` (labels made by one or more other models, a silver standard). A calibration from `model_panel` labels alone does not give the judge the power to block, because agreement with people was never measured. Pass `Pipeline(..., allow_panel_calibration=True)` to accept it explicitly; the report then says the authority rests on model-panel labels.
|
|
129
|
+
|
|
130
|
+
Calibration matches a JSONL of labels against the verdicts in the ledger, one line per label: `{"judged_fp": "sha256:…", "human": "pass"}` for a human label, or `{"judged_fp": "sha256:…", "label": "pass", "source": "model_panel"}` for a model-panel label. It stops if any label has no matching verdict, or if one file mixes the two sources.
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
gateledger calibrate rubrics/supported.md labels.jsonl --model claude-sonnet-5-5 --dir runs
|
|
134
|
+
# prints n, raw agreement, κ with its 95% interval, the confusion matrix and whether the judge may block;
|
|
135
|
+
# appends the result to runs/calibration/calibrations.jsonl
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Watching for degradation
|
|
139
|
+
|
|
140
|
+
`gateledger watch` compares the runs of a recent window with the period just before it and exits with 1 when it suspects degradation, so it can run from cron or CI.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
gateledger watch --dir runs --window 1d --baseline 14d --pipeline diagnose
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
| Kind | Signals | How it decides |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| Changes (facts) | A served model not seen in the baseline (per stage, and per judge rubric). A stage, gate or rubric version present on one side only | Flagged as is, no test |
|
|
149
|
+
| Shifts | Cost per run (per stage and per judge rubric), judge fail rate and judged items per run (per rubric), fail rate of each mechanical gate, share of runs that did not end `ok` | Two-sided permutation test with the run as the unit, Holm-adjusted so that the chance of any false alarm in one comparison stays at α (default 0.05). Each shift is printed with its n and a 95% bootstrap interval of the difference |
|
|
150
|
+
|
|
151
|
+
- The run is the unit because verdicts within one run are not independent; counting them one by one raises false alarms.
|
|
152
|
+
- Gates count the verdict of the last attempt. Waived gates and judge slots that judged nothing (`view` returned `None`) are not counted. A signal that has the same value in every run is not tested, since no split of the runs can change it.
|
|
153
|
+
- With few runs only large shifts can be told from noise: 3 runs against 3 cannot flag even a gate that went from always passing to always failing (there are only 20 ways to split them).
|
|
154
|
+
- From Python, `watch(baseline, current)` takes two lists of runs (each the records from `Ledger.read`) and returns a `WatchReport`.
|
|
155
|
+
- Tried once on the example app, 10 runs per side: it flagged 3 of 4 deliberately broken configurations (exact 95% interval 19–99%) and missed the one where a manual was removed from the index. One unchanged rerun raised no alarm, which says nothing about the false-alarm rate. [Experiment notes (Japanese)](https://github.com/hakari-labs/maint-agent/blob/main/eval/watch_experiment.md)
|
|
156
|
+
|
|
157
|
+
## What it does not do
|
|
158
|
+
|
|
159
|
+
Where a good tool already exists, gateledger leaves the job to it.
|
|
160
|
+
|
|
161
|
+
| Need | Use | Why |
|
|
162
|
+
|---|---|---|
|
|
163
|
+
| Trace UI, dashboards | Langfuse, Phoenix (via OpenTelemetry, planned) | Good UIs already exist |
|
|
164
|
+
| Prompt versioning | git | Files are enough |
|
|
165
|
+
| Prompt and model sweeps, red teaming | promptfoo | Config-driven sweeps are a solved problem |
|
|
166
|
+
| RAG metric definitions | Ragas | Use names and definitions people already know |
|
|
167
|
+
| Output tests in pytest | DeepEval | CI tests already exist |
|
|
168
|
+
| Validating one call's output and re-asking | Structured outputs, Pydantic | The SDK does this |
|
|
169
|
+
| Routing and fallback across models and providers | LiteLLM | gateledger only records which model answered |
|
|
170
|
+
|
|
171
|
+
It is not an orchestrator either (no parallelism, resume or scheduling). `Pipeline` calls its stages in order and is meant to be called from inside whatever orchestrator you already use.
|
|
172
|
+
|
|
173
|
+
## Record format
|
|
174
|
+
|
|
175
|
+
One JSONL file per run (`runs/<run_id>.jsonl`), one record per line. Record types are `run_start`, `call`, `stage`, `gate` and `run_end`. A judge call is a `call` with `gate` set, and a judge gate's `gate` record carries the verdict under `judge`.
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{"type":"call","run_id":"20261127T091403512Z-7f3a","stage":"answer","attempt":2,"reason":"repair",
|
|
179
|
+
"model_requested":"claude-opus-5-5","model_served":"claude-opus-5-5",
|
|
180
|
+
"usage":{"input":2200,"output":1000,"cache_read":5000,"cache_write":0},"cost_usd":0.0298,"latency_ms":8120}
|
|
181
|
+
{"type":"gate","run_id":"20261127T091403512Z-7f3a","stage":"answer","gate":"supported","on_fail":"block",
|
|
182
|
+
"attempt":2,"artifact_fp":"sha256:41d0…","verdict":"fail",
|
|
183
|
+
"findings":[{"claim":"drain water and replace the element","reason":"the next check is not in the quote"}],
|
|
184
|
+
"judge":{"rubric":"supported@bf57b3922ae8","judged_fp":"sha256:7a2b…",
|
|
185
|
+
"model_requested":"claude-sonnet-5-5","model_served":"claude-sonnet-5-5","score":0.5,"cost_usd":0.0039,
|
|
186
|
+
"reused_from":null,"saved_usd":null,"calibration":null,"advisory_reason":"not calibrated (agreement with human labels not measured)"}}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Where the rules come from
|
|
190
|
+
|
|
191
|
+
The author has run a multi-stage LLM system that produces long-form content every day for about six months. Each rule answers something that went wrong there.
|
|
192
|
+
|
|
193
|
+
| What happened | What gateledger does |
|
|
194
|
+
|---|---|
|
|
195
|
+
| Checks were pasted into each pipeline's launch script; a copy missed one, and on the same day one of three pipelines ran without it | Checks live behind a single entry point, so they cannot be forgotten |
|
|
196
|
+
| "Optional" checks were eventually left switched off | No skip argument. Waivers are explicit, per gate, and always recorded |
|
|
197
|
+
| A defect visible from the input alone was found after an expensive, irreversible stage that took hours | A check goes where its inputs are available; input-only checks run before the expensive stage |
|
|
198
|
+
| A model missing from the price table was booked at $0, hiding its cost | Unknown models raise |
|
|
199
|
+
| The judge's provider hit its rate limit and judging failed in every pipeline | A judge reply that cannot be parsed raises; it is never retried on another model. Moving to another model when one is unavailable is left to the provider or a router, and a verdict from the stand-in is recorded under the model that answered and cannot block |
|
|
200
|
+
| A default model name was routed to the wrong provider and failed | The provider is chosen from the model name, and the served model is checked on the response and recorded |
|
|
201
|
+
| Re-judging everything whenever the judge changed made costs jump | Freshness depends on content and rubric version; the model is only recorded |
|
|
202
|
+
| The same prompts were re-sent on every rerun, but nothing said why, so the waste was invisible | Every call carries a reason |
|
|
203
|
+
| Per-stage model choices and cost-saving switches were compared by joining separate logs | Models are configured per stage, and quality and cost come out of the same ledger |
|
|
204
|
+
|
|
205
|
+
gateledger and its example app were built over two days (27–28 November 2026) with a coding agent (Claude Code) doing the implementation, the evaluation runs and the first drafts of the documents; every commit carries a `Co-Authored-By` trailer. The author set the direction, made the design calls and signed off on the work; no person checked the test questions or the labels used to calibrate the judge, as the tables at the top say. The rules in the table above come from the author's own production system.
|
|
206
|
+
|
|
207
|
+
## Status (v0.1.0)
|
|
208
|
+
|
|
209
|
+
Included: stages, the JSONL ledger, price tables, mechanical gates (`block` / `repair` / `record` / `waive`), judges (`Judge`) with verdict reuse, calibration (`gateledger calibrate`), `gateledger report` (terminal table, SVG, HTML), `gateledger watch` (degradation checks), and LLM adapters (fake and the Anthropic SDK, `pip install "gateledger[anthropic]"`).
|
|
210
|
+
|
|
211
|
+
Not yet: `with ledger.stage(...)` for using only the ledger and gates inside an existing orchestrator; separate records before and after a fallback (reason `fallback`; today the total uses the served model's price); a SQLite index (verdict reuse reads the JSONL ledger); the `cost` command; an OpenTelemetry exporter.
|
|
212
|
+
|
|
213
|
+
Reports and CLI output are in English. Exception messages raised by the library (for example, invalid labels or an unknown model) are still in Japanese.
|
|
214
|
+
|
|
215
|
+
Changes are listed in [CHANGELOG.md](CHANGELOG.md). A Japanese version of this README is in [README.ja.md](README.ja.md).
|
|
216
|
+
|
|
217
|
+
## Development
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
uv sync --extra dev
|
|
221
|
+
uv run pytest && uv run ruff check && uv run mypy # CI runs the same with the versions in uv.lock
|
|
222
|
+
python examples/diagnose.py # regenerates docs/report.svg and docs/report.html
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## License
|
|
226
|
+
|
|
227
|
+
MIT
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# gateledger
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 日本語
|
|
4
|
+
|
|
5
|
+
多段の LLM パイプラインに、合否と料金の受領記録を残す。サーバー不要。
|
|
6
|
+
頼んだモデルと応えたモデルを両方記録し、人との一致を測っていない採点役には止める権限を与えない。
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
いまの画像は `examples/diagnose.py` を偽物の LLM で回した物で、数字は実測ではない。
|
|
11
|
+
例にしたアプリ ([maint-agent](https://github.com/hakari-labs/maint-agent)・設備保全の質問応答エージェント) のテスト用の問いで 1 回だけ測った値 (192 問・95% ブートストラップ区間)。問いの確認は人でなく 2 つの LLM の合議で、元の 202 問のうち合議が引っかかりを付けた 10 問は流していない。
|
|
12
|
+
|
|
13
|
+
| 引用のでっち上げ (照合の前) | 支えの無い主張 (採点役による推定) | 答えの無い問いへの誤答 | 1 問の費用 | やり直しに使った費用の割合 |
|
|
14
|
+
|---|---|---|---|---|
|
|
15
|
+
| 1.9% [0.9, 3.0] (落ちた 18 回答は 1 回の直しで全部戻った) | 69.0% [64.3, 73.4] (目標 5%・届かず) | 16.3% [6.1, 26.5] (目標 10%・届かず) | $0.174 [0.160, 0.188] (Bedrock の定価) | 5.7% [3.2, 8.4] |
|
|
16
|
+
|
|
17
|
+
| 採点役の一致 (ラベル 150 件・開発用) | Cohen の κ [95% 区間・問いの単位で引き直し] |
|
|
18
|
+
|---|---|
|
|
19
|
+
| 採点役の判定を見ずにラベルを付けた別のモデル 1 つ (Fable 5.2・人ではない) | 0.37 [0.22, 0.53] |
|
|
20
|
+
| 前の 2 つのモデルの合議 (係の片方は採点役と同じモデル) | 0.85 [0.75, 0.93] |
|
|
21
|
+
| 人 | 測っていない |
|
|
22
|
+
|
|
23
|
+
採点役に止める権限は無い。ラベルが人の物でなく、別のモデルのラベルとの κ も線 0.6 に届かない。最初の合議は数字の線を 2 つとも超えていて、採点役を参考に留めたのは「モデルが付けたラベルでは止める権限を与えない」という決まりだった。このため 69.0% は、採点役の基準の読みでの率になる。開発用の 150 件の主張では、採点役の不合格は 68%・別のモデルは 34% で、人のラベルが無いのでどちらの読みが正しいかは分からない。どちらでも目標 5% には届かなかった。[評価レポート](https://github.com/hakari-labs/maint-agent/blob/main/eval/test_report.md) · [デモ: 録った 30 回の実行を再生・LLM は呼ばない](https://hakari-labs.github.io/maint-agent/)
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install gateledger
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 最小の例
|
|
30
|
+
|
|
31
|
+
鍵なしでそのまま動く例は英語の [README.md](README.md#minimal-example) にある。長い例は `examples/diagnose.py` (偽物の LLM で回す)。下は本物の LLM で組む時の形だけを示す断片。
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from gateledger import Gate, Judge, Ledger, Pipeline, PriceTable, AnthropicProvider
|
|
35
|
+
|
|
36
|
+
pipe = Pipeline("diagnose", ledger=Ledger("runs/"), prices=PriceTable.bundled("2026-11"), llm=AnthropicProvider())
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@pipe.stage("answer", model="claude-opus-5-5") # 料金表に無いモデルはここでエラー
|
|
40
|
+
def answer(ctx, evidence):
|
|
41
|
+
prompt = build_prompt(evidence, ctx.findings) # repair の時は落ちたゲートの指摘が入る
|
|
42
|
+
return parse(ctx.llm.complete([{"role": "user", "content": prompt}]).text)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
pipe.gate("answer", Gate("quotes_exist", check=quotes_in_sources, on_fail="repair")) # 機械的な点検 (無料)
|
|
46
|
+
supported = Judge("rubrics/supported.md", model="claude-sonnet-5-5", view=lambda out, _: out["causes"])
|
|
47
|
+
pipe.gate("answer", Gate("supported", check=supported, on_fail="block")) # 採点役 (校正するまでは記録だけ)
|
|
48
|
+
|
|
49
|
+
result = pipe.run(evidence) # result.output / result.verdicts / result.cost
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 決まり
|
|
53
|
+
|
|
54
|
+
| 決まり | 中身 |
|
|
55
|
+
|---|---|
|
|
56
|
+
| ゲートを飛ばす引数は無い | 通さずに進める時は `pipe.waive(ステージ, ゲート, 理由)` を書く。実行のたびに `waived` と理由が記録に残る |
|
|
57
|
+
| 落ちた時の扱いは省略できない | `block` (止める)・`repair` (指摘を渡して 1 回だけ直させ、残れば記録して進む)・`record` (記録だけ) |
|
|
58
|
+
| 料金表に無いモデルはエラー | ステージを足す時点で確かめる。応えたモデルが表に無い時は、金額を空にした記録を残してからエラーにする (0 円とは書かない) |
|
|
59
|
+
| 呼び出しごとに理由 | `initial` / `repair` / `rejudge`。理由別の金額が集計だけで出る (`fallback` は名前だけあり、まだ書かない) |
|
|
60
|
+
| 頼んだモデルと応えたモデルの両方 | 金額は応えたモデルの単価で出す。食い違いはレポートに出る。振り替えの前後のモデルは LiteLLM や Inspect AI も記録する。gateledger が足すのは、応えたモデルで採点役の判定に止める権限があるかを決める事 (次の節) |
|
|
61
|
+
| 指紋 | ステージの入力と出力は、正規化した JSON の SHA-256 で記録する |
|
|
62
|
+
| 機械的な点検が先 | 同じステージのゲートは、足した順にかかわらず機械的な点検を先に、採点役を後に掛ける。安い点検で止まった物に採点の料金を払わない |
|
|
63
|
+
| 判定の再利用 | 鍵は「採点役に見せた物 (`view`) の指紋 + 基準の版」。`view` が None を返したら見せる物が無いとして採点しない (払わず合格)。モデルは鍵に入れず記録だけにするので、採点役を替えても前の判定を払わずに使う。再利用した判定は元の実行の id と、払わずに済んだ金額を持つ |
|
|
64
|
+
| 基準の版 | 基準のファイルの中身の SHA-256 から作る (`supported@bf57b3922ae8`)。中身を直せば版が変わり、前の判定も校正も使われない。版の付け忘れが起きない |
|
|
65
|
+
| 止める権限は校正済みの採点役だけ | 下の「採点役に止める権限を与える線」 |
|
|
66
|
+
|
|
67
|
+
## 採点役に止める権限を与える線
|
|
68
|
+
|
|
69
|
+
`on_fail="block"` のゲートでも、採点役の判定で止めるのは、次の 3 つを全部満たす時だけ。満たさない判定は「参考」として記録し (`advisory_reason` に理由)、止めずに進む。レポートでは `fail (uncalibrated)` のように、止めなかった理由つきで出る (ほかに `below the bar`・`panel labels only`・`other model`)。
|
|
70
|
+
|
|
71
|
+
| 条件 | 線 | 理由 |
|
|
72
|
+
|---|---|---|
|
|
73
|
+
| 人のラベルとの一致 | Cohen の κ が 0.6 以上 | Landis & Koch の区分で「かなりの一致 (0.61〜0.80)」の下の端。偶然の一致を除いて、人と 6 割以上そろう採点役でなければ、止めた理由を人に説明できない |
|
|
74
|
+
| ラベルの件数 | 100 件以上 | 一致率 0.85・偶然の一致 0.5 の時、κ の 95% 区間は 100 件で約 ±0.14、50 件では約 ±0.2 で、0.6 と 0.4 (中程度) の区別が付かない |
|
|
75
|
+
| 応えたモデル | 頼んだモデルと同じ | 校正して止める役を任せたのは頼んだ採点役。上限や障害で別のモデルが応えた判定に、その権限は移さない (応えたモデルに校正があっても同じ) |
|
|
76
|
+
|
|
77
|
+
- κ と件数は「基準の版 × 応えたモデル」の組ごとに測り、判定の記録に、その時点の κ と件数を残す。
|
|
78
|
+
- 線は引数で下げられない (ゲートを飛ばす引数を作らないのと同じ理由)。値は `gateledger.MIN_KAPPA` と `MIN_LABELS`。
|
|
79
|
+
- block のゲートで、前の判定が参考扱いしか無く、頼む採点役が校正済みなら、払って採点し直す (理由 `rejudge`)。頼む採点役も未校正なら、採点し直しても参考のままなので、前の判定を使う。
|
|
80
|
+
- ラベルの出どころ: 校正には、ラベルが人の物 (`human`) か、別のモデルが付けた物 (`model_panel`・silver。モデルが 1 つでも合議でも同じ扱い) かを残す。合議のラベルだけの校正では、人との一致を測っていないので止める権限を与えない。使う人が `Pipeline(..., allow_panel_calibration=True)` を明示した時だけ止められ、レポートには合議のラベルによる権限だと出る。
|
|
81
|
+
- 限界: ラベルを付けるのが 1 人なら、測れるのは「その人との一致」。κ の区間 (ラベルの単位で引き直すブートストラップ) も出すので、件数と一緒に見る。この区間はラベルを 1 件ずつ独立に引き直す。同じ問いから複数のラベルを取った時は狭く出るので、問いの単位の引き直しは使う側で行う。
|
|
82
|
+
|
|
83
|
+
校正は、ラベルの JSONL を台帳の判定と突き合わせて測る。人のラベルは 1 行に `{"judged_fp": "sha256:…", "human": "pass"}` (`human` は人の判定で `pass` か `fail`)、合議のラベルは `{"judged_fp": "sha256:…", "label": "pass", "source": "model_panel"}`。台帳に判定の無いラベルが 1 件でもあるか、1 つのファイルに出どころが混ざっていれば止める。
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
gateledger calibrate rubrics/supported.md labels.jsonl --model claude-sonnet-5-5 --dir runs
|
|
87
|
+
# 件数・一致率・κ と 95% 区間・混同行列・止める権限の有無を出し、runs/calibration/calibrations.jsonl に追記する
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 劣化の見張り
|
|
91
|
+
|
|
92
|
+
`gateledger watch` は、直近の期間の実行を、その前の期間 (基準) の実行と比べ、劣化の疑いがあれば 1 で終わる。cron や CI から回す。
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
gateledger watch --dir runs --window 1d --baseline 14d --pipeline diagnose
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
| 種類 | 合図 | 決め方 |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| 事実の変化 | 基準に無かった「応えたモデル」(ステージごと・採点役の基準ごと)。片方にしか無いステージ・ゲート・基準の版 | 検定せずにそのまま出す |
|
|
101
|
+
| 量の変化 | 1 実行あたりの金額 (ステージごと・採点役の基準ごと)・採点役の不合格率と 1 実行あたりの判定の数 (基準ごと)・機械的なゲートの不合格率・`ok` で終わらなかった実行の割合 | 実行を単位にした両側の並べ替え検定。Holm の補正で、1 回の比べの中でどれか 1 つでも誤って鳴る確率を α (既定 0.05) に抑える。差の 95% 区間 (ブートストラップ) と件数を添えて出す |
|
|
102
|
+
|
|
103
|
+
- 単位を実行にするのは、1 実行の中の判定どうしが似るため。判定を 1 件ずつ数えると誤報が増える。
|
|
104
|
+
- ゲートは最後の試行の判定を数える。免除と、採点しなかった枠 (`view` が `None`) は数えない。どの実行でも同じ値の合図は、入れ替えても変わらないので検定しない。
|
|
105
|
+
- 実行が少ないと、大きな変化しか揺れと分けられない。3 本対 3 本では、ゲートが全部合格から全部不合格に変わっても言えない (分け方が 20 通りしかない)。
|
|
106
|
+
- Python からは `watch(baseline, current)` に実行の列 (`Ledger.read` の記録の列) を 2 つ渡し、`WatchReport` を受け取る。
|
|
107
|
+
- 例のアプリで 1 度だけ試した (片側 10 実行)。わざと壊した 4 通りのうち 3 通りに気付き (正確な 95% 区間 19〜99%)、索引から 1 冊抜いた回は見逃した。何も変えない回は 1 回で、鳴らなかったが、誤報の率は言えない。[実験の記録](https://github.com/hakari-labs/maint-agent/blob/main/eval/watch_experiment.md)
|
|
108
|
+
|
|
109
|
+
## 作らない物
|
|
110
|
+
|
|
111
|
+
既にある道具で足りる所は作らず、そちらに乗る。
|
|
112
|
+
|
|
113
|
+
| やりたい事 | 乗る先 | 理由 |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| トレースを画面で見る・ダッシュボード | Langfuse・Phoenix など (OpenTelemetry で渡す) | 画面は既に良い物がある |
|
|
116
|
+
| プロンプトの版の管理 | git | ファイルで足りる |
|
|
117
|
+
| プロンプトやモデルの総当たりの比べ・レッドチーム | promptfoo | 設定ファイルで回す型は既に完成している |
|
|
118
|
+
| RAG の指標の定義 | Ragas の定義を借りる | 指標の名前と定義は業界で通じる物を使う |
|
|
119
|
+
| pytest 形式の出力のテスト | DeepEval | CI の中のテストは既にある |
|
|
120
|
+
| 1 回の呼び出しの出力の型の検証と聞き直し | 構造化出力・Pydantic | SDK が持っている |
|
|
121
|
+
| モデルや提供元をまたぐ振り分けと振り替え | LiteLLM | gateledger は応えたモデルを記録するだけ |
|
|
122
|
+
|
|
123
|
+
オーケストレーター (並列・途中からの再開・スケジュール) も作らない。`Pipeline` はステージを順に呼ぶだけで、既にあるオーケストレーターの中で呼ばれる側に留まる。
|
|
124
|
+
|
|
125
|
+
## 記録の形
|
|
126
|
+
|
|
127
|
+
正本は実行ごとに 1 つの JSONL (`runs/<run_id>.jsonl`)。1 行 1 件で、種類は `run_start` / `call` / `stage` / `gate` / `run_end`。採点役の呼び出しは `call` に `gate` が付き、採点役のゲートの `gate` は `judge` に判定を持つ。
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{"type":"call","run_id":"20261127T091403512Z-7f3a","stage":"answer","attempt":2,"reason":"repair",
|
|
131
|
+
"model_requested":"claude-opus-5-5","model_served":"claude-opus-5-5",
|
|
132
|
+
"usage":{"input":2200,"output":1000,"cache_read":5000,"cache_write":0},"cost_usd":0.0298,"latency_ms":8120}
|
|
133
|
+
{"type":"gate","run_id":"20261127T091403512Z-7f3a","stage":"answer","gate":"quotes_exist","on_fail":"repair",
|
|
134
|
+
"attempt":1,"artifact_fp":"sha256:9c1e…","verdict":"fail",
|
|
135
|
+
"findings":[{"cause":"燃料フィルターの詰まり","quote":"Fuel filter clogged with water","reason":"出典に無い引用"}]}
|
|
136
|
+
{"type":"gate","run_id":"20261127T091403512Z-7f3a","stage":"answer","gate":"supported","on_fail":"block",
|
|
137
|
+
"attempt":2,"artifact_fp":"sha256:41d0…","verdict":"fail",
|
|
138
|
+
"findings":[{"claim":"水抜きとエレメントの交換","reason":"次の確認が引用に無い"}],
|
|
139
|
+
"judge":{"rubric":"supported@bf57b3922ae8","judged_fp":"sha256:7a2b…",
|
|
140
|
+
"model_requested":"claude-sonnet-5-5","model_served":"claude-sonnet-5-5","score":0.5,"cost_usd":0.0039,
|
|
141
|
+
"reused_from":null,"saved_usd":null,"calibration":null,"advisory_reason":"not calibrated (agreement with human labels not measured)"}}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## なぜこの形なのか (実運用で起きた事)
|
|
145
|
+
|
|
146
|
+
作者は、LLM を多段につないで長い制作物を毎日自動で作る仕組みを、約半年動かしている。決まりはそこで実際に起きた事から来ている。
|
|
147
|
+
|
|
148
|
+
| 実運用で起きた事 | そこから決めた事 |
|
|
149
|
+
|---|---|
|
|
150
|
+
| 点検を各パイプラインの起動スクリプトへ手で書き足していたら、写した先にしか付いて行かず、同じ日に 3 本のうち 1 本で抜けた | 点検は 1 つの入口に集める。呼び忘れられない形にする |
|
|
151
|
+
| 「任意で飛ばせる点検」は、いつか必ず飛ばされたままになった | 飛ばす引数は作らない。通さずに進める時は、点検 1 つずつ明示し、記録に必ず出す |
|
|
152
|
+
| 後戻りできない高い段 (数時間かかる処理) の後で、入力だけで分かる欠陥に気付いた | 「その点検に何が要るか」で置き場を決める。入力だけで分かる点検は、高い段の前に全部置く |
|
|
153
|
+
| 料金表に無いモデルが 0 円で記録され、費用が見えなくなった | 料金表に無いモデルはエラーにする |
|
|
154
|
+
| 採点役の提供元が上限に達し、採点がどのパイプラインでも落ちた | 読めない応答 (JSON の崩れなど) は例外で止め、別のモデルで聞き直さない。使えない時に別のモデルへ替えるのは提供元や振り分けの道具に任せ、替わって応えたモデルの判定は、応えたモデルの名前で記録し、止める権限を与えない |
|
|
155
|
+
| 既定のモデル名が別の提供元の口に渡って落ちた | 提供元はモデル名から決める。頼んだモデルが実際に受け付けられたかを、応答の側で確かめて記録する |
|
|
156
|
+
| 採点役が替わるたびに全件を採点し直すと、料金が跳ねた | 判定の鮮度は「中身と基準の版」で決め、モデルは記録だけにする |
|
|
157
|
+
| 流し直しのたびに同じ依頼文が送られていたが、なぜ送ったかが残っておらず、無駄が見つけられなかった | すべての呼び出しに理由 (初回・直し・採点し直し) を付ける |
|
|
158
|
+
| 段ごとに使うモデルを決める表と、費用を抑える設定への切り替えを運用している。替えた時に質が保たれたかは、別の記録を突き合わせて見ていた | ステージごとのモデルは設定で替えられるようにし、質と金額を同じ記録から同じ表に出す |
|
|
159
|
+
|
|
160
|
+
gateledger と例のアプリ (maint-agent) は、2026-11-27〜28 の 2 日間に、コーディングエージェント (Claude Code) に実装・評価の実行・文書の下書きを任せて作った (各コミットの `Co-Authored-By`)。方針と設計の判断、それに結果の検収は作者がした。
|
|
161
|
+
|
|
162
|
+
## いまの範囲 (v0.1.0)
|
|
163
|
+
|
|
164
|
+
入っている物: Stage・Ledger (JSONL)・料金表・機械的なゲート (`block` / `repair` / `record` / `waive`)・採点役 (`Judge`) と判定の再利用・校正 (`gateledger calibrate`)・`gateledger report` (端末の表・SVG・HTML)・`gateledger watch` (劣化の見張り)・LLM の受け口 (偽物と Anthropic の SDK)。
|
|
165
|
+
|
|
166
|
+
まだ入っていない物: 既にあるオーケストレーターの中で記録とゲートだけを使う `with ledger.stage(...)`・振り替えの前後を分けた記録 (理由 `fallback`。いまは応えたモデルの単価で合計を計算する近似)・SQLite の索引 (判定の再利用は、いまは台帳の JSONL を読んで引く)・`cost` のコマンド・OpenTelemetry への出口。
|
|
167
|
+
|
|
168
|
+
レポートと CLI の出力は英語。ライブラリが投げる例外の文 (ラベルの不備・料金表に無いモデルなど) は、まだ日本語。変更の一覧は [CHANGELOG.md](CHANGELOG.md)。
|
|
169
|
+
|
|
170
|
+
## 開発
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
uv sync --extra dev
|
|
174
|
+
uv run pytest && uv run ruff check && uv run mypy # CI は同じ物を uv.lock の版で回す
|
|
175
|
+
python examples/diagnose.py # docs/report.svg と docs/report.html を作り直す
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## ライセンス
|
|
179
|
+
|
|
180
|
+
MIT
|