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
fix: preserve claim authority when resuming swarms (#10567)
[._.]/ Adam Eivydc9ea0370371
diff --git a/server/lib/README.md b/server/lib/README.mdindex 784e788509..47abb150e2 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -551,7 +551,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `autonomousJobIntervals.js` | Autonomous-job cadence vocabulary (pure). `INTERVAL_OPTIONS` (picker rows, `ms: null` for a cadence with no recurrence), `ON_DEMAND_INTERVAL`, `JOB_INTERVAL_VALUES` (every legal stored cadence, incl. `custom`), `resolveIntervalMs(interval, customMs)` → ms or `null` (the no-interval sentinel — never falls through to `DAY`), and `isOnDemandJob(job)` for the three due/next-fire implementations. Lives here so `cosValidation.js` can validate the cadence without a lib → services import; `services/autonomousJobs/constants.js` re-exports it. Separate vocabulary from the scheduled-CoS-task `INTERVAL_TYPES`. || `jobFormFields.js` | A scheduled agent job's own configuration form (pure). `JOB_FORM_FIELD_TYPES` (text/textarea/number/select/checkbox), the `jobFormFieldsSchema` / `jobFormValuesSchema` pair Zod-validates the job payload against, and the prompt projection `formatJobFormValues(fields, values)` / `appendJobFormValues(job, prompt)`. Definitions and values are stored separately so re-aiming a job (a new value) is not an edit to its design (a new field), and the projection iterates DEFINITIONS — a value whose field was deleted is inert. A field the user left blank is omitted rather than passed as an empty line, but a `false` checkbox is a real answer and is kept. Consumed by `services/autonomousJobs/skillTemplates.js`; the values reach the agent as the prompt's `## Run configuration` section. `describeReaimedValues(fields, saved, run)` names the values a manual run changed, as the one-line description suffix that keeps a re-aimed run from colliding with a differently-aimed twin in `addTask`'s first-line dedupe. || `capabilityMap.js` | Pure row builders for Setup & Capabilities, including strict network/provider first-run readiness and optional-integration health rollups; fed by `routes/capabilities.js`. |-| `claimFlowTaskTypes.js` | `CLAIM_FLOW_TASK_TYPES` — the ONE list of task kinds whose prompts own their own `claim/<item>` worktree and push/PR/MR/review lifecycle (#6613). `services/cosTaskGenerator.js` stamps `metadata.claimFlow` from it (WRITE side); `services/agentPromptBuilder.js` reads it back through `isClaimFlowTask()` to pick a run's claim posture (READ side). It lived as two byte-identical copies, so a new claim type added to one silently split the writer from the reader — no error, just a claim run treated as a plain commit-only handoff; `claimFlowTaskTypes.test.js` fails if a local copy reappears. Imports nothing. |+| `claimFlowTaskTypes.js` | `hasClaimFlowContract(task)` shares trusted claim identity across registration, completion and resume. `CLAIM_FLOW_TASK_TYPES` — the ONE list of task kinds whose prompts own their own `claim/<item>` worktree and push/PR/MR/review lifecycle (#6613). `services/cosTaskGenerator.js` stamps `metadata.claimFlow` from it (WRITE side); `services/agentPromptBuilder.js` reads it back through `isClaimFlowTask()` to pick a run's claim posture (READ side). It lived as two byte-identical copies, so a new claim type added to one silently split the writer from the reader — no error, just a claim run treated as a plain commit-only handoff; `claimFlowTaskTypes.test.js` fails if a local copy reappears. Imports nothing. || `chiptuneRender.js` | Deterministic chiptune score → mono PCM → 16-bit WAV buffer (pure Node, no audio deps); `renderScoreToPcm` / `pcmToWavBuffer` / `renderScoreToWav`. || `chiptuneScore.js` | Chiptune score contract (#2911): `chiptuneScoreSchema` (Zod) + `sanitizeChiptuneScore`, `buildScoreEvents` — the pattern/order → absolute-time flatten mirrored by `client/src/lib/chiptunePlayback.js`. || `musicVideoLayers.js` | Music Video per-scene visual layers (#8985): `MUSIC_VIDEO_VISUAL_LAYERS` (`footage`/`still`/`card`/`code`), `MUSIC_VIDEO_STILL_MOVES` (`hold`/`push`/`pan`), `sceneVisualLayer(scene, { layered })` (only a composed render honors a still/card), `sceneHasAuthoredSpan`, and `sceneRenderReady(scene, { layered })`. Pure leaf shared by `services/musicVideo/render.js` and the client board (`client/src/lib/musicVideoLayers.js`). |diff --git a/server/lib/claimContinuation.js b/server/lib/claimContinuation.jsindex cb410cedf2..312846cd96 100644--- a/server/lib/claimContinuation.js+++ b/server/lib/claimContinuation.js@@ -17,6 +17,7 @@import { resolve } from 'path';import { isPathInsideDir } from './pathSafety.js';import { isHumanClaimWorktree, worktreeAgentId } from './worktreeOwnership.js';+import { hasClaimFlowContract } from './claimFlowTaskTypes.js';import { isTruthyMeta } from './metadataFlags.js';const CASE_FOLD = process.platform === 'win32';@@ -52,7 +53,7 @@ function samePath(a, b) {* @returns {{ claimBranch: string|null, claimPicksOwnBranch: boolean, claimSelectionPending?: true }|null}*/export function claimOwnershipBinding(task) {- if (!isTruthyMeta(task?.metadata?.claimFlow)) return null;+ if (!hasClaimFlowContract(task)) return null;const claimBranch = claimContinuationBranch(task?.metadata?.claimTarget);// A pinned run may still check out a DIFFERENT branch: a pinned tracking epic// ships its first eligible child, and an oversized issue is split and its@@ -269,7 +270,7 @@ function claimHolderOccupancy({ agents, holderPath, branchName, sourceWorkspace,* @returns {{ existingBranch: string, resumedFromAgentId: string, resumeWorktreePath: string, claimResumeInPlace: true }|null}*/export function claimContinuationPointer({ task, agentId, worktrees = [], agents = [], worktreesRoot, sourceWorkspace }) {- if (task?.metadata?.claimFlow !== true && task?.metadata?.claimFlow !== 'true') return null;+ if (!hasClaimFlowContract(task)) return null;const branchName = claimContinuationBranch(task?.metadata?.claimTarget);if (!branchName || !agentId || !worktreesRoot) return null;if (!Array.isArray(agents)) return null;diff --git a/server/lib/claimFlowTaskTypes.js b/server/lib/claimFlowTaskTypes.jsindex 5307807d10..f068771bd9 100644--- a/server/lib/claimFlowTaskTypes.js+++ b/server/lib/claimFlowTaskTypes.js@@ -13,8 +13,14 @@// the explicit `claimFlow` marker existed, which carry their kind only in// `metadata.analysisType`.//-// Pure leaf: this module imports NOTHING. `server/lib/` is reached by ~400-// suites, so keep it that way.+// Pure leaf: shared by prompt selection, registration and resume authority.export const CLAIM_FLOW_TASK_TYPES = new Set(['plan-task', 'claim-issue', 'claim-issue-gitlab', 'claim-issue-jira', 'claim-work']);++/** Trusted structured task identity only; descriptions and prompts confer no authority. */+export function hasClaimFlowContract(task) {+ const metadata = task?.metadata;+ return metadata?.claimFlow === true || metadata?.claimFlow === 'true'+ || CLAIM_FLOW_TASK_TYPES.has(metadata?.analysisType || metadata?.taskAnalysisType || task?.taskType);+}diff --git a/server/services/agentManagement.claimResume.test.js b/server/services/agentManagement.claimResume.test.jsnew file mode 100644index 0000000000..0073d0e931--- /dev/null+++ b/server/services/agentManagement.claimResume.test.js@@ -0,0 +1,198 @@+/** Resume to real spawn dispatch, registration, completion and ownership gates.+ * Only provider/process, git discovery and persisted IO are doubled.+ */+import { beforeEach, describe, expect, it, vi } from 'vitest';+import { createFileWriteQueue } from '../lib/fileWriteQueue.js';++const f = vi.hoisted(() => ({ tasks: {}, state: null, disk: null, prompt: null }));+const persist = () => { f.disk = structuredClone(f.state); };+vi.mock('./cosState.js', () => ({+ withStateLock: createFileWriteQueue(),+ loadState: async () => f.state,+ saveState: async state => { f.state = state; f.disk = structuredClone(state); },+ readMergeAdmissionStateForSafetyCheck: async () => ({ trusted: true, ...structuredClone(f.disk) }),+}));+vi.mock('./cosAgentLifecycle.js', () => ({+ getAgentRecord: vi.fn(async id => f.state.agents[id]),+ readAgentRecordOrUnreadable: async id => f.state.agents[id],+ getAgents: async () => Object.values(f.state.agents),+ registerAgent: async (id, taskId, metadata) => {+ f.state.agents[id] = { id, taskId, status: 'running', startedAt: '2026-01-02T00:00:00Z', metadata };+ f.disk = structuredClone(f.state);+ },+ completeAgent: vi.fn(async id => { f.state.agents[id].status = 'completed'; f.disk = structuredClone(f.state); }),+ updateAgent: vi.fn(), isLiveAgentRecord: agent => agent?.status === 'running',+ AGENT_RECORD_UNREADABLE: Symbol('unreadable'),+}));+vi.mock('./cos.js', () => ({+ getConfig: async () => ({}),+ getTaskById: vi.fn(async id => f.tasks[id] || null),+ reviveBlockedTask: vi.fn(async (id, patch) => {+ f.tasks[id] = { ...f.tasks[id], status: 'pending', metadata: { ...f.tasks[id].metadata, ...patch.metadata } };+ return f.tasks[id];+ }),+ updateTask: async (id, patch) => Object.assign(f.tasks[id], patch),+ addTask: vi.fn(async ({ metadata, ...input }, taskType) => {+ f.tasks.replacement = { id: 'replacement', taskType, description: input.description,+ status: 'pending', metadata: { ...metadata, ...Object.fromEntries(Object.entries(input).filter(([k, v]) => k !== 'description' && v !== undefined)) } };+ return f.tasks.replacement;+ }),+ forceSpawnTask: vi.fn(), evaluateTasks: vi.fn(),+}));+vi.mock('./cosEvents.js', () => ({ emitLog: vi.fn(), cosEvents: { emit: vi.fn() } }));+vi.mock('./agentRunEventLog.js', () => ({ appendRunEvent: vi.fn() }));+vi.mock('./agentRunTracking.js', () => ({ createAgentRun: async () => ({ runId: 'run-new' }), completeAgentRun: vi.fn() }));+vi.mock('../lib/fileUtils.js', async importOriginal => ({+ ...await importOriginal(), ensureDir: vi.fn(), writeFileGuarded: vi.fn(),+}));+vi.mock('../lib/backupSnapshotBoundary.js', () => ({ withBackupAssetPublication: work => work() }));+vi.mock('../lib/gitRemote.js', async importOriginal => ({ ...await importOriginal(),+ getOriginInfo: async () => ({ host: 'github.com', fullName: 'example/repo' }),+}));+vi.mock('../lib/workTracker.js', async importOriginal => ({ ...await importOriginal(),+ resolveRepoForgeTarget: async () => ({ forge: 'github', host: 'github.com', fullName: 'example/repo' }),+}));+vi.mock('./codeReview.js', () => ({ getCodeReviewDefaults: async () => ({ reviewers: [] }) }));+vi.mock('./promptSections/forge.js', async importOriginal => ({ ...await importOriginal(), resolveManualForgeCli: async () => 'gh' }));+vi.mock('./workspaceContext.js', () => ({ snapshotOnRepoSwitch: vi.fn() }));+vi.mock('./agentProviderResolution.js', () => ({ resolveAgentProviderAndModel: async () => ({+ ok: true, provider: { id: 'example-cli', type: 'cli', command: 'codex' }, selectedModel: 'example-model', modelSelection: {},+}) }));+vi.mock('./agentWorkspacePrep.js', () => ({ prepareAgentWorkspace: async () => ({+ workspacePath: '/repos/example', worktreeInfo: null,+}) }));+vi.mock('./agentCliSpawning.js', () => ({+ buildCliSpawnConfig: () => ({ command: 'codex' }), isClaudeCliProvider: () => false,+ isTuiProvider: () => false, getClaudeSettingsEnv: async () => ({}),+ spawnDirectly: vi.fn(async ({ prompt }) => { f.prompt = prompt; return 'replacement-agent'; }),+}));+vi.mock('./agentTuiSpawning.js', () => ({ buildTuiSpawnConfig: vi.fn(), spawnTuiAgent: vi.fn() }));+vi.mock('./cosRunnerClient.js', () => ({+ terminateAgentViaRunner: vi.fn(),+ killAgentViaRunner: vi.fn(),+ pauseAgentViaRunner: vi.fn(),+ getAgentStatsFromRunner: vi.fn(),+ getActiveAgentsFromRunner: vi.fn().mockResolvedValue([])+}));++vi.mock('./toolStateMachine.js', () => ({ completeExecution: vi.fn(), errorExecution: vi.fn() }));+vi.mock('./shell.js', () => ({ writeToSession: vi.fn(), killSession: vi.fn() }));+vi.mock('./agentWorktreeCleanup.js', () => ({+ cleanupAgentWorktree: vi.fn(),+ resolveTaskResumePatch: vi.fn().mockResolvedValue({})+}));+vi.mock('./agentFinalization.js', () => ({+ dispatchRecoveredTaskOutputHook: vi.fn().mockResolvedValue(undefined),+ retireDeadAgent: vi.fn().mockResolvedValue({ success: false }),+ stampLiExecutionVerdict: vi.fn(async (taskUpdate) => taskUpdate),+}));+// Only the two I/O functions are stubbed — HOST_SHUTDOWN_REASON stays real so+// the breadcrumb value the tests assert can't drift from the one production writes.+vi.mock('../lib/hostShutdown.js', async (importOriginal) => ({+ ...(await importOriginal()),+ readHostShutdownMarker: vi.fn().mockResolvedValue(null),+ clearHostShutdownMarker: vi.fn().mockResolvedValue(undefined),+}));+vi.mock('./agentRunnerSync.js', () => ({ syncRunnerAgents: vi.fn().mockResolvedValue(0) }));+vi.mock('./agentRunnerOutputBatchers.js', () => ({ flushRunnerOutputBatcher: vi.fn().mockResolvedValue(undefined) }));+vi.mock('./worktreeManager.js', () => ({ cleanupOrphanedWorktrees: vi.fn() }));+vi.mock('./creativeDirector/local.js', () => ({+ updateRun: vi.fn().mockResolvedValue(undefined),+ getProject: vi.fn().mockResolvedValue(null),+}));+vi.mock('./creativeDirector/planAdvance.js', () => ({ advanceAfterPlanStepSettled: vi.fn().mockResolvedValue(undefined) }));+vi.mock('./creativeDirector/completionHook.js', () => ({ advanceAfterSceneSettled: vi.fn().mockResolvedValue(undefined) }));+++import { resumeAgent } from './agentManagement.js';+import { dispatchAgentRun } from './agentSpawnDispatch.js';+import { forceSpawnTask, addTask, getTaskById } from './cos.js';+import { completeAgent } from './cosAgentLifecycle.js';+import { spawnDirectly } from './agentCliSpawning.js';+import { setUseRunner } from './agentState.js';+import { updateClaimOwnership } from './cosClaimOwnership.js';+import { claimMergeAdmission } from './cosMergeAdmission.js';++const CLAIM_PROSE = 'Resume the claim swarm, preserve the worktrees, and ship all issues.';+const reviewers = ['provider:antigravity-cli'];+const reviewConfig = { reviewers, optionalReviewers: reviewers, reviewerMaxRounds: { 'provider:antigravity-cli': 2 },+ reviewerModels: { 'provider:antigravity-cli': 'gemini-3.8-flash' }, reviewerEfforts: { 'provider:antigravity-cli': 'low' } };+beforeEach(() => {+ vi.clearAllMocks(); setUseRunner(false); f.prompt = null;+ f.tasks = { original: { id: 'original', taskType: 'user', status: 'blocked', description: CLAIM_PROSE,+ metadata: { claimFlow: true, swarmCount: 6, ...reviewConfig, reviewLoop: true, useWorktree: false, openPR: false,+ prompt: CLAIM_PROSE, blockedCategory: 'agent-paused', pausedAgentId: 'prior', app: 'example' } } };+ f.state = { agents: { prior: { id: 'prior', taskId: 'original', status: 'paused',+ metadata: { configClaimFlow: true, workspacePath: '/repos/example', taskType: 'user' } } }, mergeAdmissions: {} };+ persist();+ forceSpawnTask.mockImplementation(async taskId => {+ await dispatchAgentRun({ task: f.tasks[taskId], agentId: 'replacement-agent', instanceId: 'instance-example',+ toolExecution: { id: 'exec-example' }, laneName: 'standard',+ blockAndBail: message => { throw new Error(JSON.stringify(message)); },+ cleanupOnError: message => { throw new Error(message); },+ });+ return { success: true };+ });+});++describe('claim resume contract through spawn', () => {+ it.each(['blocked', 'completed', 'legacy'])('preserves an unpinned %s swarm through registration and admission', async kind => {+ if (kind === 'completed') f.tasks.original.status = 'completed';+ if (kind === 'legacy') {+ delete f.tasks.original.metadata.claimFlow;+ f.tasks.original.metadata.analysisType = 'claim-work';+ }+ const result = await resumeAgent('prior', { context: 'Keep the existing commits.' });+ expect(result.spawned).toBe(true);+ expect(f.tasks[result.taskId].metadata).toMatchObject({ claimFlow: true, swarmCount: 6, ...reviewConfig,+ useWorktree: false, openPR: false, prompt: CLAIM_PROSE });+ const registered = f.state.agents['replacement-agent'];+ expect(registered.metadata).toMatchObject({ configClaimFlow: true, claimPicksOwnBranch: true, configCodingOnMain: false });+ expect(registered.metadata.configReviewers).not.toHaveLength(0);+ expect(f.prompt).toContain('"agentId":"replacement-agent","action":"bind"');+ expect(f.prompt).toContain('"agentId":"replacement-agent","action":"acquire"');+ expect(f.prompt).toContain('antigravity-cli');+ expect(await updateClaimOwnership({ agentId: registered.id, action: 'bind', branch: 'claim/issue-42' })).toMatchObject({ bound: true });+ const lease = await claimMergeAdmission({ agentId: registered.id, action: 'acquire' });+ expect(lease.admitted).toBe(true);+ expect(await claimMergeAdmission({ agentId: registered.id, action: 'release', token: lease.token, outcome: 'leave-open' })).toMatchObject({ released: true });++ // A separate live owner remains protected even after the trusted replacement launches.+ f.state.agents.other = { ...registered, id: 'other', metadata: { ...registered.metadata, claimBranches: ['claim/issue-43'], claimSelectionPending: false } };+ persist();+ expect(await updateClaimOwnership({ agentId: registered.id, action: 'bind', branch: 'claim/issue-43' })).toEqual({ bound: false, reason: 'owner-active' });+ expect(f.state.agents.other.metadata.claimBranches).toEqual(['claim/issue-43']);+ });++ it('registers a legacy claim launch with the same authority its completion prompt declares', async () => {+ delete f.tasks.original.metadata.claimFlow;+ f.tasks.original.metadata.analysisType = 'claim-work';+ await forceSpawnTask('original');+ expect(f.prompt).toContain('"action":"acquire"');+ expect(await updateClaimOwnership({ agentId: 'replacement-agent', action: 'bind', branch: 'claim/issue-42' })).toMatchObject({ bound: true });+ });++ it('never turns copied claim prose or caller metadata into claim authority', async () => {+ f.tasks.original.metadata = { prompt: CLAIM_PROSE };+ f.state.agents.prior.metadata.configClaimFlow = false;+ persist();+ await resumeAgent('prior', { description: CLAIM_PROSE, metadata: { claimFlow: true }, claimFlow: true });+ expect(f.state.agents['replacement-agent'].metadata.configClaimFlow).toBe(false);+ expect(f.prompt).not.toContain('"action":"acquire"');+ expect(await updateClaimOwnership({ agentId: 'replacement-agent', action: 'bind', branch: 'claim/issue-42' })).toEqual({ bound: false, reason: 'claim-owner-unverified' });+ expect(await claimMergeAdmission({ agentId: 'replacement-agent', action: 'acquire' })).toMatchObject({ admitted: false, reason: 'claim-owner-unverified' });+ });++ it.each(['missing-task', 'legacy-missing-task', 'lost-contract', 'unreadable-task'])('blocks %s before retiring or spawning', async kind => {+ if (kind === 'lost-contract') f.tasks.original.metadata = { prompt: CLAIM_PROSE };+ else delete f.tasks.original;+ if (kind === 'legacy-missing-task') delete f.state.agents.prior.metadata.configClaimFlow;+ if (kind === 'unreadable-task') getTaskById.mockRejectedValueOnce(new Error('store unreadable'));+ const before = structuredClone(f.state);+ await expect(resumeAgent('prior', { description: CLAIM_PROSE, claimFlow: true })).rejects.toMatchObject({ code: 'AGENT_RESUME_CONTRACT_MISSING', status: 409 });+ expect(addTask).not.toHaveBeenCalled();+ expect(completeAgent).not.toHaveBeenCalled();+ expect(spawnDirectly).not.toHaveBeenCalled();+ expect(f.state).toEqual(before);+ });+});diff --git a/server/services/agentManagement.js b/server/services/agentManagement.jsindex 305b435371..bb3e02ba8b 100644--- a/server/services/agentManagement.js+++ b/server/services/agentManagement.js@@ -1,3 +1,5 @@+import { hasClaimFlowContract } from '../lib/claimFlowTaskTypes.js';+import { isFalsyMeta, isTruthyMeta } from '../lib/metadataFlags.js';import { maintenance } from '../lib/maintenanceAdmission.js';/*** Agent Management@@ -390,10 +392,24 @@ export async function resumeAgent(agentId, overrides = {}) {}const taskId = agent.taskId || agent.metadata?.taskId || null;- const task = taskId ? await getTaskById(taskId).catch(() => null) : null;+ let task = taskId ? await getTaskById(taskId).catch(() => null) : null;const taskType = task?.taskType || agent.metadata?.taskType || 'user';const mode = classifyResume(task, agentId);+ if (mode === 'requeued' || mode === 'new-task') {+ const priorClaim = isTruthyMeta(agent.metadata?.configClaimFlow) || hasClaimFlowContract({ ...agent, taskType: agent.metadata?.taskType });+ // Missing task metadata cannot be reconstructed from caller prose. Only a+ // positively generic registration may use the historical description fallback.+ if ((!task && (priorClaim || !isFalsyMeta(agent.metadata?.configClaimFlow)))+ || (task && priorClaim && !hasClaimFlowContract(task))) {+ throw new ServerError('Resume blocked: the original task configuration is unavailable, so claim authority cannot be verified. Restore the original task or start a new task from its configured workflow.', {+ status: 409, code: 'AGENT_RESUME_CONTRACT_MISSING'+ });+ }+ if (hasClaimFlowContract(task)) {+ task = { ...task, metadata: { ...task.metadata, claimFlow: true } };+ }+ }let resumed;switch (mode) {case 'requeued':@@ -620,7 +636,10 @@ async function requeuePausedTask({ task, taskType, overrides }) {// `pending` is non-terminal, so the pointer that write lands survives it// (updateTask only strips a resume pointer on a terminal status).const result = await reviveBlockedTask(task.id, {- metadata: resumeOverrideMetadata(overrides, task.metadata)+ metadata: {+ ...resumeOverrideMetadata(overrides, task.metadata),+ ...(hasClaimFlowContract(task) ? { claimFlow: true } : {})+ }}, taskType);if (result?.error) {throw new ServerError(`Failed to requeue task ${task.id}: ${result.error}`, {diff --git a/server/services/agentManagement.test.js b/server/services/agentManagement.test.jsindex 50d64f5063..05ebfc3cdb 100644--- a/server/services/agentManagement.test.js+++ b/server/services/agentManagement.test.js@@ -1277,7 +1277,8 @@ describe('resumeAgent — requeues the paused agent\'s own task', () => {expect(addTask).not.toHaveBeenCalled();});- it('falls back to a fresh task when the task was deleted outright', async () => {+ it.each([false, 'false'])('keeps the missing-task fallback for generic posture %s', async configClaimFlow => {+ getAgentRecord.mockResolvedValue({ ...PAUSED_AGENT, metadata: { ...PAUSED_AGENT.metadata, configClaimFlow } });getTaskById.mockResolvedValue(null);await expect(resumeAgent('agent-paused-1')).resolves.toMatchObject({ mode: 'new-task' });});diff --git a/server/services/taskTypeHooks.js b/server/services/taskTypeHooks.jsindex 614831f54b..87ebb2d850 100644--- a/server/services/taskTypeHooks.js+++ b/server/services/taskTypeHooks.js@@ -51,7 +51,7 @@import { isFalsyMeta, isTruthyMeta } from './agentState.js';import { TRACKER_FILING_TASK_TYPES, CONCRETE_WORK_TRACKERS } from '../lib/workTracker.js';import { isAuditTaskType } from '../lib/auditCatalog.js';-import { CLAIM_FLOW_TASK_TYPES } from '../lib/claimFlowTaskTypes.js';+import { hasClaimFlowContract } from '../lib/claimFlowTaskTypes.js';// taskType → { load }. `load` is the module import thunk; a module may export// either or both hooks, and a missing export means "no hook of that kind for this@@ -235,8 +235,7 @@ export function isNonCommittingCoordinatorTask(task) {* type set is the backstop for records carrying only the scheduled type.*/export function isClaimFlowDispatch(task) {- if (isTruthyMeta(task?.metadata?.claimFlow)) return true;- return CLAIM_FLOW_TASK_TYPES.has(resolveTaskHookType(task));+ return hasClaimFlowContract(task);}/**