Skip to main content

hyprstream_pay/
capability.rs

1//! Capability model for the settlement/tariff protocol (#1399).
2//!
3//! These are the JWT scope strings that gate the RPC handlers. The
4//! `#[authorize]` macro on the AGPL service impl references these constants.
5//!
6//! Convention: `ai.hyprstream.pay.<domain>.<action>` — matching the
7//! `ai.hyprstream.ledger.*` lexicon already in use.
8
9/// Scope: invoke `SettlementIssuer::issue`. This is the purchased-credit
10/// issuance path — it requires a verified settlement attestation AND this
11/// capability. Neither alone is sufficient.
12pub const SCOPE_SETTLEMENT_ISSUE: &str = "ai.hyprstream.pay.settlement.issue";
13
14/// Scope: invoke `SettlementIssuer::status` (query a prior issuance's
15/// outcome for retry/recovery).
16pub const SCOPE_SETTLEMENT_STATUS: &str = "ai.hyprstream.pay.settlement.status";
17
18/// Scope: invoke `TariffProvider::quote` (get a priced quote for a resource).
19pub const SCOPE_TARIFF_QUOTE: &str = "ai.hyprstream.pay.tariff.quote";
20
21/// Scope: invoke `TariffProvider::resolve_unit` (resolve a unit reference for
22/// cross-cell federation).
23pub const SCOPE_TARIFF_RESOLVE: &str = "ai.hyprstream.pay.tariff.resolve";
24
25/// All settlement/tariff scopes, for registration with the scope registry.
26pub const ALL_SCOPES: &[&str] = &[
27    SCOPE_SETTLEMENT_ISSUE,
28    SCOPE_SETTLEMENT_STATUS,
29    SCOPE_TARIFF_QUOTE,
30    SCOPE_TARIFF_RESOLVE,
31];