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: failure telemetry is validation-authoritative + DRY outcomeSuccess (#2344)

Adam Eivyf2d8cd511e4c
diff --git a/server/services/taskLearning/metrics.js b/server/services/taskLearning/metrics.js
index 329ea98861..4490083eb6 100644
--- a/server/services/taskLearning/metrics.js
+++ b/server/services/taskLearning/metrics.js
@@ -87,7 +87,8 @@ export function computeLatencySplit({ startedAt, completedAt, createdAt, duratio
* and their timestamps/metadata; uses explicit null sentinels for anything not
* derivable rather than fabricating a value.
*
- * failureSignature — { category, messageSnippet, failurePosition } (null on success)
+ * failureSignature — { category, messageSnippet, failurePosition } (null when the
+ * run met its validation-authoritative outcome; see outcomeSuccess below)
* executionContext — { provider, model, modelTier, taskType, component, inputChars, routingReason }
* latency — { wallMs, queueMs, executionMs } (null members when not derivable)
* validationPassed — success-criteria validation boolean (issue #2344):
@@ -105,11 +106,17 @@ export function buildTaskTelemetryContext(agent, task) {
// Sentinel discipline: only an explicit boolean counts as a validation verdict;
// anything else (undefined/null/non-bool) is "no criterion declared" → null.
const validationPassed = typeof result.validationPassed === 'boolean' ? result.validationPassed : null;
+ // Validation-authoritative outcome (issue #2344): a declared verdict overrides
+ // the runner's exit code. Failure telemetry keys off THIS, not raw `success`,
+ // so a commit-found run (success:false, validationPassed:true) is NOT harvested
+ // as a failure (which would poison the #2329 failure-signal window that routing
+ // consumes), and a criterion-missed clean exit is treated as the failure it is.
+ const outcomeSuccess = validationPassed === null ? success : validationPassed;
const taskType = extractTaskType(task);
const errorAnalysis = result.errorAnalysis || null;
const rawMessage = errorAnalysis?.message || errorAnalysis?.details || '';
- const failureSignature = success ? null : {
+ const failureSignature = outcomeSuccess ? null : {
category: errorAnalysis?.category || null,
messageSnippet: rawMessage ? String(rawMessage).substring(0, 200) : null,
// Best-available proxy for "where in a multi-step workflow it failed": the
@@ -144,6 +151,9 @@ export function buildTaskTelemetryContext(agent, task) {
taskType,
success,
validationPassed,
+ // Validation-authoritative learning outcome (#2344): the single source of
+ // truth every aggregate/window/telemetry gate keys off, so they can't drift.
+ outcomeSuccess,
failureSignature,
executionContext,
latency
@@ -203,15 +213,13 @@ export async function recordTaskCompletion(agent, task) {
const taskType = telemetry.taskType;
const modelTier = agent.metadata?.modelTier || 'unknown';
const success = telemetry.success;
- // Learning outcome (issue #2344): when a success criterion WAS declared, its
- // validation verdict is authoritative for what the aggregates learn — a clean
- // exit that produced no committed work is NOT a tier success, and a commit-found
- // run is a success even on a non-zero exit. Only when no criterion is declared
- // (validationPassed === null) do the aggregates fall back to the runner's
- // exit-code `success`. Keeps routingAccuracy/tier/type/total counts consistent
- // with the correlation window's `bad` label. Back-compat: legacy completions
- // (and tests) that stamp no validationPassed see outcomeSuccess === success.
- const outcomeSuccess = telemetry.validationPassed === null ? success : telemetry.validationPassed;
+ // Validation-authoritative learning outcome (issue #2344) — computed once in
+ // buildTaskTelemetryContext so aggregates, the correlation window, and failure
+ // telemetry all key off the same value. A clean exit that produced no committed
+ // work is NOT a tier success; a commit-found run is a success even on a non-zero
+ // exit; with no criterion declared it falls back to the runner's exit-code
+ // `success` (so legacy completions/tests are unchanged).
+ const outcomeSuccess = telemetry.outcomeSuccess;
const duration = agent.result?.duration || 0;
const errorCategory = telemetry.failureSignature?.category || null;
@@ -300,8 +308,9 @@ export async function recordTaskCompletion(agent, task) {
}
routing.lastAttempt = new Date().toISOString();
- // Track error patterns
- if (!success && errorCategory) {
+ // Track error patterns — gated on the validation-authoritative outcome so a
+ // commit-found run isn't logged as an error and a criterion-miss is (#2344).
+ if (!outcomeSuccess && errorCategory) {
if (!data.errorPatterns[errorCategory]) {
data.errorPatterns[errorCategory] = {
count: 0,
diff --git a/server/services/taskLearning/metrics.test.js b/server/services/taskLearning/metrics.test.js
index 710829ec0a..7862e5b752 100644
--- a/server/services/taskLearning/metrics.test.js
+++ b/server/services/taskLearning/metrics.test.js
@@ -181,6 +181,39 @@ describe('buildTaskTelemetryContext', () => {
expect(bogus.validationPassed).toBeNull();
});
+ it('does NOT harvest a failure signature for a commit-found run (success:false, validationPassed:true) (#2344)', () => {
+ // Runner exit non-zero, but the declared criterion WAS met (commit found).
+ // The validation verdict is authoritative — no failure signature is built, so
+ // a fulfilled run can't poison the #2329 failure-signal window that routing
+ // consumes.
+ const agent = {
+ ...baseAgent,
+ result: {
+ success: false,
+ duration: 2000,
+ validationPassed: true,
+ errorAnalysis: { category: 'test-failure', message: 'exit 1 but committed' }
+ }
+ };
+ const ctx = buildTaskTelemetryContext(agent, { taskType: 'internal' });
+ expect(ctx.outcomeSuccess).toBe(true);
+ expect(ctx.failureSignature).toBeNull();
+ const data = { failureSignatures: {} };
+ recordFailureSignature(data, ctx);
+ expect(data.failureSignatures).toEqual({});
+ });
+
+ it('exposes a validation-authoritative outcomeSuccess distinct from runner success (#2344)', () => {
+ // Clean exit, criterion missed → outcome is a failure.
+ const missed = buildTaskTelemetryContext(
+ { ...baseAgent, result: { success: true, duration: 1, validationPassed: false } }, {});
+ expect(missed.success).toBe(true);
+ expect(missed.outcomeSuccess).toBe(false);
+ // No criterion declared → outcomeSuccess mirrors runner success.
+ const plain = buildTaskTelemetryContext({ ...baseAgent, result: { success: true, duration: 1 } }, {});
+ expect(plain.outcomeSuccess).toBe(true);
+ });
+
it('carries the validation verdict into the harvested failure signature sample (#2344)', () => {
const agent = {
...baseAgent,