Gate inbox delivery on worker-side steer ACK
Replace the fire-and-forget steer with a correlated ACK round-trip so main only marks an inbox row delivered once the worker confirms the message landed on the live Agent. Steer against a run that is still in the `preparing` window or has already started `closing` now falls back to the wake + inbox projection path instead of being silently dropped. Worker publishes `run-agent-state` transitions at Agent construction and teardown; main tracks these on `ActiveRunContext.state` and refuses to steer runs that are not `agent_active`. A rejected or timed-out ACK triggers `wakeAgentIfPossible` so the next `prepareRun` replays the row.
This commit is contained in:
1 parent
ad9205fcc9
commit
e917c614c9
12 files changed
+264
-57
No files matched your search
@@ -171,6 +171,7 @@ export function createServiceGraph(deps: ServiceGraphDependencies) {
|
||||
budgetService: leaf.budgetEnforcementService,
|
||||
sessionService: leaf.sessionManagementService,
|
||||
piRuntimeRef,
|
||||
getRuntimeMessageInjector: () => runtimeMessageInjector,
|
||||
});
|
||||
|
||||
runtimeMessageInjector = new RuntimeMessageInjector({
|
||||
@@ -181,6 +182,11 @@ export function createServiceGraph(deps: ServiceGraphDependencies) {
|
||||
if (!worker) throw new Error("Worker is not initialised — cannot deliver steer message.");
|
||||
worker.postMessage(message);
|
||||
},
|
||||
getWakeAgent: () => {
|
||||
if (!orchestrationRef.isAssigned()) return null;
|
||||
const orch = orchestrationRef.get();
|
||||
return (agentId, companyId, trigger) => orch.wakeAgentIfPossible(agentId, companyId, trigger);
|
||||
},
|
||||
logger,
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user