fix(flow): prevent premature task completion before review#280
Open
luoyanglang wants to merge 1 commit intocft0808:mainfrom
Open
fix(flow): prevent premature task completion before review#280luoyanglang wants to merge 1 commit intocft0808:mainfrom
luoyanglang wants to merge 1 commit intocft0808:mainfrom
Conversation
Contributor
Author
|
Heads-up: the current red check on this PR is from the repository's I opened a small follow-up fix at #281 using the conservative approach: skip the |
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
Issue: #191 - 六部派发闭环不稳定:任务常卡在中书省/尚书省
Type: Bug Fix
Severity: High
This PR closes one confirmed root cause behind Issue #191: tasks could be marked complete even when their todos were still unfinished. It aligns execution completion with the existing review flow, adds completion gates in the dashboard approval path, and adds regression coverage for both paths.
Root Cause
Two code paths could bypass the intended completion gate and write
Donetoo early:scripts/kanban_update.py:439cmd_done()wrotestate = 'Done'directly from execution states without validating whethertodoswere fully completed.dashboard/server.py:697handle_review_action(..., 'approve')allowedReview -> Donewithout checking todo completion, so the dashboard could also close tasks prematurely.scripts/file_lock.py:106atomic_json_update()wrote temp files without explicit UTF-8 encoding, which could raiseUnicodeEncodeErrorduring local reproduction when flow remarks contained emoji/Chinese text.That left three inconsistent completion semantics in the codebase:
Fix Description
Changed files:
scripts/kanban_update.py:234- add_todo_counts()and reuse it incmd_done()scripts/kanban_update.py:439- changecmd_done()from direct completion toReviewhandoff with todo gate and rejection auditdashboard/server.py:690- add_todo_progress()and blockReview -> Donewhen todos are incompletescripts/file_lock.py:106- force UTF-8 temp writes in atomic JSON updates on Windowstests/test_kanban.py- update expectations forcmd_done()and add incomplete-todo regression coveragetests/test_dashboard_review_action.py- add dashboard approval regression testsWhy this approach:
Reviewstate instead of introducing a new completion path.Donetransition in the review layer, which matches the current workflow semantics better than letting execution agents close tasks outright.Known limitation:
Test Results
pytest tests/test_kanban.py tests/test_dashboard_review_action.pycmd_done()handoff behavior and dashboard review completion gatespython -m py_compile scripts/file_lock.py scripts/kanban_update.py dashboard/server.py tests/test_kanban.py tests/test_dashboard_review_action.pyManual reproduction before fix:
Doingtask withtodosat2/5complete.cmd_done().Donedirectly.Result after fix:
Done.Reviewfor final approval.approveinReviewnow rejects incomplete todos instead of closing the task.Disprove Analysis
Is this already fixed elsewhere?
2026-04-12; it is still open.191and did not find an in-flight fix covering this path.b7ad34aand4e51e34improved dispatch/retry behavior, but they did not close this completion-gate gap.Default flow regression risk
cmd_done()now returns work toReview, which preserves the existing review step instead of bypassing it.cmd_state('Review', 'Done')behavior is unchanged.Edge cases considered
cmd_done()still allows handoff toReview.Review: dashboard approval now rejects completion with an explicit error.Known limitation
Checklist
#191)Found during issue triage and local reproduction. Happy to adjust if you prefer a different completion gate shape.