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

Classes

class  DoctorOptions

Functions

dict[str, object] run_doctor (Registry registry, SQLiteBackend backend, Path workspace_root, DoctorOptions options)
dict[str, object] check_permissions (Path option_c, *, bool fix, bool skip)
dict[str, object] sweep_stray_temp_files (Path orchestration_dir)
dict[str, object] sweep_expired_locks (Registry registry, SQLiteBackend backend)
dict[str, object] check_credential_consistency (SQLiteBackend backend, Path secrets_path)
dict[str, object] check_round_state (SQLiteBackend backend)
dict[str, object] auth_event_summary (SQLiteBackend backend)
dict[str, object] check_snapshot_conflicts (Registry registry, SQLiteBackend backend, Path workspace_root, DoctorOptions options)
str format_doctor_report (Mapping[str, object] report)
str _section_line (str label, object section)
Mapping[str, object]|None _secret_block (object data, str slot, str phase)
object _fingerprint_for_block (Mapping[str, object] block)
list[str] _warnings_from (*Mapping[str, object] sections)
dict[str, object] _skipped (str message)
str _resolution_mode (DoctorOptions options)
dict[str, object] _audit_snapshot_repair (Registry registry, str actor_slot, RenderResult result, str action)
dict[str, object] _trust_local (Registry registry, str actor_slot, RenderResult result)

Variables

str OPTION_C_DIR = ".option_c"
str ORCHESTRATION_DIR = "orchestration"
str SECRETS_FILENAME = "agent_secrets.json"
int EXPECTED_OPTION_C_MODE = 0o700
int EXPECTED_SECRETS_MODE = 0o600

Detailed Description

Operator doctor checks for the orchestration registry.

Purpose
-------
Provide the health checks and small repairs owned by M11.1c: local file
permissions, stray temp-file cleanup, expired-lock sweep auditing, and
credential fingerprint consistency.

Responsibilities
----------------
- Inspect and optionally repair `.option_c` and `agent_secrets.json` modes.
- Remove stray `.tmp-*` files below `.option_c/orchestration`.
- Sweep expired lock rows and emit a `doctor.repair` audit operation.
- Compare on-disk credential fingerprints with `agent_credentials`.

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

Contracts
---------
- Audit rows go through `Registry.execute_domain_command`.
- Secret values are never returned in structured output.
- Windows permission inspection is a graceful v0.2.x skip.

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- oc_chat.registry.api (Registry facade)
- oc_chat.registry.backends.sqlite (SQLite backend)
- oc_chat.registry.domain (plan_reimport for the trust-local snapshot repair)
- oc_chat.registry.render (render_all for snapshot drift detection and trust-registry repair)
- oc_chat.registry.render._common (RenderResult and plan_for_worktree lookup)

Function Documentation

◆ _audit_snapshot_repair()

dict[str, object] oc_chat.registry.doctor._audit_snapshot_repair ( Registry registry,
str actor_slot,
RenderResult result,
str action )
protected

Definition at line 562 of file doctor.py.

Here is the caller graph for this function:

◆ _fingerprint_for_block()

object oc_chat.registry.doctor._fingerprint_for_block ( Mapping[str, object] block)
protected

Definition at line 517 of file doctor.py.

Here is the caller graph for this function:

◆ _resolution_mode()

str oc_chat.registry.doctor._resolution_mode ( DoctorOptions options)
protected

Definition at line 547 of file doctor.py.

Here is the caller graph for this function:

◆ _secret_block()

Mapping[str, object] | None oc_chat.registry.doctor._secret_block ( object data,
str slot,
str phase )
protected

Definition at line 501 of file doctor.py.

Here is the caller graph for this function:

◆ _section_line()

str oc_chat.registry.doctor._section_line ( str label,
object section )
protected

Definition at line 482 of file doctor.py.

Here is the caller graph for this function:

◆ _skipped()

dict[str, object] oc_chat.registry.doctor._skipped ( str message)
protected

