High-order perturbation theory, cluster sharding, bootstrap operator-basis selection, and IBP pivot ordering involve vast combinatorial search spaces where physical intuition pays off. Weyl lets an LLM guide these decisions under one safety invariant: the LLM is strictly an untrusted superoptimization and tactic-suggestion pass with zero direct write access to the algebraic kernel.
Replacing the LLM with a purely random scheduler yields either bit-identical published output or an explicit oracle rejection—an LLM can never forge or alter a single rational coefficient.
LLM proposals carry no error tag
A rewrite proposed by an LLM never enters the derivation in an "unverified" state. The trusted kernel first checks that the candidate SIR is equivalent to the current templates (an E-Graph equivalence proof, or identical normal forms with geometry, topological data and ΔQ selection rules preserved). If the check passes, the candidate replaces the templates; otherwise it is rejected. There is therefore no LLM source in EpiSource: an accepted rewrite is indistinguishable from a hand-written template.
Capability-Scoped MCP Tool Surface (weyl-mcp)
weyl-mcp is a pure library defining strongly typed schemas, budget enforcement, and the replay log; the MCP server itself is launched by weylc mcp <file> over stdio, delegating validated actions to weylc's Pass Manager. The protocol exposes exactly 7 least-privilege tools, with no write endpoints into KIR term streams, accumulators, or rational tables:
| MCP Tool | Access | Capability Boundary & Role |
|---|---|---|
weyl.graph.inspect | Read | Inspect DeriveGraph node states, error tags, and oracle verdicts |
weyl.ir.stats | Read | Read SIR/KIR peak term counts, peak memory, spill bytes, and cluster counts |
weyl.passes.list | Read | List available passes and their parameter JSON Schemas (the LLM's entire parameter space) |
weyl.schedule.submit | Schedule | Submit a pass sequence and parameter plan; validated against Schema and budgets |
weyl.run.telemetry | Read | Stream structured telemetry records and deterministic compiler hints |
weyl.rewrite.propose | Propose | Propose an SIR template rewrite; accepted only after exact algebraic equivalence proof |
weyl.budget.status | Read | Query remaining CPU-hour, wall-minute, memory, disk, and action quotas |
In Phase 1, the LLM may tune expansion-order pacing, cluster enumeration order and sharding, prime-field count , memory budgets, ED cylinder sizes and sectors, and retry policies. Phase 2/3 extend this to bootstrap operator-basis selection, tensor contraction orders, IBP pivot ordering, and confidence-gated neural potentials via weyl-neural-rt.
Proposal–Verification Loop & Action Schema
Every LLM interaction executes inside a closed proposal–verification loop. First, the LLM observes the current state by querying weyl.graph.inspect, weyl.ir.stats, and weyl.budget.status, and then proposes an action by submitting a weyl.action envelope (schedule.submit or rewrite.propose). Before anything runs, weyl-mcp enforces a strict schema and budget gate, rejecting unknown fields via #[serde(deny_unknown_fields)], validating Pass::Params against its JSON Schema, and checking SessionBudget caps.
Validated actions then undergo kernel or oracle verification depending on their kind. A rewrite.propose action is scoped strictly to SIR templates and is accepted only if the trusted kernel checks an exact E-Graph proof or verifies that the template difference reduces to exact zero in canonical normal form (numerical ED agreement never authorizes a symbolic rewrite); rejected proposals are discarded cleanly with zero side effects. A schedule.submit action is handed to the Pass Manager, which executes the plan and runs the bound oracle (free-fermion, ED, or Lean 4).
// crates/weyl-mcp/src/lib.rs — Sandboxed action envelope and session budget
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct SessionBudget {
pub cpu_hours: f64, // Default: 1.0
pub wall_minutes: u64, // Default: 15
pub max_mem_gb: u32, // Default: 16
pub max_actions: u32, // Default: 64
pub max_disk_gb: u32, // Default: 64 (caches and spilled chunks)
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
pub struct ActionEnvelope {
pub schema: String, // Must be "weyl.action"
pub kind: ActionKind, // schedule.submit | rewrite.propose
pub graph: String, // Target DeriveGraph id and hash
pub plan: Vec<PlannedStep>, // Scheduled pass nodes and parameters
pub rationale: Option<String>, // Logged for human audit only; never parsed by compiler
pub budget: ActionBudget, // Per-action sub-budget
}Example weyl.action Schedule Proposal
{
"schema": "weyl.action",
"kind": "schedule.submit",
"graph": "toric_boundary@a1b2c3",
"plan": [
{ "node": "pcut.coeffs", "params": { "max_order": 12, "n_set": [-2, 0, 2], "energy_quantum": 2 } },
{ "node": "cluster.eval", "params": { "order": 12, "primes": 4, "shard": "by_cluster_length", "mem_gb": 64 } },
{ "node": "oracle.free_fermion", "params": { "order": 12 } }
],
"rationale": "order 10 passed; push to 12 before attempting Stage B",
"budget": { "cpu_hours": 4.0, "wall_minutes": 30 }
}Symbolic Rewrite Proposals (rewrite.propose) & Exact Verification
When the LLM suggests simplifying SIR templates via a local unitary transformation or algebraic identity, it submits kind: "rewrite.propose" alongside a candidate SirModel. The compiler ignores the prose rationale and invokes weyl-egraph / weyl-canonical to verify exact zero difference in canonical normal form:
{
"schema": "weyl.action",
"kind": "rewrite.propose",
"graph": "toric_boundary@a1b2c3",
"plan": [],
"rationale": "combine symmetry-equivalent boundary plaquettes before cluster enumeration",
"budget": { "wall_minutes": 2 }
}If the check passes, the rewrite is adopted; if it fails, the proposal is rejected and the templates are unchanged. A rejected proposal still counts as an executed action: it is logged and counted against the quota.
Deterministic Telemetry & Diagnostics (weyl.telemetry)
Whenever a pass or oracle fails, the compiler emits a structured weyl.telemetry record. All hints are generated strictly by deterministic compiler rules (e.g. first appearance of a cluster length, first activation of a channel, or memory spill thresholds)—never by an LLM:
{
"schema": "weyl.telemetry",
"run_id": "r-000173",
"node": "cluster.eval",
"status": "oracle_failed",
"ir": { "layer": "KIR", "terms_peak": 48211033, "bytes_peak": 21474836480, "spill_bytes": 0, "clusters": 13 },
"timing_ms": { "wall": 412000, "normalize": 155000 },
"err": { "trunc": { "kind": "Box", "x": 13 }, "epi": null },
"oracle": {
"kind": "ed",
"verdict": "fail",
"observable": "gap",
"sectors": { "vacuum": { "momentum": "0", "wilson_top": 1 }, "excitation": { "momentum": "pi", "wilson_top": -1 } },
"residual_slope": 8.9,
"expected_slope": 13.0,
"precision": "double-double",
"size_L": 16,
"first_bad_order": 8
},
"hints": ["terms at order 8 involve clusters of length 9 for the first time"]
}Hash-Chained Logs & Bit-Exact Replay (weylc replay)
Scientific derivations must remain reproducible even after LLM model weights change or hosted APIs disappear. To guarantee this, weyl-mcp/src/replay.rs writes an append-only JSONL replay log (weyl.replay) for every MCP session. The first line is a ReplayHeader embedding the full source text, source_sha256, and SessionBudget. Each accepted action appends a chained ReplayEntry recording its sequence number seq, an audit timestamp unix_ms (never an input to computation), the action envelope, any optional SIR candidate, and an input digest chaining all prior state:
Running weylc replay run.jsonl then re-executes the entire session offline without any LLM, verifying every result_sha256 against the recorded digest and failing immediately on a single-byte divergence.
// crates/weyl-mcp/src/replay.rs — Append-only hash-chained replay log entry
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ReplayEntry {
pub seq: u64,
pub unix_ms: u64, // Audit timestamp (never a compute input)
pub input_sha256: String, // Chains source + prev_result + action
pub action: ActionEnvelope,
pub candidate: Option<serde_json::Value>, // Candidate SIR for rewrite.propose
pub run_id: String,
pub result_sha256: String, // SHA-256 of canonical result document
}Neural Runtime & Confidence Gating (weyl-neural-rt)
weyl-neural-rt applies the same untrusted-accelerator rule to neural potentials. Its degree of freedom is a molecular configuration (species and Cartesian positions); the energy is a sum of atomic energies, each a small network over radial symmetry functions of the atom's neighbourhood, and the forces are the exact gradient of that energy. A model is a committee of independently fitted networks, stored as JSON; train::fit fits one deterministically from reference energies.
Every prediction returned by the runtime is strictly epistemic: it is an Evaluation graded with Err::epistemic and the source NeuralPotential { model }, with no constructor capable of producing an exact grade from a network output. Alongside the predicted value, the committee's variance and its individual members' values travel as a RuntimeUncertainty. During inference, Runtime::evaluate rejects a prediction whenever the committee's energy or force spread exceeds its configured threshold or a descriptor falls outside the range seen in training. When a Reference fallback (such as an analytic potential or external code) is supplied, the fallback answers instead and the result records who answered and why—following the semantics of require … otherwise …; without a fallback, the gate violation is a hard error.
In the test suite a committee of four networks is fitted to a Morse trimer: inside the training range it is accepted and accurate, and all three out-of-range molecules are sent to the fallback, or rejected when there is none.
Not yet connected
The runtime is a library. Molecular configurations are not yet a kind in the surface language, and the compiler's require uncertainty … otherwise … gate does not call it. The descriptor is two-body (radial) only, and there is no ONNX import.
# 1. Run a budget-bounded MCP sandbox session with append-only logging
$ weylc mcp examples/toric_boundary.weyl \
--log run.jsonl --cpu-hours 1 --wall-minutes 15 --max-actions 64
# 2. Replay the entire run offline without an LLM and verify every digest
$ weylc replay run.jsonl
[replay] source sha256 verified: a1b2c3...
[replay] seq 1/12 (schedule.submit) -> result sha256 OK
...
[replay] all 12 actions replayed bit-identically (0 mismatches)Zero-LLM Baseline Scheduler
Weyl never requires an LLM to run. weylc ships a deterministic built-in heuristic scheduler (advancing order by order and halting on failure) that completes Stage A standalone. In CI, heuristic, random, and LLM schedulers are benchmarked side by side: wall time and retry counts may vary, but published outputs must match bit for bit.
Three-Way Scheduler Benchmarks & Regression
Nightly CI runs the same derivation under three distinct schedulers and treats digest equality as a hard regression test that the LLM never changes results:
| Scheduler Mode | Decision Source | Permitted Variations | Mandatory Invariant |
|---|---|---|---|
| Built-in Heuristic | Fixed rule (order-by-order) | Wall time, peak RAM | Completes Stage A standalone |
| Random Scheduler | Seeded random valid actions | Oracle failure count, step count | Published output bit-identical to baseline |
| LLM MCP Scheduler | External model via weylc mcp | Wall time, sharding efficiency | Published output bit-identical; replays offline |
Any 1-byte divergence from the golden digest—or any unverified rewrite.propose leaking into DeriveGraph—blocks the build immediately.