itx: one example catalogue across REPL UI and every e2e runtime#1480
Conversation
The browser REPL examples and the e2e shared scripts collapse into one
catalogue (src/itx/examples.ts): each entry has a title, description,
context, runtimes tags, and a script body written against a PROJECT-scoped
handle — the harness connects into the project and the script gets straight
to work (itx.streams.get("/repl/demo").append(...)).
The e2e suite runs each catalogue entry through every runtime it is tagged
for: node (AsyncFunction over Cap'n Web), the new `pnpm cli itx run -e`
(a real spawned CLI evaluating over its own WebSocket), /api/itx/run
(dynamic worker), the project's iterate-config worker (baked in via git
push, invoked through itx.worker), and the browser REPL pipeline in
headless Chromium. Assertions live in e2e/example-cases.ts; a guard test
fails when a runnable example lacks a case.
REPL compatibility: top-level `return` no longer angers the editor (TS1108
filtered in the typescript worker; runtime already wrapped bodies in an
async function), and top-level imports now work — bare specifiers rewrite
to awaited dynamic imports from esm.sh, comment/string-aware so worker
sources inside template literals stay untouched. `vars` joins the REPL
scope so examples run unchanged.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… — keep diagnostics filter + catalogue Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The catalogue's project examples assume a project-scoped handle; offering them unmodified in the global REPL ran them against the wrong namespace (Bugbot finding on #1480). The REPL now knows its context: the global page shows project examples with a pointer to a project REPL instead of a Use button; a project REPL can run everything (the global narrowing example narrows to itself). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Worker-heavy catalogue examples running while the other itx e2e files load their own dynamic workers can trip the deployment's 'Too many concurrent dynamic workers' cap (seen 3/48 on a parallel full-suite run against preview-6). Shared-load contention, not behavior — retry that one error with backoff; everything else still fails immediately. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bfcd25e. Configure here.
A fresh crypto.randomUUID() cacheKey per run made every matrix runtime load
a brand-new isolate for every cap; the accumulated residents tripped
Cloudflare's loader concurrency cap deterministically by the third
worker-heavy example ('Too many concurrent dynamic workers' — same three
failures solo or parallel). Static sources get static keys: re-running an
example reuses the loaded worker, and the keys read as what they are —
content versions you bump when you edit the module text.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Verification record for this PR (all against the preview-6 deployment of this branch, post-merge-with-main): CI ( Headless Chromium, run locally against the same deployment ( CLI smoke (prd, read-only): Two follow-up fixes landed during babysitting: stable content-version cacheKeys in the catalogue (fresh-uuid keys accumulated isolates until Cloudflare's loader cap tripped — deterministic after ~3 worker-heavy examples), and the global REPL no longer offers project-context examples as runnable (Bugbot finding). 🤖 Generated with Claude Code |
Main moved the REPL examples into examples.ts (#1480) mid-flight; the live-cap examples now teach caps.define with a live target (one alias mention survives), and the REPL harness mock speaks the same verb. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

What
Refactors the itx e2e suite to work like the old capnweb e2e suite: the same script runs across every runtime, and the scripts themselves are the catalogue the REPL UI shows as Examples.
One catalogue (
src/itx/examples.ts){ id, title, description, context, runtimes, code }. The UI renders title/description/context/runtimes; the e2e suite executescode.itx.streams.get("/repl/demo").append(...)). Only the narrowing example itself is global-context.itxandvarsin scope and end with an explicitreturn— the one shape every runtime accepts.The runtime matrix (
e2e/example-matrix.ts)Each example runs in every runtime it's tagged for:
AsyncFunctionover a Cap'n Web WebSocket stubpnpm cli itx run -e …(new command; a real spawned CLI evaluating over its own connection, so it can hold live caps likenode -e)/api/itx/runwith the body wrapped asasync ({ itx, vars }) => { … }worker.js(one git push per suite), each example invoked viaitx.worker.runItxExample({ id, vars })and executed against the worker's ownenv.ITERATE.contextitx.browser.test.ts)Assertions live in
e2e/example-cases.ts; a guard test fails when a runnable example has no case, so UI examples can't silently rot.REPL compatibility
returnno longer shows a tsc error (TS1108 filtered in the REPL's TS worker; the runtime always wrapped snippets in an async function body anyway).importworks: bare specifiers rewrite to awaited dynamic imports from esm.sh (import { z } from "zod"→const … = await import("https://esm.sh/zod")). The rewrite reuses the comment/string-aware statement scanner, so worker sources inside template literals are untouched, and imported bindings persist across REPL entries. New browser-only catalogue example demonstrates it.varsis always in REPL scope (withprojectIddeclared for the editor) so catalogue examples run unchanged.CLI
pnpm cli itx run -e "<body>" [--context <project>] [--vars '{...}'] [--file …]— verified against prd:Verification
pnpm typecheck && pnpm lint && pnpm format && pnpm testgreen locally.🤖 Generated with Claude Code
Note
Medium Risk
Large test and execution-surface change (CLI eval, config-worker git pushes, dynamic
AsyncFunction/new Functionin REPL and CLI); behavior is heavily covered by e2e but touches admin-authenticated script execution and deployed worker loading.Overview
Unifies itx Examples and e2e coverage around a single catalogue in
src/itx/examples.ts(id,context,runtimes, script body withitx+vars+ trailingreturn). The REPL Examples panel and tests both consume that list;example-cases.tsholds assertions and a guard so runnable examples cannot rot without a case.Adds a cross-runtime matrix (
example-matrix.ts): the same script runs on node (Cap'n Web), cli (itx run— newscripts/itx-run.ts, wired into the iterate CLI router), dynamic-worker (/api/itx/run), and config-worker (catalogue baked into iterate-configworker.jsvia git push). Browser e2e runs catalogue snippets through the real REPL pipeline (itx.browser.test.ts).REPL/runtime alignment: default scope includes
vars; editor globals addvars,projectId, and wildcard modules; TS1108 is filtered so top-levelreturntypechecks; top-levelimportrewrites to awaited esm.sh dynamic imports with session-persisted bindings. Global vs project REPL disables project-only snippets in the UI when context does not match.Removes inlined REPL examples and the old
itx-scriptstyped script builder in favor of the catalogue; shared e2e worker sources stay in slimitx-scripts.ts.Reviewed by Cursor Bugbot for commit 925f20f. Bugbot is set up for automated code reviews on this repo. Configure here.
Environment Config Lease
No active environment config lease.
OS
Status: released
Commit:
925f20fPreview: https://os.iterate-preview-6.com
Summary: Preview app released.
Workflow run
Updated: 2026-06-10T22:27:41.380Z