Make typed swarm control own operator heat

This commit is contained in:
Meta Vens 2026-07-15 03:23:32 +01:00
commit 2059411e85
3 changed files with 10 additions and 9 deletions

View file

@ -168,21 +168,21 @@ async function projectAcceptedHeat(control) {
await node.put(documents.swarmControl, "voidbot-swarm", control);
await node.flush?.(true);
await liveProviderSession?.upsertPublication?.(controlPublication(control));
await queueOperatorViewPublication();
await queueOperatorViewPublication(control);
}
function queueOperatorViewPublication() {
function queueOperatorViewPublication(control) {
operatorPublishChain = operatorPublishChain
.then(publishCurrentOperatorView)
.then(() => publishCurrentOperatorView(control))
.catch((error) => console.error(`VoidBot swarm operator view publication failed: ${error instanceof Error ? error.message : String(error)}`));
return operatorPublishChain;
}
async function publishCurrentOperatorView() {
async function publishCurrentOperatorView(controlOverride) {
const { control: _controlPath, ...jsonInputPaths } = operatorInputPaths;
const inputs = await readSwarmOperatorInputs(jsonInputPaths);
const controlNode = await CultMesh.createNode(controlStorePath, { documents: [documents.swarmControl] });
const control = controlNode.get(documents.swarmControl, "voidbot-swarm");
const controlNode = controlOverride ? null : await CultMesh.createNode(controlStorePath, { documents: [documents.swarmControl] });
const control = controlOverride ?? controlNode?.get(documents.swarmControl, "voidbot-swarm");
const view = projectSwarmOperatorView({
...inputs,
control,
@ -225,6 +225,7 @@ async function startLiveProviderSession() {
commandHandlers: {},
});
await session.start();
console.log(`VoidBot swarm provider session ${session.state.status} as ${session.identity.providerId}${session.state.lastError ? `: ${session.state.lastError}` : ""}`);
return session;
}

View file

@ -80,7 +80,7 @@ function projectSwarmOperatorView({ heartbeat, orchestrator, pause, control, obs
repoName: participant.repoName,
state: participant.activeJobId ? "active" : participant.status,
nextTurnInMinutes: participant.nextTurnInMinutes,
heat: participant.heat ?? number(control?.globalHeat) ?? number(heartbeat?.globalHeat),
heat: number(control?.globalHeat) ?? participant.heat ?? number(heartbeat?.globalHeat),
label: participant.displayName,
status: participant.activeJobId ? "active" : participant.status,
detail: `${participant.repoName} · ${formatTurnDistance(participant.nextTurnInMinutes)}`,
@ -96,7 +96,7 @@ function projectSwarmOperatorView({ heartbeat, orchestrator, pause, control, obs
avatarUri: selected.avatarUri,
status: selected.status,
nextTurnInMinutes: selected.nextTurnInMinutes,
heat: selected.heat ?? number(control?.globalHeat) ?? number(heartbeat?.globalHeat),
heat: number(control?.globalHeat) ?? selected.heat ?? number(heartbeat?.globalHeat),
memoryCount: selected.memoryCount,
pressureCount: selected.pressureCount,
description: selected.description,

View file

@ -15,7 +15,7 @@ test("projects bounded operator state and lets control own heat", () => {
lastTickAt: "2026-07-15T10:00:00.000Z",
pendingMentions: [{ identityId: "eve" }],
participants: [
{ identityId: "eve", displayName: "Eve", status: "active", nextTurnInMinutes: 3 },
{ identityId: "eve", displayName: "Eve", status: "active", nextTurnInMinutes: 3, heat: 1.2 },
{ identityId: "odin", displayName: "Odin", status: "active", activeJobId: "job-1", nextTurnInMinutes: 8 },
],
},