# iamvxrn/alphaarc architecture

> Architecture diagram of the GitHub repository iamvxrn/alphaarc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iamvxrn/alphaarc
- Repository: https://github.com/iamvxrn/alphaarc

## Overview

#### Purpose and Execution Surfaces
AlphaARC is an experimental, non-LLM ARC-AGI-3 agent emphasizing minimum-description-length (MDL) compression as intrinsic drive. The primary implementation is Go; Python provides the canonical Kaggle-bundled agent and benchmarking harness. Go executables expose solving, staged runs, smoke/live-server checks, gate evaluation, and demos: `main.go`, `cmd/alphaarc-solve/main.go`, `cmd/alphaarc-suite/main.go`, `cmd/alphaarc-smoke/main.go`. Python bench execution begins under `python/bench/bench.py`.

#### Environment and Data Boundary
The agent consumes grid observations from either local ARC datasets/practice environments or the ARC-AGI-3 REST service. Environment adapters isolate game I/O and action transport from cognition: `pkg/environment/environment.go`, `pkg/environment/remote/client.go`, `pkg/environment/bridge/bridge.go`. Bundled ARC training/evaluation task JSON is under `data/ARC-AGI/data/training` and `data/ARC-AGI/data/evaluation`; live operation requires the ARC endpoint and API-key environment configuration.

#### Perception and Attention
Raw grids are transformed into stable object, spatial, relational, and affordance representations. Residuals—cells unexplained by the strongest regularity—focus attention on likely interactive controls. This is the perceptual boundary that feeds both structural compression and action selection: `pkg/environment/perception/perception.go`, `pkg/environment/perception/object.go`, `pkg/environment/perception/relational.go`.

#### Compression, Programs, and Goal Discovery
The macro layer evaluates MDL explanations such as reflection, translation, counting, and correspondence, then represents candidate transformations/programs and unexplained residual structure. The winning compression supplies intrinsic direction rather than a fixed reward target: `pkg/macro/mdl.go`, `pkg/macro/discover.go`, `pkg/macro/program.go`. Causal goal selection and feature affordances refine this into actionable target features: `pkg/goalsel/goalsel.go`, `pkg/feataff/feataff.go`, `pkg/goals/proposer.go`.

#### Predictive Control Loop
`pkg/pipeline/predictive_loop.go` is the main cognitive-cycle integration point: observation features, prediction, goal/attention signals, planning, action conditioning, and forecast error feed recurrent learning. Agent roles provide actor, predictor, and associator behavior: `pkg/agent/agent.go`, `pkg/agent/actor.go`, `pkg/agent/predictor.go`. Control is normally cheap one-step credit, with model-based lookahead available through `pkg/mbrl/mbrl.go`.

#### Actuation and Feedback
Selected goals are compiled/discovered as click or keyboard control sequences and issued through the environment bridge. Outcome memory, refractory behavior, and observed changes constrain retries and identify dead controls: `pkg/actuate/actuate.go`, `pkg/feataff/motor.go`, `pkg/environment/bridge/outcome_memory.go`. This closes the loop from external observation through internal inference back to game actions.

#### Learning Substrate and Offline Consolidation
A sparse graph supports concepts, spreading activation, routing, inhibition/WTA competition, and Hebbian/structural plasticity: `pkg/graph/concepts.go`, `pkg/graph/spreading.go`, `pkg/graph/plasticity.go`. Associative recall uses Hopfield memory, while homeostatic signals modulate drive: `pkg/memory/hopfield_modern.go`, `pkg/homeostasis/hormones.go`. Offline “sleep” clusters and compresses recurring graph structure via Louvain abstraction: `pkg/offline/sleep.go`, `pkg/offline/abstraction.go`.

#### Measurement and Delivery
The Python package mirrors the agent logic for Kaggle deployment—especially perception, MDL, planning, policy, and glue: `python/alphaarc/agent_glue.py`, `python/alphaarc/planner.py`, `python/alphaarc/mdl.py`. `python/bench/` runs reproducible scoring splits, decoding, and experiment variants; persisted run results provide comparative baselines. CI gate automation is defined in `.github/workflows/gate.yml`.

