mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-20 17:02:01 +00:00
召回复核修正(后端):人工节点不再挡召回、读不出召回卡记失败、旧版不再接着算、团队渠道一次召回只推一条、目录核对按数据源合并排队;账本接口带上召回标记,对账结果可以反馈
- W4R-01:召回只查新版图里会不会写外部系统(apps/backfill 抽出 graph_external_write,graph_side_effect 复用它)。召回图只有两版
的取数和口径卡,图里别处的人工节点、按流程使用的问题碰不到它;口径卡上游的人工节点 derive 本来就认作数据部分不能复用。
「按新版重新出具」走完整的正式运行,仍按 graph_side_effect 全套拒绝。原来带审批的口径升版后一组都不召回,L6 对它们失效。
- W4R-09:收尾时召回卡读不出、或缺了某个比较的旧值 / 新值,照实记重算失败(读不出召回卡),原答案一个不动。原来两边都是空,
按渲染比被当成「没变」,给每个原答案永久盖上「已核对,不影响」,收过尾之后再也不核对。
- W4R-12:这一版已经不是当前发布版(之后又发布了更新的版本)时不再发起召回、不给接着算,批次里写 continue_reason,接着算的
接口 409 带同一句。同启动时接着做只认当前发布版:新版本的召回覆盖更早的所有版本,再按旧版开「口径升到 vN」的待办只是添乱。
- W4R-13:开登录时一组答案几个主人就几条待办,全局渠道却按这一批(recall.batch_of_key:同一次召回、同一个来由)只在最早开的
那条上推一次,答案、待办按这一批汇总,几条的链到待办箱;别的几条连 task.opened 也不再推全局渠道。个人渠道照旧每人一条。
- W4R-11:目录审阅之后的核对按数据源排队、批量审阅的几张表合成一遍(catalog_pass,同一数据源一把锁);查询快照按数据源在库里
筛、按运行结束时间分页、每张表凑够 BASIS_MAX_RUNS 次运行就停;冻结的表结构快照这一遍里按工件 id 只读一次。原来批量审阅
几十张表就同时起几十个后台任务,每个都全表扫查询快照、反复读同一份几 MB 的表结构快照。
- W4R-03(本包那一半):GET /api/runs/{id}/ledger 加 recall:checked(已按 vN 核对,不影响)、basis(依据有变:哪一种、几项、
新出现几条错误级问题)、tasks(看的这个人手上说的是这个答案、还没处理的 recall 待办)。不放数、不放表名。几种状态都带。
- W4R-10(本包那一半):新事件 ledger.feedback(对账运行上的封存后事件),POST /api/ledger/answers/{run}/reconcile/{rid}/feedback
{verdict: useful | unclear} 记反馈,同一个人改主意只算最后一次(app/ledger/feedback.py);账本接口的 reconciled 每一项带
feedback {mine, useful, unclear};统计 E2 的 feedback 数到它,去掉「第 4 波接上」的占位说法。离线核对页、封存后事件摘要
都认得这个事件。
测试:test_ledger_recall 新增七个用例、改了人工节点那一个(召回照算、重新出具照实拒绝);新增 test_ledger_feedback;
test_ledger_api 的 E2 断言跟上。每个修复都先写失败的测试、去掉修复回跑确认抓得住。后端全量 14237 通过。
This commit is contained in:
@@ -347,7 +347,12 @@ async def notify_recall(task_id: str, users: list[str]) -> int:
|
||||
自己的个人渠道;然后照别的待办推 task.opened(已经推过 ledger.recall 的渠道不再推,同一个渠道只推一次)。目录、表结构变了
|
||||
的那两种只推 task.opened。
|
||||
|
||||
消息照模块说明的规矩(X6):口径名(搭建时起的工作流名)、新旧版本号、这条待办列了几个答案、召回编号、去处理的链接;不放
|
||||
全局渠道按这一批待办只推一次(同一次召回运行、同一个来由开的那几条,recall.batch_of_key):开登录时一组答案有几个主人就
|
||||
开几条待办,团队群却只该收到一条——只在这一批里最早开的那条(开出时间、id 排序,几条并发推也认同一条)上推全局渠道,
|
||||
答案、待办按这一批汇总,链到待办箱(各人在那里看到派给自己的那条);别的几条连 task.opened 也不再推全局渠道。个人渠道
|
||||
照旧每个主人各一条,只数他的答案、链到他的那条待办。
|
||||
|
||||
消息照模块说明的规矩(X6):口径名(搭建时起的工作流名)、新旧版本号、几个答案(几条待办)、召回编号、去处理的链接;不放
|
||||
旧口径的值、新口径的值、差值和原答案的值。返回推了几个渠道。"""
|
||||
from app.ledger import recall
|
||||
|
||||
@@ -361,26 +366,51 @@ async def notify_recall(task_id: str, users: list[str]) -> int:
|
||||
if task is None:
|
||||
return 0
|
||||
run = await session.get(Run, task.run_id)
|
||||
reason = (task.correlation_key or "").split(":", 1)[0]
|
||||
key = task.correlation_key or ""
|
||||
reason = key.split(":", 1)[0]
|
||||
batch = recall.batch_of_key(key)
|
||||
siblings = [t for t, k in (await session.execute(
|
||||
select(Task.id, Task.correlation_key).where(Task.run_id == task.run_id, Task.kind == recall.TASK_KIND)
|
||||
.order_by(Task.created_at, Task.id))).all() if recall.batch_of_key(k or "") == batch]
|
||||
first = not siblings or siblings[0] == task_id
|
||||
channels = await _channels(session, event, run, users) if reason == "caliber" else []
|
||||
# 不是这一批最早的那条:全局渠道已经(或正由那一条)推过了,这条只推个人渠道,task.opened 也跳过全局渠道
|
||||
shared = [] if first else list((await session.execute(select(NotifyChannel.id).where(
|
||||
NotifyChannel.scope == "global"))).scalars())
|
||||
channels = [c for c in channels if first or c.scope != "global"]
|
||||
origin = run.origin if run is not None and isinstance(run.origin, dict) else {}
|
||||
name = str(await session.scalar(select(Workflow.name).where(Workflow.id == origin.get("workflow_id")))
|
||||
or "") if origin.get("workflow_id") else ""
|
||||
base = await _base_url(session) if channels else None
|
||||
pushed = 0
|
||||
if channels:
|
||||
answers = len(recall._uses_of(origin, recall._owner_of_key(task.correlation_key or "")))
|
||||
lines = [("状态", "待处理"), ("口径", f"「{name[:80]}」"),
|
||||
("版本", f"v{origin.get('from_version')} → v{origin.get('to_version')}"), ("答案", f"{answers} 个"),
|
||||
("召回", f"#{task.run_id[:6]}")]
|
||||
message = {"event": event, "status": "pending", "ok": False,
|
||||
"title": recall.CHANGED_TITLE.format(name=name[:80] or "口径", version=origin.get("to_version")),
|
||||
"lines": lines, "links": [("去处理", f"{base}/apps/inbox/{task_id}")] if base else [],
|
||||
"subject": {"task_id": task_id, "run_id": task.run_id, "workflow_id": origin.get("workflow_id")}}
|
||||
pushed = await _push(channels, message, subject_kind="task", subject_id=task_id, event=event,
|
||||
run_id=task.run_id, task_id=task_id)
|
||||
head = [("状态", "待处理"), ("口径", f"「{name[:80]}」"),
|
||||
("版本", f"v{origin.get('from_version')} → v{origin.get('to_version')}")]
|
||||
tail = [("召回", f"#{task.run_id[:6]}")]
|
||||
mine = len(recall._uses_of(origin, recall._owner_of_key(key)))
|
||||
everyone = len(recall._uses_of(origin, ("anyone", "")))
|
||||
|
||||
def message(answers: int, tasks: int, link: tuple[str, str] | None) -> dict[str, Any]:
|
||||
return {"event": event, "status": "pending", "ok": False,
|
||||
"title": recall.CHANGED_TITLE.format(name=name[:80] or "口径", version=origin.get("to_version")),
|
||||
"lines": [*head, ("答案", f"{answers} 个"), *([("待办", f"{tasks} 条")] if tasks > 1 else []), *tail],
|
||||
"links": [link] if base and link else [],
|
||||
"subject": {"task_id": task_id, "run_id": task.run_id, "workflow_id": origin.get("workflow_id")}}
|
||||
|
||||
own = ("去处理", f"{base}/apps/inbox/{task_id}")
|
||||
group = [c for c in channels if c.scope == "global"]
|
||||
if group:
|
||||
# 这一批只有这一条(关登录时派给任何人)就链到它;几条的链到待办箱,各人看派给自己的那条
|
||||
many = len(siblings) > 1
|
||||
pushed += await _push(group, message(everyone, len(siblings), ("去待办箱", f"{base}/apps?tab=inbox")
|
||||
if many else own),
|
||||
subject_kind="task", subject_id=task_id, event=event, run_id=task.run_id,
|
||||
task_id=task_id)
|
||||
if personal := [c for c in channels if c.scope != "global"]:
|
||||
pushed += await _push(personal, message(mine, 1, own), subject_kind="task", subject_id=task_id,
|
||||
event=event, run_id=task.run_id, task_id=task_id)
|
||||
return pushed + await notify_task(task_id, "task.opened", users=users,
|
||||
exclude=frozenset(c.id for c in channels))
|
||||
exclude=frozenset(c.id for c in channels) | frozenset(shared))
|
||||
|
||||
|
||||
async def notify_run(run_id: str, event: str) -> int:
|
||||
|
||||
Reference in New Issue
Block a user