Skip to content

Replace budget_consumed records with a single claim for the presented token's spend #120

Closed

Description

@dickhardt

Problem

budget_consumed is an array of {jti, consumed} records covering up to 20 recent grants. Walking through what an issuer actually does with them: in the steady re-authorization loop, the presented token's figure is the only new information. Every prior record duplicates an actual the issuer already holds — each was delivered when that token was retired. The gap cases (an agent that crashed holding a token, a resource token lost before reaching the PS) are made safe by conservative accounting (#unreported-allocations) and recoverable without the records: the PS has the usage endpoint, and an AS has out-of-band access to the resource's figures — it sits in the resource's trust domain.

The prior records also carry the design's two real costs. Up to a kilobyte rides inside the AAuth-Requirement header on the 401 path. And they are the privacy exposure the security considerations flag: the agent relays and reads records naming the person's other agents' tokens. The presented token's own spend exposes nothing — the agent watched cost and remaining in AAuth-Budget the whole time.

Proposal

Replace the array with a single claim: what the resource has metered to date against the auth token presented on the request this resource token answers. No list, no jti member. A figure for an unexpired token is a snapshot, superseded by a later report. Long-horizon and multi-grant history moves entirely to the usage endpoint, which already serves it.

Open question: attribution without a jti

The resource token does not name the presented auth token anywhere. presented_jti is the jti of the person token whose verification established ps and sub — on a step-up it is not the presented credential (the #95 rename exists because of exactly this), and it is load-bearing for mission-stripping detection, so it cannot be overloaded. Two options:

  1. Contextual attribution. The issuer matches the figure to its newest live allocation for (sub, aud, mission_s256, agent_jkt). Ambiguous only while two allocations for one key overlap (the renewal window); an unattributable figure is discarded and the conservative rule stands, so ambiguity degrades safely.
  2. Carry the auth token's jti beside the amount. Exact attribution, still one record rather than a list — but back to an object.

A third fact bears on the choice: the proactive path. An agent re-authorizing at the authorization endpoint before a 401 presents no auth token at all, so under either option the claim is absent there and the issuer's own channels cover it.

Context

Arose from working through the AS ledger in four-party access. The editor's copy currently holds the intermediate step — the presented token's record first in the array, plus (#unreported-allocations) — and this issue is whether to go the rest of the way. The question is also going to Regent Protocol, who run both sides in production.

Activity

  1. added
    budgets
    on Sep 1, 2026
  2. dickhardt commented on Sep 4, 2026

    @dickhardt
    OwnerAuthor

    Resolution, in PR #133 (stacked on #128):

    budget_consumed becomes a single {jti, consumed} object for the auth token presented on the request the resource token answers. The jti stays, for the reason Regent gave: an issuer holding several live allocations for one agent cannot attribute an amount alone, and attributing by agent key would make the conservative fallback the normal case for exactly the agents doing concurrent work. The per-key usage query answers what the sibling records used to.

    One thing working through the issuer's ledger added, which the array never stated: when a record is final. A record is as of the resource token's iat. If that is at or after the auth token's exp, it is the token's final figure and the issuer may release the difference. If the token was still live when the record was stated, it is a snapshot and releases nothing, because the agent can keep spending. That is the insufficient-budget case: the spec leaves the old token spendable (retry a smaller request on it), so a record on that challenge cannot free the old token's remainder. An issuer that released on it would let the agent spend old remainder plus new allocation. A randomized simulation in the access module caught exactly this.

    Still worth confirming with Regent before this closes: whether their PS releases on a record for an unexpired token. Their public resource middleware (regent-httpsig) leaves the old token fully spendable after a refusal, and the PS side is not published.

    Residual doubt, on the record: it costs little, but under the settlement model in #133 the issuer settles expired allocations from the usage reading in aggregate, so the record's value is that it arrives early and exact, not that it is necessary.

  3. dickhardt commented on Sep 20, 2026

    @dickhardt
    OwnerAuthor

    Done in the budgets editor's copy: budget_consumed is a single consumption record for the auth token presented on the request the resource token answers, not an array of up to 20 grants. The open question resolved as option 2 — the record keeps jti beside consumed, so attribution is exact and long-horizon history lives at the usage endpoint. A resource MUST NOT include it without budget in the same token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    budgets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions