feat(spec): expose __sanderlingSampleInput__ corpus draw

This commit is contained in:
pj committed 2026-06-12 10:25:51 +05:30
1 parent 6a084b6740
commit 71afe0c914
1 file changed
+8
+8
View File
@@ -9,6 +9,7 @@
import { Pcg } from "./pcg.ts"; import { Pcg } from "./pcg.ts";
import { nextAction, walk } from "./pick.ts"; import { nextAction, walk } from "./pick.ts";
import { INPUT_CORPUS } from "./corpus.ts";
import type { ActionDescriptor, GeneratorNode, Host } from "./action-tree.ts"; import type { ActionDescriptor, GeneratorNode, Host } from "./action-tree.ts";
import type { Point } from "./types.ts"; import type { Point } from "./types.ts";
@@ -130,6 +131,13 @@ export function installRuntime(
const resolveRoot = typeof root === "function" ? root : () => root; const resolveRoot = typeof root === "function" ? root : () => root;
const resolveSetup = () => const resolveSetup = () =>
(globalThis as { setup?: GeneratorNode }).setup ?? null; (globalThis as { setup?: GeneratorNode }).setup ?? null;
// The LLM action backend (Go) types InputText values by drawing from the same
// edge-case corpus the seeded `typing` builtin uses. Expose that draw here so
// Go reuses the exact sampler rather than reimplementing the corpus.
defineLockedGlobal(
"__sanderlingSampleInput__",
() => INPUT_CORPUS[rng.intN(INPUT_CORPUS.length)] ?? "",
);
defineLockedGlobal("__sanderlingExtractors__", () => evaluateExtractors()); defineLockedGlobal("__sanderlingExtractors__", () => evaluateExtractors());
defineLockedGlobal("__sanderlingNextAction__", () => { defineLockedGlobal("__sanderlingNextAction__", () => {
// resolveRoot runs first: on web it also resets the per-tick candidate // resolveRoot runs first: on web it also resets the per-tick candidate