|
oc_chat
|
Classes | |
| class | CheckpointError |
| class | CheckpointSignatureError |
| class | CheckpointWriteResult |
| class | CheckpointImportResult |
Functions | |
| dict[str, object] | export_checkpoint (Registry registry, *, bool sign=False) |
| CheckpointWriteResult | write_checkpoint (Registry registry, *, Path out, bool sign=False) |
| CheckpointImportResult | import_checkpoint (SQLiteBackend backend, *, Path checkpoint_path, bool skip_signature_check=False) |
| bool | verify_checkpoint (Mapping[str, object] checkpoint, *, bool skip_signature_check=False) |
| dict[str, list[dict[str, object]]] | _export_tables (Registry registry) |
| Path | _build_temp_database (SQLiteBackend backend, Mapping[str, object] checkpoint) |
| None | _insert_rows (sqlite3.Connection conn, str table, list[object] rows) |
| dict[str, object] | _signature_block (Registry registry, Mapping[str, object] payload) |
| str | _signature_hex (Mapping[str, object] payload, *, bytes|None key=None) |
| dict[str, object] | _payload_without_signature (Mapping[str, object] payload) |
| tuple[bytes, str] | _resolve_checkpoint_key () |
| str|None | _active_operator_hmac_key_id (Registry registry) |
| bytes | _decode_key (bytes raw) |
| dict[str, object] | _read_checkpoint (Path path) |
| None | _validate_checkpoint_shape (Mapping[str, object] checkpoint) |
| list[str] | _table_names (sqlite3.Connection conn) |
| list[str] | _table_columns (sqlite3.Connection conn, str table) |
| str | _quote_identifier (object value) |
Variables | |
| int | CHECKPOINT_VERSION = 1 |
| str | CHECKPOINT_SCHEMA_VERSION = "v0.2.3" |
| str | SIGNATURE_ALGORITHM = "HMAC-SHA256" |
| str | CHECKPOINT_KEY_ENV = "OC_REGISTRY_CHECKPOINT_KEY_PATH" |
| str | KEYRING_SERVICE = "oc_chat:registry:checkpoint" |
| str | KEYRING_USERNAME = "key" |
Signed JSON checkpoint export/import for the registry.
Purpose
-------
Provide canonical JSON checkpoint export/import with an HMAC signature block
for cross-machine registry transfer.
Responsibilities
----------------
- Export every registry table into deterministic canonical JSON.
- Sign and verify checkpoint payloads with HMAC-SHA256.
- Restore verified checkpoints by building a temporary SQLite database and
replacing the target through the backend restore hook.
Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
L2 - checkpoint lifecycle events
L3 - signature and table-count details
L4 - per-table export/import tracing
Contracts
---------
- Signatures are verified before any target registry state changes.
- Operation-log and lock SQL ownership remains in the SQLite backend.
- No actor-auth or key-rotation semantics are introduced here.
Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- oc_chat.registry.backends.sqlite (schema/restore support)
- oc_chat.registry.canonical (canonical JSON serialization)
- oc_chat.registry.api (Registry facade whose backend and clock the export reads)
- keyring (lazy; checkpoint signing key when the key path environment variable is unset)
|
protected |
|
protected |
Definition at line 214 of file checkpoint.py.
|
protected |
|
protected |
Definition at line 194 of file checkpoint.py.
|
protected |
Definition at line 259 of file checkpoint.py.
|
protected |
|
protected |
|
protected |
|
protected |
Definition at line 313 of file checkpoint.py.
|
protected |
Definition at line 280 of file checkpoint.py.
|
protected |
Definition at line 296 of file checkpoint.py.
|
protected |
|
protected |
|
protected |
| dict[str, object] oc_chat.registry.checkpoint.export_checkpoint | ( | Registry | registry, |
| * | , | ||
| bool | sign = False ) |
Return a canonical JSON-safe checkpoint mapping.
Definition at line 110 of file checkpoint.py.
| CheckpointImportResult oc_chat.registry.checkpoint.import_checkpoint | ( | SQLiteBackend | backend, |
| * | , | ||
| Path | checkpoint_path, | ||
| bool | skip_signature_check = False ) |
Verify and restore ``checkpoint_path`` over ``backend``.
Definition at line 140 of file checkpoint.py.
| bool oc_chat.registry.checkpoint.verify_checkpoint | ( | Mapping[str, object] | checkpoint, |
| * | , | ||
| bool | skip_signature_check = False ) |
Verify a checkpoint signature before import.
Definition at line 168 of file checkpoint.py.
| CheckpointWriteResult oc_chat.registry.checkpoint.write_checkpoint | ( | Registry | registry, |
| * | , | ||
| Path | out, | ||
| bool | sign = False ) |
Write a checkpoint file and return its digest metadata.
Definition at line 124 of file checkpoint.py.
| str oc_chat.registry.checkpoint.CHECKPOINT_KEY_ENV = "OC_REGISTRY_CHECKPOINT_KEY_PATH" |
Definition at line 67 of file checkpoint.py.
| str oc_chat.registry.checkpoint.CHECKPOINT_SCHEMA_VERSION = "v0.2.3" |
Definition at line 65 of file checkpoint.py.
| int oc_chat.registry.checkpoint.CHECKPOINT_VERSION = 1 |
Definition at line 64 of file checkpoint.py.
| str oc_chat.registry.checkpoint.KEYRING_SERVICE = "oc_chat:registry:checkpoint" |
Definition at line 68 of file checkpoint.py.
| str oc_chat.registry.checkpoint.KEYRING_USERNAME = "key" |
Definition at line 69 of file checkpoint.py.
| str oc_chat.registry.checkpoint.SIGNATURE_ALGORITHM = "HMAC-SHA256" |
Definition at line 66 of file checkpoint.py.