@botbuddy/cli 1.115.1 → 1.116.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/daemon/bin/darwin-arm64/botbuddy-daemon +0 -0
- package/daemon/bin/linux-x64/botbuddy-daemon +0 -0
- package/daemon-release/darwin-arm64.json +4 -4
- package/daemon-release/linux-x64.json +4 -4
- package/daemon-release/manifest.json +5 -5
- package/package.json +1 -1
- package/src/stack-run-outcome.mjs +31 -12
- package/src/stack.mjs +85 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.116.0
|
|
4
|
+
|
|
5
|
+
- BOT-3536: `bb stack run --ticket <Y>` follows an agent to its next ticket. When the server refuses the run with a session-scope `STALE_AGENT_CONTEXT` (the session is still registered for X), and this checkout's branch names Y, the run sends one ticket-moving `heartbeat` on the worktree's own cached session and one fresh admission, which the unchanged fence judges again. A run for a ticket the branch does not name, an agent-scope refusal, and an env- or flag-supplied token are never rebound, and a run rebinds at most once. The refusal hint no longer offers `bb doctor --fix` (it renews the session in place and keeps its ticket); it names `bb call heartbeat --json '{"ticket_id":"Y"}'`. The receipt carries `context_rebound: {from, to}` and `registered_ticket_id`; the `stack_run_outcome` row carries `registered_ticket_id` (stale-context rows only) and `context_rebound: true`, and an older server's unknown-key refusal drops each newer key in turn. Needs MCP 2.157.2 for the two outcome keys.
|
|
6
|
+
|
|
7
|
+
## 1.115.2
|
|
8
|
+
|
|
9
|
+
- BOT-3532: the host daemon declares the status-v1 refusal contract when it submits a no-execution recovery proof (`X-BotBuddy-Recovery-Refusal: status-v1`). The server then answers a refused settlement as HTTP 409 with its fixed reason code, and the daemon reads that code exactly as it read the legacy HTTP 200 refusal: an expiry refusal re-signs a fresh proof, any other refusal keeps the proof and the fence. An unknown 409 code stays an opaque error. Needs MCP 2.157.1; older daemons keep the legacy 200 shape.
|
|
10
|
+
|
|
3
11
|
## 1.115.1
|
|
4
12
|
|
|
5
13
|
- BOT-3495: the host daemon's automatic updater no longer drains a host it cannot stop. Before `begin` (the call that drains the host), it runs the same local quiescence check as the fenced stop. When that fails, it defers the upgrade with `code=HOST_NOT_QUIESCENT`, keeps the offer for the next tick, and leaves the host state unchanged. Once activated, a drain still not quiescent 15 minutes after `activated_at` rolls back, and the rollback restarts the still-running previous daemon under rollback authority so it can complete. Needs the matching server change, which lets a rollback complete while the restored worker is blocked only by receipt finalization.
|
|
Binary file
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.116.0",
|
|
3
|
+
"source_commit": "776f87d33e41fcb5d6420d6a22f90489313889c9",
|
|
4
|
+
"source_sha256": "3b436ee9dd1f121b3e94eeaaf0e07f0b46ed6e569197fae219d9dfd1acf88a02",
|
|
5
5
|
"target": "darwin-arm64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "6102224982e9afd001cd15b6541a03bae894af75d146a6af8977d44551812ac6"
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"release_version": "1.
|
|
3
|
-
"source_commit": "
|
|
4
|
-
"source_sha256": "
|
|
2
|
+
"release_version": "1.116.0",
|
|
3
|
+
"source_commit": "776f87d33e41fcb5d6420d6a22f90489313889c9",
|
|
4
|
+
"source_sha256": "3b436ee9dd1f121b3e94eeaaf0e07f0b46ed6e569197fae219d9dfd1acf88a02",
|
|
5
5
|
"target": "linux-x64",
|
|
6
|
-
"sha256": "
|
|
6
|
+
"sha256": "f3a91bbc0a19e65e862a53bde67075fd7a94c24a8c94a4a14d0cead6b07c9615"
|
|
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.116.0",
|
|
4
|
+
"source_commit": "776f87d33e41fcb5d6420d6a22f90489313889c9",
|
|
5
|
+
"source_sha256": "3b436ee9dd1f121b3e94eeaaf0e07f0b46ed6e569197fae219d9dfd1acf88a02",
|
|
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": "6102224982e9afd001cd15b6541a03bae894af75d146a6af8977d44551812ac6",
|
|
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": "f3a91bbc0a19e65e862a53bde67075fd7a94c24a8c94a4a14d0cead6b07c9615",
|
|
19
19
|
"mode": "0755"
|
|
20
20
|
}
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -206,6 +206,10 @@ export function buildStackRunOutcomePayload({ fields = {}, exitCode, runId = ran
|
|
|
206
206
|
? fields.failure_mechanism : null;
|
|
207
207
|
// BOT-2977: sent only on a stale-context refusal, so every other payload keeps its shape.
|
|
208
208
|
const fenceScope = code === "STALE_AGENT_CONTEXT" && ["session", "agent"].includes(fields.fence_scope) ? fields.fence_scope : null;
|
|
209
|
+
// BOT-3536: the ticket the refusing fence compared with, judged at refusal time rather than
|
|
210
|
+
// from the later `sessions` snapshot; and whether this run rebound its session (any code).
|
|
211
|
+
const registeredTicketId = code === "STALE_AGENT_CONTEXT" ? pick(fields.registered_ticket_id, TICKET_RE)?.toUpperCase() ?? null : null;
|
|
212
|
+
const contextRebound = Boolean(fields.context_rebound && typeof fields.context_rebound === "object");
|
|
209
213
|
// BOT-3109: the code a requester network loss replaced; sent only on such a run.
|
|
210
214
|
const underlyingCode = category === "requester" && REQUESTER_UNDERLYING_CODES.has(fields.underlying_code) ? fields.underlying_code : null;
|
|
211
215
|
return {
|
|
@@ -233,10 +237,15 @@ export function buildStackRunOutcomePayload({ fields = {}, exitCode, runId = ran
|
|
|
233
237
|
...(callbackAuthorizationReason ? { callback_authorization_reason: callbackAuthorizationReason } : {}),
|
|
234
238
|
...(failureMechanism ? { failure_mechanism: failureMechanism } : {}),
|
|
235
239
|
...(fenceScope ? { fence_scope: fenceScope } : {}),
|
|
240
|
+
...(registeredTicketId ? { registered_ticket_id: registeredTicketId } : {}),
|
|
241
|
+
...(contextRebound ? { context_rebound: true } : {}),
|
|
236
242
|
...(underlyingCode ? { underlying_code: underlyingCode } : {}),
|
|
237
243
|
};
|
|
238
244
|
}
|
|
239
245
|
|
|
246
|
+
/** Optional keys an older server may refuse as unknown; the send drops each in turn. */
|
|
247
|
+
const LEGACY_OPTIONAL_KEYS = ["failure_mechanism", "fence_scope", "registered_ticket_id", "context_rebound"];
|
|
248
|
+
|
|
240
249
|
/**
|
|
241
250
|
* Best-effort record. `channel` is `{ auth, callTool }` from the lifecycle (the
|
|
242
251
|
* credential the lease calls used); without one there is nothing to authenticate
|
|
@@ -263,23 +272,33 @@ export async function reportStackRunOutcome({ fields, exitCode, runId, opts, env
|
|
|
263
272
|
});
|
|
264
273
|
try {
|
|
265
274
|
const call = Promise.resolve().then(async () => {
|
|
266
|
-
const
|
|
275
|
+
const refused = (res) => !ac.signal.aborted && res?.ok && res?.isError && res?.data?.code === "INVALID_STACK_RUN_OUTCOME" && typeof res?.data?.message === "string";
|
|
267
276
|
// Older servers reject unknown keys before writing. Retry only that exact,
|
|
268
277
|
// explicit rejection with the same run id; never retry an uncertain send.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
278
|
+
// BOT-3536: a row can carry more than one newer key, so each refused one is
|
|
279
|
+
// dropped in turn (at most once each), exactly as an older CLI would send it.
|
|
280
|
+
const sendDroppingLegacyKeys = async (body) => {
|
|
281
|
+
let sent = body;
|
|
282
|
+
let res = await channel.callTool(STACK_RUN_OUTCOME_TOOL, sent, { auth: channel.auth, signal: ac.signal });
|
|
283
|
+
for (let dropped = 0; dropped < LEGACY_OPTIONAL_KEYS.length && refused(res); dropped++) {
|
|
284
|
+
const refusedKey = LEGACY_OPTIONAL_KEYS.find((key) => sent[key] !== undefined && res.data.message.startsWith(`unknown key '${key}'`));
|
|
285
|
+
if (!refusedKey) break;
|
|
286
|
+
const { [refusedKey]: _omitted, ...legacyPayload } = sent;
|
|
287
|
+
sent = legacyPayload;
|
|
288
|
+
res = await channel.callTool(STACK_RUN_OUTCOME_TOOL, sent, { auth: channel.auth, signal: ac.signal });
|
|
289
|
+
}
|
|
290
|
+
return { res, sent };
|
|
291
|
+
};
|
|
292
|
+
const { res: first, sent } = await sendDroppingLegacyKeys(payload);
|
|
276
293
|
// BOT-3109: a server from before the requester category refuses it (or its underlying_code).
|
|
277
294
|
// Record exactly what that server would have got from an older CLI: the platform code.
|
|
278
|
-
|
|
295
|
+
// Built from the reduced `sent`, and itself dropping any newer key the server then
|
|
296
|
+
// refuses, so the fallback survives whichever key the server names first (review #1929).
|
|
297
|
+
const refusedRequester = sent.category === "requester" && sent.underlying_code && refused(first) &&
|
|
279
298
|
(first.data.message.startsWith("unknown key 'underlying_code'") || first.data.message.startsWith("category must be"));
|
|
280
|
-
if (
|
|
281
|
-
const { underlying_code: underlying, ...rest } =
|
|
282
|
-
return await
|
|
299
|
+
if (refusedRequester) {
|
|
300
|
+
const { underlying_code: underlying, ...rest } = sent;
|
|
301
|
+
return (await sendDroppingLegacyKeys({ ...rest, category: "platform", code: underlying })).res;
|
|
283
302
|
}
|
|
284
303
|
return first;
|
|
285
304
|
});
|
package/src/stack.mjs
CHANGED
|
@@ -1769,9 +1769,11 @@ const STALE_CONTEXT_TICKET_RE = /^[A-Z][A-Z0-9]{1,15}-[0-9]{1,12}$/;
|
|
|
1769
1769
|
function staleContextRecovery(requested, branchTicket) {
|
|
1770
1770
|
if (branchTicket === undefined || requested === "unknown") return "";
|
|
1771
1771
|
const branch = typeof branchTicket === "string" && STALE_CONTEXT_TICKET_RE.test(branchTicket) ? branchTicket : null;
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1772
|
+
// BOT-3536: `bb doctor --fix` renews the session in place (BOT-3219) and keeps its
|
|
1773
|
+
// registered ticket, so it is never offered as the rebind. A ticket-moving heartbeat is.
|
|
1774
|
+
if (branch === requested) return `Rebind this worktree's session with \`bb call heartbeat --json '{"ticket_id":"${requested}"}'\`, then retry. `;
|
|
1775
|
+
return `${branch ? `This worktree's branch is for ${branch}` : "This worktree's branch names no ticket"}, so this run was not rebound to ${requested}: `
|
|
1776
|
+
+ `run it from ${requested}'s worktree, or call register_agent with ticket_id ${requested} in this session, then retry. `;
|
|
1775
1777
|
}
|
|
1776
1778
|
|
|
1777
1779
|
/** BOT-2977: the fence the server applied (`session` for a tier-3 session, else `agent`). */
|
|
@@ -1792,21 +1794,65 @@ export function staleContextRefusalFields(data) {
|
|
|
1792
1794
|
};
|
|
1793
1795
|
}
|
|
1794
1796
|
|
|
1795
|
-
/** BOT-
|
|
1796
|
-
export async function
|
|
1797
|
+
/** BOT-3536: this checkout's branch name; undefined when unknown (not a checkout, detached HEAD). */
|
|
1798
|
+
export async function currentBranchName(cwd = process.cwd()) {
|
|
1797
1799
|
try {
|
|
1798
1800
|
const git = spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 5000 });
|
|
1799
1801
|
if (git.status !== 0 || typeof git.stdout !== "string") return undefined;
|
|
1800
1802
|
const branch = git.stdout.trim();
|
|
1801
1803
|
// A detached HEAD names no branch, so the branch's ticket is unknown, not absent.
|
|
1802
|
-
|
|
1803
|
-
const match = branch.match(/(?:^|\/)\s*(bot|ent)-(\d+)(?:-|$)/i);
|
|
1804
|
-
return match ? `${match[1].toUpperCase()}-${match[2]}` : null;
|
|
1804
|
+
return !branch || branch === "HEAD" ? undefined : branch;
|
|
1805
1805
|
} catch {
|
|
1806
1806
|
return undefined;
|
|
1807
1807
|
}
|
|
1808
1808
|
}
|
|
1809
1809
|
|
|
1810
|
+
/** The ticket a branch name carries (`<author>/bot-<n>-<slug>`), null when none. */
|
|
1811
|
+
export function branchNameTicket(branch) {
|
|
1812
|
+
const match = typeof branch === "string" ? branch.match(/(?:^|\/)\s*(bot|ent)-(\d+)(?:-|$)/i) : null;
|
|
1813
|
+
return match ? `${match[1].toUpperCase()}-${match[2]}` : null;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
/** BOT-2977: the ticket this checkout's branch names (null when none), read only for a stale-context refusal. */
|
|
1817
|
+
export async function currentBranchTicket(cwd = process.cwd()) {
|
|
1818
|
+
const branch = await currentBranchName(cwd);
|
|
1819
|
+
return branch === undefined ? undefined : branchNameTicket(branch);
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
/** BOT-3536: credentials that are this worktree's own cached session (never an env/flag token or an operator key). */
|
|
1823
|
+
const REBINDABLE_CREDENTIAL_SOURCES = new Set(["cache", "renewed", "minted"]);
|
|
1824
|
+
|
|
1825
|
+
/**
|
|
1826
|
+
* BOT-3536: the one rebind a stale-context refusal may trigger. An agent that moved
|
|
1827
|
+
* to its next ticket in the same worktree keeps a session registered for the old
|
|
1828
|
+
* one, so the session-scoped fence refuses `--ticket <new>`. When — and only when —
|
|
1829
|
+
* the server refused on the SESSION fence, this checkout's branch names exactly the
|
|
1830
|
+
* requested ticket, the server's registered ticket differs, and the credential is
|
|
1831
|
+
* the worktree's own cached session, send one ticket-moving `heartbeat` on that
|
|
1832
|
+
* session (it writes `sessions.registered_ticket_key`, BOT-2977). The caller then
|
|
1833
|
+
* sends one fresh admission, which the unchanged fence judges again.
|
|
1834
|
+
*
|
|
1835
|
+
* Unlike the CLI auto-renew rejected on 2026-11-08, this never binds the session to
|
|
1836
|
+
* the ticket a run merely ASKS for: the branch must name it, so a run for a ticket
|
|
1837
|
+
* the worktree is not on stays refused. Returns null when no rebind applies, else
|
|
1838
|
+
* `{ rebound, from, to }`.
|
|
1839
|
+
*/
|
|
1840
|
+
export async function rebindStaleSession(data, { auth, call, branch = currentBranchName } = {}) {
|
|
1841
|
+
if (data?.code !== "STALE_AGENT_CONTEXT" || staleContextFenceScope(data) !== "session") return null;
|
|
1842
|
+
const { registered_ticket_id: from, requested_ticket_id: to } = staleContextRefusalFields(data);
|
|
1843
|
+
if (!from || !to || from === to) return null;
|
|
1844
|
+
if (!REBINDABLE_CREDENTIAL_SOURCES.has(auth?.__source) || typeof call !== "function") return null;
|
|
1845
|
+
const name = await branch();
|
|
1846
|
+
if (branchNameTicket(name) !== to) return null;
|
|
1847
|
+
let res = null;
|
|
1848
|
+
try { res = await call("heartbeat", { ticket_id: to, branch: name }); } catch { res = null; }
|
|
1849
|
+
// The production answer has no `success` key: a session id, and an `error` on refusal.
|
|
1850
|
+
const sessionId = auth.__identity?.sessionId ?? null;
|
|
1851
|
+
const rebound = Boolean(res?.ok && !res.isError && !res.data?.error && typeof res.data?.session_id === "string"
|
|
1852
|
+
&& (!sessionId || res.data.session_id === sessionId));
|
|
1853
|
+
return { rebound, from, to };
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1810
1856
|
/** The refusal text for a receipt: the server's message, else the CLI's guidance, else the code. */
|
|
1811
1857
|
export function leaseRefusalError(data, { branchTicket } = {}) {
|
|
1812
1858
|
if (data?.code === "STALE_AGENT_CONTEXT") {
|
|
@@ -4330,8 +4376,8 @@ async function runStackLifecycleWatched(opts, childArgv, adapters, firstBox, fre
|
|
|
4330
4376
|
result.cleanup?.ok !== false && !incidentBox.stopSignal) {
|
|
4331
4377
|
requeuedFrom = { lease_id: result.leaseId, reap_reason: result.reapReason };
|
|
4332
4378
|
process.stderr.write(`${sessionRequeueNotice(requeuedFrom)}\n`);
|
|
4333
|
-
const { incident } = incidentBox;
|
|
4334
|
-
incidentBox = { ...freshBox(), incident };
|
|
4379
|
+
const { incident, contextRebound } = incidentBox;
|
|
4380
|
+
incidentBox = { ...freshBox(), incident, ...(contextRebound ? { contextRebound } : {}) };
|
|
4335
4381
|
// One park budget (--timeout) across both attempts.
|
|
4336
4382
|
const remaining = remainingParkSecs(opts.timeout, startedAtMs, (adapters.now ?? Date.now)());
|
|
4337
4383
|
result = await once({ ...opts, queueParkTimeout: remaining });
|
|
@@ -4349,7 +4395,9 @@ async function runStackLifecycleWatched(opts, childArgv, adapters, firstBox, fre
|
|
|
4349
4395
|
const withOutage = incidentBox.callbackOutage && withStopSignal ? { ...withStopSignal, callbackOutage: incidentBox.callbackOutage } : withStopSignal;
|
|
4350
4396
|
// BOT-3369: not a receipt field; it sizes the requester-network lookback to this run's grace.
|
|
4351
4397
|
const withGrace = incidentBox.degradedGraceMs && withOutage && typeof withOutage === "object" ? { ...withOutage, degradedGraceMs: incidentBox.degradedGraceMs } : withOutage;
|
|
4352
|
-
|
|
4398
|
+
// BOT-3536: a run that rebound its session says so on every result shape.
|
|
4399
|
+
const withRebound = incidentBox.contextRebound && withGrace && typeof withGrace === "object" ? { ...withGrace, contextRebound: incidentBox.contextRebound } : withGrace;
|
|
4400
|
+
const final = await applyRequesterNetworkLoss(withRebound, networkWatch, { failedAtMs: incidentBox.lossAtMs });
|
|
4353
4401
|
// BOT-2467: non-enumerable, so the receipt fields and result comparisons never see it.
|
|
4354
4402
|
if (final && typeof final === "object" && incidentBox.outcomeChannel) {
|
|
4355
4403
|
Object.defineProperty(final, OUTCOME_CHANNEL, { value: incidentBox.outcomeChannel, enumerable: false });
|
|
@@ -5060,11 +5108,29 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5060
5108
|
// stack digest changed) or that lost a race to a preemption answers with the OLD lease
|
|
5061
5109
|
// id: wait for it to reach `reaped`, then send the SAME request once more (it then
|
|
5062
5110
|
// provisions a fresh lease for the slot).
|
|
5111
|
+
// BOT-3536: a session-fence refusal for the ticket this branch names rebinds the
|
|
5112
|
+
// worktree's session once (rebindStaleSession) and sends one FRESH admission; the
|
|
5113
|
+
// unchanged fence judges it again. At most one rebind per run, never a second retry.
|
|
5114
|
+
const admitOnce = () => requestIdentified ? requestIdentified() : api.request(leaseArgs);
|
|
5115
|
+
let rebindTried = false;
|
|
5116
|
+
const admit = async () => {
|
|
5117
|
+
const res = await admitOnce();
|
|
5118
|
+
if (rebindTried || identifiedVerdict || res?.data?.code !== "STALE_AGENT_CONTEXT") return res;
|
|
5119
|
+
rebindTried = true;
|
|
5120
|
+
const rebind = await rebindStaleSession(res.data, {
|
|
5121
|
+
auth: rpc.auth, call: (name, args) => rpc.call(name, args), branch: adapters.branchName ?? (() => currentBranchName()),
|
|
5122
|
+
});
|
|
5123
|
+
if (!rebind?.rebound) return res;
|
|
5124
|
+
incidentBox.contextRebound = { from: rebind.from, to: rebind.to };
|
|
5125
|
+
stderrLine(`stack: this worktree's session was registered for ${rebind.from} and its branch names ${rebind.to}; rebound the session to ${rebind.to} and requesting once more`);
|
|
5126
|
+
renewIdentifiedRequest?.();
|
|
5127
|
+
return admitOnce();
|
|
5128
|
+
};
|
|
5063
5129
|
let request;
|
|
5064
5130
|
let idleRetried = false;
|
|
5065
5131
|
for (let attempt = 0; ; attempt++) {
|
|
5066
5132
|
activeWaitAbort = new AbortController();
|
|
5067
|
-
const admission = await requestWithCapacityWait(
|
|
5133
|
+
const admission = await requestWithCapacityWait(admit, opts, {
|
|
5068
5134
|
waitCapacity: adapters.waitCapacity ?? defaultWaitCapacity, log: stderrLine, signal: activeWaitAbort.signal,
|
|
5069
5135
|
});
|
|
5070
5136
|
activeWaitAbort = null;
|
|
@@ -5260,9 +5326,12 @@ async function runStackLifecycleOnce(opts, childArgv, adapters, incidentBox) {
|
|
|
5260
5326
|
// BOT-2977: name the re-registration command; the refusal itself is never retried here.
|
|
5261
5327
|
const fenceScope = staleContextFenceScope(request.data);
|
|
5262
5328
|
const branchTicket = request.data?.code === "STALE_AGENT_CONTEXT" ? await (adapters.branchTicket ?? currentBranchTicket)() : undefined;
|
|
5329
|
+
// BOT-3536: the ticket the server compared with, recorded at refusal time.
|
|
5330
|
+
const registeredTicketId = request.data?.code === "STALE_AGENT_CONTEXT" ? staleContextRefusalFields(request.data).registered_ticket_id : undefined;
|
|
5263
5331
|
return {
|
|
5264
5332
|
exitCode: leaseRefusalExit(request.data?.code), outcome: "error", code: request.data?.code,
|
|
5265
5333
|
...(fenceScope ? { fenceScope } : {}),
|
|
5334
|
+
...(registeredTicketId ? { registeredTicketId } : {}),
|
|
5266
5335
|
...capacityStaleReceiptFields(request.data), error: leaseRefusalError(request.data, { branchTicket }),
|
|
5267
5336
|
...(request.data?.sqlstate ? { sqlstate: request.data.sqlstate } : {}),
|
|
5268
5337
|
...(request.data.lease_id ? { leaseId: request.data.lease_id, state: request.data.state ?? null } : {}),
|
|
@@ -6218,6 +6287,10 @@ export function runReceiptFields(result) {
|
|
|
6218
6287
|
// BOT-2977: which fence refused a STALE_AGENT_CONTEXT run (session | agent).
|
|
6219
6288
|
...(result.code === "STALE_AGENT_CONTEXT" && (result.fenceScope === "session" || result.fenceScope === "agent")
|
|
6220
6289
|
? { fence_scope: result.fenceScope } : {}),
|
|
6290
|
+
// BOT-3536: the ticket the refusing fence compared with, and a session rebind this run made.
|
|
6291
|
+
...(result.code === "STALE_AGENT_CONTEXT" && typeof result.registeredTicketId === "string" && STALE_CONTEXT_TICKET_RE.test(result.registeredTicketId)
|
|
6292
|
+
? { registered_ticket_id: result.registeredTicketId } : {}),
|
|
6293
|
+
...(result.contextRebound ? { context_rebound: { from: result.contextRebound.from, to: result.contextRebound.to } } : {}),
|
|
6221
6294
|
// BOT-2957: the control-plane gaps this run's callback route rode through (never on a run that had none).
|
|
6222
6295
|
...(result.callbackOutage ? { callback_outage: result.callbackOutage } : {}),
|
|
6223
6296
|
// BOT-2780: the reserved requester origin generated auth links name (never a credential).
|