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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor: consolidate claim-flow resolution on isClaimFlowDispatch
Adam Eivy1f91480035e4
diff --git a/server/services/agentFinalization.goalFidelity.test.js b/server/services/agentFinalization.goalFidelity.test.jsindex dbc76af95e..0e2a28fbf4 100644--- a/server/services/agentFinalization.goalFidelity.test.js+++ b/server/services/agentFinalization.goalFidelity.test.js@@ -67,7 +67,10 @@ vi.mock('../lib/gitCommitProbe.js', () => ({}));vi.mock('./agentRunEventLog.js', () => ({ appendRunEvent: vi.fn(async () => null) }));vi.mock('./agentRunTracking.js', () => ({ createAgentRun: vi.fn(), completeAgentRun: vi.fn(async () => null) }));-vi.mock('./taskTypeHooks.js', () => ({+vi.mock('./taskTypeHooks.js', async (importOriginal) => ({+ // isClaimFlowDispatch stays REAL: the claim-flow fidelity cases below depend+ // on it resolving the claim marker/type exactly as production does.+ ...(await importOriginal()),canRunTaskOutputHookWithoutPayload: vi.fn(() => false),isProgrammaticIoTaskType: vi.fn(() => false),resolveTaskHookType: vi.fn(() => null),diff --git a/server/services/agentFinalization.js b/server/services/agentFinalization.jsindex 1c9ba32e74..cfe6a88ac5 100644--- a/server/services/agentFinalization.js+++ b/server/services/agentFinalization.js@@ -23,7 +23,6 @@ import { isPrivateSecurityTask } from '../lib/privateSecurityPolicy.js';import { join } from 'path';import { execGit } from '../lib/execGit.js';import { safeJSONParse } from '../lib/fileUtils.js';-import { CLAIM_FLOW_TASK_TYPES } from '../lib/claimFlowTaskTypes.js';import { cosEvents, emitLog } from './cosEvents.js';// The DEFINING module, not a barrel (#3450) — see the note in// `agentManagement.js`. This module is a LEAF that both transition modules@@ -789,8 +788,7 @@ async function evaluateGoalFidelity({ task, workspacePath, startedAt }) {const reviewLoopLeaveOpen = reviewLoopFollowUp&& (task.metadata?.reviewLoopLeaveOpen === true || task.metadata?.reviewLoopLeaveOpen === 'true');if (declaresNoCommitCriterion(task) && !reviewLoopLeaveOpen) return noFidelityVerdict();- const claimFlow = task.metadata?.claimFlow === true || task.metadata?.claimFlow === 'true'- || CLAIM_FLOW_TASK_TYPES.has(resolveTaskHookType(task));+ const claimFlow = isClaimFlowDispatch(task);const claimed = claimFlow? await claimedIssueObjective(workspacePath).catch(() => null): null;diff --git a/server/services/taskTypeHooks.js b/server/services/taskTypeHooks.jsindex ebdbec8b79..f3abf8eed7 100644--- a/server/services/taskTypeHooks.js+++ b/server/services/taskTypeHooks.js@@ -232,9 +232,8 @@ export function isNonCommittingCoordinatorTask(task) {* type set is the backstop for records carrying only the scheduled type.*/export function isClaimFlowDispatch(task) {- if (task?.metadata?.claimFlow === true || task?.metadata?.claimFlow === 'true') return true;- const type = task?.metadata?.analysisType || task?.metadata?.taskAnalysisType || task?.taskType || null;- return CLAIM_FLOW_TASK_TYPES.has(type);+ if (isTruthyMeta(task?.metadata?.claimFlow)) return true;+ return CLAIM_FLOW_TASK_TYPES.has(resolveTaskHookType(task));}/**diff --git a/server/services/taskTypeHooks.noCommit.test.js b/server/services/taskTypeHooks.noCommit.test.jsindex 593d3be1f7..2f48a8d41f 100644--- a/server/services/taskTypeHooks.noCommit.test.js+++ b/server/services/taskTypeHooks.noCommit.test.js@@ -117,22 +117,10 @@ describe('isClaimFlowDispatch', () => {}});- it('recognizes the explicit claimFlow marker, boolean and string form', () => {- expect(isClaimFlowDispatch(task({ claimFlow: true }))).toBe(true);- expect(isClaimFlowDispatch(task({ claimFlow: 'true' }))).toBe(true);- });-- it('resolves the archived-agent projection (taskAnalysisType) and a bare taskType', () => {- expect(isClaimFlowDispatch(task({ taskAnalysisType: 'claim-issue' }))).toBe(true);- expect(isClaimFlowDispatch({ id: 'task-1', taskType: 'claim-work' })).toBe(true);- });-- it('does not treat an ordinary committing task as a claim flow', () => {- expect(isClaimFlowDispatch(task({}))).toBe(false);- expect(isClaimFlowDispatch(task({ analysisType: 'security' }))).toBe(false);- expect(isClaimFlowDispatch(task({ claimFlow: 'false' }))).toBe(false);- expect(isClaimFlowDispatch(task({ analysisType: 'branch-reconcile' }))).toBe(false);- });+ // The marker forms (boolean/string claimFlow), the archived taskAnalysisType+ // projection, the bare taskType, and the negative shapes are pinned at the+ // CALLER boundary in agentFinalization.successCriteria.test.js, which also+ // asserts the commit probe is not invoked — the stronger contract.it('is NOT a declaresNoCommitCriterion shape — the goal-fidelity gate depends on the distinction', () => {// If claim flows ever satisfy declaresNoCommitCriterion, the goal-fidelity