Skip to content

Fix task takeover planning and PR output#126

Closed
eshulman2 wants to merge 25 commits into
mainfrom
pr112-remove-task-takeover-settings
Closed

Fix task takeover planning and PR output#126
eshulman2 wants to merge 25 commits into
mainfrom
pr112-remove-task-takeover-settings

Conversation

@eshulman2

Copy link
Copy Markdown
Collaborator

Summary

This PR fixes several task takeover workflow gaps found while testing standalone README-update tickets. It makes triage flexible enough for small contained tasks, moves planning to the agent-based pattern used by feature planning, records repo scope from generated plan tags, and makes task takeover PR descriptions use the shared Forge PR body format.

Changes

Task Takeover Triage

  • Relaxed triage so small, contained tasks do not require formal Problem Statement, Proposed Solution/Approach, and Acceptance Criteria sections.
  • Updated triage prompt tests to cover the flexible rubric.

Task Takeover Planning

  • Replaced pre-clone/container planning with direct ForgeAgent planning using repository/GitHub tools.
  • Added a dedicated task-takeover-planning skill.
  • Required generated plans to include valid repo:/ tags from configured project repos.
  • Added the selected repo labels back to Jira tickets and stored current_repo/repos_to_process from plan tags.
  • Tightened the planning prompt to require repository-relative target paths.

Task Takeover PR Creation

  • Reused the shared PR body generator and fallback template from the main PR workflow.
  • Removed the bespoke task takeover PR body text.

Testing

  • uv run pytest tests/unit/workflow/nodes/test_task_takeover_planning.py tests/unit/prompts/test_prompt_templates.py
  • uv run pytest tests/unit/workflow/nodes/test_task_takeover_pr.py tests/unit/workflow/nodes/test_pr_creation_pr_number.py tests/unit/workflow/nodes/test_code_review.py
  • uv run pytest tests/unit/workflow/nodes/test_task_takeover_pr.py tests/unit/workflow/nodes/test_task_takeover_execution.py tests/unit/workflow/task_takeover/test_graph.py tests/workflow/test_task_takeover_graph.py
  • uv run ruff check src/forge/workflow/nodes/task_takeover_planning.py src/forge/workflow/nodes/task_takeover_pr.py src/forge/workflow/nodes/task_takeover_triage.py tests/unit/workflow/nodes/test_task_takeover_planning.py tests/unit/workflow/nodes/test_task_takeover_pr.py tests/unit/prompts/test_prompt_templates.py

Related Tickets

  • AISOS task takeover testing: AISOS-2117, AISOS-2121, AISOS-2125

Generated by Forge SDLC Orchestrator

forgeSmith-bot and others added 25 commits June 29, 2026 15:34
… Task Takeover

Detailed description:
- Modified src/forge/config.py to add TaskTakeoverLabels and TaskTakeoverSettings Pydantic models.
- Added task_takeover field of type TaskTakeoverSettings to the Settings class.
- Added unit tests in tests/unit/test_config_prd.py to verify default task takeover settings and custom overrides.

Closes: AISOS-1984
Detailed description:
- Added new TASK_TAKEOVER, TASK_TRIAGE_PENDING, TASK_PLAN_PENDING, and TASK_PLAN_APPROVED constants to the ForgeLabel enum in src/forge/models/workflow.py.
- Added tests in tests/unit/models/test_workflow.py confirming these labels are properly defined and mapped.

Closes: AISOS-1985
…heck bypass

Detailed description:
- Modified 'src/forge/api/routes/jira.py' to detect task-takeover trigger labels in either 'issue_labels' or 'changelog_items'.
- Bypassed 'forge:parent' label requirements for standalone Epic/Task issues when any task-takeover trigger label is present.
- Routed standalone task webhook events to the queue under their own identity as 'routing_ticket_key'.
- Added unit tests in 'tests/unit/api/routes/test_jira_webhook.py' verifying the bypass logic and queue publishing parameters.

