Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¦ FLUX Registry (Rust)

Crates.io Rust Tests License

npm for agent policies β€” now in Rust. πŸ¦€ Install and run pre-compiled FLUX bytecode policies from the static GitHub registry.

A Rust CLI for the FLUX Registry: download, inspect, and execute pre-compiled agent policies. Same policies, same bytecode, different shell.


Philosophy

Part of Working Animal Architecture, where Ξ³ + Ξ· = C (genome + nurture = capability). The FLUX Registry is the breed catalog β€” pre-compiled, verified policies that any working animal can be trained on. Install a policy like choosing a breed for a task: the right dog for the right job, the right bytecode for the right fence.

Installation

cargo install flux-registry-cli

Or build from source:

git clone https://github.com/SuperInstance/flux-registry-rs.git
cd flux-registry-rs
cargo build --release
# Binary at target/release/flux-registry

Quick Start

# Browse available policies in the remote registry
flux-registry list --remote

# Install a policy locally
flux-registry install deadband-controller

# Run it with inputs
flux-registry run deadband-controller --input temperature=72
# β†’ action=idle

flux-registry run deadband-controller --input temperature=80
# β†’ action=cool

flux-registry run deadband-controller --input temperature=60
# β†’ action=heat

# Inspect policy metadata
flux-registry info deadband-controller

Commands

Command Description
flux-registry install <policy> Install a policy from the remote registry
flux-registry list [--remote] List installed (or remote) policies
flux-registry info <policy> Show detailed metadata, inputs, and outputs
flux-registry run <policy> --input K=V [--input K2=V2] Execute a policy with given inputs
flux-registry remove <policy> Remove an installed policy
flux-registry update-index Refresh the local registry cache

Available Policies

Policy Description Inputs Outputs
deadband-controller Thermostat with hysteresis β€” AC at 75Β°F, heat at 65Β°F temperature (Β°F) action: idle / cool / heat
budget-tracker Conservation budget enforcement β€” track resource depletion cost, budget remaining, status: ok / exceeded
rate-limiter Token bucket rate limiting β€” check and consume tokens tokens, cost remaining, allowed: denied / allowed
security-scanner Basic vulnerability detection β€” threshold-based policy check value, threshold verdict: safe / violation, severity

Policy Format

Each policy is a self-contained JSON file:

{
  "name": "deadband-controller",
  "version": "0.1.0",
  "description": "Thermostat deadband controller",
  "author": "SuperInstance",
  "bytecode": "<base64-encoded FLX0 binary>",
  "source": "deadband-controller.flx",
  "bytecode_hash": "sha256...",
  "bytecode_size": 30,
  "inputs": [
    {"name": "temperature", "type": "float", "register": "R0"}
  ],
  "outputs": [
    {"name": "action", "type": "int", "register": "R1",
     "values": {"0": "idle", "1": "cool", "2": "heat"}}
  ],
  "conservation": {"max_steps": 100, "memory_budget": 256},
  "conformance": "verified on flux-vm 0.1.0, fluxvm 0.1.0, flux-js 0.1.0",
  "tags": ["iot", "thermostat", "hvac"],
  "license": "MIT"
}

Conservation Guarantees

Every policy declares conservation limits:

"conservation": {
  "max_steps": 100,
  "memory_budget": 256
}

The VM enforces these at runtime β€” a policy cannot exceed its step count or memory allocation. This makes FLUX policies safe to run as untrusted code.

API Reference (Library)

The CLI also exposes a library crate (flux_registry_cli_lib) for embedding in other Rust applications:

policy Module

Type/Function Description
Policy Deserialized policy struct with metadata, bytecode, I/O specs
Policy::from_json(s) Parse a policy from JSON string
Policy::decode_bytecode() Decode base64 bytecode to raw bytes

registry Module

Function Description
fetch_index() Fetch the remote registry index from GitHub
fetch_policy(name) Download a specific policy JSON
list_remote() List all available policies in the remote registry

store Module

Function Description
install_policy(policy) Save policy to ~/.flux/policies/
list_installed() List all locally installed policies
get_policy(name) Load a locally installed policy
remove_policy(name) Delete a locally installed policy

vm Module

Built-in FLX0 stack-based mini VM for executing registry policies, plus fluxvm crate integration for register-based FLUX ISA compatibility.

use flux_registry_cli_lib::vm::run_policy;

let result = run_policy(&bytecode, inputs).unwrap();
println!("Output: {:?}", result.outputs);

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 FLUX Registry (Rust)                  β”‚
β”‚                                                       β”‚
β”‚  GitHub (static JSON)          Local (~/.flux/)       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ registry/       β”‚  install β”‚ policies/        β”‚   β”‚
β”‚  β”‚   index.json    β”‚ ───────▢ β”‚   deadband.json  β”‚   β”‚
β”‚  β”‚   deadband.json β”‚          β”‚   budget.json    β”‚   β”‚
β”‚  β”‚   budget.json   β”‚          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚  β”‚   rate-limiter  β”‚                   β”‚              β”‚
β”‚  β”‚   security.json β”‚          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚ flux-registry    β”‚   β”‚
β”‚                               β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚   β”‚
β”‚                               β”‚ β”‚ FLX0 Mini VM β”‚ β”‚   β”‚
β”‚                               β”‚ β”‚ (built-in)   β”‚ β”‚   β”‚
β”‚                               β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚   β”‚
β”‚                               β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚   β”‚
β”‚                               β”‚ β”‚ fluxvm crate β”‚ β”‚   β”‚
β”‚                               β”‚ β”‚ (register    β”‚ β”‚   β”‚
β”‚                               β”‚ β”‚  ISA support)β”‚ β”‚   β”‚
β”‚                               β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚   β”‚
β”‚                               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The CLI includes a built-in FLX0 stack-based mini VM for executing registry policies locally. It also depends on the fluxvm crate for register-based FLUX ISA compatibility.

Testing

# Run all tests
cargo test

# Run with verbose output
cargo test -- --nocapture

# Integration tests use tempfile for isolated policy installs
cargo test --test integration

Cross-Implementation

Runtime Language Install
flux-registry Python pip install flux-registry
flux-registry-cli Rust cargo install flux-registry-cli
flux-js JavaScript npm install flux-js

The same policy bytecode runs across all FLUX implementations. Same bytecode β€” different shells.

Ecosystem

FLUX Runtime

  • flux-vm β€” Python VM (pip install flux-vm)
  • flux-core β€” Rust VM (cargo add fluxvm)
  • flux-js β€” JavaScript VM (npm install flux-js)

Conservation

Tooling

  • flux-compiler β€” Bytecode assembler, disassembler, validator

Theory

License

MIT β€” Same bytecode, different shells. πŸ¦€

About

Rust CLI for installing and running pre-compiled FLUX agent policies

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages