@botbuddy/cli 1.101.0 → 1.103.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 +5 -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/release-notes.mjs +17 -6
- package/src/requester-network.mjs +14 -5
- package/src/stack-native-callback.mjs +28 -11
- package/src/stack-run-outcome.mjs +1 -1
- package/src/stack.mjs +57 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.102.0
|
|
4
|
+
|
|
5
|
+
- BOT-3369: a `bb stack run` whose control plane cannot be read (a status deadline, a transport error or a 5xx) no longer stops its child. The run goes degraded, keeps the child running on the last positive answer, backs off its status reads with jitter, and records `callback_outage.degraded_ms` / `grace_ms` on the receipt. The grace is the tenant's `stack_degraded_grace_secs` (10 min by default), at most two thirds of the lease's idle TTL and never under 180 s. A run that stays unreadable for the whole grace stops with `CONTROL_PLANE_UNREACHABLE` (exit 6); the heartbeat follows the same grace. A refused (fenced, revoked or reaping) lease still stops at once as `CALLBACK_AUTHORIZATION_LOST`.
|
|
6
|
+
|
|
3
7
|
## 1.100.0
|
|
4
8
|
|
|
5
9
|
- BOT-3396: a repo that commits `.botbuddy/child-layer.json` gets a dependency layer for its host test children. The manifest names `inputs` (files or `dir/*` patterns from the head), `build` (argv commands), `outputs` (workspace directories), optional `scratch` (per-run writable directories inside an output) and optional `env` (variables that point at a path inside an output). The host daemon keys the layer by the sha256 of the manifest, every matched input, the repo's toolchain digest and the host architecture; builds it once per tenant and digest in a sandboxed unit (DynamicUser, `ProtectSystem=strict`, the tenant's toolchain on `PATH`) into `/var/lib/private/bb-deplayer/<tenant>/<digest>`; and binds each output read-only into the child at the same workspace path, so relative links resolve into the child's own source. A write into an output fails (`EROFS`); each `scratch` path is a fresh per-run tmpfs. A repeat run on the same digest starts no build unit. The terminal report's `child_resources.preparation` carries the preparation seconds, `toolchain` (`none`, `reused`, `installed`) and `dependency_layer` (`digest`, `state` built or reused, `seconds`, `size_bytes`). Hosts report the `child-layer` capability and `dependency_layers` (count, bytes, in use, evicted; no tenant detail); `bb stack run --test-child` requires `child-layer` when the head commits the manifest. Failures end the run before any child starts: `CHILD_LAYER_MANIFEST_INVALID`, `CHILD_LAYER_BUILD_FAILED` (naming the failing step, with the log tail), `CHILD_LAYER_BUILD_TIMEOUT`, `CHILD_LAYER_QUOTA_EXCEEDED`, `CHILD_LAYER_DISK_FLOOR`, `CHILD_LAYER_UNAVAILABLE`. Each tenant may hold 24 GiB of layers per host; one held by a running child is never removed, and one unused for 14 days is.
|
|
10
|
+
|
|
6
11
|
## 1.99.0
|
|
7
12
|
|
|
8
13
|
- BOT-3408: `bb daemon upgrade` takes `"testChild":{"enabled":true}` (optionally `"maxRuns":1..4`) to switch test children on for a handover-pinned host, and `"testChild":{"enabled":false}` to switch them off. The host's daemon changes only the `test_child` member of its `daemon.json`, after the server has fenced the plan that pins the amended digest, and the ordinary handover re-pins it; nobody edits the file by hand. Switching off removes the member and restores the earlier bytes, so the digest is the earlier pin again. The block carries no runtime path and no tool version. Enabling is refused when the running daemon is older than 1.90.0 (`daemon_test_child_previous_daemon_too_old`). On a host with automatic updates, add `"refreshAutomaticBinding":true` to re-install the updater binding against the new digest in the same command (`daemon_test_child_automatic_binding_refresh_required` without it). `"preview":true` reports both digests and changes nothing. A refused submission puts the earlier bytes back; other refusals are `daemon_test_child_amend_refused: <CODE>` (for example `TEST_CHILD_COORDINATOR_TOO_OLD` when the host's installed updater coordinator predates 1.90.0: run `bb daemon updater-install` first).
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.103.0",
|
|
3
|
+
"source_commit": "b128d7aba280f74dac8bf98419e16d0c57acb442",
|
|
4
|
+
"source_sha256": "5c94b86ddcee3718e16a7b93533fb30be5567a029264d27fb9a2825fe4c5b2ab",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "d6e34d2cae784fd188320dfc25d0f3700627d8f9666571deee5b1ee55950bb15"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.103.0",
|
|
3
|
+
"source_commit": "b128d7aba280f74dac8bf98419e16d0c57acb442",
|
|
4
|
+
"source_sha256": "5c94b86ddcee3718e16a7b93533fb30be5567a029264d27fb9a2825fe4c5b2ab",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "81c5e1a2754c7b5398c451d5acef5976018198bc38a4ab2acd4c229b9f1a5506"
|
|
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.103.0",
|
|
4
|
+
"source_commit": "b128d7aba280f74dac8bf98419e16d0c57acb442",
|
|
5
|
+
"source_sha256": "5c94b86ddcee3718e16a7b93533fb30be5567a029264d27fb9a2825fe4c5b2ab",
|
|
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": "d6e34d2cae784fd188320dfc25d0f3700627d8f9666571deee5b1ee55950bb15",
|
|
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": "81c5e1a2754c7b5398c451d5acef5976018198bc38a4ab2acd4c229b9f1a5506",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
package/src/release-notes.mjs
CHANGED
|
@@ -13,7 +13,8 @@ export const RELEASE_NOTES_USAGE = `Usage: bb release-notes submit <note.json> [
|
|
|
13
13
|
bb release-notes withdraw <source_key> [--tenant <slug>] [--json]
|
|
14
14
|
bb release-notes list [--tag <group>=<value>]... [--type <type>] [--state <state>] [--cursor <cursor>] [--json]
|
|
15
15
|
bb release-notes get <source_key> [--json]
|
|
16
|
-
bb release-notes digest --release <version|run-id> --voice internal|external [--environment production|staging] [--format markdown|json|slack] [--repository owner/name] [--json]
|
|
16
|
+
bb release-notes digest --release <version|run-id> --voice internal|external [--environment production|staging] [--format markdown|json|slack|discord|github-release] [--repository owner/name] [--json]
|
|
17
|
+
bb release-notes digest --candidate <sha> --repository owner/name --voice internal [--format …] [--json]
|
|
17
18
|
bb release-notes pack --release <version> [--format md] [--customer <name>] [--repository owner/name] [--out <file>] [--json]
|
|
18
19
|
bb release-notes grants list [--tenant <slug>] [--json]
|
|
19
20
|
bb release-notes grants add <email> <submit|manage> [--tenant <slug>] [--json]
|
|
@@ -109,18 +110,27 @@ view --show shows the tag and its filter, --tag-only the tag, --hide neither.
|
|
|
109
110
|
Digest (BOT-3204). digest prints one production release's notes, exactly as
|
|
110
111
|
the API returns them (byte for byte when piped; on a terminal, control
|
|
111
112
|
characters print as visible escapes): markdown, json (the bbrn-digest-1
|
|
112
|
-
schema)
|
|
113
|
-
your own incoming webhook; BotBuddy posts nothing)
|
|
113
|
+
schema), slack ({"messages": [...]}: each message is a Block Kit payload for
|
|
114
|
+
your own incoming webhook; BotBuddy posts nothing), discord (one embed field
|
|
115
|
+
value, at most 1,024 characters) or github-release (a GitHub release body under
|
|
116
|
+
6,000 characters, with no heading). discord and github-release need voice
|
|
117
|
+
internal. Every internal format links to the release's notes in BotBuddy, and
|
|
118
|
+
every format is rendered by the same renderer, so a PR line reads the same in
|
|
119
|
+
all of them. voice internal is your
|
|
114
120
|
team's wording with source keys and pull requests; voice external holds only
|
|
115
121
|
published external wording and never falls back to internal text. A release
|
|
116
122
|
with no notes prints an explicit empty digest. The internal voice also lists
|
|
117
123
|
every merged pull request in the release (BOT-3342), noted or not, with its
|
|
118
124
|
tickets, project and % complete and agent. --environment staging names a
|
|
119
125
|
staging deployment by its workflow run id or commit SHA (default production).
|
|
126
|
+
--candidate <sha> (with --repository) reads a production candidate: from the
|
|
127
|
+
last production release BotBuddy recorded for that repository to the commit.
|
|
120
128
|
--json prints the whole answer (tenant, version, note_count, pr_count,
|
|
121
129
|
content_type, body). Refusals: release_unknown,
|
|
122
130
|
repository_required, release_not_shipped, no_previous_release,
|
|
123
|
-
release_range_unavailable,
|
|
131
|
+
release_range_unavailable, candidate_base_unknown (no production release is
|
|
132
|
+
recorded, so nothing is guessed), candidate_not_descendant,
|
|
133
|
+
release_notes_url_unavailable, entitlement_missing, scope_missing.
|
|
124
134
|
|
|
125
135
|
Pack (BOT-3261). pack prints the internal release pack for one production
|
|
126
136
|
release as Markdown: a cover section with counts and affected customers, release
|
|
@@ -557,7 +567,7 @@ async function cmdPublish(action, argv, { resolveAuth, call, log, errorLog }) {
|
|
|
557
567
|
// ── BOT-3204: bb release-notes digest ─────────────────────────────────
|
|
558
568
|
|
|
559
569
|
const DIGEST_TOOL = "get_release_note_digest";
|
|
560
|
-
const DIGEST_FLAGS = { "--release": "release", "--environment": "environment", "--voice": "voice", "--format": "format", "--repository": "repository" };
|
|
570
|
+
const DIGEST_FLAGS = { "--release": "release", "--candidate": "candidate", "--environment": "environment", "--voice": "voice", "--format": "format", "--repository": "repository" };
|
|
561
571
|
|
|
562
572
|
export async function cmdDigest(argv, { resolveAuth, call, log, errorLog, write, isTTY = false }) {
|
|
563
573
|
const json = argv.includes("--json");
|
|
@@ -574,7 +584,8 @@ export async function cmdDigest(argv, { resolveAuth, call, log, errorLog, write,
|
|
|
574
584
|
args[key] = v;
|
|
575
585
|
i++;
|
|
576
586
|
}
|
|
577
|
-
|
|
587
|
+
// BOT-3427: exactly one of a release and a candidate commit.
|
|
588
|
+
if (!args.voice || Boolean(args.release) === Boolean(args.candidate)) {
|
|
578
589
|
errorLog(RELEASE_NOTES_USAGE);
|
|
579
590
|
return 2;
|
|
580
591
|
}
|
|
@@ -19,17 +19,25 @@ import { execFile } from "node:child_process";
|
|
|
19
19
|
|
|
20
20
|
export const REQUESTER_NETWORK_LOST_CODE = "REQUESTER_NETWORK_LOST";
|
|
21
21
|
/** The terminal codes a requester's own network loss can produce (BOT-3109). */
|
|
22
|
-
|
|
22
|
+
// BOT-3369: CONTROL_PLANE_UNREACHABLE (a callback status unreadable for the whole degraded grace) too.
|
|
23
|
+
export const REQUESTER_NETWORK_CANDIDATE_CODES = Object.freeze(["TUNNEL_LOST", "CALLBACK_TRANSPORT_LOST", "LEASE_HEARTBEAT_UNANSWERED", "CONTROL_PLANE_UNREACHABLE"]);
|
|
23
24
|
/** `=off` disables the probe (the CLI test suites set it; nothing else should). */
|
|
24
25
|
export const REQUESTER_NETWORK_PROBE_ENV = "BOTBUDDY_REQUESTER_NETWORK_PROBE";
|
|
25
26
|
export const REQUESTER_NETWORK_SAMPLE_MS = 15_000;
|
|
26
|
-
/** The
|
|
27
|
+
/** The default lookback (the BOT-2957 180 s floor plus slack). A run with a longer degraded grace
|
|
28
|
+
* (BOT-3369) passes its own `lookbackMs` to classify(), since its loss began up to the grace before. */
|
|
27
29
|
export const REQUESTER_NETWORK_LOOKBACK_MS = 300_000;
|
|
28
30
|
/** Evidence just after the failure still counts (the sampler may see the outage a beat late). */
|
|
29
31
|
export const REQUESTER_NETWORK_FAILURE_SLACK_MS = 20_000;
|
|
30
32
|
const PROBE_TIMEOUT_MS = 3000;
|
|
31
33
|
const LOG_TIMEOUT_MS = 6000;
|
|
32
|
-
|
|
34
|
+
/** The longest degraded grace a tenant can set (BOT-3369; `tenants.stack_degraded_grace_secs` CHECK ≤ 3600). */
|
|
35
|
+
export const STACK_DEGRADED_GRACE_MAX_MS = 3_600_000;
|
|
36
|
+
/** Samples are kept by age, not count: the longest grace, its slack on both sides, and the cleanup
|
|
37
|
+
* between the failure and classify(). One older sample stays as the reference a change is read against. */
|
|
38
|
+
export const REQUESTER_NETWORK_RETAIN_MS = STACK_DEGRADED_GRACE_MAX_MS + 2 * REQUESTER_NETWORK_FAILURE_SLACK_MS + REQUESTER_NETWORK_LOOKBACK_MS;
|
|
39
|
+
// A hard ceiling so a tiny sampleMs can never grow the buffer without bound.
|
|
40
|
+
const MAX_SAMPLES = 4096;
|
|
33
41
|
|
|
34
42
|
const IFACE_RE = /^[A-Za-z0-9_.:@-]{1,32}$/;
|
|
35
43
|
|
|
@@ -250,6 +258,7 @@ export function createRequesterNetworkWatch({
|
|
|
250
258
|
} catch { sample.previousLost = null; }
|
|
251
259
|
}
|
|
252
260
|
samples.push(sample);
|
|
261
|
+
while (samples.length > 1 && samples[1].atMs < atMs - REQUESTER_NETWORK_RETAIN_MS) samples.shift();
|
|
253
262
|
if (samples.length > MAX_SAMPLES) samples.shift();
|
|
254
263
|
return sample;
|
|
255
264
|
};
|
|
@@ -268,13 +277,13 @@ export function createRequesterNetworkWatch({
|
|
|
268
277
|
timer = null;
|
|
269
278
|
if (!disabled) abortRequesterNetworkProbes();
|
|
270
279
|
},
|
|
271
|
-
async classify({ failedAtMs } = {}) {
|
|
280
|
+
async classify({ failedAtMs, lookbackMs: runLookbackMs } = {}) {
|
|
272
281
|
if (disabled || startedAtMs == null) return { decision: "undecided" };
|
|
273
282
|
try {
|
|
274
283
|
const nowMs = now();
|
|
275
284
|
// The failure, not this call (cleanup can take minutes): a change after it is not its cause.
|
|
276
285
|
const failAt = Number.isFinite(failedAtMs) ? Math.min(failedAtMs, nowMs) : nowMs;
|
|
277
|
-
const sinceMs = Math.max(startedAtMs, failAt - lookbackMs);
|
|
286
|
+
const sinceMs = Math.max(startedAtMs, failAt - Math.max(lookbackMs, Number.isFinite(runLookbackMs) ? runLookbackMs : 0));
|
|
278
287
|
const untilMs = failAt + REQUESTER_NETWORK_FAILURE_SLACK_MS;
|
|
279
288
|
const history = samples.slice();
|
|
280
289
|
const current = await take();
|
|
@@ -91,14 +91,21 @@ const REFUSAL_GRACE_MS=GENERATION_MS-REFUSAL_RETRY_MS-STATUS_DEADLINE_MS-RENEW_A
|
|
|
91
91
|
// also the longest a callback revoked during such an outage can keep running. The relay and the
|
|
92
92
|
// gateway keep their own 30 s generation, so a requester that dies still loses the route at once.
|
|
93
93
|
export const CALLBACK_STALE_PROOF_MAX_MS=180_000;
|
|
94
|
-
|
|
94
|
+
// BOT-3369: an unreadable status (deadline, transport, 5xx) is not a refusal. The route rides its last
|
|
95
|
+
// positive answer for a bounded degraded grace (default 10 min, per tenant, never past the lease TTL:
|
|
96
|
+
// stack.mjs computes it). CALLBACK_STALE_PROOF_MAX_MS stays the floor; past the grace it ends as
|
|
97
|
+
// CONTROL_PLANE_UNREACHABLE. Degraded status reads back off with jitter, so a recovering control plane
|
|
98
|
+
// is not stampeded by every degraded run at once.
|
|
99
|
+
export const CONTROL_PLANE_UNREACHABLE_CODE='CONTROL_PLANE_UNREACHABLE';
|
|
100
|
+
export const CALLBACK_READ_BACKOFF_MAX_MS=20_000;
|
|
101
|
+
export async function openNativeCallbackTransport({current,leaseId,hostKey,callbackPort,requesterMachineId,sshTarget,readCurrent,sshBin='ssh',env=process.env,run=execFile,spawnImpl=spawn,verifyRuntime=verifyInstalledCallbackRuntime,openGateway=openCallbackGateway,renewIntervalMs=RENEW_INTERVAL_MS,firstAckMs=FIRST_ACK_MS,renewAckMs=RENEW_ACK_MS,statusDeadlineMs=STATUS_DEADLINE_MS,refusalRetryMs=REFUSAL_RETRY_MS,refusalGraceMs=REFUSAL_GRACE_MS,staleProofMaxMs=CALLBACK_STALE_PROOF_MAX_MS,readBackoffMaxMs=CALLBACK_READ_BACKOFF_MAX_MS,random=Math.random,onOutage=()=>{}}){
|
|
95
102
|
if(typeof readCurrent!=='function')fail('CALLBACK_AUTHORIZATION_LOST','current callback status reader required');
|
|
96
103
|
const routeGeneration=randomUUID(),options={leaseId,hostKey,callbackPort,requesterMachineId,routeGeneration};
|
|
97
104
|
const binding=currentCallbackBinding(current,options),snapshot=JSON.stringify(binding),target=assertSshTarget(sshTarget),d=binding.descriptor;
|
|
98
105
|
await verifyRuntime({descriptor:d,sshTarget:target,sshBin,env,run});
|
|
99
106
|
const capability=randomBytes(32).toString('hex'),readinessNonce=randomBytes(16).toString('hex'),directory='/tmp/bb-callback-'+randomUUID(),socket=directory+'/callback.sock';
|
|
100
107
|
const sshArgs=['-T','-o','BatchMode=yes','-o','ControlMaster=no','-o','ControlPath=none','--',target];
|
|
101
|
-
let gateway,child,terminal,refreshTimer,retryTimer,staleTimer,statusAbort,pendingReady,pendingAck,closed=false,refreshing=false,cleanupPromise,exitResult;const exits=new Set();
|
|
108
|
+
let gateway,child,terminal,refreshTimer,retryTimer,readTimer,staleTimer,statusAbort,pendingReady,pendingAck,closed=false,refreshing=false,cleanupPromise,exitResult;const exits=new Set();
|
|
102
109
|
const reportExit=exit=>{exitResult=exit;for(const listener of exits)listener(exit)};
|
|
103
110
|
const remote=async command=>{try{return await run(sshBin,[...sshArgs,command],{env,timeout:15_000,maxBuffer:4096})}catch{fail('CALLBACK_REMOTE_OPERATION_FAILED','owned callback operation failed');}};
|
|
104
111
|
const retire=async()=>{
|
|
@@ -108,7 +115,7 @@ export async function openNativeCallbackTransport({current,leaseId,hostKey,callb
|
|
|
108
115
|
await remote(command);
|
|
109
116
|
};
|
|
110
117
|
const close=()=>cleanupPromise??=(async()=>{
|
|
111
|
-
closed=true;clearInterval(refreshTimer);clearTimeout(retryTimer);clearTimeout(staleTimer);statusAbort?.abort();pendingReady?.reject(Error('callback closed'));pendingAck?.reject(Error('callback closed'));await gateway?.close();
|
|
118
|
+
closed=true;clearInterval(refreshTimer);clearTimeout(retryTimer);clearTimeout(readTimer);clearTimeout(staleTimer);statusAbort?.abort();pendingReady?.reject(Error('callback closed'));pendingAck?.reject(Error('callback closed'));await gateway?.close();
|
|
112
119
|
if(child){child.stdin.end();const term=setTimeout(()=>child.kill('SIGTERM'),3000);const kill=setTimeout(()=>child.kill('SIGKILL'),6000);term.unref();kill.unref();try{await terminal}finally{clearTimeout(term);clearTimeout(kill)}}
|
|
113
120
|
try{await retire()}catch{fail('CALLBACK_CLEANUP_UNCERTAIN','owned callback cleanup could not be verified');}
|
|
114
121
|
})();
|
|
@@ -137,30 +144,40 @@ export async function openNativeCallbackTransport({current,leaseId,hostKey,callb
|
|
|
137
144
|
});
|
|
138
145
|
const callbackUrl=callbackReadiness(ready,callbackPort);
|
|
139
146
|
let renewedAt=null,refusal=null,provenAt=null,provenWall=null,lastReadFailure=null;
|
|
140
|
-
const outage={episodes:0,failed_reads:0,longest_ms:0,last_failure:null,recovered:0};let outageActive=false;
|
|
147
|
+
const outage={episodes:0,failed_reads:0,longest_ms:0,degraded_ms:0,grace_ms:staleProofMaxMs,last_failure:null,recovered:0};let outageActive=false,degradedClosedMs=0,readBackoffMs=0,nextReadAt=0;
|
|
141
148
|
// BOT-2957: both clocks, because a sleeping requester stops one of them on some platforms.
|
|
142
149
|
const staleFor=()=>provenAt===null?Infinity:Math.max(performance.now()-provenAt,Date.now()-provenWall);
|
|
143
|
-
|
|
150
|
+
// BOT-3369: degraded_ms is the whole time this run rode on stale proof, across every episode.
|
|
151
|
+
const noteOutage=(active,gapMs=staleFor())=>{const gap=Math.round(gapMs);outage.longest_ms=Math.max(outage.longest_ms,gap);if(active&&!outageActive)outage.episodes++;else if(!active&&outageActive){outage.recovered++;degradedClosedMs+=gap;}outage.degraded_ms=degradedClosedMs+(active?gap:0);outageActive=active;onOutage({...outage});};
|
|
152
|
+
// Equal jitter: half the backoff fixed, half random, doubling to readBackoffMaxMs.
|
|
153
|
+
// The read fires at its own jittered deadline, not the next renewal tick, which would round the jitter away.
|
|
154
|
+
const backOffReads=()=>{readBackoffMs=Math.min(readBackoffMaxMs,Math.max(renewIntervalMs,readBackoffMs*2));const delayMs=readBackoffMs/2+random()*readBackoffMs/2;nextReadAt=performance.now()+delayMs;clearTimeout(readTimer);armRead(delayMs);};
|
|
155
|
+
// The read timer is the read: it skips the renewal-only backoff guard, so a timer Node fires a moment
|
|
156
|
+
// before its deadline still reads, and one that lands during a renewal waits for that renewal to end.
|
|
157
|
+
const armRead=delayMs=>{clearTimeout(readTimer);readTimer=setTimeout(()=>{void refresh(false,true)},delayMs);readTimer.unref();};
|
|
144
158
|
// Ends the route without a positive answer. A pending refusal keeps its own name.
|
|
145
159
|
const stopUnproven=()=>{
|
|
146
160
|
if(closed)return;
|
|
147
|
-
const lost=refusal?{code:refusal.code??'CALLBACK_AUTHORIZATION_LOST',authorization_reason:boundedAuthorizationReason(refusal.authorizationReason)??'refused'}:{
|
|
148
|
-
if(outageActive)noteOutage(true);reportExit(
|
|
161
|
+
const lost=refusal?{reason:'callback_authorization_lost',code:refusal.code??'CALLBACK_AUTHORIZATION_LOST',authorization_reason:boundedAuthorizationReason(refusal.authorizationReason)??'refused'}:{reason:'control_plane_unreachable',code:CONTROL_PLANE_UNREACHABLE_CODE,read_failure:boundedAuthorizationReason('status_unreadable:'+(lastReadFailure??'no_answer'))??'status_unreadable'};
|
|
162
|
+
if(outageActive)noteOutage(true);reportExit(lost);void close().catch(()=>{});
|
|
149
163
|
};
|
|
150
164
|
const proven=(atMonotonic,atWall)=>{provenAt=atMonotonic;provenWall=atWall;refusal=null;clearTimeout(staleTimer);staleTimer=setTimeout(stopUnproven,Math.max(0,staleProofMaxMs-(performance.now()-atMonotonic)));staleTimer.unref();};
|
|
151
165
|
const rereadSoon=()=>{clearTimeout(retryTimer);retryTimer=setTimeout(()=>{void refresh()},refusalRetryMs);retryTimer.unref();};
|
|
152
166
|
gateway.onClose(()=>{if(closed)return;if(staleFor()>=staleProofMaxMs){stopUnproven();return;}reportExit({reason:'callback_gateway_closed',code:'CALLBACK_GATEWAY_EXPIRED'});void close().catch(()=>{})});
|
|
153
|
-
const refresh=async(first=false)=>{
|
|
154
|
-
if(closed
|
|
167
|
+
const refresh=async(first=false,readDue=false)=>{
|
|
168
|
+
if(closed)return;if(refreshing){if(readDue)armRead(5);return;}refreshing=true;clearTimeout(retryTimer);
|
|
155
169
|
// BOT-2957: every failure below names the step it failed in.
|
|
156
170
|
let step='status_read';
|
|
157
171
|
try{
|
|
158
172
|
statusAbort=new AbortController();let statusTimeout,renewed=binding;const readAt=performance.now(),readWall=Date.now();
|
|
159
173
|
try{
|
|
174
|
+
// BOT-3369: while degraded, a renewal between backed-off reads rides the last positive answer. In the
|
|
175
|
+
// grace's last backoff window every renewal reads again, so a late refusal keeps its own name.
|
|
176
|
+
if(!first&&!readDue&&outageActive&&!refusal&&performance.now()<nextReadAt&&staleFor()+readBackoffMs<staleProofMaxMs)throw Object.assign(Error('callback status read backed off'),{transient:true,readFailure:lastReadFailure??'no_answer',backedOff:true});
|
|
160
177
|
const status=await new Promise((resolve,reject)=>{statusTimeout=setTimeout(()=>{statusAbort.abort();reject(Object.assign(Error('callback status deadline'),{transient:true,readFailure:'deadline'}));},statusDeadlineMs);statusTimeout.unref();Promise.resolve().then(()=>readCurrent(statusAbort.signal)).then(resolve,reject).finally(()=>clearTimeout(statusTimeout));});
|
|
161
178
|
if(closed)return;step='status_answer';renewed=currentCallbackBinding(status,options);
|
|
162
179
|
if(JSON.stringify(renewed)!==snapshot)refuse(tokenReason('binding_changed',changedBindingField(binding,renewed)),'callback context changed');
|
|
163
|
-
if(outageActive)noteOutage(false);proven(readAt,readWall);lastReadFailure=null;
|
|
180
|
+
if(outageActive)noteOutage(false);proven(readAt,readWall);lastReadFailure=null;readBackoffMs=0;nextReadAt=0;clearTimeout(readTimer);
|
|
164
181
|
}catch(error){
|
|
165
182
|
// The opening renewal never rides on anything: it needs a fresh positive answer.
|
|
166
183
|
if(first){if(error?.transient===true&&!error.authorizationReason)error.authorizationReason=boundedAuthorizationReason('status_unreadable:'+(error.readFailure??'no_answer'))??'status_unreadable';throw error;}
|
|
@@ -171,7 +188,7 @@ export async function openNativeCallbackTransport({current,leaseId,hostKey,callb
|
|
|
171
188
|
// BOT-2957: an unanswered read is not an authorization answer. Renew on the last positive
|
|
172
189
|
// answer, only until the bound since that read, and never on any read after a refusal.
|
|
173
190
|
if(staleFor()>=staleProofMaxMs){stopUnproven();return;}
|
|
174
|
-
outage.failed_reads++;outage.last_failure=lastReadFailure;noteOutage(true);
|
|
191
|
+
if(!error.backedOff){outage.failed_reads++;outage.last_failure=lastReadFailure;backOffReads();}noteOutage(true);
|
|
175
192
|
}else{
|
|
176
193
|
// BOT-2880: a definitive answer stops the child only if one re-read repeats it, while the live
|
|
177
194
|
// generation can still carry that re-read. An expired grace fails closed.
|
|
@@ -29,7 +29,7 @@ export const STACK_RUN_OUTCOME_OPT_OUT_ENV = "BOTBUDDY_STACK_RUN_OUTCOME";
|
|
|
29
29
|
export const STACK_RUN_OUTCOME_CATEGORIES = Object.freeze(["platform", "script", "interrupted", "invocation", "released", "requester"]);
|
|
30
30
|
/** BOT-3109: the only code the `requester` category carries, and the codes it can replace. */
|
|
31
31
|
export const REQUESTER_CATEGORY_CODE = "REQUESTER_NETWORK_LOST";
|
|
32
|
-
const REQUESTER_UNDERLYING_CODES = new Set(["TUNNEL_LOST", "CALLBACK_TRANSPORT_LOST", "LEASE_HEARTBEAT_UNANSWERED"]);
|
|
32
|
+
const REQUESTER_UNDERLYING_CODES = new Set(["TUNNEL_LOST", "CALLBACK_TRANSPORT_LOST", "LEASE_HEARTBEAT_UNANSWERED", "CONTROL_PLANE_UNREACHABLE"]);
|
|
33
33
|
/**
|
|
34
34
|
* BOT-2881: a signal carries no sender, so a hold's owner says so first. The hold sets this to an
|
|
35
35
|
* absolute path when it starts `bb stack run`, and its stop command creates that file before
|
package/src/stack.mjs
CHANGED
|
@@ -54,13 +54,13 @@ import { checkReadoptedStackMounts } from "./stack-mount-health.mjs";
|
|
|
54
54
|
import { machineUuid } from "./machine-id.mjs";
|
|
55
55
|
import { DEFAULT_BUNDLE_MAX_BYTES, OPTIONAL_SUPABASE_SERVICES, STACK_SERVICES_OPT_IN_PATH, buildStackBundle, stackServicesOptInBody, uploadStackBundle, validateBundleIncludePath, validateSupabaseServiceName } from "./stack-bundle.mjs";
|
|
56
56
|
import { assertSshTarget, establishSshTunnel } from "./stack-tunnel.mjs";
|
|
57
|
-
import { CALLBACK_STALE_PROOF_MAX_MS, NATIVE_CALLBACK_TRANSPORT, boundedAuthorizationReason, openNativeCallbackTransport } from "./stack-native-callback.mjs";
|
|
57
|
+
import { CALLBACK_STALE_PROOF_MAX_MS, CONTROL_PLANE_UNREACHABLE_CODE, NATIVE_CALLBACK_TRANSPORT, boundedAuthorizationReason, openNativeCallbackTransport } from "./stack-native-callback.mjs";
|
|
58
58
|
import { FORWARD_ATTESTATION_ENV, startForwardAttestation, readForwardAttestation } from "./stack-forward-attestation.mjs";
|
|
59
59
|
import { stackServicesForForwards } from "./stack-service-discovery.mjs";
|
|
60
60
|
import { ENGINE_PUBLISHES_BEYOND_LOOPBACK, engineSocketIsLocal, formatPublishIp, isLoopbackIp, publishIpFix, resolvePublishIp } from "./docker-publish-ip.mjs";
|
|
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
|
-
import { REQUESTER_NETWORK_CANDIDATE_CODES, REQUESTER_NETWORK_LOST_CODE, createRequesterNetworkWatch, requesterNetworkLostMessage } from "./requester-network.mjs";
|
|
63
|
+
import { REQUESTER_NETWORK_CANDIDATE_CODES, REQUESTER_NETWORK_FAILURE_SLACK_MS, REQUESTER_NETWORK_LOOKBACK_MS, REQUESTER_NETWORK_LOST_CODE, STACK_DEGRADED_GRACE_MAX_MS, createRequesterNetworkWatch, requesterNetworkLostMessage } from "./requester-network.mjs";
|
|
64
64
|
import { provisionFailureFields, provisionFailureLine } from "./stack-provision-failure.mjs";
|
|
65
65
|
import { hostChildApi, hostChildReceiptFields, startHostChild, childEnvFrom, 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";
|
|
@@ -469,12 +469,18 @@ ${bold("REMOTE LEASES")} (BOT-2142, stack run)
|
|
|
469
469
|
callback_authorization_reason names the refused check, e.g. requester_host_disabled
|
|
470
470
|
(the requester machine's own Docker host was set to disabled: use maintenance),
|
|
471
471
|
lease_state:reaping, binding_changed:descriptor.producer_pid.
|
|
472
|
-
A control plane that does not answer is not a refusal (BOT-2957): the
|
|
473
|
-
|
|
474
|
-
|
|
472
|
+
A control plane that does not answer is not a refusal (BOT-2957, BOT-3369): the
|
|
473
|
+
run goes degraded and the child keeps running on the last positive answer for
|
|
474
|
+
the degraded grace — the tenant's callback_degraded_grace_secs (default 600 s),
|
|
475
|
+
at most 2/3 of the lease TTL, never under 180 s. Status reads back off with
|
|
476
|
+
jitter meanwhile. A refusal answered mid-grace still stops at once.
|
|
477
|
+
callback_outage on the receipt counts the gaps a run rode through
|
|
478
|
+
(episodes, longest_ms, degraded_ms, grace_ms).
|
|
479
|
+
6 CONTROL_PLANE_UNREACHABLE the callback status stayed unreadable for the whole degraded grace;
|
|
480
|
+
child stopped, lease reaped. control_plane_read_failure names the read, e.g.
|
|
475
481
|
status_unreadable:deadline, status_unreadable:http_503, status_unreadable:rpc_error.
|
|
476
|
-
|
|
477
|
-
|
|
482
|
+
6 LEASE_HEARTBEAT_UNANSWERED every heartbeat touch went unanswered for the degraded grace; child
|
|
483
|
+
stopped, lease reaped
|
|
478
484
|
5 CALLBACK_PORT_BUSY --callback-port is already listening on the serving host (another run or
|
|
479
485
|
service), the host refused this run's -R because another run took the
|
|
480
486
|
port first, or another listener shares the port; this run holds no -R —
|
|
@@ -486,7 +492,7 @@ ${bold("REMOTE LEASES")} (BOT-2142, stack run)
|
|
|
486
492
|
(BUNDLE_UNSAFE_LINK: it resolves outside the stack); no lease is created
|
|
487
493
|
6 TUNNEL_LOST the forward exited mid-child: the child is stopped, the lease released,
|
|
488
494
|
park_reason tunnel_lost (its failures were transport, not product)
|
|
489
|
-
6 REQUESTER_NETWORK_LOST one of TUNNEL_LOST, CALLBACK_TRANSPORT_LOST or
|
|
495
|
+
6 REQUESTER_NETWORK_LOST one of TUNNEL_LOST, CALLBACK_TRANSPORT_LOST, LEASE_HEARTBEAT_UNANSWERED or CONTROL_PLANE_UNREACHABLE,
|
|
490
496
|
while THIS machine's own network changed (macOS: primary interface or IPv4,
|
|
491
497
|
or configd saw it detach; Linux: default route). underlying_code keeps the
|
|
492
498
|
original code, requester_network {lost_at, evidence} says when; recorded as
|
|
@@ -512,6 +518,17 @@ const STACK_COMMANDS = new Set(["up", "run", "status", "touch", "done", "cancel"
|
|
|
512
518
|
export const STACK_HEARTBEAT_UNANSWERED_CODE = "LEASE_HEARTBEAT_UNANSWERED";
|
|
513
519
|
const HEARTBEAT_RETRY_MS = 15_000;
|
|
514
520
|
const HEARTBEAT_TOUCH_DEADLINE_MS = 15_000;
|
|
521
|
+
// BOT-3369: how long a run rides an unreadable control plane (callback status reads and heartbeat
|
|
522
|
+
// touches) before it stops with CONTROL_PLANE_UNREACHABLE. The tenant sets it
|
|
523
|
+
// (get_stack_lease.callback_degraded_grace_secs); it never outlasts the lease's server-side TTL
|
|
524
|
+
// (idle TTL less one heartbeat cadence, since the last answered touch was at most one cadence before
|
|
525
|
+
// the outage), and never drops below the BOT-2957 floor of 180 s (a grace of 0 is that behaviour).
|
|
526
|
+
export const STACK_DEGRADED_GRACE_DEFAULT_SECS = 600;
|
|
527
|
+
export function stackDegradedGraceMs({ graceSecs, idleTtlSecs } = {}) {
|
|
528
|
+
const tenantMs = Math.min(STACK_DEGRADED_GRACE_MAX_MS, (Number.isSafeInteger(graceSecs) && graceSecs >= 0 ? graceSecs : STACK_DEGRADED_GRACE_DEFAULT_SECS) * 1000);
|
|
529
|
+
const ttlMs = Number.isFinite(idleTtlSecs) && idleTtlSecs > 0 ? Math.floor(idleTtlSecs * 1000 * 2 / 3) : Infinity;
|
|
530
|
+
return Math.max(CALLBACK_STALE_PROOF_MAX_MS, Math.min(tenantMs, ttlMs));
|
|
531
|
+
}
|
|
515
532
|
|
|
516
533
|
/** Scoped help is assembled from the canonical text, so flags cannot drift. */
|
|
517
534
|
export function stackCommandHelp(command) {
|
|
@@ -4200,7 +4217,9 @@ async function runStackLifecycleWatched(opts, childArgv, adapters, firstBox, fre
|
|
|
4200
4217
|
const withWebUrl = incidentBox.webUrl && withPortBlock && !withPortBlock.webUrl ? { ...withPortBlock, webUrl: incidentBox.webUrl } : withPortBlock;
|
|
4201
4218
|
const withStopSignal = incidentBox.stopSignal && withWebUrl ? { ...withWebUrl, stopSignal: incidentBox.stopSignal } : withWebUrl;
|
|
4202
4219
|
const withOutage = incidentBox.callbackOutage && withStopSignal ? { ...withStopSignal, callbackOutage: incidentBox.callbackOutage } : withStopSignal;
|
|
4203
|
-
|
|
4220
|
+
// BOT-3369: not a receipt field; it sizes the requester-network lookback to this run's grace.
|
|
4221
|
+
const withGrace = incidentBox.degradedGraceMs && withOutage && typeof withOutage === "object" ? { ...withOutage, degradedGraceMs: incidentBox.degradedGraceMs } : withOutage;
|
|
4222
|
+
const final = await applyRequesterNetworkLoss(withGrace, networkWatch, { failedAtMs: incidentBox.lossAtMs });
|
|
4204
4223
|
// BOT-2467: non-enumerable, so the receipt fields and result comparisons never see it.
|
|
4205
4224
|
if (final && typeof final === "object" && incidentBox.outcomeChannel) {
|
|
4206
4225
|
Object.defineProperty(final, OUTCOME_CHANNEL, { value: incidentBox.outcomeChannel, enumerable: false });
|
|
@@ -4223,7 +4242,12 @@ export async function applyRequesterNetworkLoss(result, watch, { failedAtMs = nu
|
|
|
4223
4242
|
if (result.cleanup?.ok === false || result.exitCode === EXIT.CLEANUP_FAILED || result.callbackCleanupUncertain === true) return result;
|
|
4224
4243
|
let network;
|
|
4225
4244
|
try {
|
|
4226
|
-
|
|
4245
|
+
// BOT-3369: a loss that ended a run only after waiting out its degraded grace began up to that
|
|
4246
|
+
// grace before. An immediate transport loss (TUNNEL_LOST, CALLBACK_TRANSPORT_LOST) waited for
|
|
4247
|
+
// nothing, so it keeps the BOT-3109 window and an old network change cannot claim it.
|
|
4248
|
+
const waitedOutGrace = result.code === CONTROL_PLANE_UNREACHABLE_CODE || result.code === "LEASE_HEARTBEAT_UNANSWERED";
|
|
4249
|
+
const lookbackMs = Math.max(REQUESTER_NETWORK_LOOKBACK_MS, waitedOutGrace && Number.isFinite(result.degradedGraceMs) ? result.degradedGraceMs + 2 * REQUESTER_NETWORK_FAILURE_SLACK_MS : 0);
|
|
4250
|
+
network = await watch.classify({ failedAtMs, lookbackMs });
|
|
4227
4251
|
} catch {
|
|
4228
4252
|
return result;
|
|
4229
4253
|
}
|
|
@@ -5443,6 +5467,9 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5443
5467
|
stderrLine(`stack: lease ${leaseId} moved to ${placement.hostKey ?? "another host"} while queued (${placement.placementReason ?? "moved"}) — forwarding to it`);
|
|
5444
5468
|
}
|
|
5445
5469
|
let childConnection = current.data.connection;
|
|
5470
|
+
// BOT-3369: one grace for the callback route and the heartbeat, read from the lease's current answer.
|
|
5471
|
+
const degradedGraceMs = stackDegradedGraceMs({ graceSecs: current.data.callback_degraded_grace_secs, idleTtlSecs: current.data.idle_ttl_secs ?? opts.idleTtl ?? 1800 });
|
|
5472
|
+
incidentBox.degradedGraceMs = degradedGraceMs;
|
|
5446
5473
|
// BOT-3371: what the stack runs, as its host reported it (a daemon-started stack only).
|
|
5447
5474
|
if (Array.isArray(current.data.connection.supabase_services)) placement.supabaseServices = current.data.connection.supabase_services;
|
|
5448
5475
|
// BOT-2775: a callback_policy auto lease serves its callback natively whenever it is remote,
|
|
@@ -5468,12 +5495,13 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5468
5495
|
if (useNativeCallback) {
|
|
5469
5496
|
try {
|
|
5470
5497
|
nativeCallback = await openCallback({ current: current.data, leaseId, hostKey: placement.hostKey, callbackPort: opts.callbackPort, requesterMachineId: machineUuidFn(), sshTarget,
|
|
5498
|
+
staleProofMaxMs: degradedGraceMs,
|
|
5471
5499
|
readCurrent: (signal) => readCallbackStatus(api, leaseId, signal),
|
|
5472
5500
|
onOutage: (outage) => {
|
|
5473
5501
|
const previous = incidentBox.callbackOutage;
|
|
5474
5502
|
incidentBox.callbackOutage = outage;
|
|
5475
|
-
if (outage.episodes > (previous?.episodes ?? 0)) stderrLine(`stack: the control plane is not answering (${outage.last_failure}); the
|
|
5476
|
-
if (outage.recovered > (previous?.recovered ?? 0)) stderrLine(
|
|
5503
|
+
if (outage.episodes > (previous?.episodes ?? 0)) stderrLine(`stack: degraded — the control plane is not answering (${outage.last_failure}); the child keeps running on the last positive answer for up to ${Math.round(degradedGraceMs / 1000)} s`);
|
|
5504
|
+
if (outage.recovered > (previous?.recovered ?? 0)) stderrLine(`stack: recovered — the control plane answered again after ${Math.round(outage.longest_ms / 1000)} s; the child kept running`);
|
|
5477
5505
|
},
|
|
5478
5506
|
});
|
|
5479
5507
|
nativeCallback.onExit((exit) => { if (childResult) return; incidentBox.lossAtMs ??= Date.now(); callbackLost = exit; fencing = true; stopChild("SIGTERM", EXIT.LEASE_FAILED); });
|
|
@@ -5729,7 +5757,9 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5729
5757
|
testChildRenew?.unref?.();
|
|
5730
5758
|
}
|
|
5731
5759
|
leaseIdleTtlSecs = current.data.idle_ttl_secs ?? opts.idleTtl ?? 1800;
|
|
5732
|
-
|
|
5760
|
+
// BOT-3369 review: the heartbeat's grace runs from the last confirmed touch, so the cadence must fit
|
|
5761
|
+
// well inside it too: a touch missed at the next cadence still has two thirds of the grace to retry.
|
|
5762
|
+
const cadenceMs = Math.max(1_000, Math.floor(Math.min(leaseIdleTtlSecs * 1000, degradedGraceMs) / 3));
|
|
5733
5763
|
// BOT-1798 (Codex #928 R8 P2): the directory's retention tracks the LEASE's
|
|
5734
5764
|
// last activity, not its creation, so a batch that outlives the default window
|
|
5735
5765
|
// and then loses its owner process is never collected while it is still running.
|
|
@@ -5739,7 +5769,9 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5739
5769
|
const usageLease = { ...current.data, execution_mode: current.data.execution_mode ?? (servedRemote ? "remote" : "local") };
|
|
5740
5770
|
const heartbeatNow = adapters.now ?? Date.now;
|
|
5741
5771
|
let heartbeating = false;
|
|
5742
|
-
|
|
5772
|
+
// BOT-3369 review: the server keeps the run alive for its TTL after the last touch it confirmed,
|
|
5773
|
+
// so the heartbeat's grace runs from that touch (the run's start until one lands).
|
|
5774
|
+
let lastConfirmedTouchAt = heartbeatNow();
|
|
5743
5775
|
const touchLease = async () => {
|
|
5744
5776
|
if (fencing || childResult || heartbeating) return;
|
|
5745
5777
|
heartbeating = true;
|
|
@@ -5783,8 +5815,8 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5783
5815
|
// BOT-2957: an unanswered touch says nothing about the lease, and one of them used to
|
|
5784
5816
|
// stop a healthy child during a control-plane stall. Only a real answer fences at once.
|
|
5785
5817
|
if (unanswered) {
|
|
5786
|
-
|
|
5787
|
-
if (heartbeatNow() -
|
|
5818
|
+
// Retry only when that retry can conclude (its wait plus its own deadline) inside the grace.
|
|
5819
|
+
if (heartbeatNow() - lastConfirmedTouchAt + HEARTBEAT_RETRY_MS + HEARTBEAT_TOUCH_DEADLINE_MS <= degradedGraceMs) {
|
|
5788
5820
|
clock.clearTimeout(heartbeatRetry);
|
|
5789
5821
|
heartbeatRetry = clock.setTimeout(() => touchLease(), HEARTBEAT_RETRY_MS);
|
|
5790
5822
|
heartbeatRetry?.unref?.();
|
|
@@ -5796,7 +5828,7 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5796
5828
|
stopChild("SIGTERM", EXIT.LEASE_FAILED);
|
|
5797
5829
|
return;
|
|
5798
5830
|
}
|
|
5799
|
-
|
|
5831
|
+
lastConfirmedTouchAt = heartbeatNow();
|
|
5800
5832
|
clock.clearTimeout(heartbeatRetry);
|
|
5801
5833
|
heartbeatRetry = null;
|
|
5802
5834
|
keepAlive();
|
|
@@ -5843,6 +5875,12 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5843
5875
|
return { exitCode: cleanup.ok ? EXIT.LEASE_FAILED : EXIT.CLEANUP_FAILED, outcome: "failed", code: originLost.code, leaseId, childExitCode: childResult.code, cleanup, fenced: true,
|
|
5844
5876
|
error: "the requester origin closed while the child was running, so the child was stopped and the lease released" };
|
|
5845
5877
|
}
|
|
5878
|
+
if (callbackLost?.code === CONTROL_PLANE_UNREACHABLE_CODE && !receivedSignal) {
|
|
5879
|
+
// BOT-3369: the status stayed unreadable for the whole degraded grace. Not a refusal: named as an outage.
|
|
5880
|
+
const readFailure = boundedAuthorizationReason(callbackLost.read_failure) ?? "status_unreadable";
|
|
5881
|
+
return { exitCode: cleanup.ok && !callbackCleanupError ? EXIT.LEASE_FAILED : EXIT.CLEANUP_FAILED, outcome: "failed", code: CONTROL_PLANE_UNREACHABLE_CODE, callbackCause: "CALLBACK_STATUS_UNREADABLE", controlPlaneReadFailure: readFailure, leaseId, childExitCode: childResult.code, cleanup, fenced: true,
|
|
5882
|
+
error: `the control plane did not answer for the whole ${Math.round(degradedGraceMs / 1000)} s degraded grace (${readFailure}); child stopped and lease released` };
|
|
5883
|
+
}
|
|
5846
5884
|
if (callbackLost && !receivedSignal) {
|
|
5847
5885
|
// BOT-2828: the receipt names the hop and cause that closed the route, not only the class.
|
|
5848
5886
|
const callbackCause = callbackLost.code ?? (callbackLost.reason === "callback_authorization_lost" ? "CALLBACK_AUTHORIZATION_LOST" : "CALLBACK_RELAY_EXITED");
|
|
@@ -5997,6 +6035,8 @@ export function runReceiptFields(result) {
|
|
|
5997
6035
|
...(result.callbackCause ? { callback_cause: result.callbackCause } : {}),
|
|
5998
6036
|
// BOT-2880: which check refused a CALLBACK_AUTHORIZATION_LOST (a bounded token, never a value).
|
|
5999
6037
|
...(result.callbackAuthorizationReason ? { callback_authorization_reason: result.callbackAuthorizationReason } : {}),
|
|
6038
|
+
// BOT-3369: on a CONTROL_PLANE_UNREACHABLE run, the status read that kept failing (status_unreadable:<token>).
|
|
6039
|
+
...(result.controlPlaneReadFailure ? { control_plane_read_failure: result.controlPlaneReadFailure } : {}),
|
|
6000
6040
|
...(result.code === "REQUESTER_ORIGIN_DIGEST_UNAVAILABLE" && ["origin_config_missing", "origin_digest_missing"].includes(result.failureMechanism)
|
|
6001
6041
|
? { failure_mechanism: result.failureMechanism } : {}),
|
|
6002
6042
|
// BOT-2977: which fence refused a STALE_AGENT_CONTEXT run (session | agent).
|