Skip to content

feat(id): Zig counter example world on the Zig SDK (#12596) - #12837

Open
dezren39 wants to merge 1 commit into
xaltha/12596-zig-sdk-screen-capfrom
xaltha/12596-zig-counter
Open

dezren39 wants to merge 1 commit into
xaltha/12596-zig-sdk-screen-capfrom
xaltha/12596-zig-counter

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Slice 3 of #12596: the playable example world for the Zig guest SDK — examples/zig-counter/, the third twin of roc-counter/rust-counter (same counter scenario, same Plaza ABI v1 surface from roc-world/ABI.md).

Stacked on PR #12827 (base xaltha/12596-zig-sdk-screen-cap), which is stacked on PR #12793; this PR retargets to main as the stack merges.

What it adds

  • src/main.zig — the pure program (init/update/view/layout/records/wants/snapshot/restore) plus the plaza_* glue mirroring the Rust SDK's plaza_guest! plumbing: leaked model pointer, one shared output slot released by the next output call, plaza_alloc/plaza_free over the guest allocator, diagnostic pair reading empty at rest. Uses the SDK's screen helper for the boxed 20x3 view (30 wide at viewport width >= 30) and its json helper to encode the {"count":N} records document.
  • build.zig/build.zig.zon — path-depends on ../zig-sdk; builds an import-free wasm32-freestanding module exporting exactly the 14 documented exports + memory (verified against the built module; rdynamic roots the exports since there is no entry point).
  • build.sh — toolchain guard + host tests + guest build, refreshing the checked-in counter.wasm (65,445 bytes) so the F12.7 conformance suite can load it as the zig-counter fixture with no Zig toolchain, like its twins.
  • zig-sdk/zig-sdk-test.sh now also covers the example (fmt check, host tests, guest build); zig-sdk/README.md updated; root .gitignore gains the zig-counter build-output lines mirroring the zig-sdk ones.

Verification (pinned Zig 0.16.0, local)

  • zig-sdk-test.sh green end to end: SDK suites, counter host tests 3/3 (mirrors of the rust-counter suite, including byte-equality of the boxed screen document), SDK + counter wasm32-freestanding builds OK, zig fmt --check clean.
  • The checked-in counter.wasm driven at the raw ABI level (WebAssembly instantiation, host-side alloc/write/free exactly as the runner does): plaza_abi_version = 1; inc x2 (one event whitespace-padded) then view = the twins' boxed screen document with count=2, byte-identical; records {"count":2}; wants {}; snapshot 2 -> restore round-trips; restore total on junk input; zero imports.

Remaining on #12596

The F12.7 conformance run — add zig-counter to CONFORMANCE_MODULES in crates/id-worlds/src/sandbox.rs and record the pass for the Phase 12 exit audit (#12231) — plus wiring zig-sdk-test.sh into the roc-test just recipe once the nix Zig version is confirmed 0.16.0.

Refs #12596


Show it working
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Slice 3 of #12596: examples/zig-counter/, the third twin of
roc-counter/rust-counter — the same counter scenario on the Plaza
ABI v1 surface, built on the Zig guest SDK (screen for the boxed
view/layout, json for the records document).

- src/main.zig: the pure program (init/update/view/layout/records/
  wants/snapshot/restore) plus the plaza_* glue mirroring the Rust
  SDK's plaza_guest! plumbing (leaked model pointer, one shared
  output slot, alloc/free over the guest allocator); host tests
  mirror the rust-counter suite.
- build.zig builds an import-free wasm32-freestanding module with
  exactly the 14 documented exports + memory; build.sh runs the
  tests and refreshes the checked-in counter.wasm so the F12.7
  conformance suite can load it without a Zig toolchain.
- zig-sdk-test.sh now also covers the example (fmt, host tests,
  guest build); root .gitignore gains the zig-counter build-output
  lines, mirroring the zig-sdk ones.

Verified with pinned Zig 0.16.0: zig-sdk-test.sh green (SDK suites
53 tests + counter 3/3 host tests, both wasm builds OK); the
checked-in counter.wasm driven at the raw ABI level (init, inc x2
with a trimmed event, view byte-identical to the twins' boxed
screen document, records {"count":2}, wants {}, snapshot/restore
round-trip, restore total on junk) — all checks pass, zero imports.

Refs #12596. Stacked on xaltha/12596-zig-sdk-screen-cap (PR #12827);
retargets to main as the stack merges.
@dezren39
dezren39 requested a review from a team as a code owner November 23, 2026 03:34
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b20f5cf8-8fa6-44d7-ab54-7171f2770cf8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

dezren39 added a commit that referenced this pull request Nov 23, 2026
…2596)

The Zig guest SDK's playable example (examples/zig-counter, PR #12837)
joins roc-counter, rust-counter and tic-tac-toe in CONFORMANCE_MODULES,
so the ABI.md export-surface, abi-version and snapshot/restore
round-trip conformance tests now run against the checked-in Zig module
with no Zig toolchain required.
@dezren39
dezren39 removed the request for review from a team November 23, 2026 05:56

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant