Skip to content

COGANT Related Work

Extended related-work commentary supplementing ../manuscript/08_00_scope_and_related_work.md. Citations key to the annotated entries in LITERATURE.md.

Program Graph Extraction

COGANT's first-stage output — a typed program graph with 14 node kinds and 11 edge kinds — sits inside the program graph extraction tradition established by Allamanis et al. (2018) and extended to intermediate-representation granularity by Cummins et al. (2021). The Allamanis schema augments an AST with data-flow, control-flow, and lexical-reuse edges and is the de-facto input format for learned code-understanding models; ProGraML generalizes this to LLVM-IR and shows that a single graph can subsume AST, CFG, and data-flow for classical compiler analyses. The Code Property Graph of Yamaguchi et al. (2014) predates both and underlies the Joern platform, demonstrating that vulnerability patterns can be expressed as queries over a merged AST/CFG/PDG graph. COGANT adopts the unified-graph abstraction these lines converge on but differs in two respects. First, it works at the source-AST level rather than at IR level, sacrificing cross-language uniformity to preserve the names and comments that are the primary signal for role assignment. Second, it treats the graph as input to a symbolic fixpoint rule engine rather than to a neural model or query language. The correctness arguments for the translate stage are therefore data-flow analyses in the sense of Nielson, Nielson, and Hankin (2005), and the 22-rule engine is an instance of their monotone framework with termination guaranteed by lattice height and soundness by rule monotonicity.

Semantic Role Assignment in Static Analysis

Assigning roles rather than just types to program elements is a comparatively young direction. Rabin and Alipour (approx. 2020) imported the NLP notion of semantic role labeling into source-code analysis, framing parameters and locals as thematic roles relative to a predicate. Bielik, Raychev, and Vechev (2016) took a probabilistic-grammar approach with PHOG, predicting each AST node's role from a learned context function, and Raychev, Vechev, and Krause (2015) had previously shown that a conditional random field over program graphs can recover types and names not explicit in the source text. COGANT's role taxonomy is narrower and more formal than any of these: it is dictated by the active-inference ontology (state, observation, action, hidden, boundary) and is assigned by deterministic rules rather than a learned model. The choice is deliberate. Research uses of COGANT require auditable, reproducible assignments that can be inspected line-by-line. A learned classifier would dominate on coverage but would forfeit the auditability property that is, at this stage, the primary contribution. Hybrid rule-plus-learned assignment is identified in the R&D log as a v0.3 direction.

Active Inference and the Free Energy Principle

COGANT targets the Active Inference Institute's Generalized Notation Notation, and its theoretical substrate is the Free Energy Principle (FEP) as stated by Friston (2010) and elaborated in the Parr, Pezzulo, and Friston (2022) textbook. The discrete-time POMDP formulation — with A, B, C, D matrices and an explicit variational free energy functional — is the reference that COGANT's statespace and process stages derive from program graphs. Da Costa et al. (2020) provide the synthesis paper whose pseudocode COGANT's implementation most closely tracks, and Friston, Kilner, and Harrison (2006) remain the reference for the accuracy-complexity decomposition that informally motivates COGANT's confidence tiers. The claim COGANT instantiates — that a codebase implicitly specifies a generative model whose hidden states, observations, and policies can be read off by static analysis — is a software-engineering instance of FEP, not a novel theoretical commitment. COGANT does not compute free energy at runtime; it represents the generative model in a form downstream active-inference tools can consume.

Generalized Notation Notation

COGANT's output format is the Active Inference Institute's Generalized Notation Notation, whose reference implementation is the generalized-notation-notation package (optionally installed and pinned to its v5.1.0 release): a Markdown-structured, section-based notation declaring state variables, observations, actions, matrices, time horizons, equations, and Markov blankets. Every COGANT fixture is scored by COGANT's package validator, which checks the emitted markdown sections, JSON package structure, A/B/C/D matrix validity, state-space alignment, provenance, and checksums; upstream AII validation and pipeline checks run through the cogant.gnn.upstream_bridge facade only when the optional upstream extra is installed and the check is requested. Champion, Grześ, and Bowman's branching-time active inference (approx. 2022) extends GNN to hierarchical branching models; COGANT currently emits only flat GNN, but the scoping report identifies branching-time extraction as a v0.2 goal.

Program Synthesis and Reverse Engineering

The cogant.reverse module is a program synthesizer, and the SyGuS framework of Alur et al. (2013) gives the clearest statement of the problem class: synthesis from a formal specification together with a grammar constraining the output. COGANT specializes this to the case where the grammar is Python's AST and the specification is a GNN bundle. Because the forward extract function is deterministic and rule-based, reverse synthesis is strictly simpler than general SyGuS whenever the GNN came from extract — it is essentially an inversion problem. Solar-Lezama's sketching paradigm (2008) frames the more interesting case in which the GNN has been hand-edited or partially authored: the reverse output is a skeleton with holes, and filling them is sketch completion. Gulwani's FlashFill (2011) and Seshia's oracle-guided synthesis survey (2015) complete the picture of the synthesis landscape COGANT reverses into.

Markov Blankets Beyond Biology

COGANT claims that module boundaries in a codebase function as Markov blankets: minimal variable sets that conditionally insulate internal implementation from external interface. The concept originates with Pearl (1988) as a statistical property of Bayesian networks, and has been generalized to dynamical systems by Kirchhoff et al. (2018) and Palacios et al. (2020), who argue that Markov blankets are the formal signature of biological autonomy. Bruineberg et al. (2022) provide an important critical corrective: "Pearl blankets" (statistical, relative to a joint distribution) should not be conflated with "Friston blankets" (dynamical, relative to a system's sparse coupling), and papers that slide between these readings have over-claimed. COGANT explicitly adopts the Pearl reading: the extracted blankets are computed over the program graph treated as a DAG of state-and-observation nodes, and the five seed strategies correspond to five choices of "internal set." The project does not make dynamical-system claims about running programs.

Category-Theoretic Foundations

The deepest framing of COGANT is categorical. The forward and reverse functors form a pair whose composition should approximate the identity — the defining property of a lens in the sense of Foster et al. (2007); Hofmann, Pierce, and Wagner (2011) extend this to edit lenses, and Diskin et al. (2011) to the symmetric case. Spivak's polynomial-functor framework (2020, 2022) and the Niu and Spivak (2023) monograph provide the strongest categorical setting: in the category Poly of polynomial endofunctors on Set, COGANT's functor pair is a morphism whose wiring-diagram composition is the round-trip map. Awodey (2010) and Fong and Spivak (2019) are the standard and applied references for this framing, with Fong and Spivak's chapter on Galois connections directly relevant to the confidence-tier lattice. A formal categorical treatment — turning the informal "extract ⊣ reverse" claim into a proved adjunction — is scoped in the R&D log as the "COGANT-Theory" follow-on paper.

References

See LITERATURE.md in this directory for full annotated entries keyed by the short citations used above, including DOIs, arXiv identifiers, and a "details need verification" flag for entries whose venue and date remain to be confirmed.