auto-sync: 2026-05-29 13:39:38
This commit is contained in:
+27
-13
@@ -577,20 +577,32 @@ Project ID: {project_id}
|
||||
outcome: str, round_num: int):
|
||||
"""解析庞统 review 结论,更新 parent 状态
|
||||
|
||||
庞统可能的结论:
|
||||
- GOAL_ACHIEVED → parent → done(最终完成)
|
||||
- 创建了新 sub task → parent → working(下一轮自动聚合)
|
||||
- 其他 → parent → working(保守恢复,让下一轮自然流转)
|
||||
庞统完成后的回调。outcome 是 'completed'/'failed' 等状态字符串。
|
||||
需要从 DB 判断庞统做了什么:
|
||||
- 检查是否有新 sub task(比 round 开始前多)
|
||||
- 检查是否有 GOAL_ACHIEVED 标记
|
||||
"""
|
||||
db_path = self._resolve_db_path(project_id)
|
||||
conn = get_connection(db_path)
|
||||
try:
|
||||
# 解析庞统结论
|
||||
is_achieved = False
|
||||
if outcome and "GOAL_ACHIEVED" in outcome.upper():
|
||||
is_achieved = True
|
||||
# 检查庞统是否创建了新 sub task
|
||||
sub_count = conn.execute(
|
||||
"SELECT COUNT(*) FROM tasks WHERE parent_task=?",
|
||||
(parent_id,)
|
||||
).fetchone()[0]
|
||||
|
||||
if is_achieved:
|
||||
# 检查最新 comment 是否包含 GOAL_ACHIEVED
|
||||
goal_achieved = False
|
||||
latest_comment = conn.execute(
|
||||
"SELECT body FROM comments "
|
||||
"WHERE task_id=? AND author='pangtong-fujunshi' "
|
||||
"ORDER BY created_at DESC LIMIT 1",
|
||||
(parent_id,)
|
||||
).fetchone()
|
||||
if latest_comment and "GOAL_ACHIEVED" in (latest_comment["body"] or "").upper():
|
||||
goal_achieved = True
|
||||
|
||||
if goal_achieved:
|
||||
# Goal 达成 → parent 最终完成
|
||||
conn.execute("BEGIN IMMEDIATE")
|
||||
conn.execute(
|
||||
@@ -598,8 +610,9 @@ Project ID: {project_id}
|
||||
"WHERE id=? AND status='reviewing'",
|
||||
(parent_id,))
|
||||
conn.commit()
|
||||
logger.info("Parent %s review conclusion: GOAL_ACHIEVED → done",
|
||||
parent_id)
|
||||
logger.info(
|
||||
"Parent %s review conclusion: GOAL_ACHIEVED → done",
|
||||
parent_id)
|
||||
else:
|
||||
# 庞统可能创建了新 sub task 或需要继续 → 恢复 working
|
||||
conn.execute("BEGIN IMMEDIATE")
|
||||
@@ -609,8 +622,9 @@ Project ID: {project_id}
|
||||
(parent_id,))
|
||||
conn.commit()
|
||||
logger.info(
|
||||
"Parent %s review conclusion: continue → working (round %d)",
|
||||
parent_id, round_num)
|
||||
"Parent %s review conclusion: continue → working "
|
||||
"(round %d, subs=%d)",
|
||||
parent_id, round_num, sub_count)
|
||||
except Exception:
|
||||
logger.exception("Failed to handle review conclusion for %s", parent_id)
|
||||
# 安全恢复:reviewing → working
|
||||
|
||||
Reference in New Issue
Block a user