Skip to content

Balance: say whose money the spent amount is - #322

Merged
fylorn merged 1 commit into
mainfrom
feat/spent-scope
Oct 10, 2026
Merged

fylorn merged 1 commit into
mainfrom
feat/spent-scope

Conversation

@fylorn

@fylorn fylorn commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Spent gains scope: "key" | "user" | null. The enterprise gateway's GET /v1/usage answers at the top level whether it is about the key itself (the key has limits of its own: the key's limits and the key's usage) or about the owner user as a whole (the key has none: the user's effective limits and the total across the user's keys); the thinkwatch reader puts that scope on the spent amount. Other sources leave it empty. Part of protocol 46, unreleased.

Checks: cargo clippy --workspace --all-targets -D warnings, cargo test -p tw-gateway, cargo test -p tw-api --features ts, cargo test -p twcore --test msg_codes.

🤖 Generated with Claude Code

The enterprise gateway's usage answer now says at the top level whether
it is about the key (the key has limits of its own) or the owner user
as a whole (it has none). `Spent` gains `scope` and the enterprise
reader fills it from that field; other sources leave it empty. A key
holder can then tell "this key spent $3.50" from "the account spent
$3.50 across its keys".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fylorn
fylorn merged commit c6d8f6c into main Oct 10, 2026
5 checks passed
@fylorn
fylorn deleted the feat/spent-scope branch October 10, 2026 15:09
This was referenced Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant