@volter/supercode-orchestrator 0.4.55 → 0.4.56

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.
Files changed (2) hide show
  1. package/board/dispatch.mjs +23 -1
  2. package/package.json +1 -1
@@ -837,6 +837,27 @@ export function noticeOf(entry, audience, kind, task, payload, comment = null) {
837
837
  return text.trim() ? text : null;
838
838
  }
839
839
 
840
+ /**
841
+ * Who hears a card without having asked: each running card's session hears its card and its subtasks (a subscription a
842
+ * launch or a missed fleet read lost comes back), and each of the workflow's managers (`params.managers`) hears every
843
+ * open card as the `manager` audience, whoever filed it, when the workflow's notify names one.
844
+ */
845
+ function ensureSubscriptions(board, entry) {
846
+ const managers = Array.isArray(entry.params.managers) ? entry.params.managers.map(String) : [];
847
+ const toManagers = Object.keys(entry.workflow.notify?.manager ?? {}).length > 0;
848
+ tx(board, (db) => {
849
+ for (const t of db.prepare("SELECT id, current_run_id FROM tasks WHERE status NOT IN ('done', 'archived')").all()) {
850
+ if (toManagers) for (const m of managers) subscribeIn(db, t.id, m, 'manager');
851
+ if (!t.current_run_id) continue;
852
+ const session = json(db.prepare('SELECT metadata FROM task_runs WHERE id = ?').get(t.current_run_id)?.metadata, {})?.supercode;
853
+ const address = addressOf(session);
854
+ if (!address || (session.slot ?? 'worker') !== 'worker') continue;
855
+ subscribeIn(db, t.id, address, 'worker');
856
+ for (const st of db.prepare('SELECT task_id FROM supercode_cards WHERE subtask_of = ?').all(t.id)) subscribeIn(db, st.task_id, address, 'worker');
857
+ }
858
+ });
859
+ }
860
+
840
861
  /** The event kinds an audience hears (the workflow's notify). */
841
862
  const heardBy = (entry, audience) => Object.keys(entry.workflow.notify?.[audience] ?? {});
842
863
 
@@ -844,7 +865,7 @@ async function notify(board, fleet, report, entry) {
844
865
  const from = boardAddress(board.label);
845
866
  // each subscription's notices go in order; different subscribers are told side by side
846
867
  await pool(subscriptions(board.db).filter((sub) => sub.platform === 'supercode'), SEND_CONCURRENCY, async (sub) => {
847
- const role = ['worker', 'dependency'].includes(sub.delivery_metadata?.role) ? sub.delivery_metadata.role : 'creator';
868
+ const role = ['worker', 'dependency', 'manager'].includes(sub.delivery_metadata?.role) ? sub.delivery_metadata.role : 'creator';
848
869
  // a session the fleet does not list this tick is told next tick: one reading is not a loss (a loaded box drops
849
870
  // sessions from a read, and a dropped subscription never came back), and a session that is replaced on its card
850
871
  // has its subscription moved when the new one starts
@@ -1164,6 +1185,7 @@ export async function tick({ root, lanes, settings, only = null, slugs = null, d
1164
1185
  // what the moves asked for, once they are committed (messages to actors, closed panes, cleaned workspaces)
1165
1186
  await runEffects(board, effects);
1166
1187
  phase('goals');
1188
+ ensureSubscriptions(board, entry);
1167
1189
  await notify(board, fleet, report, entry); phase('notify');
1168
1190
  fireHooks(board, settings, report);
1169
1191
  if (String(board.db.prepare('PRAGMA journal_mode').get()?.journal_mode).toLowerCase() === 'wal') board.db.prepare('PRAGMA wal_checkpoint(PASSIVE)').get();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-orchestrator",
3
- "version": "0.4.55",
3
+ "version": "0.4.56",
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": {