feat(activity): surface the cross-model verification verdict (the moat, made visible)

The definition-of-done stop-gate already has a DIFFERENT model lineage
(gpt-oss-120b) judge each worker's handoff — the verification a single-agent
runtime structurally cannot do (its judge would be itself). But the verdict was
invisible: it only downgraded the outcome and buried the gap in `next`. Now the
run records who judged and what they caught, and Activity shows it:
"✓/✗ Cross-model check — <worker> did it, <judge> verified/flagged …".

- contract: OrchestrationTaskSummary gains a structured `verification`
  {judge, worker, met, gap}, written by the DoD gate at close.
- control: gateAndCloseRun stamps the verdict onto the run summary (worker
  adapter threaded from the run).
- digests: buildRunTimeline renders the verdict line in the Activity stream.
- dod-gate: export DOD_JUDGE_MODEL; FIX — summaryForJudge now passes `commit`
  to the judge. DoDs say "committed"/"shipped", so without it the judge
  false-negatived a fully-evidenced handoff for "no commit evidence"
  (verified live against gpt-oss: the fix flips that case to met).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mao NakamotoandClaude Opus 4.8 committed 2026-07-13 15:47:07 +02:00
1 parent 59153f9beb
commit 928df7b2a9
5 files changed
+52 -5

No files matched your search

+13 -3
View File
@@ -31,7 +31,7 @@ import {
} from "@/lib/orchestration/derive-project-lifecycle";
import { adapterFor } from "@/lib/orchestration/adapter-registry";
import { getProjectGoalConfig } from "@/db/queries/project-context";
import { verifyDefinitionOfDone, applyDoDGate } from "@/lib/orchestration/dod-gate";
import { verifyDefinitionOfDone, applyDoDGate, DOD_JUDGE_MODEL } from "@/lib/orchestration/dod-gate";
import type { RunClosePatch } from "@/lib/orchestration/close-from-session";
import type { OrchestrationOutcome } from "@/db/schema/orchestration-runs";
@@ -46,7 +46,7 @@ const closingRuns = new Set<string>();
* the run closes "partial" with the gap as `next`, so autopilot's continue-loop
* keeps working instead of stopping on the agent's own say-so (the /goal pattern).
*/
async function gateAndCloseRun(runId: string, closePatch: RunClosePatch, userId: string, projectKey: string, recentOutcomes: OrchestrationOutcome[] = []): Promise<void> {
async function gateAndCloseRun(runId: string, closePatch: RunClosePatch, userId: string, projectKey: string, recentOutcomes: OrchestrationOutcome[] = [], workerAdapter = "agent"): Promise<void> {
let patch = closePatch;
if (closePatch.outcome === "success") {
const { definitionOfDone: dod, maxTurns } = await getProjectGoalConfig(userId, projectKey).catch(() => ({ definitionOfDone: null, maxTurns: null }));
@@ -57,6 +57,16 @@ async function gateAndCloseRun(runId: string, closePatch: RunClosePatch, userId:
let priorPartials = 0;
for (const o of recentOutcomes) { if (o === "partial") priorPartials++; else break; }
patch = applyDoDGate(closePatch, verdict, { maxTurns, priorPartials });
// Record the cross-model verdict on the run so Activity can show that a
// DIFFERENT model lineage judged the worker's handoff — the moat made
// visible ("worker did it, judge checked it, here's the verdict").
patch = {
...patch,
summary: {
...patch.summary,
verification: { judge: DOD_JUDGE_MODEL, worker: workerAdapter, met: verdict.met, gap: verdict.gap || undefined },
},
};
}
}
await updateOrchestrationRun(runId, patch, userId);
@@ -310,7 +320,7 @@ export async function GET() {
// more than once for the same run.
if (closePatch && !closingRuns.has(latestRun.id)) {
closingRuns.add(latestRun.id);
gateAndCloseRun(latestRun.id, closePatch, ownerUserId, tab, recentOutcomesMap.get(tab) ?? [])
gateAndCloseRun(latestRun.id, closePatch, ownerUserId, tab, recentOutcomesMap.get(tab) ?? [], latestRun.adapter)
.catch((err) => console.error("[control] run close failed:", err))
.finally(() => closingRuns.delete(latestRun.id));
}
+14
View File
@@ -376,6 +376,20 @@ function buildRunTimeline(runs: RunRow[], blockedReasons: Map<string, string>):
const err = rawErr.length > 160 ? `${rawErr.slice(0, 157)}…` : rawErr;
const parts: string[] = [];
if (done) parts.push(done);
// Cross-model verdict — the moat made visible. When a project declares a
// definition_of_done, a DIFFERENT model lineage judged this worker's handoff
// (see dod-gate.ts). Surface WHO judged and WHAT they caught, so "done"
// demonstrably means a second mind agreed — not the agent grading itself.
const v = run.summary?.verification;
if (v) {
const judge = v.judge.includes("/") ? v.judge.split("/").pop() : v.judge;
const worker = getAdapterLabel(run.adapter);
parts.push(
v.met
? `✓ Cross-model check — ${worker} did it, ${judge} verified the definition of done is met`
: `✗ Cross-model check — ${worker} did it, ${judge} found the definition of done NOT met${v.gap ? `: ${v.gap}` : ""}`,
);
}
if (next) parts.push(`Next: ${next}`);
if (!parts.length && run.payload?.resultText) parts.push(run.payload.resultText);
if (err) parts.push(`Error: ${err}`);
+11
View File
@@ -146,6 +146,17 @@ export type OrchestrationTaskSummary = {
commit?: string;
"block-reason"?: string;
"no-op-count"?: string;
/** Cross-model definition-of-done verdict — written by the DoD stop-gate at
* close when the project declares a definition_of_done. Records that a
* DIFFERENT model lineage judged the worker's own handoff (the verification a
* single-agent runtime structurally cannot do — its judge would be itself).
* Surfaced in Activity so "done" visibly means a second mind agreed. */
verification?: {
judge: string; // the judging model (different lineage from the worker)
worker: string; // the adapter that did the work
met: boolean; // did the handoff evidence the stated Definition of Done?
gap?: string; // when not met, the single most important thing still required
};
};
export type OrchestrationTaskStatus = {
+9 -1
View File
@@ -17,7 +17,11 @@ import { callGroqText } from "@/lib/groq";
import type { RunClosePatch } from "./close-from-session";
import type { OrchestrationTaskSummary } from "./contract";
const JUDGE_MODEL = "openai/gpt-oss-120b"; // different lineage from the worker
/** The default cross-model judge — a different lineage from the workers
* (claude/llama/grok), so its blind spots don't overlap theirs. Exported so the
* close path can record WHO judged in the run's surfaced verdict. */
export const DOD_JUDGE_MODEL = "openai/gpt-oss-120b";
const JUDGE_MODEL = DOD_JUDGE_MODEL; // different lineage from the worker
export type DoDVerdict = { met: boolean; gap: string };
@@ -34,6 +38,10 @@ function summaryForJudge(s: OrchestrationTaskSummary): string {
["tests", "Tests"],
["tsc", "Typecheck"],
["lint", "Lint"],
// The resulting HEAD sha (or "none"). DoDs routinely say "committed"/"shipped",
// so the judge must SEE whether the agent actually committed — without this it
// false-negatives a fully-evidenced handoff for "no commit evidence".
["commit", "Commit (resulting HEAD sha, or 'none' if no commit)"],
["health", "Health"],
["next", "Agent's stated next step"],
];
+5 -1
View File
@@ -14,9 +14,13 @@ import {
export function buildOrchestrationSummary(
fields: Partial<Record<OrchestrationTaskSummaryField, string | undefined>>,
): OrchestrationTaskSummary {
// Object.fromEntries infers a string-record; the summary also has the optional
// structured `verification` field (absent here — set only by the DoD gate at
// close), so cast through unknown. Every required text field is present via the
// SSOT field list above.
return Object.fromEntries(
ORCHESTRATION_TASK_SUMMARY_FIELDS.map((field) => [field, fields[field] ?? ""]),
) as OrchestrationTaskSummary;
) as unknown as OrchestrationTaskSummary;
}
export function parseOrchestrationSummary(text: string | undefined): OrchestrationTaskSummary | undefined {