@bakers-build/conductor 0.20.0 → 0.21.1-next.1

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.
@@ -68,6 +68,12 @@ export declare class Conductor {
68
68
  private readonly slots;
69
69
  /** The runtime alias of each run this process dispatched. */
70
70
  private readonly runRuntimes;
71
+ /**
72
+ * Tickets whose dispatch failed for a reason that cannot heal by itself, by
73
+ * ticket uuid; the server does not claim them until the recheck passes.
74
+ * shortcut: in memory, so a restart costs one more failed run before the hold returns; persist beside the frozen-state file if that matters.
75
+ */
76
+ private readonly heldTickets;
71
77
  /** Serializes git worktree add/remove: parallel ones fight over git locks. */
72
78
  private gitLock;
73
79
  /** The last good machine `tunnel` policy, re-read for each run's env. */
@@ -278,6 +284,8 @@ export declare class Conductor {
278
284
  * (missing or broken) or a failed read keeps the last good value.
279
285
  */
280
286
  private currentTunnel;
287
+ /** Releases every held ticket whose cause is gone; a failing recheck keeps the hold. */
288
+ private releaseHeals;
281
289
  /** Dispatches one claimed run; a failure terminalises it (BB-149). */
282
290
  private dispatchOrFail;
283
291
  /**
@@ -1,6 +1,6 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
2
2
  import { basename, dirname, join } from 'node:path';
3
- import { killRunProcesses, layeredEnv, loadRunClone, pickSecrets, protectedProjectPaths, saveRunClone, secretsFilePath, shellQuote, stemForConfigFile, transferIsolatedCommit, } from '@bakers-build/core';
3
+ import { DispatchBlocked, isDispatchBlocked, killRunProcesses, layeredEnv, loadRunClone, pickSecrets, protectedProjectPaths, saveRunClone, secretsFilePath, shellQuote, stemForConfigFile, transferIsolatedCommit, } from '@bakers-build/core';
4
4
  import { HttpError } from 'dropsh/plugin';
5
5
  import { CONDUCTOR_TOKEN_ENV, CONDUCTOR_URL_ENV, DEFAULT_ENV_DENY, matchesEnvDeny, } from '../plugins/agent.js';
6
6
  import { homeKey, homePath } from '../plugins/agent-home.js';
@@ -233,6 +233,12 @@ export class Conductor {
233
233
  slots = new SlotResolver();
234
234
  /** The runtime alias of each run this process dispatched. */
235
235
  runRuntimes = new Map();
236
+ /**
237
+ * Tickets whose dispatch failed for a reason that cannot heal by itself, by
238
+ * ticket uuid; the server does not claim them until the recheck passes.
239
+ * shortcut: in memory, so a restart costs one more failed run before the hold returns; persist beside the frozen-state file if that matters.
240
+ */
241
+ heldTickets = new Map();
236
242
  /** Serializes git worktree add/remove: parallel ones fight over git locks. */
237
243
  gitLock = Promise.resolve();
238
244
  /** The last good machine `tunnel` policy, re-read for each run's env. */
@@ -568,6 +574,7 @@ export class Conductor {
568
574
  for (const line of unavailable) {
569
575
  this.logger.warn({ conductorId: this.id }, `claims withheld: ${line}`);
570
576
  }
577
+ await this.releaseHeals();
571
578
  let claimed = 0;
572
579
  // A refusal backs off silently: counted as withheld, so no idle line.
573
580
  let withheld = this.claimsPaused ||
@@ -579,6 +586,9 @@ export class Conductor {
579
586
  run = await this.remote.claimNext({
580
587
  leaseSeconds: this.config.lease_seconds,
581
588
  conductorId: this.id,
589
+ ...(this.heldTickets.size
590
+ ? { excludeTickets: [...this.heldTickets.keys()] }
591
+ : {}),
582
592
  });
583
593
  }
584
594
  catch (err) {
@@ -1363,6 +1373,17 @@ export class Conductor {
1363
1373
  }
1364
1374
  return this.tunnel;
1365
1375
  }
1376
+ /** Releases every held ticket whose cause is gone; a failing recheck keeps the hold. */
1377
+ async releaseHeals() {
1378
+ for (const [ticket, blocked] of this.heldTickets) {
1379
+ if (!(await Promise.resolve()
1380
+ .then(() => blocked.recheck())
1381
+ .catch(() => false)))
1382
+ continue;
1383
+ this.heldTickets.delete(ticket);
1384
+ this.logger.info({ ticket }, 'dispatch unblocked');
1385
+ }
1386
+ }
1366
1387
  /** Dispatches one claimed run; a failure terminalises it (BB-149). */
1367
1388
  async dispatchOrFail(run) {
1368
1389
  const at = {};
@@ -1386,6 +1407,10 @@ export class Conductor {
1386
1407
  this.runRuntimes.delete(run.runUuid);
1387
1408
  if (at.worktree)
1388
1409
  this.config.runtime_isolation?.delete(at.worktree);
1410
+ if (isDispatchBlocked(err)) {
1411
+ this.heldTickets.set(run.ticketUuid, err);
1412
+ this.logger.warn({ run: run.runUuid, ticket: run.ticketUuid, err: err.message }, 'dispatch blocked');
1413
+ }
1389
1414
  try {
1390
1415
  await this.remote.markFailed(run.runUuid, String(err));
1391
1416
  this.signalUi(at.worktree);
@@ -1445,7 +1470,11 @@ export class Conductor {
1445
1470
  catch (err) {
1446
1471
  entry.failure = err instanceof Error ? err.message : String(err);
1447
1472
  log();
1448
- throw new Error(`plugins: ${harness} install failed: ${entry.failure}`);
1473
+ const message = `plugins: ${harness} install failed: ${entry.failure}`;
1474
+ // A block (e.g. a missing login) keeps its recheck, so the ticket is held.
1475
+ if (isDispatchBlocked(err))
1476
+ throw new DispatchBlocked(message, err.recheck);
1477
+ throw new Error(message);
1449
1478
  }
1450
1479
  log();
1451
1480
  return { env: launch.env, args: launch.args };
@@ -59,6 +59,8 @@ export declare class ConductorTakeoverRequired extends Error {
59
59
  export interface ClaimOptions {
60
60
  leaseSeconds: number;
61
61
  conductorId: string;
62
+ /** Tickets the server must not claim: held after a dispatch that cannot heal by itself. */
63
+ excludeTickets?: string[];
62
64
  }
63
65
  export interface ClaimedRun {
64
66
  runUuid: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/conductor",
3
- "version": "0.20.0",
3
+ "version": "0.21.1-next.1",
4
4
  "description": "bakers.build, the open source AI software factory: conductor engine + CLI: registers, claims tickets via JSON:API, dispatches agents.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,14 +43,14 @@
43
43
  "dependencies": {
44
44
  "@dropsh/plugin-jsonapi-schema": "^0.8.2",
45
45
  "@dropsh/plugin-oauth2": "^0.8.2",
46
- "@bakers-build/core": "^0.20.0",
47
- "@bakers-build/message": "^0.20.0",
46
+ "@bakers-build/core": "^0.21.1-next.1",
47
+ "@bakers-build/message": "^0.21.1-next.1",
48
48
  "@modelcontextprotocol/sdk": "1.32.1",
49
49
  "commander": "^12.1.0",
50
50
  "dropsh": "^0.8.2"
51
51
  },
52
52
  "bakersBuild": {
53
- "commit": "f0dfe478bb1378684622216adaa97571657e3e00",
54
- "channel": "latest"
53
+ "commit": "e68e166d4a443132ec8797eaa946a77e0943cfe6",
54
+ "channel": "next"
55
55
  }
56
56
  }