Safe concurrent engineering for MoonBit agent fleets

Selûne lets coding agents edit one MoonBit repository in parallel. It isolates their changes, validates them, and commits through Git.

Measured on a 7-package fixture with up to 1,000 sandbox cells; 100–1,000-agent fleet throughput is a sensitivity model (see provenance table).

Selûne Astrolabe of Seven Silver Stars emblem anchoring the MoonBit 1.0 RC1 platform

Why raw Git and shell scripts fail for concurrent agents

Ordinary Git remains the sole authority in Selûne. Every derived index, context pack, and evidence record is content-addressed and rebuildable—solving six structural failure modes in multi-agent coding.

Text patch collisions

Raw unified diffs conflict whenever concurrent edits shift nearby lines or rename a symbol. Selûne records typed EditOp plans against LogicalDefId read sets and replays stale candidates semantically onto moved heads.

Wasted revalidation

File-level hashing forces full rebuilds on comments and private body tweaks. Separating InterfaceDigest (.mbti) from alpha-normalized BodyDigest limits invalidation strictly to affected closures and reuses drift-audited cache verdicts.

Untrusted agent execution

Agent-authored tests and build scripts execute inside hermetic Linux bwrap --unshare-all --unshare-net worktree cells with private object directories, supervisor-only CAS landing, and anti-cheat policy gates.

Bloated & hostile context

Whole-file reads waste tokens and expose agents to prompt injections in comments or docs. Staged moonbit-context-pack/1 bundles maximize prompt-cache hits, isolate held_out_tests/, and quarantine injections with grants_permissions=false.

Unchecked protocol races

Speculative batching, lease expiry, and worktree reclamation hide subtle races. Selûne proves both protocol models in Quint 0.35 + Veil 2.0 + Lean 4.35 (code refinement tracked open) and runs 1,000,000 seeded DST schedules.

Optional layer lock-in

Graphify non-code links, Neo4j/OGS 1.1.0 projections, SCIP exports, and C-ABI keyed crypto sit strictly outside the commit path. Removing any optional overlay degrades gracefully without affecting commit safety.

Requirements, Maturity & Incremental Adoption

You do not have to adopt all 20 libraries at once. Adopt read-only retrieval, Linux cells, MCP, or standalone MARS 1.0 independently—with explicit platform constraints and maturity labels up front.

Platform & Toolchain Constraints

  • Linux-only sandbox: Hermetic execution uses Linux bwrap, cgroups v2, and optional btrfs CoW _build seeding. macOS and Windows users can run Tier 0 (moon test, standalone native libs/mars) without Linux namespaces.
  • Pre-release compiler: Pinned to MoonBit 1.0 RC1 (compiler moonc v1.0.0-rc1+3c0520448, CLI moon 0.1.20261126)—expect release-candidate churn until 1.0 GA.
  • Proof scope boundary: All 18/18 Lean 4.35.0 proofs verify protocol models (commit_queue.qnt and cell_lifecycle.qnt); code-level refinement (QueueImplementation) remains open.
  • Operational footprint: SQLite index rebuild took 3.9 s on 96 facts (7-package Ledgerflow); Lean/Veil/Quint proof checks require a separate formal toolchain install (Tier 2).

Adopt One Piece at a Time

  • MARS 1.0 (libs/mars/ & mars-next/) Beta · Standalone — Pure MoonBit 1.0 RC1 requirement-to-proof ledger (zero Python dependency) usable on any language repo without Selûne (standalone guide).
  • Fact Store & agentic find Beta — Read-only SQLite compiler symbol index (0.95 ms live retrieval on Ledgerflow) adoptable before any merge automation.
  • Worktree Cells & bwrap Sandbox Beta · Linux — Isolated candidate execution, private object directories, and automated GC.
  • Stateless MCP 2026-07-28 Gateway Beta — Horizontal HTTP/stdio tool gateway for external agent fleets.
  • Speculative Commit Queue & Fleet Orchestration Experimental — Protocol-model-proved and DST-tested; code refinement open.

