GNN format
COGANT exports its state-space models in Generalized Notation Notation (GNN), the Active Inference Institute's reference text format for generative-model specifications. A GNN package is a directory containing a manifest.json, a model.gnn.md (the human-readable bracket-notation file), a model.gnn.json companion for machine consumption, and diagrams plus metadata.
Bracket notation, at a glance
A GNN model.gnn.md is organized into named sections enclosed in ## headings. The minimum viable model declares state-space variables, connections, and a parameterization block.
## ModelName
cogant_flask_app_current
## ModelAnnotation
Generated by COGANT v0.7.0 from examples/real_world/flask_app/; COGANT schema GNN v2.0.0, checked against the pinned generalized-notation-notation 5.1.0 release line.
98 graph nodes, 597 edges, 19 semantic mappings kept after conflict resolution.
## StateSpaceBlock
s_f0[3,1,type=int] # observation: request.method, db_connected, response_code
u_f0[3,1,type=int] # action id: validate_input, query_database, format_response
x_f0[6,1,type=float] # hidden state: Application internal + request/response flags
## Connections
x_f0 > s_f0 # hidden state emits observation
u_f0 > x_f0 # action updates hidden state
x_f0 > x_f0 # persistence (identity-biased)
## InitialParameterization
A_m0 = [[0.9, 0.1, 0.0],
[0.1, 0.9, 0.0],
[0.0, 0.0, 1.0]] # likelihood: P(observation | hidden_state)
B_f0 = identity_3x3_per_action # transition fallback when WRITES evidence is missing
C_m0 = [0.0, 0.0, 0.0] # uniform preferences (no CONSTRAINT mappings)
D_f0 = uniform(6) # uniform prior over hidden states
## Time
Discrete
ModelTimeHorizon=Unbounded
## ActInfOntologyAnnotation
s_f0 = HiddenStateFactor0
u_f0 = PolicyVector
x_f0 = HiddenStateFactor0
Bracket shapes
Each StateSpaceBlock entry declares a variable and its shape:
name[dim1,dim2,...,type=int|float|bool]
s_*— observations (sensory).u_*— actions / control inputs.x_*— hidden states (latent).pi_*— policies (distributions over action sequences).
The first index is the modality / factor (s_f0, s_f1, ...); the dimensions specify the domain size per factor.
Connections
A > B means "A is an input to B" or equivalently "B depends on A". Typical connections:
x > s— hidden state emits observation (A matrix).u > x— action updates hidden state (B matrix).x > x— state persistence (the B matrix diagonal).s > pi— observation informs policy (planning).
Matrices A / B / C / D
COGANT derives the generative-model matrices from the program graph and the semantic mappings:
| Matrix | Shape | Edges used | Semantics |
|---|---|---|---|
| A (likelihood) | [n_obs x n_states] |
READS, OBSERVES |
P(observation \| hidden_state) |
| B (transition) | [n_states x n_states x n_actions] |
WRITES, MUTATES, CALLS |
P(next_state \| current_state, action) |
| C (preference) | [n_obs] |
CONSTRAINT confidence scores |
log P(preferred observations) |
| D (prior) | [n_states] |
CONFIGURATION nodes + domain defaults |
P(initial hidden state) |
When the graph has no evidence to anchor a given matrix, the builder falls back to documented defaults: A uses a 0.9 / 0.1 diagonal bias, B is identity per action, C is uniform, D is uniform. These fallbacks are logged as validation warnings so downstream consumers know not to treat them as learned parameters.
Package layout
A cogant translate ... --layout-output run produces a gnn_package/ subdirectory with:
gnn_package/
├── manifest.json # package metadata, file inventory, checksums
├── model.gnn.md # bracket-notation model (human-readable)
├── model.gnn.json # JSON twin (machine-readable)
├── A.json, B.json, C.json, D.json
├── ontology_annotation.json # node-id <-> variable mapping
├── provenance.json # per-variable source spans
├── diagrams/ # PNG + Mermaid state-space views
└── reports/ # validator score + warnings
cogant validate <gnn_package> runs GNNValidator over the package and prints a 0–100 score plus error/warning tables; the flask_app example validates at 100.0 / 100.
See also
- Active Inference mapping — how roles and matrices are derived from the program graph.
- Flask app walkthrough — a concrete GNN export from a real repository.
cogant.gnnAPI reference — programmatic access to the formatter and validator.