@volter/supercode-orchestrator 0.4.48 → 0.4.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/board/cli.mjs CHANGED
@@ -1085,7 +1085,11 @@ async function serve(root, args = {}) {
1085
1085
  process.on('SIGTERM', stop);
1086
1086
  process.on('SIGINT', stop);
1087
1087
  const log = (text) => process.stdout.write(`${new Date().toISOString()} ${text}\n`);
1088
- log(`dispatching the boards of ${root} from ${localMachine()}`);
1088
+ // the orchestrator this serve runs, as installed: a newer install ends the serve after its tick, so whatever keeps it
1089
+ // running starts it again on the new code (a fix reaches the board with no hand relaunch)
1090
+ const installed = () => { try { return JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version ?? null; } catch { return null; } };
1091
+ const running = installed();
1092
+ log(`dispatching the boards of ${root} from ${localMachine()} (orchestrator ${running ?? 'unknown'})`);
1089
1093
  const stuck = {};
1090
1094
  const warned = {};
1091
1095
  let pausedSaid = false;
@@ -1113,6 +1117,8 @@ async function serve(root, args = {}) {
1113
1117
  } catch (error) {
1114
1118
  log(`tick failed: ${error.message}`);
1115
1119
  }
1120
+ const now = installed();
1121
+ if (running && now && now !== running) { log(`orchestrator ${now} is installed (this serve runs ${running}); stopping, for its keeper to start the new one`); break; }
1116
1122
  // the next tick is due an interval after this one began (a long tick is not followed by a full interval's wait)
1117
1123
  const rest = Math.max(1, interval - Math.floor((Date.now() - began) / 1000));
1118
1124
  for (let waited = 0; waited < rest && !stopped; waited += 1) await new Promise((done) => setTimeout(done, 1000));
@@ -474,6 +474,8 @@ export async function sessionEffect(board, e) {
474
474
  if (e.kind === 'close_session') {
475
475
  const rows = tx(board, (db) => db.prepare('SELECT id, metadata FROM task_runs WHERE task_id = ? ORDER BY id DESC').all(e.id));
476
476
  for (const row of rows) {
477
+ // a run newer than the one that left the status is its successor, already started in this tick: not closed
478
+ if (e.runId && row.id > e.runId) continue;
477
479
  const session = json(row.metadata, {})?.supercode;
478
480
  if ((session?.slot ?? 'worker') !== e.slot || !session?.pane || session.closed_at) continue;
479
481
  // the session that sent the event is not closed under its own command: the dispatcher closes it next tick
@@ -583,9 +585,10 @@ function launchPane(board, task, runId, lane, fleet, { input = null, slot = 'wor
583
585
  let replaced = null;
584
586
  if (prev?.forgotten) replaced = { session_id: prev.session_id, why: 'the workflow let it go' };
585
587
  else if (prev && prev.machine === machine) {
586
- if (sessionAlive(fleet, prev)) {
588
+ // a session the board closed is not kept, whatever a fleet reading taken before the close still lists
589
+ if (!prev.closed_at && sessionAlive(fleet, prev)) {
587
590
  // the session is kept; the heartbeat's count belongs to the run that ended, so the new run starts it again
588
- const { missing_since: _m, goal_turns: _t, goal_nudged_at: _n, ...kept } = prev;
591
+ const { missing_since: _m, goal_turns: _t, goal_nudged_at: _n, close_requested: _q, closed_at: _c, ...kept } = prev;
589
592
  session = { ...kept, mode: 'adopt', launched_at: now(), seen_at: now() };
590
593
  // a kept session is told what this run is for (its card came back to it, with what happened since)
591
594
  if (input) deliverNow(board, prev.address ?? `sc:${prev.machine}:claude-code:${prev.session_id}`, input, `board-run-${task.id}-r${runId}`);
@@ -462,7 +462,8 @@ const ACTIONS = {
462
462
  },
463
463
  cleanup_workspace(ctx) { ctx.effects.push({ kind: 'cleanup_workspace', id: ctx.id }); },
464
464
  stop_run(ctx) { ctx.effects.push({ kind: 'stop_run', id: ctx.id, runId: ctx.runId }); },
465
- close_session(ctx, slot) { ctx.effects.push({ kind: 'close_session', id: ctx.id, slot }); },
465
+ // the run leaving the status is the one whose session closes, never a run started after it (a reclaim's successor)
466
+ close_session(ctx, slot) { ctx.effects.push({ kind: 'close_session', id: ctx.id, slot, runId: ctx.runId }); },
466
467
  // the slot's last session is let go: its next run starts a new session (a card's context is otherwise kept: a
467
468
  // session that cannot be resumed stops the card, it is never replaced on the board's own account)
468
469
  forget_session(ctx, slot) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-orchestrator",
3
- "version": "0.4.48",
3
+ "version": "0.4.50",
4
4
  "type": "module",
5
5
  "description": "The orchestrator runtime over the Volter Harness ontology: one typed operational model whose folder is its serialization, read and written through the harness orchestration doors (docs/ORCHESTRATOR-IR.md)",
6
6
  "exports": {