@botbuddy/cli 1.112.0 → 1.114.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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.114.0
4
+
5
+ - BOT-3483: `bb wait` rides out a short lock wait when it registers. Registration fences the agent's session row; while another transaction held a row that references the session (the hourly sensor job linking usage, an ingest batch) the database cancelled it at the statement timeout and the wait failed closed with `register_failed`. The fence now takes `FOR NO KEY UPDATE`, which those writers no longer block, and still refuses a stale session-token generation. When the relay still reports a lock wait (`wait_registration_contended`, SQLSTATE 57014 or 55P03; the relay sends it from this release on), the CLI retries the registration up to 3 times (after 2 s, 6 s and 12 s, never past the wait's own deadline) on the same logical wait id, so it never registers twice, then fails closed with exit 5 and a `wait_registration_contended` receipt carrying the SQLSTATE and the number of attempts.
6
+
7
+ ## 1.113.0
8
+
9
+ - BOT-3496: the fleet host daemon reports each running test child's memory so the host's memory admission ledger counts the child once instead of twice (its unit's memory was in the host's baseline as well as in its reservation). The runner learns each live unit's cgroup from the `systemctl show` it already makes. When the heartbeat builds a resource sample, it reads the child's working set at that instant (`memory.current` − `inactive_file` from `/sys/fs/cgroup/<ControlGroup>`, the measure containers already use), and the next claims carry it as `child_memory` with that sample's `observed_at`. A child with no readable cgroup sends nothing, so the ledger keeps its fail-closed count. Needs MCP 2.153.0.
10
+
3
11
  ## 1.112.0
4
12
 
5
13
  - BOT-3448: a fleet host reports `tar-extract` only when its tar can extract an archive with directories inside a test child's sandbox. On Ubuntu 26.04 it cannot: under the child's DynamicUser sandbox, systemd answers `openat2` with ENOSYS, and that tar build has no fallback. Listing (`tar -t`) and reading one member to stdout (`tar -xO`) still work there, so `tar` stays its own capability. A child that unpacks archives into a directory can declare `--child-requires tar-extract`; until the host's tar can, placement refuses it by name instead of starting a run that fails mid-way. The CLI's own tests no longer extract into a directory with the system tar, so the CLI lane runs green as a host child. Needs this daemon on the host.
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.112.0",
3
- "source_commit": "9ee512fa02546dc19da38e62a7acd0c9c0fe0ec4",
4
- "source_sha256": "ab0aeca6b4bc33f23b90662d1e36f4b11d64f4fc552b0f74ea9d653953ad58b3",
2
+ "release_version": "1.114.0",
3
+ "source_commit": "892603d162b26436a93e6dd3332969907c492482",
4
+ "source_sha256": "b35f67f8a37243b2eba151b87aaca8e48947dde8f1817f862371f05d18798558",
5
5
  "target": "darwin-arm64",
6
- "sha256": "a3ee46320e5577495f96884ffde8e280ffd5ee9f35dfa388d396a6bac935b092"
6
+ "sha256": "7299f77e5c1c37a106e93785994fb91f6aaf485ab6d3f68eb2c2bda1e8edf6a3"
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "release_version": "1.112.0",
3
- "source_commit": "9ee512fa02546dc19da38e62a7acd0c9c0fe0ec4",
4
- "source_sha256": "ab0aeca6b4bc33f23b90662d1e36f4b11d64f4fc552b0f74ea9d653953ad58b3",
2
+ "release_version": "1.114.0",
3
+ "source_commit": "892603d162b26436a93e6dd3332969907c492482",
4
+ "source_sha256": "b35f67f8a37243b2eba151b87aaca8e48947dde8f1817f862371f05d18798558",
5
5
  "target": "linux-x64",
