Merge pull request #36 from xmindlab-heicode/feat/review-timeline-events

评审/返工时间线对客户端可见:review/rework 4 类脱敏事件纳入冻结集(Refs #34)
This commit is contained in:
观风听雪
2026-06-11 17:15:50 +08:00
committed by GitHub
9 changed files with 264 additions and 8 deletions
+21
View File
@@ -970,9 +970,25 @@ async def run_cross_review(run, tasks) -> bool:
verdict = cross_review_mod.aggregate_reviews(decisions)
run.metadata["cross_review"] = verdict.to_dict()
# Client-visible review timeline (#34): emit REDACTED projections (allowlist only — no
# evidence/summary/reason free text; see cross_review.*_client_payload). HM registers these 4
# types; the cockpit renders the review/rework timeline from them.
reviewer_ids = [d.reviewer_agent_id for d in decisions]
await swarm_runtime.emit_event(run, "review.started",
payload=cross_review_mod.review_started_client_payload(run.swarm_id, reviewer_ids, cycle=cycles))
await swarm_runtime.emit_event(run, "review.decision_made",
payload=cross_review_mod.review_decision_client_payload(run.swarm_id, verdict, cycle=cycles))
task_owner = {t.task_id: t.assigned_agent_id for t in tasks if t.assigned_agent_id}
valid_targets = [tid for tid in verdict.rework_targets if tid in run.task_ids]
if verdict.accepted or not valid_targets:
# A prior cycle's rework was redone and is now accepted → mark those targets complete.
if cycles > 0:
for a in (run.metadata.get("rework_attributions") or []):
await swarm_runtime.emit_event(run, "rework.completed",
payload=cross_review_mod.rework_completed_client_payload(
run.swarm_id, task_id=a.get("target_task_id"),
root_cause=a.get("root_cause"), cycle=cycles))
run.metadata["reviews"] = [] # consumed
await swarm_runtime.save_run(run)
return False
@@ -994,6 +1010,11 @@ async def run_cross_review(run, tasks) -> bool:
"status": "running", "retry_tasks": reopened,
"disagreement": verdict.disagreement,
})
# Client-visible rework timeline (#34): one redacted rework.requested per reopened target.
for a in attributions:
if a.target_task_id in reopened:
await swarm_runtime.emit_event(run, "rework.requested",
payload=cross_review_mod.rework_requested_client_payload(run.swarm_id, a, cycle=cycles + 1))
logger.info(f"Cross-review reopened {reopened} on run {run.swarm_id} (cycle {cycles + 1})")
return True