|
oc_chat
|
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" |
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)
|
protected |
Definition at line 116 of file check_registry_clock_discipline.py.
|
protected |
Definition at line 112 of file check_registry_clock_discipline.py.
|
protected |
Definition at line 95 of file check_registry_clock_discipline.py.
| int check_registry_clock_discipline.main | ( | list[str] | None | argv = None | ) |
Definition at line 59 of file check_registry_clock_discipline.py.
| 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.
| str check_registry_clock_discipline.CLOCK_ALLOWLIST = "oc_chat/registry/clock.py" |
Definition at line 56 of file check_registry_clock_discipline.py.
| dict check_registry_clock_discipline.RAW_TIME_MODULES = {"time", "datetime"} |
Definition at line 55 of file check_registry_clock_discipline.py.