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(issue-2696): exempt gh/git coordinator tasks from the [task-<id>] commit criterion

[._.]/ Adam Eivybf0776f3c2c5
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 5abc15ea48..6c3bf5fcb8 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -48,6 +48,8 @@
## 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-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.
- [issue-2752] **Generating a Character avatar before you've entered your name no longer produces a D&D adventurer.** The Character reframe leaves a fresh install's name and class blank, but clicking "Generate avatar" first still fell back to a fantasy `fantasy portrait of an adventurer, warrior class, D&D character art …` prompt — the exact generic RPG art the reframe moves away from. The avatar fallback is now a human portrait: a blank identity renders a neutral `portrait of a person, photographic, natural lighting …`, and once you've filled in your name (and class) it shapes a photographic portrait from those instead of a fantasy one. Callers that genuinely want a fantasy avatar still pass their own prompt to opt out.
diff --git a/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.js b/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.js
new file mode 100644
index 0000000000..c98839ab23
--- /dev/null
+++ b/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.js
@@ -0,0 +1,106 @@
+/**
+ * Purge the gh/git COORDINATOR learning buckets poisoned by the commit-criterion
+ * bug (#2696) — the branch-reconcile / issue-reconcile analogue of migration 197.
+ *
+ * Background:
+ * branch-reconcile and issue-reconcile are COORDINATOR tasks: their coordinator agent
+ * runs in the app's LIVE checkout (useWorktree/openPR locked off — see taskSchedule.js
+ * MANAGED_AGENT_OPTIONS) and delivers its work through git+gh side effects (a merged PR,
+ * a resolved conflict, healed issue state), NEVER a `[task-<id>]` commit. But
+ * `evaluateSuccessCriteria` only knew one machine-checkable criterion — a `[task-<id>]`
+ * commit — and, because these tasks DO have a workspacePath (the live checkout), fell
+ * through to it. Since a declared verdict OVERRIDES the runner's exit code in
+ * task-learning (`outcomeSuccess` in taskLearning/metrics.js), every correctly executed
+ * coordinator run was recorded as a FAILURE, dragging both buckets to ~0% (the exact
+ * symptom #2696 reports for `self-improve:branch-reconcile`).
+ *
+ * `agentLifecycle.js` now exempts these coordinator task types from the commit criterion
+ * (NON_COMMITTING_COORDINATOR_TASK_TYPES), the same way pipeline/media jobs and the
+ * programmatic-I/O reasoning run already were. But that fix is PROSPECTIVE: an install
+ * that has already run branch-reconcile / issue-reconcile carries buckets whose
+ * `succeeded`/`successRate`/`recentOutcomes` are fabricated failures.
+ *
+ * That stale data is not inert — it feeds the CoS Learning card, routing, duration
+ * estimates, and the #2760 scope-awareness classifier, which would keep steering the
+ * loop away from these scopes on evidence that was never true.
+ *
+ * Approach:
+ * DELETE each bucket rather than repair it — the recorded outcomes cannot be
+ * reconstructed (`validationPassed:false` overwrote the runner's real verdict), so the
+ * truth of each historical run is not on disk. Deleting resets each type to an honest
+ * "no runs recorded yet". Reuses `removeTaskTypeFromLearningData` so the fabricated
+ * failures are unwound from every aggregate they touched (totals, byModelTier,
+ * routingAccuracy, errorPatterns, failureSignatures, correlationWindow), not just
+ * `byTaskType`. Environmental failures (rate-limit/auth/network) are PRESERVED — they
+ * never landed in `byTaskType` and are true regardless of this bug.
+ *
+ * Scoped to the two gh/git coordinator types. NOT accessibility: accessibility's prompt
+ * ends "Test and commit changes" — it is a fixing task that genuinely commits, so its
+ * commit criterion is real and its bucket was never poisoned by this bug. Kept in lockstep
+ * with NON_COMMITTING_COORDINATOR_TASK_TYPES in agentLifecycle.js.
+ *
+ * No-op by construction on installs that never ran these types — the file is only
+ * rewritten when at least one bucket is actually present.
+ */
+
+import { readFile, writeFile } from 'fs/promises';
+import { join } from 'path';
+
+import { removeTaskTypeFromLearningData } from '../../server/services/taskLearning/metrics.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'];
+
+export default {
+ async up({ rootDir }) {
+ const path = join(rootDir, LEARNING_REL);
+ const raw = await readFile(path, 'utf-8').catch((err) => {
+ if (err.code === 'ENOENT') return null;
+ throw err;
+ });
+ if (raw == null) {
+ console.log('✅ Coordinator learning: no learning store — nothing to purge');
+ return { purged: 0, reason: 'no-file' };
+ }
+
+ let data;
+ try {
+ data = JSON.parse(raw);
+ } catch {
+ // A corrupt learning store is not this migration's problem to fix, and rewriting it
+ // would risk destroying recoverable data.
+ console.warn('⚠️ Coordinator learning: store is not valid JSON — skipping');
+ return { purged: 0, reason: 'unparseable' };
+ }
+ if (!data || typeof data !== 'object' || Array.isArray(data)) {
+ console.warn('⚠️ Coordinator learning: store is not an object — skipping');
+ return { purged: 0, reason: 'unexpected-shape' };
+ }
+
+ const byTaskType = data.byTaskType;
+ const present = (byTaskType && typeof byTaskType === 'object' && !Array.isArray(byTaskType))
+ ? COORDINATOR_BUCKETS.filter((b) => Object.hasOwn(byTaskType, b))
+ : [];
+ if (present.length === 0) {
+ console.log('✅ Coordinator learning: no branch-reconcile/issue-reconcile bucket — no changes');
+ return { purged: 0 };
+ }
+
+ // Unwinds each bucket AND its contribution to every other aggregate. The environmental
+ // ledger is intentionally left alone.
+ let purged = 0;
+ for (const bucket of present) {
+ const previous = removeTaskTypeFromLearningData(data, bucket);
+ purged += previous?.completed || 0;
+ }
+
+ await writeFile(path, JSON.stringify(data, null, 2) + '\n');
+ console.log(`🧹 Coordinator learning: purged ${purged} mis-recorded coordinator run(s) across ${present.length} bucket(s) (#2696)`);
+ return { purged, buckets: present };
+ },
+};
diff --git a/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.test.js b/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.test.js
new file mode 100644
index 0000000000..55a1465727
--- /dev/null
+++ b/scripts/migrations/198-purge-poisoned-coordinator-learning-buckets.test.js
@@ -0,0 +1,129 @@
+import { describe, it, expect, beforeEach, afterEach } from 'vitest';
+import { mkdtemp, mkdir, rm, readFile, writeFile } from 'fs/promises';
+import { tmpdir } from 'os';
+import { join } from 'path';
+
+import migration from './198-purge-poisoned-coordinator-learning-buckets.js';
+
+let rootDir;
+
+const LEARNING_REL = 'data/cos/learning.json';
+const BR_BUCKET = 'self-improve:branch-reconcile';
+const IR_BUCKET = 'self-improve:issue-reconcile';
+
+async function seed(data) {
+ await mkdir(join(rootDir, 'data', 'cos'), { recursive: true });
+ await writeFile(join(rootDir, LEARNING_REL), JSON.stringify(data, null, 2));
+}
+
+async function readLearning() {
+ return JSON.parse(await readFile(join(rootDir, LEARNING_REL), 'utf-8'));
+}
+
+beforeEach(async () => { rootDir = await mkdtemp(join(tmpdir(), 'mig198-')); });
+afterEach(async () => { await rm(rootDir, { recursive: true, force: true }); });
+
+describe('198-purge-poisoned-coordinator-learning-buckets (#2696)', () => {
+ it('drops BOTH coordinator buckets and leaves every other task type untouched', async () => {
+ await seed({
+ byTaskType: {
+ [BR_BUCKET]: { completed: 8, succeeded: 0, failed: 8, successRate: 0, recentOutcomes: [{ t: '2026-07-01T00:00:00Z', s: false }] },
+ [IR_BUCKET]: { completed: 3, succeeded: 0, failed: 3, successRate: 0, recentOutcomes: [] },
+ 'self-improve:accessibility': { completed: 5, succeeded: 4, failed: 1, successRate: 80, recentOutcomes: [] },
+ 'idle-review': { completed: 3, succeeded: 3, failed: 0, successRate: 100 }
+ }
+ });
+ const out = await migration.up({ rootDir });
+ expect(out.purged).toBe(11);
+ expect(out.buckets.sort()).toEqual([BR_BUCKET, IR_BUCKET].sort());
+ const data = await readLearning();
+ expect(data.byTaskType[BR_BUCKET]).toBeUndefined();
+ expect(data.byTaskType[IR_BUCKET]).toBeUndefined();
+ // accessibility is a fixing task that commits — NOT poisoned by this bug, must survive.
+ expect(Object.keys(data.byTaskType).sort()).toEqual(['idle-review', 'self-improve:accessibility']);
+ expect(data.byTaskType['self-improve:accessibility'].successRate).toBe(80);
+ });
+
+ it('purges just the one coordinator bucket present when the other never ran', async () => {
+ await seed({
+ byTaskType: {
+ [BR_BUCKET]: { completed: 4, succeeded: 0, failed: 4, successRate: 0 },
+ 'idle-review': { completed: 2, succeeded: 2, failed: 0, successRate: 100 }
+ }
+ });
+ const out = await migration.up({ rootDir });
+ expect(out.purged).toBe(4);
+ expect(out.buckets).toEqual([BR_BUCKET]);
+ expect((await readLearning()).byTaskType[BR_BUCKET]).toBeUndefined();
+ });
+
+ it('unwinds the coordinator contribution from totals as well as the buckets', async () => {
+ await seed({
+ byTaskType: {
+ [BR_BUCKET]: { completed: 6, succeeded: 0, failed: 6, successRate: 0, totalDurationMs: 3000, successDurationMs: 0, successMaxDurationMs: 0 },
+ [IR_BUCKET]: { completed: 4, succeeded: 0, failed: 4, successRate: 0, totalDurationMs: 2000, successDurationMs: 0, successMaxDurationMs: 0 },
+ 'idle-review': { completed: 4, succeeded: 4, failed: 0, successRate: 100, totalDurationMs: 2000, successDurationMs: 2000, successMaxDurationMs: 700 }
+ },
+ totals: { completed: 14, succeeded: 4, failed: 10, totalDurationMs: 7000, successDurationMs: 2000, successMaxDurationMs: 700 }
+ });
+ await migration.up({ rootDir });
+ const { totals } = await readLearning();
+ // Only the surviving idle-review runs remain — a true 4/4, not 4/14.
+ expect(totals.completed).toBe(4);
+ expect(totals.succeeded).toBe(4);
+ expect(totals.failed).toBe(0);
+ expect(totals.totalDurationMs).toBe(2000);
+ });
+
+ it('PRESERVES genuine environmental failures — they were never poisoned by the bug', async () => {
+ await seed({
+ byTaskType: { [BR_BUCKET]: { completed: 2, succeeded: 0, failed: 2, successRate: 0, totalDurationMs: 0 } },
+ totals: { completed: 2, succeeded: 0, failed: 2, totalDurationMs: 0 },
+ environmentalFailures: {
+ 'network': { count: 3, lastOccurred: '2026-07-01T00:00:00Z', taskTypes: { [BR_BUCKET]: 2, 'idle-review': 1 } }
+ }
+ });
+ await migration.up({ rootDir });
+ const data = await readLearning();
+ expect(data.byTaskType[BR_BUCKET]).toBeUndefined();
+ expect(data.environmentalFailures.network.taskTypes[BR_BUCKET]).toBe(2);
+ expect(data.environmentalFailures.network.count).toBe(3);
+ });
+
+ it('is a no-op on an install that never ran either coordinator', async () => {
+ await seed({ byTaskType: { 'idle-review': { completed: 3, succeeded: 3, failed: 0, successRate: 100 } } });
+ const before = await readFile(join(rootDir, LEARNING_REL), 'utf-8');
+ const out = await migration.up({ rootDir });
+ expect(out.purged).toBe(0);
+ // Untouched byte-for-byte — no rewrite when nothing matched.
+ expect(await readFile(join(rootDir, LEARNING_REL), 'utf-8')).toBe(before);
+ });
+
+ it('no-ops when the learning store does not exist yet', async () => {
+ expect(await migration.up({ rootDir })).toEqual({ purged: 0, reason: 'no-file' });
+ });
+
+ it('skips (never rewrites) a corrupt or unexpectedly-shaped store', async () => {
+ await mkdir(join(rootDir, 'data', 'cos'), { recursive: true });
+ await writeFile(join(rootDir, LEARNING_REL), '{ not json');
+ expect(await migration.up({ rootDir })).toEqual({ purged: 0, reason: 'unparseable' });
+ expect(await readFile(join(rootDir, LEARNING_REL), 'utf-8')).toBe('{ not json');
+
+ await writeFile(join(rootDir, LEARNING_REL), JSON.stringify([1, 2]));
+ expect(await migration.up({ rootDir })).toEqual({ purged: 0, reason: 'unexpected-shape' });
+ });
+
+ it('does not confuse the bare schedule names for the recorded bucket keys', async () => {
+ // 'branch-reconcile' / 'issue-reconcile' are the SCHEDULE keys (and the type-failure
+ // ledger's), never the buckets the runs landed in — they must not be purged.
+ await seed({ byTaskType: {
+ 'branch-reconcile': { completed: 4, succeeded: 4, failed: 0, successRate: 100 },
+ 'issue-reconcile': { completed: 2, succeeded: 2, failed: 0, successRate: 100 }
+ } });
+ const out = await migration.up({ rootDir });
+ expect(out.purged).toBe(0);
+ const data = await readLearning();
+ expect(data.byTaskType['branch-reconcile']).toBeDefined();
+ expect(data.byTaskType['issue-reconcile']).toBeDefined();
+ });
+});
diff --git a/server/services/agentLifecycle.js b/server/services/agentLifecycle.js
index a869d1d343..55f53985f3 100644
--- a/server/services/agentLifecycle.js
+++ b/server/services/agentLifecycle.js
@@ -805,6 +805,18 @@ 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
@@ -829,6 +841,10 @@ export function releaseAgentLane({ agentId, success, duration, exitCode, executi
export async function evaluateSuccessCriteria({ task, terminatedByUser, workspacePath, success = false, hookResult = null }) {
if (terminatedByUser) return null;
const taskType = task?.taskType || 'user';
+ // The SCHEDULED type (`metadata.analysisType`) if any, else the queue category —
+ // the same resolution the programmatic-I/O gate uses, reused for the coordinator
+ // gate below so both key on the task's real type, not the CoS bucket ('internal').
+ const scheduledType = resolveTaskHookType(task);
// Programmatic-I/O tasks (taskTypeHooks.js) declare their OWN criterion — the
// sentinel parsed and the hook accepted it — so this branch comes FIRST: it is
// keyed on the hook result rather than on a workspace/commit, and must not be
@@ -839,7 +855,7 @@ export async function evaluateSuccessCriteria({ task, terminatedByUser, workspac
// Judging them purely by exit code instead is also wrong: an exit-0 run whose
// `.agent-done` sentinel was missing/malformed, or whose hook threw, produced
// nothing usable and must be recorded as the failure it is (#2727).
- if (isProgrammaticIoTaskType(resolveTaskHookType(task))) {
+ if (isProgrammaticIoTaskType(scheduledType)) {
return resolveProgrammaticIoVerdict({ success, hookResult });
}
// Interactive/user tasks declare no machine-checkable criterion; neither does
@@ -852,6 +868,16 @@ 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).
+ 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 0f5673d0b7..07959dd249 100644
--- a/server/services/agentLifecycle.successCriteria.test.js
+++ b/server/services/agentLifecycle.successCriteria.test.js
@@ -257,3 +257,45 @@ describe('evaluateSuccessCriteria — commit criterion (#2344)', () => {
expect(await evaluateSuccessCriteria({ task: { id: 't2', taskType: 'internal' }, workspacePath: '/w' })).toBe(false);
});
});
+
+/**
+ * gh/git COORDINATOR task types (#2696): branch-reconcile / issue-reconcile drive
+ * their work through git+gh in the app's LIVE checkout (workspacePath IS set) and never
+ * produce a `[task-<id>]` commit, so the commit criterion scored every successful run a
+ * failure and drove their learning bucket to ~0% — the same artifact #2700 fixed for the
+ * programmatic-I/O reasoning run. They must declare NO commit criterion (fall back to the
+ * exit code), exactly like pipeline/media jobs.
+ */
+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();
+ 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('exempts a coordinator typed on taskType alone, not just metadata.analysisType', async () => {
+ // Same resolver as the programmatic-I/O gate (resolveTaskHookType), so a task shaped
+ // with the scheduled type at the top level is exempted the same way.
+ const task = { id: 't2', taskType: 'branch-reconcile' };
+ expect(await evaluateSuccessCriteria({ task, workspacePath: '/w', success: true })).toBeNull();
+ expect(checkForTaskCommit).not.toHaveBeenCalled();
+ });
+
+ it('does NOT exempt accessibility — it is a fixing task that DOES commit (#2696 scope)', async () => {
+ // accessibility's prompt ends "Test and commit changes": it makes code changes in a
+ // worktree and commits, so its commit criterion is real and its 0% (if any) is a
+ // genuine agent failure, NOT the coordinator artifact. Must stay commit-checked.
+ checkForTaskCommit.mockResolvedValueOnce(false);
+ const task = { id: 't3', taskType: 'internal', metadata: { analysisType: 'accessibility', selfImprovement: true } };
+ expect(await evaluateSuccessCriteria({ task, workspacePath: '/w', success: true })).toBe(false);
+ expect(checkForTaskCommit).toHaveBeenCalledWith('t3', '/w');
+ });
+});