@botbuddy/cli 1.123.7 → 1.124.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.124.1
4
+
5
+ - BOT-3700: a fleet host now applies a stack's migrations with `supabase db push --local --include-all`, as staging and production do. A lease that re-adopts a warm stack no longer fails at `stage=schema` when the branch gained a migration older than one the stack already held. A remaining migration-history refusal is named on the provision failure as `history=out_of_order` or `history=missing_local`.
6
+
7
+ ## 1.124.0
8
+
9
+ - BOT-3690: a `bb stack run --test-child --child-placement require-host` run no longer holds a stack while it waits for the host's runner. The control plane admits the run's stack only together with a free runner slot on the same host, so a queued run holds neither, and its line says which it waits for: `stack: waiting for a runner slot on <host> — no stack is held while waiting (the stack and the runner are admitted together)` (or a stack unit, or both). The request now sends `runner_wait: true`: when this slot's idle stack sits on a host whose runner is busy, the stack is not re-adopted. It stays idle and reclaimable, and the run prints `stack: TEST_CHILD_RUNNER_WAIT: waiting for a runner slot on <host> …`, parks on the runner release signal (bounded by the pool's next expiry and `--timeout`) and requests again. The receipt carries `runner_pairing` (`waiting_for`, `stack_held: false`, and the runner waits). The placement wait line now says it waits for a runner slot, and each `test_child_waits` entry carries `waiting_for`.
10
+
3
11
  ## 1.123.4
4
12
 
5
13
  - BOT-3678: a checkout whose `.botbuddy-agent.json` predates the `tenant` field (the pre-BOT-1608 `{"schema_version":1,"profile":…}` shape, found on old branches) no longer shows "This repo is bound to a tenant BB status does not support". `bb status-band read` refuses a new `repo_binding_stale` code, and the band (1.12.3) says the checkout's `.botbuddy-agent.json` predates tenant binding and to update this branch from main. A binding that names an unknown tenant still refuses `tenant_mismatch`. No tenant is ever inferred from `profile`.
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.123.7",
3
- "source_commit": "6facb2c1345d29afdeb7e01dc7b48c6f3a22b7c1",
4
- "source_sha256": "32da3f0dde227064c68fbd924594ee0a6315340f74acdc3acf18d7dca7b9fd57",
2
+ "release_version": "1.124.1",
3
+ "source_commit": "1f3575a48c4f392a5bb2883570cf97b7cb5af3ce",
4
+ "source_sha256": "73ecaebabf8ac69618fb4066bc8ac90c12e700bca67c6806ec6931a95fe7d0ff",
5
5
  "target": "darwin-arm64",
6
- "sha256": "a7c335c6d6fc11340f6a4cb7422471d68f7b2ede49585c43a1e6f34673ed959e"
6
+ "sha256": "749c2e8fc3284122973aa6f3763ce09c4e6bd53e2d5700a79d16ca4dcfa865d1"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.123.7",
3
- "source_commit": "6facb2c1345d29afdeb7e01dc7b48c6f3a22b7c1",
4
- "source_sha256": "32da3f0dde227064c68fbd924594ee0a6315340f74acdc3acf18d7dca7b9fd57",
2
+ "release_version": "1.124.1",
3
+ "source_commit": "1f3575a48c4f392a5bb2883570cf97b7cb5af3ce",
4
+ "source_sha256": "73ecaebabf8ac69618fb4066bc8ac90c12e700bca67c6806ec6931a95fe7d0ff",
5
5
  "target": "linux-x64",
