Architecture
Internal architecture of COGANT: the 10-stage pipeline (ingest → static → normalize → graph → dynamic → translate → statespace → process → export → validate), the data model, and the cross-cutting concerns (concurrency, memory, performance, error handling, security). Read this section if you are modifying COGANT itself, integrating it deeply, or auditing how a result was produced. End users should usually start in ../api/, ../tutorials/, or ../concepts/ instead.
The 10-stage pipeline
COGANT executes a deterministic, topologically-ordered sequence of 10 stages to transform source code into an Active Inference model:
- ingest — Load and enumerate source files from the target repository
- static — Extract static analysis: AST nodes, type information, symbol tables (Python via CPython
ast, JS/TS viatree-sitter) - normalize — Canonicalize language-specific representations into a unified fact language
- graph — Build the typed
ProgramGraphwith nodes (functions, classes, modules) and edges (READS, WRITES, CALLS, CONTAINS, etc.) - dynamic — Optional enrichment: merge coverage databases and runtime traces into the graph
- translate — Fixpoint application of 22 declarative translation rules to assign Active Inference roles (HIDDEN_STATE, OBSERVATION, ACTION, POLICY, etc.)
- statespace — Compile
SemanticMappingsinto a state-space model with hidden states, observations, actions, and transitions - process — Extract the process/execution model and control-flow topology
- export — Emit the final GNN markdown bundle (19 canonical sections), JSON artifacts, and validation report
- validate — Run integrity and schema checks; score the bundle 0–100
Each stage is optional: the stages list in PipelineConfig can be reordered or truncated to skip stages. Conversely, the skip_stages list lets callers skip individual stages without rebuilding the config.
Documentation map
The tables below group the architecture pages by topic: Orientation for first-time readers, Cross-cutting concerns for system-wide properties, Pipeline stages mapped to the 10-runner model, the Pipeline stage → API reference crosswalk, and Stage-by-stage step references for fine-grained debugging. Implementation snapshots of the engine live under the stage tables.
Contents
Orientation
| Page | Description | Level |
|---|---|---|
| Overview | One-page architectural summary | Beginner |
| System Overview | Layered system diagram and component relationships | Beginner |
| On This Page | Conventions used across the architecture docs | Reference |
| Pipeline Module Index | Cross-reference of pipeline modules to source files | Reference |
| COGANT Pipeline Index | Master index of pipeline-related documents | Reference |
| Detailed Pipeline Guide | Long-form walkthrough of the pipeline | Intermediate |
| Component Details | Per-component design notes | Intermediate |
| See Also | Cross-links to related documentation | Beginner |
Cross-cutting concerns
| Page | Description | Level |
|---|---|---|
| Data Flow | How data moves between stages | Intermediate |
| Concurrency and Parallelism | Thread / process model and parallel-execution strategy | Advanced |
| Memory Management | Memory ownership and budget per stage | Advanced |
| Error Handling | Exception strategy and recovery | Intermediate |
| Performance | Performance characteristics and tuning levers | Intermediate |
| Configuration System | Layered configuration model | Intermediate |
| Testing Strategy | How COGANT itself is tested | Intermediate |
| Extensibility | Where extension points live in the architecture | Intermediate |
| Security Considerations | Architectural security posture | Intermediate |
Pipeline stages (10-runner model)
| Runner Stage | Page | Description | Level |
|---|---|---|---|
| 1. ingest | Step 1: Ingest Repository, COGANT Ingest and Static Analysis Pipeline | Load repository files and directory structure | Intermediate |
| 2. static | Step 2: Analyze Each Python File, COGANT Ingest and Static Analysis Pipeline | Extract AST, symbols, type information | Intermediate |
| 3. normalize | 1. Normalize, Step 1: Normalize Language-Specific Facts | Canonicalize language-specific facts | Intermediate |
| 4. graph | 2. Build Graph, Step 3: Build Program Graph from Extracted Information | Build typed program graph with nodes and edges | Intermediate |
| 5. dynamic | Step 3: Merge with Dynamic Analysis | Optional: merge coverage and trace data | Intermediate |
| 6. translate | 3. Translate, Step 4: Translate Using Rules | Apply 22 declarative rules; assign Active Inference roles | Intermediate |
| 7. statespace | Detailed Pipeline Guide, State-space compilation | Compile state-space model from semantic mappings | Intermediate |
| 8. process | Process/execution model extraction | Extract process model and control-flow topology | Intermediate |
| 9. export | 6. Export, Step 7: Export Final Mappings | Emit GNN markdown, JSON, and companion artifacts | Intermediate |
| 10. validate | Audit, Identify Issues, Report | Validate schema; score bundle 0–100 | Intermediate |
| — (Markov) | Detailed Graph Engine | Markov blanket extraction (runs during translate/statespace) | Advanced |
| — (Reverse) | COGANT Graph Construction, Normalization, and Translation Engine | Reverse synthesizer: GNN → Python code | Advanced |
Implementation snapshots
| Page | Description | Level |
|---|---|---|
| Detailed Graph Engine | Internals of the graph engine that powers stages 3-4 | Advanced |
| Graph Engine Summary | Compressed reference for the graph engine | Reference |
| COGANT Engine Implementation Summary | Implementation snapshot of the translate engine | Reference |
| COGANT Graph Construction, Normalization, and Translation Engine | Long-form engine description | Advanced |
Pipeline stage → API reference
Each runner stage maps to one or more cogant Python packages. Use this table when you have a runner stage in mind and want to jump straight to the implementing module's API docs:
| Runner Stage | Architecture page | API reference | Implementing package |
|---|---|---|---|
| 1. ingest | Step 1: Ingest Repository | cogant.ingest (module docs in source) |
cogant.ingest |
| 2. static | Step 2: Analyze Each Python File | cogant.static |
cogant.static, cogant.parsers |
| 3. normalize | 1. Normalize | cogant.static → Symbols/Types |
cogant.static.symbols, cogant.static.types |
| 4. graph | 2. Build Graph, Step 3: Build Program Graph | cogant.graph (module docs in source) |
cogant.graph.builder |
| 5. dynamic | Step 3: Merge Dynamic Analysis | cogant.dynamic API, cogant.dynamic enrichment |
cogant.dynamic |
| 6. translate | 3. Translate, Step 4: Translate Using Rules | cogant.translate, cogant.translate.confidence, Translation rules reference |
cogant.translate.engine, cogant.translate.rules.* |
| 6a. (Markov) | Detailed Graph Engine | cogant.markov |
cogant.markov.blanket, cogant.markov.extractor |
| 7. statespace | Detailed Pipeline Guide | cogant.statespace |
cogant.statespace.compiler |
| 8. process | Concurrency and Parallelism | cogant.process (module docs in source) |
cogant.process |
| 9. export | 6. Export, Step 7: Export Final Mappings | cogant.gnn, export stage & GNN package |
cogant.gnn.formatter, cogant.gnn.package, cogant.gnn.json_export |
| 10. validate | Audit, Identify Issues | cogant.validate (module docs in source), cogant.gnn → Validator |
cogant.validate, cogant.gnn.validator |
| Reverse | — | cogant.reverse |
cogant.reverse.parser, cogant.reverse.synthesizer |
| Runtime | Concurrency and Parallelism | cogant.runtime |
cogant.runtime.loop, cogant.runtime.metrics |
For a conceptual walkthrough of each stage, see the concepts pages — every concept page links back to its implementing module.
Stage-by-stage step references
These finer-grained pages document individual operations inside each stage. Useful when debugging a specific call site; not required reading for the big picture.
| Page | Stage | Description |
|---|---|---|
| Step 1: Ingest Repository | Ingest | Repository ingest entry point |
| Ingest a Local Repository | Ingest | Local-path ingest path |
| Ingest a Remote Git Repository | Ingest | Remote git ingest path |
| Enumerate All Source Files | Ingest | File-walking strategy |
| Parse Python setup.py | Ingest | Manifest parser |
| Parse requirements.txt | Ingest | Manifest parser |
| Parse pyproject.toml | Ingest | Manifest parser |
| Parse package.json | Ingest | Manifest parser |
| Parse Cargo.toml | Ingest | Manifest parser |
| Parse from File | Ingest | Generic file parser entry |
| Parse from String | Ingest | Generic string parser entry |
| Step 2: Analyze Each Python File | Analyze | Per-file static analysis |
| Extract from File | Analyze | Symbol extractor (file) |
| Extract from Source | Analyze | Symbol extractor (source) |
| Extract Symbols | Analyze | Symbol-extraction details |
| Analyze File | Analyze | File-level analysis |
| Analyze Source | Analyze | Source-level analysis |
| Analyze Imports | Analyze | Import resolution |
| Build Call Graph | Analyze | Call-graph construction |
| Infer Types | Analyze | Type inference |
| Infer from File | Analyze | Inference (file entry) |
| Infer from Source | Analyze | Inference (source entry) |
| Analyze Data Flow | Analyze | Data-flow analysis |
| Step 1: Normalize Language-Specific Facts | Normalize | Normalize entry |
| Language-Specific Fact | Normalize | Per-language fact model |
| Normalize to Canonical Form | Normalize | Canonicalization |
| Generate Stable IDs | Normalize | Stable identifier scheme |
| Same Inputs = Same ID (Deterministic) | Normalize | Determinism guarantee |
| Step 2: Build Graph from Normalized Facts | Build Graph | Build-graph entry |
| Step 3: Build Program Graph from Extracted Information | Build Graph | Program-graph construction |
| Convert to Node | Build Graph | Fact-to-node conversion |
| Add Nodes | Build Graph | Node insertion |
| Add Edge | Build Graph | Edge insertion |
| Add Edges from Analysis Results | Build Graph | Bulk edge insertion |
| Step 3: Merge with Dynamic Analysis Results | Build Graph | Static + dynamic merge |
| Merge Static and Dynamic Graphs | Build Graph | Merge details |
| Query | Build Graph | Graph query API |
| Finalize | Build Graph | Finalization step |
| Filter | Build Graph | Graph filtering |
| Centrality | Build Graph | Centrality metrics |
| Path Finding | Build Graph | Path-finding utilities |
| Components and Cycles | Build Graph | SCC / cycle detection |
| Dependencies | Build Graph | Dependency extraction |
| Step 4: Translate Using Rules | Translate | Translate entry |
| Register Rules | Translate | Rule-registration API |
| ...Register 6 More Rules | Translate | Rule-registration example |
| Translate | Translate | Translation operation |
| Analyze | Translate | Post-translate analysis |
| Step 5: Score by Confidence | Score | Score entry |
| Score Mappings | Score | Mapping scoring |
| Filter by Confidence | Score | Confidence filtering |
| Identify Issues | Score | Issue identification |
| Report | Score | Score-stage report |
| Step 6: Human Review and Curation | Review | Review entry |
| Review Process (Interactive) | Review | Interactive review flow |
| Add for Review | Review | Queue an item for review |
| Accept | Review | Accept a reviewed item |
| Split | Review | Split a reviewed item |
| Step 7: Export Final Mappings | Export | Export entry |
| Export | Export | Export operation |
| Audit | Export | Export audit trail |
| Access Results | Export | Reading exported results |
| Use final_mappings for GNN Training | Export | Downstream GNN-training use case |
Recommended Reading Order
- Overview — one-page summary of the architecture.
- System Overview — see the layered diagram.
- Detailed Pipeline Guide — long-form pipeline walkthrough.
- The six canonical stage pages in order: 1. Normalize, 2. Build Graph, 3. Translate, 4. Score, 5. Review, 6. Export.
- Detailed Graph Engine — internals of the engine that powers stages 2 and 3.
- The cross-cutting concerns table when you start touching real code: Data Flow, Error Handling, Performance, Configuration System, Testing Strategy, Extensibility, Security Considerations.
- The stage-by-stage step references only when debugging a specific call site.
Agent notes: AGENTS.md - Hub: ../index.md