feat(active_inference): Expected Free Energy decomposition (epistemic/pragmatic)#19
Merged
Merged
Conversation
Add the defining Active Inference quantity the template was missing (and that 15_discussion_outlook.md flags as deferred): a closed-form EFE decomposition on the finite T-maze generative model. src/simulation/efe_decomposition.py computes both canonical forms and their exact identity: G(pi) = risk + ambiguity = -(pragmatic_value + epistemic_value) where risk = KL[q(o|pi) || softmax(C)], ambiguity = E_q(s)[H[p(o|s)]], pragmatic_value = E_q(o)[ln p(o)], epistemic_value = I(s;o|pi). The identity is machine-checked to 1e-10, mirroring the analytical track's decomposition_identity_holds. Closed-form, no sampling, byte-deterministic. 17 deterministic no-mocks tests, 100% module coverage; full active_inference suite 286/287, 92.1% (maintained); ruff/mypy/format clean.
main's v3.2.0 prep added infrastructure modules (validation/docs/* subpackage, etc.) without refreshing the factsheet, so canonical_facts.md drifted to 516 vs the tracked tree's 518 and test_canonical_facts_infrastructure_python_count_matches_tree fails on main (and on any PR merged with it). Update both the header measurement and the 'Last refreshed count' literal to 518 (git ls-files infrastructure | grep .py). Unblocks CI.
This was referenced Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the single most defining Active Inference quantity the template was missing — and which
15_discussion_outlook.mdexplicitly flags as deferred ("extending to full expected-free-energy policy selection is documented as a follow-on track"). Identified as the #1 addition by all three agents of a survey of the exemplar.Layer 1 (this commit): the scientific core
src/simulation/efe_decomposition.pycomputes, in closed form on the finite T-maze generative model (A,B,C,D), both canonical EFE decompositions and their exact algebraic identity:G(π) = risk + ambiguity— risk =KL[q(o|π) ‖ softmax(C)](pragmatic deviation), ambiguity =E_q(s)[H[p(o|s)]](outcome uncertainty)= −(pragmatic_value + epistemic_value)— pragmatic =E_q(o)[ln p(o)](utility), epistemic =I(s;o|π)(mutual-information info-gain / salience)risk + ambiguity + pragmatic + epistemic ≡ 0to 1e-10, mirroring the analytical track'sdecomposition_identity_holds(Theorem 5.1).Closed-form, no sampling, byte-deterministic. 17 deterministic no-mocks tests, 100% module coverage. Full active_inference suite 286/287, 92.1% (maintained); ruff/mypy/format clean. The EFE-minimizing policy correctly seeks the goal; the identity holds across all policies and likelihood settings.
Planned follow-on layers (same PR or follow-up)
Producer →
output/data/efe_decomposition.json(byte-deterministic) → EFE risk/ambiguity bar figure → Methods/Results section with hydrated tokens → claim-ledger + sheaf-track binding, each gated on the full suite + render.