-
Notifications
You must be signed in to change notification settings - Fork 0
Design Principles and Architecture
Relevant source files
The following files were used as context for generating this wiki page:
- .goreleaser.yml
- AGENTS.md
- CHANGELOG.md
- CONTRIBUTING.md
- IMPROVEMENTS.md
- Makefile
- README.md
- STRUCTURE.md
- cmd/axis/testdata/summary_corrupt_state.golden
- cmd/axis/testdata/summary_empty_state.golden
- cmd/axis/testdata/summary_live_snapshot.golden
- docs/README.md
- docs/agent-worklog.md
- docs/architecture.md
- docs/current-state.md
- docs/development-process.md
- docs/doctrine.md
- docs/future-roadmap.md
- docs/invariants.md
- docs/phase1_spec.md
- docs/ram-balancing-research.md
- docs/substrate-roadmap.md
- docs/white_paper_v1.md
- hack/pr-review-cycle.sh
- hack/refresh-current-state.sh
- hack/test-lint-failclosed.sh
- internal/buildinfo/version.go
- internal/daemon/daemon_testmain_test.go
AXIS is a local-first cluster substrate designed to provide a deterministic, verifiable foundation for distributed task execution and AI agent coordination. It operates as a strict 5-layer stack where each layer is subordinate to the one below it.
The architecture is organized into five distinct planes. A core invariant of the system is that advisory surfaces (Layer 5) can never override the observed state of the lower planes.
| Layer | Name | Responsibility | Key Packages |
|---|---|---|---|
| 5 | Advisory | Experimental helpers, Chat, and Agent loops. |
internal/chat, internal/agent, internal/mcp
|
| **** | Execution | Guarded task runs, safety gates, and resource accounting. |
internal/execution, internal/safety, internal/reservation
|
| 3 | Placement | Deterministic node selection via Filter → Rank → Select. |
internal/placement, internal/workload
|
| 2 | Snapshot | Cluster-wide state assembly and daemon-backed caching. |
internal/snapshot, internal/daemon
|
| 1 | Fact Plane | Raw hardware discovery and telemetry collection. |
internal/facts, internal/transport
|
Sources: README.md:20-46, AGENTS.md:90-103
The following diagram illustrates the flow from raw hardware discovery to high-level advisory surfaces, mapping system concepts to code entities.
Diagram: System Flow and Code Mapping
graph TD
subgraph Layer1 ["Layer 1: Fact Plane"]
A["SSHExecutor"] -->|"probes"| B["LocalCollector"]
A -->|"probes"| C["RemoteCollector"]
B --> D["NodeFacts"]
C --> D
end
subgraph Layer2 ["Layer 2: Snapshot"]
D --> E["snapshot.Build()"]
E --> F["ClusterSnapshot"]
F --> G["daemon.Cache"]
end
subgraph Layer3 ["Layer 4: Placement"]
F --> H["placement.Engine"]
H -->|"Filter/Rank"| I["PlacementDecision"]
end
subgraph Layer4 ["Layer 4: Execution"]
I --> J["execution.RunGuarded()"]
J --> K["reservation.Ledger"]
K -->|"Overlay"| F
end
subgraph Layer5 ["Layer 5: Advisory"]
F -.-> L["agent.Agent"]
F -.-> M["mcp.Server"]
end
style Layer1 stroke-dasharray: 5 5
style Layer5 stroke-dasharray: 5 5
Sources: AGENTS.md:90-136, internal/buildinfo/version.go:1-5, README.md:119-145
No generated output may present itself as cluster truth unless it is backed by a real snapshot or live probe docs/current-state.md:7-7. This ensures that AI agents or experimental CLI commands cannot "hallucinate" the state of the cluster.
Placement is not a "best effort" guess. It follows a rigid Filter → Rank → Select pipeline:
- Filter: Hard constraints (RAM floor, GPU vendor match, tool availability, thermal health) README.md:123-132.
- Rank: A 10-level deterministic sort, ending in a node-name tiebreak to ensure consistency README.md:134-144.
-
Select: Calculation of a
FitScore(0-100) based on locality and resource suitability README.md:146-151.
AXIS is distributed as a single, statically-linked binary with zero external runtime dependencies other than SSH README.md:9-11. This simplifies deployment across heterogeneous environments (macOS, Linux, x86, ARM).
Sources: docs/current-state.md:7-7, README.md:119-151, AGENTS.md:11-20
The foundation of AXIS is the NodeFacts struct AGENTS.md:151-153.
-
Discovery: Nodes are discovered via
nodes.yamlor UDP beacons README.md:41-44. - Telemetry: Probes collect real-time data including Linux PSI/Darwin VM pressure, battery levels, and thermal throttling docs/current-state.md:55-57.
-
Snapshot Assembly: The
snapshot.Build()function deduplicates nodes and classifies network topology (e.g.,direct-lanvstailscale) CHANGELOG.md:4-4.
Sources: internal/buildinfo/version.go:1-5, docs/current-state.md:53-58, AGENTS.md:105-117
The transition from "knowing" to "doing" happens through the internal/execution package.
To prevent over-subscription, AXIS uses a double-entry reservation.Ledger docs/current-state.md:69-69. When a task is placed, RAM/VRAM is "committed" in the ledger. Subsequent placement decisions use a snapshotview which subtracts these active reservations from the raw hardware facts docs/current-state.md:45-46.
Execution follows a strict lifecycle:
-
Safety Evaluation: The
internal/safetyengine parses the command to assign a risk score docs/current-state.md:69-69. -
Resource Lock: A reservation is created in
~/.axis/state.jsondocs/current-state.md:41-41. -
Context Injection:
AXIS_CONTEXT_FILEis injected into the remote environment docs/current-state.md:44-44. - Cleanup: Remote cleanup traps ensure temporary files are removed even on failure docs/current-state.md:67-67.
Sources: docs/current-state.md:41-69, AGENTS.md:129-132, README.md:29-31
The Advisory layer contains the AI-powered interfaces:
-
axis agent: A tool-calling loop with 32+ tools for cluster management CHANGELOG.md:20-30. -
axis chat: An interactive REPL that auto-routes inference to the best node via SSH tunnels CHANGELOG.md:41-42. - MCP Server: Implements the Model Context Protocol to expose cluster state to external LLMs docs/current-state.md:39-39.
Diagram: Advisory Context Injection This diagram shows how Layer 5 consumes Layer 2 data without modifying it.
graph LR
subgraph Core ["Authoritative Core"]
DS[("state.json")] --> DC["daemon.Cache"]
NF["NodeFacts"] --> DC
end
subgraph Advisory ["Advisory Surfaces"]
DC -->|"Read Only"| AG["agent.Agent"]
DC -->|"Read Only"| MC["mcp.Server"]
DC -->|"Read Only"| CH["chat.Engine"]
end
AG -->|"Request Task"| RE["execution.RunGuarded"]
RE -->|"Update"| DS
Sources: docs/current-state.md:39-41, AGENTS.md:121-136, CHANGELOG.md:20-30
AXIS maintains persistent state in the user's home directory to survive reboots and binary updates.
| File | Purpose | Implementation |
|---|---|---|
~/.axis/nodes.yaml |
Static cluster configuration | internal/config |
~/.axis/state.json |
Active reservations and heartbeats | internal/state |
~/.axis/skills.json |
Learned execution successes/failures | internal/skills |
The system includes a Tombstone Immune System that records task failures. If a node causes repeated crashes, it is automatically excluded from placement for 24h to 7d docs/current-state.md:63-63.
Sources: docs/current-state.md:41-42, docs/current-state.md:63-63, AGENTS.md:108-110