This commit is contained in:
zyp
2026-11-27 14:43:37 +08:00
parent 1ae94dfb1f
commit b18c6efe92
64 changed files with 5629 additions and 2414 deletions
@@ -1,5 +1,6 @@
"""Task-specific explanations, grounded in the authorized review snapshot."""
import logging
import re
import time
from typing import Literal
@@ -8,6 +9,9 @@ from .confidential_delivery import CONFIDENTIAL_DELIVERY_POLICY
from .review_failure import review_failure
logger = logging.getLogger(__name__)
TASK_PROGRESS_METADATA = re.compile(
r"\r?\n登记进度:[^\r\n]*\r?\n状态编码:[^\r\n]*\r?\n权重:[^\r\n]*\r?\n责任人编号:[^\r\n]*\Z"
)
class Citation(BaseModel):
@@ -66,6 +70,7 @@ verdict只评价subject本身:sound=当前安排未发现明确问题,clarif
actions允许为空,最多4项;每项包含scope、具体title、reason、suggestion、evidence。subject是当前工作可处理的意见;goal_plan是由总目标负责人处理的整体分工,不得把总目标的其他工作全要求当前子任务承担。
看完所有tasks再判断遗漏。已有同级任务承担的工作应明确承认,不能因当前任务未包含就说没有安排。一个任务可以承接多个步骤,不强制每个实现细节都单建任务。
workflow是分析参照,basis=inferred是可选实施思路,不能自动判为缺项。不要照着流程列待办;要解释为什么某个缺口会影响原目标、哪项现有工作能补充,并允许不同实施路径。
对统筹型父任务,结合已明确承接的子任务核对工作范围和交付要求,已有清单或完成标准无需在父任务重复填写。分工看是否有明确承担者,进度看是否已执行;未到截止日期的进行中任务不能仅因没完成就算缺分工。如果具体周期或事项在资料中没有对应安排,明确指出哪个周期或事项,并请负责人核对已有记录。
不要每次都要求补负责人、时间、工作量、前置依赖;只在输入有具体缺失或冲突且确实影响该工作时提出。日期和责任人已提供就直接使用。无法预测一定按期完成不等于任务填写有错。
描述充分性必须单独核对,不能用方向相关、日期和负责人齐全替代。普通技术和业务含义可理解,但不可发明原文未写的工作范围、交付结果、系统用途、集成关系、已完成成果、公司制度或必需指标。
独立理解goal的业务对象与用途;不能因为同级任务出现了另一个业务领域,就把目标重新解释为也包含它。grounded_alignment是经原文核实的当前任务关系,若为unrelated不能给sound。
@@ -179,7 +184,17 @@ def review_commentary(*, subject, goal, tasks, sources, review_kind, workflow,
# For a goal review, changes to its own definition and breakdown both
# belong to the current subject; don't classify all advice as peers' work.
schema['$defs']['ReviewAction']['properties']['scope']['enum'] = ['subject']
instruction += '\n本次评价的是目标本身,修改目标描述及其分工均属于当前目标负责人的意见,actions统一使用scope=subject。先明确目标内容的缺失,再处理下级分工问题。'
data.pop('schedule')
for task in [data['subject'], data['goal'], *data['tasks']]:
if task is not None:
task.pop('status', None)
task.pop('progress', None)
for source in data['sources']:
if source['id'].startswith('task:'):
source['text'] = TASK_PROGRESS_METADATA.sub('', source['text'])
instruction += ('\n本次评价的是目标本身,目标描述及分工均由当前目标负责人处理,actions使用scope=subject。'
'直接对照目标原文和所有已读子任务说明问题。若有明确分工缺口,指出缺哪项工作或哪个周期、缺口的影响及如何核对或补齐。'
'依据不完整时明确可见范围,不能把未读取的安排判为缺失。日期风险由系统另行展示。')
schema['$defs']['Citation'] = citation_schema(data['sources'])
instruction += DESCRIPTION_INSTRUCTION + PROPORTIONATE_REVIEW + CONFIDENTIAL_DELIVERY_POLICY + '\n引用必须从对应source_id的quote候选原文中选择,保留原有换行和标点,不合并或改写。'
if alignment and alignment['status'] == 'unrelated':
@@ -223,6 +238,8 @@ def validate_commentary(raw, subject_id, available, review_kind, alignment):
if not any(c.source_id == f"task:{subject_id}" for c in result.evidence):
raise ValueError("缺少当前工作原文依据")
subject_actions = [a for a in result.actions if a.scope == "subject"]
if any(not any(char.isalnum() for char in text) for a in result.actions for text in (a.title, a.reason, a.suggestion)):
raise ValueError("调整建议缺少具体问题、原因或处理内容")
if description.status == 'needs_detail' and (result.verdict == 'sound' or not subject_actions):
raise ValueError('任务要求不充分不能显示暂无调整建议')
if review_kind == 'task' and any(a.scope != 'subject' for a in result.actions):