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

refactor([issue-2764]): collapse null-on-success enforcement to one site

[._.]/ Adam Eivyff92aaba3b2a
diff --git a/server/services/layeredIntelligenceExecutionFailures.js b/server/services/layeredIntelligenceExecutionFailures.js
index 0336960752..4f08ec61cb 100644
--- a/server/services/layeredIntelligenceExecutionFailures.js
+++ b/server/services/layeredIntelligenceExecutionFailures.js
@@ -179,14 +179,18 @@ const RAW_CATEGORY_TAXONOMY = new Map(Object.entries({
* null).
* Anything else falls through to `unknown-failure`.
*
+ * The classifier owns the "null when there is nothing to diagnose" rule (mirroring
+ * classifyRejection returning null for a merged/unresolved proposal), so callers
+ * pass the run's `success` flag unconditionally rather than pre-guarding. To
+ * re-classify a stored failed record from its retained raw signal, pass
+ * `{ success: false, errorCategory: record.failureSignal }`.
+ *
* Deterministic and total: same inputs always yield the same token.
*/
-export function classifyExecutionFailure({ success = null, executionOutcome = null, errorCategory = null, validationPassed = null } = {}) {
- // Resolve whether this is a failed execution. Prefer an explicit boolean
- // `success`; otherwise fall back to the stored `executionOutcome` token so the
- // classifier can also re-diagnose a persisted record.
- const failed = success === false || (success === null && executionOutcome === 'failure');
- if (!failed) return null;
+export function classifyExecutionFailure({ success, errorCategory = null, validationPassed = null } = {}) {
+ // Only a failed execution (success strictly false) has something to diagnose — a
+ // success, or an unknown/absent success flag, has no failure to explain.
+ if (success !== false) return null;
// 1. A mapped raw error category is the most specific signal.
const mapped = RAW_CATEGORY_TAXONOMY.get(normalizeToken(errorCategory));
diff --git a/server/services/layeredIntelligenceExecutionFailures.test.js b/server/services/layeredIntelligenceExecutionFailures.test.js
index eeaffb5cc2..2d9c4850b3 100644
--- a/server/services/layeredIntelligenceExecutionFailures.test.js
+++ b/server/services/layeredIntelligenceExecutionFailures.test.js
@@ -43,10 +43,10 @@ describe('execution-failure taxonomy vocabulary', () => {
});
describe('classifyExecutionFailure', () => {
- it('returns null when the execution did not fail', () => {
+ it('returns null unless success is strictly false — nothing else to diagnose', () => {
expect(classifyExecutionFailure({ success: true, errorCategory: 'test-failure' })).toBeNull();
- expect(classifyExecutionFailure({ success: null, executionOutcome: 'success' })).toBeNull();
- // Nothing at all → nothing to diagnose.
+ // An absent/unknown success flag is not a failure.
+ expect(classifyExecutionFailure({ errorCategory: 'test-failure' })).toBeNull();
expect(classifyExecutionFailure({})).toBeNull();
});
@@ -82,8 +82,9 @@ describe('classifyExecutionFailure', () => {
expect(classifyExecutionFailure({ success: false, errorCategory: 'rate-limit' })).toBe(UNKNOWN_EXECUTION_FAILURE);
});
- it('re-diagnoses a persisted record from executionOutcome when no explicit success is given', () => {
- expect(classifyExecutionFailure({ executionOutcome: 'failure', errorCategory: 'test-failure' })).toBe('testing');
+ it('re-classifies a stored failed record from its retained raw signal', () => {
+ // The §3-forward path: pass success:false + the persisted failureSignal.
+ expect(classifyExecutionFailure({ success: false, errorCategory: 'test-failure' })).toBe('testing');
});
it('is deterministic', () => {
diff --git a/server/services/layeredIntelligenceOutcomes.js b/server/services/layeredIntelligenceOutcomes.js
index 88db22ecde..7bb23eebab 100644
--- a/server/services/layeredIntelligenceOutcomes.js
+++ b/server/services/layeredIntelligenceOutcomes.js
@@ -202,12 +202,13 @@ export async function recordProposalExecution({ appId, slug, scope = null, succe
// fallback and the scope-preservation merge below.
const normScope = typeof scope === 'string' && scope.trim() ? scope.trim() : null;
// Diagnose WHY a failed hand-off failed (#2764 §1) from the failure signal the
- // caller already computed — a success has nothing to diagnose, so both fields
- // stay null on success. `failureSignal` keeps the raw category (root-cause
- // signal) even when it doesn't map to a taxonomy token, so a later reconcile
- // could re-classify without re-running the task. Classification is deterministic
- // and pure — no provider round-trip (the "no cold-bootstrap LLM" policy).
- const failureCategory = success ? null : classifyExecutionFailure({ success, errorCategory, validationPassed });
+ // caller already computed. The classifier owns the null-on-success rule (it
+ // returns null unless success is strictly false), so no outer guard here.
+ // `failureSignal` keeps the raw category (root-cause signal) even when it doesn't
+ // map to a taxonomy token, so a later reconcile could re-classify without
+ // re-running the task. Classification is deterministic and pure — no provider
+ // round-trip (the "no cold-bootstrap LLM" policy).
+ const failureCategory = classifyExecutionFailure({ success, errorCategory, validationPassed });
const failureSignal = success ? null : (typeof errorCategory === 'string' && errorCategory.trim() ? errorCategory.trim() : null);
await ensureTypeIndex(store);
// Fence the whole read-modify-write in the per-id write queue (#2765, codex P2). A bare
diff --git a/server/services/taskLearning/metrics.js b/server/services/taskLearning/metrics.js
index 2b0e66aaf0..47684a8c96 100644
--- a/server/services/taskLearning/metrics.js
+++ b/server/services/taskLearning/metrics.js
@@ -302,18 +302,19 @@ function deriveLiExecutionPayload(task, success, { errorCategory = null, validat
const li = task?.metadata?.taskLiProposal;
if (!li || typeof li !== 'object' || Array.isArray(li)) return null;
if (!li.appId || !li.slug) return null;
- // On failure, carry the run's failure signal so the outcome store can classify
- // the execution-failure taxonomy (#2764 §1). Harmless on success (the store
- // ignores it and nulls both diagnosis fields). `errorCategory` is the raw
- // agentErrorAnalysis category; `validationPassed` distinguishes a clean-exit
- // criterion miss (→ testing) when no error pattern matched.
+ // Carry the run's failure signal so the outcome store can classify the
+ // execution-failure taxonomy (#2764 §1). The store keys classification off
+ // `success` and ignores these on a successful run (where they are already null
+ // upstream anyway — a clean run has no failureSignature), so they are forwarded
+ // as-is. `errorCategory` is the raw agentErrorAnalysis category; `validationPassed`
+ // distinguishes a clean-exit criterion miss (→ testing) when no error matched.
return {
appId: li.appId,
slug: li.slug,
scope: li.scope ?? null,
success: !!success,
- errorCategory: success ? null : errorCategory,
- validationPassed: success ? null : validationPassed
+ errorCategory,
+ validationPassed
};
}