Uh oh!
There was an error while loading. Please reload this page.
feat(ledger): operator-authed POST /.admin/tokens/debit - #9
Merged
Conversation
Adds the metering counterpart of mint: an operator-authed endpoint that debits a WebID's MIND balance, returning 402 insufficient_balance when the owner is out of MIND. Wraps the existing `debit` trait primitive (balance check + append-only debit entry) — the same shape as admin_mint. External LLM chokepoints (Slides' /api/generate, the Builder git bridge) spend a user's free allotment on their behalf with the operator token, rather than requiring a user-signed transfer. The 402 is their signal to fall back to the user's own key. Regenerates docs/openapi.json (drift gate). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 20, 2026
Review follow-up — keep the lib.rs route inventory in sync with the new endpoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 freeto 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.
What
Adds
POST /.admin/tokens/debit— the metering counterpart ofmint. Operator-authed; debits a WebID's MIND balance and returns402 insufficient_balancewhen out of MIND. Thin wrapper over the existingdebittrait primitive (same shape asadmin_mint).Why
mind-node has no external LLM-proxy endpoint — metering only happens internally for pod scripts (
Pod.llm). The Builder/Slides Next apps can't use that path, so they meter via explicit debit: check balance (GET /.admin/tokens?owner=), then debit by WebID after each LLM call.mintalready covers the signup grant. This is the unblocker for the free-LLM onboarding allotment (Builder + Slides).Tested
cargo test -p solidrs-ledger20/20 pass; clippy + rustfmt clean.docs/openapi.jsonregenerated; drift gate (scripts/gen-openapi.sh --check) green.🤖 Generated with Claude Code