codex_sponsor_controls
Owner-defined model locks and rolling prompt limits for shared Codex quota.
The controls in this module are deliberately scoped to one validated sponsorship edge. They never constrain a beneficiary’s own linked account, and every provider attempt revalidates the live grant plus policy revision before reserving rate-limit capacity.
Bases:
RuntimeErrorSponsor controls could not be read or changed safely.
- class codex_sponsor_controls.SponsorPromptAuthorization(status, count=0, reservation=None)
Bases:
object- Parameters:
status (Literal['allowed', 'rate_limited', 'changed', 'revoked'])
count (int)
reservation (SponsorPromptReservation | None)
- reservation: SponsorPromptReservation | None
- class codex_sponsor_controls.SponsorPromptReservation(rate_key, member, added)
Bases:
objectA rolling-window reservation made immediately before a provider call.
- class codex_sponsor_controls.SponsorQuotaPolicy(locks=(), rate_limits=(), revision='')
Bases:
objectOne generation-bound sponsor policy for one beneficiary.
- Parameters:
- async codex_sponsor_controls.authorize_sponsor_prompt(redis, grant, policy, *, model_alias, turn_id, now_ms)
Revalidate policy and atomically reserve one rolling-window prompt.
- Return type:
- Parameters:
redis (Any)
grant (CodexSponsorGrant)
policy (SponsorQuotaPolicy)
model_alias (str)
turn_id (str)
now_ms (int)
- codex_sponsor_controls.effort_is_allowed(policy, model_alias, effort)
Return whether one pair survives the owner’s model ceiling.
- Return type:
- Parameters:
policy (SponsorQuotaPolicy)
model_alias (str)
effort (str)
- async codex_sponsor_controls.load_sponsor_policy(redis, grant)
Load the policy for an exact live grant generation.
A hash from an older grant generation is treated as absent. A malformed hash claiming to govern the current grant fails closed.
- Return type:
- Parameters:
redis (Any)
grant (CodexSponsorGrant)
- async codex_sponsor_controls.release_sponsor_prompt(redis, reservation)
Refund a newly-added reservation after a proven effect-free refusal.
- Return type:
- Parameters:
redis (Any)
reservation (SponsorPromptReservation | None)
- async codex_sponsor_controls.set_sponsor_model_lock(redis, grant, *, models, maximum_effort)
- async codex_sponsor_controls.set_sponsor_rate_limit(redis, grant, *, model, daily_limit)
- Return type:
- Parameters:
redis (Any)
grant (CodexSponsorGrant)
model (str)
daily_limit (int | None)
- codex_sponsor_controls.sponsor_policy_redis_key(owner_subject, beneficiary_subject)