Skip to content

Repository files navigation

construct-core

CILicense: MIT

The v2 layered trait system for the SuperInstance Construct API.

This crate implements a hardware-agnostic agent runtime with three progressively capable trait layers. Each layer adds capabilities — but also requirements. An ESP32 implements only Layer 0. A DGX cluster implements all three.

Architecture

┌─────────────────────────────────────────┐
│ Layer 2: AsyncConstruct │ std + async (tokio)
│ • request_tool / release_tool │ Tool lifecycle management
│ • query_async │ Async I/O, GPU, network
│ • active_tools │
├─────────────────────────────────────────┤
│ Layer 1: SyncConstruct │ no_std + alloc
│ • load_skill / unload_skill │ Dynamic skill management
│ • query_owned │ Heap-allocated queries/responses
│ • loaded_skills │
├─────────────────────────────────────────┤
│ Layer 0: BareMetalConstruct │ no_std, no alloc
│ • query_lookup │ O(1) table lookup
│ • capabilities │ Static capability introspection
│ • query (default impl) │ Stack-only, zero alloc
└─────────────────────────────────────────┘

Why Split Traits This Way?

Because hardware is not a spectrum — it's a taxonomy. An ESP32 will never have a heap. A Raspberry Pi will never run tokio. Rather than a single trait with unimplemented!() stubs, we give each hardware class its own trait that covers exactly what it can actually do.

This means:

  • Compile-time correctness: If you have a &dyn BareMetalConstruct, the compiler guarantees you can't accidentally call load_skill on hardware that can't allocate.
  • Zero-cost abstractions: No Option<Box<dyn Tool>> on bare metal. No alloc::vec::Vec on ESP32. Each layer uses only the primitives it needs.
  • Clear upgrade path: Moving from ESP32 → Pi → DGX means implementing additional traits, not rewriting everything.

Feature Gates

[features]
default = ["std"]
std = ["alloc"] # Layer 2 + Layer 1 + Layer 0alloc = [] # Layer 1 + Layer 0bare-metal = [] # Layer 0 only
FeatureLayers AvailableTarget
bare-metal0ESP32, Cortex-M bare metal
alloc0 + 1Raspberry Pi, embedded Linux
std (default)0 + 1 + 2Workstation, DGX, Cloud

Usage

Layer 0: Bare Metal (ESP32)

use construct_core::{BareMetalConstruct,EspConstruct,TritAction};let esp = EspConstruct::new();let action = esp.query_lookup(42);println!("Action at index 42: {}", action);let caps = esp.capabilities();println!("Lookup table size: {}", caps.lookup_table_size);

Layer 1: Sync (Raspberry Pi)

use construct_core::{SyncConstruct,PiConstruct,SkillId,QueryKind,OwnedQuery};letmut pi = PiConstruct::new();
pi.load_skill(SkillId::TernaryEvolution).unwrap();let q = OwnedQuery::new(QueryKind::Action,vec![42]);let resp = pi.query_owned(q).unwrap();println!("{} (confidence: {:.2})", resp.action, resp.confidence);

Layer 2: Async (DGX / Cloud)

use construct_core::{AsyncConstruct,DgxConstruct,ToolSpec,QueryKind,OwnedQuery};letmut dgx = DgxConstruct::new();let tool = dgx.request_tool(ToolSpec::VectorDb).unwrap();let q = OwnedQuery::new(QueryKind::Strategy,vec![1,2,3]);let resp = dgx.query_async(q).await.unwrap();
dgx.release_tool(tool).unwrap();

Core Types

TypeDescription
TritActionTrinary decision: Avoid, Explore, Choose
SkillIdEnum of known agent skills (no String needed)
Query / OwnedQueryZero-copy and heap-allocated query types
Response / OwnedResponseZero-copy and heap-allocated response types
ToolSpecTool specification (VectorDb, CodeEditor, Terminal, etc.)
ToolHandleSimple u32 tool ID — no trait objects
ConstructErrorError enum: NotAvailable, RateLimited, Timeout, InvalidQuery
HardwareTierAdvisory tier (Embedded, SingleBoard, Workstation, Cluster)
BareMetalCapabilitiesStatic capability struct — all const-compatible, heap-free

