// Release — Constraint block. // // The task may not start before `earliestStart` (a day index in the // resolved calendar frame) — material arrival, permit dates, or frozen // in-progress work compiled down from a re-leveling run. // // MiniZinc compile contract: harness supplies `start_day[t]`. import { z } from "zod"; import type { ReleaseConstraint } from "../level-core/types.ts"; import type { ConstraintBlock, MiniZincFragment } from "./types.ts"; export const ReleaseInputSchema = z.object({ taskUniqueId: z.number().int(), earliestStart: z.number().int().nonnegative(), }); export type ReleaseInput = z.infer; const ReleaseOutputSchema: z.ZodType = z.object({ kind: z.literal("Release"), taskUniqueId: z.number().int(), earliestStart: z.number().int().nonnegative(), }); export const ReleaseBlock: ConstraintBlock = { id: "Release", schema: { input: ReleaseInputSchema, output: ReleaseOutputSchema }, apply: ({ taskUniqueId, earliestStart }): ReleaseConstraint => ({ kind: "Release", taskUniqueId, earliestStart, }), toMiniZinc: ({ taskUniqueId, earliestStart }): MiniZincFragment => ({ text: `constraint start_day[${String(taskUniqueId)}] >= ${String(earliestStart)};`, }), doc: { nl: "The task may not start before the given day index.", pseudocode: "start(task) >= earliestStart", }, };