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: delegate isClaimFlowTask to isClaimFlowDispatch

Adam Eivyb5ec3a2b220f
diff --git a/server/lib/claimFlowTaskTypes.test.js b/server/lib/claimFlowTaskTypes.test.js
index bdcaccaf04..b1a511cf25 100644
--- a/server/lib/claimFlowTaskTypes.test.js
+++ b/server/lib/claimFlowTaskTypes.test.js
@@ -45,12 +45,22 @@ describe('CLAIM_FLOW_TASK_TYPES is declared exactly once', () => {
});
it.each([
- ['services/agentPromptBuilder.js', 'reads the set back via isClaimFlowTask()'],
- ['services/cosTaskGenerator.js', 'stamps metadata.claimFlow from the set'],
- ])('%s imports the shared set (%s)', (relPath) => {
+ // The prompt side delegates to isClaimFlowDispatch (taskTypeHooks.js), which
+ // imports the set — the read side consumes the shared set transitively while
+ // finalization/learning resolve the SAME shapes (#6613 writer/reader guard).
+ ['services/agentPromptBuilder.js', 'reads the set back via isClaimFlowDispatch()', false],
+ ['services/cosTaskGenerator.js', 'stamps metadata.claimFlow from the set', true],
+ ])('%s imports the shared set (%s)', (relPath, _desc, direct) => {
const source = readFileSync(join(SERVER_DIR, relPath), 'utf8');
- expect(source).toMatch(/import\s*\{[^}]*\bCLAIM_FLOW_TASK_TYPES\b[^}]*\}\s*from\s*'\.\.\/lib\/claimFlowTaskTypes\.js'/);
expect(LOCAL_DECLARATION.test(source)).toBe(false);
+ if (direct) {
+ expect(source).toMatch(/import\s*\{[^}]*\bCLAIM_FLOW_TASK_TYPES\b[^}]*\}\s*from\s*'\.\.\/lib\/claimFlowTaskTypes\.js'/);
+ } else {
+ expect(source).toMatch(/import\s*\{[^}]*\bisClaimFlowDispatch\b[^}]*\}\s*from\s*'\.\/taskTypeHooks\.js'/);
+ // The delegation itself must stay — dropping it would narrow the prompt
+ // side back to analysisType-only and split writer from reader again.
+ expect(source).toMatch(/isClaimFlowDispatch\(task\)/);
+ }
});
});
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.js
index d5cb1d4ddc..e98ee4df65 100644
--- a/server/services/agentPromptBuilder.js
+++ b/server/services/agentPromptBuilder.js
@@ -20,7 +20,7 @@ import { getDigitalTwinForPrompt } from './digital-twin.js';
import { taskContextBlock } from '../lib/cosTaskPrompt.js';
import { PR_COMPLETIONS, leavesPrForHuman, resolvePrCompletion } from '../lib/prDisposition.js';
// Shared with cosTaskGenerator.js, which stamps the same set as metadata.claimFlow.
-import { CLAIM_FLOW_TASK_TYPES } from '../lib/claimFlowTaskTypes.js';
+import { isClaimFlowDispatch } from './taskTypeHooks.js';
import { getCodeReviewDefaults } from './codeReview.js';
import { LIGHT_CONTEXT_PROVIDER_TYPES, SIMPLIFY_INLINE_REVIEW } from './promptSections/constants.js';
import { detectSkillTemplates, getAgentInstructionsContext, loadSkillTemplates } from './promptSections/instructions.js';
@@ -113,8 +113,15 @@ export function isUiAuditTask(task) {
}
export function isClaimFlowTask(task, isTruthyMetaFn = (value) => value === true || value === 'true') {
+ // Delegates to isClaimFlowDispatch (taskTypeHooks.js) so the prompt-side
+ // claim posture and the finalization/learning-side exemption resolve the
+ // SAME task shapes — that predicate reads the marker plus the full
+ // analysisType → taskAnalysisType → taskType chain, covering an archived
+ // projection or a bare taskType this narrower chain used to miss (the #6613
+ // writer/reader split, one shape over). The isTruthyMetaFn seam stays for
+ // the suites that inject it.
return isTruthyMetaFn(task?.metadata?.claimFlow)
- || CLAIM_FLOW_TASK_TYPES.has(task?.metadata?.analysisType);
+ || isClaimFlowDispatch(task);
}
/**