Main entry points: [`pkg/pipeline/predictive_loop.go`](https://github.com/iamvxrn/alphaarc/blob/main/pkg/pipeline/predictive_loop.go) (Predictive control loop), [`pkg/environment/environment.go`](https://github.com/iamvxrn/alphaarc/blob/main/pkg/environment/environment.go) (Environment adapters), [`pkg/graph/concepts.go`](https://github.com/iamvxrn/alphaarc/blob/main/pkg/graph/concepts.go) (Sparse concept graph), [`pkg/environment/bridge/bridge.go`](https://github.com/iamvxrn/alphaarc/blob/main/pkg/environment/bridge/bridge.go) (Environment bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrypoints["Execution surfaces"]
  node_go_commands["Go commands<br/>executables<br/>[main.go]"]
  node_ci_gate["CI gate<br/>automation<br/>[gate.yml]"]
end

subgraph group_environment["Environment boundary"]
  node_arc_data[("ARC task data<br/>dataset")]
  node_arc_service{{"ARC-AGI-3 service<br/>external REST API"}}
  node_environment_adapters["Environment adapters<br/>game I/O<br/>[environment.go]"]
  node_remote_client["Remote client<br/>REST transport<br/>[client.go]"]
  node_environment_bridge["Environment bridge<br/>action bridge<br/>[bridge.go]"]
end

subgraph group_cognition["Online cognition"]
  node_perception["Perception and residuals<br/>grid representation<br/>[perception.go]"]
  node_mdl_discovery["MDL discovery<br/>compression search<br/>[discover.go]"]
  node_programs["Transformation programs<br/>candidate programs<br/>[program.go]"]
  node_goal_selection["Goal and affordance selection<br/>intrinsic goals<br/>[goalsel.go]"]
  node_predictive_loop["Predictive control loop<br/>cognitive cycle<br/>[predictive_loop.go]"]
  node_agent_roles["Actor, predictor, associator<br/>agent roles<br/>[agent.go]"]
  node_model_based_rl["Model-based lookahead<br/>planning<br/>[mbrl.go]"]
  node_actuation["Action compiler<br/>motor control<br/>[actuate.go]"]
end

subgraph group_learning["Learning substrate"]
  node_sparse_graph[("Sparse concept graph<br/>associative substrate<br/>[concepts.go]")]
  node_memory_drive["Memory and homeostasis<br/>recall and drive<br/>[hopfield_modern.go]"]
  node_offline_sleep["Offline abstraction<br/>consolidation<br/>[sleep.go]"]
end

subgraph group_python["Python delivery"]
  node_python_agent["Python bundled agent<br/>Kaggle agent<br/>[agent_glue.py]"]
  node_python_bench["Benchmark harness<br/>experiment runner<br/>[bench.py]"]
end

node_go_commands -->|"runs agents against"| node_environment_adapters
node_go_commands -->|"starts"| node_predictive_loop
node_arc_data -->|"local observations"| node_environment_adapters
node_arc_service -->|"REST observations/actions"| node_remote_client
node_remote_client -->|"implements live I/O"| node_environment_adapters
node_environment_adapters -->|"grid observations"| node_perception
node_perception -->|"structures and residuals"| node_mdl_discovery
node_mdl_discovery -->|"evaluates"| node_programs
node_mdl_discovery -->|"intrinsic direction"| node_goal_selection
node_perception -->|"features and attention"| node_predictive_loop
node_goal_selection -->|"goal signals"| node_predictive_loop
node_agent_roles -->|"role behaviors"| node_predictive_loop
node_model_based_rl -.->|"lookahead plans"| node_predictive_loop
node_predictive_loop -->|"conditioned action"| node_actuation
node_actuation -->|"control sequences"| node_environment_bridge
node_environment_bridge -->|"action transport"| node_environment_adapters
node_environment_bridge -->|"outcomes and changes"| node_predictive_loop
node_predictive_loop -->|"learning signals"| node_sparse_graph
node_sparse_graph -->|"associative state"| node_memory_drive
node_memory_drive -->|"recall and drive"| node_predictive_loop
node_sparse_graph -->|"recurring structure"| node_offline_sleep
node_offline_sleep -->|"compressed abstractions"| node_sparse_graph
node_python_agent -->|"evaluated by"| node_python_bench
node_arc_data -->|"benchmark tasks"| node_python_bench
node_ci_gate -->|"gates"| node_go_commands
node_ci_gate -->|"gates"| node_python_bench

click node_go_commands "https://github.com/iamvxrn/alphaarc/blob/main/cmd/alphaarc-solve/main.go"
click node_arc_data "https://github.com/iamvxrn/alphaarc/tree/main/data/ARC-AGI/data/training"
click node_environment_adapters "https://github.com/iamvxrn/alphaarc/blob/main/pkg/environment/environment.go"
click node_remote_client "https://github.com/iamvxrn/alphaarc/blob/main/pkg/environment/remote/client.go"
click node_environment_bridge "https://github.com/iamvxrn/alphaarc/blob/main/pkg/environment/bridge/bridge.go"
click node_perception "https://github.com/iamvxrn/alphaarc/blob/main/pkg/environment/perception/perception.go"
click node_mdl_discovery "https://github.com/iamvxrn/alphaarc/blob/main/pkg/macro/discover.go"
click node_programs "https://github.com/iamvxrn/alphaarc/blob/main/pkg/macro/program.go"
click node_goal_selection "https://github.com/iamvxrn/alphaarc/blob/main/pkg/goalsel/goalsel.go"
click node_predictive_loop "https://github.com/iamvxrn/alphaarc/blob/main/pkg/pipeline/predictive_loop.go"
click node_agent_roles "https://github.com/iamvxrn/alphaarc/blob/main/pkg/agent/agent.go"
click node_model_based_rl "https://github.com/iamvxrn/alphaarc/blob/main/pkg/mbrl/mbrl.go"
click node_actuation "https://github.com/iamvxrn/alphaarc/blob/main/pkg/actuate/actuate.go"
click node_sparse_graph "https://github.com/iamvxrn/alphaarc/blob/main/pkg/graph/concepts.go"
click node_memory_drive "https://github.com/iamvxrn/alphaarc/blob/main/pkg/memory/hopfield_modern.go"
click node_offline_sleep "https://github.com/iamvxrn/alphaarc/blob/main/pkg/offline/sleep.go"
click node_python_agent "https://github.com/iamvxrn/alphaarc/blob/main/python/alphaarc/agent_glue.py"
click node_python_bench "https://github.com/iamvxrn/alphaarc/blob/main/python/bench/bench.py"
click node_ci_gate "https://github.com/iamvxrn/alphaarc/blob/main/.github/workflows/gate.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_go_commands,node_ci_gate toneBlue
class node_arc_data,node_arc_service,node_environment_adapters,node_remote_client,node_environment_bridge toneAmber
class node_perception,node_mdl_discovery,node_programs,node_goal_selection,node_predictive_loop,node_agent_roles,node_model_based_rl,node_actuation toneMint
class node_sparse_graph,node_memory_drive,node_offline_sleep toneRose
class node_python_agent,node_python_bench toneIndigo
```

## Components

### Execution surfaces

- [Go commands](https://github.com/iamvxrn/alphaarc/blob/main/cmd/alphaarc-solve/main.go): executables · Solve, suite, smoke, and demo entrypoints. · `cmd/alphaarc-solve/main.go`
- [CI gate](https://github.com/iamvxrn/alphaarc/blob/main/.github/workflows/gate.yml): automation · `.github/workflows/gate.yml`

### Environment boundary

- [ARC task data](https://github.com/iamvxrn/alphaarc/tree/main/data/ARC-AGI/data/training): dataset · `data/ARC-AGI/data/training`
- **ARC-AGI-3 service**: external REST API · Live operation requires endpoint and API-key configuration.
- [Environment adapters](https://github.com/iamvxrn/alphaarc/blob/main/pkg/environment/environment.go): game I/O · Isolates observation and action transport from cognition. · `pkg/environment/environment.go`
- [Remote client](https://github.com/iamvxrn/alphaarc/blob/main/pkg/environment/remote/client.go): REST transport · `pkg/environment/remote/client.go`
- [Environment bridge](https://github.com/iamvxrn/alphaarc/blob/main/pkg/environment/bridge/bridge.go): action bridge · Tracks outcomes and dead controls. · `pkg/environment/bridge/bridge.go`

### Online cognition

- [Perception and residuals](https://github.com/iamvxrn/alphaarc/blob/main/pkg/environment/perception/perception.go): grid representation · Builds objects, relations, affordances, and attention-driving residuals. · `pkg/environment/perception/perception.go`
- [MDL discovery](https://github.com/iamvxrn/alphaarc/blob/main/pkg/macro/discover.go): compression search · Selects the shortest structural explanation and residual structure. · `pkg/macro/discover.go`
- [Transformation programs](https://github.com/iamvxrn/alphaarc/blob/main/pkg/macro/program.go): candidate programs · `pkg/macro/program.go`
- [Goal and affordance selection](https://github.com/iamvxrn/alphaarc/blob/main/pkg/goalsel/goalsel.go): intrinsic goals · Refines compression into actionable target features. · `pkg/goalsel/goalsel.go`
- [Predictive control loop](https://github.com/iamvxrn/alphaarc/blob/main/pkg/pipeline/predictive_loop.go): cognitive cycle · Integrates prediction, attention, goals, planning, action, and forecast error. · `pkg/pipeline/predictive_loop.go`
- [Actor, predictor, associator](https://github.com/iamvxrn/alphaarc/blob/main/pkg/agent/agent.go): agent roles · `pkg/agent/agent.go`
- [Model-based lookahead](https://github.com/iamvxrn/alphaarc/blob/main/pkg/mbrl/mbrl.go): planning · Optional deeper planning beyond cheap one-step credit. · `pkg/mbrl/mbrl.go`
- [Action compiler](https://github.com/iamvxrn/alphaarc/blob/main/pkg/actuate/actuate.go): motor control · Produces click and keyboard control sequences. · `pkg/actuate/actuate.go`

### Learning substrate

- [Sparse concept graph](https://github.com/iamvxrn/alphaarc/blob/main/pkg/graph/concepts.go): associative substrate · Supports activation, routing, inhibition, and plasticity. · `pkg/graph/concepts.go`
- [Memory and homeostasis](https://github.com/iamvxrn/alphaarc/blob/main/pkg/memory/hopfield_modern.go): recall and drive · Hopfield recall and hormonal modulation shape behavior. · `pkg/memory/hopfield_modern.go`
- [Offline abstraction](https://github.com/iamvxrn/alphaarc/blob/main/pkg/offline/sleep.go): consolidation · Clusters and compresses recurring graph structure. · `pkg/offline/sleep.go`

### Python delivery

- [Python bundled agent](https://github.com/iamvxrn/alphaarc/blob/main/python/alphaarc/agent_glue.py): Kaggle agent · Mirrors perception, MDL, planning, policy, and glue. · `python/alphaarc/agent_glue.py`
- [Benchmark harness](https://github.com/iamvxrn/alphaarc/blob/main/python/bench/bench.py): experiment runner · Runs scoring splits, decoding, and variants. · `python/bench/bench.py`

## Connections

- Go commands → Environment adapters: runs agents against
- Go commands → Predictive control loop: starts
- ARC task data → Environment adapters: local observations
- ARC-AGI-3 service → Remote client: REST observations/actions
- Remote client → Environment adapters: implements live I/O
- Environment adapters → Perception and residuals: grid observations
- Perception and residuals → MDL discovery: structures and residuals
- MDL discovery → Transformation programs: evaluates
- MDL discovery → Goal and affordance selection: intrinsic direction
- Perception and residuals → Predictive control loop: features and attention
- Goal and affordance selection → Predictive control loop: goal signals
- Actor, predictor, associator → Predictive control loop: role behaviors
- Model-based lookahead → Predictive control loop: lookahead plans
- Predictive control loop → Action compiler: conditioned action
- Action compiler → Environment bridge: control sequences
- Environment bridge → Environment adapters: action transport
- Environment bridge → Predictive control loop: outcomes and changes
- Predictive control loop → Sparse concept graph: learning signals
- Sparse concept graph → Memory and homeostasis: associative state
- Memory and homeostasis → Predictive control loop: recall and drive
- Sparse concept graph → Offline abstraction: recurring structure
- Offline abstraction → Sparse concept graph: compressed abstractions
- Python bundled agent → Benchmark harness: evaluated by
- ARC task data → Benchmark harness: benchmark tasks
- CI gate → Go commands: gates
- CI gate → Benchmark harness: gates