Implementations

ConstructLayer 0Layer 1Layer 2Hardware
EspConstructESP32, Cortex-M
PiConstructRaspberry Pi
DgxConstructDGX, Cloud

Implementing for New Hardware

  1. Layer 0 only (microcontroller): Implement BareMetalConstruct. You need:

    • A lookup table ([u8; N])
    • A BareMetalCapabilities value
    • Optionally override query()
  2. Layer 0 + 1 (SBC): Also implement SyncConstruct. You need:

    • A Vec<SkillId> for loaded skills
    • load_skill, unload_skill, loaded_skills
    • query_owned for heap-based queries
  3. All layers (server): Also implement AsyncConstruct. You need:

    • Tool tracking (Vec<ToolHandle>)
    • request_tool, release_tool, active_tools
    • query_async for async queries

Design Decisions

  • ToolHandle is a u32, not Box<dyn Tool> — no vtable overhead, no lifetime complexity. Tools are identified by ID, managed by the construct.
  • HardwareTier has no PartialOrd — a cluster isn't "greater than" an ESP32. They're different categories for different jobs.
  • TritAction is repr(u8) — fits in one byte, converts to/from u8 for table storage. No padding, no surprises.
  • SkillId is an enum, not a string — no heap allocation for skill names, pattern matching in match statements, compile-time exhaustive checking.

License

MIT

Ecosystem

This repo is part of the SuperInstance flagship ecosystem — agent-first computation, constraint theory, and self-improving runtimes.

FLUX Runtime Family

RepoLanguageDescription
flux-runtimePythonFull FLUX runtime: markdown→bytecode, 2037 tests, zero deps
flux-coreRustRegister-based bytecode VM, deterministic agent computation
flux-jsJavaScriptFLUX VM for Node.js and browsers, ~400ns/iter
flux-compilerRust/PythonFormal-methods compiler for safety-critical codegen
flux-vmRustStack-based constraint-checking VM, 50 opcodes, Turing-incomplete

PLATO Engine Family

RepoLanguageDescription
plato-serverPythonKnowledge tiles, fleet sync via Matrix, HTTP API
plato-engine-blockRustOriginal room runtime: no_std + alloc, builder pattern
plato-engine-block-cC99Embedded reference: zero heap alloc, bare-metal portable
plato-engine-block-elixirElixirBEAM supervision trees, fault tolerance, hot reload
plato-runtime-kernelRustSpatial model: tensor grid, batons, assertion traps

Constraint / Theory Family

RepoLanguageDescription
categorical-agentsRustCategory theory for agent composition (functors, naturality)
cuda-constraint-engineCUDA/CGPU constraint checking at 1B+ constraints/sec
grand-pattern-rsRustFibonacci dual-direction cellular graph architecture
lau-hodge-theoryRustHodge decomposition, Betti numbers, spectral sequences
ternary-scienceRustExperimental evidence for ternary intelligence, 5 conservation laws

Agent / Infrastructure Family

RepoLanguageDescription
construct-coreRustLayered trait system: bare-metal → alloc → async agent runtime
crabBashAgent shell for repo entry/leave (MUD-room metaphor)
exocortexRustPersistent cognitive substrate, S3-compatible memory
git-agentPythonThe repo IS the agent — autonomous lifecycle via Git
capitaine-1TypeScriptGit-native repo-agent, Cloudflare Workers heartbeat
codespace-edge-rdResearchCodespace→Edge agent lifecycle and yoke transfer protocols
git-agent-codespaceDevContainerOne-click Codespace template for Git-Agent runtimes

Registries

RegistryPackageInstall
PyPIflux-vmpip install flux-vm
crates.iofluxvmcargo add fluxvm
npmflux-jsnpm install flux-js(coming soon)

Philosophy & Architecture

About

Hardware-agnostic agent runtime with layered trait system for the SuperInstance Construct API

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages