@botbuddy/cli 1.107.0 → 1.110.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 +8 -0
- package/daemon/bin/darwin-arm64/botbuddy-daemon +0 -0
- package/daemon/bin/linux-x64/botbuddy-daemon +0 -0
- package/daemon-release/darwin-arm64.json +4 -4
- package/daemon-release/linux-x64.json +4 -4
- package/daemon-release/manifest.json +5 -5
- package/package.json +1 -1
- package/src/host-child.mjs +4 -2
- package/src/host-toolchain.mjs +44 -0
- package/src/stack.mjs +48 -7
- package/src/test-child.mjs +16 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.110.0
|
|
4
|
+
|
|
5
|
+
- BOT-3363 (PR 3 of 3): a host test child goes through the host's memory admission ledger, the same one stack leases ask. When the ledger holds a child, `bb stack run --test-child` prints `<host>'s memory admission ledger does not admit the child yet (<code>: it needs X GiB, Y GiB free under the ceiling, cost learned|default) — waiting (no slot is held while waiting)` and waits on the pool's platform wait (a slot release, or the server's re-check deadline at most 60 s away); a child whose cost is above the host's ceiling stops at once with `ADMISSION_COST_EXCEEDS_CEILING` and its receipt. The fleet host daemon takes no new test child while the host is below its local disk or memory floor (the claim is a peek, so the run keeps its place; the log line is BOT-2849's `memory admission: deferred test-child …`), and sets the child unit's `MemoryMax` to its reservation when the claim carries one (an enforced, learned reservation). Needs MCP 2.151.0.
|
|
6
|
+
|
|
7
|
+
## 1.108.0
|
|
8
|
+
|
|
9
|
+
- 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.
|
|
10
|
+
|
|
3
11
|
## 1.106.2
|
|
4
12
|
|
|
5
13
|
- 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.
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.110.0",
|
|
3
|
+
"source_commit": "62787041db72a2944b3abd150da2629cd6f2d4f7",
|
|
4
|
+
"source_sha256": "362a9e2dac87e39790748eccfd742254cf89a8177bd06184d6a3ef643d6e9d19",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "445643f5f93d639933ea9fd4beb4a2da1cda84c8a3f38905cf49c186aedf6d28"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.110.0",
|
|
3
|
+
"source_commit": "62787041db72a2944b3abd150da2629cd6f2d4f7",
|
|
4
|
+
"source_sha256": "362a9e2dac87e39790748eccfd742254cf89a8177bd06184d6a3ef643d6e9d19",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "738a3cb5e55c0716cec11eb3d126f8725128f71acce2bc41eb8e86f8b5781e95"
|
|
7
7
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
|
-
"release_version": "1.
|
|
4
|
-
"source_commit": "
|
|
5
|
-
"source_sha256": "
|
|
3
|
+
"release_version": "1.110.0",
|
|
4
|
+
"source_commit": "62787041db72a2944b3abd150da2629cd6f2d4f7",
|
|
5
|
+
"source_sha256": "362a9e2dac87e39790748eccfd742254cf89a8177bd06184d6a3ef643d6e9d19",
|
|
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": "
|
|
11
|
+
"sha256": "445643f5f93d639933ea9fd4beb4a2da1cda84c8a3f38905cf49c186aedf6d28",
|
|
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": "
|
|
18
|
+
"sha256": "738a3cb5e55c0716cec11eb3d126f8725128f71acce2bc41eb8e86f8b5781e95",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
package/src/host-child.mjs
CHANGED
|
@@ -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) {
|
package/src/host-toolchain.mjs
CHANGED
|
@@ -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;
|
|
@@ -328,7 +340,8 @@ ${bold("run OPTIONS")}
|
|
|
328
340
|
serving_host, and the slot and the lease are released. A full serving-host
|
|
329
341
|
pool still waits for a slot.
|
|
330
342
|
--child-requires LIST BOT-3030: what the child needs on a host (comma list: node>=24,pnpm,deno,
|
|
331
|
-
curl,git,jq,psql,tar,playwright-chromium-libs
|
|
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
|
|
332
345
|
only when they run inside a child's sandbox on that host (BOT-3402).
|
|
333
346
|
BOT-3395: curl, git, jq, psql and tar count only when they run inside a
|
|
334
347
|
child's sandbox too, and the host reports each one's version. A host
|
|
@@ -387,6 +400,12 @@ ${bold("run OPTIONS")}
|
|
|
387
400
|
throwaway reverse forward and opens -R 127.0.0.1:N:127.0.0.1:N only when
|
|
388
401
|
the host keeps it on loopback (sshd GatewayPorts no/clientspecified);
|
|
389
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.
|
|
390
409
|
--bundle-max-mb N Remote-lease bundle size cap in MB (default 50, compressed). The bundle
|
|
391
410
|
excludes .bb-stack.json, node_modules, supabase/.temp|.branches and
|
|
392
411
|
untracked-secret dotenv files (.env, .env.local, .env.*.local).
|
|
@@ -446,6 +465,7 @@ ${bold("REMOTE LEASES")} (BOT-2142, stack run)
|
|
|
446
465
|
The receipt carries execution_mode (local|remote), execution_host_key, requester_host,
|
|
447
466
|
transport (none|ssh-forward), and for a remote lease forwards [{name, remote, local}] + bundle,
|
|
448
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).
|
|
449
469
|
The child also gets BOTBUDDY_STACK_EXECUTION_MODE and BOTBUDDY_STACK_TRANSPORT.
|
|
450
470
|
Requeue (BOT-2207/BOT-2334): under auto, including --callback-port, a lease that QUEUES on this machine uploads its bundle at once
|
|
451
471
|
(a callback lease moves only to a host with native callbacks, BOT-2775);
|
|
@@ -4871,8 +4891,11 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
4871
4891
|
// the backend places it on a host that serves native callbacks (Linux Go protocol 5) or
|
|
4872
4892
|
// co-located, and the transport the lease answers with decides the route (useNativeCallback).
|
|
4873
4893
|
// A remote answer without the native transport fails closed; it never falls back to -R.
|
|
4874
|
-
|
|
4875
|
-
const
|
|
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);
|
|
4876
4899
|
let useNativeCallback = requireNativeCallback;
|
|
4877
4900
|
const leaseArgs = {
|
|
4878
4901
|
slot, host_key: opts.host || undefined, repo: opts.repo, ticket_id: opts.ticket,
|
|
@@ -4889,7 +4912,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
4889
4912
|
require_stack_digest: true,
|
|
4890
4913
|
// BOT-2269: what the bundle carries beyond the defaults (paths, sha256, key NAMES).
|
|
4891
4914
|
...(bundle?.included?.length ? { bundle_included: bundle.included } : {}),
|
|
4892
|
-
...(
|
|
4915
|
+
...(requesterCallbackPort != null ? { callback_port: requesterCallbackPort,
|
|
4893
4916
|
...(requireNativeCallback ? { callback_transport: NATIVE_CALLBACK_TRANSPORT } : autoCallbackPolicy ? { callback_policy: "auto" } : {}) } : {}),
|
|
4894
4917
|
};
|
|
4895
4918
|
// BOT-2780: the identified admission key and a digest of the immutable origin context.
|
|
@@ -5571,7 +5594,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5571
5594
|
// BOT-2142: forward every stack port over ONE ssh and hand the child the local ports.
|
|
5572
5595
|
sshTarget = current.data.connection?.ssh_target ?? current.data.ssh_target ?? sshTarget;
|
|
5573
5596
|
try {
|
|
5574
|
-
tunnel = await openTunnel({ connection: current.data.connection, sshTarget, hostKey: placement.hostKey, callbackPort: useNativeCallback ? null :
|
|
5597
|
+
tunnel = await openTunnel({ connection: current.data.connection, sshTarget, hostKey: placement.hostKey, callbackPort: useNativeCallback ? null : requesterCallbackPort,
|
|
5575
5598
|
...(useNativeCallback ? { reserveLocalPorts: [opts.callbackPort] } : {}) });
|
|
5576
5599
|
} catch (error) {
|
|
5577
5600
|
const cleanup = await requestCleanup();
|
|
@@ -5708,7 +5731,13 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5708
5731
|
// BOT-3396: a head that commits .botbuddy/child-layer.json needs a host that builds it.
|
|
5709
5732
|
const declaresLayer = (adapters.headDeclaresChildLayer ?? headDeclaresChildLayer)(execution.worktreeRoot);
|
|
5710
5733
|
if (declaresLayer) stderrLine("stack: this head declares a dependency layer (.botbuddy/child-layer.json): placement requires a host with `child-layer`");
|
|
5711
|
-
|
|
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);
|
|
5712
5741
|
testChildWaitAbort = new AbortController();
|
|
5713
5742
|
try {
|
|
5714
5743
|
placed = await acquireTestChildSlot({
|
|
@@ -5757,6 +5786,16 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5757
5786
|
return { exitCode, outcome: receivedSignal ? "interrupted" : "refused", code: placed.code, leaseId, cleanup, error: placed.error, ...required };
|
|
5758
5787
|
}
|
|
5759
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
|
+
}
|
|
5760
5799
|
if (testChild?.placement?.host_kind === "serving_host") {
|
|
5761
5800
|
// BOT-3030: the child runs on the serving host; this run keeps the lease and the slot.
|
|
5762
5801
|
let hostEnv;
|
|
@@ -5790,6 +5829,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5790
5829
|
log: stderrLine, ...(adapters.hostChildOutput ? { writeOutput: adapters.hostChildOutput } : {}),
|
|
5791
5830
|
signal: activeWaitAbort.signal, artifactGlobs: opts.childArtifacts ?? [],
|
|
5792
5831
|
testRunId: adapters.hostChildTestRunId !== undefined ? adapters.hostChildTestRunId : testRunIdFrom(),
|
|
5832
|
+
...(hostLocalCallbackRun(opts) ? { callbackPort: opts.callbackPort } : {}),
|
|
5793
5833
|
...(adapters.hostChildFetch ? { fetchArtifacts: adapters.hostChildFetch } : {}),
|
|
5794
5834
|
});
|
|
5795
5835
|
} finally {
|
|
@@ -5810,6 +5850,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5810
5850
|
outcome: receivedSignal ? "interrupted" : "refused", code: started.code, leaseId, cleanup, error: started.error, testChild };
|
|
5811
5851
|
}
|
|
5812
5852
|
child = started.child;
|
|
5853
|
+
if (hostLocalCallbackRun(opts)) placement.callbackTransport = HOST_LOCAL_CALLBACK_TRANSPORT;
|
|
5813
5854
|
} else {
|
|
5814
5855
|
child = startChild(childArgv, childEnv, childCwd);
|
|
5815
5856
|
}
|
package/src/test-child.mjs
CHANGED
|
@@ -93,6 +93,16 @@ export function defaultTestChildWait(target, { bin = process.execPath, cli = pro
|
|
|
93
93
|
* Returns `{ ok: true, slotId, ttlSeconds, placement, waits }` or
|
|
94
94
|
* `{ ok: false, code, error, placement?, waits }`. Never throws.
|
|
95
95
|
*/
|
|
96
|
+
const gib = (bytes) => (Number.isFinite(Number(bytes)) ? `${(Number(bytes) / 1024 ** 3).toFixed(2)} GiB` : "unknown");
|
|
97
|
+
|
|
98
|
+
/** BOT-3363: the one line a run prints when the host's memory admission ledger holds its child. */
|
|
99
|
+
export function admissionWaitLine(data) {
|
|
100
|
+
const a = data?.admission ?? {};
|
|
101
|
+
return `stack: ${TEST_CHILD_CAPACITY}: ${data?.run_host ?? "the run host"}'s memory admission ledger does not admit the child yet `
|
|
102
|
+
+ `(${data?.admission_code ?? a.code ?? "unknown"}: it needs ${gib(a.cost_bytes)}, ${gib(a.free_before_bytes)} free under the ceiling`
|
|
103
|
+
+ `${a.cost_source ? `, cost ${a.cost_source}` : ""}) — waiting (no slot is held while waiting)`;
|
|
104
|
+
}
|
|
105
|
+
|
|
96
106
|
/** BOT-3398: why a require-host child was refused, in the words of the placement. */
|
|
97
107
|
export function requiredHostError(placement) {
|
|
98
108
|
const missing = Array.isArray(placement?.missing_prerequisites) && placement.missing_prerequisites.length
|
|
@@ -138,9 +148,11 @@ export async function acquireTestChildSlot({ api, leaseId, wait = defaultTestChi
|
|
|
138
148
|
const expiryMs = Date.parse(data.next_expiry_at ?? "");
|
|
139
149
|
const deadline = Number.isFinite(expiryMs) ? new Date(expiryMs).toISOString() : new Date(Date.now() + FALLBACK_PARK_MS).toISOString();
|
|
140
150
|
if (waits.length === 0) {
|
|
141
|
-
log(
|
|
151
|
+
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}` : ""}`);
|
|
142
153
|
}
|
|
143
|
-
waits.push({ at: new Date().toISOString(), held: data.held ?? null, slots: data.slots ?? null, run_host: data.run_host ?? null
|
|
154
|
+
waits.push({ at: new Date().toISOString(), held: data.held ?? null, slots: data.slots ?? null, run_host: data.run_host ?? null,
|
|
155
|
+
...(data.limit === "admission" ? { admission_code: data.admission_code ?? data.admission?.code ?? null } : {}) });
|
|
144
156
|
if (waits.length > maxWaits || isStopped()) {
|
|
145
157
|
return { ok: false, code: TEST_CHILD_CAPACITY, waits, error: `all test_child slots on ${data.run_host} stayed held` };
|
|
146
158
|
}
|
|
@@ -160,7 +172,8 @@ export async function acquireTestChildSlot({ api, leaseId, wait = defaultTestChi
|
|
|
160
172
|
continue;
|
|
161
173
|
}
|
|
162
174
|
const code = data?.code ?? TEST_CHILD_UNAVAILABLE;
|
|
163
|
-
|
|
175
|
+
// BOT-3363: a typed ledger refusal (ADMISSION_COST_EXCEEDS_CEILING) carries its receipt.
|
|
176
|
+
return { ok: false, code, waits, placement: data?.child_placement ?? null, ...(data?.admission ? { admission: data.admission } : {}),
|
|
164
177
|
error: `the control plane did not place the test child, so it was not started (${data?.message ?? data?.error ?? answer?.error ?? "no answer"})` };
|
|
165
178
|
}
|
|
166
179
|
}
|