v0.1 · MIT

A differentiable physics kernel for verifiable domain operations.

Every timestep derives from one Lagrangian, expressed as a typed graph. Scenes pick the participating terms; solvers are programs over the graph.

starting engine…
avbd_stack_1000.lagra
starting engine…
lagrangian_dam_break.lagra

Same engine binary, different active LagrangianNodes. Drag any block on the left; click play on the right to release the dam.

From .lagra source to live render

The entire source for the two-bead oscillator on the right. The compiler reads this file, the kernel walks the resulting graph, the solver advances state, the renderer reads pixels. Nothing else.

scene solver_walkthrough_oscillator {
    uses newtonian.classical_mechanics
    description "Two-bead harmonic oscillator."
    wasm true                  // landing-page bundle

    entity { type: ball_small,
        position: [-1.35, 0, 0],
        mass: 1.0, size: 0.35 }
    entity { type: ball_small,
        position: [ 1.35, 0, 0],
        mass: 1.0, size: 0.35 }

    bond harmonic [0, 1] {
        k: 2.0, r0: 2.0, damping: 0.04 }

    solver { dt: 0.002,
              steps_per_frame: 12 }
}
starting engine…
solver_walkthrough_oscillator.lagra

Every token on the left maps to a typed object the engine evolves on the right. The Lagrangian-graph compilation and the verifiability-by-derivation framing for this scene are written up in the paper.

Eight harmonic bonds, one Lagrangian

Nine particles, eight HarmonicBond nodes, one UniformAcceleration for gravity. The kernel doesn't know it's a "chain" — it just walks eight pairwise terms.

arrows show net force per bead · drag any bead · ▮▮ pauses · reset re-seeds

entity bead   { mass: 1.0,   size: 0.4  }
entity anchor { mass: 1.0e8, size: 0.15 }  // huge mass → pinned

scene pendulum_chain {
    uses newtonian.classical_mechanics
    environment classical_gravity

    entity { type: anchor, position: [0,  3.50, 0] }
    entity { type: bead,   position: [0,  2.95, 0] }
    // 7 more beads, each 0.55 below the previous

    bond harmonic [0, 1] { k: 120, r0: 0.55, damping: 0.10 }
    // 7 more pairwise bonds with the same {k, r0, damping}

    solver { dt: 0.003, steps_per_frame: 12 }
}
starting engine…
pendulum_chain.lagra

IDE, MCP server, and projects

Lagra is designed to ship inside an agent harness — Claude Code, Codex, or its own desktop IDE — and to be driven by code as readily as by hand.

crates/lagra-ide drives the same engine as the wasm demos above, with live validator overlays, per-particle drill-down, scene-source editing, and an MCP agents tab. Scenes spawn sub-agents that hold a typed handle to the running World and register actions as typed InterventionKind events.

Projects (avbd, optical_lagrangian, quantum_distillation, rigidformer) extend the runtime without bloating the kernel — see the repo for catalogs.

crates/lagra-ide · Albert agent in the bottom terminal scene tree · inspector · MCP agent

Advancing science

Because the entire engine is governed by a single equation, that equation itself can be changed — and the consequences measured everywhere at once. Every change becomes a falsifiable claim against the 66-scene regression suite.

The DNA helix on the right folds from first principles — 60 coarse-grained particles under Coulomb + harmonic bonds + base-pair stacking, no empirical Turner parameters in the force field. The same engine runs first-principles RNA folds, a qubit-Hamiltonian bridge for quantum-hardware execution, and the Albert harness — inspired by DeepMind's AI mathematician — which proposes Lagrangian modifications and validates each candidate against the suite.

→ project details on about, source in the repo.

starting engine…
dna_double_helix.lagra

Games & performance

Interventions are a natural fit for game-style state. Instead of coding mechanics, you insert entities and forces into the equation — gameplay logic and physics share the same scripting surface.

One codebase: native, mobile, wasm. The bundle on this page is ~800 KB gzipped, full parser + solver + CPU rasterizer included. On native, an optional gpu feature adds a wgpu compute-shader overlay without changing the pipeline.

Jenga — pull a block, drop the tower

36 rigid bodies, 12 layers of 3, settled on a friction floor. Drag any block — the red dot attaches a damped-spring intervention through the same surface a gameplay scripting hook would use. AVBD's contact solver keeps the stack stable through small perturbations and topples it gracefully when you yank too hard.

starting engine…
avbd_jenga_tower.lagra

Machine learning

Differentiability is intrinsic to the Lagrangian — particles compute differentials at every step that flow back into the environment, yielding exact gradients over long trajectories for reinforcement learning, neural surrogates, or discovery loops. Trained modules (e.g. rigidformer in for AVBD's pairwise contact pass) swap in as sub-Lagrangians inside the same kernel, falling back to the exact evaluator when drift exceeds tolerance.

Conservation verifiers gate every step, so the engine trains against its own outputs without drifting off-physics. The Lagrangian formalism is scale-agnostic: the same engine simulates Q-desic geodesics around black holes and femtometer molecular dynamics, and automated agents exploring this parameter space can surface cross-scale connections that human intuition misses.

Lagra pipeline: .lagra source → Lagrangian Graph → Action Kernel → Solver → Verifier, with PASS feeding the next frame and FAIL halting the run. compile-time per-step (runtime loop) .lagra source scene as typed declarations Lagrangian Graph vertices = DoF, edges = ℒᵢ Action Kernel walks the graph, emits force F Solver Verlet / RATTLE / AVBD Verifier conservation each frame PASS → next frame   ·   FAIL → halt
Same pipeline for the 1000-block stack, the dam-break fluid, and the DNA helix — only the active edges differ.
→ Read more · every layer with math, code, and visuals

The verifiable physics loop

Twelve typed layers, Noether-gated each frame — the engine the ML on the left trains against.

01.lagra sourcetext
02lexertokens
03parserAST
04type checktyped AST
05compileLagrangianGraph + Stepper + Verifier
06bootstrapWorld[0]
07action kernelFi = −∂V/∂qi
08solverWorld[N+1]
09verifierPASS / FAIL
10render planframe decision
11rasterizerpixel buffer
12outputcanvas / surface / png
→ deep dive · every layer with math, code, and visuals