6
- "sha256": "5827dad83423d04732a0176e05395d5d8b2ff98c867f738b180acf63a26e7a11"
6
+ "sha256": "5934188f52f9db719e80dda1a471e96888b835f72fb4e6c50d094f0ecf8e3d10"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.123.7",
4
- "source_commit": "6facb2c1345d29afdeb7e01dc7b48c6f3a22b7c1",
5
- "source_sha256": "32da3f0dde227064c68fbd924594ee0a6315340f74acdc3acf18d7dca7b9fd57",
3
+ "release_version": "1.124.1",
4
+ "source_commit": "1f3575a48c4f392a5bb2883570cf97b7cb5af3ce",
5
+ "source_sha256": "73ecaebabf8ac69618fb4066bc8ac90c12e700bca67c6806ec6931a95fe7d0ff",
6
6
  "targets": {
7
7
  "darwin-arm64": {
8
8
  "goos": "darwin",
9
9
  "goarch": "arm64",
10
10
  "binary": "daemon/bin/darwin-arm64/botbuddy-daemon",
11
- "sha256": "a7c335c6d6fc11340f6a4cb7422471d68f7b2ede49585c43a1e6f34673ed959e",
11
+ "sha256": "749c2e8fc3284122973aa6f3763ce09c4e6bd53e2d5700a79d16ca4dcfa865d1",
12
12
  "mode": "0755"
13
13
  },
14
14
  "linux-x64": {
15
15
  "goos": "linux",
16
16
  "goarch": "amd64",
17
17
  "binary": "daemon/bin/linux-x64/botbuddy-daemon",
18
- "sha256": "5827dad83423d04732a0176e05395d5d8b2ff98c867f738b180acf63a26e7a11",
18
+ "sha256": "5934188f52f9db719e80dda1a471e96888b835f72fb4e6c50d094f0ecf8e3d10",
19
19
  "mode": "0755"
20
20
  }
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botbuddy/cli",
3
- "version": "1.123.7",
3
+ "version": "1.124.1",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
package/src/stack.mjs CHANGED
@@ -66,7 +66,7 @@ import { provisionFailureFields, provisionFailureLine } from "./stack-provision-
66
66
  import { hostChildApi, hostChildReceiptFields, startHostChild, childEnvFrom, testRunIdFrom, HOST_CHILD_DEFAULT_MAX_RUNTIME_S } from "./host-child.mjs";
67
67
  import { HOST_CHILD_ARTIFACT_GLOBS_MAX, returnHostChildArtifacts, validateChildArtifactGlob } from "./host-child-artifacts.mjs";
68
68
  import { childLayerPrerequisites, headDeclaresChildLayer, headSystemPackages, headToolchain, systemPackagesPrerequisites, toolchainConflictError, toolchainPrerequisites } from "./host-toolchain.mjs";
69
- import { acquireTestChildSlot, CHILD_PLACEMENT_REQUIRED, defaultTestChildWait, readPs, requesterSample, startChildSampler, testChildApi, testChildReceiptFields } from "./test-child.mjs";
69
+ import { acquireTestChildSlot, CHILD_PLACEMENT_REQUIRED, defaultTestChildWait, FALLBACK_PARK_MS, pairedQueueLine, readPs, requesterSample, runnerWaitLine, startChildSampler, TEST_CHILD_RUNNER_WAIT, testChildApi, testChildReceiptFields } from "./test-child.mjs";
70
70
 
71
71
  export const STACK_SCHEMA_VERSION = 1;
72
72
 
@@ -1173,8 +1173,18 @@ export function describeUnitLedger(ledger) {
1173
1173
  return lines;
1174
1174
  }
1175
1175
 
1176
+ /** BOT-3690: the receipt's `runner_pairing`: which slot a require-host run waited for, holding no stack. */
1177
+ export function runnerPairingReceipt(p) {
1178
+ return {
1179
+ waiting_for: p.waiting_for ?? null, stack_held: p.stack_held === true,
1180
+ ...(p.queued_at ? { queued_at: p.queued_at } : {}),
1181
+ ...(p.runner_waits ? { runner_waits: p.runner_waits, first_wait_at: p.first_wait_at ?? null, run_host: p.run_host ?? null, idle_lease_id: p.idle_lease_id ?? null } : {}),
1182
+ };
1183
+ }
1184
+
1176
1185
  function queueReceiptFields(d) {
1177
1186
  return {
1187
+ ...(d?.waiting_for ? { waiting_for: d.waiting_for, stack_held: false } : {}),
1178
1188
  queue_position: d?.queue_position ?? null,
1179
1189
  ...(d?.queue_position_reason !== undefined ? { queue_position_reason: d.queue_position_reason } : {}),
1180
1190
  ...(d?.scored_ticket_id !== undefined ? { scored_ticket_id: d.scored_ticket_id } : {}),
@@ -4382,7 +4392,7 @@ export async function runStackLifecycle(opts, childArgv, adapters = {}) {
4382
4392
  return { exitCode: EXIT.INVALID, outcome: "refused", code: "TOOLCHAIN_PREREQUISITE_CONFLICT", error: toolchainConflictError(declared.conflicts) };
4383
4393
  }
4384
4394
  }
4385
- const freshBox = () => ({ incident: null, execution: null, idleLease: null, webUrl: null, portBlock: { released: false, reason: "no port-block claim was created before stack allocation" } });
4395
+ const freshBox = () => ({ incident: null, execution: null, idleLease: null, runnerPairing: null, webUrl: null, portBlock: { released: false, reason: "no port-block claim was created before stack allocation" } });
4386
4396
  const incidentBox = freshBox();
4387
4397
  const startedAtMs = (adapters.now ?? Date.now)();
4388
4398
  // BOT-3109: watch this machine's own primary network for the run's life (null disables).
@@ -4429,7 +4439,9 @@ async function runStackLifecycleWatched(opts, childArgv, adapters, firstBox, fre
4429
4439
  const withExecution = incidentBox.execution && !withIncident?.execution ? { ...withIncident, execution: incidentBox.execution } : withIncident;
4430
4440
  const withIdleOnly = incidentBox.idleLease && !withExecution?.idleLease ? { ...withExecution, idleLease: incidentBox.idleLease } : withExecution;
4431
4441
  // BOT-3240: the test child's placement and cost ride every result shape, refusals included.
4432
- const withIdle = incidentBox.testChild && withIdleOnly && !withIdleOnly.testChild ? { ...withIdleOnly, testChild: incidentBox.testChild } : withIdleOnly;
4442
+ const withTestChild = incidentBox.testChild && withIdleOnly && !withIdleOnly.testChild ? { ...withIdleOnly, testChild: incidentBox.testChild } : withIdleOnly;
4443
+ // BOT-3690: which slot a paired run waited for, and that it held no stack while it did.
4444
+ const withIdle = incidentBox.runnerPairing && withTestChild && !withTestChild.runnerPairing ? { ...withTestChild, runnerPairing: incidentBox.runnerPairing } : withTestChild;
4433
4445
  const withPortBlock = incidentBox.portBlock && !withIdle?.portBlock ? { ...withIdle, portBlock: incidentBox.portBlock } : withIdle;
4434
4446
  const withWebUrl = incidentBox.webUrl && withPortBlock && !withPortBlock.webUrl ? { ...withPortBlock, webUrl: incidentBox.webUrl } : withPortBlock;
4435
4447
  const withStopSignal = incidentBox.stopSignal && withWebUrl ? { ...withWebUrl, stopSignal: incidentBox.stopSignal } : withWebUrl;
@@ -4662,6 +4674,8 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
4662
4674
  // BOT-1803: idle-lease bookkeeping for the receipt.
4663
4675
  const idleLease = { reused: null, reprovisioned: null, previousLeaseId: null, stackDigest: null, readoptHealth: null };
4664
4676
  incidentBox.idleLease = idleLease;
4677
+ // BOT-3690: set only for a require-host child, whose stack and runner are admitted together.
4678
+ let runnerPairing = null;
4665
4679
  // BOT-1803: set when this run's port block must stay reserved although nothing of ours
4666
4680
  // was provisioned (the slot's idle/live stack in THIS directory is still bound to it).
4667
4681
  let retainBlock = false;
@@ -5051,7 +5065,9 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
5051
5065
  require_stack_digest: true,
5052
5066
  // BOT-2269: what the bundle carries beyond the defaults (paths, sha256, key NAMES).
5053
5067
  ...(bundle?.included?.length ? { bundle_included: bundle.included } : {}),
5054
- ...(requireHostChild ? { child_host_prerequisites: childPrerequisites } : {}),
5068
+ // BOT-3690: the lease is admitted only together with a runner slot on its host; runner_wait
5069
+ // says this CLI waits on the runner signal when its idle stack's runner is busy.
5070
+ ...(requireHostChild ? { child_host_prerequisites: childPrerequisites, runner_wait: true } : {}),
5055
5071
  ...(requesterCallbackPort != null ? { callback_port: requesterCallbackPort,
5056
5072
  ...(requireNativeCallback ? { callback_transport: NATIVE_CALLBACK_TRANSPORT } : autoCallbackPolicy ? { callback_policy: "auto" } : {}) } : {}),
5057
5073
  };
@@ -5312,6 +5328,36 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
5312
5328
  }
5313
5329
  continue;
5314
5330
  }
