Skip to content

refactor: extract helpers from generateManagedAppImprovementTaskForType (#2836)#2864

Open
atomantic wants to merge 2 commits into
mainfrom
claim/issue-2836
Open

refactor: extract helpers from generateManagedAppImprovementTaskForType (#2836)#2864
atomantic wants to merge 2 commits into
mainfrom
claim/issue-2836

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Summary

generateManagedAppImprovementTaskForType() in server/services/cosTaskGenerator.js had grown to ~533 lines, mixing metadata assembly, override sanitization, precondition/perpetual-work gating, deterministic reconcile pre-steps, and watcher polling in one function. This extracts that logic into named helpers (mirroring existing siblings like checkStagePrecondition), leaving the main function a thin orchestrator.

New module-level helpers (all behavior-preserving, moved verbatim):

  • buildImprovementTaskMetadata — base metadata + sanitized global/per-app override merge
  • resolveTaskInputHook — buildTaskInput hook ({ skip } / { hookPrompt, hookOverride })
  • resolveClaimWorkRouting — claim-work single-source router → promptTaskType
  • applyPerpetualWorkGate — perpetual drain work-detector gate
  • resolveBranchReconcileBlock / resolveIssueReconcileBlock — deterministic reconcile pre-steps
  • resolveReferenceWatchBlock / resolvePrWatcherBlock — watcher polling + prompt-block injection

Each gate-checking helper returns a discriminated { skip } result the orchestrator forwards as its return null, and the block-producing helpers return an empty block for non-matching task types — so dispatch ordering, park/convergence semantics, cadence recording, and every early-return path are unchanged.

Test plan

  • cd server && npm test -- cosTaskGenerator — 63 pass (source-pinned wiring guards for claim-work routing, {reviewers} interpolation, swarm block, model-literal, etc. all still green)
  • cd server && npm test -- cosTask cos.test taskSchedule — 510 pass across 8 suites
  • Runtime import smoke-check confirms the module loads and all public exports remain functions

Closes #2836

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract helpers from generateManagedAppImprovementTaskForType() in cosTaskGenerator.js

1 participant