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

address review (codex+claude): broaden coordinator exemption + harden migration against backfill

[._.]/ Adam Eivyf233258c386c
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 6c3bf5fcb8..6b2744a0cc 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -48,7 +48,7 @@
## Fixed
-- [issue-2696] **The branch-reconcile and issue-reconcile background jobs no longer report a permanent 0% success rate.** These coordinators finish your in-flight work by driving git and GitHub directly — opening and merging PRs, resolving conflicts, healing stuck issue labels — so they deliberately never make a `task-…` commit of their own. But the success check only knew how to look for that commit, so it scored every *successful* run as a failure and pinned both task types at 0% on the CoS Learning card (and steered the self-improvement loop away from them on evidence that was never true). They're now judged the same way pipeline and media jobs already were — by whether the run itself succeeded — and a one-time migration clears the mis-recorded history on upgrade so the rate reflects reality from here on. This is the same measurement bug already fixed for the Layered Intelligence reasoning run; the accessibility audit, which genuinely does commit its fixes, is unaffected and still judged on its commit.
+- [issue-2696] **Background jobs that finish your work through git/GitHub/Jira instead of a commit no longer report a permanent 0% success rate.** The branch-reconcile, issue-reconcile, branch-cleanup, and Jira status-report jobs deliver their result as a side effect — a merged PR, a resolved conflict, a deleted branch, a posted report — so they deliberately never make a `task-…` commit of their own. But the success check only knew how to look for that commit, so it scored every *successful* run as a failure and pinned those task types at 0% on the CoS Learning card (which in turn steered the self-improvement loop away from them on evidence that was never true). They're now judged the same way pipeline and media jobs already were — by whether the run itself succeeded — and a one-time migration clears the mis-recorded history on upgrade (and the "Backfill History" button no longer re-poisons it from the old records). This is the same measurement bug already fixed for the Layered Intelligence reasoning run; jobs that genuinely do commit their work — the accessibility audit, the Jira sprint manager, the PLAN.md replan — are unaffected and still judged on their commit, so a real failure there is never masked.
- [issue-2737] **An unattended background AI job that hits a failing provider no longer buries you in a stack of red error toasts.** Jobs that run without you watching — like the weekly goal check-in, which makes one AI call per goal at once — used to fire a separate red error toast for *every* failed call when a provider was down (an expired key, a dead endpoint, a model returning nothing). A seven-goal check-in against a broken provider meant seven stacked toasts you never saw coming. Those background failures now collapse into a single toast per provider that counts them ("Example Provider failed on 5 background AI calls"), with the first one still showing the provider's real reason. AI actions *you* triggered are unchanged: they still report their failure the instant it happens, one toast each, with the provider's actual error — so a failure you're waiting on is never aggregated away.
diff --git a/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.js b/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.js
index c98839ab23..c1eb800667 100644
--- a/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.js
+++ b/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.js
@@ -47,14 +47,16 @@ import { readFile, writeFile } from 'fs/promises';
import { join } from 'path';
import { removeTaskTypeFromLearningData } from '../../server/services/taskLearning/metrics.js';
+import { NON_COMMITTING_COORDINATOR_TASK_TYPES } from '../../server/services/taskTypeHooks.js';
const LEARNING_REL = 'data/cos/learning.json';
// The keys the coordinator runs are recorded under. A scheduled coordinator task carries
// `metadata.analysisType = '<type>'`, and extractTaskType's first branch prefixes any such
// task into `self-improve:<type>` — so these, not the bare schedule names, are the poisoned
-// buckets. Mirrors NON_COMMITTING_COORDINATOR_TASK_TYPES in agentLifecycle.js.
-const COORDINATOR_BUCKETS = ['self-improve:branch-reconcile', 'self-improve:issue-reconcile'];
+// buckets. Derived from NON_COMMITTING_COORDINATOR_TASK_TYPES (the runtime source of truth)
+// so a new coordinator type added there is automatically healed on upgrade — the two can't drift.
+const COORDINATOR_BUCKETS = [...NON_COMMITTING_COORDINATOR_TASK_TYPES].map((t) => `self-improve:${t}`);
export default {
async up({ rootDir }) {
diff --git a/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.test.js b/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.test.js
index 55a1465727..1d3640dce5 100644
--- a/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.test.js
+++ b/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.test.js
@@ -44,6 +44,24 @@ describe('198-purge-poisoned-coordinator-learning-buckets (#2696)', () => {
expect(data.byTaskType['self-improve:accessibility'].successRate).toBe(80);
});
+ it('purges ALL four coordinator buckets and leaves committing types alone', async () => {
+ await seed({
+ byTaskType: {
+ 'self-improve:branch-reconcile': { completed: 2, succeeded: 0, failed: 2, successRate: 0 },
+ 'self-improve:issue-reconcile': { completed: 2, succeeded: 0, failed: 2, successRate: 0 },
+ 'self-improve:branch-cleanup': { completed: 3, succeeded: 0, failed: 3, successRate: 0 },
+ 'self-improve:jira-status-report': { completed: 1, succeeded: 0, failed: 1, successRate: 0 },
+ // These COMMIT — their bucket is legitimate and must survive.
+ 'self-improve:jira-sprint-manager': { completed: 4, succeeded: 3, failed: 1, successRate: 75 },
+ 'self-improve:accessibility': { completed: 5, succeeded: 4, failed: 1, successRate: 80 }
+ }
+ });
+ const out = await migration.up({ rootDir });
+ expect(out.purged).toBe(8);
+ const data = await readLearning();
+ expect(Object.keys(data.byTaskType).sort()).toEqual(['self-improve:accessibility', 'self-improve:jira-sprint-manager']);
+ });
+
it('purges just the one coordinator bucket present when the other never ran', async () => {
await seed({
byTaskType: {
diff --git a/server/services/agentLifecycle.js b/server/services/agentLifecycle.js
index 55f53985f3..db39028fa8 100644
--- a/server/services/agentLifecycle.js
+++ b/server/services/agentLifecycle.js
@@ -21,7 +21,7 @@ import { createToolExecution, startExecution, completeExecution, errorExecution
import { determineLane, acquire, release } from './executionLanes.js';
import { analyzeAgentFailure, resolveFailedTaskUpdate, resolveTypeFailureSignal } from './agentErrorAnalysis.js';
import { createAgentRun, completeAgentRun, checkForTaskCommit } from './agentRunTracking.js';
-import { isProgrammaticIoTaskType, resolveTaskHookType } from './taskTypeHooks.js';
+import { isProgrammaticIoTaskType, resolveTaskHookType, NON_COMMITTING_COORDINATOR_TASK_TYPES } from './taskTypeHooks.js';
import { buildAgentPrompt, getAppWorkspace } from './agentPromptBuilder.js';
import { isOllamaClaudeProvider, isClaudeCommand, providerSuppliesGithubToken } from '../lib/providerModels.js';
import { buildOpencodeEnvVars } from '../lib/opencodeConfig.js';
@@ -805,18 +805,6 @@ export function releaseAgentLane({ agentId, success, duration, exitCode, executi
}
}
-// Scheduled COORDINATOR task types whose deliverable is a git/gh side effect (a merged
-// PR, a resolved conflict, healed issue state), NOT a `[task-<id>]` commit. Their
-// coordinator runs in the app's LIVE checkout with useWorktree/openPR locked off (see
-// taskSchedule.js MANAGED_AGENT_OPTIONS), so the `[task-<id>]` commit criterion in
-// evaluateSuccessCriteria would score every SUCCESSFUL run as a failure and poison their
-// learning bucket to ~0% (#2696). Kept as an explicit allow-list — NOT every
-// MANAGED_AGENT_OPTIONS type — because plan-task / claim-issue / claim-work also lock
-// worktree/PR off yet DO commit (they run the /claim flow in their own worktree), so their
-// commit criterion is real and must stay. Mirrored by migration 198, which purges the
-// buckets these already poisoned on existing installs.
-const NON_COMMITTING_COORDINATOR_TASK_TYPES = new Set(['branch-reconcile', 'issue-reconcile']);
-
/**
* Evaluate a completed autonomous run against its DECLARED success criteria
* (issue #2344). Distinct from the runner's exit-code `success`: it answers
@@ -868,15 +856,15 @@ export async function evaluateSuccessCriteria({ task, terminatedByUser, workspac
// tasks they register no output hook, so there is no deliverable signal to
// judge them by — they stay exit-code-judged (unchanged by #2727).
if (task?.metadata?.pipeline || task?.metadata?.mediaJob) return null;
- // gh/git COORDINATOR task types deliver their work through git+gh operations in
- // the app's live checkout — opening/merging PRs, resolving conflicts, healing
- // issue state — and by design NEVER produce a `[task-<id>]` commit (useWorktree/
- // openPR are locked off, see taskSchedule.js MANAGED_AGENT_OPTIONS). Because their
- // workspacePath IS set (the live checkout), the commit check above would return
- // false on every SUCCESSFUL run and drive their learning bucket to ~0% (#2696) —
- // the same artifact #2700 fixed for the programmatic-I/O reasoning run. They
- // register no output hook, so like pipeline/media jobs there is no deliverable
- // signal to judge them by; fall back to the exit code (null = criterion undeclared).
+ // gh/git/external COORDINATOR task types (NON_COMMITTING_COORDINATOR_TASK_TYPES in
+ // taskTypeHooks.js — branch-reconcile/issue-reconcile/branch-cleanup/jira-status-report)
+ // deliver their work as a side effect — a merged PR, a resolved conflict, a deleted
+ // branch, a posted report — and by design NEVER produce a `[task-<id>]` commit. Because
+ // their workspacePath IS set (the app's live checkout), the commit check above would
+ // return false on every SUCCESSFUL run and drive their learning bucket to ~0% (#2696) —
+ // the same artifact #2700 fixed for the programmatic-I/O reasoning run. They register no
+ // output hook, so like pipeline/media jobs there is no deliverable signal to judge them
+ // by; fall back to the exit code (null = criterion undeclared).
if (NON_COMMITTING_COORDINATOR_TASK_TYPES.has(scheduledType)) return null;
return await checkForTaskCommit(task.id, workspacePath);
}
diff --git a/server/services/agentLifecycle.successCriteria.test.js b/server/services/agentLifecycle.successCriteria.test.js
index 07959dd249..e211a1b9d7 100644
--- a/server/services/agentLifecycle.successCriteria.test.js
+++ b/server/services/agentLifecycle.successCriteria.test.js
@@ -269,16 +269,25 @@ describe('evaluateSuccessCriteria — commit criterion (#2344)', () => {
describe('evaluateSuccessCriteria — gh/git coordinator exemption (#2696)', () => {
beforeEach(() => vi.clearAllMocks());
- it('declares NO commit criterion for a branch-reconcile coordinator run', async () => {
- const task = { id: 't1', taskType: 'internal', metadata: { analysisType: 'branch-reconcile' } };
- expect(await evaluateSuccessCriteria({ task, workspacePath: '/w', success: true })).toBeNull();
+ it('declares NO commit criterion for every non-committing coordinator type', async () => {
+ // The structurally-no-commit coordinators: they run in the live checkout and deliver a
+ // git/gh/external side effect, never a [task-<id>] commit.
+ for (const analysisType of ['branch-reconcile', 'issue-reconcile', 'branch-cleanup', 'jira-status-report']) {
+ const task = { id: 't1', taskType: 'internal', metadata: { analysisType } };
+ expect(await evaluateSuccessCriteria({ task, workspacePath: '/w', success: true })).toBeNull();
+ }
expect(checkForTaskCommit).not.toHaveBeenCalled();
});
- it('declares NO commit criterion for an issue-reconcile coordinator run', async () => {
- const task = { id: 't1', taskType: 'internal', metadata: { analysisType: 'issue-reconcile' } };
- expect(await evaluateSuccessCriteria({ task, workspacePath: '/w', success: false })).toBeNull();
- expect(checkForTaskCommit).not.toHaveBeenCalled();
+ it('STILL commit-checks committing self-improve types (jira-sprint-manager, do-replan)', async () => {
+ // jira-sprint-manager commits + opens MRs; do-replan commits PLAN.md edits — their commit
+ // criterion is real, so exempting them would MASK genuine failures. Must stay checked.
+ for (const analysisType of ['jira-sprint-manager', 'do-replan']) {
+ checkForTaskCommit.mockResolvedValueOnce(true);
+ const task = { id: 't1', taskType: 'internal', metadata: { analysisType, selfImprovement: true } };
+ expect(await evaluateSuccessCriteria({ task, workspacePath: '/w', success: true })).toBe(true);
+ }
+ expect(checkForTaskCommit).toHaveBeenCalledTimes(2);
});
it('exempts a coordinator typed on taskType alone, not just metadata.analysisType', async () => {
diff --git a/server/services/taskLearning/lifecycle.js b/server/services/taskLearning/lifecycle.js
index 6e200d5989..57c0b812e5 100644
--- a/server/services/taskLearning/lifecycle.js
+++ b/server/services/taskLearning/lifecycle.js
@@ -9,6 +9,21 @@
import { cosEvents, emitLog } from './store.js';
import { recordTaskCompletion, recalculateModelTierMetrics } from './metrics.js';
+import { isNonCommittingCoordinatorTask } from '../taskTypeHooks.js';
+
+// A pre-#2696 gh/git coordinator run (branch-reconcile/issue-reconcile/branch-cleanup/
+// jira-status-report) carries a FOSSIL `result.validationPassed` — a boolean the old
+// `[task-<id>]` commit criterion stamped on a run that never makes such a commit (almost
+// always `false`). recordTaskCompletion trusts a persisted boolean over the exit code, so
+// re-recording one verbatim would restore the very bucket migration 198 purged. These types
+// now declare NO commit criterion, so drop the fossil and let the exit-code success stand —
+// exactly as finalize now records a live coordinator run. Non-coordinator agents (and those
+// with no boolean verdict) pass through untouched.
+function withoutStaleCoordinatorVerdict(agent, task) {
+ if (!isNonCommittingCoordinatorTask(task)) return agent;
+ if (typeof agent?.result?.validationPassed !== 'boolean') return agent;
+ return { ...agent, result: { ...agent.result, validationPassed: null } };
+}
/**
* Initialize learning system - listen for agent completions
@@ -54,7 +69,7 @@ export async function backfillFromHistory() {
metadata: agent.metadata
};
- await recordTaskCompletion(agent, task).catch(() => {});
+ await recordTaskCompletion(withoutStaleCoordinatorVerdict(agent, task), task).catch(() => {});
backfilled++;
}
}
diff --git a/server/services/taskLearning/lifecycle.test.js b/server/services/taskLearning/lifecycle.test.js
new file mode 100644
index 0000000000..e20370654d
--- /dev/null
+++ b/server/services/taskLearning/lifecycle.test.js
@@ -0,0 +1,64 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+
+// backfillFromHistory (#2696): re-recording a pre-fix gh/git coordinator agent verbatim would
+// restore the very learning bucket migration 198 purged, because those agents carry a fossil
+// `result.validationPassed:false` stamped by the old commit criterion and recordTaskCompletion
+// trusts a persisted boolean over the exit code. The backfill must strip that fossil for
+// coordinator types (and only those) so the exit-code success stands.
+
+const agentsStore = vi.hoisted(() => ({ list: [] }));
+
+vi.mock('./metrics.js', () => ({
+ recordTaskCompletion: vi.fn(async () => {}),
+ recalculateModelTierMetrics: vi.fn(async () => {}),
+}));
+vi.mock('./store.js', () => ({
+ cosEvents: { on: vi.fn() },
+ emitLog: vi.fn(),
+}));
+vi.mock('../cos.js', () => ({ getAgents: vi.fn(async () => agentsStore.list) }));
+
+import { backfillFromHistory } from './lifecycle.js';
+import { recordTaskCompletion } from './metrics.js';
+
+const completed = (taskId, analysisType, validationPassed) => ({
+ status: 'completed',
+ taskId,
+ result: { success: true, duration: 100, validationPassed },
+ metadata: { analysisType, taskType: 'internal', taskDescription: taskId },
+});
+
+describe('backfillFromHistory — stale coordinator verdict (#2696)', () => {
+ beforeEach(() => vi.clearAllMocks());
+
+ it('strips a fossil validationPassed:false for a coordinator agent before re-recording', async () => {
+ agentsStore.list = [completed('t1', 'branch-reconcile', false)];
+ await backfillFromHistory();
+ const [agentArg] = recordTaskCompletion.mock.calls[0];
+ // null → recordTaskCompletion falls back to the exit-code success (a true coordinator run),
+ // instead of restoring the 0% bucket the migration just purged.
+ expect(agentArg.result.validationPassed).toBeNull();
+ });
+
+ it('strips the fossil for every coordinator type', async () => {
+ agentsStore.list = ['branch-reconcile', 'issue-reconcile', 'branch-cleanup', 'jira-status-report']
+ .map((t, i) => completed(`t${i}`, t, false));
+ await backfillFromHistory();
+ for (const call of recordTaskCompletion.mock.calls) {
+ expect(call[0].result.validationPassed).toBeNull();
+ }
+ });
+
+ it('passes a committing type through UNTOUCHED — its commit verdict is real', async () => {
+ // accessibility genuinely commits; a persisted false is a real miss, not a fossil.
+ agentsStore.list = [completed('t1', 'accessibility', false)];
+ await backfillFromHistory();
+ expect(recordTaskCompletion.mock.calls[0][0].result.validationPassed).toBe(false);
+ });
+
+ it('leaves a coordinator agent with no boolean verdict untouched (nothing to strip)', async () => {
+ agentsStore.list = [completed('t1', 'branch-cleanup', null)];
+ await backfillFromHistory();
+ expect(recordTaskCompletion.mock.calls[0][0].result.validationPassed).toBeNull();
+ });
+});
diff --git a/server/services/taskTypeHooks.js b/server/services/taskTypeHooks.js
index 261a118d8d..41c9bfec1a 100644
--- a/server/services/taskTypeHooks.js
+++ b/server/services/taskTypeHooks.js
@@ -72,6 +72,38 @@ export function resolveTaskHookType(task) {
return task?.metadata?.analysisType || task?.taskType || null;
}
+/**
+ * Scheduled COORDINATOR task types whose deliverable is a git/gh/external side effect —
+ * a merged PR, a resolved conflict, a deleted branch, healed issue state, a status report
+ * posted to Jira — NOT a `[task-<id>]` commit. Their agent runs in the app's LIVE checkout
+ * (no worktree, no PR), so they DO have a workspacePath at finalize, and the `[task-<id>]`
+ * commit criterion would score every SUCCESSFUL run as a failure and pin their learning
+ * bucket at ~0% (#2696). They declare no commit criterion (fall back to the exit code),
+ * exactly like pipeline/media jobs.
+ *
+ * Deliberately NOT every self-improvement type: accessibility / security / code-quality
+ * / plan-task / claim-issue / claim-work / jira-sprint-manager / do-replan all COMMIT
+ * (fixing tasks, /claim flows, or a triage that commits PLAN.md), so their commit
+ * criterion is real and must stay — exempting them would MASK genuine failures. Only the
+ * structurally-no-commit coordinators belong here. pr-watcher is intentionally excluded:
+ * its prompt is customizable to push code, so exempting it could mask a customized run's
+ * failure. Kept as a leaf so both agentLifecycle (the live criterion) and taskLearning's
+ * history backfill (migration-durability) read ONE source of truth. Migration 198 purges
+ * the buckets these already poisoned on existing installs.
+ */
+export const NON_COMMITTING_COORDINATOR_TASK_TYPES = new Set([
+ 'branch-reconcile', 'issue-reconcile', 'branch-cleanup', 'jira-status-report',
+]);
+
+/**
+ * Whether a task declares NO `[task-<id>]` commit criterion because it is a gh/git
+ * coordinator (see NON_COMMITTING_COORDINATOR_TASK_TYPES). Keyed on the same resolver as
+ * the programmatic-I/O gate so the scheduled type — not the CoS queue category — decides.
+ */
+export function isNonCommittingCoordinatorTask(task) {
+ return NON_COMMITTING_COORDINATOR_TASK_TYPES.has(resolveTaskHookType(task));
+}
+
/**
* Resolve the pre-agent input hook for a task type, or null if it has none.
* `buildTaskInput({ app, taskType })` → `{ prompt?, providerId?, model?, skip? }`.