PRD: Egress control plane — metering, budgets, and forced cutoff #285

Open
didericis-claude wants to merge 1 commits from prd-egress-control-plane into main
Collaborator

Closes #251.

PRD: 99ba532783/docs/prds/prd-new-egress-control-plane.md

Summary

Drafts the design for an out-of-band egress enforcement & cost-control plane (Plane A), distinct from the agent-initiated supervise sidecar (Plane B, PRD 0013). The egress proxy meters authoritative token usage per bottle/provider, budgets are evaluated with agent → bottle → parent → global precedence, and budget exhaustion fires a per-bottle cutoff policy (cutoff / freeze / kill) host-side — never via the supervise queue.

Captures the decisions from the #251 thread:

  • SQLite, now but narrow. New host-level ledger at ~/.bot-bottle/bot-bottle.db behind a thin repository API; sqlite3 is stdlib so it doesn't break the stdlib-first stance. Existing per-bottle flat-file state is not migrated.
  • Gate vs. account split. Accounting uses authoritative response usage (via the existing egress response hook, with SSE final-usage tailing); a count_tokens estimator/endpoint is reserved for an optional pre-flight gate.
  • ~/.bot-bottle/settings.yml (host root, not per-repo) for budgets keyed by provider + default shutdown policy, within the yaml_subset.py subset.
  • Host-level controller + TUI dashboard, host-only — remote control / authn deferred.

Open questions

Carried in the PRD: SSE usage-tailing robustness, mid-request budget crossing vs. pre-flight gate, provider↔host attribution, parent-bottle budget semantics for extends chains, and the dashboard↔controller transport seam.

Closes #251. PRD: https://gitea.dideric.is/didericis/bot-bottle/src/commit/99ba5327830363cd2cc2a081eca0e6cd0c1e2076/docs/prds/prd-new-egress-control-plane.md ## Summary Drafts the design for an **out-of-band egress enforcement & cost-control plane** (Plane A), distinct from the agent-initiated supervise sidecar (Plane B, PRD 0013). The egress proxy meters authoritative token usage per bottle/provider, budgets are evaluated with **agent → bottle → parent → global** precedence, and budget exhaustion fires a per-bottle **cutoff policy** (`cutoff` / `freeze` / `kill`) host-side — never via the supervise queue. Captures the decisions from the #251 thread: - **SQLite, now but narrow.** New host-level ledger at `~/.bot-bottle/bot-bottle.db` behind a thin repository API; `sqlite3` is stdlib so it doesn't break the stdlib-first stance. Existing per-bottle flat-file state is **not** migrated. - **Gate vs. account split.** Accounting uses authoritative response `usage` (via the existing egress `response` hook, with SSE final-usage tailing); a `count_tokens` estimator/endpoint is reserved for an optional pre-flight gate. - **`~/.bot-bottle/settings.yml`** (host root, not per-repo) for budgets keyed by provider + default shutdown policy, within the `yaml_subset.py` subset. - **Host-level controller + TUI dashboard**, host-only — remote control / authn deferred. ## Open questions Carried in the PRD: SSE usage-tailing robustness, mid-request budget crossing vs. pre-flight gate, provider↔host attribution, parent-bottle budget semantics for `extends` chains, and the dashboard↔controller transport seam.
didericis-claude added 1 commit 2026-06-25 19:16:00 -04:00
Out-of-band egress enforcement & cost-control plane: meter token usage
at the egress proxy, evaluate budgets with agent→bottle→parent→global
precedence, and force cutoff/freeze/kill without the agent in the loop.
Introduces a host-level SQLite ledger behind a thin repository API and a
host-only TUI dashboard. Closes the design discussion on #251.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NkwFXLFff9PYPy4wgVBJp9
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin prd-egress-control-plane:prd-egress-control-plane
git checkout prd-egress-control-plane
Sign in to join this conversation.