4.7 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. - Documented upstream navigation in
docs/craftos_pc_glossary.md, covering CLI flags, mounts,periphemu, save data, and troubleshooting pages. - 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-craftos,check, andtest. The installed pre-commit hook invokesjust cidirectly, andjust testowns 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. - Contributors should use the local CraftOS-PC glossary first when researching emulator behavior, then follow the linked upstream pages for details.
- Headless smoke tests live under
tests/and are driven byjust test. Today there are two:tests/boot.lua(prints a marker and shuts down — proves the BIOS started) andtests/ready.lua(round-trips acraftos-readyevent throughos.queueEvent/os.pullEventRaw— proves the CC event queue works). Each is invoked ascraftos --headless --script <file>and its stdout is grepped for__READY__. Adding a third test means dropping a Lua file intests/and adding it to the loop in thetest:recipe. - The macOS install symlinks the binary into
/usr/local/bin, which makes CraftOS-PC unable to auto-discover the ROM that ships inside the.appbundle (Could not mount ROM). Thetest:recipe works around this by passing--rom /Applications/CraftOS-PC.app/Contents/Resourceson Darwin. Linux (AppImage) and Windows (installer) auto-discover correctly, so no flag is passed there. - 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
- API-loading smoke test. Extend the
tests/set with a script that mounts the repo into the VM (--mount-ro /cc-libs=.) andrequires/apis/eventloop,/apis/net, and the router, asserting the wiring loads without errors. Today's smokes only prove CraftOS-PC itself works, not that our code loads inside it. - CI. Run
just teston 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(the same flag we already pass on macOS for a different reason).