open source · pure Rust · single binary

traits.build

Typed, composable function objects compiled into a single Rust binary. Define traits in TOML, call them via CLI or REST. The kernel is traits all the way down.

Explore Traits API Docs
25
compiled traits
3
namespaces
~2 MB
binary size
0
runtime deps

Architecture

The kernel is traits all the way down

CLI & HTTP

sys.cli parses args, kernel.serve starts actix-web. Every sys.* trait is a direct subcommand.

Dispatcher

Resolves paths, validates & coerces arguments, dispatches to compiled Rust trait functions.

Registry

Concurrent DashMap of .trait.toml definitions. Loads from disk + compiled builtins. Hot-reloadable.

Interface System

provides / requires / bindings. Per-call overrides, global bindings, or auto-discovery.

Plugin Loader

kernel.dylib_loader discovers cdylib .dylib plugins at startup for dynamic trait extensions.

Type System

int, float, string, bool, bytes, any, list<T>, map<K,V>, T? — validated at dispatch time.

Why Traits?

Functions as the universal building block

🚀

Single binary, zero runtime

Every trait compiles directly into the binary via build.rs. No containers, no workers, no runtime dependencies. One ~2 MB executable does everything.

⚙️

Self-describing kernel

Registry, dispatcher, config, CLI, and HTTP server are all traits. Call kernel.main to see every module, interface, and bootstrap step.

🔌

CLI + REST, one trait

Every trait is callable via REST API (POST /traits/ns/name) and CLI (traits name args). No glue code needed.

🔗

Interface wiring

Traits declare provides, requires, and bindings in TOML. Resolution: per-call overrides → global bindings → auto-discover.

🧩

Build-time codegen

build.rs discovers all .trait.toml files, generates dispatch tables, embeds definitions, auto-bumps versions and checksums.

📦

cdylib plugins

Extend at runtime with .dylib shared libraries. The kernel discovers and loads them at startup via kernel.dylib_loader.

Built-in traits

25 traits across kernel, sys, and www — all compiled in

TraitWhat it does
kernel.mainEntry point, bootstrap, compiled module list, interface introspection
kernel.dispatcherPath resolution, argument validation & coercion, compiled dispatch
kernel.registryLoad .trait.toml definitions, DashMap lookup, interface resolution
kernel.configtraits.toml parsing, env var overrides, runtime config
kernel.serveStart the actix-web HTTP server with CORS & SSE streaming
kernel.dylib_loaderDiscover and load cdylib .dylib plugins at startup
kernel.typesTraitValue, TraitType, type parsing (list<map<string,int>>)
kernel.globalsOnceLock statics: REGISTRY, CONFIG, TRAITS_DIR, HANDLES
kernel.callCall any trait by dot-notation path (inter-trait dispatch)
kernel.plugin_apiC ABI export macro for cdylib trait plugins
kernel.reloadHot-reload the trait registry from disk
sys.cliClap parsing, subcommand dispatch, arg coercion, pipe support
sys.registryRead API: list, info, tree, namespaces, count, search
sys.checksumSHA-256 checksums for strings, I/O pairs, and signatures
sys.versionGenerate YYMMDD date-format versions
sys.snapshotSnapshot a trait version (YYMMDD or YYMMDD.HHMMSS)
sys.test_runnerRun .features.json tests — dispatch examples + shell commands
sys.listList all registered traits
sys.infoShow detailed trait metadata and signatures
sys.psList running background traits with process details
www.traits.buildThis landing page
www.adminAdmin dashboard with deployment controls (Basic Auth)
www.admin.deployDeploy to Fly.io
www.admin.scaleScale Fly.io machines up or down
www.admin.destroyDestroy Fly.io machines

Interface system

Declare dependencies as typed contracts, not hard-coded paths

# kernel/main/main.trait.toml
[trait]
description = "Binary entry point"

# Declare what this trait needs
[requires]
dispatcher = "kernel/dispatcher"
registry   = "kernel/registry"
config     = "kernel/config"

# Wire each slot to a concrete provider
[bindings]
dispatcher = "kernel.dispatcher"
registry   = "kernel.registry"
config     = "kernel.config"

Resolution chain

per-call overrides global bindings caller [bindings] auto-discover

Trait definition format

.trait.toml — one file defines everything

# traits/sys/checksum/checksum.trait.toml
[trait]
description = "SHA-256 checksums"
version     = "v260320.142947"
author      = "system"
tags        = ["system", "crypto"]
provides    = ["sys/checksum"]

[signature]
params = [
  { name = "mode",  type = "string", description = "hash | io_pairs | signature" },
  { name = "input", type = "any",    description = "Data to checksum" },
]

[signature.returns]
type = "string"
description = "Hex-encoded SHA-256 hash"

[implementation]
language = "rust"
source   = "builtin"    # compiled directly into the binary
entry    = "checksum"
int
float
string
bool
bytes
any
list<T>
map<K,V>
T? (optional)
handle

Quick start

Two ways to talk to every trait

# CLI — every sys.* trait is a direct subcommand
$ traits serve --port 8090
$ traits list
$ traits checksum hash "hello"
"2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
$ traits info sys.checksum
$ traits test_runner '*'       # run all .features.json tests
$ echo hello | traits checksum hash  # pipe support
# REST API — POST /traits/{namespace}/{name}
$ curl -X POST https://traits.build/traits/sys/checksum \
    -H 'Content-Type: application/json' \
    -d '{"args": ["hash", "hello"]}'

# List everything
$ curl https://traits.build/traits/sys/list

# Health check
$ curl https://traits.build/health

How it works

build.rs discovers traits, generates dispatch, compiles everything in

# 1. Define a trait (TOML + Rust source)
traits/sys/checksum/checksum.trait.toml
traits/sys/checksum/checksum.rs

# 2. build.rs discovers it automatically
#    - Embeds the TOML via include_str!
#    - Generates mod declarations
#    - Creates dispatch_compiled() match arms
#    - Validates checksums, bumps versions

# 3. cargo build produces a single binary
$ cargo build --release
#    target/release/traits (~2 MB)

# 4. Run it anywhere
$ ./traits serve --port 8090
#    25 traits loaded, 0 workers, 0 dependencies