Evaluator payment-scope/v1
Identifier: https://probityai.github.io/agent-evidence-vectors/evaluator/payment-scope/v1
This evaluator judges one payment against the scope a principal granted to an agent. A record that names this identifier in its evaluator member can be re-derived by any party: given the same inputs, every conforming implementation returns the same verdict and the same first failing dimension. The identifier never changes meaning. A change to the function is published as v2 under a new identifier, and v1 stays as written.
The vocabulary terms that carry it are evaluator and asserted_verdict.
Inputs
The scope, as granted by the principal:
| member | type | meaning |
|---|---|---|
currency |
string | ISO 4217 alphabetic code of the ceiling: exactly three uppercase letters A to Z |
amount_ceiling_minor |
integer, 0 to 2^53-1 | the largest single payment allowed, in minor units of currency |
merchants |
array of strings | the payees allowed, compared byte for byte |
expires_at |
integer, 0 to 2^53-1 | seconds since the Unix epoch; a payment at this instant is still inside the scope |
actions |
array of strings | the action kinds allowed (for example pay), compared byte for byte |
single_use |
boolean | whether the scope allows one payment only |
The payment, as recorded:
| member | type | meaning |
|---|---|---|
currency |
string | ISO 4217 alphabetic code of the payment: exactly three uppercase letters A to Z |
amount_minor |
integer, 0 to 2^53-1 | the amount, in minor units |
merchant |
string | the payee |
at |
integer, 0 to 2^53-1 | seconds since the Unix epoch at which the payment was authorized |
action |
string | the action kind |
prior_uses |
integer, 0 to 2^53-1 | how many payments the same scope had already authorized |
An input that is missing, of another type, or outside its range makes the record malformed; the evaluator never fills a default. A boolean is never an integer, an integer is never a boolean, and an array of strings given as one string is of another type (matching inside it by substring is the defect this rule closes). A verifier refuses a malformed record with evaluator-inputs-malformed and returns no verdict for it. Amounts are never converted between currencies.
Output
within, or outside together with the first failing dimension. The dimensions are checked in this fixed order, and the first that fails is reported:
currency: the payment's currency differs from the scope's.amount:amount_minoris greater thanamount_ceiling_minor. A payment exactly at the ceiling is within.merchant:merchantis not inmerchants.expiry:atis later thanexpires_at.action:actionis not inactions.single_use:single_useis true andprior_usesis greater than 0.
Checking a record that asserts a verdict
A record may carry an asserted verdict next to this identifier. A verifier recomputes the verdict from the recorded inputs and compares. The asserted verdict is never an input: a key that is entitled to sign can sign a verdict its own inputs refute, and only the recomputation shows it. On a difference the verifier refuses the record with asserted_verdict_contradicted, whoever signed it. An asserted verdict is one of the two output strings within or outside, compared byte for byte. A record that names this evaluator and carries no asserted verdict, or carries any other value (Within, ["within"], true), is refused with no-asserted-verdict or asserted-verdict-not-an-evaluator-output, never reported as contradicted: there is no claim to contradict. A verifier that does not hold this evaluator reports evaluator_unknown and an indeterminate result, and never substitutes another function.
Worked example
A scope of 10 minor units (USD 0.10) and a recorded payment of 500 minor units (USD 5.00) to an allowed merchant, inside the expiry, for an allowed action:
{"scope": {"currency": "USD", "amount_ceiling_minor": 10, "merchants": ["m-1"], "expires_at": 2000,
"actions": ["pay"], "single_use": true},
"payment": {"currency": "USD", "amount_minor": 500, "merchant": "m-1", "at": 1000, "action": "pay",
"prior_uses": 0}}
The evaluator returns outside, first failing dimension amount. The payment itself may be valid and correctly signed; the evaluator answers a different question, whether the agent stayed inside the scope it was given.
Reference implementation
payment_scope_v1 in the agent-evidence-vocabulary Python package (packages/vocabulary/registry.py in this repository), held to a table of cases by packages/vocabulary/scripts/test_evaluation_claim.py.