sync update from LAN repo (source dhk-1 @ 3e87be55)
This commit is contained in:
1 parent
ab6068a7c1
commit
42f2a26fa8
1482 files changed
+227759
-9584
No files matched your search
@@ -39,6 +39,8 @@ class TaskAssignment:
|
||||
agent_profile_snapshot: dict[str, Any]
|
||||
command_overlay_revision: int
|
||||
label: str
|
||||
agent_id: str | None = None
|
||||
agent_description: str | None = None
|
||||
angle: str | None = None
|
||||
command_overlays: list[dict[str, Any]] = field(default_factory=list)
|
||||
|
||||
@@ -105,6 +107,42 @@ class TaskLedger:
|
||||
await self._store.patch_run(run_id, current_phase=phase_id, status="running")
|
||||
return assignments
|
||||
|
||||
async def start_assignment(self, assignment: TaskAssignment) -> bool:
|
||||
"""Mark one queued assignment running immediately before model execution.
|
||||
|
||||
A wave may contain multiple assignments while the current executor runs
|
||||
them one by one. Keeping this transition separate from queue creation
|
||||
prevents not-yet-started siblings from being shown as running, while
|
||||
still making the active member visible for the entire streamed reply.
|
||||
"""
|
||||
|
||||
run = await self._store.get_run(assignment.run_id)
|
||||
if run is None or run.get("cancel_requested") or run.get("status") in {"cancelled", "completed", "failed"}:
|
||||
return False
|
||||
nodes = await self._store.list_node_runs(assignment.run_id)
|
||||
node = next((item for item in nodes if item["node_run_id"] == assignment.node_run_id), None)
|
||||
if node is None:
|
||||
return False
|
||||
if node.get("status") == "running":
|
||||
return True
|
||||
if node.get("status") != "queued":
|
||||
return False
|
||||
require_transition("queued", "running")
|
||||
node["status"] = "running"
|
||||
node["started_at"] = iso_now()
|
||||
await self._store.save_node_run(node)
|
||||
await self._emit(
|
||||
assignment,
|
||||
"node.status.changed",
|
||||
{
|
||||
"node_id": assignment.node_id,
|
||||
"node_run_id": assignment.node_run_id,
|
||||
"status": "running",
|
||||
"phase_id": assignment.phase_id,
|
||||
},
|
||||
)
|
||||
return True
|
||||
|
||||
async def apply_result(self, assignment: TaskAssignment, result: TaskResult) -> ApplyOutcome:
|
||||
ignored = list(result.suggested_next_node_ids or [])
|
||||
if result.kind == "advice":
|
||||
@@ -149,6 +187,15 @@ class TaskLedger:
|
||||
node["awaiting_input"] = result.clarification or {"reason": "clarification", "question": result.repair_reason or ""}
|
||||
node["ended_at"] = iso_now()
|
||||
await self._store.save_node_run(node)
|
||||
await self._emit(
|
||||
assignment,
|
||||
"node.status.changed",
|
||||
{
|
||||
"node_id": assignment.node_id,
|
||||
"node_run_id": assignment.node_run_id,
|
||||
"status": "awaiting_input",
|
||||
},
|
||||
)
|
||||
await self._store.patch_run(assignment.run_id, status="awaiting_input", session_status="awaiting_input")
|
||||
return ApplyOutcome(node_status="awaiting_input", run_status="awaiting_input", ignored_coordinator_suggestions=ignored)
|
||||
|
||||
@@ -178,6 +225,15 @@ class TaskLedger:
|
||||
require_transition(node["status"], "validating")
|
||||
node["status"] = "validating"
|
||||
await self._store.save_node_run(node)
|
||||
await self._emit(
|
||||
assignment,
|
||||
"node.status.changed",
|
||||
{
|
||||
"node_id": assignment.node_id,
|
||||
"node_run_id": assignment.node_run_id,
|
||||
"status": "validating",
|
||||
},
|
||||
)
|
||||
if not gate.ok:
|
||||
if gate.parsed:
|
||||
rejected = await self._board.submit(
|
||||
@@ -248,6 +304,15 @@ class TaskLedger:
|
||||
node["ended_at"] = iso_now()
|
||||
node["error"] = None
|
||||
await self._store.save_node_run(node)
|
||||
await self._emit(
|
||||
assignment,
|
||||
"node.status.changed",
|
||||
{
|
||||
"node_id": assignment.node_id,
|
||||
"node_run_id": assignment.node_run_id,
|
||||
"status": "completed",
|
||||
},
|
||||
)
|
||||
await self._emit(assignment, "artifact.validated", {"artifact_id": artifact["id"], "node_id": assignment.node_id})
|
||||
if expected == "ReviewDecision" and (gate.parsed or {}).get("verdict") == "revise":
|
||||
await self._replan_review_targets(assignment, gate.parsed or {})
|
||||
@@ -704,6 +769,8 @@ class TaskLedger:
|
||||
agent_profile_snapshot=snapshot,
|
||||
command_overlay_revision=int(current.get("command_overlay_revision") or 0),
|
||||
label=str(spec.get("label") or node_id),
|
||||
agent_id=str(spec.get("agent_id") or "") or None,
|
||||
agent_description=str(spec.get("agent_description") or "") or None,
|
||||
angle=spec.get("angle"),
|
||||
command_overlays=[dict(item) for item in snapshot.get("command_overlays") or [] if isinstance(item, dict)],
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user