Repository navigation
π± tokens: per-issue/PR/head-SHA launch attribution over the token collector - #12164
Conversation
β¦lector The governor and review-swarm kick paths now record which issue / PR / head SHA each delivered kick was launched for (tokens.LaunchRecord, durable at /data/launch-attribution.jsonl, attached to the existing Collector via SetLaunchLog/RecordLaunch/Launches). A cached join in pkg/dashboard/collect/launch_cost.go places the existing per-message usage timeline against those launches using the same pricing table, window, and unattributed/backend_unsupported buckets as /api/repo-cost, and serves GET /api/launch-cost with per-launch and per-ref figures (repeat-spend launches counter, distinct head SHAs, undivided launch_* and even-split share_* totals, ?ref= filter). The dashboard Cost panel gains a 'cost by work item' table. Attribution only: no new budget gate; the governor window budget stays the single enforced budget (RFC #12134, constraint D). Closes #12128 Refs #12134 Signed-off-by: Andrew Anderson <andy@clubanderson.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
Shared CI baseline triage: Separately, PR-local (FIX_DIFF): π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 |
Adds pkg/dashboard/collect tests for LaunchCostCollector persistence (missing/corrupt/zero/unwritable), Start/Snapshot, and empty-ref launch shapes so the package stays above its coverage floor. Docs now state the actual 14-day repo-cost window. Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Signed-off-by: Andrew Anderson <andy@clubanderson.com>
|
merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 260c2d1. |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Closes #12128
Refs #12134
cc @mrbobbytables
What
Per-issue / PR / head-SHA launch attribution, built on the existing token collector, pricing table, and repo-cost join β no parallel budget gate (RFC #12134, constraint D).
pkg/tokens/launch.go:LaunchRecord{Agent, Trigger, Repo, Refs[], LaunchedAtMs}+LaunchRef{Ref, Kind issue|pr|external, Repo, Number, HeadSHA}. Durable bounded JSONL at/data/launch-attribution.jsonl(ring of 4000, compacted in place), attached to the existingtokens.CollectorviaSetLaunchLog/RecordLaunch/Launches. Summed session fields are untouched.cmd/hive/launch_attribution.go+ the existingonDeliveredseam inrunEvalCycle: governor kicks record the issue refs the scheduler put in the message; review-swarm kicks record the PR with its head SHA (review-<kind>trigger).pkg/dashboard/collect/launch_cost.go: pureComputeLaunchCost(summary, launches, now). SameUsageEventtimeline, sameEstimateCostUSD, same 24h window and mandatoryunattributed/backend_unsupportedbuckets as/api/repo-cost; invariant Ξ£ by_launch + buckets == total. A launch is an opening event: usage is owned by the latest launch for the same agent until the next launch or a 6h horizon. Per-ref:launches(repeat-spend counter, includes kicks that produced no usage),head_shas, undividedlaunch_tokens/usd(upper bound) and even-splitshare_tokens/usd; USD isnullwhen nothing attributed.LaunchCostCollector(cached, persisted like repo-cost) andGET /api/launch-cost(?ref=owner/repo#Nnarrows; totals stay whole-window). Not-ready reportsready=falsewith empty lists, never a fabricated$0.00. Route name deliberately avoids the removed/api/issue-costsstub (π± fix: remove stub per-issue cost featureΒ #4838) and is real data from the kick path.src/docs/token-tracking.md(new Launch attribution section),src/docs/api-reference.md(+ citation--fix),dashboard/openapi.json, changelog fragment.Tests
pkg/tokens: ref parsing, PR ref head SHA, JSONL persist/restore, ring bound + compaction, nil-safe collector hooks.pkg/dashboard/collect: partition invariant across every branch (leading, horizon, lonely agent, backend_unsupported, no-timeline Claude), per-ref share vs launch totals, repeat heads on one PR, launched-without-usage counting, attribution rules table.pkg/dashboard: handler snapshot +?ref=filter + persistence round-trip, not-ready honesty, inline fallback reading the collector's launch log; OpenAPI parity + style ratchet green.cmd/hive:launchRecordForKickgovernor and review shapes; boot-collectors test updated for the new collector.Validation:
gofmt(new files clean),go vet,go build ./...,go test ./pkg/proxy/... ./pkg/tokens/... ./pkg/dashboard/... ./cmd/hive/all green.