Skip to content

Add Custom Debugger: client-side Blaze evaluator via WebAssembly - #411

Open
itvi-1234 wants to merge 3 commits into
ioflux-org:mainfrom
itvi-1234:feature/wasm-custom-debugger
Open

itvi-1234 wants to merge 3 commits into
ioflux-org:mainfrom
itvi-1234:feature/wasm-custom-debugger

Conversation

@itvi-1234

Copy link
Copy Markdown
Contributor

Summary

Adds a Custom Debugger to Studio: paste any JSON Schema + instance and step through the real Sourcemeta Blaze evaluator's push/pass/fail trace, with synced highlighting in both the schema and instance editors.

Everything runs entirely client-side — Blaze's C++ compiler is compiled to WebAssembly and bundled alongside its official pure-JS evaluator port, so there is no server, no local port, and no network dependency. It works fully offline on GitHub Pages, same as the rest of Studio.

What's included

  • src/lib/blaze/ — the compiled blaze_wasm.wasm/.js (Blaze's compiler via Emscripten) plus the matching pure-JS evaluator (evaluator.mjs, describe.mjs, opcodes.mjs) from the same Blaze build, wrapped by index.ts's traceCustom(schemaText, instanceText).
  • src/components/CustomDebugger/ — the debugger UI: dual Monaco editors (schema/instance), a call-stack visualizer, and step controls (step back/forward, play, jump to next failure).
  • A bug-icon button in the nav bar (NavigationBar.tsx) opens the debugger as a full-screen overlay, wired through AppContext/AppProvider (isCustomDebuggerOpen / openCustomDebugger / closeCustomDebugger) so it's reachable from both the normal and fullscreen nav bar instances. It mounts lazily (CustomDebuggerGate.tsx) so the ~1.5MB WASM module is only fetched on first use.
  • resolveEvaluatePath.ts — Blaze's evaluatePath follows the JSON Schema spec's evaluation-path format, which inserts a literal $ref token into the path and continues with the referenced schema's own relative path. That doesn't line up with the pasted schema text's physical JSON pointers, so this walks the same path against the parsed schema, following $ref hops, to recover the pointer that highlighting can actually use. Same-document refs ($defs, etc.) now resolve and highlight correctly; a genuine external $ref (a different document) still can't be highlighted, since that document's text isn't available client-side.
  • A changeset (.changeset/wasm-custom-debugger.md) for the release.

Why WebAssembly

Blaze's compiler is C++-only; there's no JS/WASM build of it upstream. Studio is a static site with no backend, so a local compile server wasn't an option here. Compiling the compiler to WASM keeps the "paste schema, paste instance, see it debug" flow fully static and portable, consistent with how the rest of Studio works.

Compiles Sourcemeta Blaze's C++ compiler to WebAssembly so schema
compilation and step-by-step trace evaluation run entirely in the
browser, with no server or port dependency. Adds a debugger button to
the nav bar that opens a full-screen editor where you can paste any
schema + instance and step through push/pass/fail evaluation with
synced Monaco highlighting on both panels.

Signed-off-by: itvi-1234 <rjsumit71@gmail.com>
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Preview Deployed!

Item Status
Latest Deploy Visit Preview
Environment Preview (PR-411)
Action View Logs

Last updated at 2026-09-04T14:41:50Z

The debugger's schema panel now opens pre-filled with whatever schema
is currently loaded in Studio's main editor (converted from YAML if
that's the active format), instead of always starting from a sample
schema. The instance panel is left as a sample for the user to edit,
since there's no equivalent "current instance" in Studio's main view.

Signed-off-by: itvi-1234 <rjsumit71@gmail.com>
DEFAULT_SCHEMA now mirrors Studio's own default schema
(src/data/defaultJSONSchema.json) instead of an unrelated sample, and
DEFAULT_INSTANCE is a person that actually validates against it —
verified against the real Blaze evaluator. Previously the sample
instance didn't correspond to whatever schema a fresh Studio session
seeds the debugger with, so a first-time "Compile & Trace" click
against the just-opened default schema failed for unrelated reasons.

Signed-off-by: itvi-1234 <rjsumit71@gmail.com>
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