Closes: AISOS-1986
Detailed description:
- Created TaskTakeoverWorkflow class inheriting from BaseWorkflow.
- Implemented state_schema property returning TaskTakeoverState.
- Implemented .matches() method matching only when exact forge:managed label is present alongside exact takeover trigger labels (including custom settings label).
- Ensured no prefix-matching on forge:managed is performed for trigger matching.
- Added placeholder build_graph returning a mock StateGraph.
- Registered TaskTakeoverWorkflow first in default router to ensure precedence.
- Created unit tests validating TaskTakeoverWorkflow matches conditions, state schema, and routing precedence.

Closes: AISOS-1987
…exact router matching

Detailed description:
- Updated WorkflowRouter.resolve inside src/forge/workflow/router.py to filter out any prefix-based triggers for the Task Takeover Workflow, ensuring that only exact matching is used for trigger resolution.
- Verified priority registration where TaskTakeoverWorkflow is registered before BugWorkflow in src/forge/workflow/registry.py.
- Added tests to tests/unit/workflow/test_router.py to verify that accidental prefix-based trigger labels do not trigger TaskTakeoverWorkflow.
- Added tests to tests/unit/workflow/test_registry.py to verify that conflicting labels correctly prioritize TaskTakeoverWorkflow over BugWorkflow.

Closes: AISOS-1988
…rchestrator Worker

Detailed description:
- Modify worker.py to handle planning-approval states for task_plan_approval_gate.
- Recognize forge:task-plan-approved label addition and map task_plan_approval_gate to 'task_plan' stage.
- Add task_plan_approval_gate to the _YOLO_GATES set to support automated bypass mode.
- Update set_workflow_label in Jira client to preserve forge:managed:task and forge:managed:task-takeover labels during transitions.
- Add unit tests verifying task plan approval, YOLO gate, and identity preservation.

Closes: AISOS-1989
Detailed description:
- Added triage_passed, triage_missing_fields, and plan_content fields to TaskTakeoverState in src/forge/workflow/task_takeover/state.py, and updated create_initial_task_takeover_state to set appropriate default values.
- Implemented build_task_takeover_graph and route_entry in src/forge/workflow/task_takeover/graph.py to structure the StateGraph for Task Takeover workflow.
- Updated TaskTakeoverWorkflow.build_graph in src/forge/workflow/task_takeover/__init__.py to import and construct the compiled StateGraph.
- Added comprehensive unit tests in tests/unit/workflow/task_takeover/test_graph.py to validate the state defaults, route entry resume mapping, conditional triage checks, and correct StateGraph compilation.

Closes: AISOS-1990
Detailed description:
- Created task-takeover-triage.md to strictly evaluate Problem Statement, Proposed Solution/Approach, and Acceptance Criteria.
- Created task-takeover-planning.md to direct agents to map solutions to repository files and test plans.
- Created task-takeover-qa.md for answering clarifying questions during interactive planning gates.
- Updated unit tests in tests/unit/prompts/test_prompt_templates.py to verify template loading and correctness.

Closes: AISOS-1991
Detailed description:
- Created the triage_task node under src/forge/workflow/nodes/task_takeover_triage.py to verify Problem Statement, Proposed Solution/Approach, and Acceptance Criteria for Task Takeover tickets.
- Exported triage_task in src/forge/workflow/nodes/__init__.py.
- Wired the state graph in src/forge/workflow/task_takeover/graph.py to route through the new triage_task node and handle transitioning.
- Added comprehensive unit tests in tests/unit/workflow/nodes/test_task_takeover_triage.py verifying first-run comments, resume bypass, missing fields comments/label, and error retry escalation.

