Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: mark overturned goal-fidelity findings (#7694)

[._.]/ Adam Eivy03908e3409c5
diff --git a/client/src/components/cos/tabs/AgentCard.jsx b/client/src/components/cos/tabs/AgentCard.jsx
index 3921848183..e165e9b7cd 100644
--- a/client/src/components/cos/tabs/AgentCard.jsx
+++ b/client/src/components/cos/tabs/AgentCard.jsx
@@ -208,11 +208,15 @@ function InvestigateFindingsButton({ agent }) {
function GoalFidelityPanel({ review }) {
const tone = GOAL_FIDELITY_TONE[review?.verdict];
if (!tone) return null;
+ const overturned = review.overturned;
+ const presentation = overturned
+ ? { border: 'border-port-success/30', text: 'text-port-success', label: 'Overturned' }
+ : tone;
return (
- <div className={`mt-2 bg-port-bg/50 border rounded p-2.5 ${tone.border}`}>
- <div className={`text-[11px] flex flex-wrap items-center gap-1 ${tone.text}`}>
+ <div className={`mt-2 bg-port-bg/50 border rounded p-2.5 ${presentation.border}`}>
+ <div className={`text-[11px] flex flex-wrap items-center gap-1 ${presentation.text}`}>
<Target size={10} aria-hidden="true" />
- Goal fidelity: {tone.label}
+ Goal fidelity: {presentation.label}
<span className="min-w-0 [overflow-wrap:anywhere] text-gray-500">
{/* A forge-established verdict has no reviewer model and read no diff —
say where it came from rather than leaving the reader to assume a
@@ -221,6 +225,11 @@ function GoalFidelityPanel({ review }) {
{review.model ? ` · ${review.model}` : ''}{review.diffTruncated ? ' · partial diff' : ''})
</span>
</div>
+ {overturned && (
+ <p className="mt-1.5 text-xs text-gray-400">
+ Overturned after investigation · context gap: {overturned.gap}
+ </p>
+ )}
{review.missing?.length > 0 && (
<div className="mt-1.5 text-xs text-gray-400">
<span className="text-gray-500">Asked for but missing:</span>
@@ -1036,7 +1045,8 @@ export default function AgentCard({ agent, onPause, onKill, onDelete, onResume,
panel above links the one that exists instead. That holds for a task
HELD for approval too: the answer there is to approve the task that
exists, not to queue an unheld duplicate beside it. */}
- {completed && !remote && !agent.result?.goalFidelity?.followUp?.taskId
+ {completed && !remote && !agent.result?.goalFidelity?.overturned
+ && !agent.result?.goalFidelity?.followUp?.taskId
&& ['fix-first', 'rethink'].includes(agent.result?.goalFidelity?.verdict) && (
<InvestigateFindingsButton key={agent.id} agent={agent} />
)}
diff --git a/client/src/components/cos/tabs/AgentCard.test.jsx b/client/src/components/cos/tabs/AgentCard.test.jsx
index dbd3929e00..e78aa939dd 100644
--- a/client/src/components/cos/tabs/AgentCard.test.jsx
+++ b/client/src/components/cos/tabs/AgentCard.test.jsx
@@ -787,6 +787,26 @@ describe('AgentCard goal fidelity', () => {
expect(screen.getByText('no tests were run')).toBeInTheDocument();
});
+ it('shows an overturned verdict with its context gap and hides the investigation action', () => {
+ render(
+ <MemoryRouter>
+ <AgentCard agent={withReview({
+ verdict: 'rethink',
+ missing: ['the retry backoff'],
+ overturned: {
+ gap: 'work-outside-diff',
+ calibrationTaskId: 'calib-1',
+ at: '2026-09-19T10:00:00.000Z',
+ },
+ })} completed />
+ </MemoryRouter>
+ );
+
+ expect(screen.getByText('Goal fidelity:', { exact: false })).toHaveTextContent('Overturned');
+ expect(screen.getByText(/context gap: work-outside-diff/)).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'Investigate findings' })).not.toBeInTheDocument();
+ });
+
// #7690: the automatic follow-up — the finding's durable half. What it did
// belongs beside the verdict, or a filed issue is unreachable from the card
// that reported the problem.
diff --git a/server/services/goalFidelityCalibration.js b/server/services/goalFidelityCalibration.js
index 07459e7b86..a2e08b4b10 100644
--- a/server/services/goalFidelityCalibration.js
+++ b/server/services/goalFidelityCalibration.js
@@ -34,16 +34,14 @@
* - Nothing here can fail a run or a request beyond its own result. The caller
* reports what happened and moves on.
*
- * Still open: the overturn is not written back onto the run record, so the agent
- * card keeps rendering the disproved verdict and keeps offering to investigate
- * it. Tracked in #7694, which spans the client surface and a task→agent lookup
- * a report does not currently carry.
*/
import { updateTask } from './cos.js';
+import { getAgents, updateAgent } from './cosAgentLifecycle.js';
import { getSettings } from './settings.js';
import { fileInvestigationTask } from './investigationTaskProducer.js';
import { SUPERVISED_INVESTIGATION_DELIVERY, investigationOutcome } from '../lib/investigationTasks.js';
+import { isPlainObject } from '../lib/objects.js';
import {
GOAL_FIDELITY_CONTEXT_GAPS,
buildGoalFidelityCalibrationTask,
@@ -138,9 +136,44 @@ export async function reportGoalFidelityFalsePositive({ gap, detail, evidence, f
const outcome = investigationOutcome(filed, { subject: 'the calibration task' });
if (outcome.duplicate) await unionAffectedRun(filed.task, taskId);
+ if (outcome.queued) await stampOverturnedRuns(taskId, resolvedGap, outcome.taskId);
return report({ gap: resolvedGap, fingerprint: calibrationFingerprint, ...outcome });
}
+/**
+ * Mark every retained run for the reported task without rewriting the reviewer's
+ * verdict. A task can have more than one agent attempt, and each card needs to
+ * stop presenting the disproved finding as current.
+ *
+ * Best-effort like the calibration-task union below: the calibration already
+ * exists at this point, so a stale/missing run record must not turn a successful
+ * report into an HTTP failure.
+ */
+async function stampOverturnedRuns(taskId, gap, calibrationTaskId) {
+ if (!taskId || !calibrationTaskId) return;
+ const agents = await getAgents().catch((err) => {
+ console.error(`❌ goal-fidelity calibration: could not resolve runs for ${taskId}: ${err.message}`);
+ return [];
+ });
+ const matches = agents.filter(agent => agent.taskId === taskId || agent.metadata?.taskId === taskId);
+ const at = new Date().toISOString();
+ await Promise.all(matches.map((agent) => {
+ const result = isPlainObject(agent.result) ? agent.result : {};
+ const goalFidelity = isPlainObject(result.goalFidelity) ? result.goalFidelity : {};
+ return updateAgent(agent.id, {
+ result: {
+ ...result,
+ goalFidelity: {
+ ...goalFidelity,
+ overturned: { gap, calibrationTaskId, at },
+ },
+ },
+ }).catch((err) => {
+ console.error(`❌ goal-fidelity calibration: could not stamp run ${agent.id}: ${err.message}`);
+ });
+ }));
+}
+
/**
* Fold a repeat report's run into the calibration that already tracks this gap.
*
diff --git a/server/services/goalFidelityCalibration.test.js b/server/services/goalFidelityCalibration.test.js
index 5629555301..840e3a1075 100644
--- a/server/services/goalFidelityCalibration.test.js
+++ b/server/services/goalFidelityCalibration.test.js
@@ -22,8 +22,11 @@ import { describe, it, expect, beforeEach, vi } from 'vitest';
const getSettings = vi.fn();
const fileInvestigationTask = vi.fn();
const updateTask = vi.fn();
+const getAgents = vi.fn();
+const updateAgent = vi.fn();
vi.mock('./cos.js', () => ({ updateTask }));
+vi.mock('./cosAgentLifecycle.js', () => ({ getAgents, updateAgent }));
vi.mock('./settings.js', () => ({ getSettings }));
vi.mock('./investigationTaskProducer.js', () => ({ fileInvestigationTask }));
@@ -46,6 +49,8 @@ const filed = () => ({ args: fileInvestigationTask.mock.calls[0][0], opts: fileI
beforeEach(() => {
vi.clearAllMocks();
getSettings.mockResolvedValue({ codeReview: { goalFidelity: { enabled: true } } });
+ getAgents.mockResolvedValue([]);
+ updateAgent.mockResolvedValue({});
updateTask.mockResolvedValue({});
fileInvestigationTask.mockResolvedValue({ task: { id: 'calib-1' }, approvalRequired: false, loopReason: null });
});
@@ -75,6 +80,33 @@ describe('reportGoalFidelityFalsePositive', () => {
expect(filed().args.affectedTasks).toEqual(['task-7']);
});
+ it('stamps every matching run when the calibration was queued without rewriting its verdict', async () => {
+ getAgents.mockResolvedValue([
+ { id: 'agent-1', taskId: 'task-7', result: { success: false, goalFidelity: { verdict: 'rethink', evidence: 'partial diff' } } },
+ { id: 'agent-2', metadata: { taskId: 'task-7' }, result: { goalFidelity: { verdict: 'fix-first' } } },
+ { id: 'agent-other', taskId: 'task-8', result: { goalFidelity: { verdict: 'rethink' } } },
+ ]);
+
+ await reportGoalFidelityFalsePositive(REPORT);
+
+ expect(updateAgent).toHaveBeenCalledTimes(2);
+ expect(updateAgent).toHaveBeenCalledWith('agent-1', {
+ result: {
+ success: false,
+ goalFidelity: {
+ verdict: 'rethink',
+ evidence: 'partial diff',
+ overturned: {
+ gap: 'work-outside-diff',
+ calibrationTaskId: 'calib-1',
+ at: expect.any(String),
+ },
+ },
+ },
+ });
+ expect(updateAgent.mock.calls[1][1].result.goalFidelity.verdict).toBe('fix-first');
+ });
+
it('sends no affected tasks when the report named no run', async () => {
await reportGoalFidelityFalsePositive({ gap: 'rubric-gap' });
expect(filed().args.affectedTasks).toEqual([]);
@@ -105,6 +137,8 @@ describe('reportGoalFidelityFalsePositive', () => {
expect(result.queued).toBe(false);
expect(result.reason).toMatch(/disabled/);
expect(fileInvestigationTask).not.toHaveBeenCalled();
+ expect(getAgents).not.toHaveBeenCalled();
+ expect(updateAgent).not.toHaveBeenCalled();
});
it('runs on an install that configured nothing, since the gate defaults on', async () => {