Skip to content

Browser playground with BETH operator console#6

Merged
buchk merged 5 commits into
mainfrom
feature/playground
Jul 14, 2026
Merged

Browser playground with BETH operator console#6
buchk merged 5 commits into
mainfrom
feature/playground

Conversation

@buchk

@buchk buchk commented Jul 13, 2026

Copy link
Copy Markdown
Owner

What

A zero-install, zero-backend playground deployed to GitHub Pages (https://buchk.github.io/TypeFerence/) on every push to main: edit typed source in the browser and watch compiled Codex/Copilot/Cursor/neutral artifacts, diagnostics, the embedding graph, and the determinism digest update live — plus an Equivalence tab that walks the full BETH loop without ever asking for a credential.

How

  • go/cmd/typeference-wasm — a js/wasm entry point over the existing internal/ packages, exposing compile and pack. The compiler is not forked, wrapped, or reimplemented; the wasm runs the same compile.Validatecompile.Buildcompile.HashDirectory and eval.Pack pipelines as the CLI.
  • web/playground/memfs.js — an in-memory implementation of the Node-style fs API that Go's js/wasm syscall layer expects, so the compiler's ordinary os calls work unchanged inside the tab.
  • web/playground/ — dependency-free HTML/CSS/JS: syntax-colored editor, artifact browser, embedding graph (computed structural-interface satisfaction shown as dashed edges), resolved-bundle view, shareable gzip+base64url links, light/dark theme, CSP pinning connect-src to the page's own origin.
  • BETH operator console (beth.js, ADR-0011) — packs scenario × surface cells in-browser with the real equivalence pack code (examples ship scenarios); cells render as copy-prompt/paste-response cards, which is exactly BETH's attested-operator collection model (ADR-0009); the assembled run exports as a deterministic ustar+gzip archive (fixed mtime); scoring happens locally (typeference equivalence score <run> --live — the judge key stays in your terminal); dropping scorecard.json back onto the page renders adherence per surface, cross-surface agreement, and every divergence with the judge's reasoning.
  • make playground builds the gitignored assets; wasm_exec.js is copied from the building toolchain's GOROOT so it can never skew from the wasm binary. CI builds the bridge and packer to prevent bitrot.

Determinism, made interactive

The in-memory source dir is named after the loaded example and the ARD publisher domain matches the repo's own build commands, so the Helio example reproduces the committed dist/ digest exactly (a22f5410ba5f8e17…) and the maintainer example recompiles the repository-root AGENTS.md byte for byte (8b21fee0…) — browser, Windows CLI, and CI's Linux build all agree on the bytes.

No secrets in the browser (ADR-0011)

A bring-your-own-key run surface was built first, worked, and was rejected anyway: asking visitors to paste provider keys into a hosted page is the anti-pattern this project's trust posture argues against. The ADR records the decision and preserves the verified transport knowledge (e.g. OpenAI only answers browser CORS on the Responses API). The console needs no keys at any step that touches this page.

Verified end to end

  • gofmt/go vet/go test ./... clean; wasm bridge and packer build in CI.
  • All three examples compile in-browser with digests matching CLI runs; error paths, graph, bundle, share links, stale-pack marker exercised in a real browser session.
  • Full BETH round trip with the real toolchain: browser-packed starter run → real download → extracted with system tar → scored by the CLI with zero workspace drift (the CLI's SHA-256 digest check verified the browser-written bytes exactly) → judged via seeded judge-response.json including a deliberate divergence → the CLI's scorecard.json rendered back in the browser (fail banner, 3/3·3/3·3/3·2/3 adherence, 2/3 agreement, divergence with all four verdicts).

Also

  • ADR-0010 (playground), ADR-0011 (equivalence console), and a design note capturing the typed-context-shapes idea for a future ADR (docs/design-notes/typed-context-shapes.md).
  • Pages must be enabled once with source "GitHub Actions" (the workflow passes enablement: true, which usually handles this on first deploy).

🤖 Generated with Claude Code

buchk and others added 4 commits July 13, 2026 14:47
The unmodified Go compiler built for js/wasm, running against an
in-memory Node-style fs shim, with a dependency-free static UI:
live recompilation, artifact browser, embedding graph (including
computed structural-interface satisfaction), resolved-bundle view,
shareable gzip+base64url links, and the determinism digest in the
status bar. Deployed to GitHub Pages on push to main.

The in-memory source directory is named after the loaded example and
the ARD publisher domain matches the repository's own build commands,
so the Helio example reproduces the committed dist/ digest exactly and
the maintainer example reproduces the repository-root AGENTS.md byte
for byte — verified against the Windows CLI during development.

Generated assets (typeference.wasm, wasm_exec.js, examples.json) are
gitignored and produced by 'make playground'; wasm_exec.js is copied
from the building toolchain so it cannot skew from the wasm binary.
CI builds the wasm bridge and example packer to prevent bitrot.
See ADR-0010.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nsole

Working, browser-verified bring-your-own-key Run tab (Anthropic, OpenAI
Responses API, Gemini, GitHub Models; SSE streaming verified against
synthetic wire-format streams; error paths verified against live
endpoints; keys memory-only, opt-in persistence, CSP pinning
connect-src). Kept as scaffolding only: ADR-0011 records the decision
to replace it with a no-secrets BETH operator console (pack in wasm,
copy/paste collection per ADR-0009's operator model, tar.gz export,
local scoring, scorecard visualization) before this branch merges.

Also captures the typed-context-shapes idea as a design note
(docs/design-notes/) for a future ADR.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The Equivalence tab walks the full BETH loop (ADR-0009) with no secrets
in the browser (ADR-0011): the wasm bridge grows a pack entry point
over the real eval.Pack; examples ship scenarios (helio's from
evals/scenarios, inline ones for starter and maintainer); cells render
as copy-prompt/paste-response cards (BETH's operator model); the
assembled run exports as a deterministic ustar+gzip archive (fixed
mtime); the console prints the local score command; and dropping
scorecard.json back in renders adherence, agreement, and divergences.

providers.js and the key UI are deleted; the CSP now pins connect-src
to the page's own origin.

Verified end to end with the real toolchain: browser-packed starter
run exported, extracted with system tar, scored by the CLI with zero
workspace drift (digest-verified bytes), judged via seeded
judge-response.json including a deliberate divergence, and the
resulting scorecard.json rendered back in the browser.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@buchk buchk changed the title Browser playground: the Go compiler as WebAssembly Browser playground with BETH operator console Jul 14, 2026
… link

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@buchk buchk merged commit 7851a05 into main Jul 14, 2026
8 checks passed
@buchk buchk deleted the feature/playground branch July 14, 2026 03:40
buchk added a commit that referenced this pull request Jul 15, 2026
Browser playground with BETH operator console
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