6
- "sha256": "fe9b1d14b08c13bda327ea96ba53f4bd5d8a28d01bd1037baefc392645cddbfa"
6
+ "sha256": "37544cf77f133494663fb2cdd46fc1368e7c7865111c59c9d54d1cee869e8aa8"
7
7
  }
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "schema_version": 1,
3
- "release_version": "1.112.0",
4
- "source_commit": "9ee512fa02546dc19da38e62a7acd0c9c0fe0ec4",
5
- "source_sha256": "ab0aeca6b4bc33f23b90662d1e36f4b11d64f4fc552b0f74ea9d653953ad58b3",
3
+ "release_version": "1.114.0",
4
+ "source_commit": "892603d162b26436a93e6dd3332969907c492482",
5
+ "source_sha256": "b35f67f8a37243b2eba151b87aaca8e48947dde8f1817f862371f05d18798558",
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": "a3ee46320e5577495f96884ffde8e280ffd5ee9f35dfa388d396a6bac935b092",
11
+ "sha256": "7299f77e5c1c37a106e93785994fb91f6aaf485ab6d3f68eb2c2bda1e8edf6a3",
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": "fe9b1d14b08c13bda327ea96ba53f4bd5d8a28d01bd1037baefc392645cddbfa",
18
+ "sha256": "37544cf77f133494663fb2cdd46fc1368e7c7865111c59c9d54d1cee869e8aa8",
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.112.0",
3
+ "version": "1.114.0",
4
4
  "description": "BotBuddy — Swarm coordination CLI for multi-agent workflows",
5
5
  "type": "module",
