3.5 KiB
ADR 0005: CraftOS-PC As The Local Harness
Status
Accepted
Date
2026-06-08
Context
This repository targets CC:Tweaked on Minecraft 1.21. The Lua we ship runs inside the ComputerCraft sandbox: it depends on os.pullEventRaw, peripheral, rednet, textutils.serializeJSON, modem channels, and a handful of CC-specific globals. Standard Lua (or LuaJIT) cannot execute this code as-is, so a normal local test harness was never a serious option.
In practice contributors have been running the code in two places:
- In-game on a real Minecraft server, which is slow to iterate on.
- In CraftOS-PC (https://www.craftos-pc.cc/), a desktop emulator that ships the same ROM/BIOS as CC:Tweaked, supports modem peripherals via
periphemu, and can run fully headless (--cli --headless --script <file>).
CraftOS-PC has been the de facto local harness for months, but that fact lived only as a single line in CLAUDE.md. There was no install guide, no minimum version, and just install did not check that the binary was present. The recent upgrade from v2.6.6 → v2.8.3 (the first one in years) made it obvious that this dependency needed to be made explicit.
Decision
Treat CraftOS-PC as a first-class local development dependency.
- Minimum version
v2.8.3— recent enough to have the current CC:Tweaked ROM, old enough that contributors already on a 2.8.x build will not be forced to upgrade again immediately. - Documented install in
docs/install-craftos-pc.md, with a SHA-256-verified macOS flow and pointers to the official Windows/Linux artifacts. - Verified by
just installvia acheck-craftosrecipe that runscraftos --versionand requires v2.8.3 or newer. Failure prints a one-line pointer to the install guide instead of a long stack trace. just ciis the local verification entry point. Today it runscheck-craftosandcheck. The installed pre-commit hook invokesjust cidirectly.just testexists as the future home for CraftOS-PC-driven smoke tests.
The existing CLAUDE.md constraint ("Do not run Lua locally or add a test harness unless asked") is reframed rather than removed: there is still no standalone Lua harness, and we are not adding a Busted-style test runner. The harness is CraftOS-PC, invoked deliberately.
Consequences
- Contributors must install CraftOS-PC before
just installsucceeds. The install guide makes this a 4-step copy/paste on macOS. - Future smoke tests have a clear home: a script under
tests/(or similar) driven bycraftos --cli --headless --script tests/smoke.lua, called fromjust test. - The harness version becomes a project-level concern. When CC:Tweaked ships breaking changes that require a newer CraftOS-PC build, we bump the minimum version in
docs/install-craftos-pc.mdandcheck-craftoskeeps contributors honest. - No CI integration yet. Running CraftOS-PC headless in GitHub Actions is feasible (the AppImage works on Ubuntu runners) but is out of scope here; the contract is local-only for now.
Future Work
- Headless smoke test. A
tests/smoke.luathat boots an emulated computer,requires/apis/eventloop,/apis/net, and the router, and asserts the wiring loads without errors. Hooked intojust test, then intojust ciwhen it is ready to run on every commit. - CI. Run the smoke test on push using the Linux AppImage.
- Pinned ROM. CraftOS-PC ships its own copy of the CC:Tweaked ROM per release. If we ever need to test against a specific in-game version, point CraftOS-PC at a vendored ROM via
--rom.