feat(09-02): convert high-frequency callsites to granular emitEvent
- Replace publishDomainChanged() with granular events at 9 high-frequency callsites - saveTask/deleteTask emit task-updated events in ipc-core-work-graph-handlers - decideApproval emits approval-updated, addComment emits task-updated - worker-service emits run-updated for status changes and completion - worker-service emits agent-updated for budget hard-stop pause - orchestration-service emits agent-updated for auto-pause, run-updated for dispatch - Wire emitEvent dependency to orchestration-service via service-graph - Keep publishDomainChanged for low-frequency and multi-entity paths Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
c1de05a7f1
commit
5124209ddb
5 files changed
+20
-11
No files matched your search
@@ -114,7 +114,7 @@ export function registerCoreOperationHandlers({
|
|||||||
decisionNote: parsed.decisionNote,
|
decisionNote: parsed.decisionNote,
|
||||||
detail: parsed.decisionNote,
|
detail: parsed.decisionNote,
|
||||||
});
|
});
|
||||||
publishDomainChanged();
|
emitEvent({ type: "approval-updated", approvalId: approval.id, action: "decided" });
|
||||||
return ok(true);
|
return ok(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ export function registerCoreOperationHandlers({
|
|||||||
detail: parsed.body.slice(0, 100),
|
detail: parsed.body.slice(0, 100),
|
||||||
});
|
});
|
||||||
emitEvent({ type: "agent-message", taskId: parsed.taskId, comment });
|
emitEvent({ type: "agent-message", taskId: parsed.taskId, comment });
|
||||||
publishDomainChanged();
|
emitEvent({ type: "task-updated", taskId: parsed.taskId, action: "updated" });
|
||||||
try {
|
try {
|
||||||
const task = db.getTask(parsed.taskId);
|
const task = db.getTask(parsed.taskId);
|
||||||
if (task.assigneeAgentId) {
|
if (task.assigneeAgentId) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export function registerCoreWorkGraphHandlers({
|
|||||||
ensureCompanyExists,
|
ensureCompanyExists,
|
||||||
findInvalidReference,
|
findInvalidReference,
|
||||||
publishDomainChanged,
|
publishDomainChanged,
|
||||||
|
emitEvent,
|
||||||
wakeAgentIfPossible,
|
wakeAgentIfPossible,
|
||||||
handleApprovalResolved,
|
handleApprovalResolved,
|
||||||
handleTaskCreated,
|
handleTaskCreated,
|
||||||
@@ -29,6 +30,7 @@ export function registerCoreWorkGraphHandlers({
|
|||||||
| "ensureCompanyExists"
|
| "ensureCompanyExists"
|
||||||
| "findInvalidReference"
|
| "findInvalidReference"
|
||||||
| "publishDomainChanged"
|
| "publishDomainChanged"
|
||||||
|
| "emitEvent"
|
||||||
| "wakeAgentIfPossible"
|
| "wakeAgentIfPossible"
|
||||||
| "handleApprovalResolved"
|
| "handleApprovalResolved"
|
||||||
| "handleTaskCreated"
|
| "handleTaskCreated"
|
||||||
@@ -355,7 +357,7 @@ export function registerCoreWorkGraphHandlers({
|
|||||||
wakeAgentIfPossible(parsed.assigneeAgentId, parsed.companyId, "assignment");
|
wakeAgentIfPossible(parsed.assigneeAgentId, parsed.companyId, "assignment");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
publishDomainChanged();
|
emitEvent({ type: "task-updated", taskId: id, action: isNew ? "created" : "updated" });
|
||||||
return ok(id);
|
return ok(id);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -437,7 +439,11 @@ export function registerCoreWorkGraphHandlers({
|
|||||||
entityId: parsed.id,
|
entityId: parsed.id,
|
||||||
detail: "",
|
detail: "",
|
||||||
});
|
});
|
||||||
publishDomainChanged();
|
if (entity === "task") {
|
||||||
|
emitEvent({ type: "task-updated", taskId: parsed.id, action: "deleted" });
|
||||||
|
} else {
|
||||||
|
publishDomainChanged();
|
||||||
|
}
|
||||||
return ok(true);
|
return ok(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ interface OrchestrationDependencies {
|
|||||||
error: (...args: unknown[]) => void;
|
error: (...args: unknown[]) => void;
|
||||||
};
|
};
|
||||||
publishDomainChanged: () => void;
|
publishDomainChanged: () => void;
|
||||||
|
emitEvent: (event: any) => void;
|
||||||
notify: (options: NotificationOptions) => void;
|
notify: (options: NotificationOptions) => void;
|
||||||
createRunToken: (agentId: string, companyId: string, runId: string) => string;
|
createRunToken: (agentId: string, companyId: string, runId: string) => string;
|
||||||
getApiPort: () => number;
|
getApiPort: () => number;
|
||||||
@@ -67,6 +68,7 @@ export function createOrchestrationService({
|
|||||||
db,
|
db,
|
||||||
logger,
|
logger,
|
||||||
publishDomainChanged,
|
publishDomainChanged,
|
||||||
|
emitEvent,
|
||||||
notify,
|
notify,
|
||||||
createRunToken,
|
createRunToken,
|
||||||
getApiPort,
|
getApiPort,
|
||||||
@@ -138,7 +140,7 @@ export function createOrchestrationService({
|
|||||||
navigation: { section: "agents", entityId: agent.id },
|
navigation: { section: "agents", entityId: agent.id },
|
||||||
batchKey: "agent_paused",
|
batchKey: "agent_paused",
|
||||||
});
|
});
|
||||||
publishDomainChanged();
|
emitEvent({ type: "agent-updated", agentId: agent.id, action: "paused" });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +451,7 @@ export function createOrchestrationService({
|
|||||||
entityId: agent.id,
|
entityId: agent.id,
|
||||||
detail: `${trigger} heartbeat for ${agent.name}`,
|
detail: `${trigger} heartbeat for ${agent.name}`,
|
||||||
});
|
});
|
||||||
publishDomainChanged();
|
emitEvent({ type: "run-updated", runId: run.id, action: "created" });
|
||||||
return run.id;
|
return run.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,7 +562,7 @@ export function createOrchestrationService({
|
|||||||
entityId: run.id,
|
entityId: run.id,
|
||||||
detail: task.title,
|
detail: task.title,
|
||||||
});
|
});
|
||||||
publishDomainChanged();
|
emitEvent({ type: "run-updated", runId: run.id, action: "created" });
|
||||||
return ok(run.id);
|
return ok(run.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ export function createServiceGraph({
|
|||||||
db,
|
db,
|
||||||
logger,
|
logger,
|
||||||
publishDomainChanged,
|
publishDomainChanged,
|
||||||
|
emitEvent,
|
||||||
notify,
|
notify,
|
||||||
createRunToken,
|
createRunToken,
|
||||||
getApiPort: () => apiServerRef.current?.getPort() ?? 0,
|
getApiPort: () => apiServerRef.current?.getPort() ?? 0,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ interface WorkerServiceDependencies {
|
|||||||
workerPath: string;
|
workerPath: string;
|
||||||
isQuitting: () => boolean;
|
isQuitting: () => boolean;
|
||||||
publishDomainChanged: () => void;
|
publishDomainChanged: () => void;
|
||||||
emitEvent: (event: WorkerUiEvent) => void;
|
emitEvent: (event: any) => void;
|
||||||
wakeAgentIfPossible: (agentId: string | null | undefined, companyId: string, trigger: string) => string | null;
|
wakeAgentIfPossible: (agentId: string | null | undefined, companyId: string, trigger: string) => string | null;
|
||||||
dispatchRunToWorker: (params: {
|
dispatchRunToWorker: (params: {
|
||||||
runId: string;
|
runId: string;
|
||||||
@@ -239,7 +239,7 @@ export function createWorkerService({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
emitEvent(event);
|
emitEvent(event);
|
||||||
publishDomainChanged();
|
emitEvent({ type: "run-updated", runId: event.runId, action: "status_changed" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +280,7 @@ export function createWorkerService({
|
|||||||
entityId: run.id,
|
entityId: run.id,
|
||||||
detail: event.summary ?? event.errorMessage ?? "",
|
detail: event.summary ?? event.errorMessage ?? "",
|
||||||
});
|
});
|
||||||
publishDomainChanged();
|
emitEvent({ type: "run-updated", runId: run.id, action: "completed" });
|
||||||
emitEvent({
|
emitEvent({
|
||||||
type: "run-status",
|
type: "run-status",
|
||||||
runId: run.id,
|
runId: run.id,
|
||||||
@@ -320,7 +320,7 @@ export function createWorkerService({
|
|||||||
navigation: { section: "agents", entityId: updatedAgent.id },
|
navigation: { section: "agents", entityId: updatedAgent.id },
|
||||||
batchKey: "agent_paused",
|
batchKey: "agent_paused",
|
||||||
});
|
});
|
||||||
publishDomainChanged();
|
emitEvent({ type: "agent-updated", agentId: updatedAgent.id, action: "paused" });
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((event.status === "failed" || event.status === "timed_out") && !isQuitting() && !destroyed) {
|
if ((event.status === "failed" || event.status === "timed_out") && !isQuitting() && !destroyed) {
|
||||||
|
|||||||
Reference in new issue
Block a user