Closes: AISOS-1992
Detailed description:
- Implemented the generate_plan async node in src/forge/workflow/nodes/task_takeover_planning.py. It clones the target repository, gathers codebase file structure/metadata, and invokes a sandboxed ContainerRunner task utilizing the task-takeover-planning.md prompt.
- Handled safely writing the generated plan to .forge/plan.md and posting a safely-truncated comment to Jira (with a truncation message if it exceeds 25,000 characters).
- Applied the forge:task-plan-pending label to the ticket and transitioned to plan_approval_gate with is_paused=True.
- Connected the generate_plan node, plan_approval_gate, and route_plan_approval router within the StateGraph in src/forge/workflow/task_takeover/graph.py.
- Refined orchestrator worker's resume handling in src/forge/orchestrator/worker.py to support Task-level plan approval resumption and transition labels correctly.
- Added 8 unit tests in tests/unit/workflow/nodes/test_task_takeover_planning.py to verify plan generation, comment truncation, retry policy, and comment revision/feedback parsing flows.

Closes: AISOS-1993
Detailed description:
- Created task_plan_approval_gate and route_task_plan_approval in task_plan_approval.py to handle human-in-the-loop plan reviews for Task Takeover workflow.
- Integrated route_task_plan_approval with comment_classifier to route comment revision requests starting with '!' to regenerate_plan, questions starting with '?' or '@forge ask' to answer_question, and label change to 'forge:task-plan-approved' to setup_workspace.
- Connected the new gate node, routing, and answer_question in task_takeover graph.
- Enhanced qa_handler and agent to leverage the task-takeover-qa prompt template for task plan approval gate Q&A.
- Added comprehensive unit tests for task plan approval gates and updated existing planning and Q&A tests.

Closes: AISOS-1994
Detailed description:
- Created unit and integration tests for task takeover triage logic in 'tests/workflow/test_task_takeover_triage.py' to cover all complete and incomplete mandatory sections permutations, mocking LLM outputs.
- Created LangGraph path transitions and interactive gates routing tests in 'tests/workflow/test_task_takeover_graph.py'.
- Verified that workflow identity labels 'forge:managed:task' and 'forge:managed:task-takeover' are preserved exactly during label state transitions.

Closes: AISOS-1995
Detailed description:
- Created the task execution node in src/forge/workflow/nodes/task_takeover_execution.py implementing execute_task_changes async function.
- Integrated ContainerRunner to run task modifications and automated tests inside a sandboxed container.
- Handled staging, committing, and recording of logs, execution results, and commit info in state using GitOperations.
- Added comprehensive unit tests in tests/unit/workflow/nodes/test_task_takeover_execution.py and verified with full type-safety under mypy and ruff.

Closes: AISOS-1996
Detailed description:
- Created the task takeover qualitative review node `src/forge/workflow/nodes/task_takeover_review.py` with the `run_qualitative_review` function.
- Added prompt template `src/forge/prompts/v1/task-takeover-review.md` implementing explicit assertions for Acceptance Criteria fulfillment and Automated Test Coverage.
- Added fields `review_verdict`, `review_feedback`, `qualitative_review_retry_count`, and `qualitative_review_failed` to `TaskTakeoverState`.
- Registered the new review node in `src/forge/workflow/nodes/__init__.py`.
- Wrote 10 comprehensive unit and integration tests in `tests/unit/workflow/nodes/test_task_takeover_review.py` and registered the new template.

Closes: AISOS-1997
Detailed description:
- Created src/forge/workflow/nodes/task_takeover_pr.py implementing the create_task_takeover_pr node to push implementation branch changes, open a GitHub pull request, comment the markdown PR link on Jira, transition the issue to "In Review", and clean up workspace/container sandbox resources.
- Registered and exported create_task_takeover_pr node in src/forge/workflow/nodes/__init__.py.
- Integrated the new node along with setup_workspace, execute_task_changes, and run_qualitative_review into the task takeover StateGraph in src/forge/workflow/task_takeover/graph.py and updated route_entry routing.
- Wrote unit and integration tests under tests/unit/workflow/nodes/test_task_takeover_pr.py validating all functionality.

