@botbuddy/cli 1.73.4 → 1.73.7
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 +12 -0
- package/claude-plugin/.claude-plugin/marketplace.json +1 -1
- package/claude-plugin/bb-status/.claude-plugin/plugin.json +1 -1
- package/claude-plugin/bb-status/README.md +8 -0
- package/claude-plugin/bb-status/hooks/register.js +126 -26
- 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-provision-failure.mjs +81 -0
- package/src/stack-run-outcome.mjs +10 -0
- package/src/stack-tunnel.mjs +23 -2
- package/src/stack.mjs +19 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.73.7
|
|
4
|
+
|
|
5
|
+
- `bb stack run` says why a stack failed to provision and whose fault it was (BOT-3238). When the serving host rolls a provision back, the receipt now carries a typed `code` (`STACK_SCHEMA_FAILED` or `STACK_PROVISION_FAILED`, where before it was `null`), the lease's `reap_reason`, a `failure_kind` (`schema` or `platform`) and, when the host sent it, `provision_failure: { stage, sqlstate, migration }`. One stderr line names the cause. When Postgres rejects your own migrations or seed (a schema-stage failure with a SQLSTATE that is not a resource, connection or server condition), the run is recorded as a `script` failure and no platform feedback is offered, because retrying or moving host fails the same way. A lease that failed with no recorded reason says `reason_unavailable: true`. The exit code (6) is unchanged.
|
|
6
|
+
|
|
7
|
+
## 1.73.6
|
|
8
|
+
|
|
9
|
+
- `bb stack run --callback-port` no longer refuses a callback tunnel just because the serving host is busy (BOT-2860). Before it opens the real `-R`, the GatewayPorts probe proves that the host keeps reverse forwards on loopback, using a spare host port. It gave up after 2 ports that already had a listener, and parallel sessions' tunnels crowd exactly the ranges it picks from. It now tries up to 20 ports (`PROBE_PORT_ATTEMPTS`), skipping busy ones, within a 60 s overall budget (`DEFAULT_PROBE_BUDGET_MS`) after which it refuses. Only a busy port moves it on: a wildcard bind, a missing `lsof`, an unconfirmed forward or a timeout still refuse at once.
|
|
10
|
+
|
|
11
|
+
## 1.73.5
|
|
12
|
+
|
|
13
|
+
- The bb-status band's badges are compact rounded pills in Claude Code Desktop, shaped like Claude's own buttons (BOT-3230). Each status, the context alarm, every wait and the staging-red banner is one pill: a rounded rectangle in its darker colour with white words and icon. Before, a rounded border drew a whole empty row above and below the words. Each wait's and staging's `↗` link stays beside its pill. Failure notes such as `Guessed from branch · Couldn't load staging` now sit on their own line under the tree, so the first row's title keeps its full width instead of wrapping one word per line. The terminal draws its badges as before. The plugin version moves to 1.4.3, so `bb update` installs it.
|
|
14
|
+
|
|
3
15
|
## 1.73.4
|
|
4
16
|
|
|
5
17
|
- A new Claude Code session in a repo where both the bb-session start-up hook and the bb-status band run is registered by the hook again. The band's first read at session start bootstrapped the same session at the same moment, and both bootstraps failed: the session stayed unregistered for minutes and the model never got its BB identity. For its session's first 30 seconds `bb status-band read` (with the new `--session-started-at`) now leaves the bootstrap to the hook and answers `session_starting` with `retry_after_ms`; the band shows "Connecting this session to BB…" and reads once more when told. A session the hook did not register is still bound by the band after that window. The band's plugin version moves to 1.4.2.
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"name": "bb-status",
|
|
12
12
|
"source": "./bb-status",
|
|
13
13
|
"description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging, context use and active waits, for BotBuddy and Supply Guard sessions",
|
|
14
|
-
"version": "1.4.
|
|
14
|
+
"version": "1.4.3"
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
"name": "bb-session",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bb-status",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "BB session status above the prompt: tickets, PRs with review counts, epic, staging, context use and active waits, live only while the session is on screen.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "BotBuddy"
|
|
@@ -206,3 +206,11 @@ rounded (`borderStyle: "round"`) outside the terminal; the staging banner is the
|
|
|
206
206
|
same red badge as the context alarm. PRs nest by indent with no trunk line, and
|
|
207
207
|
rows sit in one column Box with an even `rowGap`. The read runs from the
|
|
208
208
|
worktree root even when Claude's working directory is a subfolder.
|
|
209
|
+
|
|
210
|
+
**BOT-3230 pills.** On Desktop and the other graphical surfaces every badge
|
|
211
|
+
(status, context alarm, wait, staging red) is one SVG pill: a rounded rect
|
|
212
|
+
(6px radius, 22px tall) in the badge's darker fill, with the white icon and
|
|
213
|
+
words inside, its width estimated from the words. A Claude Code `Box` has no
|
|
214
|
+
corner radius, and a border draws a whole row above and below. Links stay
|
|
215
|
+
`Link` elements beside the pill. Failure notes are their own dim line under
|
|
216
|
+
the tree. The terminal keeps filled `Box` badges.
|
|
@@ -812,10 +812,76 @@ function inked(source, bg) {
|
|
|
812
812
|
.replace(/#[0-9a-f]{6}\b/gi, "#ffffff")
|
|
813
813
|
.replace(/@BG@/g, bg);
|
|
814
814
|
}
|
|
815
|
-
|
|
816
|
-
|
|
815
|
+
// BOT-3230: off the terminal every badge is one SVG pill — a rounded rect in
|
|
816
|
+
// its fill, the icon and words in white — the only element that can draw a
|
|
817
|
+
// corner radius (Jono, 2026-11-14: "I want it to look like Details"). A Box
|
|
818
|
+
// border drew a whole row above and below the words. The terminal keeps the
|
|
819
|
+
// filled Box.
|
|
820
|
+
const PILL = { h: 22, rx: 6, pad: 8, icon: 12, gap: 5, font: 13 };
|
|
821
|
+
const RED = "#c62828"; // the context alarm's and staging red's one fill
|
|
822
|
+
function pills() {
|
|
823
|
+
return surface !== "terminal";
|
|
817
824
|
}
|
|
818
|
-
|
|
825
|
+
// The system font's advance at 13px, estimated per character, slightly over
|
|
826
|
+
// so the words never touch the rounded end.
|
|
827
|
+
function glyphPx(ch) {
|
|
828
|
+
if (ch === " ") return 3.6;
|
|
829
|
+
if (/[il.,:;'|!·]/.test(ch)) return 3.3;
|
|
830
|
+
if (/[fjrt\/()\[\]]/.test(ch)) return 4.4;
|
|
831
|
+
if (/[mw]/.test(ch)) return 10.2;
|
|
832
|
+
if (/[MW%]/.test(ch)) return 11;
|
|
833
|
+
if (/[A-Z]/.test(ch)) return 8.1;
|
|
834
|
+
if (/[0-9]/.test(ch)) return 7.1;
|
|
835
|
+
if (/[a-z]/.test(ch)) return 6.5;
|
|
836
|
+
if (ch.codePointAt(0) > 0x2000) return 15; // ⏳ ▲ and other symbols
|
|
837
|
+
return 7.1;
|
|
838
|
+
}
|
|
839
|
+
function textPx(text, bold) {
|
|
840
|
+
const w = [...String(text)].reduce((n, ch) => n + glyphPx(ch), 0);
|
|
841
|
+
return Math.ceil(w * (bold ? 1.06 : 1));
|
|
842
|
+
}
|
|
843
|
+
function xml(text) {
|
|
844
|
+
return String(text).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
845
|
+
}
|
|
846
|
+
// The pill's own width; `slot` (≥ it) widens the drawing, never the pill, so
|
|
847
|
+
// a column of pills lines up.
|
|
848
|
+
function pillWidth({ text, icon, bold }) {
|
|
849
|
+
return PILL.pad * 2 + (icon ? PILL.icon + (text ? PILL.gap : 0) : 0) + (text ? textPx(text, bold) : 0);
|
|
850
|
+
}
|
|
851
|
+
function pillSource({ text, icon, fill, bold }, slot) {
|
|
852
|
+
const w = pillWidth({ text, icon, bold });
|
|
853
|
+
const outer = Math.max(w, slot || 0);
|
|
854
|
+
let x = PILL.pad;
|
|
855
|
+
let body = `<rect x="0" y="0" width="${w}" height="${PILL.h}" rx="${PILL.rx}" fill="${fill}"/>`;
|
|
856
|
+
if (icon) {
|
|
857
|
+
body += String(icon).replace(/^<svg /, `<svg x="${x}" y="${(PILL.h - PILL.icon) / 2}" `);
|
|
858
|
+
x += PILL.icon + (text ? PILL.gap : 0);
|
|
859
|
+
}
|
|
860
|
+
if (text)
|
|
861
|
+
body += `<text x="${x}" y="15" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif" font-size="${PILL.font}"${bold ? ' font-weight="600"' : ""} fill="#ffffff">${xml(text)}</text>`;
|
|
862
|
+
return { width: outer, source: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${outer} ${PILL.h}" width="${outer}" height="${PILL.h}">${body}</svg>` };
|
|
863
|
+
}
|
|
864
|
+
function pillSvg(el, pill, slot) {
|
|
865
|
+
const { width, source } = pillSource(pill, slot);
|
|
866
|
+
return el.Svg({ alt: pill.alt || pill.text, width, height: PILL.h, source });
|
|
867
|
+
}
|
|
868
|
+
function statusText(spec) {
|
|
869
|
+
return spec.status.map((part) => part.text).join(" · ");
|
|
870
|
+
}
|
|
871
|
+
// The pill's alt: what its icon said (kind and state), then any further parts
|
|
872
|
+
// (a PR's review count, a project's done/total). When the pill shows a status
|
|
873
|
+
// the icon does not say (a conflicted open PR reads "Conflict"), that status
|
|
874
|
+
// leads the parts, so the alt never drops a warning (Codex P2, PR #1662).
|
|
875
|
+
function statusPill(spec) {
|
|
876
|
+
const said = (spec.iconAlt || "").toLowerCase();
|
|
877
|
+
const first = (spec.status[0]?.text || "").toLowerCase();
|
|
878
|
+
const rest = spec.status.slice(first && said.endsWith(first) ? 1 : 0).map((part) => part.text);
|
|
879
|
+
const alt = spec.iconAlt ? [spec.iconAlt, ...rest].join(" · ") : statusText(spec);
|
|
880
|
+
return { text: statusText(spec), icon: spec.iconSource, fill: badgeColors(spec.hex).bg, alt };
|
|
881
|
+
}
|
|
882
|
+
function statusBadge(el, key, spec, slot) {
|
|
883
|
+
if (pills() && spec.iconSource && typeof el.Svg === "function")
|
|
884
|
+
return [el.Box({ key, flexDirection: "row", flexShrink: 0, children: [pillSvg(el, statusPill(spec), slot)] })];
|
|
819
885
|
if (!spec.status.length) return spec.icon ? [spec.icon] : [];
|
|
820
886
|
const { bg, fg, muted } = badgeColors(spec.hex);
|
|
821
887
|
const children = spec.icon ? [spec.icon] : [];
|
|
@@ -823,7 +889,7 @@ function statusBadge(el, key, spec) {
|
|
|
823
889
|
if (i) children.push(el.Text({ color: muted, children: [" · "] }));
|
|
824
890
|
children.push(el.Text({ color: part.muted ? muted : fg, children: [part.text] }));
|
|
825
891
|
});
|
|
826
|
-
return [el.Box({ key, flexDirection: "row", flexShrink: 0, backgroundColor: bg,
|
|
892
|
+
return [el.Box({ key, flexDirection: "row", flexShrink: 0, backgroundColor: bg, paddingX: 1, children })];
|
|
827
893
|
}
|
|
828
894
|
function bandLine(el, spec, widths, right) {
|
|
829
895
|
const ids = [];
|
|
@@ -837,7 +903,9 @@ function bandLine(el, spec, widths, right) {
|
|
|
837
903
|
if (spec.note) title.push(dim(el, " " + spec.note));
|
|
838
904
|
const children = [
|
|
839
905
|
el.Box({ key: spec.key + "-ids", flexDirection: "row", width: widths.ids, flexShrink: 0, children: ids }),
|
|
840
|
-
|
|
906
|
+
// Off the terminal every pill is drawn at the widest pill's width (pixels),
|
|
907
|
+
// so the column needs no cell width of its own.
|
|
908
|
+
el.Box({ key: spec.key + "-status", flexDirection: "row", ...(widths.statusPx ? {} : { width: widths.status }), flexShrink: 0, children: statusBadge(el, spec.key + "-badge", spec, widths.statusPx) }),
|
|
841
909
|
el.Box({ key: spec.key + "-title", flexDirection: "row", flexGrow: 1, flexShrink: 1, minWidth: 0, flexWrap: "wrap", children: title }),
|
|
842
910
|
];
|
|
843
911
|
if (right && right.length)
|
|
@@ -869,24 +937,37 @@ function waitBadges(el, key, w, now) {
|
|
|
869
937
|
if (!w || !Number.isSafeInteger(w.count) || w.count < 1) return [];
|
|
870
938
|
const style = pulsing ? { bold: true } : {};
|
|
871
939
|
const { bg, fg } = badgeColors(ICON.violet);
|
|
872
|
-
const shape = { backgroundColor: bg,
|
|
940
|
+
const shape = { backgroundColor: bg, paddingX: 1 };
|
|
941
|
+
const svg = pills() && typeof el.Svg === "function";
|
|
873
942
|
// An older BB lists no items: the one count badge, as before.
|
|
874
943
|
if (!Array.isArray(w.items) || !w.items.length) {
|
|
875
944
|
const text = waitsText(w, now);
|
|
876
|
-
|
|
945
|
+
if (!text) return [];
|
|
946
|
+
if (svg) return [el.Box({ key: key + "-waits", flexDirection: "row", flexShrink: 0, children: [pillSvg(el, { text, fill: bg, bold: pulsing })] })];
|
|
947
|
+
return [el.Box({ key: key + "-waits", flexDirection: "row", flexShrink: 0, ...shape, children: [el.Text({ color: fg, ...style, children: [text] })] })];
|
|
877
948
|
}
|
|
878
|
-
const out = w.items.slice(0, MAX_WAIT_BADGES).map((i) =>
|
|
879
|
-
|
|
949
|
+
const out = w.items.slice(0, MAX_WAIT_BADGES).map((i) => {
|
|
950
|
+
const text = "⏳ " + i.label + " · " + shortAge(i.created_at, now);
|
|
951
|
+
if (svg)
|
|
952
|
+
return el.Box({
|
|
953
|
+
key: key + "-wait-" + i.id,
|
|
954
|
+
flexDirection: "row",
|
|
955
|
+
flexShrink: 0,
|
|
956
|
+
alignItems: "center",
|
|
957
|
+
columnGap: 1,
|
|
958
|
+
children: [pillSvg(el, { text, fill: bg, bold: pulsing }), el.Link({ href: LINKS.wait(i.id), label: "↗" })],
|
|
959
|
+
});
|
|
960
|
+
return el.Box({
|
|
880
961
|
key: key + "-wait-" + i.id,
|
|
881
962
|
flexDirection: "row",
|
|
882
963
|
flexShrink: 0,
|
|
883
964
|
...shape,
|
|
884
965
|
children: [
|
|
885
|
-
el.Text({ color: fg, ...style, children: [
|
|
966
|
+
el.Text({ color: fg, ...style, children: [text + " "] }),
|
|
886
967
|
el.Link({ href: LINKS.wait(i.id), label: "↗" }),
|
|
887
968
|
],
|
|
888
|
-
})
|
|
889
|
-
);
|
|
969
|
+
});
|
|
970
|
+
});
|
|
890
971
|
if (w.count > out.length) out.push(dim(el, "+" + (w.count - out.length) + " more"));
|
|
891
972
|
return out;
|
|
892
973
|
}
|
|
@@ -895,11 +976,13 @@ function contextLine(el, key, waits = null) {
|
|
|
895
976
|
const alarm = contextAlarm(context);
|
|
896
977
|
if (alarm)
|
|
897
978
|
children.push(
|
|
898
|
-
|
|
979
|
+
pills() && typeof el.Svg === "function"
|
|
980
|
+
? el.Box({ key: key + "-ctx", flexDirection: "row", flexShrink: 0, children: [pillSvg(el, { text: alarm, fill: RED, bold: true })] })
|
|
981
|
+
: el.Box({ key: key + "-ctx", flexDirection: "row", flexShrink: 0, backgroundColor: "error", paddingX: 1, children: [el.Text({ color: "#ffffff", bold: true, children: [alarm] })] }),
|
|
899
982
|
);
|
|
900
983
|
children.push(...waitBadges(el, key, waits, currentTime));
|
|
901
984
|
if (!children.length) return null;
|
|
902
|
-
return el.Box({ key, flexDirection: "row", flexWrap: "wrap", columnGap: 1, rowGap: 0, children });
|
|
985
|
+
return el.Box({ key, flexDirection: "row", flexWrap: "wrap", alignItems: "center", columnGap: 1, rowGap: 0, children });
|
|
903
986
|
}
|
|
904
987
|
async function readContext($) {
|
|
905
988
|
try {
|
|
@@ -925,22 +1008,24 @@ function shortAge(fromIso, now) {
|
|
|
925
1008
|
return hours < 48 ? hours + "h" : Math.floor(hours / 24) + "d";
|
|
926
1009
|
}
|
|
927
1010
|
function stagingBanner(el, key, since) {
|
|
1011
|
+
const text = "▲ Staging red" + (since ? " " + shortAge(since, currentTime) : "");
|
|
928
1012
|
return el.Box({
|
|
929
1013
|
key,
|
|
930
1014
|
flexDirection: "row",
|
|
1015
|
+
alignItems: "center",
|
|
931
1016
|
columnGap: 1,
|
|
932
1017
|
children: [
|
|
933
1018
|
// BOT-3228: the same red badge, white lettering, as the context alarm.
|
|
934
|
-
el.
|
|
935
|
-
key: key + "-badge",
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
1019
|
+
pills() && typeof el.Svg === "function"
|
|
1020
|
+
? el.Box({ key: key + "-badge", flexDirection: "row", flexShrink: 0, children: [pillSvg(el, { text, fill: RED, bold: true })] })
|
|
1021
|
+
: el.Box({
|
|
1022
|
+
key: key + "-badge",
|
|
1023
|
+
flexDirection: "row",
|
|
1024
|
+
flexShrink: 0,
|
|
1025
|
+
backgroundColor: "error",
|
|
1026
|
+
paddingX: 1,
|
|
1027
|
+
children: [el.Text({ color: "#ffffff", bold: true, children: [text] })],
|
|
1028
|
+
}),
|
|
944
1029
|
el.Link({ href: LINKS.staging, label: "Open staging ↗" }),
|
|
945
1030
|
],
|
|
946
1031
|
});
|
|
@@ -977,6 +1062,8 @@ function bandLines(el, $, inPane) {
|
|
|
977
1062
|
prefix,
|
|
978
1063
|
ids: [{ label: t.key, href: LINKS.ticket(t.key), out: OUT.ticket(s.tenant, t.key) }],
|
|
979
1064
|
icon: lead(el, "◆", "#ffffff", "ticket " + t.status, inked(ticketIcon(t.status), badgeColors(ticketHex(t.status)).bg)),
|
|
1065
|
+
iconSource: inked(ticketIcon(t.status), badgeColors(ticketHex(t.status)).bg),
|
|
1066
|
+
iconAlt: "ticket " + t.status,
|
|
980
1067
|
hex: ticketHex(t.status),
|
|
981
1068
|
status: [{ text: t.status }],
|
|
982
1069
|
title: t.title,
|
|
@@ -993,6 +1080,8 @@ function bandLines(el, $, inPane) {
|
|
|
993
1080
|
prefix,
|
|
994
1081
|
ids: [{ label: "PR " + p.number, href: LINKS.pr(p.repo, p.number), out: OUT.pr(p.repo, p.number) }],
|
|
995
1082
|
icon: lead(el, "⎇", "#ffffff", "pr " + p.state, inked(prIcon(p.state), badgeColors(hex).bg)),
|
|
1083
|
+
iconSource: inked(prIcon(p.state), badgeColors(hex).bg),
|
|
1084
|
+
iconAlt: "pr " + p.state,
|
|
996
1085
|
hex,
|
|
997
1086
|
status,
|
|
998
1087
|
title: p.title,
|
|
@@ -1012,6 +1101,8 @@ function bandLines(el, $, inPane) {
|
|
|
1012
1101
|
},
|
|
1013
1102
|
],
|
|
1014
1103
|
icon: lead(el, "◇", "#ffffff", "project " + s.epic.state + " " + s.epic.percent + "%", inked(epicIcon(s.epic.state, s.epic.percent), badgeColors(epicHex(s.epic.state)).bg)),
|
|
1104
|
+
iconSource: inked(epicIcon(s.epic.state, s.epic.percent), badgeColors(epicHex(s.epic.state)).bg),
|
|
1105
|
+
iconAlt: "project " + s.epic.state + " " + s.epic.percent + "%",
|
|
1015
1106
|
hex: epicHex(s.epic.state),
|
|
1016
1107
|
status: [{ text: s.epic.percent + "%" }, ...(Number.isSafeInteger(s.epic.total) && s.epic.total > 0 ? [{ text: s.epic.done + "/" + s.epic.total, muted: true }] : [])],
|
|
1017
1108
|
// BOT-3213: the project a coordinator session runs, with its tickets by state.
|
|
@@ -1053,15 +1144,24 @@ function bandLines(el, $, inPane) {
|
|
|
1053
1144
|
if (s.staging == null) notes.push(UNREAD.staging);
|
|
1054
1145
|
const right = [...tag];
|
|
1055
1146
|
if (stale()) right.push(el.Text({ color: "warning", children: ["STALE"] }));
|
|
1056
|
-
|
|
1147
|
+
// BOT-3230: the notes are their own line under the tree. In the first row
|
|
1148
|
+
// they were a column that never shrank, squeezing the title to a word a line.
|
|
1149
|
+
const noteLine = notes.length
|
|
1150
|
+
? el.Box({ key: k("line-notes-row"), flexDirection: "row", children: [el.Text({ key: k("line-notes"), dimColor: true, wrap: "wrap", children: [notes.join(" · ")] })] })
|
|
1151
|
+
: null;
|
|
1057
1152
|
if (details) right.push(details);
|
|
1153
|
+
const svgPills = pills() && typeof el.Svg === "function";
|
|
1058
1154
|
const widths = {
|
|
1059
1155
|
ids: Math.max(0, ...specs.map((x) => idsWidth(x.ids, x.prefix))),
|
|
1060
1156
|
status: Math.max(0, ...specs.map(statusWidth)),
|
|
1157
|
+
statusPx: svgPills ? Math.max(0, ...specs.filter((x) => x.iconSource).map((x) => pillWidth(statusPill(x)))) : 0,
|
|
1061
1158
|
};
|
|
1062
1159
|
const lines = specs.length
|
|
1063
1160
|
? specs.map((spec, i) => bandLine(el, spec, widths, i === 0 ? right : null))
|
|
1064
|
-
:
|
|
1161
|
+
: right.length
|
|
1162
|
+
? [el.Box({ key: k("line-notes-only"), flexDirection: "row", columnGap: 1, children: right })]
|
|
1163
|
+
: [];
|
|
1164
|
+
if (noteLine) lines.push(noteLine);
|
|
1065
1165
|
// BOT-3223 AC-1: context alarm and wait badges lead, on one wrapping line.
|
|
1066
1166
|
const ctx = contextLine(el, k("line-context"), s.waits);
|
|
1067
1167
|
if (ctx) lines.unshift(ctx);
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.73.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.73.7",
|
|
3
|
+
"source_commit": "d0189483f2caa6d81fad5f59be783bd1ec2d86d3",
|
|
4
|
+
"source_sha256": "c4773b3dbdf5faf65a3641dbcd676de8ee5962adaf2acac74c3146dc977fa686",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "247f88078a3a7f30617d2370b6a5ef751e4d1dac98a619936dc5923af8e0eb64"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.73.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.73.7",
|
|
3
|
+
"source_commit": "d0189483f2caa6d81fad5f59be783bd1ec2d86d3",
|
|
4
|
+
"source_sha256": "c4773b3dbdf5faf65a3641dbcd676de8ee5962adaf2acac74c3146dc977fa686",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "dd5d13fefb7cb6e43b2d08a9d2a52e34b93f6a76744b052ccf21d3fc3d1ec7c4"
|
|
7
7
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
|
-
"release_version": "1.73.
|
|
4
|
-
"source_commit": "
|
|
5
|
-
"source_sha256": "
|
|
3
|
+
"release_version": "1.73.7",
|
|
4
|
+
"source_commit": "d0189483f2caa6d81fad5f59be783bd1ec2d86d3",
|
|
5
|
+
"source_sha256": "c4773b3dbdf5faf65a3641dbcd676de8ee5962adaf2acac74c3146dc977fa686",
|
|
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": "247f88078a3a7f30617d2370b6a5ef751e4d1dac98a619936dc5923af8e0eb64",
|
|
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": "dd5d13fefb7cb6e43b2d08a9d2a52e34b93f6a76744b052ccf21d3fc3d1ec7c4",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// BOT-3238 — name WHY a stack lease failed to provision, and whose fault it was.
|
|
2
|
+
//
|
|
3
|
+
// A provision the serving host rolled back ends `reaping / provision_failed`, and
|
|
4
|
+
// the host's bounded, redacted reason is persisted on the lease as `error`
|
|
5
|
+
// (BOT-2701 detail: `stage=<stage> outcome=<outcome> exit=<n> cleanup=<c>
|
|
6
|
+
// sqlstate=<SQLSTATE> migration=<version>`). Before this module the run receipt
|
|
7
|
+
// carried that text only inside its free-form `error`, with `code: null`, and the
|
|
8
|
+
// outcome record filed every such run as a `platform` failure. A migration in the
|
|
9
|
+
// caller's own repo that Postgres rejects is the caller's failure, not the host's:
|
|
10
|
+
// on ENT-7111 three runs blamed a healthy host for a `LOCK TABLE` outside a
|
|
11
|
+
// transaction (SQLSTATE 25P01).
|
|
12
|
+
//
|
|
13
|
+
// Pure: no I/O, so the classification is unit-tested on its own.
|
|
14
|
+
|
|
15
|
+
/** The caller's own schema (migrations + seed) was rejected by Postgres. Category `script`. */
|
|
16
|
+
export const STACK_SCHEMA_FAILED = "STACK_SCHEMA_FAILED";
|
|
17
|
+
/** Any other rolled-back provision: the host, its Docker engine or the stack start. Category `platform`. */
|
|
18
|
+
export const STACK_PROVISION_FAILED = "STACK_PROVISION_FAILED";
|
|
19
|
+
|
|
20
|
+
// SQLSTATE classes that describe the server, not the SQL it was given: connection
|
|
21
|
+
// (08), insufficient resources (53, e.g. 53200 max_locks_per_transaction), operator
|
|
22
|
+
// intervention (57, e.g. 57014 statement timeout), system error (58) and internal
|
|
23
|
+
// error (XX). A schema-stage failure in one of these stays a platform failure.
|
|
24
|
+
const PLATFORM_SQLSTATE_CLASSES = new Set(["08", "53", "57", "58", "XX"]);
|
|
25
|
+
|
|
26
|
+
const STAGE_RE = /(?:^|\s)stage=([a-z_]{1,32})(?=\s|$)/;
|
|
27
|
+
const SQLSTATE_RE = /(?:^|\s)sqlstate=([0-9A-Z]{5})(?=\s|$)/;
|
|
28
|
+
// A migration version, or `seed` when the host attributes the failure to the seed file
|
|
29
|
+
// (daemon/native_diagnostic.go; never guessed from the last migration).
|
|
30
|
+
const MIGRATION_RE = /(?:^|\s)migration=([0-9]{1,20}|seed)(?=\s|$)/;
|
|
31
|
+
|
|
32
|
+
/** The bounded detail fields of a host provision error, each null when absent. */
|
|
33
|
+
export function parseProvisionError(error) {
|
|
34
|
+
if (typeof error !== "string" || error.length === 0) return { stage: null, sqlstate: null, migration: null };
|
|
35
|
+
const text = error.slice(0, 2048);
|
|
36
|
+
return {
|
|
37
|
+
stage: STAGE_RE.exec(text)?.[1] ?? null,
|
|
38
|
+
sqlstate: SQLSTATE_RE.exec(text)?.[1] ?? null,
|
|
39
|
+
migration: MIGRATION_RE.exec(text)?.[1] ?? null,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The receipt fields for a lease that ended before reaching active, from one read of
|
|
45
|
+
* it (`get_stack_lease` data), or null when the read says nothing about a provision
|
|
46
|
+
* failure. `failure_kind` is `schema` (the caller's migrations or seed) or `platform`.
|
|
47
|
+
*/
|
|
48
|
+
export function provisionFailureFields(lease) {
|
|
49
|
+
if (!lease || typeof lease !== "object") return null;
|
|
50
|
+
const reapReason = typeof lease.reap_reason === "string" && lease.reap_reason ? lease.reap_reason : null;
|
|
51
|
+
if (reapReason !== "provision_failed") return null;
|
|
52
|
+
const error = typeof lease.error === "string" && lease.error ? lease.error : null;
|
|
53
|
+
if (!error) {
|
|
54
|
+
return { code: STACK_PROVISION_FAILED, reapReason, failureKind: "platform", detail: null, reasonUnavailable: true };
|
|
55
|
+
}
|
|
56
|
+
const detail = parseProvisionError(error);
|
|
57
|
+
const schema = detail.stage === "schema" && detail.sqlstate != null && !PLATFORM_SQLSTATE_CLASSES.has(detail.sqlstate.slice(0, 2));
|
|
58
|
+
return {
|
|
59
|
+
code: schema ? STACK_SCHEMA_FAILED : STACK_PROVISION_FAILED,
|
|
60
|
+
reapReason,
|
|
61
|
+
failureKind: schema ? "schema" : "platform",
|
|
62
|
+
detail: detail.stage || detail.sqlstate || detail.migration ? detail : null,
|
|
63
|
+
reasonUnavailable: false,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** One stderr line for a human reading the run, naming the cause and whose it is. */
|
|
68
|
+
export function provisionFailureLine(leaseId, failure, hostKey = null) {
|
|
69
|
+
if (!failure) return null;
|
|
70
|
+
const where = hostKey ? ` on ${hostKey}` : "";
|
|
71
|
+
if (failure.failureKind === "schema") {
|
|
72
|
+
const source = failure.detail?.migration;
|
|
73
|
+
const migration = source === "seed" ? "your seed" : source ? `migration ${source}` : "your schema";
|
|
74
|
+
return `stack: lease ${leaseId} failed to provision: ${migration} was rejected by Postgres (SQLSTATE ${failure.detail.sqlstate}). ` +
|
|
75
|
+
"This is your repo's migrations or seed, not the host — fix it and run again; retrying or moving host fails the same way.";
|
|
76
|
+
}
|
|
77
|
+
if (failure.reasonUnavailable) {
|
|
78
|
+
return `stack: lease ${leaseId} failed to provision${where}; the host recorded no reason — inspect \`bb stack status ${leaseId}\``;
|
|
79
|
+
}
|
|
80
|
+
return `stack: lease ${leaseId} failed to provision${where} (a platform failure, not your code) — see the receipt's \`error\``;
|
|
81
|
+
}
|
|
@@ -59,6 +59,8 @@ const EXIT_CLEANUP_FAILED = 8;
|
|
|
59
59
|
const SIGNAL_EXITS = new Set([129, 130, 143]);
|
|
60
60
|
// Typed codes that are the platform's fault whatever the exit code says.
|
|
61
61
|
const PLATFORM_CODES = new Set(["TUNNEL_LOST", "LEASE_PREEMPTED", "HOST_CAPACITY_SOURCE_STALE"]);
|
|
62
|
+
// Mirrors stack-provision-failure.mjs STACK_SCHEMA_FAILED (kept local for the same reason as EXIT).
|
|
63
|
+
const STACK_SCHEMA_FAILED_CODE = "STACK_SCHEMA_FAILED";
|
|
62
64
|
|
|
63
65
|
function boundedCode(value) {
|
|
64
66
|
return typeof value === "string" && CODE_RE.test(value) ? value : null;
|
|
@@ -87,6 +89,14 @@ export function classifyStackRunOutcome(fields = {}, exitCode) {
|
|
|
87
89
|
// BOT-3109: set only when the requester network probe proved a local change (never a guess).
|
|
88
90
|
if (code === REQUESTER_CATEGORY_CODE) return { category: "requester", code };
|
|
89
91
|
if (code && PLATFORM_CODES.has(code)) return { category: "platform", code };
|
|
92
|
+
// BOT-3238: Postgres rejected the caller's own migrations or seed while the stack
|
|
93
|
+
// provisioned. The host did its job; the repo's schema failed, so it is a script failure.
|
|
94
|
+
// Only when the run ended as that lease failure with its teardown proven: an unproven
|
|
95
|
+
// cleanup (exit 8, cleanup false) may still hold the host's containers, so it stays
|
|
96
|
+
// CLEANUP_FAILED / platform below.
|
|
97
|
+
if (code === STACK_SCHEMA_FAILED_CODE && fields.lease_fenced !== true && fields.cleanup !== false && exitCode === EXIT_LEASE_FAILED) {
|
|
98
|
+
return { category: "script", code };
|
|
99
|
+
}
|
|
90
100
|
// The stdout fence also covers unresolved cleanup. The lifecycle supplies its
|
|
91
101
|
// original lease-fence fact separately so coincident child exits cannot hide it.
|
|
92
102
|
if ((fields.lease_fenced ?? fields.fenced) === true) return { category: "platform", code: code ?? "LEASE_LOST" };
|
package/src/stack-tunnel.mjs
CHANGED
|
@@ -400,6 +400,19 @@ export function randomProbePort(random = Math.random) {
|
|
|
400
400
|
|
|
401
401
|
const REMOTE_FORWARD_BUSY = /remote port forwarding failed|address already in use|cannot listen/i;
|
|
402
402
|
export const DEFAULT_PROBE_READY_MS = 10_000;
|
|
403
|
+
/**
|
|
404
|
+
* BOT-2860: how many host ports the GatewayPorts probe may try. Only a BUSY port (a listener before
|
|
405
|
+
* the probe, a foreign listener beside it, or sshd refusing the bind) moves on to another port;
|
|
406
|
+
* every other outcome refuses at once, so a larger budget never weakens fail-closed. Parallel
|
|
407
|
+
* sessions' tunnels crowd TUNNEL_PORT_RANGES on a busy host, and two picks were not enough there.
|
|
408
|
+
*/
|
|
409
|
+
export const PROBE_PORT_ATTEMPTS = TUNNEL_PORT_PICKS;
|
|
410
|
+
/**
|
|
411
|
+
* BOT-2860 (review): the whole probe's time budget. With PROBE_PORT_ATTEMPTS tries on a slow host
|
|
412
|
+
* (each remote check may take up to its spawnSync timeout), the probe could otherwise run for
|
|
413
|
+
* minutes; once this is spent no further port is tried and the probe refuses.
|
|
414
|
+
*/
|
|
415
|
+
export const DEFAULT_PROBE_BUDGET_MS = 60_000;
|
|
403
416
|
|
|
404
417
|
/**
|
|
405
418
|
* Codex #1134 P1: the probe's LOCAL destination is a port this process holds for the whole probe —
|
|
@@ -439,11 +452,13 @@ function listenSilent(port) {
|
|
|
439
452
|
* exposed even if sshd binds it wildcard), asks
|
|
440
453
|
* the host which address P really holds (`verifyCallbackLoopback` with `port: P`), and kills the
|
|
441
454
|
* probe. Fail closed: an exposed bind, lsof missing, or a listener that never appears is
|
|
442
|
-
* CALLBACK_NOT_LOOPBACK; a busy P is retried
|
|
455
|
+
* CALLBACK_NOT_LOOPBACK; a busy P is retried on another port, at most PROBE_PORT_ATTEMPTS ports in
|
|
456
|
+
* all, then refused.
|
|
443
457
|
*/
|
|
444
458
|
export async function probeGatewayPorts({
|
|
445
459
|
sshBin = "ssh", sshTarget, env = process.env, spawnImpl = spawn, run = spawnSync, pickProbePort = randomProbePort,
|
|
446
|
-
holdLocalPort = holdSilentLocalPort, readyTimeoutMs = DEFAULT_PROBE_READY_MS, attempts =
|
|
460
|
+
holdLocalPort = holdSilentLocalPort, readyTimeoutMs = DEFAULT_PROBE_READY_MS, attempts = PROBE_PORT_ATTEMPTS,
|
|
461
|
+
budgetMs = DEFAULT_PROBE_BUDGET_MS, now = Date.now,
|
|
447
462
|
sleep = (ms) => new Promise((r) => setTimeout(r, ms)),
|
|
448
463
|
}) {
|
|
449
464
|
const fail = (why) => tunnelError("CALLBACK_NOT_LOOPBACK",
|
|
@@ -452,7 +467,13 @@ export async function probeGatewayPorts({
|
|
|
452
467
|
"(or clientspecified) on the host, or run without --callback-port.");
|
|
453
468
|
const tried = new Set();
|
|
454
469
|
let busyTail = "";
|
|
470
|
+
const budgetEnds = now() + budgetMs;
|
|
471
|
+
let spent = 0;
|
|
455
472
|
for (let attempt = 1; attempt <= attempts; attempt++) {
|
|
473
|
+
if (attempt > 1 && now() > budgetEnds) {
|
|
474
|
+
throw fail(`the host refused ${spent} probe ports and the probe's ${Math.round(budgetMs / 1000)}s budget is spent: ${busyTail}`);
|
|
475
|
+
}
|
|
476
|
+
spent = attempt;
|
|
456
477
|
// BOT-2503: an invalid or serving-band pick never reaches ssh; at most TUNNEL_PORT_PICKS picks.
|
|
457
478
|
let port = null;
|
|
458
479
|
for (let i = 0; port == null && i < TUNNEL_PORT_PICKS; i++) {
|
package/src/stack.mjs
CHANGED
|
@@ -61,6 +61,7 @@ import { ENGINE_PUBLISHES_BEYOND_LOOPBACK, engineSocketIsLocal, formatPublishIp,
|
|
|
61
61
|
import { bold, dim, yellow } from "./utils.mjs";
|
|
62
62
|
import { STACK_RELEASE_INTENT_ENV, classifyStackRunOutcome, observeStackRunSignal, ownerReleaseHeld, reportStackRunOutcome } from "./stack-run-outcome.mjs";
|
|
63
63
|
import { REQUESTER_NETWORK_CANDIDATE_CODES, REQUESTER_NETWORK_LOST_CODE, createRequesterNetworkWatch, requesterNetworkLostMessage } from "./requester-network.mjs";
|
|
64
|
+
import { provisionFailureFields, provisionFailureLine } from "./stack-provision-failure.mjs";
|
|
64
65
|
|
|
65
66
|
export const STACK_SCHEMA_VERSION = 1;
|
|
66
67
|
|
|
@@ -337,6 +338,10 @@ ${bold("EXIT CODES")}
|
|
|
337
338
|
3 not authenticated
|
|
338
339
|
4 invalid arguments 5 backend/coordination 6 lease failed/reaped
|
|
339
340
|
7 internal error 8 cleanup/reap proof failed
|
|
341
|
+
A provision the host rolled back (exit 6) names its cause (BOT-3238): code STACK_SCHEMA_FAILED
|
|
342
|
+
(Postgres rejected your migrations/seed: failure_kind "schema", provision_failure {stage, sqlstate,
|
|
343
|
+
migration}; recorded as your script, not the platform) or STACK_PROVISION_FAILED (failure_kind
|
|
344
|
+
"platform"), plus reap_reason; reason_unavailable true when the host recorded none.
|
|
340
345
|
|
|
341
346
|
${bold("IDLE LEASES")} (BOT-1803)
|
|
342
347
|
stack run sends stack_digest (the deterministic sha256 of the materialised stack bundle, also
|
|
@@ -5161,14 +5166,22 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5161
5166
|
// BOT-2099 (hops 3–4): name the Helper's reason (e.g. `schema readiness rejected:
|
|
5162
5167
|
// canonical_probe`) — it is persisted on the lease as `error` — instead of only the state.
|
|
5163
5168
|
let why = "";
|
|
5169
|
+
// BOT-3238: a rolled-back provision also gets a typed code, its reap_reason and
|
|
5170
|
+
// whose failure it was (the caller's schema vs the platform) from the same read.
|
|
5171
|
+
let provisionFailure = null;
|
|
5164
5172
|
if (active?.failed) {
|
|
5165
5173
|
const read = await readLeaseQuietly(leaseId);
|
|
5166
5174
|
if (read?.ok && read.data?.success && typeof read.data.error === "string" && read.data.error) why = ` — ${read.data.error}`;
|
|
5175
|
+
if (read?.ok && read.data?.success) provisionFailure = provisionFailureFields(read.data);
|
|
5176
|
+
}
|
|
5177
|
+
if (provisionFailure) {
|
|
5178
|
+
try { stderrLine(provisionFailureLine(leaseId, provisionFailure, placement?.hostKey ?? null)); } catch { /* the receipt still carries it */ }
|
|
5167
5179
|
}
|
|
5168
5180
|
const cleanup = await requestCleanup();
|
|
5169
5181
|
return {
|
|
5170
5182
|
exitCode: cleanup?.ok === false ? EXIT.CLEANUP_FAILED : (active?.auth ? EXIT.AUTH : EXIT.LEASE_FAILED),
|
|
5171
5183
|
outcome: "error", leaseId, state: active?.state ?? null, error: active?.error || `lease ${active?.state ?? "failed"} before reaching active${why}`, cleanup,
|
|
5184
|
+
...(provisionFailure ? { code: provisionFailure.code, reapReason: provisionFailure.reapReason, provisionFailure } : {}),
|
|
5172
5185
|
...(parkIncident ? { incident: parkIncident } : {}),
|
|
5173
5186
|
};
|
|
5174
5187
|
}
|
|
@@ -5551,6 +5564,12 @@ export function runReceiptFields(result) {
|
|
|
5551
5564
|
...(result.parkReason ? { park_reason: result.parkReason } : {}),
|
|
5552
5565
|
// BOT-3094: why a queued lease was lost, and the lease a session re-request replaced.
|
|
5553
5566
|
...(result.reapReason ? { reap_reason: result.reapReason } : {}),
|
|
5567
|
+
// BOT-3238: whose fault a rolled-back provision was, and the host's bounded detail.
|
|
5568
|
+
...(result.provisionFailure ? {
|
|
5569
|
+
failure_kind: result.provisionFailure.failureKind,
|
|
5570
|
+
...(result.provisionFailure.detail ? { provision_failure: result.provisionFailure.detail } : {}),
|
|
5571
|
+
...(result.provisionFailure.reasonUnavailable ? { reason_unavailable: true } : {}),
|
|
5572
|
+
} : {}),
|
|
5554
5573
|
...(result.requeuedFrom ? { requeued_from: result.requeuedFrom } : {}),
|
|
5555
5574
|
// BOT-2142: where the lease ran and how the child reached it.
|
|
5556
5575
|
execution_mode: result.execution?.mode ?? null,
|