How the Pieces Fit Together

Component Role Standalone? Where to Start
MoonBit 1.0 RC1 Programming language, compiler (moonc v1.0.0-rc1), CLI (moon 0.1.20261126), moon ide, and native SMT prover (moon prove). Yes (upstream) toolchain.lock
Selûne Agent engineering platform wrapping MoonBit and Git with facts, semantic replay, Linux worktree cells, validation, and stateless MCP. Modular (adopt by layer) Tools & API · Architecture
MARS 1.0 Language-agnostic formal obligation ledger linking requirements to Quint/Veil/Lean proofs and run receipts. Yes (native MoonBit binary + optional Lean) MARS 1.0 Guide · 3D Proof Orrery
DrWatt External IOG requirements harness storing structured EARS sentences (requirements.json) and runnable checks hashed by MARS. Yes (external tool) Verification
OpenSpec Behavioral Markdown specifications (specifications/) and ruling-authorized change deltas (ADDED/MODIFIED/REMOVED/RENAMED). Yes (spec convention) Governance Deltas
llm-wiki/ & SIM Compiled LLM knowledge base (29 pages across 12 sources, 7 entities, 7 concepts, 3 syntheses) + 4 SIM root-cause entries, llm-wiki/tools/{lint,sim}.py, libs/knowledge/wiki.mbt, ./bin/selune wiki, and 3 read-only MCP tools (agentic_wiki_index, agentic_wiki_lint, agentic_wiki_query)—strictly fail-open and off the commit path. Yes (optional overlay) Knowledge & SIM · Tools
SelûneCraft Browser WebGL2 end-to-end fixture compiled from MoonBit 1.0 RC1 with an interactive HTML launcher and requirements SC-001..SC-006. Yes (browser fixture) HTML Launcher · Examples

The Circle of Seven Silver Stars

Twenty self-contained MoonBit 1.0 RC1 modules organized into seven calibrated subsystems, each enforcing explicit schema and trust boundaries.

1. Toolchain, Syntax & Identity

libs/toolchain, libs/syntax, libs/identity — Pinned toolchain.lock, bounded Tree-sitter C bridge, LogicalDefId, InterfaceDigest, and alpha-normalized BodyDigest.

2. Typed Fact Store & Shards

libs/facts, libs/export, schemas/ — 13 entities, 12 relationships (no unqualified proves), 8 distinct provenance classes, atomic SQLite WAL, structural shard sharing, and OGS 1.1.0 / SCIP export.

3. Structured Edits & Replay

libs/edit — 7 typed EditOp variants, read-set tracking, transitive rename composition, and compiler-backed replay onto moved heads.

4. Hermetic Validation & Evidence

libs/validate, libs/evidence, libs/cache — Bubblewrap sandboxes, exact 10-state non-upgradable verdict vocabulary, DSSE/SLSA attestations, SARIF 2.1.0, and >=1% sampled drift checking.

5. Worktree Cells & Lunar GC

libs/cells — Detached locked worktrees, private GIT_OBJECT_DIRECTORY, btrfs CoW _build seeding, CAS lease registry, and single-collector 6-phase lunar reclamation.

6. Runtime, Queue & DST

libs/runtime, libs/queue, libs/sim — Flat multi-reason Cause[E], exit-aware Scope, TxRef STM, object-store git merge-tree --write-tree speculative batches, bisection, and 1M-schedule DST.

7. Policy, Context & Stateless Gateway

libs/policy, libs/context, libs/knowledge, libs/cli, libs/mcp, libs/telemetry, libs/crypto_ffi — Anti-cheat gates, injection-hardened packs, opt-in Graphify, agentic CLI, and stateless MCP 2026-07-28.

Milestone Verification Scorecard

Every figure carries explicit provenance distinguishing live host measurements, machine-checked protocol proofs, and analytical sensitivity models.