5331
+ // BOT-3690: this slot's idle stack sits on a host whose runner is busy. It is left idle (and
5332
+ // reclaimable), so this run holds nothing while it waits: park on the runner signal (the
5333
+ // BOT-2969 release spine) bounded by the pool's next expiry, then request again.
5334
+ if (requireHostChild && request.data?.success === false && request.data.code === TEST_CHILD_RUNNER_WAIT && request.data.run_host) {
5335
+ const d = request.data;
5336
+ const nowMs = (adapters.now ?? Date.now)();
5337
+ runnerPairing ??= { waiting_for: "runner", stack_held: false, runner_waits: 0, first_wait_at: new Date(nowMs).toISOString(),
5338
+ run_host: d.run_host, idle_lease_id: d.lease_id ?? null, deadlineMs: nowMs + (opts.queueParkTimeout ?? opts.timeout) * 1000 };
5339
+ incidentBox.runnerPairing = runnerPairing;
5340
+ if (runnerPairing.runner_waits === 0) stderrLine(runnerWaitLine(d));
5341
+ runnerPairing.runner_waits += 1;
5342
+ if (nowMs >= runnerPairing.deadlineMs) {
5343
+ return { exitCode: EXIT.TIMEOUT, outcome: "timeout", code: TEST_CHILD_RUNNER_WAIT,
5344
+ error: `the runner slot on ${d.run_host} stayed held for --timeout; no stack was used while waiting (idle stack ${d.lease_id ?? "?"} stayed idle)` };
5345
+ }
5346
+ const expiryMs = Date.parse(d.next_expiry_at ?? "");
5347
+ const deadline = new Date(Math.min(Number.isFinite(expiryMs) ? expiryMs : nowMs + FALLBACK_PARK_MS, runnerPairing.deadlineMs)).toISOString();
5348
+ const since = Number.isSafeInteger(Number(d.signal_cursor)) ? Number(d.signal_cursor) : null;
5349
+ activeWaitAbort = new AbortController();
5350
+ let parked = false;
5351
+ try { parked = await (adapters.testChildWait ?? defaultTestChildWait)({ runHost: d.run_host, deadline, since, signal: activeWaitAbort.signal }); } catch { parked = false; }
5352
+ activeWaitAbort = null;
5353
+ if (receivedSignal) return { exitCode: SIGNAL_EXIT[receivedSignal] ?? EXIT.INTERNAL, outcome: "interrupted", code: TEST_CHILD_RUNNER_WAIT };
5354
+ if (!parked) {
5355
+ return { exitCode: EXIT.BACKEND, outcome: "error", code: TEST_CHILD_RUNNER_WAIT,
5356
+ error: `the wait for a runner slot on ${d.run_host} failed; no lease was taken and idle stack ${d.lease_id ?? "?"} stays idle` };
5357
+ }
5358
+ attempt = -1; // a fresh request: its idle-stack answers are judged as the first
5359
+ continue;
5360
+ }
5315
5361
  let why = attempt === 0 && request.data?.success === false && request.data?.lease_id ? IDLE_REPROVISION_REASONS[request.data.code] : null;
