oc_chat
Loading...
Searching...
No Matches
oc_chat.registry.auth.roles Namespace Reference

Classes

class  RoleGuard

Functions

bool _is_system_operation (str operation_type)

Variables

 SlotKind = str
 ALL_SLOT_KINDS = frozenset({"operator", "orchestrator", "worker"})
tuple SYSTEM_OPERATION_PREFIXES = ("migrate.", "heartbeat.")
 SYSTEM_OPERATION_TYPES = frozenset({"doctor.diagnose"})
dict ROLE_ALLOWSETS
tuple PREFIX_ALLOWSETS

Detailed Description

Runtime role guard for registry operations.

Purpose
-------
Map registry operation namespaces to the actor slot kinds that may author
them.

Responsibilities
----------------
- Keep the allow table in one auditable location.
- Raise typed role errors before any operation-log mutation starts.
- Provide an explicit system-actor bypass for enumerated internal rows.

Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
    L2 - lifecycle events
    L3 - semantic details
    L4 - deep tracing

Contracts
---------
- A role mismatch is not an auth failure and does not write ``auth_events``.
- Unknown test/private operation namespaces remain compatibility-allowed.

Dependencies
------------
- oc_chat.registry.errors (ActorRoleMismatchError raised on a role mismatch)
- oc_diagnostics (structured debug logging via _dbg)

Function Documentation

◆ _is_system_operation()

bool oc_chat.registry.auth.roles._is_system_operation ( str operation_type)
protected

Definition at line 119 of file roles.py.

Here is the caller graph for this function:

Variable Documentation

◆ ALL_SLOT_KINDS

oc_chat.registry.auth.roles.ALL_SLOT_KINDS = frozenset({"operator", "orchestrator", "worker"})

Definition at line 49 of file roles.py.

◆ PREFIX_ALLOWSETS

tuple oc_chat.registry.auth.roles.PREFIX_ALLOWSETS
Initial value:
1= (
2 ("plan.", frozenset({"operator", "orchestrator", "worker"})),
3 ("queue.", frozenset({"operator", "orchestrator"})),
4 ("roadmap_", frozenset({"operator", "orchestrator"})),
5 ("roadmap.", frozenset({"operator", "orchestrator"})),
6 ("round.", frozenset({"orchestrator"})),
7 ("migrate.", frozenset({"operator"})),
8 ("db.", frozenset({"operator"})),
9 ("doctor.", frozenset({"operator"})),
10 ("_test.", ALL_SLOT_KINDS),
11)

Definition at line 70 of file roles.py.

◆ ROLE_ALLOWSETS

dict oc_chat.registry.auth.roles.ROLE_ALLOWSETS
Initial value:
1= {
2 "auth.register_key": frozenset({"operator"}),
3 "auth.rotate_start": frozenset({"operator"}),
4 "auth.rotate_finalize": frozenset({"operator"}),
5 "auth.reset": frozenset({"operator"}),
6 "audit.override": frozenset({"operator", "orchestrator"}),
7 "audit.verify": frozenset({"operator", "orchestrator"}),
8 "db.archive_log.start": frozenset({"operator"}),
9 "db.archive_log.complete": frozenset({"operator"}),
10 "doctor.repair": frozenset({"operator"}),
11 "handover.accept": frozenset({"orchestrator", "operator"}),
12 "handover.initiate": frozenset({"orchestrator", "operator"}),
13 "handover.timeout": frozenset({"operator"}),
14 "role.handover.complete": frozenset({"orchestrator", "operator"}),
15 "role.handover.start": frozenset({"orchestrator", "operator"}),
16}

Definition at line 53 of file roles.py.

◆ SlotKind

oc_chat.registry.auth.roles.SlotKind = str

Definition at line 47 of file roles.py.

◆ SYSTEM_OPERATION_PREFIXES

tuple oc_chat.registry.auth.roles.SYSTEM_OPERATION_PREFIXES = ("migrate.", "heartbeat.")

Definition at line 50 of file roles.py.

◆ SYSTEM_OPERATION_TYPES

oc_chat.registry.auth.roles.SYSTEM_OPERATION_TYPES = frozenset({"doctor.diagnose"})

Definition at line 51 of file roles.py.