20 MoonBit Modules Syntax, identity, facts, replay, Linux cells, queue, runtime, policy, context, and MCP.
18 / 18 Lean 4.35 Model Proofs Protocol models (7/7 queue + 11/11 cells; 0 sorry); code refinement open (QueueImplementation).
10 / 10 Live moon prove & 15 / 15 Cell Gates 4/4 queue + 6/6 Ledgerflow kernel goals (0 timeouts) and 1,000,000 seeded DST schedules.
Milestone Gate & Verified Evidence Provenance
M0 Pinned MoonBit 1.0 RC1 (moonc v1.0.0-rc1+3c0520448, CLI moon 0.1.20261126); 3/3 byte-identical check outputs and .mbti files under LC_ALL=C TZ=UTC. Measured Live
M1 34/34 mutation corpus + 4/4 live Ledgerflow moon info mutations: body edits preserve InterfaceDigest; Draft 2020-12 & OGS 1.1.0 schemas validated (0 errors). Measured Live
M2 9/9 seeded replay corpus + live Ledgerflow Worked Example B pass semantic replay where 3-way git merge-file conflicts. Measured Live
M3 Hermetic Linux bwrap --unshare-all --unshare-net escape probes blocked, 0% cache drift on sampled reruns, non-servable timeout/tool-error verdicts. Measured Live
M4 18/18 Lean 4.35.0 standard-axiom proofs (protocol models: 7/7 commit queue incl. inv_all + 11/11 cell lifecycle; 0 sorry, 0 SMT trust; code refinement open in QueueImplementation), 11,437,544 bounded finite-instance exhaustive Veil 2.0 states (0 violations, Level 1 evidence), 34/34 ITF traces (335/335 states), and 1,000,000 DST schedules. Machine-Checked (Models)
M5 17/17 seeded test/spec weakening attacks blocked (100%); scoped bwrap mutation testing kills 13/13 mutants; infrastructure errors classified separately from kills. Measured Live
M6 10/10 prompt injections + 12/12 secret canaries flagged (0 benign FP); 3x byte-identical context pack & manifest digests; held_out_tests/ isolated. Measured Live
M7 / Cells 15/15 live Linux worktree-cell host gates (private per-cell GIT_OBJECT_DIRECTORY, exclusive validation slots, 4-valued cgroup observation, collector lease fencing; 1,000 sandbox cells created/reclaimed in 2.09 s). Virtual-clock fleet scaling across 10/100/1,000 simulated agents is separately marked simulated. Measured Live Sensitivity Model
M8 / Benchmark 810 raw blinded paired trials on 7-package Ledgerflow: SQLite facts cut live retrieval to 0.95 ms (87.59% recall); Full Stack vs rg cuts -2,599.9 tokens & -13.57 ms live (identical retrieval to Arm D; cost reduction & fleet throughput are analytical sensitivity models, never measured production defaults); Arm F (Neo4j Bolt) is Not Measured Offline. Measured Live Sensitivity Model Not Measured Offline
M9 / Provers & FFI 10/10 live moon prove goals (4/4 queue + 6/6 Ledgerflow kernel under both default & prelude_proof_machine_int, 0 timeouts); C-ABI keyed HMAC FFI (2,145 C assertions + 368 RFC 4231 vectors); SelûneCraft WebGL2 fixture (322k raycasts/s, SC-001..SC-006). Measured Live

Three-Command Quickstart

export PATH="$HOME/.moon/bin:$PATH" LC_ALL=C TZ=UTC

# 1. Verify pinned toolchain & 3-run byte-identical M0 reproducibility
python3 libs/toolchain/runner/moon_runner.py --cwd libs/toolchain m0-repro --runs 3

# 2. Index beta-app/ledgerflow into the SQLite sharded fact store & query symbols
python3 libs/facts/tools/index_workspace.py --repo beta-app/ledgerflow --store /tmp/selune-store
./libs/cli/bin/agentic --repo beta-app/ledgerflow find --name verify

# 3. Check a standalone MARS 1.0 obligation module (pure MoonBit libs/mars compiler)
./bin/selune mars check mars-next/examples/token_escrow/obligations.mars --fresh