Something went wrong. Try again.
A functional toolkit for authoring resource-leveling algorithms — compose constraint and scoring blocks, enumerate feasible schedules
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364// Run provenance — the `levelset` metadata block a leveling run embeds in// every materialized ProjectFile (spaCy ships config.cfg + meta.json inside// every model directory; this is the leveling equivalent). Six months// later, "why does floor 3 start in June?" is answerable from the file// itself: which constraints, which weights, which engine version.//// Everything here is plain JSON: configs and results serialize, code never// does. `runConfig` is kept loosely typed at this layer so the schema// package doesn't depend on level-blocks; `runFromConfig` writes a filled// RunConfig into it.
import { z } from "zod";
// Loose objects: a `levelset` block written by a newer levelset version (or// annotated by app tooling) must survive a read → write round trip with its// unknown keys intact, not be silently truncated to this version's fields.export const RunIssueJsonSchema = z.looseObject({ code: z.string(), severity: z.enum(["error", "warning"]), source: z.string(), message: z.string(),});
// Loose for the same forward-compatibility reason as the containing// provenance: a newer engine may add sweep diagnostics an older reader must// preserve.export const SweepProvenanceSchema = z.looseObject({ combinations: z.number().int().nonnegative(), feasibleCells: z.number().int().nonnegative(), winner: z.record(z.string(), z.unknown()), skipped: z.array( z.looseObject({ point: z.record(z.string(), z.unknown()), reason: z.string(), }), ),});export type SweepProvenance = z.infer<typeof SweepProvenanceSchema>;
export const RunProvenanceSchema = z.looseObject({ /** levelset version that produced the schedule. */ levelsetVersion: z.string(), /** ISO timestamp of materialization. */ generatedAt: z.string().optional(), /** Name of the search backend that produced the schedule. */ search: z.string().optional(), /** The *filled* run config (every default expanded) — the reproducible * artifact: rerunning it against the same source project must produce * the same schedule. */ runConfig: z.record(z.string(), z.unknown()).optional(), seed: z.number().int().optional(), /** Raw scorer values achieved, keyed by scorer instanceId. */ scores: z.record(z.string(), z.number()).optional(), /** Static-analysis warnings the run proceeded under. */ warnings: z.array(RunIssueJsonSchema).optional(), /** Schedule annotations (unsupportedConstraints, approximatedRelations, * disabledConstraints, …) carried out of the search. */ annotations: z.record(z.string(), z.unknown()).optional(), /** Parameter-grid execution summary and the selected coordinate. */ sweep: SweepProvenanceSchema.optional(),});
export type RunProvenance = z.infer<typeof RunProvenanceSchema>;