Repository navigation
Costs view: notional cost of agent chats and subagents (REQ-COSTS-001) - #77
Merged
Merged
Conversation
…TS-001) A workstation job (smithy pe-costs) extracts token counts from the agent transcripts, prices them with a versioned list-price table and sends one report. The Costs view shows, labelled "notional list price, not billed": notional $ per day for the last 30 days, the top sessions, repositories and models, subagent spend by task category, and the share of subagent calls and dollars on a cheaper tier than the caller. GET /api/costs serves the report with its age. Ingest: [hub] costs_file, a file the job copies to the ground station over ssh and warte re-reads when its mtime changes; and POST /api/costs behind the existing bearer-token auth (usable once #17 issues tokens), with an 8 MiB body limit on that route. The read API is unauthenticated (#46), so a report with unknown fields (a task description), free text in a name, or a bad amount is rejected and nothing from it is stored. The reason shown never quotes the input. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G5qpB7zvxLvdrvn5YRyj4R
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.
A Costs view and
GET /api/costs. They show what agent chats and subagents cost as notional list prices, not billed: list prices applied to the token counts in agent transcripts. The report comes from a workstation job in smithy that extracts and prices the transcripts.The view
Ingest, and a deviation from the plan. The plan was a POST pushed with curl. But every POST already passes warte's bearer-token auth (REQ-API-002), and nothing issues tokens yet (#17). Opening this one route would break REQ-API-002 and let anyone on the LAN forge the view. So the report has two ways in, with the same checks on both:
[hub] costs_file(optional): the job copies its report there over ssh, the channel the scheduled jobs already use from launchd. warte re-reads the file when its mtime changes, and the mtime becomesreceived_at. The path is deployment config.POST /api/costs: behind the existing auth, so it works once Feature: warte-sync skill (agents sync with warte on startup) #17 lands. It has an 8 MiB body limit on this route, because a report carries every session.Privacy. The read API is unauthenticated (#46), so a report may hold numbers, model ids, repository names and categories only.
deny_unknown_fields, and every string must match a short character class with no spaces.Tests (
tests/costs.rs, synthetic reports)report: nulland an empty-state view.descriptionfield, apromptfield, text in a name, a path as a repo, a negative amount, a missing label, a wrong schema, a bad window name. Nothing is stored for any of them.Other checks
/api/costs(inopenapi.json, GET 200).Negative controls (each restored by re-editing; afterwards the suite exits 0):
deny_unknown_fieldsonSubagent: exit 101;Integration: the real extractor's report (about 0.9 MB) was served locally through
costs_file. It passed validation and the view rendered; no figures are given here.cargo fmt --check,cargo clippy --all-targets -D warningsandcargo testare green locally.🤖 Generated with Claude Code
https://claude.ai/code/session_01G5qpB7zvxLvdrvn5YRyj4R