Move the engine core into core/, a project of its own (pplus-core)

What programs mean (the languages, translators, Mojo checker and
interpreter, prover, fuzzer, machine model, catalog problems and the Mojo
corpus with godbolt's stored answers) was mixed into the site's tree, so a
change to the prover and a change to a button went through the same gate
and the same docs. This moves all of it under core/, laid out as its own
repository, ready to be extracted with its history and pinned here as a
git submodule.

- core/: src/{engines,services,sync,mojo,exercises,curriculum,common},
  mojo/, syntax/mojo.xml, its tests (with Workspace and workForProblem in
  place of the site's Session), scripts (corpus pipeline, play, the
  exercise and probe starters, engines export/diff), and its docs
  (engines, trust, mojo-corpus, exercises, coverage). Its own pixi.toml,
  package.json, README, AGENTS.md and CI workflow.
- core/tests/boundary.test.mjs: library modules use no DOM, import no
  page widget, and import nothing outside src/.
- core/scripts/cli.mjs: pixi run cli check|run|prove|fuzz|translate.
- core/scripts/dafny.py: Dafny 4.11.0 pinned by version and SHA-256 per
  platform, fetched into .tools/ (pixi run dafny-fetch, pixi run dafny).
- The site imports core only as #core/<path>.js: an import map in
  index.html, "imports" in package.json for node, core's declarations for
  tsc. The site's TypeScript builds core first (npm run build).
- assemble.sh, the Quarto engine copy, the render cache key, check-pages,
  quarto-export and quarto-css read core/dist and core/mojo; quarto-css
  copies core's syntax/mojo.xml into the extension.
- Site tests that covered engines moved to core; the rest keep Session.
- README, AGENTS.md, docs/app.md, docs/deploy.md and the CI workflow
  describe the split (checkout with submodules; core's tests and corpus
  status run against the pinned commit).

Gate: site 110 pass; core 307 pass; corpus status --strict passes.
Manual check: the assembled site opens Bridge (count-base-proved),
Developer and Hardware (count-base) with the editor, the stepper and the
board, and no module errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
This commit is contained in:
alexmandClaude committed 2026-10-05 05:43:58 +00:00
1 parent f43bbfe0cf
commit 82e18f7966
1567 files changed
+3670 -981

No files matched your search

@@ -0,0 +1,2 @@
def boot():
print("MQ Robotics control daemon starting")
@@ -0,0 +1,2 @@
def main():
print("MQ Robotics nav stack online")
@@ -0,0 +1,6 @@
heartbeat() -> String:
return "heartbeat ok"
def main():
print(heartbeat())
@@ -0,0 +1,6 @@
def grid_cells(rows, cols):
return rows * cols
def main():
print("Grid cells:", grid_cells(3, 4))
@@ -0,0 +1,8 @@
# Ring-buffer helpers for the sensor ingest loop
def grow_capacity(n: Int) -> Int:
return n # TODO: should double the buffer's capacity
def main():
print("New capacity:", grow_capacity(21))
@@ -0,0 +1,6 @@
def log_command(name: String) -> String:
return "Dispatching command: " + name
def main():
print(log_command("rotate-90"))
@@ -0,0 +1,6 @@
def set_limits(max_speed: Int, max_accel: Int):
print("speed:", max_speed, "accel:", max_accel)
def main():
set_limits(5, 2)
@@ -0,0 +1,6 @@
def spin_up(rpm: Int, ramp_ms: Int) -> Int:
return rpm + ramp_ms
def main():
print("total:", spin_up(900))
@@ -0,0 +1,8 @@
def run_diagnostic(name: String, *, verbose: Bool) -> String:
if verbose:
return name + " [verbose]"
return name
def main():
print(run_diagnostic("imu", True))
@@ -0,0 +1,9 @@
def total(readings: Int) -> Int:
var s = 0
for r in readings:
s += r
return s
def main():
print("sum:", total(3, 4, 5))
@@ -0,0 +1,7 @@
def run_self_test():
# TODO: implement the real self-test later; this is just a stub
def main():
run_self_test()
print("self-test stub ran")
@@ -0,0 +1,6 @@
def footprint(side: Int) -> Int:
return side * side
def main():
print(footprint(4), footprint(2, 3))
@@ -0,0 +1,8 @@
def read_sensor(id: Int) raises -> Int:
if id < 0:
raise Error("bad sensor id")
return id * 10
def main():
print("reading:", read_sensor(2))
@@ -0,0 +1,4 @@
def main():
tick_count = 0
tick_count += 1
print("Ticks processed:", tick_count)
@@ -0,0 +1,4 @@
def main():
var threshold
threshold = 10
print("threshold:", threshold)
@@ -0,0 +1,3 @@
def main():
var count: Int = "5"
print("count:", count)
@@ -0,0 +1,5 @@
def main():
var a: List[Int] = [1, 2, 3]
var b = a^
a.append(4)
print("a:", len(a), "b:", len(b))
@@ -0,0 +1,5 @@
def main():
var readings: List[Int] = [10, 20, 30]
var first = readings[0]
first = 99
print("first:", readings[0])
@@ -0,0 +1,6 @@
def widen_add(reading: Int8, total: Int64) -> Int64:
return reading + total
def main():
print("total:", widen_add(100, 1000))
@@ -0,0 +1,6 @@
def avg_latency(total_ms: Int, num_loops: Int) -> Float64:
return total_ms / num_loops
def main():
print("avg latency:", avg_latency(7, 2))
@@ -0,0 +1,3 @@
def main():
var v = Velocity(1.0, 2.0, 3.0, 4.0)
print("Velocity lane 0:", v[0])
@@ -0,0 +1,10 @@
def combine_counts(
a: SIMD[DType.int32, 4], b: SIMD[DType.int32, 4]
) -> SIMD[DType.int32, 4]:
return a
def main():
var imu_a = SIMD[DType.int32, 4](1, 2, 3, 4)
var imu_b = SIMD[DType.int32, 4](10, 20, 30, 40)
print("Combined counts:", combine_counts(imu_a, imu_b))
@@ -0,0 +1,6 @@
def device_tag(family: String, model: String) -> String:
return family + "-" + model
def main():
print(device_tag("mq", "amr"))
@@ -0,0 +1,6 @@
def main():
var path: List[Int] = [10, 20, 30]
var corrected = 15
path.append(corrected) # TODO: replace path[0] instead of appending
print("first waypoint:", path[0])
print("waypoints:", len(path))
@@ -0,0 +1,12 @@
def scan_stats() -> Tuple[Int, Int]:
var num_scans = 4
var total_points = 512
return (num_scans, total_points)
def main():
var stats = scan_stats()
var scans = stats[1]
var points = stats[0]
print("scans:", scans)
print("points:", points)
@@ -0,0 +1,5 @@
def main():
var waypoints = List()
waypoints.append(128)
waypoints.append(256)
print("Queued waypoints:", len(waypoints))
@@ -0,0 +1,9 @@
from std.collections import Dict
def main():
var joint_angles = Dict[String, Int]()
joint_angles["joint_3"] = 128
# TODO: also record joint_8 at an angle of 256
print("joint angle:", joint_angles["joint_3"])
print("joints:", len(joint_angles))
@@ -0,0 +1,9 @@
from std.collections import Set
def main():
var seen = Set()
seen.add(1)
seen.add(1)
seen.add(2)
print("unique:", len(seen))
@@ -0,0 +1,17 @@
def cache_lookup(sensor_id: Int) -> Int:
if sensor_id == 7:
return 512
return None
def main() raises:
var hit = cache_lookup(7)
var miss = cache_lookup(3)
if hit:
print('hit:', hit.value())
else:
print('hit:', hit)
if miss:
print('miss:', miss.value())
else:
print('miss:', miss)
@@ -0,0 +1,6 @@
def square_area(side: Int) -> Int:
return side * 2
def main():
print("area:", square_area(4))
@@ -0,0 +1,7 @@
def split_into_bins(total: Int, per_bin: Int) -> Tuple[Int, Int]:
return total % per_bin, total // per_bin
def main():
var result = split_into_bins(17, 5)
print("bins:", result[0], "left:", result[1])
@@ -0,0 +1,6 @@
def battery_low(level: Int) -> Bool:
return level < 20
def main():
print("low:", battery_low(20))
@@ -0,0 +1,6 @@
def in_range(temp: Int) -> Bool:
return 0 <= temp
def main():
print("in range:", in_range(90))
@@ -0,0 +1,9 @@
def status_word(ready: Int, armed: Int) -> Int:
return ready & armed
def main():
var READY = 1
var ARMED = 2
var flags = status_word(READY, ARMED)
print("armed:", (flags & ARMED) != 0)
@@ -0,0 +1,6 @@
def can_drive(has_fix: Bool, calibrated: Bool) -> Bool:
return has_fix or calibrated
def main():
print("go:", can_drive(True, False))
@@ -0,0 +1,7 @@
def is_allowed(sensor_id: Int, allowed: List[Int]) -> Bool:
return sensor_id not in allowed
def main():
var allowed: List[Int] = [2, 4, 6]
print("ok:", is_allowed(4, allowed))
@@ -0,0 +1,6 @@
def speed_label(speed: Int) -> String:
return speed > 10 ? "fast" : "slow"
def main():
print("mode:", speed_label(12))
@@ -0,0 +1,4 @@
def main():
var scale = 2
scale = 3
print("scale:", scale)
@@ -0,0 +1,7 @@
def path_cost(setup: Int, per_segment: Int, segments: Int) -> Int:
# setup plus per-segment cost, then multiplied across the segments
return setup + per_segment * segments
def main():
print("Total distance:", path_cost(2, 3, 4))
@@ -0,0 +1,10 @@
def route_task(queue_depth: Int) -> String:
if queue_depth < 100:
return "overflow-core"
else:
return "fast-core"
def main():
print(route_task(250))
print(route_task(40))
@@ -0,0 +1,7 @@
def main():
var attempt = 1
var total = 0
while attempt <= 5:
total += attempt
# missing: advance the loop counter
print("Retry budget:", total)
@@ -0,0 +1,7 @@
def main():
var total = 0
for i in range(1, 10):
if i % 3 == 0:
# skip the reserved control-loop slots
total += i
print("Scheduled units:", total)
@@ -0,0 +1,11 @@
def power_mode(level: Int) -> String:
if level >= 80:
return "boost"
else:
return "sleep"
def main():
print(power_mode(95))
print(power_mode(50))
print(power_mode(10))
@@ -0,0 +1,5 @@
def main():
var total = 0
for i in range(0, 10):
total += i
print("total:", total)
@@ -0,0 +1,5 @@
def main():
var readings: List[Int] = [1, 2, 3]
for r in readings:
r += 10
print("first:", readings[0])
@@ -0,0 +1,10 @@
def total_points(batch: List[Int]) -> Int:
var total = 0
for count in batch:
total = count
return total
def main():
var batch: List[Int] = [12, 8, 20, 5]
print("total points:", total_points(batch))
@@ -0,0 +1,8 @@
def validate_velocity(n: Int) -> Int:
if n <= 0:
pass # TODO: reject the invalid velocity by raising an Error
return n
def main():
print("Validated:", validate_velocity(256))
@@ -0,0 +1,8 @@
def checked(n: Int) raises -> Int:
if n < 0:
raise Error("negative reading")
return n
def main():
print("value:", checked(-1))
@@ -0,0 +1,12 @@
def attempt() raises:
try:
raise Error("sensor fault")
except e:
print("logging:", e)
def main():
try:
attempt()
except:
print("recovered")
@@ -0,0 +1,8 @@
def main() raises:
# MQ Robotics stores the active calibration profile on disk.
with open("calib.txt", "w") as f:
f.write("max_speed=1.5")
with open("calib.txt", "r") as f:
pass
print(f.read())
@@ -0,0 +1,13 @@
struct LidarScan(Copyable, Movable):
var near_points: Int
def __init__(out self, near_points: Int, far_points: Int):
self.near_points = near_points
def total(self) -> Int:
return self.near_points + self.far_points
def main():
var scan = LidarScan(8, 256)
print("Total points:", scan.total())
@@ -0,0 +1,10 @@
struct Battery:
var charge: Int
def __init__(out self, charge: Int):
self.charge = charge
def main():
var b = Battery(15)
print("low:", b.is_low())
@@ -0,0 +1,18 @@
struct FrameCounter(Copyable, Movable):
var count: Int
def __init__(out self, count: Int):
self.count = count
def increment(self):
self.count += 1
def get(self) -> Int:
return self.count
def main():
var counter = FrameCounter(0)
counter.increment()
counter.increment()
print("Frames handled:", counter.get())
@@ -0,0 +1,7 @@
struct Encoder:
def ticks_per_rev() -> Int:
return 4096
def main():
print("ppr:", Encoder.ticks_per_rev())
@@ -0,0 +1,11 @@
struct LidarScan(Copyable, Movable):
var near_points: Int
var far_points: Int
def total(self) -> Int:
return self.near_points + self.far_points
def main():
var scan = LidarScan(8, 256)
print("Total points:", scan.total())
@@ -0,0 +1,14 @@
struct FileHandle(Movable):
var fd: Int
def __init__(out self, fd: Int):
self.fd = fd
def take(var h: FileHandle) -> Int:
return h.fd
def main():
var h = FileHandle(3)
print("fd:", take(h))
@@ -0,0 +1,12 @@
struct EnergyBudget(Copyable, Movable):
var millijoules: Int
def __init__(out self, millijoules: Int):
self.millijoules = millijoules
def main():
var drive_budget = EnergyBudget(100)
var sense_budget = EnergyBudget(56)
var total = drive_budget + sense_budget
print("combined budget:", total.millijoules)
@@ -0,0 +1,11 @@
struct Offset(Copyable, Movable):
var v: Int
def __init__(out self, v: Int):
self.v = v
def main():
var o = Offset(5)
var n = -o
print("neg:", n.v)
@@ -0,0 +1,11 @@
struct Version(Copyable, Movable):
var major: Int
def __init__(out self, major: Int):
self.major = major
def main():
var a = Version(2)
var b = Version(2)
print("equal:", a == b)
@@ -0,0 +1,14 @@
struct Frame(Copyable, Movable):
var a: Int
var b: Int
var c: Int
def __init__(out self, a: Int, b: Int, c: Int):
self.a = a
self.b = b
self.c = c
def main():
var f = Frame(10, 20, 30)
print("channel 1:", f[1])
@@ -0,0 +1,3 @@
def main():
var root = sqrt(144.0)
print("Square root:", root)
@@ -0,0 +1,9 @@
def record_sample(total: Int, sample: Int):
total += sample
def main():
var total = 0
record_sample(total, 12)
record_sample(total, 8)
print("Total distance:", total)
@@ -0,0 +1,8 @@
def load_map(var cells: List[Int]) -> Int:
return len(cells)
def main():
var cells: List[Int] = [16, 32, 64, 128]
var result = load_map(cells)
print("map cells loaded:", result)
@@ -0,0 +1,15 @@
struct CommandQueue(Copyable, Movable):
var depth: Int
def __init__(out self, depth: Int):
self.depth = depth
def borrow_depth(ref self) -> ref [self] Int:
return self.depth
def main():
var q = CommandQueue(4)
ref d = q.borrow_depth()
d = 10
print("queue depth:", q.depth)
@@ -0,0 +1,11 @@
struct Waypoint(Copyable, Movable):
var x: Int
var y: Int
def __init__(out self, x: Int, y: Int):
self.x = x
def main():
var w = Waypoint(3, 7)
print("y:", w.y)
@@ -0,0 +1,14 @@
struct RobotConfig(Copyable, Movable):
var name: String
var max_rate: Int
def __init__(out self, name: String, max_rate: Int):
self.name = name
self.max_rate = max_rate
def main():
# The fleet console re-badges an existing config under a new name.
var base = RobotConfig("base", 512)
var arm = RobotConfig("arm", base)
print("Robot:", arm.name, "max_rate:", arm.max_rate)
@@ -0,0 +1,13 @@
struct Celsius(Copyable, Movable):
var deg: Int
def __init__(out self, deg: Int):
self.deg = deg
def report(t: Celsius):
print("temp:", t.deg)
def main():
report(25)
@@ -0,0 +1,21 @@
struct ScanBuffer:
var samples: List[Int]
def __init__(out self, var samples: List[Int]):
self.samples = samples^
def push(mut self, t: Int):
self.samples.append(t)
def size(self) -> Int:
return len(self.samples)
def main():
var original: List[Int] = [1, 2, 3]
var snapshot = ScanBuffer(original^)
# The black-box recorder keeps an independent copy so later edits don't leak in.
var working = snapshot.copy()
working.push(99)
print("snapshot size:", snapshot.size())
print("working size:", working.size())
@@ -0,0 +1,11 @@
struct Reading(Copyable, Movable):
var v: Int
def __init__(out self, v: Int):
self.v = v
def main():
var a = Reading(5)
var b = a
print("a:", a.v, "b:", b.v)
@@ -0,0 +1,16 @@
struct MotorHandle:
var motor_id: Int
def __init__(out self, motor_id: Int):
self.motor_id = motor_id
print("Acquired motor", self.motor_id)
def drive():
var handle = MotorHandle(0)
print("Driving with motor", handle.motor_id)
def main():
drive()
print("Scheduler idle")
@@ -0,0 +1,3 @@
def main():
var tick_budget = 50 * 20
print("tick budget:", tick_budget)
@@ -0,0 +1,6 @@
def main():
var num_axes = 4
var total = 0
comptime for i in range(num_axes):
total += i
print("axis sum:", total)
@@ -0,0 +1,6 @@
def scale(factor: Int, x: Int) -> Int:
return x * factor
def main():
print("Scaled:", scale[3](14))
@@ -0,0 +1,12 @@
struct Buffer(Copyable, Movable):
def __init__(out self):
pass
def capacity(self) -> Int:
return Self.size
def main():
var b = Buffer[8]()
print("capacity:", b.capacity())
print("size:", b.size)
@@ -0,0 +1,21 @@
trait Sensor:
def read(self) -> String:
...
struct Lidar:
var name: String
def __init__(out self, name: String):
self.name = name
def read(self) -> String:
return "Reading from " + self.name
def announce[T: Sensor](sensor: T):
print(sensor.read())
def main():
announce(Lidar("lidar-front"))
@@ -0,0 +1,19 @@
trait Greeter:
def name(self) -> String:
...
def greet(self) -> String:
...
struct Robot(Greeter):
def __init__(out self):
pass
def name(self) -> String:
return "amr"
def main():
var r = Robot()
print(r.greet())
@@ -0,0 +1,12 @@
struct Track:
var name: String
var waypoints: List[Int]
def __init__(out self, name: String, var waypoints: List[Int]):
self.name = name
self.waypoints = waypoints^
def main():
var t = Track("loop-a", [10, 20, 30, 40, 50])
print("len:", len(t))
@@ -0,0 +1,8 @@
# Logs any value the telemetry bus touches, whatever its type.
def log_value(value: T):
print("telemetry:", value)
def main():
log_value(42)
log_value("ready")
@@ -0,0 +1,8 @@
def make_drive[num_motors: Int]() -> Int:
# The drive train must pair motors across an even motor count.
comptime assert num_motors % 2 == 0, "num_motors must be even"
return num_motors * 64
def main():
print("Drive slots:", make_drive[7]())
@@ -0,0 +1,8 @@
def transform_size[dim: Int]() -> Int:
# a dim x dim transform matrix has dim * dim entries
return dim * dim
def main():
var dim = 8
print("matrix entries:", transform_size[dim]())
@@ -0,0 +1,14 @@
struct RobotConfig(Copyable, Movable):
var max_speed: Int
var wheel_radius: Int
var num_sensors: Int
def __init__(out self, max_speed: Int, wheel_radius: Int, num_sensors: Int):
self.max_speed = max_speed
self.wheel_radius = wheel_radius
self.num_sensors = num_sensors
def main():
comptime field_count = reflect[RobotConfig].num_fields()
print("RobotConfig fields:", field_count)
@@ -0,0 +1,12 @@
from std.memory.alloc import unsafe_alloc
def main():
# Stage a single encoder reading in a scratch buffer.
# BUG: allocate, write the value, read it back, then release it.
var ptr = unsafe_alloc(1)
ptr.unsafe_write(copy=99)
var value = ptr[]
print("Encoder count:", value)
ptr.unsafe_deinit_pointee()
ptr.unsafe_free()
@@ -0,0 +1,6 @@
def main():
var ptr = alloc[Int]({count = 2}).unsafe_leak()
ptr[unsafe_offset=0] = 10
ptr[unsafe_offset=1] = 20
print("second:", ptr[unsafe_offset=0])
ptr.unsafe_free()
@@ -0,0 +1,10 @@
from std.testing import assert_equal
def total_distance(near: Int, far: Int) -> Int:
return near + far
def main() raises:
assert_equal(total_distance(100, 50), 200)
print("All checks passed!")
@@ -0,0 +1,13 @@
from std.testing import assert_raises
def clamp(n: Int) raises -> Int:
if n < 0:
raise Error("negative speed")
return n
def main() raises:
with assert_raises():
_ = clamp(5)
print("raised as expected")