// SerialSGS — Search block. // // Wraps the greedy serial Schedule Generation Scheme as a registry-named // search so a run config can select the backend declaratively. Future // backends (CP-SAT, MiniZinc subprocess) register beside it under their own // versioned codes rather than forking the run API. import { z } from "zod"; import { serialSGS } from "../level-core/search/serialSGS.ts"; import type { Search } from "../level-core/types.ts"; import type { MiniZincFragment, SearchBlock } from "./types.ts"; export const SerialSGSInputSchema = z.object({}); export type SerialSGSInput = z.infer; const SearchOutputSchema: z.ZodType = z.custom( (val): val is Search => typeof val === "object" && val !== null && typeof (val as Search).name === "string" && typeof (val as Search).run === "function", ); export const SerialSGSBlock: SearchBlock = { id: "SerialSGS", schema: { input: SerialSGSInputSchema, output: SearchOutputSchema }, apply: (): Search => serialSGS, toMiniZinc: (): MiniZincFragment => ({ // The search itself never lowers to MiniZinc — a MiniZinc backend // replaces it wholesale. Emitted as a comment so concatenated compiles // stay valid. text: `% search: greedy serial-SGS (in-process; not a MiniZinc construct)`, }), doc: { nl: "Greedy serial schedule-generation scheme: topological order, earliest feasible placement per task. Deterministic, single schedule per run.", pseudocode: "for task in topo order: place at earliest day satisfying precedence + caps", }, };