@botbuddy/cli 1.106.2 → 1.109.0

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,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.108.0
4
+
5
+ - BOT-3399: a callback suite can run as a test child on its stack's fleet host. `bb stack run --test-child --child-placement require-host --callback-port N` asks for no requester callback route and no requester origin: the stack keeps its own host-local auth origin (GoTrue's external URL is the host's `127.0.0.1:<api port>`), and the port is declared on the host run. The host daemon proves the route before the child starts: it listens where the lease's own edge runtime resolves `host.docker.internal`, admits only that container, and forwards to the child's `127.0.0.1:N` (`BOTBUDDY_CALLBACK_PORT`, `BOTBUDDY_CALLBACK_LISTEN`). The relay runs inside the child's unit, so the route lives exactly as long as the child. A route that cannot be set up (for example the port is in use) fails the run with `HOST_CALLBACK_ROUTE_UNAVAILABLE` before the child starts, and the receipt shows `callback_transport: host_local_v1`. A prefer-host callback child that lands on the serving host is now refused with `HOST_CALLBACK_ROUTE_UNAVAILABLE` instead of running with a route that leads back to this machine. Placement asks for a host that advertises `host-local-callback`, so a host on an older daemon never starts such a child without its route. Needs MCP 2.149.0 and this daemon on the host.
6
+
3
7
  ## 1.106.2
4
8
 
5
9
  - BOT-3025: `bb stack run --host <host> --callback-port N` now goes through the identified admission like an unpinned run: it asks for `callback_policy auto` (the pin is sent as `host_key`) and reserves a requester origin. On a Linux Go host (protocol 5) the lease answers `native_origin_v1` and the callback takes the native route, instead of the loopback `-R` that a Linux container cannot reach through `host.docker.internal`; generated GoTrue links name the requester origin, never the unforwarded remote API port. A pin to a host that cannot serve the native route is refused `HOST_CALLBACK_TRANSPORT_UNSUPPORTED` before the child starts (never a fallback to `-R`). A pin that names this machine stays co-located and unchanged. `--stack-path` and fixed-nonce runs keep the legacy path, and a beta-ring `--host` pin is still refused a requester origin.
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.106.2",
3
- "source_commit": "b0bab35ab46bec60cf4554a7c4df08554d8c5624",
4
- "source_sha256": "916aff86d976c832370e70811cb633b742aa0cb722c8ce0c21282d14981dc3e7",
2
+ "release_version": "1.109.0",
3
+ "source_commit": "657abfe1b8b9be22c3a9c6500e267d81d6d74cc2",
4
+ "source_sha256": "39d0be4c288a6a187241be394ba0f6d2d058edb2fcf63c08b4d54404b8f2c77c",
5
5
  "target": "darwin-arm64",
6
- "sha256": "67e07a4b8f1bbc17582df37f4758650542e145b7ebbdf26e0f5579a73cbca367"
6
+ "sha256": "72f29fd91b98c53661c1bd37dbc92772b46d5c4a6cf5b27af3f0c6f251d10976"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.106.2",
3
- "source_commit": "b0bab35ab46bec60cf4554a7c4df08554d8c5624",
4
- "source_sha256": "916aff86d976c832370e70811cb633b742aa0cb722c8ce0c21282d14981dc3e7",
2
+ "release_version": "1.109.0",
3
+ "source_commit": "657abfe1b8b9be22c3a9c6500e267d81d6d74cc2",
4
+ "source_sha256": "39d0be4c288a6a187241be394ba0f6d2d058edb2fcf63c08b4d54404b8f2c77c",
5
5
  "target": "linux-x64",
6
- "sha256": "19b110b0ef1bf918cdaf02791bb25c0991f5963fad0bf35dfc0ab705d79a43df"
6
+ "sha256": "35abb00a5e1a80c535cad8d9808baa470cebbc0f6ebfd388b7c5b033ba405354"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.106.2",
4
- "source_commit": "b0bab35ab46bec60cf4554a7c4df08554d8c5624",
5
- "source_sha256": "916aff86d976c832370e70811cb633b742aa0cb722c8ce0c21282d14981dc3e7",
3
+ "release_version": "1.109.0",
4
+ "source_commit": "657abfe1b8b9be22c3a9c6500e267d81d6d74cc2",
5
+ "source_sha256": "39d0be4c288a6a187241be394ba0f6d2d058edb2fcf63c08b4d54404b8f2c77c",
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": "67e07a4b8f1bbc17582df37f4758650542e145b7ebbdf26e0f5579a73cbca367",
11
+ "sha256": "72f29fd91b98c53661c1bd37dbc92772b46d5c4a6cf5b27af3f0c6f251d10976",
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": "19b110b0ef1bf918cdaf02791bb25c0991f5963fad0bf35dfc0ab705d79a43df",
18
+ "sha256": "35abb00a5e1a80c535cad8d9808baa470cebbc0f6ebfd388b7c5b033ba405354",
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.106.2",
3
+ "version": "1.109.0",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
@@ -106,7 +106,7 @@ export function hostRunExitCode(run) {
106
106
  export async function startHostChild({
107
107
  api, upload, slotId, argv, env = {}, worktreeRoot, maxRuntimeSeconds = HOST_CHILD_DEFAULT_MAX_RUNTIME_S,
108
108
  bundle: prebuilt = null, wait = defaultHostChildWait, log = () => {}, writeOutput = (s) => process.stdout.write(s), now = Date.now,
109
- signal = undefined, artifactGlobs = [], fetchArtifacts = fetch, testRunId = null,
109
+ signal = undefined, artifactGlobs = [], fetchArtifacts = fetch, testRunId = null, callbackPort = null,
110
110
  }) {
111
111
  const bundle = prebuilt ?? buildHeadBundle(worktreeRoot);
112
112
  if (!bundle.ok) return { ok: false, code: "HOST_CHILD_BUNDLE_FAILED", error: bundle.error };
@@ -116,7 +116,9 @@ export async function startHostChild({
116
116
  created = await api.create({ slot_id: slotId, argv, cwd: "", env, bundle_sha256: bundle.sha256, bundle_size_bytes: bundle.sizeBytes, max_runtime_seconds: maxRuntimeSeconds,
117
117
  ...(artifactGlobs.length ? { artifact_globs: artifactGlobs } : {}),
118
118
  // BOT-3464: the child's own run credential may add timing to this test run only.
119
- ...(testRunId ? { test_run_id: testRunId } : {}) });
119
+ ...(testRunId ? { test_run_id: testRunId } : {}),
120
+ // BOT-3399: the lease's edge runtime reaches the child's 127.0.0.1:<port> on its host.
121
+ ...(callbackPort != null ? { callback_port: callbackPort } : {}) });
120
122
  } catch (error) { created = { ok: false, error: String(error?.message ?? error) }; }
121
123
  const c = created?.data;
122
124
  if (!created?.ok || !c?.success) {
@@ -127,3 +127,47 @@ export function childLayerPrerequisites(prerequisites, declaresLayer) {
127
127
  if (declaresLayer && !wanted.includes(CHILD_LAYER_CAPABILITY)) wanted.push(CHILD_LAYER_CAPABILITY);
128
128
  return wanted;
129
129
  }
130
+
131
+ // BOT-3470 — the system packages a dependency layer declares (`system_packages` in
132
+ // `.botbuddy/child-layer.json`). The host fetches, verifies and overlays them on each child's
133
+ // own /usr, and proves the capabilities they `provide` with the declared probe before any
134
+ // child starts. So a requirement the head's packages provide needs only a host that serves
135
+ // system packages for the declared distribution.
136
+ const SYSTEM_PACKAGES_DISTRIBUTION = /^[a-z][a-z0-9]{0,31}-[0-9]{1,4}(?:\.[0-9]{1,4}){0,2}$/;
137
+ const CAPABILITY_NAME = /^[a-z][a-z0-9-]{0,47}$/;
138
+
139
+ /** `ubuntu-26.04` → `system-packages-ubuntu-26-04`, the name a serving host reports. */
140
+ export function systemPackagesCapability(distribution) {
141
+ return `system-packages-${distribution.replaceAll(".", "-")}`;
142
+ }
143
+
144
+ /** The committed head's `system_packages` (distribution and provides), or null. */
145
+ export function headSystemPackages(worktreeRoot, { run = spawnSync } = {}) {
146
+ // nosemgrep: javascript.lang.security.detect-child-process.detect-child-process -- fixed argv, no shell.
147
+ const shown = run("git", ["-C", worktreeRoot, "show", `HEAD:${CHILD_LAYER_MANIFEST}`], { encoding: "utf8", maxBuffer: MAX_BYTES });
148
+ if (shown.status !== 0 || typeof shown.stdout !== "string") return null;
149
+ let doc;
150
+ try {
151
+ doc = JSON.parse(shown.stdout);
152
+ } catch {
153
+ return null; // the host refuses a malformed manifest by name
154
+ }
155
+ const declared = doc?.system_packages;
156
+ if (!declared || typeof declared !== "object" || !SYSTEM_PACKAGES_DISTRIBUTION.test(declared.distribution ?? "")) return null;
157
+ const provides = Array.isArray(declared.provides) ? declared.provides.filter((p) => typeof p === "string" && CAPABILITY_NAME.test(p)) : [];
158
+ return { distribution: declared.distribution, provides };
159
+ }
160
+
161
+ /**
162
+ * Placement prerequisites for a head's system packages: each requirement they provide is
163
+ * replaced by the host's `system-packages-<distribution>`, which a declaring head always needs.
164
+ */
165
+ export function systemPackagesPrerequisites(prerequisites, declared) {
166
+ const wanted = [...(prerequisites ?? [])];
167
+ if (!declared) return { prerequisites: wanted, provided: [] };
168
+ const capability = systemPackagesCapability(declared.distribution);
169
+ const provided = wanted.filter((p) => declared.provides.includes(p));
170
+ const rest = wanted.filter((p) => !declared.provides.includes(p));
171
+ if (!rest.includes(capability)) rest.push(capability);
172
+ return { prerequisites: rest, provided };
173
+ }
package/src/stack.mjs CHANGED
@@ -64,7 +64,7 @@ import { REQUESTER_NETWORK_CANDIDATE_CODES, REQUESTER_NETWORK_FAILURE_SLACK_MS,
64
64
  import { provisionFailureFields, provisionFailureLine } from "./stack-provision-failure.mjs";
65
65
  import { hostChildApi, hostChildReceiptFields, startHostChild, childEnvFrom, testRunIdFrom, HOST_CHILD_DEFAULT_MAX_RUNTIME_S } from "./host-child.mjs";
66
66
  import { HOST_CHILD_ARTIFACT_GLOBS_MAX, returnHostChildArtifacts, validateChildArtifactGlob } from "./host-child-artifacts.mjs";
67
- import { childLayerPrerequisites, headDeclaresChildLayer, headToolchain, toolchainConflictError, toolchainPrerequisites } from "./host-toolchain.mjs";
67
+ import { childLayerPrerequisites, headDeclaresChildLayer, headSystemPackages, headToolchain, systemPackagesPrerequisites, toolchainConflictError, toolchainPrerequisites } from "./host-toolchain.mjs";
68
68
  import { acquireTestChildSlot, CHILD_PLACEMENT_REQUIRED, defaultTestChildWait, readPs, requesterSample, startChildSampler, testChildApi, testChildReceiptFields } from "./test-child.mjs";
69
69
 
70
70
  export const STACK_SCHEMA_VERSION = 1;
@@ -79,8 +79,20 @@ export const STACK_SCHEMA_VERSION = 1;
79
79
  * keep the legacy path unchanged. Beta:
80
80
  * BOT-2780's `--remote --reap` gate, which refuses those contexts instead.
81
81
  */
82
+ /**
83
+ * BOT-3399: a test child that must run on the serving host and declares a callback port gets a
84
+ * host-local callback route (host_local_v1): the lease's edge runtime reaches the child on that
85
+ * host. Such a run asks for no requester route and no requester origin.
86
+ */
87
+ export const HOST_LOCAL_CALLBACK_TRANSPORT = "host_local_v1";
88
+ export const HOST_LOCAL_CALLBACK_CAPABILITY = "host-local-callback";
89
+ export const hostLocalCallbackRun = (opts) => Boolean(opts.testChild) && opts.childPlacement === "require-host" && opts.callbackPort != null;
90
+
82
91
  export const requesterOriginEnabled = (opts) => {
83
92
  if (opts.execution === "local" || opts.localOnly || opts.localExec) return false;
93
+ // BOT-3399: a require-host test child reads its auth links on the serving host, so GoTrue keeps
94
+ // the stack's own host-local API origin; a requester origin would name this machine instead.
95
+ if (opts.testChild && opts.childPlacement === "require-host") return false;
84
96
  // Beta keeps BOT-2780's gate (remote + --reap); its idle/callback runs stay on BOT-2775's path.
85
97
  if (opts.executionRing === "beta") return opts.execution === "remote" && opts.reap === true;
86
98
  if (opts.execution != null && opts.execution !== "auto" && opts.execution !== "remote") return false;
@@ -204,6 +216,15 @@ ${bold("up OPTIONS")}
204
216
  supabase/config.toml declares a DISTINCT project_id + remapped ports,
205
217
  or use 'stack run', which materializes one for you.
206
218
  --purpose <text> Free-text purpose recorded on the lease.
219
+ --admission-class <label>
220
+ BOT-3363 (up and run): the workload class this request declares (a-z, 0-9, . _ : -).
221
+ A host with admission settings reserves memory per class = tenant + label; a host
222
+ whose settings name gated labels gates only requests declaring one of them.
223
+ --admission-cost <size> BOT-3363 (up and run): the declared default memory cost (3GiB, 512MiB or bytes). The
224
+ host admission ledger admits the lease only when baseline + reserved + this cost fits
225
+ the host's memory ceiling and observed free memory; otherwise it waits and prints
226
+ bb wait 'admit:id=<lease_id>'. A cost above the ceiling is refused at once
227
+ (ADMISSION_COST_EXCEEDS_CEILING). Omitted = the host's default cost.
207
228
  --idle-ttl <seconds> Idle seconds before the reaper STOPS an unused stack (default 1800).
208
229
  --timeout <seconds> Seconds to park for capacity (default ${DEFAULT_TIMEOUT_SEC} = 72 h, BOT-2400). At the
209
230
  deadline the lease is NOT released: it keeps its queue place (owner hold) and the
@@ -319,7 +340,8 @@ ${bold("run OPTIONS")}
319
340
  serving_host, and the slot and the lease are released. A full serving-host
320
341
  pool still waits for a slot.
321
342
  --child-requires LIST BOT-3030: what the child needs on a host (comma list: node>=24,pnpm,deno,
322
- curl,git,jq,psql,tar,playwright-chromium-libs). node, pnpm and deno count
343
+ curl,git,jq,psql,tar,playwright-chromium-libs, or a name the head's
344
+ system_packages provide, e.g. playwright-webkit-libs). node, pnpm and deno count
323
345
  only when they run inside a child's sandbox on that host (BOT-3402).
324
346
  BOT-3395: curl, git, jq, psql and tar count only when they run inside a
325
347
  child's sandbox too, and the host reports each one's version. A host
@@ -378,6 +400,12 @@ ${bold("run OPTIONS")}
378
400
  throwaway reverse forward and opens -R 127.0.0.1:N:127.0.0.1:N only when
379
401
  the host keeps it on loopback (sshd GatewayPorts no/clientspecified);
380
402
  otherwise exit 5 CALLBACK_NOT_LOOPBACK (BOT-2184).
403
+ With --test-child --child-placement require-host the route is host-local
404
+ instead (BOT-3399, host_local_v1): no requester route or origin; the host
405
+ relays the lease's own edge runtime to the child's 127.0.0.1:N
406
+ (BOTBUDDY_CALLBACK_PORT, BOTBUDDY_CALLBACK_LISTEN) for the life of the child,
407
+ or refuses with HOST_CALLBACK_ROUTE_UNAVAILABLE before it starts. A
408
+ prefer-host callback child placed on the serving host is refused the same way.
381
409
  --bundle-max-mb N Remote-lease bundle size cap in MB (default 50, compressed). The bundle
382
410
  excludes .bb-stack.json, node_modules, supabase/.temp|.branches and
383
411
  untracked-secret dotenv files (.env, .env.local, .env.*.local).
@@ -437,6 +465,7 @@ ${bold("REMOTE LEASES")} (BOT-2142, stack run)
437
465
  The receipt carries execution_mode (local|remote), execution_host_key, requester_host,
438
466
  transport (none|ssh-forward), and for a remote lease forwards [{name, remote, local}] + bundle,
439
467
  plus callback_transport "native_origin_v1" when --callback-port used the native route (BOT-2775).
468
+ or "host_local_v1" when a require-host test child got the host-local route (BOT-3399).
440
469
  The child also gets BOTBUDDY_STACK_EXECUTION_MODE and BOTBUDDY_STACK_TRANSPORT.
441
470
  Requeue (BOT-2207/BOT-2334): under auto, including --callback-port, a lease that QUEUES on this machine uploads its bundle at once
442
471
  (a callback lease moves only to a host with native callbacks, BOT-2775);
@@ -611,6 +640,8 @@ export function parseStackArgs(argv) {
611
640
  const opts = {
612
641
  slot: null, host: null, repo: null, ticket: null, ticketUrl: null,
613
642
  prId: null, prUrl: null, purpose: null, runId: null, idleTtl: null, stackPath: ".", stackPathExplicit: false,
643
+ // BOT-3363: the admission class label and declared default memory cost (bytes) of this request.
644
+ admissionClass: null, admissionCostBytes: null,
614
645
  timeout: DEFAULT_TIMEOUT_SEC, provisionTimeout: null, reapTimeout: 300, hardTtl: null,
615
646
  connectionFile: null, noWait: false, claimOnly: false, localExec: false, keepVolumes: false, waitCapacity: null, holdOnTimeout: null,
616
647
  dockerContext: null, dockerEndpoint: null,
@@ -647,6 +678,22 @@ export function parseStackArgs(argv) {
647
678
  case "--pr": if (need(a, rest[i + 1])) opts.prId = rest[++i]; break;
648
679
  case "--pr-url": if (need(a, rest[i + 1])) opts.prUrl = rest[++i]; break;
649
680
  case "--purpose": if (need(a, rest[i + 1])) opts.purpose = rest[++i]; break;
681
+ case "--admission-class": {
682
+ if (need(a, rest[i + 1])) {
683
+ const label = String(rest[++i]).trim().toLowerCase();
684
+ if (!ADMISSION_CLASS_PATTERN.test(label)) errors.push("--admission-class must be 1-64 characters of a-z, 0-9, \".\", \"_\", \":\" or \"-\", starting with a letter or digit");
685
+ else opts.admissionClass = label;
686
+ }
687
+ break;
688
+ }
689
+ case "--admission-cost": {
690
+ if (need(a, rest[i + 1])) {
691
+ const bytes = parseAdmissionCost(rest[++i]);
692
+ if (bytes == null) errors.push("--admission-cost must be a memory size from 1MiB to 1TiB: bytes, or a number with MiB or GiB (e.g. 3GiB)");
693
+ else opts.admissionCostBytes = bytes;
694
+ }
695
+ break;
696
+ }
650
697
  case "--run-id": if (need(a, rest[i + 1])) opts.runId = rest[++i]; break;
651
698
  case "--stack-path": if (need(a, rest[i + 1])) { opts.stackPath = rest[++i]; opts.stackPathExplicit = true; } break;
652
699
  case "--local-max-locks": {
@@ -951,6 +998,47 @@ export function parseStackArgs(argv) {
951
998
  return { command, leaseId, opts, errors, errorCodes, childArgv };
952
999
  }
953
1000
 
1001
+ // BOT-3363: the admission class label grammar the control plane accepts.
1002
+ export const ADMISSION_CLASS_PATTERN = /^[a-z0-9][a-z0-9._:-]{0,63}$/;
1003
+ const ADMISSION_COST_MIN = 1024 * 1024;
1004
+ const ADMISSION_COST_MAX = 1024 ** 4;
1005
+
1006
+ /** BOT-3363: `3GiB`, `512MiB` or plain bytes → bytes, or null when malformed / out of range. */
1007
+ export function parseAdmissionCost(raw) {
1008
+ const m = /^\s*(\d+(?:\.\d+)?)\s*(gib|mib|b)?\s*$/i.exec(String(raw ?? ""));
1009
+ if (!m) return null;
1010
+ const unit = (m[2] ?? "b").toLowerCase();
1011
+ if (unit === "b" && m[1].includes(".")) return null;
1012
+ const bytes = Math.round(Number(m[1]) * (unit === "gib" ? 1024 ** 3 : unit === "mib" ? 1024 ** 2 : 1));
1013
+ return Number.isSafeInteger(bytes) && bytes >= ADMISSION_COST_MIN && bytes <= ADMISSION_COST_MAX ? bytes : null;
1014
+ }
1015
+
1016
+ /** BOT-3363: the request fields for a declared admission class / cost (none when undeclared). */
1017
+ export function admissionLeaseArgs(opts) {
1018
+ return {
1019
+ ...(opts?.admissionClass ? { admission_class: opts.admissionClass } : {}),
1020
+ ...(opts?.admissionCostBytes ? { admission_cost_bytes: opts.admissionCostBytes } : {}),
1021
+ };
1022
+ }
1023
+
1024
+ const gib = (b) => (Number.isFinite(Number(b)) ? `${(Number(b) / 1024 ** 3).toFixed(2)} GiB` : "?");
1025
+
1026
+ /**
1027
+ * BOT-3363: the human lines for a host admission ledger receipt (host_admission_receipt.v1) on
1028
+ * a queued or refused lease: what it waits on, its cost against the ceiling, and the exact
1029
+ * `bb wait 'admit:id=…'` that wakes when it is admitted. Nothing for an ungated host.
1030
+ */
1031
+ export function describeAdmission(admission) {
1032
+ if (!admission || typeof admission !== "object" || admission.gated !== true) return [];
1033
+ const cls = admission.class?.key ?? "?";
1034
+ const line = `admission: ${admission.mode ?? "?"} ${admission.verdict ?? "?"} — ${admission.code ?? "?"} (class ${cls}, cost ${gib(admission.cost_bytes)} ${admission.cost_source ?? "?"}`
1035
+ + `, free ${gib(admission.free_before_bytes)} of ceiling ${gib(admission.ceiling_bytes)}, baseline ${gib(admission.baseline_bytes)}, reserved ${gib(admission.reserved_bytes)}`
1036
+ + `, observed available ${gib(admission.observed_available_bytes)})`;
1037
+ const lines = [line];
1038
+ if (typeof admission.wait === "string" && admission.wait) lines.push(`admission: wait with ${admission.wait} — it wakes when this lease is admitted, or ends admission_refused`);
1039
+ return lines;
1040
+ }
1041
+
954
1042
  /**
955
1043
  * BOT-2019: the human line for a queued lease's server position. `queue_position` is the
956
1044
  * server's dispatch rank (stack_lease_dispatch_queue — the order leases are considered in,
@@ -2943,6 +3031,7 @@ async function cmdUpOnce(opts, {
2943
3031
  ticket_id: opts.ticket || undefined, ticket_url: opts.ticketUrl || undefined,
2944
3032
  pr_id: opts.prId || undefined, pr_url: opts.prUrl || undefined,
2945
3033
  purpose: opts.purpose || undefined, idle_ttl_secs: opts.idleTtl ?? undefined,
3034
+ ...admissionLeaseArgs(opts),
2946
3035
  stack_path: execution.stackPath,
2947
3036
  worktree_root: execution.worktreeRoot,
2948
3037
  machine_uuid: hardwareUuid,
@@ -3082,9 +3171,10 @@ async function cmdUpOnce(opts, {
3082
3171
  const where = describeQueuePosition(d);
3083
3172
  reportLaneStatus({ phase: "waiting", reason: "queued_for_capacity", detail: where || "host at capacity" });
3084
3173
  process.stderr.write(`stack: lease ${leaseId} queued — ${where}\n`);
3174
+ for (const line of describeAdmission(d.admission)) process.stderr.write(`stack: ${line}\n`);
3085
3175
  for (const line of describeUnitLedger(d.ledger)) process.stderr.write(`stack: ${line}\n`);
3086
3176
  if (opts.noWait) {
3087
- return emitResult(buildReceipt({ command: "up", outcome: "queued", lease_id: leaseId, state, host_key: d.host_key, slot, queued: true, ...queueReceiptFields(d), holders: d.holders, ...(d.ledger ? { unit_ledger: d.ledger } : {}) }), opts, EXIT.QUEUED);
3177
+ return emitResult(buildReceipt({ command: "up", outcome: "queued", lease_id: leaseId, state, host_key: d.host_key, slot, queued: true, ...queueReceiptFields(d), holders: d.holders, ...(d.ledger ? { unit_ledger: d.ledger } : {}), ...(d.admission ? { admission: d.admission } : {}) }), opts, EXIT.QUEUED);
3088
3178
  }
3089
3179
  // Park zero-poll until the lease leaves the queue (granted in BOT-1187 order).
3090
3180
  // BOT-2013: a lease reaped while queued (orphaned_agent, …) is lost, not "left the queue".
@@ -4435,7 +4525,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
4435
4525
  let tunnelLost = null;
4436
4526
  // BOT-2780: the requester origin closed under a live run (SSH loss or forward failure).
4437
4527
  let originLost = null;
4438
- const placement = { mode: null, hostKey: null, requesterHost: null, transport: "none", forwards: null, bundle: null, placementReason: null, considered: null,
4528
+ const placement = { mode: null, hostKey: null, requesterHost: null, transport: "none", forwards: null, bundle: null, placementReason: null, considered: null, admission: null,
4439
4529
  // BOT-3371: the optional services this run asked for, and what the stack reports it runs.
4440
4530
  supabaseServicesRequested: opts.supabaseServices ?? [], supabaseServices: null };
4441
4531
  incidentBox.execution = placement;
@@ -4801,13 +4891,17 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
4801
4891
  // the backend places it on a host that serves native callbacks (Linux Go protocol 5) or
4802
4892
  // co-located, and the transport the lease answers with decides the route (useNativeCallback).
4803
4893
  // A remote answer without the native transport fails closed; it never falls back to -R.
4804
- const requireNativeCallback = opts.callbackPort != null && opts.executionRing === "beta" && executionRequest !== "local";
4805
- const autoCallbackPolicy = opts.callbackPort != null && opts.executionRing !== "beta" && executionRequest !== "local" && Boolean(execution.admissionRequestId);
4894
+ // BOT-3399: a host-local callback is declared on the host run, never on the lease.
4895
+ const hostLocalCallback = hostLocalCallbackRun(opts);
4896
+ const requesterCallbackPort = hostLocalCallback ? null : opts.callbackPort;
4897
+ const requireNativeCallback = requesterCallbackPort != null && opts.executionRing === "beta" && executionRequest !== "local";
4898
+ const autoCallbackPolicy = requesterCallbackPort != null && opts.executionRing !== "beta" && executionRequest !== "local" && Boolean(execution.admissionRequestId);
4806
4899
  let useNativeCallback = requireNativeCallback;
4807
4900
  const leaseArgs = {
4808
4901
  slot, host_key: opts.host || undefined, repo: opts.repo, ticket_id: opts.ticket,
4809
4902
  ticket_url: opts.ticketUrl || undefined, pr_id: opts.prId || undefined, pr_url: opts.prUrl || undefined,
4810
4903
  purpose: opts.purpose || "stack run", idle_ttl_secs: opts.idleTtl ?? undefined,
4904
+ ...admissionLeaseArgs(opts),
4811
4905
  stack_path: execution.stackPath, worktree_root: execution.worktreeRoot,
4812
4906
  machine_uuid: hardwareUuid,
4813
4907
  execution: executionRequest,
@@ -4818,7 +4912,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
4818
4912
  require_stack_digest: true,
4819
4913
  // BOT-2269: what the bundle carries beyond the defaults (paths, sha256, key NAMES).
4820
4914
  ...(bundle?.included?.length ? { bundle_included: bundle.included } : {}),
4821
- ...(opts.callbackPort != null ? { callback_port: opts.callbackPort,
4915
+ ...(requesterCallbackPort != null ? { callback_port: requesterCallbackPort,
4822
4916
  ...(requireNativeCallback ? { callback_transport: NATIVE_CALLBACK_TRANSPORT } : autoCallbackPolicy ? { callback_policy: "auto" } : {}) } : {}),
4823
4917
  };
4824
4918
  // BOT-2780: the identified admission key and a digest of the immutable origin context.
@@ -5197,6 +5291,8 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
5197
5291
  // BOT-2207: why the server placed (or queued) it there, and every host it weighed.
5198
5292
  placement.placementReason = request.data.placement_reason ?? null;
5199
5293
  placement.considered = Array.isArray(request.data.considered) ? request.data.considered : null;
5294
+ // BOT-3363: the host admission ledger receipt (queued or admitted), when the host is gated.
5295
+ placement.admission = request.data.admission ?? null;
5200
5296
  if (executionRequest === "remote" && !remoteLease) {
5201
5297
  const cleanup = await requestCleanup();
5202
5298
  return {
@@ -5292,6 +5388,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
5292
5388
  if (state === "queued") {
5293
5389
  // BOT-2019: say where the lease sits (server dispatch rank, or why it has none) before parking.
5294
5390
  stderrLine(`stack: lease ${leaseId} queued — ${describeQueuePosition(parkView)}`);
5391
+ for (const line of describeAdmission(parkView.admission)) stderrLine(`stack: ${line}`);
5295
5392
  for (const line of describeUnitLedger(parkView.ledger)) stderrLine(`stack: ${line}`);
5296
5393
  for (const line of describeConsidered(parkView.considered)) stderrLine(`stack: ${line}`);
5297
5394
  parkReason = queuedParkReason(parkView) ?? parkReason;
@@ -5470,6 +5567,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
5470
5567
  placement.mode = current.data.execution_mode ?? placement.mode ?? (remoteLease ? "remote" : null);
5471
5568
  placement.placementReason = current.data.placement_reason ?? placement.placementReason;
5472
5569
  if (Array.isArray(current.data.considered)) placement.considered = current.data.considered;
5570
+ if (current.data.admission) placement.admission = current.data.admission;
5473
5571
  // BOT-2207: a queued auto lease may have been MOVED to another owned host while it waited.
5474
5572
  // Follow it exactly like a first-time remote placement: forward to the NEW host's ssh_target.
5475
5573
  const servedRemote = remoteLease || current.data.execution_mode === "remote";
@@ -5496,7 +5594,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
5496
5594
  // BOT-2142: forward every stack port over ONE ssh and hand the child the local ports.
5497
5595
  sshTarget = current.data.connection?.ssh_target ?? current.data.ssh_target ?? sshTarget;
5498
5596
  try {
5499
- tunnel = await openTunnel({ connection: current.data.connection, sshTarget, hostKey: placement.hostKey, callbackPort: useNativeCallback ? null : opts.callbackPort,
5597
+ tunnel = await openTunnel({ connection: current.data.connection, sshTarget, hostKey: placement.hostKey, callbackPort: useNativeCallback ? null : requesterCallbackPort,
5500
5598
  ...(useNativeCallback ? { reserveLocalPorts: [opts.callbackPort] } : {}) });
5501
5599
  } catch (error) {
5502
5600
  const cleanup = await requestCleanup();
@@ -5633,7 +5731,13 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
5633
5731
  // BOT-3396: a head that commits .botbuddy/child-layer.json needs a host that builds it.
5634
5732
  const declaresLayer = (adapters.headDeclaresChildLayer ?? headDeclaresChildLayer)(execution.worktreeRoot);
5635
5733
  if (declaresLayer) stderrLine("stack: this head declares a dependency layer (.botbuddy/child-layer.json): placement requires a host with `child-layer`");
5636
- const prerequisites = childLayerPrerequisites(toolchain.prerequisites, declaresLayer);
5734
+ // BOT-3470: its declared system packages bring the capabilities they provide with them.
5735
+ const systemPackages = declaresLayer ? (adapters.headSystemPackages ?? headSystemPackages)(execution.worktreeRoot) : null;
5736
+ const system = systemPackagesPrerequisites(childLayerPrerequisites(toolchain.prerequisites, declaresLayer), systemPackages);
5737
+ if (systemPackages) stderrLine(`stack: this head declares ${systemPackages.distribution} system packages: placement requires a host with \`${system.prerequisites.at(-1)}\`${system.provided.length ? `; ${system.provided.join(", ")} come from them, proven by the declared probe` : ""}`);
5738
+ const prerequisites = system.prerequisites;
5739
+ // BOT-3399: a host-local callback child goes only to a host whose daemon serves the route.
5740
+ if (hostLocalCallbackRun(opts) && !prerequisites.includes(HOST_LOCAL_CALLBACK_CAPABILITY)) prerequisites.push(HOST_LOCAL_CALLBACK_CAPABILITY);
5637
5741
  testChildWaitAbort = new AbortController();
5638
5742
  try {
5639
5743
  placed = await acquireTestChildSlot({
@@ -5682,6 +5786,16 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
5682
5786
  return { exitCode, outcome: receivedSignal ? "interrupted" : "refused", code: placed.code, leaseId, cleanup, error: placed.error, ...required };
5683
5787
  }
5684
5788
  }
5789
+ if (testChild?.placement?.host_kind === "serving_host" && opts.callbackPort != null && !hostLocalCallbackRun(opts)) {
5790
+ // BOT-3399: a callback child on the serving host needs the host-local route; the requester
5791
+ // route this run holds leads back here, where its child is not. Refused before it starts.
5792
+ testChild.released = await releaseTestChild(null);
5793
+ await closeTunnel();
5794
+ const cleanup = await requestCleanup();
5795
+ return { exitCode: receivedSignal ? SIGNAL_EXIT[receivedSignal] : cleanup.ok ? EXIT.BACKEND : EXIT.CLEANUP_FAILED, outcome: "refused",
5796
+ code: "HOST_CALLBACK_ROUTE_UNAVAILABLE", leaseId, cleanup, testChild,
5797
+ error: "this callback child was placed on the serving host, but the run holds a requester callback route; run it with --child-placement require-host for a host-local route (host_local_v1)" };
5798
+ }
5685
5799
  if (testChild?.placement?.host_kind === "serving_host") {
5686
5800
  // BOT-3030: the child runs on the serving host; this run keeps the lease and the slot.
5687
5801
  let hostEnv;
@@ -5715,6 +5829,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
5715
5829
  log: stderrLine, ...(adapters.hostChildOutput ? { writeOutput: adapters.hostChildOutput } : {}),
5716
5830
  signal: activeWaitAbort.signal, artifactGlobs: opts.childArtifacts ?? [],
5717
5831
  testRunId: adapters.hostChildTestRunId !== undefined ? adapters.hostChildTestRunId : testRunIdFrom(),
5832
+ ...(hostLocalCallbackRun(opts) ? { callbackPort: opts.callbackPort } : {}),
5718
5833
  ...(adapters.hostChildFetch ? { fetchArtifacts: adapters.hostChildFetch } : {}),
5719
5834
  });
5720
5835
  } finally {
@@ -5735,6 +5850,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
5735
5850
  outcome: receivedSignal ? "interrupted" : "refused", code: started.code, leaseId, cleanup, error: started.error, testChild };
5736
5851
  }
5737
5852
  child = started.child;
5853
+ if (hostLocalCallbackRun(opts)) placement.callbackTransport = HOST_LOCAL_CALLBACK_TRANSPORT;
5738
5854
  } else {
5739
5855
  child = startChild(childArgv, childEnv, childCwd);
5740
5856
  }
@@ -6070,6 +6186,8 @@ export function runReceiptFields(result) {
6070
6186
  // BOT-2207: why it ran where it did (e.g. moved_remote_on_requeue) and every host weighed.
6071
6187
  ...(result.execution?.placementReason ? { placement_reason: result.execution.placementReason } : {}),
6072
6188
  ...(result.execution?.considered ? { considered: result.execution.considered } : {}),
6189
+ // BOT-3363: the host admission ledger receipt this lease started with (gated hosts only).
6190
+ ...(result.execution?.admission ? { admission: result.execution.admission } : {}),
6073
6191
  fenced: result.fenced === true || result.cleanup?.ok === false, error: result.error ?? result.cleanup?.error ?? null,
6074
6192
  // BOT-2099: a platform auth/availability blip during the park is reported as an
6075
6193
  // incident (reason, window, attempts, recovered) — never as the lease's outcome.
package/src/wait-core.mjs CHANGED
@@ -44,6 +44,9 @@ export const EXIT = Object.freeze({
44
44
  // fire: the receipt carries the incident and the caller's role; re-arm from
45
45
  // next_cursor (the wait's cursor_start) after acting on the incident.
46
46
  PREEMPTED: 14,
47
+ // BOT-3363: an `admit:id=` wait whose lease the host admission ledger refused for good (its
48
+ // memory cost is above the host's admission ceiling). The receipt names the typed reason.
49
+ ADMISSION_REFUSED: 15,
47
50
  });
48
51
 
49
52
  // BOT-2013: the uuid spellings Postgres accepts for a lease id (uuid_in), mirrored by the SQL
@@ -323,6 +326,17 @@ const VALIDATORS = {
323
326
  if (!p.request) throw new Error("guidance needs request=<request_id>");
324
327
  return { request: String(p.request) };
325
328
  },
329
+ // BOT-3363 — admit: one stack lease admitted by its host's memory admission ledger. The
330
+ // relay sees the lease's own stack_lease frames (serverConditions); it wakes on the start
331
+ // (provisioning/active), or ends admission_refused / lease_lost when the lease ends unadmitted.
332
+ admit: (p) => {
333
+ const unexpected = Object.keys(p).filter((key) => key !== "id");
334
+ if (unexpected.length) throw new Error(`admit does not accept ${unexpected.join(", ")}`);
335
+ const m = LEASE_UUID_SPELLING.exec(String(p.id ?? "").trim().toLowerCase());
336
+ if (!m) throw new Error("admit needs id=<the lease id bb stack printed>");
337
+ const hex = m[1].replace(/-/g, "");
338
+ return { id: `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}` };
339
+ },
326
340
  // BOT-1220 — lease: park on a batch stack lease (BOT-1218) leaving the queue /
327
341
  // becoming active, so `botbuddy stack up` on a saturated host wakes zero-poll the
328
342
  // instant it's granted in BOT-1187 order. The signal is recipient-scoped to the
@@ -806,7 +820,30 @@ function prReviewFiltersMatch(signal, params, guard) {
806
820
  * server's command-run terminal condition for its run; its `waiting_over` stays local.
807
821
  */
808
822
  export function serverConditions(conditions) {
809
- return conditions.map((c) => (c.type === "push" ? { id: c.id, type: "command-run", params: { runId: c.params.runId } } : c));
823
+ return conditions.map((c) => {
824
+ if (c.type === "push") return { id: c.id, type: "command-run", params: { runId: c.params.runId } };
825
+ // BOT-3363: an admit wait is the relay's recipient-scoped lease wait for that lease.
826
+ if (c.type === "admit") return { id: c.id, type: "lease", params: { id: c.params.id } };
827
+ return c;
828
+ });
829
+ }
830
+
831
+ // BOT-3363: the lease states that mean an admit: wait's lease was admitted (it started).
832
+ const ADMITTED_LEASE_STATES = Object.freeze(new Set(["provisioning", "active"]));
833
+
834
+ /** BOT-3363: the terminal detail of an admit: frame — admitted, refused (typed) or lost. */
835
+ export function admitDetail(signal, condition) {
836
+ if (condition?.type !== "admit" || signal?.signal_type !== "stack_lease") return null;
837
+ const p = signal.payload ?? {};
838
+ const leaseState = p.state ?? null;
839
+ const reapReason = typeof p.reap_reason === "string" ? p.reap_reason : null;
840
+ const base = { lease_id: p.lease_id ?? condition.params?.id ?? null, lease_state: leaseState };
841
+ if (ADMITTED_LEASE_STATES.has(leaseState)) return { kind: "admitted", state: { ...base, admitted: true } };
842
+ if (LEASE_LOST_STATES.has(leaseState)) {
843
+ if (reapReason && reapReason.startsWith("admission_")) return { kind: "refused", state: { ...base, admitted: false, reap_reason: reapReason } };
844
+ return { kind: "lost", state: { ...base, admitted: false, reap_reason: reapReason } };
845
+ }
846
+ return null;
810
847
  }
811
848
 
812
849
  export function parseConditions(specs) {
@@ -1506,6 +1543,10 @@ function conditionMatchesSignal(condition, signal, waitSessionId) {
1506
1543
  signal.payload?.run_id === params.id && Number.isInteger(signal.payload?.exit_code);
1507
1544
  case "guidance":
1508
1545
  return signal.signal_type === "guidance_response" && signal.subject_key === params.request;
1546
+ case "admit":
1547
+ // BOT-3363: only a start or an end decides an admit wait; a queued frame keeps waiting.
1548
+ return signal.signal_type === "stack_lease" && signal.subject_key === `lease:${params.id}` &&
1549
+ (ADMITTED_LEASE_STATES.has(signal.payload?.state) || LEASE_LOST_STATES.has(signal.payload?.state));
1509
1550
  case "lease":
1510
1551
  // BOT-1220: recipient-scoped stack-lease transition (queued→provisioning, or
1511
1552
  // →active). The relay only delivers it to the lease's owning agent, so any
@@ -2025,6 +2066,16 @@ export async function runWaitLoop({
2025
2066
  reap_reason: typeof p.reap_reason === "string" ? p.reap_reason : null, cleanup_unverified: true },
2026
2067
  });
2027
2068
  }
2069
+ const admit = admitDetail(signal, condition);
2070
+ if (admit?.kind === "refused") {
2071
+ return finalize("admission_refused", { exitCode: EXIT.ADMISSION_REFUSED, matched: [entry], state: admit.state, error: admit.state.reap_reason });
2072
+ }
2073
+ if (admit?.kind === "lost") {
2074
+ return finalize("lease_lost", { exitCode: EXIT.LEASE_LOST, matched: [entry], state: admit.state, error: "lease_lost" });
2075
+ }
2076
+ if (admit?.kind === "admitted") {
2077
+ return finalize("matched", { exitCode: EXIT.MATCHED, matched: [entry], state: admit.state });
2078
+ }
2028
2079
  const lost = leaseLostDetail(signal, condition);
2029
2080
  if (lost) {
2030
2081
  return finalize("lease_lost", { exitCode: EXIT.LEASE_LOST, matched: [entry], state: lost, error: "lease_lost" });
@@ -12,7 +12,7 @@ const MAX_RECEIPT_BYTES = 64 * 1024;
12
12
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
13
13
  const COMMAND_STATUSES = new Set(["success", "failure", "cancelled", "timed_out", "owner_lost"]);
14
14
  // BOT-2783: review_timeout is terminal (exit 13, typed REVIEW_TIMEOUT provenance).
15
- const TERMINAL_OUTCOMES = new Set(["matched", "timeout", "error", "superseded", "lease_lost", "abandoned", "cancelled", "review_timeout", "preempted"]);
15
+ const TERMINAL_OUTCOMES = new Set(["matched", "timeout", "error", "superseded", "lease_lost", "abandoned", "cancelled", "review_timeout", "preempted", "admission_refused"]);
16
16
 
17
17
  // Persisted != delivered. Await the stream callback before exiting, including
18
18
  // when a bounded receipt is larger than the pipe's immediately writable space.
package/src/wait.mjs CHANGED
@@ -194,6 +194,12 @@ CONDITIONS (TYPE:key=val,key=val — repeat for several; --any wakes on the fir
194
194
  child_exit_code, category, outcome and code. Live-only and
195
195
  recipient-scoped to the run's agent. Never substitute a
196
196
  lease: transition, a log tail or a polling loop.
197
+ admit:id=<lease_id> BOT-3363: that stack lease admitted by its host's memory
198
+ admission ledger (bb stack prints this wait when the ledger
199
+ holds a lease). Matches when the lease starts
200
+ (state.admitted true); a lease the ledger can never admit
201
+ ends admission_refused (exit 15, state.reap_reason); any
202
+ other loss ends lease_lost (exit 9). Level-triggered.
197
203
  lease:id=<lease_id>[,state=<s>] a batch stack lease (BOT-1218). Without state=: the lease
198
204
  leaving the queue / becoming active — the zero-poll wake
199
205
  for a parked bb stack up (recipient-scoped to the owner).
@@ -336,7 +342,10 @@ OUTPUT
336
342
  command) · 13 review timeout
337
343
  (REVIEW_TIMEOUT: a Codex review still incomplete at its
338
344
  deadline; receipt error carries minutes/source/reason —
339
- use the fallback reviewer, never infer approval).
345
+ use the fallback reviewer, never infer approval)
346
+ · 15 admission refused (an admit:id= lease the host's
347
+ admission ledger can never admit; receipt state.reap_reason
348
+ names why — lower the declared cost or use another host).
340
349
  If the receipt has
341
350
  reacquire_lock (claim=true), acquire_lock again FIRST and re-run
342
351
  only on a queued/busy result (granted = you hold it — just resume);
@@ -871,6 +880,8 @@ async function registerWait(opts, conditions, deadlineIso) {
871
880
  // `error` and its stored receipt carries the precise outcome.
872
881
  export function cloudStatusForOutcome(outcome) {
873
882
  if (outcome === "lease_lost") return "error";
883
+ // BOT-3363: nor admission_refused — the stored receipt carries the typed reason.
884
+ if (outcome === "admission_refused") return "error";
874
885
  // BOT-2783: no review_timeout status either — the session ends `timeout` and the
875
886
  // stored receipt (and the guard) carry the typed REVIEW_TIMEOUT provenance.
876
887
  if (outcome === "review_timeout") return "timeout";
@@ -885,6 +896,14 @@ export function leaseLostNotice(receipt) {
885
896
  `(reap_reason=${st.reap_reason ?? "unknown"}) — request a new lease (exit ${EXIT.LEASE_LOST})`;
886
897
  }
887
898
 
899
+ /** BOT-3363: the one stderr line for an admission_refused receipt (null for any other outcome). */
900
+ export function admissionRefusedNotice(receipt) {
901
+ if (receipt?.outcome !== "admission_refused") return null;
902
+ const st = receipt.state ?? {};
903
+ return `bb-wait: lease ${st.lease_id ?? "?"} can never be admitted on its host ` +
904
+ `(reap_reason=${st.reap_reason ?? "unknown"}) — lower its declared cost or request another host (exit ${EXIT.ADMISSION_REFUSED})`;
905
+ }
906
+
888
907
  /**
889
908
  * BOT-2360: the one stderr line for an `abandoned` receipt (null for any other outcome). The
890
909
  * server ended this wait (its liveness reaper or a cancel) while the client was
@@ -993,7 +1012,7 @@ export function stagingSuspectNotice(receipt) {
993
1012
  }
994
1013
 
995
1014
  function writeLeaseLostNotice(receipt, conditionArgs = [], options = {}) {
996
- const notice = leaseLostNotice(receipt) ?? waitAbandonedNotice(receipt) ?? reviewTimeoutNotice(receipt) ??
1015
+ const notice = leaseLostNotice(receipt) ?? admissionRefusedNotice(receipt) ?? waitAbandonedNotice(receipt) ?? reviewTimeoutNotice(receipt) ??
997
1016
  waitPreemptedNotice(receipt, conditionArgs, options) ?? stagingSuspectNotice(receipt);
998
1017
  if (notice) process.stderr.write(`${notice}\n`);
999
1018
  }
@@ -1797,6 +1816,7 @@ export function recoveredExitCode(receipt) {
1797
1816
  if (receipt?.outcome === "matched") return EXIT.MATCHED;
1798
1817
  if (receipt?.outcome === "review_timeout") return EXIT.REVIEW_TIMEOUT;
1799
1818
  if (receipt?.outcome === "lease_lost") return EXIT.LEASE_LOST;
1819
+ if (receipt?.outcome === "admission_refused") return EXIT.ADMISSION_REFUSED;
1800
1820
  if (receipt?.outcome === "cancelled") return EXIT.MATCHED;
1801
1821
  if (receipt?.outcome === "timeout") return EXIT.TIMEOUT;
1802
1822
  if (receipt?.outcome === "superseded") return EXIT.SUPERSEDED;