oc_chat
Loading...
Searching...
No Matches
check_registry_clock_discipline Namespace Reference

Classes

class  _RawTimeImportVisitor

Functions

int main (list[str]|None argv=None)
list[dict[str, object]] scan_path (Path path)
list[dict[str, object]] _scan_file (Path path)
bool _is_allowlisted (Path path)
str _format_report (list[dict[str, object]] violations)

Variables

dict RAW_TIME_MODULES = {"time", "datetime"}
str CLOCK_ALLOWLIST = "oc_chat/registry/clock.py"

Detailed Description

AST guard for registry clock discipline.

Purpose
-------
Fail CI when registry modules import raw wall-clock modules outside the
central `oc_chat/registry/clock.py` implementation.

Responsibilities
----------------
- Walk Python files below `oc_chat/registry/` by default.
- Parse imports with `ast`.
- Flag `import time`, `import datetime`, and equivalent from-imports.
- Allow only `oc_chat/registry/clock.py`.

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

Contracts
---------
- Exit 0 on a clean tree and 1 when violations are found.
- JSON mode returns `{"ok": bool, "violations": [...]}`.

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- ast (Python AST parsing)
- pathlib (filesystem path walking)
- argparse (CLI argument parsing)
- json (JSON report formatting)

Function Documentation

◆ _format_report()

str check_registry_clock_discipline._format_report ( list[dict[str, object]] violations)
protected

Definition at line 116 of file check_registry_clock_discipline.py.

Here is the caller graph for this function:

◆ _is_allowlisted()

bool check_registry_clock_discipline._is_allowlisted ( Path path)
protected

Definition at line 112 of file check_registry_clock_discipline.py.

Here is the caller graph for this function:

◆ _scan_file()

list[dict[str, object]] check_registry_clock_discipline._scan_file ( Path path)
protected

Definition at line 95 of file check_registry_clock_discipline.py.

Here is the caller graph for this function:

◆ main()

int check_registry_clock_discipline.main ( list[str] | None argv = None)

Definition at line 59 of file check_registry_clock_discipline.py.

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

◆ scan_path()

list[dict[str, object]] check_registry_clock_discipline.scan_path ( Path path)
Return raw time import violations below `path`.

Definition at line 83 of file check_registry_clock_discipline.py.

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

Variable Documentation

◆ CLOCK_ALLOWLIST

str check_registry_clock_discipline.CLOCK_ALLOWLIST = "oc_chat/registry/clock.py"

Definition at line 56 of file check_registry_clock_discipline.py.

◆ RAW_TIME_MODULES

dict check_registry_clock_discipline.RAW_TIME_MODULES = {"time", "datetime"}

Definition at line 55 of file check_registry_clock_discipline.py.