Repository navigation
Conversation
First slice of the third guest language (Phase 12 exit criterion 3, results-first plan step A7): the Zig SDK skeleton plus the two pure helpers everything else builds on. - src/json.zig: Zig port of RocJson — value type, decode/encode with the same 64 KiB in/out limits and 64-level nesting limit, exact number lexemes, same DecodeError codes (0-6). Tests mirror the Roc expect cases, including the 64-depth and 64 KiB limit cases. - src/grid.zig: Zig port of RocGrid — bounded row-major grids with never-trapping get/set, neighbors4, row/bytes/dimensions/fromCells. set mutates in place (Zig idiom) instead of returning a new grid. - build.zig / build.zig.zon: static library + zig build test; minimum Zig 0.16.0, matching the tree's Zig pin. - zig-toolchain.sh: version guard mirroring roc-toolchain.sh, pinned via pkgs/id/nix/zig-version. - zig-sdk-test.sh: guard + zig fmt --check + zig build test + wasm32-freestanding build. Refs #12596
zig build writes its cache and install tree next to build.zig; keep them out of the tree so the new zig-sdk cannot be committed with build artifacts.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 16 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
dezren39
added a commit
that referenced
this pull request
Nov 23, 2026
Zig ports of the Roc Screen and RocCap libraries, completing the four-helper parity the issue asks for (screen, json, grid, cap): - src/screen.zig: cell-grid Screen with putText/putRow/putGrid/ fill/rule/boxed and renderPlain/renderJson/renderAnsi plus renderRowsJson and boxEdge. The JSON screen document is byte-for-byte the Roc one (run-length style spans, default runs omitted, rows padded to width); tests mirror the Screen.roc expect cases. - src/cap.zig: RocCap Session (issue/attach/requests/counter/ fromPending/answered/done/isEmpty) and the eight request document builders, on top of the SDK json values; documents encode byte-for-byte like Roc. Drawing and session updates mutate in place (the grid port's precedent); renders and documents allocate from a caller-provided allocator. Verified with pinned Zig 0.16.0: zig fmt --check clean, zig build test green (22 new tests), wasm32-freestanding build OK via zig-sdk-test.sh. Stacked on xaltha/12596-zig-sdk (PR #12793, slice 1) — retarget to main once that merges. Refs #12596.
This was referenced Nov 23, 2026
This branch has not been deployed
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.
Refs #12596
First slice of the third guest language (Phase 12 exit criterion 3: guest languages with a passing conformance suite, at least 3; results-first plan step A7). It moves the acceptance criterion "a Zig guest SDK with screen, json, grid, and cap helpers equal to the Roc libraries" from nothing to two of the four helpers landed and tested — it does not close the issue.
What this slice lands
pkgs/id/examples/zig-sdk/src/json.zig: Zig port of RocJson — value type, decode/encode with the same 64 KiB in/out limits and 64-level nesting limit, exact number lexemes, same DecodeError codes (InvalidJson 0 … WrongType 6). Tests mirror the Rocexpectcases, including the 64-depth and 64 KiB limit cases.pkgs/id/examples/zig-sdk/src/grid.zig: Zig port of RocGrid — bounded row-major grids with never-trapping get/set, neighbors4, row/bytes/dimensions/fromCells.build.zig/build.zig.zon: static library +zig build test; minimum Zig 0.16.0, matching the tree's Zig pin (the roc-world host'sbuild.zig.zonwants 0.16).zig-toolchain.sh: version guard mirroringroc-toolchain.sh, pinned via newpkgs/id/nix/zig-version(0.16.0).zig-sdk-test.sh: guard +zig fmt --check+zig build test+ awasm32-freestandingbuild proving the SDK compiles for the guest target..gitignore: Zig build outputs (.zig-cache,zig-out) ignored.Two deliberate differences from Roc, documented in the README and at the use site: memory is explicit (caller-provided allocator; an arena is the natural fit in a wasm32-freestanding guest), and
Grid.setmutates in place instead of returning a new grid.Verification (local, no laptop needed)
Downloaded pinned Zig 0.16.0 (verified shasum) to
~/tools/zig-0.16.0and ranZIG=~/tools/zig-0.16.0/zig bash zig-sdk-test.sh:zig fmt --check: cleanzig build test --summary all: 31/31 tests passedzig build -Dtarget=wasm32-freestanding: OK (SDK compiles for the guest target)No Rust changes, no laptop build needed for this slice.
What remains on #12596
screenhelper (Zig port ofScreen, includingrender_json).caphelper (Zig port ofRocCap).zig-counter, mirroringroc-counter) exporting the Plaza ABI v1 surface fromroc-world/ABI.md.zig-sdk-test.shinto theroc-testjust recipe once the nix-provided Zig version is confirmed to be 0.16.0 (deliberately left out of this slice rather than risk breakingjust ci).Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.