Resolve the effectiveContextPolicy 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 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.
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.