gateway: phase-7 endpoints, run cap meters, tygo in CI - #1686
Merged
Merged
Conversation
Cap meters (phase 9): the accumulator records each chain layer's caps,
exp and parent link in meta:run:<id> and indexes the leaf run under
runs:user:<user>; /runs/:id/state serves max_cost_usd / max_steps /
ancestors, and RunDetail draws one cost + one steps meter per
budgeted run in the chain (badge "exceeded" at/over any cap).
Phase 7 remainder: spend/by-{session,model}, histogram/{tokens,latency},
sessions/:id{,/summary}, users/:id/{spend,quota}, agents/:name/spend.
Window/bucket params take the full Bifrost duration vocabulary
(rolling); token totals are filled in the existing rollups.
logstore_client_test.go plus per-handler tests.
tygo: types.ts is generated (byte-stable, tygo v0.2.21 pinned);
non-struct types live in manual.ts. New gateway-check workflow runs
go build/vet/test, make tygo-check and make ui-build on gateway/**.
Supersedes #1563.
Docs: phase 7 inventory, vocabulary and checklist match the code;
by-realm dropped from phases 7/8; phase 9 tygo section; UI AGENTS.md.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three stakgraph-only gaps from the gateway gap list, in one branch because they share the tygo-generated
types.ts:1. Cap meters on run detail (phase 9)
bifrost:meta:run:<id>per chain layer (max_cost_usd,max_steps,exp,parent;agent/useron the leaf) and indexes the leaf underbifrost:runs:user:<user>(ZSET scored by exp). Same TTL axis ascost:run; idempotent HSET on every call.GET /_plugin/runs/:id/stategainsmax_cost_usd/max_steps(null = no cap),exp,agent_name,user_id, andancestors[](nearest parent first, bounded walk, cycle-safe).enforce_budgets.2. Missing phase 7 endpoints
/_plugin/spend/by-session,/_plugin/spend/by-model/_plugin/histogram/tokens,/_plugin/histogram/latency(nearest-rank p50/p95/p99 + sample count)/_plugin/sessions/:id,/_plugin/sessions/:id/summary— onmetadata.session-id, not Bifrost's native session routes (those aliasparent_request_id)/_plugin/users/:id/spend,/_plugin/users/:id/quota(Bifrost customer budget + in-flight runs from the new index; degrades cleanly without a Customer or without Redis)/_plugin/agents/:name/spend1d,1w,1M, …), rolling from now; the SPA picker keeps its subset. Token totals are now filled in the existing rollups (they were left at 0).logstore_client_test.goadded; handler tests for every new route. The e2e test against a real Bifrost is still not in CI (scripts/smoke-test.shremains manual).3. tygo in CI (phase 8 ship gate)
types.tsis now genuinely generated (make tygo, byte-stable); the non-struct types moved toui/src/api/manual.ts(unions,ApiError, trust mirrors, Bifrost chat/usage shapes)..github/workflows/gateway-check.yml:go build/vet/test ./internal/...,make tygo-checkwith tygo pinned at v0.2.21,make ui-build.Docs: phase 7 inventory/vocabulary/checklist brought in line with the code; by-realm references dropped from phases 7/8; phase 9 tygo section updated; UI AGENTS.md updated.
Test plan
go test ./internal/...green (auth: meta/index/lineage; adminapi: every new route, vocabulary, quota degradation, cap/ancestor state; logstore client)go vet ./internal/...,go build ./internal/...make tygotwice → identical output;tsc -b;vite build/_pluginbackend: chained meters (warning tones, capless steps, killed ancestor), capless fallback, over-cap badge + note