2.7 KiB
04 — Integration & tooling
Sub-plan of trap-sandbox-gateway-spec. Build last (M4): requires both the TS gateway (M1) and the Lua client (M2) to exist. References the spec's Protocol/Handshake for assertions.
Scope
Host tooling (just/npm.just recipes, sandbox-serve, docs) and the cross-side tests: TS
integration (real craftos ↔ real gateway) plus the full-boot e2e.
Task checklist
just/npm.just: extendinstall/build/check/test/test-integration/cito covertools/trap-sandboxalongside mcp-bridge; ensurejust install/just ciinclude it.just/opencode.just(or new recipe): addjust sandbox-servemirroringopencode-serve.docs/public-ports.md: add a4444row.- TS integration harness + cases (
tools/trap-sandbox/test-integration/). - Full-boot e2e.
- Gate:
npm run test:integrationgreen;just cicovers both tools.
Tooling
just/npm.just: extend recipes (install/build/check/test/test-integration/ci) to covertools/trap-sandboxalongside mcp-bridge; ensurejust install/just ciinclude it.just/opencode.just(or a new recipe): addjust sandbox-servemirroringopencode-serve(source.env, exportOPENCODE_SERVER_PASSWORD, defaultOPENCODE_URL/SANDBOX_PORT, runnpm run dev --prefix tools/trap-sandbox).docs/public-ports.md: add a4444row (note it sits outside the 4242–4244 range; 4244 reserved).
Test layout
test-integration/ # harness.ts (app on :0, startCraftos, fake-opencode http server) + lua/ + *.test.ts
TS integration (tools/trap-sandbox/test-integration, real craftos ↔ real gateway, serialized)
Self-contained gateway-client.lua for the health round-trip (opencodeOk true/false via the
fake-opencode server), reverse ping via registry.request, duplicate (newest-wins), and the
auth canary — wrong secret asserts in-band hello ok:false code:"unauthorized", correct secret
asserts hello ok:true.
Full-boot e2e (TS integration)
craftos --exec replicates boot (set sandbox.url, _G.bootEventLoop, run real servers/sandbox,
then under parallel wait for trapos_sandbox_connected and run sandbox health); assert stdout
contains sandboxOk: true. Bounded by generous timeouts.
Verification gate (also the project-level acceptance)
npm test,npm run test:integration,npm run lint/checkclean intools/trap-sandbox.just _craftos-testrunstests/sandbox.lua;just cicovers both tools.- Manual:
just sandbox-serve; in-gameset sandbox.url ws://<host>:4444/gateway(+set sandbox.password <secret>ifSANDBOX_PASSWORDset), reboot,sandbox health→sandboxOk: true/opencodeOk: ….