Skip to main content

Module contexts

Module contexts 

Source

Structs§

ContextRecord

Constants§

CONTEXT_KEY_BASE
Base path for application context keys.

Functions§

allocate_context_index
Allocate the next context index and return (index, base_path).
create_context
Create a new top-level application context and store it.
delete_context
Delete a context by ID.
effective_context_policy
Resolve the effective ContextPolicy for context_id by intersecting the policies of every context on the path root→leaf (field-wise, additive narrowing — see ContextPolicy docs). Contexts with no policy (or a missing record) contribute nothing; a chain that constrains nothing resolves to ContextPolicy::unrestricted, i.e. today’s behaviour.
enforce_daily_quota
Enforce a per-day operation quota for a context (the quotas arm of ContextPolicy). Atomically counts this operation in the current UTC day and returns Forbidden once the ceiling is reached. Counters are keyed by day (quota:{context}:{op}:{YYYY-MM-DD}) in the contexts keyspace, so they roll over automatically and stale days are inert (a future sweep can prune them). allocate_u32 is 0-indexed, so the call that returns limit is the (limit+1)-th — rejecting it allows exactly limit operations per day.
get_context
Retrieve a context by ID.
list_contexts
List all context records.
store_context
Store (create or overwrite) a context record.
store_new_context
Store a NEW context record, claiming the id atomically. Returns false (storing nothing) when the id is already taken — creation paths must treat that as a Conflict, never overwrite: last-writer- wins on a context record silently re-points its BIP-32 base path.
validate_slug
Validate a single context id segment.