feat(runtime): replan oversized tasks after repeated recovery failures#131
Open
feat(runtime): replan oversized tasks after repeated recovery failures#131
Conversation
#104) Add an optional replanning stage that triggers after repeated recovery failures, splitting oversized tasks into smaller sub-tasks instead of repeatedly remediating the same broad unit. Config: Add options.replanning block (enabled, triggerAttempts, maxSubtasks, minIssueOverlapForTrigger). Orchestrator: Detect non-convergence via issue-set overlap across parity retry attempts. Trigger replanning when threshold met. Invoke task-decomposer to split failing task, generate deterministic sub-task IDs (task-001a, task-001b, ...), inject into Phase 4 queue with dependency-safe rewiring. Depth-1 guard prevents recursive replanning of sub-tasks. Checkpoint: Record replanning events and blocked tasks for resume safety. Replay prior replanning on resume, skip completed sub-tasks. Schema: Relax ID patterns to ^task-[0-9]+[a-z]?$ for sub-task IDs. TaskQueue: Add replaceWithSubtasks() for queue injection. Tests: New task-decomposer-schema tests, replanning trigger detection, sub-task generation, maxSubtasks enforcement, depth guard, checkpoint resume, and observability event tests.
Forward parityIssues, lineRange, parentTaskId, sourceFiles, and targetFiles into the task-decomposer agentPayload during Phase 4 replanning so the agent has the failing task's scope and unresolved issues. Change replanning to mark the parent task as completed (not blocked) since its work is now represented by the generated sub-tasks. Update TaskQueue.replaceWithSubtasks(), checkpoint calls, and resume logic accordingly. Remove the now-unnecessary replannedParentIds skip in the resume path. Add context-builder tests for replanning payload forwarding and update orchestrator replanning tests to assert completedTasks.
…#104) Replace the incorrect completed/blocked marking of replanned parents with a dedicated "replanned" state that properly handles dependencies and interruption recovery. TaskQueue: Add replanned set and subtaskMap. getReady() skips replanned tasks. isComplete() treats them as terminal. isDepSatisfied() resolves a replanned dependency only when ALL of its replacement sub-tasks are completed or blocked, so downstream tasks correctly wait for sub-task completion. Checkpoint: Add replannedTasks[] field with replanTask() method that moves the parent out of failedTasks/blockedTasks into replannedTasks. Backward-compat default for old checkpoints without the field. Orchestrator: replanTask() calls checkpoint.replanTask() instead of completeTask(). Resume path replays replanning events, then applies replannedTasks from checkpoint. Result filtering excludes replanned parents from failed/blocked lists. Progress: Track replanned status in progress writer for observability. Interruption safety: The checkpoint write order is: 1. recordReplanningEvent() — persists parent→subtask mapping 2. replanTask() — marks parent as replanned On resume, replanning events are replayed first (restoring sub-tasks into the queue), then replannedTasks are applied. If interrupted between steps 1 and 2, the parent is still in the original plan and the replanning event triggers replay; if before step 1, nothing happened and the parent retries from scratch. Tests: Add 6 checkpoint tests for replannedTasks lifecycle. Update orchestrator replanning tests to use replanTask().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional replanning stage that triggers after repeated recovery failures, so AAMF can split or re-scope an oversized task instead of repeatedly remediating the same broad unit.
Closes #104
Changes
Config (
schema.ts)options.replanningconfig block:enabled,triggerAttempts,maxSubtasks,minIssueOverlapForTriggerTypes (
agents/types.ts)parentTaskIdfield toMigrationTaskfor tracking sub-task lineageOrchestrator (
core/orchestrator.ts)replanTask(): invoketask-decomposeragent to split failing task → generate deterministic sub-task IDs (task-001a,task-001b, ...)Checkpoint (
core/checkpoint.ts)recordReplanningEvent(): persist replanning events for resume safetyblockTask(): mark parent tasks as blocked after replanningreplanningEventsin checkpoint stateTask Queue (
execution/task-queue.ts)replaceWithSubtasks(): mark parent as blocked + inject sub-tasks into active task mapSchema (
task-decomposer.tasks.schema.json)^task-[0-9]+[a-z]?$to support sub-task IDsResume support
Observability
task-replannedandsubtasks-injectedeventsTests
task-decomposer-schema.test.ts(7 cases for ID pattern validation)