6
6
  "bin": {
package/src/wait.mjs CHANGED
@@ -790,6 +790,13 @@ async function registerWait(opts, conditions, deadlineIso) {
790
790
  // BOT-2855: keep the relay's typed reason for the caller and the receipt.
791
791
  err.errorCode = typedCode || "register_failed";
792
792
  err.httpStatus = res.status;
793
+ // BOT-3483: a lock wait on the session fence is transient — retry it.
794
+ const sqlstate = typeof body.sqlstate === "string" ? body.sqlstate : null;
795
+ if (typedCode === "wait_registration_contended" || WAIT_REGISTER_CONTENTION_SQLSTATES.includes(sqlstate)) {
796
+ err.contended = true;
797
+ err.sqlstate = sqlstate;
798
+ err.errorCode = "wait_registration_contended";
799
+ }
793
800
  if (body.error === "initial_eval_failed") {
794
801
  err.initialEval = true;
795
802
  err.detail = body.detail || "initial evaluation failed";
@@ -1207,6 +1214,25 @@ export const DEFAULT_SSE_IDLE_TIMEOUT_MS = 70_000;
1207
1214
  // to spare (asserted in bot2360-abandoned-wait.test.mjs against the registered cron job).
1208
1215
  export const WAIT_CONNECT_TIMEOUT_MS = 30_000;
1209
1216
 
1217
+ // BOT-3483: register_wait_session_fenced fences the agent's `sessions` row, so a
1218
+ // registration can queue behind another transaction's row lock and be cancelled by
1219
+ // the statement timeout (57014) or refused by lock_timeout (55P03). The relay types
1220
+ // that as `wait_registration_contended`; retry it this many times with this backoff
1221
+ // (total 20 s, inside a wait's own deadline) on the SAME logical wait id, then fail
1222
+ // closed with the typed code. BOTBUDDY_WAIT_REGISTER_BACKOFF_MS="a,b,c" overrides
1223
+ // the delays (tests); an unparsable override keeps the defaults.
1224
+ export const WAIT_REGISTER_CONTENTION_BACKOFF_MS = Object.freeze([2_000, 6_000, 12_000]);
1225
+ export const WAIT_REGISTER_CONTENTION_SQLSTATES = Object.freeze(["57014", "55P03"]);
1226
+
1227
+ function waitRegisterContentionBackoffMs() {
1228
+ const raw = process.env.BOTBUDDY_WAIT_REGISTER_BACKOFF_MS;
1229
+ if (!raw) return WAIT_REGISTER_CONTENTION_BACKOFF_MS;
1230
+ const parsed = raw.split(",").map((v) => Number(v.trim()));
1231
+ return parsed.length === WAIT_REGISTER_CONTENTION_BACKOFF_MS.length && parsed.every((ms) => Number.isFinite(ms) && ms >= 0)
1232
+ ? parsed
1233
+ : WAIT_REGISTER_CONTENTION_BACKOFF_MS;
1234
+ }
1235
+
1210
1236
  function waitConnectTimeoutMs() {
1211
1237
  const raw = Number(process.env.BOTBUDDY_WAIT_CONNECT_TIMEOUT_MS);
1212
1238
  return Number.isFinite(raw) && raw > 0 ? raw : WAIT_CONNECT_TIMEOUT_MS;
@@ -2312,6 +2338,9 @@ export async function runWait(argv, { recoveryLocalWaitId = null } = {}) {
2312
2338
  // is idempotent on the checkpoint's logical_wait_id (BOT-1656), so the
2313
2339
  // reservation above is not repeated.
2314
2340
  let attempts = 0;
2341
+ // BOT-3483: retries of a contended registration (same opts.localWaitId each time).
2342
+ const contentionBackoff = waitRegisterContentionBackoffMs();
2343
+ let contentionRetries = 0;
2315
2344
  let reg;
2316
2345
  for (;;) {
2317
2346
  try {
@@ -2319,6 +2348,17 @@ export async function runWait(argv, { recoveryLocalWaitId = null } = {}) {
2319
2348
  reg = await registerWait(opts, serverConditions(conditions), new Date(deadlineMs).toISOString());
2320
2349
  break;
2321
2350
  } catch (error) {
2351
+ if (error && error.contended) {
2352
+ const delay = contentionBackoff[contentionRetries];
2353
+ // Never back off past the wait's own deadline.
2354
+ if (delay !== undefined && Date.now() + delay < deadlineMs) {
2355
+ contentionRetries += 1;
2356
+ await new Promise((resolve) => setTimeout(resolve, delay));
2357
+ continue;
2358
+ }
2359
+ error.attempts = contentionRetries + 1;
2360
+ throw error;
2361
+ }
2322
2362
  if (!shouldRenewCachedSession(error, opts.credentialSource, attempts)) throw error;
2323
2363
  attempts += 1;
2324
2364
  await clearAgentState(process.cwd());
@@ -2638,6 +2678,26 @@ export async function runWait(argv, { recoveryLocalWaitId = null } = {}) {
2638
2678
  process.exit(EXIT.INTERNAL);
2639
2679
  }
2640
2680
  if (err instanceof WaitCheckpointError) return emitSavedWaitError(err);
2681
+ if (err && err.contended) {
2682
+ // BOT-3483: still contended after every retry. Fail closed (never arm
2683
+ // untracked) with the typed code; re-running `bb wait` is the next step.
2684
+ process.stderr.write(`bb-wait: wait-session registration failed (wait_registration_contended) after ${err.attempts ?? 1} attempts — the session row stayed locked by another transaction (SQLSTATE ${err.sqlstate ?? "unknown"}); failing closed, not arming untracked. Re-run the same bb wait: ${err.message}\n`);
2685
+ await emitReceipt(withPrincipalReceipt(
2686
+ {
2687
+ schema_version: 1,
2688
+ outcome: "error",
2689
+ error: "wait_registration_contended",
2690
+ error_code: "wait_registration_contended",
2691
+ sqlstate: err.sqlstate ?? null,
2692
+ attempts: err.attempts ?? 1,
2693
+ detail: String(err.message),
2694
+ ...(Number.isInteger(err.httpStatus) ? { http_status: err.httpStatus } : {}),
2695
+ },
2696
+ null,
2697
+ { sessionTenant: sessionTenant ?? null, agentId: null },
2698
+ ));
2699
+ process.exit(EXIT.BACKEND);
2700
+ }
2641
2701
  if (hasClaim) {
2642
2702
  process.stderr.write(`bb-wait: claim=true wait-session registration failed (failing closed, not arming untracked): ${err && err.message || err}\n`);
2643
2703
  await emitReceipt({ schema_version: 1, outcome: "error", error: "claim_registration_failed" });