Skip to content

About

A general-purpose, capability-oriented programming language built around canonical dyadic.ir/1.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Dyadic

Dyadic (dyadic-lang) is a general-purpose, capability-oriented programming language built around a single portable intermediate representation (dyadic.ir/1).

Pure functions (fn), effectful functions (fx), durable concurrent workflows (workflow), algebraic types and pattern matching, bytecode execution (dyadic.bc/1), WebAssembly 1.0 compilation, selective content-addressed replay, and fail-closed Black Box audit evidence all operate over the same canonical IR.

Licensed under the Apache License, Version 2.0.

Why Dyadic

Instead of stitching together separate tools for type checking, sandboxing, workflow orchestration, bytecode/Wasm execution, and audit trails, Dyadic unifies them through one compiler frontend and one canonical IR:

  1. Canonical IR as Source of Truth (dyadic.ir/1): Type, effect, and taint checks run before lowering to canonical IR (.dyc). Optimization (--opt), VM bytecode compilation (internal/vm), WebAssembly 1.0 emission (internal/wasm), workflow scheduling (internal/runtime), selective replay (internal/replay), and Matrix/POG interoperability (internal/interop) all consume dyadic.ir/1.
  2. Purity and Explicit Capabilities (fn vs. fx / workflow): Pure fn declarations cannot invoke host effects or read ambient external state. Effectful operations must declare capabilities (cap) with ordered risk levels (read < safe < mutate < danger), explicit signatures (with [...]), resource scopes (hosts, paths, commands), and runtime attenuation via .dys policy rules.
  3. Static Taint Boundaries (Tainted<T>): Untrusted inputs carry Tainted<T> and cannot flow into mutating or dangerous sinks without verify(...) or explicit require approval(...) gates.
  4. Multiple Verified Targets: Execute workflows directly on the DAG scheduler, compile pure code into dyadic.bc/1 stack bytecode, emit standalone WebAssembly 1.0 binaries with linear memory (--target wasm), or export pure subsets to .dm and /v1/pog.
  5. Write-Ahead Black Box Evidence: In enforce mode with audit write_ahead, mutating operations record RFC 8785 UTF-16 canonical JSON envelopes chained via SHA-256 and signed with Ed25519 checkpoints (dyadic.blackbox.bundle/1).
  6. Self-Hosted Compiler (std.compiler): std/selfhost.dy and std/compiler.dy tokenize, validate purity, resolve workflow dataflow $future dependencies, and emit schema-valid dyadic.ir/1 JSON executable across the VM, workflow runtime, and Wasm 1.0 (tested through Stage 2 self-compilation).

Design Scope (v0.2.0 Implemented vs. Roadmap)

Area Available in v0.2.0 Planned Roadmap
Core language (fn, fx, workflow, structs, enums, maps, generics, lambdas, ?, loops, match, test) Implemented Ongoing ergonomics and richer diagnostics
Portable IR (dyadic.ir/1) and --opt IR optimizer Implemented Whole-program specialization and link-time optimization
Execution targets Go DAG runtime, dyadic.bc/1 VM, WebAssembly 1.0 Native AOT .dyl codegen backend (extension reserved in ADR-0002)
Capability security and Tainted<T> enforcement Static compile checks + runtime leases + .dys policy rules Fine-grained effect polymorphism and low-level memory region controls
AI and agent abstractions Optional first-class role, agent, budget, within, agent.run primitives Pluggable inference providers and distributed worker transport
Developer tooling CLI, --opt IR optimizer, REPL, stdio LSP, formatter, TextMate grammar Editor extensions and package registry workflows

General-purpose programs and WebAssembly modules require no AI roles or model configuration to compile or execute.

Installation

Prerequisites

  • Go 1.26+ (zero third-party Go module dependencies)
  • Node.js 24+ (optional, for executing compiled .wasm tests)

Install with Go or Build from Source

go install github.com/DyadicOrg/dyadic-lang/cmd/dyadic@v0.2.0
dyadic version

Or build directly from a clone:

git clone https://github.com/DyadicOrg/dyadic-lang.git
cd dyadic-lang
go build -o dyadic ./cmd/dyadic
./dyadic version

Pre-built binaries and SHA256SUMS.txt are published on GitHub Releases for Linux (amd64, arm64), macOS (amd64, arm64), and Windows (amd64, arm64).

Quickstart

Pure Functions, Generics, and WebAssembly (examples/wasm-math)

./dyadic test examples/wasm-math
./dyadic build examples/wasm-math --target wasm -o build/math.wasm
./dyadic build examples/wasm-math --target vm -o build/math.dybc
./dyadic run build/math.dybc --graph fib --param n=10

Capability-Gated Workflow with Black Box Evidence (examples/research-agent)

./dyadic check examples/research-agent
./dyadic test examples/research-agent
./dyadic build examples/research-agent --target ir -o build/research.dyc
./dyadic run build/research.dyc \
  --sandbox ./sandbox \
  --approve \
  --param url=https://dyadic.app/docs \
  --bundle build/research.bundle.json
