Skip to content

feat(wasi): --world server — verified HTTP handlers as wasi:http components — v0.0.195 - #850

Merged
aallan merged 5 commits into
mainfrom
feat/wasi-http-serve
Jul 2, 2026
Merged

feat(wasi): --world server — verified HTTP handlers as wasi:http components — v0.0.195#850
aallan merged 5 commits into
mainfrom
feat/wasi-http-serve

Conversation

@aallan

@aallan aallan commented Jul 2, 2026

Copy link
Copy Markdown
Owner

What

--world server — verified HTTP handlers as portable wasi:http components and release v0.0.195. Stage D of the server-effects sprint (WASI.md); builds on the v0.0.194 WASI Preview 2 target (#237) and the v0.0.193 <HttpServer> effect (#305). Refs #237, #305 (both closed; lineage only).

vera compile --target wasi-p2 --world server examples/http_server.vera
wasmtime serve examples/http_server.wasm     # stock CLI, no flags

One contract-verified handle(@Request -> @Response) program, two deployment paths: the native vera serve driver (#305, unchanged) and now a wasi:http/incoming-handler@0.2.0 component any wasi:http host can run. Live-tested under stock wasmtime serve 46.0.1: routing, handler-set headers, a 1 MiB body byte-identical under GC stress, guest trap → host 500, @0.2.3 semver linking.

Design (live-validated before implementation, per the Stage-C pattern)

  • Topology: MAIN owns memory exactly as in the shipped Stage-C emitter (the check-7 spike's $Libc two-module realloc dodge proved unnecessary — recorded in WASI.md); the serve wrapper lives in the adapter, importing the wasi:http lowers directly plus MAIN's handle/alloc/GC globals; dispatch table 16→32 slots. Every request-half import spelling and flattening was proven by wasmtime-py parse and a served round-trip before the emitter was written.
  • Headers without a host — the stage's hard problem, solved rather than descoped: Request/Response headers are Map<String, String>, whose operations are host imports on the core target. A Vera Map is two plain guest-heap blocks, so the server world implements the String-keyed Map ops in guest WAT with the host's exact semantics (position-preserving update, later-insert-wins, power-of-two capacity, entry shadow-pushes), pinned by a host-vs-served differential battery (mixed-case / absent / duplicate / 41-header matrix, insertion-order agreement). Non-String instantiations and all other collection families stay gated.
  • Marshalling: the generated $serve_handle reads method / path-with-query / headers / body into the GC-exempt arena, copies out into the guest-heap Request ADT from the compilation's own adt_layouts (WAT-level shadow-stack rooting throughout), calls handle, decodes Response, and drives the outgoing-response sequence (borrow-before-transfer, child-stream-drop-before-finish, 4096-byte chunks). Status u16 pre-check and forbidden-header errors answer 500 gracefully instead of trapping the server (live-tested with status 70000).
  • Honest surface (each rejection a diagnostic, never silent): IO.print/IO.stderr route to the serve console; read_line/read_char/read_file/write_file/get_env/args/exit are rejected — negative-probed: those imports do not link under the wasi:http proxy world. Bodies buffered (streaming is future work); request headers share the ~63 KiB arena.
  • cli-world emission is byte-identical to v0.0.194 — pinned by test (the pin's mutation validation caught a stale-.pyc false green; purged and confirmed RED).
  • vera run rejects server-world artifacts with a pointer to wasmtime serve (wasmtime-py's built-in host has no wasi:http and no resource-definition API — verified).

Tests (RED-first; 5 mutation kills)

33 new emitter tests + 5 CLI tests in tests/test_wasi_target.py: server-world parse battery, family-gate diagnostics (8), cli-world byte-pin (3), layout tripwires, and a 9-test live wasmtime serve smoke (skipif no CLI) — example round-trips, the header-matrix differential, map-order differential, IO.print console routing, trap→500 with requires text, graceful-500 paths, 1 MiB + 50-header GC stress, plus an in-suite eager-GC shadow-push mutation-validation test that performs its own surgery deterministically. CLI: server component parse, --wat export check, vera run rejection, --world-requires-wasi-p2, missing-handler diagnostic.

Mutations killed: later-wins→first-wins (header differential RED), map update→append (order differential RED), Request-build shadow-push dropped (500 vs 200), server table size leaked into cli emission (pin RED after .pyc purge), family-gate line removed (exactly its test RED).

Docs + release v0.0.195

Spec §13.7 (server world) with conformance renumbered §13.8; TOOLCHAIN/README/SKILL/CLAUDE command surfaces; WASI.md check-7 loose ends closed ($Libc and incoming-body.finish superseded, with the design-study evidence); CHANGELOG v0.0.195 + link refs; version sync (6 sites); HISTORY Stage-16 row + By-the-numbers trailing column refreshed to v0.0.195; doc counts (5,806 tests).

Verification

  • full suite + stress green; mypy clean; ruff check (+ --select S) clean without --fix
  • conformance 104 / examples 36 / doc-counts / version-sync / site-assets / limitations / encoding / diagnostic-fields / allowlist gates (no duplicate keys)
  • 5 mutation kills, restored green
  • end-to-end demo: compiled examples/http_server.vera served by stock wasmtime serve, no flags

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a WASI Preview 2 server world for wasi:http components, runnable with wasmtime serve (including adapter behaviour) and supported via vera serve.
    • Added a --world option for vera compile/vera run to select CLI vs server component modes (with vera run rejecting server-world hosting).
  • Bug Fixes
    • Fixed a garbage-collection use-after-free involving pair-typed let bindings.
    • Reduced flakiness in a live keyboard-interrupt async test.
  • Tests
    • Added end-to-end coverage and smoke checks for server-world emission and wasmtime serve request/response parity.
  • Documentation
    • Updated CHANGELOG, HISTORY, README, TOOLCHAIN, SKILL, WASI, ROADMAP, and spec to document --world server workflows and the v0.0.195 release.

…onents — v0.0.195

vera compile --target wasi-p2 --world server packages the same
contract-checked handle(Request -> Response) program vera serve hosts
natively as a wasi:http/incoming-handler@0.2.0 component that stock
wasmtime serve runs unmodified (live-tested: routing, handler headers,
1 MiB body byte-identical under GC stress, trap -> 500, @0.2.3 links).
Headers work without a host: the String-keyed Map ops are implemented
in guest WAT with exact host-semantics parity, pinned by a host-vs-
served differential battery.  The server-world surface is explicit —
IO print/stderr only; stdin/filesystem/env ops rejected with
diagnostics (negative-probed: they do not link under the proxy
world); bodies buffered; cli-world emission byte-identical (pinned).
vera run rejects server artifacts with a pointer to wasmtime serve.
Design live-validated before implementation; five mutation kills.
Spec §13.7; WASI.md check-7 loose ends closed.

Co-Authored-By: Claude <noreply@anthropic.invalid>
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9b172291-da9f-433a-a9db-dda7cf4b6fb1

📥 Commits

Reviewing files that changed from the base of the PR and between 32aea1c and 9ca571c.

📒 Files selected for processing (4)
  • README.md
  • TESTING.md
  • tests/test_wasi_target.py
  • vera/cli.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • aallan/vera-bench (manual)

📝 Walkthrough

Walkthrough

This PR adds --world server support for WASI Preview 2 compilation and execution, wiring it through codegen, CLI, runtime validation, tests, and documentation. It also bumps the project version to 0.0.195 and re-keys SKILL.md allowlist entries.

Changes

Server-world compiler and CLI feature

Layer / File(s) Summary
Codegen refactor: shared helpers and layout support
vera/codegen/wasi.py
Adds shared module-parsing helpers, world-specific slab layout support, and shared GC/bytes-equality helper templates.
Server-world component emission
vera/codegen/wasi.py
Adds world selection to emit_wasi_component and implements the server-world wasi:http/incoming-handler pipeline.
Runtime handler validation refactor
vera/runtime/server.py
Parameterises handler validation error prefixes through validate_handler, with _validate_handler delegating to it.
CLI --world flag wiring for compile and run
vera/cli.py
Adds --world parsing, validation, dispatch, and server-world rejection for vera run.
Server-world test coverage
tests/test_wasi_target.py
Adds emission, gate, layout, CLI, and live wasmtime serve coverage for the server world.
Spec and documentation updates for server world
spec/13-wasi.md, CHANGELOG.md, HISTORY.md, README.md, ROADMAP.md, TOOLCHAIN.md, SKILL.md, TESTING.md, CLAUDE.md, WASI.md, pyproject.toml, vera/__init__.py
Documents the server-world target, updates examples and status text, and bumps version/release metadata to 0.0.195.

SKILL.md allowlist re-keying

Layer / File(s) Summary
Re-key ALLOWLIST line numbers
scripts/check_skill_examples.py
Updates ALLOWLIST line-number keys to match the current fenced example locations in SKILL.md.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI as vera/cli.py
  participant Emitter as emit_wasi_component
  participant ServerPipeline as _emit_server_component
  participant Wasmtime as wasmtime serve

  User->>CLI: vera compile --target wasi-p2 --world server file.vera
  CLI->>Emitter: emit_wasi_component(result, world="server")
  Emitter->>ServerPipeline: validate, gate, and assemble server component
  ServerPipeline-->>Emitter: wasi:http/incoming-handler component
  Emitter-->>CLI: compiled component
  CLI-->>User: server component output
  User->>Wasmtime: wasmtime serve component.wasm
  Wasmtime->>Wasmtime: invoke handle(Request -> Response)
Loading

Possibly related PRs

  • aallan/vera#492: Both PRs update scripts/check_skill_examples.py to re-anchor ALLOWLIST entries for fenced SKILL.md examples.
  • aallan/vera#601: Also re-keys ALLOWLIST mappings in scripts/check_skill_examples.py for moved SKILL.md code fences.

Suggested labels: compiler, tests, spec, ci, docs

🚥 Pre-merge checks | ✅ 7 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Diagnostics Carry An Error Code ⚠️ Warning New --world/server validation errors are plain ValueErrors and JSON diagnostics with only severity/description/location; no stable E/W### code is attached. Give each new world/server diagnostic a registered code in vera/errors.py, then thread error_code through the CLI JSON/text wrappers and validate_handler/emit_wasi_component error paths.
✅ Passed checks (7 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarises the main change: adding --world server support for verified HTTP handlers and the v0.0.195 release.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Changelog Covers Public-Surface Changes ✅ Passed PASS — the v0.0.195 note explicitly describes the new --world server CLI, vera run rejection, and spec §13.7 server-world surface.
Spec And Implementation Move Together ✅ Passed PASS — spec/13-wasi.md’s new server-world section matches the codegen/CLI/runtime changes for --world server, including wasmtime serve and the supported/rejected host surface.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/wasi-http-serve

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.92097% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.01%. Comparing base (e3927ba) to head (9ca571c).

Files with missing lines Patch % Lines
vera/cli.py 63.88% 13 Missing ⚠️
vera/codegen/wasi.py 97.57% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #850      +/-   ##
==========================================
+ Coverage   92.00%   92.01%   +0.01%     
==========================================
  Files          95       95              
  Lines       28363    28677     +314     
  Branches      332      332              
==========================================
+ Hits        26095    26387     +292     
- Misses       2260     2282      +22     
  Partials        8        8              
Flag Coverage Δ
javascript 65.23% <ø> (ø)
python 94.97% <93.92%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@TESTING.md`:
- Line 9: The test overview counts are inconsistent in the Tests row, so update
the summary in TESTING.md to make the total match the breakdown. Reconcile the
values shown for passed, stress, and skipped tests against the total, and adjust
either the total or one of the subcounts so the numbers add up consistently in
the overview table.

In `@vera/cli.py`:
- Around line 404-425: Move the pure CLI flag validation in cli.py so the
world/target compatibility check runs before _load_and_parse and
codegen_compile, since it only depends on world and target and not on result.
Keep the wasi-p2 emit gating that uses result in place, but hoist the existing
world != "cli" and target != "wasi-p2" guard to return the error immediately for
invalid flag combinations, both in normal and as_json paths.

In `@vera/codegen/wasi.py`:
- Around line 2668-2674: Add a wasmtime serve smoke test that exercises the
server-side IO surface exposed by _SERVER_IO_OPS in vera/codegen/wasi.py. Extend
tests/test_wasi_target.py with a round-trip test that actually runs under
wasmtime serve and calls IO.time, IO.sleep, and Random.random_* instead of only
verifying the component loads. Use the existing
test_time_sleep_random_handler_parses_as_component and the server-world wiring
around time/sleep/random_* as the entry point so the new test catches
proxy-world drift in the clock/random adapters.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: cfb5d2d5-7457-4073-b430-bd0031f19a33

📥 Commits

Reviewing files that changed from the base of the PR and between e3927ba and 7143d6c.

⛔ Files ignored due to path filters (6)
  • docs/SKILL.md is excluded by !docs/**
  • docs/index.html is excluded by !docs/**
  • docs/index.md is excluded by !docs/**
  • docs/llms-full.txt is excluded by !docs/**
  • docs/llms.txt is excluded by !docs/**
  • uv.lock is excluded by !**/*.lock, !uv.lock
📒 Files selected for processing (17)
  • CHANGELOG.md
  • CLAUDE.md
  • HISTORY.md
  • README.md
  • ROADMAP.md
  • SKILL.md
  • TESTING.md
  • TOOLCHAIN.md
  • WASI.md
  • pyproject.toml
  • scripts/check_skill_examples.py
  • spec/13-wasi.md
  • tests/test_wasi_target.py
  • vera/__init__.py
  • vera/cli.py
  • vera/codegen/wasi.py
  • vera/runtime/server.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • aallan/vera-bench (manual)

Comment thread TESTING.md Outdated
Comment thread vera/cli.py Outdated
Comment thread vera/codegen/wasi.py
…ion, teardown kill fallback

- vera run --world server with the DEFAULT target now gives the same
  usage error cmd_compile gives instead of a message implying the user
  asked for wasi-p2; the previously-untested default-target path gets
  a test.
- CHANGELOG @0.2.3 phrasing corrected (imports are pinned @0.2.0;
  wasmtime's semver-compatible lookup links them — the design study
  probed @0.2.3 acceptance separately).
- Spec §13.7 server-world surface now lists IO.time / IO.sleep /
  Random (implementation accepted them; prose understated).
- The serve-smoke context manager force-kills on SIGTERM timeout
  instead of leaking the process.

Co-Authored-By: Claude <noreply@anthropic.invalid>
@aallan

aallan commented Jul 2, 2026

Copy link
Copy Markdown
Owner Author

Review round 1 — pr-review-toolkit code-reviewer

Empirical review of 7143d6c (every claim verified by running code): no correctness bugs found.

Confirmed by execution: family-gate completeness — shim emitted ⟺ dispatch slot populated (both derive from the same used set), unknown imports raise loudly, and every non-Map<String,String> family is rejected by name; the cli-world byte-pin is real — HEAD's cli emission diffed byte-identical against main's via a throwaway worktree; map parity — exactly the 8 compiler-emitted map ops + 2 GC stubs have in-guest emitters, $ks_vs classification fails closed on malformed suffixes, and the live map-order differential pins exact host semantics under real wasmtime serve; the serve-smoke banner regex matches wasmtime 46's actual output; the _serve_handle shadow-push/pop accounting balances 5/5; Windows fixture rules and docs honesty (no blanket compliance claims; §13.7 caps and rejected-op list match the implementation) all hold.

Four low-severity nits, all fixed in the follow-up commit:

  • vera run --world server with the default target now gives the same usage error cmd_compile gives, instead of a message implying the user asked for wasi-p2 — with a test for the previously uncovered path.
  • CHANGELOG phrasing corrected: imports are pinned @0.2.0 and link under wasmtime's semver-compatible lookup (the design study probed @0.2.3 acceptance separately — the component doesn't emit it).
  • Spec §13.7's server-world surface now lists IO.time / IO.sleep / Random (the implementation accepted them; the prose understated).
  • The serve-smoke context manager force-kills on SIGTERM timeout instead of leaking the process.

…clock/random smoke

- The pure --world/--target flag validation now fires before any
  parse/compile work in both cmd_compile and cmd_run (an incompatible
  combo no longer costs a compile round-trip to discover).
- TESTING.md overview breakdown reconciled (5,742 + 26 + 40 = 5,808).
- New serve-smoke test executes IO.time / IO.sleep / Random.random_int
  through a real request under stock wasmtime serve (the surface was
  previously parse-tested only) — time bracketed against the host
  clock with the established cross-clock slack, random range-checked.

Co-Authored-By: Claude <noreply@anthropic.invalid>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

185-185: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Mention the --world/--target gating rule.

The paragraph documents --world server as the deployment path but doesn't note that it's only valid with --target wasi-p2 (enforced by cmd_compile/cmd_run, per this PR's cli.py changes). As per path instructions for README.md, the wasi-p2 description should "explicitly mention ... that server-world behavior is enforced by the target/world gating rules."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 185, The README wording for the wasi-p2 section omits the
target/world gating rule, so update the `vera compile --target wasi-p2` and
`--world server` description to explicitly state that server-world behavior is
only allowed with `--target wasi-p2` and is enforced by the
`cmd_compile`/`cmd_run` checks. Keep the focus on the `--target wasi-p2` and
`--world server` contract so readers understand the server deployment path is
gated by those options, not available independently.

Source: Path instructions

♻️ Duplicate comments (2)
TESTING.md (1)

9-9: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Overview "Tests" breakdown still doesn't add up.

5,735 passed + 26 stress + 40 skipped = 5,801, not 5,807. This exact inconsistency was flagged in a previous review round (then the total was 5,806, off by 5) and remains unresolved — it's now off by 6 since this PR bumps the total by 1 (the new test_run_world_without_wasi_p2_is_a_usage_error test) without updating the passed sub-count.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@TESTING.md` at line 9, The Tests summary in TESTING.md is inconsistent
because the total count does not match the sub-counts. Update the breakdown near
the Tests table so the total in the row matches the sum of passed, stress, and
skipped tests, and make sure the passed count reflects the newly added
test_run_world_without_wasi_p2_is_a_usage_error. Use the Tests row in TESTING.md
as the source of truth and adjust the numbers so they add up exactly.
vera/cli.py (1)

404-425: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Pure flag-validation still runs after a full compile (now in two places).

world != "cli" and target != "wasi-p2" depends only on the CLI flags, yet both cmd_compile (404-425) and the new cmd_run copy (763-782) check it only after _load_and_parse/codegen_compile succeeds. A user who passes --world server on a program that also fails to compile burns a full compile cycle before learning the flags were wrong. This was already raised as non-blocking/optional in a prior review round for cmd_compile; it's now duplicated verbatim in cmd_run.

Also applies to: 763-782

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@vera/cli.py` around lines 404 - 425, Move the pure flag check for `world !=
"cli" and target != "wasi-p2"` in `cmd_compile` and the duplicated `cmd_run`
logic so it runs before `_load_and_parse` or `codegen_compile` starts. Keep the
existing error formatting and JSON/stderr handling, but validate the CLI flags
first using the same `world`, `target`, `as_json`, and `msg` logic so invalid
combinations fail fast without doing a full compile.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@README.md`:
- Line 185: The README wording for the wasi-p2 section omits the target/world
gating rule, so update the `vera compile --target wasi-p2` and `--world server`
description to explicitly state that server-world behavior is only allowed with
`--target wasi-p2` and is enforced by the `cmd_compile`/`cmd_run` checks. Keep
the focus on the `--target wasi-p2` and `--world server` contract so readers
understand the server deployment path is gated by those options, not available
independently.

---

Duplicate comments:
In `@TESTING.md`:
- Line 9: The Tests summary in TESTING.md is inconsistent because the total
count does not match the sub-counts. Update the breakdown near the Tests table
so the total in the row matches the sum of passed, stress, and skipped tests,
and make sure the passed count reflects the newly added
test_run_world_without_wasi_p2_is_a_usage_error. Use the Tests row in TESTING.md
as the source of truth and adjust the numbers so they add up exactly.

In `@vera/cli.py`:
- Around line 404-425: Move the pure flag check for `world != "cli" and target
!= "wasi-p2"` in `cmd_compile` and the duplicated `cmd_run` logic so it runs
before `_load_and_parse` or `codegen_compile` starts. Keep the existing error
formatting and JSON/stderr handling, but validate the CLI flags first using the
same `world`, `target`, `as_json`, and `msg` logic so invalid combinations fail
fast without doing a full compile.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: aeec6706-b0a7-4220-b02d-4b999ac162a1

📥 Commits

Reviewing files that changed from the base of the PR and between 7143d6c and 3c6bcf1.

📒 Files selected for processing (8)
  • CHANGELOG.md
  • HISTORY.md
  • README.md
  • ROADMAP.md
  • TESTING.md
  • spec/13-wasi.md
  • tests/test_wasi_target.py
  • vera/cli.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • aallan/vera-bench (manual)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
vera/cli.py (2)

1616-1620: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Diagnostic dict is missing the location field carried by every other envelope in this file.

All other JSON diagnostics in cmd_compile/cmd_run (and the file-not-found / trap paths) include "location": {"line": 0, "column": 0}. A consumer that reads diag["location"] will KeyError only on this invalid---world path. Given the JSON CLI output is a documented stability contract, keep the shape uniform.

🔧 Proposed fix
                 if use_json:
                     print(json.dumps({"ok": False, "file": "",
                                       "diagnostics": [{"severity": "error",
-                                                       "description": msg}]},
+                                                       "description": msg,
+                                                       "location": {"line": 0, "column": 0}}]},
                                      indent=2))

As per path instructions: "JSON CLI output fields are a stability contract".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@vera/cli.py` around lines 1616 - 1620, The JSON envelope in the
invalid-`--world` branch is missing the standard `location` field, unlike the
other diagnostic payloads in `cmd_compile`, `cmd_run`, and the
file-not-found/trap paths. Update the `use_json` branch in this CLI handler to
emit the same diagnostic shape by adding a `location` object with line and
column set to 0 inside the `diagnostics` entry, keeping the JSON output
consistent with the rest of the file.

Source: Path instructions


775-799: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Optional: this server-world refusal never touches result, so it can hoist above the compile.

The world == "server" branch depends only on world (and by the Line 618 gate, target is already guaranteed to be wasi-p2 when we get here). As placed, vera run --world server --target wasi-p2 on a program that also fails to compile shows the compile error first; the user fixes it, recompiles, and only then learns vera run cannot host the component — the same two-round-trip pattern that motivated hoisting the pure flag check earlier in this PR. Moving this block just below the Line 631 validation gives immediate, program-independent feedback and skips a discarded compile. Non-blocking.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@vera/cli.py` around lines 775 - 799, The `world == "server"` refusal in
`vera.cli.run` is independent of compilation and only depends on the
already-validated `world`/`target` state, so it should be checked earlier. Hoist
this branch to immediately after the existing `target`/world validation in `run`
so `vera run --world server --target wasi-p2` fails fast with the hosting error
instead of first reporting unrelated compile failures; keep the same `msg`, JSON
error path, and stderr behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@vera/cli.py`:
- Around line 1616-1620: The JSON envelope in the invalid-`--world` branch is
missing the standard `location` field, unlike the other diagnostic payloads in
`cmd_compile`, `cmd_run`, and the file-not-found/trap paths. Update the
`use_json` branch in this CLI handler to emit the same diagnostic shape by
adding a `location` object with line and column set to 0 inside the
`diagnostics` entry, keeping the JSON output consistent with the rest of the
file.
- Around line 775-799: The `world == "server"` refusal in `vera.cli.run` is
independent of compilation and only depends on the already-validated
`world`/`target` state, so it should be checked earlier. Hoist this branch to
immediately after the existing `target`/world validation in `run` so `vera run
--world server --target wasi-p2` fails fast with the hosting error instead of
first reporting unrelated compile failures; keep the same `msg`, JSON error
path, and stderr behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6e413643-446f-4ac3-b7bd-4636fb8049aa

📥 Commits

Reviewing files that changed from the base of the PR and between 3c6bcf1 and 32aea1c.

📒 Files selected for processing (6)
  • HISTORY.md
  • README.md
  • ROADMAP.md
  • TESTING.md
  • tests/test_wasi_target.py
  • vera/cli.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • aallan/vera-bench (manual)

T and others added 2 commits July 2, 2026 18:31
… fields, README gating clause

- The world==server run-refusal now fires before any parse/compile
  work in cmd_run, matching the hoisted flag validation (the message,
  JSON shape, and stderr behavior are unchanged).
- main()'s --target and --world invalid-value JSON envelopes gain the
  standard location field (JSON CLI output fields are a stability
  contract; the --target gap was pre-existing and identical).
- README's wasi-p2 paragraph states the gating rule explicitly:
  --world server is only valid with --target wasi-p2.

Skip-changelog: CLI diagnostic-shape polish + README clause within the v0.0.195 feature already described in this PR's CHANGELOG section

Co-Authored-By: Claude <noreply@anthropic.invalid>
…side the guarded class

The new test_time_sleep_random_execute_under_serve was appended after
TestCliServerWorld rather than inside the skipif-guarded
TestWasmtimeServeSmoke class, so every CI test job at 32aea1c failed
with FileNotFoundError: 'wasmtime' (runners lack the CLI; it passed
locally where wasmtime exists).  The test now carries its own skipif
with a docstring note on why.

Skip-changelog: test-only guard fix within this PR's feature

Co-Authored-By: Claude <noreply@anthropic.invalid>
@aallan

aallan commented Jul 2, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai Outside-diff findings, all resolved:

  • README.md — gating clause added in b295dfa: the paragraph now states --world server is only valid together with --target wasi-p2 and that the CLI rejects other combinations.
  • TESTING.md — already reconciled at 32aea1c: the Tests row reads 5,742 passed + 26 stress + 40 skipped = 5,808 (the review ran against the prior head).
  • vera/cli.py (compile-hoist) — already done at 32aea1c: the pure --world/--target validation runs at the top of both cmd_compile and cmd_run, before any parse/compile work.
  • vera/cli.py (run-refusal hoist) — fixed in b295dfa: the world == "server" refusal now fires immediately after the flag validation in cmd_run, before parse/compile; message, JSON shape, and stderr behavior unchanged.
  • vera/cli.py (JSON location field) — fixed in b295dfa: main()'s invalid---world envelope gains the standard location field, and the identical pre-existing gap in the invalid---target envelope is fixed alongside (JSON CLI output fields are a stability contract).

Separately: the all-red CI at 32aea1c was my test-placement error — the new clock/random serve smoke sat outside the skipif-guarded class and hit FileNotFoundError: 'wasmtime' on runners without the CLI. It now carries its own skipif (9ca571c, test-only).

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -e
git fetch origin pull/850/head:pr850 2>&1 | tail -5
git checkout pr850 2>&1 | tail -5
echo "---README.md gating clause---"
grep -n "world server" README.md | head -20
echo "---TESTING.md tests row---"
grep -n "5,742\|5,808\|5,768" TESTING.md
echo "---cli.py world/target validation hoist---"
rg -n "def cmd_compile|def cmd_run" vera/cli.py
echo "---cmd_run body head---"
sed -n '/def cmd_run/,/^def /p' vera/cli.py | head -60
echo "---location field in json envelopes---"
rg -n "location" vera/cli.py | head -30

Length of output: 6102


All confirmed — the fixes match your summary exactly: README.md's gating clause is in place (Line 185), TESTING.md's Tests row correctly reads 5,742 passed + 26 stress + 40 skipped = 5,808 (Line 9), and cmd_run hoists both the --world/--target validation and the world == "server" refusal ahead of any parse/compile work, with location present in the JSON error envelopes. Thanks for the detailed writeup and for tracking down the CI red herring — appreciate the precision here.

@aallan
aallan merged commit 91e19d1 into main Jul 2, 2026
28 checks passed
@aallan
aallan deleted the feat/wasi-http-serve branch July 2, 2026 17:52
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