diff --git a/pipeline_bidding/bid_review_capability.py b/pipeline_bidding/bid_review_capability.py index 20d30e8..64952bf 100644 --- a/pipeline_bidding/bid_review_capability.py +++ b/pipeline_bidding/bid_review_capability.py @@ -112,6 +112,7 @@ async def review_chapter(chapter_id, score, max_score="", comments="", detail="" from_state=c.get("status"), to_state=CH_APPROVED, who=who, agent_id=agent_id, detail="%.2f/%.2f (%.0f%%)" % (sc, ms, ratio * 100)) + await _sync_mirror(sor, pid, chapter_id) return True, ("章节「%s」评审通过 %.2f/%.2f(%.0f%%,门限 %.0f%%)" % (c.get("title"), sc, ms, ratio * 100, th["chapter_pass_ratio"] * 100)) @@ -147,6 +148,7 @@ async def review_chapter(chapter_id, score, max_score="", comments="", detail="" % (c.get("chapter_no"), c.get("title"), sc, ms, (comments or "")[:1500])), assignee_role="owner.superuser", dedup_by_title=True) await sor.sqlExe("COMMIT", {}) + await _sync_mirror(sor, pid, chapter_id) return True, ("章节「%s」评审 %.2f/%.2f:失分全部因实体材料缺失(非写作缺陷)," "已如实披露放行 + 发信息流供料待办「%s」,不阻塞标书推进。" % (c.get("title"), sc, ms, title)) @@ -206,6 +208,17 @@ async def review_chapter(chapter_id, score, max_score="", comments="", detail="" th["chapter_pass_ratio"] * 100, revise)) +async def _sync_mirror(sor, project_id, chapter_id): + """章节状态变更后同步工作空间镜像文件(元数据/版本/状态一致,2026-09-16: + 镜像只在 write_chapter 同步 → 评审通过后文件头仍显示 written 旧版,用户 + 看文件误判状态)。失败只记日志,不阻断评审/通过主流程。""" + try: + from .bid_chapter_mirror import sync_chapter_mirror + await sync_chapter_mirror(sor, project_id, chapter_id) + except Exception as e: # noqa: BLE001 + logger.warning("章节镜像同步失败(不阻断): chapter=%s err=%s", chapter_id, e) + + async def approve_chapter(chapter_id, comment="", who=None, agent_id=None): """人工/评审直接通过章节(written/reviewing/rejected → approved)。""" db, dbname = get_db() @@ -223,6 +236,7 @@ async def approve_chapter(chapter_id, comment="", who=None, agent_id=None): await record(sor, c.get("project_id"), TABLE, chapter_id, "approve", from_state=c.get("status"), to_state=CH_APPROVED, who=who, agent_id=agent_id, detail=comment) + await _sync_mirror(sor, c.get("project_id"), chapter_id) return True, "章节「%s」已通过" % c.get("title") @@ -245,6 +259,7 @@ async def reject_chapter(chapter_id, comment="", who=None, agent_id=None): from_state=c.get("status"), to_state=CH_REJECTED, who=who, agent_id=agent_id, detail=comment[:480]) return True, "章节「%s」已退回重写(第 %d 次)" % (c.get("title"), revise) + await _sync_mirror(sor, c.get("project_id"), chapter_id) async def list_reviews(project_id, scope="", chapter_id="", limit=50): diff --git a/pipeline_bidding/bid_score_capability.py b/pipeline_bidding/bid_score_capability.py index cc394e0..5b7fee2 100644 --- a/pipeline_bidding/bid_score_capability.py +++ b/pipeline_bidding/bid_score_capability.py @@ -284,6 +284,12 @@ async def finalize_bid_score(review_id, comments="", who=None, agent_id=None): await record(sor, pid, "bid_chapters", cid, "score_reject", from_state=c.get("status"), to_state=CH_REJECTED, who=who, agent_id=agent_id, detail=(s.get("improvement") or "")[:400]) + # 退回也同步镜像(文件头状态/评审分/改进意见要与库一致,2026-09-16) + try: + from .bid_chapter_mirror import sync_chapter_mirror + await sync_chapter_mirror(sor, pid, cid) + except Exception as e: # noqa: BLE001 + logger.warning("章节镜像同步失败(不阻断): chapter=%s err=%s", cid, e) touched += 1 if touched == 0 and weak: await create_human_task(