Canonical GEO-INFER Active Inference implementation. Use when implementing or reviewing free-energy minimization, belief updating, generative models, policy selection, H3/spatial active inference, or typed ACT diagnostics.
Resources
6Install
npx skillscat add activeinferenceinstitute/geo-infer/geo-infer-act Install via the SkillsCat registry.
SKILL.md
GEO-INFER-ACT
Instructions
Use GEO-INFER-ACT/src/geo_infer_act as the canonical implementation for
Active Inference inside GEO-INFER. Prefer these public exports:
from geo_infer_act import (
ActiveInferenceModel,
ActiveInferenceStepResult,
FreeEnergyBreakdown,
FreeEnergyCalculator,
GenerativeModel,
H3BeliefUpdateResult,
H3CellDiagnostics,
H3EdgeDiagnostics,
H3GridInferenceResult,
H3LevelDiagnostics,
H3SpatialConsistency,
NestedH3BeliefUpdateResult,
NestedH3GridInferenceResult,
NestedH3LevelSummary,
PolicyEvaluation,
PolicySelector,
SpatialActiveInferenceAgent,
SpatialInferenceTrace,
)Examples
import numpy as np
from geo_infer_act import ActiveInferenceModel, GenerativeModel
generative_model = GenerativeModel(
"categorical",
{"state_dim": 3, "obs_dim": 3},
)
agent = ActiveInferenceModel(
model_type="categorical",
policy_selection_mode="deterministic",
random_seed=42,
)
agent.set_generative_model(generative_model)
result = agent.step(
np.array([1.0, 0.0, 0.0]),
available_actions=["survey", "wait"],
return_result=True,
)
assert isinstance(result, ActiveInferenceStepResult)import numpy as np
from geo_infer_act import ActiveInferenceModel, GenerativeModel
cells = ["89283082803ffff"]
model = GenerativeModel("categorical", {"state_dim": 4, "obs_dim": 4})
model.enable_nested_h3_spatial([7, 8, 9], cells=cells)
agent = ActiveInferenceModel(
model_type="categorical",
policy_selection_mode="deterministic",
)
agent.set_generative_model(model)
nested = agent.infer_over_nested_h3_grid(
{model.h3_cells[0]: np.array([1.0, 0.0, 0.0, 0.0])},
return_result=True,
)
trace = agent.trace_over_nested_h3_grid(
{model.h3_cells[0]: np.array([1.0, 0.0, 0.0, 0.0])},
grid_result=nested,
)
assert isinstance(nested, NestedH3GridInferenceResult)
assert isinstance(trace, SpatialInferenceTrace)Guidelines
Method Contracts
geo_infer_act.utils.pymdp_adapteris the only production runtime bridge toinferactively-pymdp==1.0.3; it builds JAXpymdp.agent.Agentinstances,
validates the exact installed version, uses explicit RNG-key action sampling,
and returns normalized posterior, action posterior, negative EFE, and VFE/free
energy metadata.FreeEnergyCalculator.compute_categorical_free_energy(..., return_breakdown=True)
returnsFreeEnergyBreakdownwithfree_energy = complexity - accuracy.FreeEnergyCalculator.compute_expected_free_energy(..., return_breakdown=True)
returns pragmatic, epistemic, risk, ambiguity, and entropy terms.PolicySelector.select_policy(...)returns selected policy metadata and aPolicyEvaluationobject.ActiveInferenceModel.step(..., return_result=True)returns anActiveInferenceStepResultwithout breaking the legacy(beliefs, action)
return shape.GenerativeModel.update_h3_beliefs(..., return_result=True)returns anH3BeliefUpdateResultwith normalized per-cell beliefs, aggregate free
energy, andH3SpatialConsistency.ActiveInferenceModel.infer_over_h3_grid(..., return_result=True)andSpatialActiveInferenceAgent.step(..., return_result=True)returnH3GridInferenceResult; their default dictionary outputs remain compatible
and include per-cell pymdp metadata.GenerativeModel.compute_h3_cell_diagnostics(...),ActiveInferenceModel.trace_over_h3_grid(...),ActiveInferenceModel.trace_over_nested_h3_grid(...),SpatialActiveInferenceAgent.trace_step(...), andSpatialActiveInferenceAgent.trace_nested_step(...)returnSpatialInferenceTracewithH3CellDiagnostics,H3EdgeDiagnostics, andH3LevelDiagnostics.GenerativeModel.enable_nested_h3_spatial(...)delegates hierarchy
construction to SPACE and stores parent/child closure for ordered H3
resolutions.GenerativeModel.update_nested_h3_beliefs(..., return_result=True)returnsNestedH3BeliefUpdateResultwith normalized finest-cell beliefs,
parent-level aggregate beliefs,NestedH3LevelSummaryrows, cross-level
coherence, and finite aggregate free energy.ActiveInferenceModel.infer_over_nested_h3_grid(..., return_result=True)andSpatialActiveInferenceAgent.step_nested(..., return_result=True)returnNestedH3GridInferenceResultwhile preserving existing flat H3 behavior.- H3 methods must validate real
h3>=4.5.0,<5cells. Synthetic cells are only
for explicitcell_*unit-test paths. - Runner
h3and nested H3 modes emitdata/pymdp_h3_diagnostics.json,data/pymdp_policy_posteriors.csv, andvisualizations/pymdp_policy_free_energy.htmlwith manifest-linked sidecars. - Runner
h3,spatial, and nested H3 modes emitdata/spatial_inference_trace.json,data/spatial_research_statistics.json,data/h3_cell_diagnostics.csv,data/h3_edge_diagnostics.csv,visualizations/h3_belief_flux_map.html,visualizations/h3_policy_surface.html,visualizations/h3_policy_transitions.html,visualizations/h3_spatial_autocorrelation.html,visualizations/h3_entropy_free_energy_phase.html, andvisualizations/spatial_inference_research_report.html; nested mode also
emitsdata/nested_h3_parent_child_diagnostics.csv,data/nested_h3_level_diagnostics.csv, andvisualizations/nested_h3_hierarchy_map.htmlplusvisualizations/nested_h3_parent_child_residuals.html. - Research-profile H3 runs are opt-in with
RunConfig.parameters["research_profile"] = Trueorgeo-infer-act-run --research-profile. They keep real H3 cells and realinferactively-pymdp==1.0.3while installing deterministic likelihoods,
preferences, and action-conditioned transitions that avoid collapsed traces. - The deterministic visualization gallery is generated with
uv run python GEO-INFER-ACT/examples/spatial_active_inference_gallery.py.
Useuv run; system Python may contain a legacy pymdp distribution and is
outside the supported ACT/H3 runtime contract.
Integrations
- AGENT active-inference adapters should call or conform to ACT typed result
contracts. - MATH/BAYES convenience surfaces may expose helpers, but ACT remains the
canonical implementation for Active Inference policy and free-energy logic. - Optional external backends may be absent; use real local ACT methods or
explicitnot_availableresults.
Verification
uv run python GEO-INFER-TEST/validate_h3_active_inference_contract.py
uv run python GEO-INFER-TEST/validate_active_inference_contract.py
uv run python GEO-INFER-TEST/validate_act_geospatial_contract.py
uv run pytest GEO-INFER-ACT/tests/unit/test_spatial_trace_diagnostics.py -q
uv run pytest GEO-INFER-ACT/tests/unit/test_spatial_research_statistics.py -q
uv run pytest GEO-INFER-ACT/tests/unit/test_pymdp_h3_backend.py -q
uv run pytest GEO-INFER-ACT/tests/unit/test_nested_h3_active_inference.py -q
uv run python GEO-INFER-ACT/examples/spatial_active_inference_gallery.py --json
uv run --package geo-infer-act --extra dev python -m pytest GEO-INFER-ACT/tests -qDo not add inert placeholders, fake policy selection, first-policy defaults, or
undocumented public methods. Do not import legacy pymdp.control orpymdp.inference in production code.