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: extend validation-authoritative outcome to duration backfill + correlation tier filter (#2344)

Adam Eivy1cf75e335f57
diff --git a/server/services/taskLearning/metrics.js b/server/services/taskLearning/metrics.js
index f3cd6b570a..329ea98861 100644
--- a/server/services/taskLearning/metrics.js
+++ b/server/services/taskLearning/metrics.js
@@ -19,7 +19,7 @@ import {
loadLearningData,
saveLearningData
} from './store.js';
-import { deriveFailureSignalAvoidance } from './routing.js';
+import { deriveFailureSignalAvoidance, isNonRoutableLearnedTier } from './routing.js';
import { recordCorrelationSample } from './correlationQuality.js';
// Cap on retained per-category signature samples — bounds file growth the same
@@ -223,8 +223,10 @@ export async function recordTaskCompletion(agent, task) {
// run's own outcome into its own prediction and inflate the gauge. Uses the
// signal's BASE sensitivity (default aggressive bar) as a fixed predictor —
// measuring the gate against its own correlation-gated output would be circular.
- // Skipped for the unknown tier (no routable prediction to make).
- const correlationPredictedRisk = (modelTier && modelTier !== 'unknown')
+ // Skipped for the unknown tier AND non-routable learned tiers (minimal/low):
+ // routing can never flag those, so recording them as "predicted safe" would
+ // encode "no routable prediction" as a true-negative and skew the gauge.
+ const correlationPredictedRisk = (modelTier && modelTier !== 'unknown' && !isNonRoutableLearnedTier(modelTier))
? deriveFailureSignalAvoidance(data, taskType).avoidTiers.includes(modelTier)
: null;
@@ -623,7 +625,14 @@ export async function recalculateDurationStats() {
agentCount++;
const duration = meta.result?.duration || 0;
- if (!meta.result?.success || duration <= 0) continue;
+ // Validation-authoritative outcome (issue #2344), consistent with the live
+ // recordTaskCompletion path: an archived clean-exit run that missed its
+ // declared criterion is NOT a success (excluded from success-only ETAs),
+ // and a commit-found run is a success even on a non-zero exit. Falls back to
+ // the raw exit-code success for records that predate validationPassed.
+ const vp = meta.result?.validationPassed;
+ const outcomeSuccess = typeof vp === 'boolean' ? vp : !!meta.result?.success;
+ if (!outcomeSuccess || duration <= 0) continue;
successCount++;
const taskType = extractTaskType({
diff --git a/server/services/taskLearning/routing.js b/server/services/taskLearning/routing.js
index 164fcca511..0c46494221 100644
--- a/server/services/taskLearning/routing.js
+++ b/server/services/taskLearning/routing.js
@@ -56,6 +56,14 @@ const tierWeight = (tier) => TIER_WEIGHT[tier] ?? HEAVIEST_WEIGHT;
*/
const NON_ROUTABLE_LEARNED_TIERS = new Set(['minimal', 'low']);
+/**
+ * True for a learned tier the selection path can't actually route to
+ * (`minimal`/`low`). Exported so the correlation window (metrics.js) can skip
+ * these the same way `deriveFailureSignalAvoidance` does — recording a
+ * never-flaggable tier as "predicted safe" would skew the global gauge (#2344).
+ */
+export const isNonRoutableLearnedTier = (tier) => NON_ROUTABLE_LEARNED_TIERS.has(tier);
+
/** Minimum success rate (%) for a tier to count as "proven" for a task type. */
const HIGH_SUCCESS_THRESHOLD = 80;