Skip to content

Eval And Repair Contract

Eval results are deterministic feedback for agents. They should be path-rich and directly repairable.

interface EvalFinding {
rule: string;
targetId?: string;
targetPath: string;
groupPath?: string;
severity: "hard" | "soft" | "info";
message?: string;
actual?: unknown;
required?: unknown;
requiredMin?: unknown;
requiredMax?: unknown;
unit?: string;
repairHints?: RepairHint[];
}
SeverityMeaning
hardCandidate should not be committed as valid
softCandidate is usable but lower scoring or needs review
infoInformational metric, trace, or warning
FieldPurpose
targetPathExact entity, property, metric, or generated object that failed
groupPathSemantic group that owns the rule or constraint
targetIdStable ID if available

Example:

{
"rule": "planning.setback_distance",
"targetPath": "site.main.envelopes.primary.faces.front",
"groupPath": "site.main.parcels.pcl_001.constraints.setbacks.front",
"severity": "hard",
"actual": "4200mm",
"requiredMin": "5000mm"
}
interface RepairHint {
kind: "operationSuggestion" | "paramAdjustment" | "deleteOrReplace" | "manualReview";
op?: string;
targetPath?: string;
params?: Record<string, unknown>;
rationale?: string;
}
{
"kind": "operationSuggestion",
"op": "fitMassingToEnvelope",
"targetPath": "buildings.b_001",
"params": {
"envelope": "site.main.envelopes.primary",
"allowedMoves": ["shrink_footprint"]
},
"rationale": "The building footprint exceeds the front setback-derived envelope."
}
const result = await branch.evaluate(patch, {
scope: "affected",
tiers: [0, 1, 2, 3],
returnRepairHints: true
});
if (!result.valid) {
const repairPatch = result.findings.flatMap((finding) => finding.repairHints ?? []);
await branch.applyPatch(repairPatch);
}