[AISOS-2159] Workflow continues to PR creation after container execution failure #159
[AISOS-2159] Workflow continues to PR creation after container execution failure #159ekuris-redhat wants to merge 11 commits into
Conversation
… in task takeover Detailed description: - Modified routing logic in graph.py to prevent proceeding to PR creation when the maximum retry count is reached but container execution failed or when no changes/commits exist on the branch. In these error cases, the workflow routes to escalate_blocked instead of proceeding to create_pr. - Added unit tests in test_task_takeover_graph.py to cover these new routing behaviors and ensure robustness. Closes: AISOS-2159
Detailed description: - Added comprehensive unit tests in tests/unit/workflow/task_takeover/test_graph.py to verify routing in the task takeover workflow's _route_after_qualitative_review function when retry limit is reached. - Confirmed that routing correctly escalates to 'escalate_blocked' if no changes were committed or if there is an active error, and successfully proceeds to 'create_pr' only if changes were successfully committed and no active error exists. Closes: AISOS-2159
…review routing Detailed description: - Updated the "Qualitative Review" section of the task-workflow guide to document the new routing conditions. - Specifically noted that when the retry limit is hit, the workflow only proceeds to PR creation if there is no active error and changes have been successfully committed. Otherwise, it escalates to blocked. Closes: AISOS-2159-docs
|
Tested locally with Podman stopped (podman machine stop):
Before this fix, the same scenario would proceed to create_pr and fail with a 422 from GitHub. |
|
/forge rebase |
|
Rebase triggered by @eshulman2 Merging |
Auto-committed by Forge container fallback.
|
Merge conflicts resolved and pushed. The PR branch has been updated. Resolved files: |
| else getattr(commit_info, "committed", False) | ||
| ) | ||
|
|
||
| if last_error or not committed: |
There was a problem hiding this comment.
commit_info.committed only describes the latest execution attempt. A previous attempt may already have created a valid commit, while a feedback retry that produces no additional changes overwrites this flag with false; reaching the review cap then escalates even though the branch contains PR-worthy changes. Please check the branch against its base (or preserve cumulative commit state) instead of relying on the latest attempt’s flag.
| else getattr(commit_info, "committed", False) | ||
| ) | ||
|
|
||
| if last_error or not committed: |
There was a problem hiding this comment.
The earlier if last_error and not verdict branch still returns create_pr at the retry limit, bypassing this new active-error safeguard. run_qualitative_review exceptions produce exactly that state (last_error set and review_verdict=None), so this check is never reached. Please route that case to escalate_blocked as documented, and test the state shape produced by the review node.
|
Forge is addressing PR review feedback now. This status update is informational. |
…l code review Detailed description: - Fixed an outdated assertion in in to match the newly implemented routing behavior where active-error review infrastructure failures escalate to blocked instead of proceeding to PR creation. - Verified all tests and linting check out correctly. Closes: AISOS-2159-review-review-impl
Auto-committed by Forge container fallback.
eshulman2
left a comment
There was a problem hiding this comment.
The state-based guard is the right fix, but the Git fallback should be removed. It adds filesystem I/O to a routing function, relies on the private _run_git API, hard-codes origin/main, and can allow an active last_error to proceed to PR creation when an earlier commit exists.
Please make the following changes:
- Remove the Git fallback block from
_route_after_qualitative_reviewand drop thePath,GitOperations, andWorkspaceimports. - Keep the router pure and state-driven: an active
last_errormust always route toescalate_blocked; at the retry cap, proceed only whencommit_info.committedis true. - Fix
commit_info.committedat its source intask_takeover_execution.py. It currently describes only the latest execution attempt, so a no-op feedback retry can overwrite an earlier successful commit withfalse. Preserve the successful/cumulative committed state once the branch has a valid implementation commit. - Add a typed
commit_infofield (preferably backed by a dedicatedTypedDict) toTaskTakeoverStateand initialize it consistently if appropriate. - Update
_route_after_qualitative_review’s docstring to describe the retry-cap, active-error, and committed-state behavior. - Add regression coverage for an earlier successful commit followed by a no-op feedback retry, plus the invariant that
last_erroralways blocks PR creation.
Items 1 and 3 need to land together: simply removing the fallback while retaining the current per-attempt committed semantics would falsely block branches that already contain valid changes.
|
Forge is addressing PR review feedback now. This status update is informational. |
…ask takeover execution sandbox tests Detailed description: - Fixed test failures in tests/sandbox/test_task_execution.py where GitOperations was being mocked directly on task_takeover_execution. - Since execute_task_changes now uses prepare_workspace to obtain the workspace_path and git helper, the test mocks have been updated to mock prepare_workspace instead of GitOperations. Closes: AISOS-2159-review-review-impl
|
/forge rebase |
|
Rebase triggered by @eshulman2 Merging |
Auto-committed by Forge container fallback.
|
Merge conflicts resolved and pushed. The PR branch has been updated. Resolved files: |
|
Rebase triggered by @ekuris-redhat Merging |
Summary
This pull request resolves a critical issue in the Task Takeover workflow where a failure in the container execution environment (such as Podman being unavailable) or an absence of code changes would still erroneously proceed to pull request creation, resulting in 422 Unprocessable Entity errors from GitHub. By validating the active error state and checking that a valid commit was actually made on the branch when the qualitative review retry limit is reached, we ensure that empty or broken workflows gracefully escalate to blocked rather than attempting to open invalid pull requests.
Changes
Core Workflow Logic
src/forge/workflow/task_takeover/graph.py: Modified the_route_after_qualitative_reviewrouting function to verify thatstate.last_erroris empty and that a successful commit was recorded (state.commit_info.committed) before transitioning to PR creation. If an active error exists or no changes are committed when the retry limit is exhausted, the workflow now routes toescalate_blocked.Documentation
docs/guide/task-workflow.md: Updated the "Qualitative Review" section to explicitly document this new fallback routing logic, ensuring engineering documentation matches the runtime execution rules.Test Suite
tests/unit/workflow/task_takeover/test_graph.py: Added comprehensive unit tests to validate the updated routing behavior under multiple conditions:test_route_after_qualitative_review_no_changes_escalates(verifies escalation when no changes/commits exist)test_route_after_qualitative_review_with_last_error_escalates(verifies escalation when an active error is recorded)test_route_after_qualitative_review_with_changes_creates_pr(verifies PR creation when there is a successful commit and no active error)tests/sandbox/test_task_execution.py: Updated GitOperations mocking to mockprepare_workspaceinstead of mockingGitOperationsdirectly ontask_takeover_executionto align with the workspace-path and git helper acquisition logic.Implementation Notes
stateobject variables (state.last_errorandstate.commit_info), preserving clean architectural separation.Testing
tests/unit/workflow/task_takeover/test_graph.pyto cover all boundary states of the qualitative review retry routing, and updated sandbox execution tests to reflect mock alignment.Related Tickets
Generated by Forge SDLC Orchestrator