The Symbolic Ledger (AST)
PyOB's core intelligence relies on its ability to see code as a tree rather than text. It utilizes the ast module to populate SYMBOLS.json.
update_ledger_for_file()
This method, located in EntranceController, parses Python files into ast.FunctionDef and ast.ClassDef nodes to track exactly where every symbol is defined.
# Simplified AST walk logic from update_ledger_for_file
tree = ast.parse(code)
for n in ast.walk(tree):
if isinstance(n, (ast.FunctionDef, ast.ClassDef)):
self.ledger["definitions"][n.name] = rel_path
elif isinstance(n, ast.Assign):
# Tracking Uppercase Constants
for target in n.targets:
if isinstance(target, ast.Name) and target.id.isupper():
self.ledger["definitions"][target.id] = rel_path
entrance.py / entrance_mixins.py
The control hub. Responsible for the main loop, symbolic ripple detection, and external safety pods.
| Method Name | Primary Logic |
|---|---|
execute_targeted_iteration |
Core loop. Backs up workspace, triggers reviewer pipeline, refreshes metadata. |
detect_symbolic_ripples |
Diffs old/new code, finds changed symbols, and queues all dependent files. |
reboot_pyob |
Verifies syntax integrity before performing an os.execv hot-restart. |
autoreviewer.py / reviewer_mixins.py
The verification heart. It enforces Rule 7 (no 'src.' prefixes) and manages the 5-layer pipeline.
# The Verification Gate sequence
if not self.run_linter_fix_loop():
return False # Linter/Syntax Error
if not self.run_and_verify_app():
return False # Runtime Crash Detected
if not self.check_downstream_breakages():
return False # Downstream Mypy Breakage
Engine Module Map
pyob_code_parser.py
Generates HTML dropdowns from AST trees for AI context injections.
prompts_and_memory.py
Handles PIR.md, ALF.md, and PF.md template loading.
models.py
The "Heartbeat" router for Gemini, Llama-3 (GH), and Local Ollama.
feature_mixins.py
Orchestrates multi-file creation and architectural feature implementation.
The Healing Logic
When a crash occurs, PyOB uses _fix_runtime_errors to parse tracebacks and automatically generate patches.
Auto-Dependency Locking
If a ModuleNotFoundError is detected, PyOB automatically runs pip install and freezes the new state into requirements.txt without human intervention.