IB-WP-0019-T01: plan snapshot persistence

Every generate plan invocation now appends its compact summary to
output/budget/plans.yaml with a deterministic 12-char snapshot_id
hashed over the selection filters and the estimated call/token/cost
totals. Identical-fingerprint plans refresh the most recent entry's
recorded_at instead of stacking duplicates. Retention defaults to the
last 50 snapshots; older entries are pruned and counted on a top-level
pruned_count field.

The summary now echoes its input filters (chapter_filter, chunk_filter,
from_chapter, to_chapter) so reviewers can read the snapshot without
cross-referencing the CLI invocation.

New module src/infospace_bench/budget.py owns layer 1 (per-infospace
recording) of the IB-WP-0019 three-layer design; layer 2 still belongs
in llm-connect LLM-WP-0004 and layer 3 in state-hub.

99 tests pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-17 19:19:35 +02:00
parent df87e212a2
commit 182f7011bb
4 changed files with 337 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ related_workplans:
- IB-WP-0014
- IB-WP-0018
- LLM-WP-0004
state_hub_workstream_id: "063c6285-a56e-476b-8666-109d6fa35858"
---
# IB-WP-0019 — Budget and Usage Registry for Infospaces
@@ -76,8 +77,9 @@ Three layers, each owned by a different repo:
```task
id: IB-WP-0019-T01
status: todo
status: done
priority: high
state_hub_task_id: "7f1a4e0a-c1ad-49f3-aad1-6946de9b1219"
```
- Append the compact `plan_generation_summary` payload to
@@ -95,6 +97,7 @@ priority: high
id: IB-WP-0019-T02
status: todo
priority: high
state_hub_task_id: "a612f8d4-f96d-4fae-9aa6-66a7946414f5"
```
- On `run` and `resume` completion, scan the run-record YAML written by
@@ -116,6 +119,7 @@ priority: high
id: IB-WP-0019-T03
status: todo
priority: high
state_hub_task_id: "688c590d-8885-455e-bcf6-61409a45e001"
```
- Add `docs/model-rates.yaml` with `model -> {prompt_per_1k,
@@ -135,6 +139,7 @@ priority: high
id: IB-WP-0019-T04
status: todo
priority: medium
state_hub_task_id: "c6adc4fb-9062-4c81-a0b2-98d3166e047d"
```
- Compute a small variance record on each run: actual_calls /
@@ -154,6 +159,7 @@ priority: medium
id: IB-WP-0019-T05
status: todo
priority: medium
state_hub_task_id: "968bca1d-63ff-4818-83bb-ca314b1e633c"
```
- After each completed run, call state-hub `record_token_event` with
@@ -173,6 +179,7 @@ priority: medium
id: IB-WP-0019-T06
status: todo
priority: medium
state_hub_task_id: "7cb34bfc-c562-4dda-a6d4-b44158644e19"
```
- Add `infospace-bench budget list <workspace>` that walks
@@ -190,6 +197,7 @@ priority: medium
id: IB-WP-0019-T07
status: todo
priority: low
state_hub_task_id: "b97906e0-2835-4246-9868-840c02d64fae"
```
- Confirm `output/budget/` ends up inside the archive package built by