Sley Documentation

Home | Docs | Tutorial | Who / Why / Better | llms.txt | ZJX


1. Thesis

Sley is an AI-native structural programming language where the canonical program is a typed graph. Human-readable text is one stable projection of that graph.

The design center is human-readable, agent-writable, and agent-readable. Humans review intent. Agents write and inspect typed shards. The Loom accepts only verified graph grafts.

2. Canonical Naming

WordMeaning
SleyThe language.
LoomThe compiler, scheduler, and runtime engine.
ShardAn isolated structural slice, edit unit, or execution cell.
SwarmThe agent orchestration and message model.
ArenaA scoped memory, lifetime, and authority domain.
forgeA temporary isolated arena block.
graftA verified structural patch application.
spliceA local subgraph insertion or replacement.
traceThe accepted provenance chain.
sealAn immutable content-addressed artifact.
ZJXThe native compressed structural transport and cache envelope.

3. Binding Forms

Sley does not center a generic variable. Names are binding nodes with visible purpose, lifetime, mutability, sharing, authority, and provenance.

FormUse
takeTask or message input.
bindImmutable local value.
stateMutable local lifecycle state.
cellAtomic mutable cell shared by spawned workers.
knotExplicit Swarm-shared distributed state.
slotNamed structural field in type or agent storage.
gateRuntime authority or capability handle.
leaseTimebound borrowed resource or authority.
veilSecret or redacted value.
dialOperator or deployment tunable.
flagBoolean feature or safety switch.
memoDeterministic memoized value.
cacheNoncanonical ephemeral cached value.
deriveRecomputed view from other bindings.
flowStream or event sequence binding.
portMailbox or route endpoint.
tallyAccumulator or reducer binding.
holeTyped gap reserved for agent completion.
draftAgent-written candidate value pending verification.
taintUntrusted external input requiring cleanse or verification.
witnessProof, invariant evidence, or verification artifact.
sealImmutable content-addressed artifact binding.
anchorStable identity handle for graph nodes or public API.
viewRead-only borrowed projection.
cursorTraversal or index position.

Hard rule: no var, no generic mutable let, no silent shared state, and no hidden authority in ordinary bindings.

4. Current Prototype Surface

  • Module, import, type, effect, and function declarations.
  • Record types and typed record literals.
  • Explicit function parameters and return types.
  • Literals, identifiers, unary and binary operators, calls, field access, lists, maps, indexing, and ? result flow.
  • Statement-level if/else, while, for, and set local mutation.
  • Static checks for duplicate declarations, unknown types, effects, return mismatches, call arity/types, effect propagation, control flow, and collection types.
  • Runtime evaluation for zero-argument pure main programs.
  • Structural patch operations for declaration and function-body edits.

This implemented slice is active v0 work. Public docs use the canonical Sley vocabulary.

5. Target CLI Surface

CommandPurpose
sley parseParse human syntax into the compiler representation.
sley formatPrint stable normalized human syntax.
sley checkRun static type and effect checks.
sley runRun supported pure v0 programs.
sley graphInspect typed graph shards.
sley graftApply verified structural patch bundles.
sley traceInspect accepted provenance receipts.
sley sealCreate immutable content-addressed artifacts.

6. Minimal Target Syntax

program      := module_decl? item*
item         := type_decl | effect_decl | task_decl | agent_decl | import_decl
module_decl  := "module" module_path
import_decl  := "import" module_path
type_decl    := "type" Name "=" type_expr
effect_decl  := "effect" Name
task_decl    := "task" Name inputs? "->" type_expr uses? block
agent_decl   := "agent" Name block
binding      := "take" | "bind" | "state" | "gate" | "slot" | "knot"
uses         := "uses" gate_list
block        := "{" stmt* "}"
stmt         := binding_stmt | return_stmt | expr_stmt | if_stmt | while_stmt | for_stmt | forge_block

7. Effects And Authority

Sley treats side effects as explicit capabilities. A task that needs host authority declares and receives the gate it uses. The Loom can reject calls that cross an undeclared authority boundary.

effect DatabaseRead

task get_user -> Result<User, Error> uses DatabaseRead {
  take id: Text
  take gate db: DbRead

  bind row = call db.query_one("select * from users where id = ?", id)?
  return Ok(User { id: row.text("id"), name: row.text("name"), email: row.text("email") })
}

8. Swarm And Arena Model

task replaces the ordinary function as the arena-backed executable unit. agent names a long-running stateful Swarm participant. spawn, cast, call, absorb, join, race, and quorum describe agent work without importing old async/await assumptions.

forge { ... } creates a temporary isolated arena. Values that must outlive it are returned, traced, or sealed; temporary work melts down with the arena.

9. Structural Patching

The patch model is the AI-facing surface. Instead of asking an agent to rewrite arbitrary file text, Sley accepts graph operations such as:

  • graft a verified patch bundle.
  • splice a local subgraph insertion or replacement.
  • prune a dead branch.
  • move or rename stable declarations.
  • seal an immutable artifact and attach a trace.
  • Rename declarations.

Unsupported, stale, malformed, type-invalid, or unauthorized grafts return explicit diagnostics.

10. Native ZJX

ZJX is the default structural transport and cache envelope for the agent/compiler loop. Sley semantic identity should remain the canonical typed graph bytes until both the graph encoding and ZJX format are deterministic, canonical, and frozen. See ZJX Documentation for the transport boundary.

.sley       human-readable source projection
.sley.graph canonical graph bytes, if exposed
.zjx        compressed graph, graft, trace, or seal envelope

11. Current Limits

  • Lambdas, pattern matching, and multi-statement expression blocks are not complete.
  • Comment attachment and durable provenance storage are not complete.
  • run supports pure execution only.
  • The full binding ontology is canonical design direction, not all current parser syntax.
  • Some target Sley names are still being wired into every local tool.
  • Some patch operations are declared but intentionally return unsupported-operation diagnostics.

12. Next Work

The next useful implementation work is target binding syntax, richer module semantics, Swarm/agent examples, capability gates, ZJX shard transport, and broader graft operations.


Return to Sley home