fix(evals): bind routine history grading to observed provider

This commit is contained in:
Dotta committed 2026-10-28 00:47:54 -05:00
1 parent 765dd51e0f
commit 78783dda57
2 files changed
+19 -1

No files matched your search

@@ -19,6 +19,23 @@ describe("routine invocation and native failure distinction", () => {
const missing = valid(); missing.state.failedEvents = [];
expect(gradeIntegratorRoutineHistory(missing).passed).toBe(false);
});
it("accepts actual OpenCode failure history instead of defaulting its provider to Codex", () => {
const o = valid();
o.state.failedRun.runnerProfileJson.nativeExecutionInput.provider.kind = "opencode";
o.runs[0] = structuredClone(o.state.failedRun);
expect(gradeIntegratorRoutineHistory(o).passed).toBe(true);
const wrongProvider = structuredClone(o);
wrongProvider.state.failedRun.runnerProfileJson.nativeExecutionInput.provider.kind = "codex";
expect(gradeIntegratorRoutineHistory(wrongProvider).passed).toBe(false);
const missingProvider = structuredClone(o);
missingProvider.state.failedRun.runnerProfileJson.nativeExecutionInput.provider.kind = "";
expect(gradeIntegratorRoutineHistory(missingProvider).passed).toBe(false);
const wrongModel = structuredClone(o);
wrongModel.state.failedRun.runnerProfileJson.nativeExecutionInput.provider.model = "supported-model";
expect(gradeIntegratorRoutineHistory(wrongModel).passed).toBe(false);
const noTerminal = structuredClone(o); noTerminal.state.failedEvents = [];
expect(gradeIntegratorRoutineHistory(noTerminal).passed).toBe(false);
});
it("rejects preflight or cancellation substituted for an admitted native failure", () => {
const cancelled = valid(); cancelled.runs[0]!.status = "cancelled";
expect(gradeIntegratorRoutineHistory(cancelled).passed).toBe(false);
@@ -27,8 +27,9 @@ export function gradeIntegratorRoutineHistory(value: unknown) {
const failedInvocation = o.executions.find(run => run.id === o.state.failedInvocationId); const completedInvocation = o.executions.find(run => run.id === o.state.completedInvocationId);
const failed = o.runs.find(run => run.id === (o.state.failedRun as { id?: string } | undefined)?.id);
const failureEvidence = o.state.failedRun as Parameters<typeof admittedModelFailure>[0]["run"];
const provider = (failed as typeof failureEvidence)?.runnerProfileJson?.nativeExecutionInput?.provider?.kind;
c.add("genuine-task-bound-native-failure", !!failedTask && failed?.status === "failed" && failed.runtimeMode === "native" && !!failedInvocation && failedInvocation.linkedIssueId === failedTask.id
&& admittedModelFailure({ run: failureEvidence, events: o.state.failedEvents as Parameters<typeof admittedModelFailure>[0]["events"] ?? [], companyId: o.companyId, agentId: (o.state.worker as Entity | undefined)?.id ?? "", issueId: failedTask.id, model: String(o.state.failedModel) }), "The failure is a genuinely admitted task-bound unavailable-model native execution, never a rejected HTTP request or a patched/cancelled status.");
&& (provider === "codex" || provider === "opencode") && admittedModelFailure({ provider, run: failureEvidence, events: o.state.failedEvents as Parameters<typeof admittedModelFailure>[0]["events"] ?? [], companyId: o.companyId, agentId: (o.state.worker as Entity | undefined)?.id ?? "", issueId: failedTask.id, model: String(o.state.failedModel) }), "The failure is a genuinely admitted task-bound unavailable-model native execution, never a rejected HTTP request or a patched/cancelled status.");
c.add("separate-real-successful-invocation", !!completedTask && completedTask.status === "done" && completedInvocation?.status === "completed" && completedInvocation.linkedIssueId === completedTask.id
&& completedTask.id !== failedTask?.id && o.runs.some(run => run.id === o.state.completedNativeRunId && run.status === "succeeded" && run.runtimeMode === "native" && run.contextSnapshot?.issueId === completedTask.id), "A second independently invoked routine actually completed its normal task under a successful native run.");
const start = Number(o.state.weekStart), end = Number(o.state.weekEnd);