LogicAIn is a high-fidelity toolkit that implements the Codebase-as-Data architecture. It turns a Python codebase into a queryable data graph, decomposing every function and class into a SQL registry, mapping the dependencies between them, and exposing the entire structure through a single CLI tool—no manual SQL required.
| Layer | File | Purpose |
|---|---|---|
| AST Decomposer | src/ast_decomposer.py |
Parses Python files and extracts every function, class, import, and constant. |
| Graph Engine | src/graph_engine.py |
Builds a networkx directed graph from the registry and answers dependency queries. |
| Sync Script | sync_codebase.py |
Walks src/, decomposes each file, and writes the results to logic_registry.db. |
| CLI | logic.py |
Single entry-point for all registry operations (no SQL needed). |
pip install networkxpython logic.py syncScans src/, decomposes every .py file, and upserts all logic nodes into
logic_registry.db.
python logic.py sync
# optional overrides:
python logic.py sync --src ./my_src --db /tmp/my_registry.dbScans the source directory and updates the registry.
python logic.py trace ASTDecomposerPrints all direct and transitive callers and callees for the named function or class.
Trace: ASTDecomposer
====================
Direct callers (1 found):
↑ run_sync
Direct callees (3 found):
↓ get_full_decomposition
...
python logic.py checkReports:
- Circular dependencies — code that loops back on itself.
- Orphaned nodes — functions or classes that are not called by anything and do not call anything.
Returns exit code 1 if any circular dependencies are found.
python logic.py context my_functionOutputs a Markdown block containing the node's metadata and its immediate dependencies. Designed for copy-pasting into an LLM prompt.
# Logic Context: `my_function`
## `my_function`
- **Type**: function
- **File**: `src/my_module.py`
- **Lines**: 42–58
- **Arguments**: `radius: float`
- **Returns**: `float`
- **Calls**: `helper_one`, `helper_two`
...| Variable | Default | Description |
|---|---|---|
LOGIC_DB_PATH |
logic_registry.db |
Path to the SQLite registry database. |
The SQLite database (logic_registry.db) mirrors the target PostgreSQL schema:
CREATE TABLE logic_registry (
id INTEGER PRIMARY KEY AUTOINCREMENT,
node_name TEXT NOT NULL,
node_type TEXT NOT NULL, -- 'function' | 'class'
source_file TEXT NOT NULL,
line_start INTEGER,
line_end INTEGER,
docstring TEXT,
logic_calls TEXT, -- JSON array of callee names
metadata TEXT, -- JSON object (args, return_type, …)
synced_at TEXT,
UNIQUE(node_name, source_file)
);Switching to PostgreSQL requires only changing the connection call in
sync_codebase.py and src/graph_engine.py.
All work on this toolkit lives on the codebase-as-data-v2 branch and is
intentionally kept separate from the main TFusion project.