5316
5362
  // BOT-2403: a re-adopted idle stack is handed over only when its edge runtime still sees
5317
5363
  // the functions (the gate restarts the runtime once). Still broken → reap it and send the
@@ -5571,6 +5617,13 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
5571
5617
  if (state === "queued") {
5572
5618
  // BOT-2019: say where the lease sits (server dispatch rank, or why it has none) before parking.
5573
5619
  stderrLine(`stack: lease ${leaseId} queued — ${describeQueuePosition(parkView)}`);
5620
+ // BOT-3690: a paired lease names the slot it waits for; it holds no stack while queued.
5621
+ const pairedLine = requireHostChild ? pairedQueueLine(parkView) : null;
5622
+ if (pairedLine) {
5623
+ stderrLine(pairedLine);
5624
+ runnerPairing = { ...(runnerPairing ?? {}), waiting_for: parkView.waiting_for, stack_held: false, queued_at: runnerPairing?.queued_at ?? new Date((adapters.now ?? Date.now)()).toISOString() };
5625
+ incidentBox.runnerPairing = runnerPairing;
5626
+ }
5574
5627
  for (const line of describeAdmission(parkView.admission)) stderrLine(`stack: ${line}`);
5575
5628
  for (const line of describeUnitLedger(parkView.ledger)) stderrLine(`stack: ${line}`);
5576
5629
  for (const line of describeConsidered(parkView.considered)) stderrLine(`stack: ${line}`);
@@ -6364,6 +6417,7 @@ export function runReceiptFields(result) {
6364
6417
  // BOT-3478 (AC-7): why the lease was preempted, and for over_limit the limit and both leases.
6365
6418
  ...(result.preemption ?? {}),
6366
6419
  ...(result.idleLease?.reused ? { reused: result.idleLease.reused } : {}),
6420
+ ...(result.runnerPairing ? { runner_pairing: runnerPairingReceipt(result.runnerPairing) } : {}),
6367
6421
  ...(result.idleLease?.reprovisioned ? { reprovisioned: result.idleLease.reprovisioned } : {}),
6368
6422
  ...(result.idleLease?.previousLeaseId ? { previous_lease_id: result.idleLease.previousLeaseId } : {}),
6369
6423
  ...(result.idleLease?.stackDigest ? { stack_digest: result.idleLease.stackDigest } : {}),
@@ -110,6 +110,27 @@ export function requiredHostError(placement) {
110
110
  return `--child-placement require-host: placement chose ${placement?.host_kind ?? "no host"} (${placement?.placement_reason ?? "unknown"}), not the serving host${missing}; the child was not started`;
111
111
  }
112
112
 
113
+ /** BOT-3690: the paired-admission answer for an idle stack whose host runner is busy. */
114
+ export const TEST_CHILD_RUNNER_WAIT = "TEST_CHILD_RUNNER_WAIT";
115
+ const WAITING_FOR_WORDS = Object.freeze({ runner: "a runner slot", stack: "a stack unit", stack_and_runner: "a stack unit and a runner slot" });
116
+
117
+ /**
118
+ * BOT-3690: a require-host child's lease is admitted only together with a runner slot on its
119
+ * host, so a queued one holds neither. Names the slot it waits for; null for an unpaired lease.
120
+ */
121
+ export function pairedQueueLine(d) {
122
+ if (!d?.waiting_for) return null;
123
+ return `stack: waiting for ${WAITING_FOR_WORDS[d.waiting_for] ?? d.waiting_for} on ${d.host_key ?? "the host"} — `
124
+ + "no stack is held while waiting (the stack and the runner are admitted together)";
125
+ }
126
+
127
+ /** BOT-3690: the line for an idle stack left idle while its next run waits for the runner. */
128
+ export function runnerWaitLine(d) {
129
+ const counts = Number.isInteger(d?.held) && Number.isInteger(d?.slots) ? ` (${d.held} of ${d.slots} held)` : "";
130
+ return `stack: ${TEST_CHILD_RUNNER_WAIT}: waiting for a runner slot on ${d?.run_host ?? "the host"}${counts} — `
131
+ + `no stack is in use while waiting; idle stack ${d?.lease_id ?? "?"} stays idle · reclaimable until the runner frees`;
132
+ }
133
+
113
134
  export const RUNNABLE_HOST_KINDS = Object.freeze(["requester", "serving_host"]);
114
135
 
115
136
  export async function acquireTestChildSlot({ api, leaseId, wait = defaultTestChildWait, log = () => {}, isStopped = () => false, maxWaits = Infinity, onPark = async () => {}, signal = null, sample = placementSample, prerequisites = null, requireHost = false }) {
@@ -149,9 +170,9 @@ export async function acquireTestChildSlot({ api, leaseId, wait = defaultTestChi
149
170
  const deadline = Number.isFinite(expiryMs) ? new Date(expiryMs).toISOString() : new Date(Date.now() + FALLBACK_PARK_MS).toISOString();
150
171
  if (waits.length === 0) {
151
172
  log(data.limit === "admission" ? admissionWaitLine(data)
152
- : `stack: ${TEST_CHILD_CAPACITY}: all ${data.slots} test_child slot(s) on ${data.run_host} are held — waiting (no slot is held while waiting)${data.limit ? ` · limit: ${data.limit}` : ""}`);
173
+ : `stack: ${TEST_CHILD_CAPACITY}: all ${data.slots} test_child slot(s) on ${data.run_host} are held — waiting for a runner slot (no runner slot is held while waiting)${data.limit ? ` · limit: ${data.limit}` : ""}`);
153
174
  }
154
- waits.push({ at: new Date().toISOString(), held: data.held ?? null, slots: data.slots ?? null, run_host: data.run_host ?? null,
175
+ waits.push({ at: new Date().toISOString(), waiting_for: data.limit === "admission" ? "admission" : "runner", held: data.held ?? null, slots: data.slots ?? null, run_host: data.run_host ?? null,
155
176
  ...(data.limit === "admission" ? { admission_code: data.admission_code ?? data.admission?.code ?? null } : {}) });
156
177
  if (waits.length > maxWaits || isStopped()) {
157
178
  return { ok: false, code: TEST_CHILD_CAPACITY, waits, error: `all test_child slots on ${data.run_host} stayed held` };