codex_quota_sponsorship
Generation-bound Codex quota sponsorship state.
Sponsorship grants access to an owner’s capacity as a routing fallback. It does not transfer ownership of the account generation, its credential home, or any account-management capability to the beneficiary.
- class codex_quota_sponsorship.CodexSponsorGrant(owner_subject, beneficiary_subject, account_id, owner_connected_at, granted_at)
Bases:
objectAn internal, generation-pinned fallback candidate.
- Parameters:
- exception codex_quota_sponsorship.CodexSponsorshipIdentityChanged
Bases:
CodexSponsorshipStoreUnavailableThe beneficiary’s canonical identity changed during a grant.
- exception codex_quota_sponsorship.CodexSponsorshipOwnerChanged
Bases:
CodexSponsorshipStoreUnavailableThe owner’s linked account generation changed during a grant.
Bases:
RuntimeErrorSponsorship state could not be verified or changed safely.
- class codex_quota_sponsorship.ResolvedCodexBeneficiary(user_id, target_alias, subject, unified_id)
Bases:
objectOne server-resolved Discord target without any credential material.
- codex_quota_sponsorship.beneficiary_grants_redis_key(beneficiary_subject)
- codex_quota_sponsorship.discord_identity_alias_key(user_id)
- async codex_quota_sponsorship.get_valid_codex_sponsors(redis, beneficiary_subject)
Return validated fallback candidates, pruning stale generations atomically.
Tuple order is deterministic for testing and transport, not a donor-draining priority. The inference layer must apply per-turn fair ordering and must fall back only after an effect-free self-account quota refusal.
- Return type:
- Parameters:
- async codex_quota_sponsorship.get_valid_codex_beneficiaries(redis, *, owner_subject, owner_account_id, owner_connected_at)
List raw Discord IDs currently authorized by one account generation.
The lookup verifies both sponsorship indexes atomically and prunes dangling records. Only owner-visible target IDs leave this boundary; account IDs, canonical beneficiary subjects, and provider identity never do.
- async codex_quota_sponsorship.grant_codex_sponsorship(redis, *, owner_subject, owner_account_id, owner_connected_at, beneficiary, granted_at=None)
Atomically add or refresh one generation-bound owner grant.
Falsemeans the exact grant already existed. The beneficiary’s own linked account remains primary; callers may use returned grants only as fallback candidates after self capacity is absent or exhausted.
- codex_quota_sponsorship.is_explicit_discord_user_id(value)
Accept only a raw Discord snowflake, never a mention or subject token.
- codex_quota_sponsorship.owner_grants_redis_key(owner_subject)
- async codex_quota_sponsorship.resolve_discord_beneficiary(redis, user_id)
Resolve a raw Discord ID to the same canonical subject used at ingress.
- Return type:
- Parameters: