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: ignore idle task success rates in review hub

[._.]/ Adam Eivy44e6277b5299
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index cab33fa436..1e263eadf5 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -17,6 +17,7 @@
## Fixed
- **CoS agent PRs no longer open with TUI startup noise as their description.** A PR that PortOS opened for a Codex/Antigravity/OpenCode agent led with the session's own lifecycle log — `📟 TUI session started: … (codex …)`, `💡 Open the Shell tab…`, `📟 Prompt pasted…` — before getting to what the agent actually did. The PR description now starts at the agent's completion summary and drops PortOS's status lines, along with the trailing `## Branch` / `## PR` section that only repeats what the PR page already shows.
+- **Review Hub success-rate alerts now require recent runs.** Low lifetime rates for task types that have been idle no longer appear as current health anomalies; alerts are shown only after enough runs occur in the rolling 30-day performance window.
- **Branch reconciler no longer hands long-lived shared branches to the coordinator agent.** `gh-pages` (the GitHub Pages publishing branch) is now protected alongside `main`/`master`/`dev`/`develop`/`release`, so the scheduled `branch-reconcile` task never tries to "open a PR" merging it into the default branch (which would break the published site). The reconciler now reuses the single canonical `PROTECTED_BRANCHES` set in `server/lib/gitArgs.js` instead of its own narrower list, so it also picks up `dev`/`develop` protection.
## Changed
diff --git a/server/services/proactiveAlerts.js b/server/services/proactiveAlerts.js
index 98eb0be16f..aa420c4d62 100644
--- a/server/services/proactiveAlerts.js
+++ b/server/services/proactiveAlerts.js
@@ -14,7 +14,7 @@
import os from 'os';
import { getGoals } from './identity.js';
-import { getPerformanceSummary, getLearningSummary } from './taskLearning.js';
+import { getPerformanceSummary } from './taskLearning.js';
import { listProcesses } from './pm2.js';
import { annotateExpectedExit } from './apps.js';
import { getUsage } from './usage.js';
@@ -66,25 +66,31 @@ async function checkGoalStalls() {
}
/**
- * Detect task types with poor success rates
+ * A low lifetime rate is historical context, not a current anomaly. The
+ * performance summary only selects `windowed` after at least five runs in the
+ * 30-day window, so this also keeps thin samples from creating noisy alerts.
+ */
+function hasCurrentPerformanceEvidence(item) {
+ return item?.rateSource === 'windowed';
+}
+
+/**
+ * Detect recently active task types with poor success rates
*/
async function checkSuccessRates() {
const perf = await getPerformanceSummary().catch(() => null);
if (!perf) return [];
- return (perf.needsAttention || []).map(item => ({
- type: 'success_drop',
- severity: item.successRate < 30 ? 'high' : 'medium',
- title: `Low success rate: ${item.taskType}`,
- // Evidence pairing (issue #2617): a recency-windowed rate is quoted with
- // the WINDOW's sample count — "0% success across 200 tasks" (lifetime
- // count next to a 6-sample windowed rate) would overstate the evidence.
- detail: item.rateSource === 'windowed'
- ? `${item.successRate}% success across the last ${item.windowedCompleted} runs`
- : `${item.successRate}% success across ${item.completed} tasks`,
- link: '/cos/learning',
- metadata: { taskType: item.taskType, successRate: item.successRate, completed: item.completed, rateSource: item.rateSource, windowedCompleted: item.windowedCompleted }
- }));
+ return (perf.needsAttention || [])
+ .filter(hasCurrentPerformanceEvidence)
+ .map(item => ({
+ type: 'success_drop',
+ severity: item.successRate < 30 ? 'high' : 'medium',
+ title: `Low success rate: ${item.taskType}`,
+ detail: `${item.successRate}% success across the last ${item.windowedCompleted} runs`,
+ link: '/cos/learning',
+ metadata: { taskType: item.taskType, successRate: item.successRate, completed: item.completed, rateSource: item.rateSource, windowedCompleted: item.windowedCompleted }
+ }));
}
/**
@@ -161,28 +167,32 @@ async function checkSystemHealth() {
* Check task learning health for critical issues
*/
async function checkLearningHealth() {
- const summary = await getLearningSummary().catch(() => null);
- if (!summary || summary.status === 'good' || summary.status === 'none') return [];
+ const perf = await getPerformanceSummary().catch(() => null);
+ if (!perf) return [];
const alerts = [];
+ const recentAttention = (perf.needsAttention || []).filter(hasCurrentPerformanceEvidence);
+ const skipped = (perf.skipped || []).filter(hasCurrentPerformanceEvidence).length;
+ const critical = recentAttention.filter(item => item.successRate < 40).length;
+ const warning = recentAttention.length - critical;
- if (summary.skipped > 0) {
+ if (skipped > 0) {
alerts.push({
type: 'learning_health',
severity: 'high',
- title: `${summary.skipped} task type${summary.skipped > 1 ? 's' : ''} being skipped`,
+ title: `${skipped} task type${skipped > 1 ? 's' : ''} being skipped`,
detail: 'Very low success rates caused automatic skip — review task configuration',
link: '/cos/learning',
- metadata: { skipped: summary.skipped, critical: summary.critical }
+ metadata: { skipped, critical }
});
- } else if (summary.critical > 0) {
+ } else if (critical > 0) {
alerts.push({
type: 'learning_health',
severity: 'medium',
- title: `${summary.critical} task type${summary.critical > 1 ? 's' : ''} need attention`,
+ title: `${critical} task type${critical > 1 ? 's' : ''} need attention`,
detail: `Success rates below ${SUCCESS_RATE_WARNING}% — may need provider or prompt adjustments`,
link: '/cos/learning',
- metadata: { critical: summary.critical, warning: summary.warning }
+ metadata: { critical, warning }
});
}
diff --git a/server/services/proactiveAlerts.test.js b/server/services/proactiveAlerts.test.js
index c1d26b6b78..0b3632560f 100644
--- a/server/services/proactiveAlerts.test.js
+++ b/server/services/proactiveAlerts.test.js
@@ -3,13 +3,13 @@ import { describe, it, expect, vi, beforeEach } from 'vitest';
const mock = vi.hoisted(() => ({
processes: [],
desktopProcessNames: new Set(),
- desktopLookupError: null
+ desktopLookupError: null,
+ performance: { needsAttention: [], skipped: [] }
}));
vi.mock('./identity.js', () => ({ getGoals: vi.fn(async () => []) }));
vi.mock('./taskLearning.js', () => ({
- getPerformanceSummary: vi.fn(async () => ({ byType: [] })),
- getLearningSummary: vi.fn(async () => ({ byType: [] }))
+ getPerformanceSummary: vi.fn(async () => mock.performance)
}));
vi.mock('./pm2.js', () => ({ listProcesses: vi.fn(async () => mock.processes) }));
// Mirrors the real annotateExpectedExit, including its fail-open behavior: a
@@ -41,6 +41,7 @@ describe('proactiveAlerts — desktop (GUI) process exemption (#2991)', () => {
mock.processes = [];
mock.desktopProcessNames = new Set();
mock.desktopLookupError = null;
+ mock.performance = { needsAttention: [], skipped: [] };
});
it('does not alert when the only errored process is a quit game window', async () => {
@@ -97,3 +98,46 @@ describe('proactiveAlerts — desktop (GUI) process exemption (#2991)', () => {
expect(alerts).toHaveLength(1);
});
});
+
+describe('proactiveAlerts — current task performance', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ mock.processes = [];
+ mock.desktopProcessNames = new Set();
+ mock.desktopLookupError = null;
+ mock.performance = { needsAttention: [], skipped: [] };
+ });
+
+ it('does not alert on a low historical rate when the task type has not run recently', async () => {
+ const stale = {
+ taskType: 'self-improve:example',
+ successRate: 0,
+ completed: 12,
+ rateSource: 'lifetime',
+ windowedCompleted: 0
+ };
+ mock.performance = { needsAttention: [stale], skipped: [stale] };
+
+ const { alerts } = await generateAlerts();
+ expect(alerts.filter(a => a.type === 'success_drop' || a.type === 'learning_health')).toEqual([]);
+ });
+
+ it('keeps alerts backed by enough runs in the current window', async () => {
+ const active = {
+ taskType: 'self-improve:example',
+ successRate: 20,
+ completed: 25,
+ rateSource: 'windowed',
+ windowedCompleted: 5
+ };
+ mock.performance = { needsAttention: [active], skipped: [active] };
+
+ const { alerts } = await generateAlerts();
+ expect(alerts.find(a => a.type === 'success_drop')).toMatchObject({
+ detail: '20% success across the last 5 runs'
+ });
+ expect(alerts.find(a => a.type === 'learning_health')).toMatchObject({
+ metadata: { skipped: 1, critical: 1 }
+ });
+ });
+});