feat(wasm): compile the kernel cube to graff-kernel.wasm - #591
Draft
justrach wants to merge 2 commits into
Draft
Conversation
fx ships fx-core.wasm / fx-term.wasm behind a JS host. graff cannot
compile the live agent that way yet (HTTP, bash, TTY). The kernels
already are total functions over finite cubes, so zig build wasm emits
those: catalog({0,1}^6) and confined(path), with a JS loader and a
compile-only tier-1 check. Not JSPI, not WASI, not the agent (ADR 0012).
CI tsc failed on remote.test.ts: process.off("unhandledRejection") is
not in bun-types' Process overloads. Cast through EventEmitter so the
test still asserts create-rejection is observed, not unhandled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fx compiles to WASM as
fx-core.wasm/fx-term.wasmbehind a JS host (JSPI fetch, no bash). graff cannot do that for the live agent yet —std.http.Client, jobs, MCP stdio, and TTY restore do not compile towasm32-freestanding.What does compile is the maths: the ToolCatalog cube (
{0,1}^6→ 64 name lists) and the lexical path jail. This PR ships that as the first artifact.What you get
zig build wasm # zig-out/bin/graff-kernel.wasm (~2.8 KB, ReleaseSmall)No JSPI. No WASI. Not the agent.
Guardrails
spec/kernels/tool_catalog.json,path_confine.json).scripts/eval-tier1.sh --only wasmis compile-only so the target cannot rot.zig build wasmon Linux and Windows.graff-core.wasm/graff-term.wasmneeds an explicit host capability table (fetch, workspace, no implicit bash), the same way fx does. Do not compilesrc/main.zigand hope.Until that host layer exists, embed the live harness with
graff serve+ the remote SDK.Demo after
zig build wasm:python3 -m http.server 8080→/sdk/wasm/demo.html.CI
sdktypecheck failed onprocess.off("unhandledRejection")— bun-types only overloadsProcess.offformemoryPressure. Fixed by casting throughEventEmitterinremote.test.ts(also on #593).