From bf89f3b1cf6a19fbe70e0d213bc14dc91e53b3a6 Mon Sep 17 00:00:00 2001 From: PJ Date: Mon, 1 Jun 2026 16:42:48 +0530 Subject: [PATCH] feat(spec): goja runtime entry wires the shared picker over the Go host --- pkg/spec/src/goja-runtime.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pkg/spec/src/goja-runtime.ts diff --git a/pkg/spec/src/goja-runtime.ts b/pkg/spec/src/goja-runtime.ts new file mode 100644 index 0000000..b99b8d8 --- /dev/null +++ b/pkg/spec/src/goja-runtime.ts @@ -0,0 +1,23 @@ +// Goja-side runtime entry for the native verifier (internal/verifier). +// +// Go installs globalThis.__sanderlingHost__ (platform/seed/queryCandidates/ +// reportUnsupported, implemented over the hierarchy tree in bindings.go) before +// the spec evaluates. This module bundles AFTER the spec, reads that host, and +// wires the shared picker via installRuntime so the goja verifier and the V8 web +// runtime run the SAME pick.ts over the SAME Pcg. +// +// Extractors are driven by Go (bindExtract + PushSnapshot advance current/ +// previous against the Go-built `state`), so the extractor callback is a no-op +// here; Go never invokes __sanderlingExtractors__ on native. + +import { installRuntime } from "./runtime-entry.ts"; +import type { GeneratorNode, Host } from "./action-tree.ts"; + +const host = (globalThis as { __sanderlingHost__?: Host }).__sanderlingHost__; +if (!host) throw new Error("goja runtime: __sanderlingHost__ not installed"); + +installRuntime( + host, + () => (globalThis as { actions?: GeneratorNode }).actions ?? null, + () => ({}), +);