Definition at line 539 of file doctor.py.

Here is the caller graph for this function:

◆ _trust_local()

dict[str, object] oc_chat.registry.doctor._trust_local ( Registry registry,
str actor_slot,
RenderResult result )
protected

Definition at line 590 of file doctor.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _warnings_from()

list[str] oc_chat.registry.doctor._warnings_from ( *Mapping[str, object] sections)
protected

Definition at line 529 of file doctor.py.

Here is the caller graph for this function:

◆ auth_event_summary()

dict[str, object] oc_chat.registry.doctor.auth_event_summary ( SQLiteBackend backend)
Return auth-event counts for doctor output.

Definition at line 361 of file doctor.py.

Here is the caller graph for this function:

◆ check_credential_consistency()

dict[str, object] oc_chat.registry.doctor.check_credential_consistency ( SQLiteBackend backend,
Path secrets_path )
Compare non-revoked DB credential fingerprints with the secrets file.

Definition at line 264 of file doctor.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_permissions()

dict[str, object] oc_chat.registry.doctor.check_permissions ( Path option_c,
* ,
bool fix,
bool skip )
Check POSIX modes for `.option_c` and `agent_secrets.json`.

Definition at line 148 of file doctor.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_round_state()

dict[str, object] oc_chat.registry.doctor.check_round_state ( SQLiteBackend backend)
Audit round/round_job invariants (read-only).

Flags the OI-324 invariant (a ``closed`` round must be ``clean``) and any
round-job left in ``failed`` status that needs an operator resume or abort.

Definition at line 314 of file doctor.py.

Here is the caller graph for this function:

◆ check_snapshot_conflicts()

dict[str, object] oc_chat.registry.doctor.check_snapshot_conflicts ( Registry registry,
SQLiteBackend backend,
Path workspace_root,
DoctorOptions options )
Detect and optionally resolve rendered artifact drift.

Definition at line 381 of file doctor.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ format_doctor_report()

str oc_chat.registry.doctor.format_doctor_report ( Mapping[str, object] report)
Return a compact human-readable doctor summary.

Definition at line 457 of file doctor.py.

Here is the call graph for this function:

◆ run_doctor()

dict[str, object] oc_chat.registry.doctor.run_doctor ( Registry registry,
SQLiteBackend backend,
Path workspace_root,
DoctorOptions options )
Run all enabled doctor checks and return a JSON-safe report.

Definition at line 89 of file doctor.py.

Here is the call graph for this function:

◆ sweep_expired_locks()

dict[str, object] oc_chat.registry.doctor.sweep_expired_locks ( Registry registry,
SQLiteBackend backend )
Sweep expired locks and audit the repair when rows were removed.

Definition at line 227 of file doctor.py.

Here is the caller graph for this function:

◆ sweep_stray_temp_files()

dict[str, object] oc_chat.registry.doctor.sweep_stray_temp_files ( Path orchestration_dir)
Remove stray `.tmp-*` files below the orchestration directory.

Definition at line 198 of file doctor.py.

Here is the caller graph for this function:

Variable Documentation

◆ EXPECTED_OPTION_C_MODE

int oc_chat.registry.doctor.EXPECTED_OPTION_C_MODE = 0o700

Definition at line 71 of file doctor.py.

◆ EXPECTED_SECRETS_MODE

int oc_chat.registry.doctor.EXPECTED_SECRETS_MODE = 0o600

Definition at line 72 of file doctor.py.

◆ OPTION_C_DIR

str oc_chat.registry.doctor.OPTION_C_DIR = ".option_c"

Definition at line 67 of file doctor.py.

◆ ORCHESTRATION_DIR

str oc_chat.registry.doctor.ORCHESTRATION_DIR = "orchestration"

Definition at line 68 of file doctor.py.

◆ SECRETS_FILENAME

str oc_chat.registry.doctor.SECRETS_FILENAME = "agent_secrets.json"

Definition at line 70 of file doctor.py.