./dyadic verify build/research.bundle.json

Create a New Workspace

./dyadic init my-app
cd my-app
../dyadic check .
../dyadic build -o build/my-app.dyc .
../dyadic run build/my-app.dyc

File Types

  • .dy: Primary Dyadic source files (fn, fx, workflow, type, enum, cap, role, agent, budget, test)
  • .dyt: Contract and type interfaces (bodyless signatures, structs, enums, capabilities, roles)
  • .dyw: Standalone workflow files
  • .dyp: Package and skill bundle declarations (package, version, requires)
  • .dys: Runtime and policy defaults (system, mode, audit, budget, allow, ask, deny)
  • .dyc: Compiled canonical dyadic.ir/1 artifact (program, library, or workflow)
  • .dyl: Reserved per ADR-0002 for future native OS library linking

CLI Commands

  • dyadic check <path>: Parse and run type, capability, taint, and policy checks
  • dyadic build [--target ir|vm|wasm] [--opt] [--lock] [-o path] <path>: Compile to .dyc, .dybc, or .wasm
  • dyadic run [--vm] [--opt] [--graph name] [--param k=v] [--sandbox dir] [--approve] [--shell] [--bundle path] [--trace path] <path>: Run source, .dyc, or .dybc
  • dyadic test <path>: Execute embedded test "..." { ... } blocks
  • dyadic disasm [--opt] <path>: Disassemble pure functions into dyadic.bc/1 bytecode instructions
  • dyadic inspect [--schema] [--opt] <path>: Print IR/bytecode summary, capabilities, and budgets
  • dyadic verify [--schema] <path>: Verify a Black Box evidence bundle or IR/evidence schema conformance
  • dyadic replay --prev <a.dyc> --trace <trace.json> --next <b.dyc>: Compute content-addressed selective replay plan and re-run safely
  • dyadic export-pog [--submit url --token bearer] <path>: Export workflow DAG as a dyadic.pog.plan/1 manifest
  • dyadic matrix-check <path> / dyadic matrix-export [-o out.dm] <path>: Check and export deterministic pure subsets as Matrix (.dm)
  • dyadic fmt [--check] <path>: Format .dy, .dyt, .dyw, .dyp, .dys source files
  • dyadic lsp: Run stdio Language Server Protocol server (diagnostics, hover, definitions, dot-completions)
  • dyadic repl: Interactive expression, declaration, type, and bytecode shell
  • dyadic init [dir]: Initialize a new Dyadic project (dyadic.toml, dyadic.lock, src/main.dy)
  • dyadic version: Print toolchain and IR/bytecode/evidence schema versions

Repository Structure

  • cmd/dyadic/: CLI, REPL, --opt and Stage 2 self-hosting bootstrap tests
  • internal/lexer/, internal/ast/, internal/parser/: Lossless lexer, typed AST, and parser
  • internal/types/: Type inference, generics, purity, capability subset, and Tainted<T> checker
  • internal/ir/: Canonical dyadic.ir/1 representation, builder, digests, and --opt IR optimizer
  • internal/runtime/: Concurrent DAG scheduler, pure evaluator, capability leases, budgets, and durability ledger
  • internal/vm/: Stack bytecode compiler and bounded VM (dyadic.bc/1)
  • internal/wasm/: Standalone WebAssembly 1.0 compiler with linear memory and runtime helpers
  • internal/replay/: Content-addressed selective replay analyzer and re-executor
  • internal/blackbox/: RFC 8785 UTF-16 canonical JSON, salted commitments, and Ed25519 bundle verifier
  • internal/interop/: JSON Schema validators, /v1/pog exporter, and Matrix (.dm) parity bridge
  • internal/format/, internal/lsp/, internal/project/: Code formatter, stdio LSP, and manifest/lockfile loader
  • std/: Embedded standard library (core.dyt, math.dy, collections.dy, text.dy, verify.dy, selfhost.dy, compiler.dy)
  • schemas/: JSON Schemas (ir.schema.json, evidence.schema.json)
  • editor/syntaxes/: TextMate grammar for .dy, .dyt, .dyw, .dyp, .dys
  • docs/: Language Spec, Core IR Spec, Architecture, and ADRs
  • examples/: Runnable hello, research-agent, and wasm-math workspaces

Verification

gofmt -l .
go vet ./...
go test -count=1 ./...
go run ./cmd/dyadic test std
go run ./cmd/dyadic test examples/hello
go run ./cmd/dyadic test examples/research-agent
go run ./cmd/dyadic test examples/wasm-math
go run ./cmd/dyadic fmt --check examples std

Contributing and Security

  • See CONTRIBUTING.md for development guidelines and architectural invariants.
  • See SECURITY.md for private vulnerability reporting and security boundaries.

About

A general-purpose, capability-oriented programming language built around canonical dyadic.ir/1.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages