@botbuddy/cli 1.117.0 → 1.118.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 +4 -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/stack.mjs +80 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.118.0
|
|
4
|
+
|
|
5
|
+
- BOT-3519: `bb stack run --test-child --child-placement require-host` places the stack lease only on a host that can run the child. The CLI derives the child's whole prerequisite set before the lease (toolchain or the declared tools, `child-layer`, `system-packages-<distro>` for the head's declared system packages, `host-local-callback` for a `--callback-port` run, and `--child-requires`) and sends it as `child_host_prerequisites`. The control plane then weighs only owned hosts in `child_exec_hosts` whose capabilities, reported in the last 15 minutes, provide all of it; a busy one queues the lease as usual. When none qualifies the run ends before any lease or bundle upload with exit 5 and `CHILD_HOST_PREREQUISITES_MISSING` (also for a `--host` pin that lacks one): the receipt's `child_placement.considered[]` names each host with `child_reason` and `missing_prerequisites`, and the run prints one line per host. When the only host that could run it is draining or in maintenance, the code is `CHILD_HOST_UNAVAILABLE` and `child_placement.child_host` names it. `prefer-host` is unchanged. Needs MCP 2.158.0.
|
|
6
|
+
|
|
3
7
|
## 1.117.0
|
|
4
8
|
|
|
5
9
|
- BOT-3463: a run started by `bb stack run`, `bb run` (foreground and detached, so `bb test` and `bb push` too) owns every process its command launches. The child's environment carries a run-scoped marker (`BOTBUDDY_RUN_ID`, `BOTBUDDY_RUN_REGISTRY`) that every descendant inherits, `setsid` daemons included, and the run writes an owner record under `~/.botbuddy/owned-runs/` (0600). When the run ends (exit, signal, timeout, lease loss) its owner stops what is still marked, plus the child's process group and its descendants: SIGTERM, then SIGKILL after 5 s. A detached worker whose command exited lets its output drain for 2 s, then stops what kept the pipes open. When the owner itself dies (SIGKILL), the per-machine reaper (`bb __reap-orphans`, started by bb, one lock per machine) stops that run's tree within one 10 s interval. A `bb` invocation also starts a sweep when none ran for 10 minutes; it stops leftovers of earlier releases by their run-scoped `BOTBUDDY_STACK_LEASE_ID` / `BOTBUDDY_TEST_RUN_ID` marker once the run's top process has only init above it. Processes are never matched by name: one without a marker, such as a dev server started by hand, is never touched. Each stopped process group is one `sensor_events` row (`bb-cli` / `run_process_reaped`: run id, PID, PGID, age), kept in a local outbox until `sensor-ingest` takes it. `BOTBUDDY_RUN_REAPER=off` disables the reaper. Host test children are unchanged: their systemd unit (`KillMode=control-group`) already ends with the run.
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.118.0",
|
|
3
|
+
"source_commit": "f61949cb5c11c1ab0fd33274a3d69fed41633e4f",
|
|
4
|
+
"source_sha256": "126904b6d3e90b5ce30af5fc7c33feb99efe8023a5b1374f4c8db22a5afbf66e",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "a58c0dcbf5101515a362023b6e744d49bde8767ced42e68e7579053e3e077073"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.118.0",
|
|
3
|
+
"source_commit": "f61949cb5c11c1ab0fd33274a3d69fed41633e4f",
|
|
4
|
+
"source_sha256": "126904b6d3e90b5ce30af5fc7c33feb99efe8023a5b1374f4c8db22a5afbf66e",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "b6fe4938aaebf1ac5f303b2ab7fa466314ab580426159c85de3be5c26e35ff8a"
|
|
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.118.0",
|
|
4
|
+
"source_commit": "f61949cb5c11c1ab0fd33274a3d69fed41633e4f",
|
|
5
|
+
"source_sha256": "126904b6d3e90b5ce30af5fc7c33feb99efe8023a5b1374f4c8db22a5afbf66e",
|
|
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": "a58c0dcbf5101515a362023b6e744d49bde8767ced42e68e7579053e3e077073",
|
|
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": "b6fe4938aaebf1ac5f303b2ab7fa466314ab580426159c85de3be5c26e35ff8a",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
package/src/stack.mjs
CHANGED
|
@@ -339,7 +339,14 @@ ${bold("run OPTIONS")}
|
|
|
339
339
|
requester pool) is refused before the child starts with CHILD_PLACEMENT_REQUIRED
|
|
340
340
|
(exit 5); the receipt adds child_placement_reason, missing_prerequisites and
|
|
341
341
|
serving_host, and the slot and the lease are released. A full serving-host
|
|
342
|
-
pool still waits for a slot.
|
|
342
|
+
pool still waits for a slot. BOT-3519: require-host also places the LEASE
|
|
343
|
+
only on an owned host whose child capabilities meet the whole prerequisite
|
|
344
|
+
set (toolchain, child-layer, system-packages-<distro>, host-local-callback
|
|
345
|
+
and --child-requires); a busy one is waited for. Refused before any lease
|
|
346
|
+
or upload (exit 5): CHILD_HOST_PREREQUISITES_MISSING (child_placement.
|
|
347
|
+
considered[] names each host and what it lacks; also a --host pin that
|
|
348
|
+
lacks one) or CHILD_HOST_UNAVAILABLE (the only host that could is
|
|
349
|
+
draining or in maintenance; child_placement.child_host names it).
|
|
343
350
|
--child-requires LIST BOT-3030: what the child needs on a host (comma list: node>=24,pnpm,deno,
|
|
344
351
|
curl,git,jq,psql,tar,tar-extract,playwright-chromium-libs, or a name the
|
|
345
352
|
head's system_packages provide, e.g. playwright-webkit-libs). node, pnpm
|
|
@@ -1717,6 +1724,39 @@ export function stackPathRootRefusalNotice(code, message) {
|
|
|
1717
1724
|
return `${yellow("⚠")} stack: ${message || STACK_PATH_ROOT_REFUSED_FALLBACK}`;
|
|
1718
1725
|
}
|
|
1719
1726
|
|
|
1727
|
+
/**
|
|
1728
|
+
* BOT-3240/3407/3396/3470/3399: a --test-child run's whole host prerequisite set — the head's
|
|
1729
|
+
* toolchain (or its declared tools), its dependency layer, its declared system packages and a
|
|
1730
|
+
* host-local callback — plus --child-requires. BOT-3519: computed once before the lease, so a
|
|
1731
|
+
* require-host run's lease is placed only on a host that provides all of it.
|
|
1732
|
+
*/
|
|
1733
|
+
export function childPrerequisiteSet(opts, worktreeRoot, adapters = {}, log = () => {}) {
|
|
1734
|
+
const head = (adapters.headToolchain ?? headToolchain)(worktreeRoot);
|
|
1735
|
+
const toolchain = toolchainPrerequisites(opts.childRequires ?? [], head);
|
|
1736
|
+
if (head.manifest) log(`stack: this head declares its toolchain (mise.toml, mise.lock): placement requires a host with \`toolchain\`${toolchain.provided.length ? `; ${toolchain.provided.join(", ")} come from the manifest` : ""}`);
|
|
1737
|
+
else if (head.lockMissing) log("stack: this head commits mise.toml without mise.lock, so a host builds no toolchain for it; run `mise lock` and commit mise.lock to give host children the repo's own tools");
|
|
1738
|
+
const declaresLayer = (adapters.headDeclaresChildLayer ?? headDeclaresChildLayer)(worktreeRoot);
|
|
1739
|
+
if (declaresLayer) log("stack: this head declares a dependency layer (.botbuddy/child-layer.json): placement requires a host with `child-layer`");
|
|
1740
|
+
const systemPackages = declaresLayer ? (adapters.headSystemPackages ?? headSystemPackages)(worktreeRoot) : null;
|
|
1741
|
+
const system = systemPackagesPrerequisites(childLayerPrerequisites(toolchain.prerequisites, declaresLayer), systemPackages);
|
|
1742
|
+
if (systemPackages) log(`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` : ""}`);
|
|
1743
|
+
const prerequisites = [...system.prerequisites];
|
|
1744
|
+
if (hostLocalCallbackRun(opts) && !prerequisites.includes(HOST_LOCAL_CALLBACK_CAPABILITY)) prerequisites.push(HOST_LOCAL_CALLBACK_CAPABILITY);
|
|
1745
|
+
return prerequisites;
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
/** BOT-3519: the lease refusals that mean no owned host can run this require-host test child. */
|
|
1749
|
+
export const CHILD_HOST_REFUSAL_CODES = Object.freeze(["CHILD_HOST_PREREQUISITES_MISSING", "CHILD_HOST_UNAVAILABLE", CHILD_PLACEMENT_REQUIRED]);
|
|
1750
|
+
|
|
1751
|
+
/** BOT-3519: one line per considered host — what it lacks, or why it cannot take the child. */
|
|
1752
|
+
export function childHostRefusalLines(data) {
|
|
1753
|
+
const name = (c) => (typeof c.display_name === "string" && c.display_name && c.display_name !== c.host_key ? `${c.display_name} (${c.host_key})` : c.host_key);
|
|
1754
|
+
return (Array.isArray(data?.considered) ? data.considered : [])
|
|
1755
|
+
.filter((c) => c && typeof c.host_key === "string" && c.verdict_code === "HOST_CHILD_UNQUALIFIED")
|
|
1756
|
+
.map((c) => ` ${name(c)}: ${c.child_reason === "stack_colocated" ? "this machine's own host (a co-located stack never serves a host child)"
|
|
1757
|
+
: Array.isArray(c.missing_prerequisites) && c.missing_prerequisites.length ? `lacks ${c.missing_prerequisites.join(", ")} (${c.child_reason ?? "unknown"})` : c.child_reason ?? "cannot run the child"}`);
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1720
1760
|
/**
|
|
1721
1761
|
* Exit code for a lease the server REFUSED (`success: false`). A refused root path is a
|
|
1722
1762
|
* bad argument the caller must fix — INVALID (4) — not a backend fault, which automation
|
|
@@ -4568,6 +4608,8 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
4568
4608
|
let testChild = null;
|
|
4569
4609
|
let testChildRenew = null;
|
|
4570
4610
|
let testChildWaitAbort = null;
|
|
4611
|
+
// BOT-3519: the test child's whole prerequisite set, derived before the lease is requested.
|
|
4612
|
+
let childPrerequisites = null;
|
|
4571
4613
|
const releaseTestChild = async (resources) => {
|
|
4572
4614
|
if (!testChild?.slotId) return null;
|
|
4573
4615
|
const slotId = testChild.slotId;
|
|
@@ -4976,6 +5018,10 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
4976
5018
|
// BOT-3399: a host-local callback is declared on the host run, never on the lease.
|
|
4977
5019
|
const hostLocalCallback = hostLocalCallbackRun(opts);
|
|
4978
5020
|
const requesterCallbackPort = hostLocalCallback ? null : opts.callbackPort;
|
|
5021
|
+
// BOT-3519: a require-host child's lease goes only to a host that can run it, so the whole
|
|
5022
|
+
// prerequisite set is known (and sent) before the lease exists.
|
|
5023
|
+
const requireHostChild = Boolean(opts.testChild) && opts.childPlacement === "require-host";
|
|
5024
|
+
childPrerequisites = opts.testChild ? childPrerequisiteSet(opts, execution.worktreeRoot, adapters, stderrLine) : null;
|
|
4979
5025
|
const requireNativeCallback = requesterCallbackPort != null && opts.executionRing === "beta" && executionRequest !== "local";
|
|
4980
5026
|
const autoCallbackPolicy = requesterCallbackPort != null && opts.executionRing !== "beta" && executionRequest !== "local" && Boolean(execution.admissionRequestId);
|
|
4981
5027
|
let useNativeCallback = requireNativeCallback;
|
|
@@ -4994,6 +5040,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
4994
5040
|
require_stack_digest: true,
|
|
4995
5041
|
// BOT-2269: what the bundle carries beyond the defaults (paths, sha256, key NAMES).
|
|
4996
5042
|
...(bundle?.included?.length ? { bundle_included: bundle.included } : {}),
|
|
5043
|
+
...(requireHostChild ? { child_host_prerequisites: childPrerequisites } : {}),
|
|
4997
5044
|
...(requesterCallbackPort != null ? { callback_port: requesterCallbackPort,
|
|
4998
5045
|
...(requireNativeCallback ? { callback_transport: NATIVE_CALLBACK_TRANSPORT } : autoCallbackPolicy ? { callback_policy: "auto" } : {}) } : {}),
|
|
4999
5046
|
};
|
|
@@ -5327,6 +5374,28 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5327
5374
|
// an idle mode mismatch) is not proof that its ports are free. Keep the
|
|
5328
5375
|
// claim until owner-safe cleanup is verified; never reap a possibly live batch.
|
|
5329
5376
|
if (request.data?.lease_id) retainBlock = true;
|
|
5377
|
+
// BOT-3519: no owned host can run this require-host child: refused before any lease or upload.
|
|
5378
|
+
// A held lease on a host that cannot run the child is named too (held_lease); its id is kept so
|
|
5379
|
+
// the operator can release it, and its port block stays retained.
|
|
5380
|
+
if (requireHostChild && CHILD_HOST_REFUSAL_CODES.includes(request.data?.code) && (!request.data?.lease_id || request.data.held_lease === true)) {
|
|
5381
|
+
const d = request.data;
|
|
5382
|
+
if (d.lease_id) retainBlock = true;
|
|
5383
|
+
for (const line of childHostRefusalLines(d)) stderrLine(line);
|
|
5384
|
+
return {
|
|
5385
|
+
exitCode: EXIT.BACKEND, outcome: "refused", code: d.code,
|
|
5386
|
+
error: `--child-placement require-host: ${d.message ?? d.code}`,
|
|
5387
|
+
...(d.lease_id ? { leaseId: d.lease_id, state: d.state ?? null } : {}),
|
|
5388
|
+
childHostRefusal: {
|
|
5389
|
+
prerequisites: Array.isArray(d.prerequisites) ? d.prerequisites : childPrerequisites,
|
|
5390
|
+
considered: Array.isArray(d.considered) ? d.considered : [],
|
|
5391
|
+
...(d.child_host ? { child_host: d.child_host } : {}),
|
|
5392
|
+
...(d.host_key ? { host_key: d.host_key } : {}),
|
|
5393
|
+
...(d.child_reason ? { child_reason: d.child_reason } : {}),
|
|
5394
|
+
...(d.child_placement_reason ? { child_placement_reason: d.child_placement_reason } : {}),
|
|
5395
|
+
...(Array.isArray(d.missing_prerequisites) ? { missing_prerequisites: d.missing_prerequisites } : {}),
|
|
5396
|
+
},
|
|
5397
|
+
};
|
|
5398
|
+
}
|
|
5330
5399
|
// BOT-2977: name the re-registration command; the refusal itself is never retried here.
|
|
5331
5400
|
const fenceScope = staleContextFenceScope(request.data);
|
|
5332
5401
|
const branchTicket = request.data?.code === "STALE_AGENT_CONTEXT" ? await (adapters.branchTicket ?? currentBranchTicket)() : undefined;
|
|
@@ -5825,22 +5894,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5825
5894
|
const waitTouch = clock.setInterval(() => { void touchWhileWaiting(); }, waitCadenceMs);
|
|
5826
5895
|
waitTouch?.unref?.();
|
|
5827
5896
|
let placed;
|
|
5828
|
-
|
|
5829
|
-
// placement asks the host for `toolchain` instead of for those tools.
|
|
5830
|
-
const head = (adapters.headToolchain ?? headToolchain)(execution.worktreeRoot);
|
|
5831
|
-
const toolchain = toolchainPrerequisites(opts.childRequires, head);
|
|
5832
|
-
if (head.manifest) stderrLine(`stack: this head declares its toolchain (mise.toml, mise.lock): placement requires a host with \`toolchain\`${toolchain.provided.length ? `; ${toolchain.provided.join(", ")} come from the manifest` : ""}`);
|
|
5833
|
-
else if (head.lockMissing) stderrLine("stack: this head commits mise.toml without mise.lock, so a host builds no toolchain for it; run `mise lock` and commit mise.lock to give host children the repo's own tools");
|
|
5834
|
-
// BOT-3396: a head that commits .botbuddy/child-layer.json needs a host that builds it.
|
|
5835
|
-
const declaresLayer = (adapters.headDeclaresChildLayer ?? headDeclaresChildLayer)(execution.worktreeRoot);
|
|
5836
|
-
if (declaresLayer) stderrLine("stack: this head declares a dependency layer (.botbuddy/child-layer.json): placement requires a host with `child-layer`");
|
|
5837
|
-
// BOT-3470: its declared system packages bring the capabilities they provide with them.
|
|
5838
|
-
const systemPackages = declaresLayer ? (adapters.headSystemPackages ?? headSystemPackages)(execution.worktreeRoot) : null;
|
|
5839
|
-
const system = systemPackagesPrerequisites(childLayerPrerequisites(toolchain.prerequisites, declaresLayer), systemPackages);
|
|
5840
|
-
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` : ""}`);
|
|
5841
|
-
const prerequisites = system.prerequisites;
|
|
5842
|
-
// BOT-3399: a host-local callback child goes only to a host whose daemon serves the route.
|
|
5843
|
-
if (hostLocalCallbackRun(opts) && !prerequisites.includes(HOST_LOCAL_CALLBACK_CAPABILITY)) prerequisites.push(HOST_LOCAL_CALLBACK_CAPABILITY);
|
|
5897
|
+
const prerequisites = childPrerequisites ?? childPrerequisiteSet(opts, execution.worktreeRoot, adapters, stderrLine);
|
|
5844
5898
|
testChildWaitAbort = new AbortController();
|
|
5845
5899
|
try {
|
|
5846
5900
|
placed = await acquireTestChildSlot({
|
|
@@ -6254,6 +6308,15 @@ export function runReceiptFields(result) {
|
|
|
6254
6308
|
...(result.requiredPlacement.missing_prerequisites?.length ? { missing_prerequisites: result.requiredPlacement.missing_prerequisites } : {}),
|
|
6255
6309
|
...(result.requiredPlacement.serving_host ? { serving_host: result.requiredPlacement.serving_host } : {}),
|
|
6256
6310
|
} : {}),
|
|
6311
|
+
// BOT-3519: a require-host lease refused before it existed: the child's prerequisite set and
|
|
6312
|
+
// every considered host with what it lacks (or the one host it would wait for).
|
|
6313
|
+
...(result.childHostRefusal ? {
|
|
6314
|
+
child_placement: { prerequisites: result.childHostRefusal.prerequisites, considered: result.childHostRefusal.considered,
|
|
6315
|
+
...(result.childHostRefusal.child_host ? { child_host: result.childHostRefusal.child_host } : {}) },
|
|
6316
|
+
...(result.childHostRefusal.child_placement_reason ? { child_placement_reason: result.childHostRefusal.child_placement_reason } : {}),
|
|
6317
|
+
...(result.childHostRefusal.host_key ? { serving_host: result.childHostRefusal.host_key } : {}),
|
|
6318
|
+
...(result.childHostRefusal.missing_prerequisites?.length ? { missing_prerequisites: result.childHostRefusal.missing_prerequisites } : {}),
|
|
6319
|
+
} : {}),
|
|
6257
6320
|
// BOT-1803: an idle release is `cleanup: { idle: true, idle_since }` (nothing was reaped).
|
|
6258
6321
|
cleanup: result.cleanup?.idle ? { idle: true, idle_since: result.cleanup.idle_since ?? null } : result.cleanup?.ok ?? null,
|
|
6259
6322
|
cleanup_code: result.cleanup?.code ?? null,
|