oc_chat
Loading...
Searching...
No Matches
oc_chat.registry.store_scope Namespace Reference

Classes

class  StoreScopeError

Functions

None assert_live_store (sqlite3.Connection conn)
None stamp_authored_projection (sqlite3.Connection conn)

Variables

str _AUTHORED_PROJECTION = "authored_projection"
str _LIVE_STORE = "live_store"

Detailed Description

Central store-scope guard for the OC Chat registry.

Purpose
-------
Enforce the V0.22 §5.3.1 / AC §8.57 contract: every live runtime command
(queue, round, auth) must refuse an ``authored_projection`` store with a
clear diagnostic, and the authored-projection rebuild must stamp the store
before any live open can succeed.

Responsibilities
----------------
- Expose ``assert_live_store(conn)`` — raises ``StoreScopeError`` when
  ``registry_meta.store_scope = 'authored_projection'``.
- Expose ``stamp_authored_projection(conn)`` — writes the scope stamp
  before the rebuild path returns a store handle.
- Tolerate pre-v0.3.2 databases (missing ``store_scope`` column) by
  treating them as ``live_store`` (lenient mode, dormant in v1).

Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
    L2 - store-scope lifecycle
    L3 - scope check details
    L4 - column presence probes

Contracts
---------
- Callers own connection and transaction lifecycle.
- ``assert_live_store`` is idempotent and read-only; safe to call in any
  transaction mode.
- ``stamp_authored_projection`` must be called before the temp store is
  returned to callers; the stamp is permanent for that DB file.

Dependencies
------------
- sqlite3 (the caller's connection and its OperationalError)
- oc_diagnostics (structured debug logging via _dbg)

Function Documentation

◆ assert_live_store()

None oc_chat.registry.store_scope.assert_live_store ( sqlite3.Connection conn)
Raise ``StoreScopeError`` if the connected store is an authored projection.

Silently returns for pre-v0.3.2 databases (missing ``store_scope`` column)
and for uninitialized databases (missing ``registry_meta`` row) — both are
treated as ``live_store`` in v1 (dormant guard per L-a §9.3).

Definition at line 69 of file store_scope.py.

◆ stamp_authored_projection()

None oc_chat.registry.store_scope.stamp_authored_projection ( sqlite3.Connection conn)
Write ``store_scope = 'authored_projection'`` to ``registry_meta``.

Called by the authored-projection rebuild path before returning a store
handle so that any subsequent live-command open fails fast.
Callers own the enclosing transaction.

Definition at line 93 of file store_scope.py.

Variable Documentation

◆ _AUTHORED_PROJECTION

str oc_chat.registry.store_scope._AUTHORED_PROJECTION = "authored_projection"
protected

Definition at line 54 of file store_scope.py.

◆ _LIVE_STORE

str oc_chat.registry.store_scope._LIVE_STORE = "live_store"
protected

Definition at line 55 of file store_scope.py.