@volter/supercode-orchestrator 0.5.154 → 0.5.155

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/cli.mjs +33 -14
  2. package/package.json +2 -2
package/board/cli.mjs CHANGED
@@ -279,6 +279,9 @@ async function requestedSponsor(args) {
279
279
  return { requestedByUnverified: { observation: args['requested-by'], label: resolved?.label ?? 'unresolved', request: args.request ?? null } };
280
280
  }
281
281
 
282
+ // `list --json` reads each card's parents and standing block per card up to this many cards, and in one read of each past it
283
+ const LIST_PER_CARD = 64;
284
+
282
285
  const tagsOf = (card) => { const tags = Array.isArray(card.tags) ? card.tags : json(card.tags, null); return Array.isArray(tags) ? tags : card.tenant ? [card.tenant] : []; };
283
286
 
284
287
  const say = (args, human, value) => { current().out(args.json ? `${JSON.stringify(value, null, 2)}\n` : `${human}\n`); };
@@ -520,20 +523,36 @@ export async function runVerb(argv) {
520
523
  if (args.json) {
521
524
  // beyond Hermes's fields: the workflow's own status, the cards it waits on and its open run, so a reader of the
522
525
  // whole board (a board file's sync) needs no `show` per card
523
- const extra = withBoard((b) => new Map(cards.map((t) => {
524
- const run = t.current_run_id ? b.db.prepare('SELECT id, status, started_at, metadata FROM task_runs WHERE id = ?').get(t.current_run_id) : null;
525
- const session = run ? json(run.metadata, {})?.supercode ?? {} : {};
526
- return [t.id, {
527
- workflow_status: t.stage ?? t.status,
528
- parents: b.db.prepare('SELECT parent_id FROM task_links WHERE child_id = ? ORDER BY parent_id').all(t.id).map((r) => r.parent_id),
529
- run: run ? { id: run.id, status: run.status, started_at: run.started_at, session: session.address ?? session.session_id ?? null, execution: executionOf(run) } : null,
530
- // the message whose answer its standing block waits for (`block --waiting-on`)
531
- waiting_on: (() => {
532
- const last = b.db.prepare("SELECT kind, payload FROM task_events WHERE task_id = ? AND kind IN ('blocked', 'unblocked', 'dependency_wait') ORDER BY id DESC LIMIT 1").get(t.id);
533
- return last?.kind === 'blocked' ? json(last.payload, {})?.waiting_on ?? null : null;
534
- })(),
535
- }];
536
- })));
526
+ const extra = withBoard((b) => {
527
+ // A whole board's parents and standing blocks are read once, not once per card. Asked per card, the block's
528
+ // read fetched every event row of every card through the card's index to answer from the few of these
529
+ // kinds (on 2026-10-11: 45,670 rows of a 17 MB table for 2,154 cards, to find 332), on the owner's event
530
+ // loop, for as long as the listing took. A short listing still asks per card: it reads less than the scan.
531
+ const whole = cards.length > LIST_PER_CARD;
532
+ const parentsOf = new Map(), standing = new Map();
533
+ if (whole) {
534
+ for (const row of b.db.prepare('SELECT child_id, parent_id FROM task_links ORDER BY child_id, parent_id').all()) {
535
+ if (!parentsOf.has(row.child_id)) parentsOf.set(row.child_id, []);
536
+ parentsOf.get(row.child_id).push(row.parent_id);
537
+ }
538
+ // in id order, so the last one kept for a card is its latest
539
+ for (const row of b.db.prepare("SELECT task_id, kind, payload FROM task_events WHERE kind IN ('blocked', 'unblocked', 'dependency_wait') ORDER BY id").all()) standing.set(row.task_id, row);
540
+ }
541
+ return new Map(cards.map((t) => {
542
+ const run = t.current_run_id ? b.db.prepare('SELECT id, status, started_at, metadata FROM task_runs WHERE id = ?').get(t.current_run_id) : null;
543
+ const session = run ? json(run.metadata, {})?.supercode ?? {} : {};
544
+ return [t.id, {
545
+ workflow_status: t.stage ?? t.status,
546
+ parents: whole ? parentsOf.get(t.id) ?? [] : b.db.prepare('SELECT parent_id FROM task_links WHERE child_id = ? ORDER BY parent_id').all(t.id).map((r) => r.parent_id),
547
+ run: run ? { id: run.id, status: run.status, started_at: run.started_at, session: session.address ?? session.session_id ?? null, execution: executionOf(run) } : null,
548
+ // the message whose answer its standing block waits for (`block --waiting-on`)
549
+ waiting_on: (() => {
550
+ const last = whole ? standing.get(t.id) : b.db.prepare("SELECT kind, payload FROM task_events WHERE task_id = ? AND kind IN ('blocked', 'unblocked', 'dependency_wait') ORDER BY id DESC LIMIT 1").get(t.id);
551
+ return last?.kind === 'blocked' ? json(last.payload, {})?.waiting_on ?? null : null;
552
+ })(),
553
+ }];
554
+ }));
555
+ });
537
556
  say(args, '', cards.map((t) => ({ ...cardDict(t), ...extra.get(t.id) })));
538
557
  return 0;
539
558
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-orchestrator",
3
- "version": "0.5.154",
3
+ "version": "0.5.155",
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": {
@@ -24,7 +24,7 @@
24
24
  "check-types": "node scripts/generate-types.mjs --check"
25
25
  },
26
26
  "dependencies": {
27
- "@volter/supercode-harness-sdk": "^0.3.91",
27
+ "@volter/supercode-harness-sdk": "^0.3.95",
28
28
  "@volter/teams": "0.2.65",
29
29
  "@volter/ztrack": "^2.4.23",
30
30
  "yaml": "^2.9.0"