Closes: AISOS-1998
Detailed description:
- Created 'tests/workflow/test_qualitative_review.py' containing comprehensive unit and integration tests.
- Tested the qualitative reviewer verdict parsing and acceptance criteria extraction logic with various realistic LLM review outputs.
- Validated state updates (verdict, feedback, retry counts, failed flag) for both passing (adequate) and failing (tests_incomplete) reviews.
- Verified node behavior under valid vs invalid diff structures to assert proper validation of requirements and automated test coverage.
- Aligned test patterns with nearby code structures in 'tests/unit/workflow/nodes/test_local_reviewer.py'.

Closes: AISOS-1999
Detailed description:
- Created tests/sandbox/test_task_execution.py with comprehensive integrated sandbox and workflow execution tests.
- Verified successful container execution with ContainerRunner including command construction, memory and CPU limits, and workspace mounting.
- Verified test-and-build recovery workflows by simulating compilation errors/test failures, asserting logs are captured back to the workflow state, and verifying successful self-correction and git commit on subsequent retry.
- Added workspace and container lifecycle teardown/cleanup assertions evaluating cleanup_podman_containers and teardown_workspace to ensure secure resource management.

Closes: AISOS-2000
Detailed description:
- Connected execution flow nodes (setup_workspace, execute_task_changes, run_qualitative_review, create_task_takeover_pr) in Task Takeover StateGraph inside src/forge/workflow/task_takeover/graph.py.
- Added _route_after_qualitative_review conditional routing logic which transitions back to execution on failed or incomplete verdicts up to the configured review_max_attempts limit, and routes to PR on adequate reviews or escalate_blocked when limit is reached.
- Registered the new review_max_attempts configuration in TaskTakeoverSettings inside src/forge/config.py with a default of 2.
- Updated execute_task_changes in src/forge/workflow/nodes/task_takeover_execution.py to inject previous qualitative review feedback into the agent prompt, establishing a smart self-correction loop.
- Added comprehensive unit and integration tests to verify graph compilation, node mapping, and conditional routing logic.

Closes: AISOS-2001
Detailed description:
- Fixed ADF description parsing in src/forge/integrations/jira/models.py to handle empty docs correctly.
- Added add_structured_comment to mock JiraClient in test_prd_rejected.py to fix PRD regeneration test failures.
- Updated outdated comment and classification assertions in test_task_implementation_status.py and test_qa_mode.py.
- Fixed imports in test_task_handoff.py and redundant execution of 3rd pass in test_local_review_status_comments.py.
- Fixed unused imports in task_takeover_triage.py.

Closes: AISOS-1977-review
Detailed description:
- Updated CLAUDE.md to list new Task Takeover labels, identity preservation labels, and updated forge:yolo description.
- Updated docs/guide/labels.md to document the 'Task Takeover Workflow' labels and trigger labels.
- Updated docs/reference/config.md to document the task_takeover settings and Pydantic schema options.

Closes: AISOS-1977-docs
Detailed description:
- Extracted JIRA issue labels in worker and passed to router.resolve.
- Aligned JIRA webhook route and TaskTakeoverWorkflow matcher to allow standalone trigger-only takeover tickets and enforce task_takeover.enabled setting.
- Cleaned up clone workspace at the end of planning to prevent directory collision.
- Added task_plan_approval_gate to retry approval gates set.

Closes: AISOS-1977
…atch unit tests

Detailed description:
- Added an autouse 'mock_settings' fixture in 'TestDefaultRouter' ('tests/unit/workflow/test_registry.py') and 'TestWorkflowRouter' ('tests/unit/workflow/test_router.py').
- This enables the task takeover settings in those tests, since 'task_takeover.enabled' defaults to 'False' but must be 'True' for workflow matching and resolution tests to succeed.
- Verified that all unit tests, flow tests, and workflow tests pass cleanly.

Closes: AISOS-1977-review-review-impl
@eshulman2

Copy link
Copy Markdown
Collaborator Author

Closing this duplicate PR. The changes are being moved to the existing Task Takeover PR #112.

@eshulman2 eshulman2 closed this Jul 6, 2026
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.

2 participants