fix: P1-21 code-to-design 审计修复 — pending 分组 + apply_full_replace
- invalidate_by_adr 新增 pending 分组:ADR 直接关联的 TODO 任务也标记 INVALIDATED - apply_full_replace 保留 DISPATCHED 状态,不再保留 INVALIDATED(全量替换时重置) - 新增 2 项测试:apply_full_replace 状态保留 + 真实 git revert - 测试从 11→13 项,全部通过 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -89,8 +89,10 @@ class TaskGraph:
|
||||
self._add_edge(edge)
|
||||
|
||||
def apply_full_replace(self, nodes: list[TaskNode], edges: list[Edge]) -> None:
|
||||
"""全量替换模式:Arc 产出完整 DAG,保留已完成任务状态。"""
|
||||
done_status = {tid: n.status for tid, n in self.nodes.items() if n.status == "DONE"}
|
||||
"""全量替换模式:Arc 产出完整 DAG,保留已完成任务状态。
|
||||
INVALIDATED 状态不保留(已被级联失效标记的任务在全量替换时重置)。"""
|
||||
done_status = {tid: n.status for tid, n in self.nodes.items()
|
||||
if n.status in ("DONE", "DISPATCHED")}
|
||||
self.nodes = {n.id: n for n in nodes}
|
||||
self.edges = list(edges)
|
||||
for tid, status in done_status.items():
|
||||
@@ -267,6 +269,7 @@ class TaskGraph:
|
||||
affected = self.tasks_by_adr(adr_id)
|
||||
completed = [t for t in affected if t.status == "DONE"]
|
||||
in_progress = [t for t in affected if t.status == "DISPATCHED"]
|
||||
pending = [t for t in affected if t.status == "TODO"]
|
||||
|
||||
# 1. 冻结调度
|
||||
self.dispatch_frozen = True
|
||||
@@ -281,8 +284,13 @@ class TaskGraph:
|
||||
t.status = "INVALIDATED"
|
||||
delta.removed_tasks.append(t.id)
|
||||
|
||||
# 4. 级联失效下游
|
||||
downstream_ids = self._find_downstream([t.id for t in completed + in_progress])
|
||||
# 4. 标记 ADR 直接关联的 TODO 任务为 INVALIDATED
|
||||
for t in pending:
|
||||
t.status = "INVALIDATED"
|
||||
delta.removed_tasks.append(t.id)
|
||||
|
||||
# 5. 级联失效下游
|
||||
downstream_ids = self._find_downstream([t.id for t in completed + in_progress + pending])
|
||||
cascaded = []
|
||||
for tid in downstream_ids:
|
||||
node = self.nodes.get(tid)
|
||||
@@ -291,8 +299,8 @@ class TaskGraph:
|
||||
delta.removed_tasks.append(tid)
|
||||
cascaded.append(tid)
|
||||
|
||||
# 5. 回滚快照引用(由调用方在 git revert 后填入)
|
||||
all_invalidated = [t.id for t in completed + in_progress] + cascaded
|
||||
# 6. 回滚快照引用(由调用方在 git revert 后填入)
|
||||
all_invalidated = [t.id for t in completed + in_progress + pending] + cascaded
|
||||
|
||||
return CascadeReport(
|
||||
invalidated_completed=len(completed),
|
||||
|
||||
Reference in New Issue
Block a user