benignswarm 0.12.159 → 0.12.160

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/dist/args.js CHANGED
@@ -46,7 +46,7 @@ export const BOOL_FLAGS = [
46
46
  "all", "here", "keep-worktree", "prune", "abandon", "defer", "hold", "clear", "met", "shared", "archive",
47
47
  "approve", "turn", "service", "print-hooks", "create", "rotate", "drain", "codex-userns", "bwrap-userns", "agy-userns", "print-apparmor", "overdue",
48
48
  "cancel", "rerun", "confirmed", "refuted", "no-source", "confirm-bypass-signal", "assessment-only", "continue",
49
- "no-wait-verify", "preview", "remove-empty", "dry-run", "quota-substitution",
49
+ "no-wait-verify", "preview", "remove-empty", "dry-run", "quota-substitution", "auto-merge",
50
50
  "in-container", "retrieve-ec2", "stdin", "context-confirmed", "confirm-compatible", "move-provisioned", "provisioned", "no-commits-beyond-target", "train",
51
51
  ];
52
52
  export function parse(argv) {
@@ -177,16 +177,13 @@ export async function gate(p, out) {
177
177
  const unitText = p.positionals[2]?.trim();
178
178
  const unitNumber = unitText ? Number(unitText) : NaN;
179
179
  if (!Number.isSafeInteger(unitNumber) || unitNumber < 1) {
180
- throw new CliError("usage", "b9s gate run <n> [--merge-candidate <sha>] --on <machine> | b9s gate run --train [--target <branch>] [--on <machine>]");
180
+ throw new CliError("usage", "b9s gate run <n> [--merge-candidate <sha>] [--on <machine>] | b9s gate run --train [--target <branch>] [--on <machine>]");
181
181
  }
182
182
  const machine = str(p.flags, "on")?.trim();
183
- if (!machine) {
184
- throw new CliError("usage", "b9s gate run <n> [--merge-candidate <sha>] --on <machine> (--on is required)");
185
- }
186
183
  const candidate = str(p.flags, "merge-candidate")?.trim() || undefined;
187
184
  const res = await client.call("POST", `/projects/${project}/gate-jobs`, {
188
185
  unit: unitNumber,
189
- machine,
186
+ ...(machine ? { machine } : {}),
190
187
  ...(candidate ? { merge_candidate: candidate } : {}),
191
188
  });
192
189
  const job = res.job;
@@ -512,6 +512,7 @@ function waitActionResult(unit, on, clear) {
512
512
  * b9s wu classify <n> --tags a,b [--note ...] classifier role only, when the process has that step
513
513
  * b9s wu tags <n> --add a,b --remove c [--note ...] owner before review, a reviewer during it
514
514
  * b9s wu done <n> --merged <sha> after approval; the sha is checked against the target branch
515
+ * b9s wu pr <n> [--auto-merge] open or reuse a PR for the unit branch through the linked GitHub App
515
516
  * b9s wu merge <n> [--note "..."] request the role-checked hosted merge; API only, no local Git state
516
517
  * b9s wu merge status <n> read hosted merge operation and audit status
517
518
  * b9s wu abandon <n> [--note ...]
@@ -1298,6 +1299,16 @@ export async function wu(p, out) {
1298
1299
  out.print(withRuleText(fmt(r.unit) + (verifiedRemoteTarget ? `\nverified on ${verifiedRemoteTarget}` : "") + cleanupUnitWorktree(r.unit.worktree, def, keepWorktree, antigravityWorkspaceWrite, "done", !deferredCleanupError && !keepWorktree, deferredCleanupError), r, "close"), r);
1299
1300
  return;
1300
1301
  }
1302
+ case "pr": {
1303
+ const unitNumber = Number(p.positionals[2]);
1304
+ if (!Number.isInteger(unitNumber) || unitNumber < 1)
1305
+ throw new CliError("usage", "wu pr <number> [--auto-merge]");
1306
+ const autoMerge = bool(p.flags, "auto-merge");
1307
+ const result = await client.call("POST", `${base}/${unitNumber}/pr`, { auto_merge: autoMerge });
1308
+ const pull = result.pull_request;
1309
+ out.print(`Pull request for WU #${unitNumber}: ${pull.url}${autoMerge ? " (auto-merge enabled)" : ""}`, result);
1310
+ return;
1311
+ }
1301
1312
  case "merge": {
1302
1313
  const statusOnly = p.positionals[2] === "status";
1303
1314
  const rawNumber = statusOnly ? p.positionals[3] : p.positionals[2];
@@ -1330,6 +1341,9 @@ export async function wu(p, out) {
1330
1341
  const failText = run.status === "failed"
1331
1342
  ? `\nFailed step: ${run.failed_step ?? "gate"}${run.attributed_unit_number ? `; culprit WU #${run.attributed_unit_number} (${run.attribution_method ?? "attributed"})` : ""}${run.error ? `\nError: ${run.error}` : ""}`
1332
1343
  : "";
1344
+ const retryText = Array.isArray(run.retry_reasons) && run.retry_reasons.length
1345
+ ? `\nRetry history: ${run.retry_reasons.map((reason) => `retried: ${reason}`).join("; ")}`
1346
+ : "";
1333
1347
  const entryLines = entries.map((e) => ({
1334
1348
  unit: `#${e.work_unit_number}`,
1335
1349
  status: e.status,
@@ -1337,7 +1351,7 @@ export async function wu(p, out) {
1337
1351
  owner: e.owner_name ?? "-",
1338
1352
  reason: e.reason ?? "-",
1339
1353
  }));
1340
- out.print(`Merge train run ${run.id} [${run.status}] on ${run.target_branch}${run.machine ? ` (${run.machine})` : ""}${run.merged_sha ? ` -> ${run.merged_sha.slice(0, 9)}` : ""}${run.closed_units?.length ? `\nClosed: ${run.closed_units.map((n) => `#${n}`).join(", ")}` : ""}${skippedText}${failText}${run.log_evidence_id ? `\nLog: evidence:${run.log_evidence_id}` : ""}${entryLines.length ? `\n${table(entryLines, ["unit", "status", "head", "owner", "reason"])}` : ""}`, detail);
1354
+ out.print(`Merge train run ${run.id} [${run.status}] on ${run.target_branch}${run.machine ? ` (${run.machine})` : ""}${run.merged_sha ? ` -> ${run.merged_sha.slice(0, 9)}` : ""}${run.closed_units?.length ? `\nClosed: ${run.closed_units.map((n) => `#${n}`).join(", ")}` : ""}${skippedText}${retryText}${failText}${run.log_evidence_id ? `\nLog: evidence:${run.log_evidence_id}` : ""}${entryLines.length ? `\n${table(entryLines, ["unit", "status", "head", "owner", "reason"])}` : ""}`, detail);
1341
1355
  return;
1342
1356
  }
1343
1357
  const qs = new URLSearchParams();
@@ -1361,7 +1375,7 @@ export async function wu(p, out) {
1361
1375
  const activeLine = res.active_run
1362
1376
  ? `Active run: ${res.active_run.id} [${res.active_run.status}] on ${res.active_run.target_branch}${res.active_run.machine ? ` (${res.active_run.machine})` : ""} · ${res.active_run.queued_units?.length ?? 0} queued`
1363
1377
  : "Active run: none";
1364
- const historyLines = res.history.slice(0, 10).map((r) => ` ${r.created_at.slice(0, 16).replace("T", " ")} ${r.id.slice(0, 8)} [${r.status}] ${r.target_branch}${r.merged_sha ? ` ${r.merged_sha.slice(0, 9)}` : ""}${r.closed_units?.length ? ` closed ${r.closed_units.map((n) => `#${n}`).join(",")}` : ""}${r.failed_step ? ` failed at ${r.failed_step}` : ""}${r.attributed_unit_number ? ` (send back WU #${r.attributed_unit_number})` : ""}`);
1378
+ const historyLines = res.history.slice(0, 10).map((r) => ` ${r.created_at.slice(0, 16).replace("T", " ")} ${r.id.slice(0, 8)} [${r.status}] ${r.target_branch}${r.merged_sha ? ` ${r.merged_sha.slice(0, 9)}` : ""}${r.closed_units?.length ? ` closed ${r.closed_units.map((n) => `#${n}`).join(",")}` : ""}${r.failed_step ? ` failed at ${r.failed_step}` : ""}${r.attributed_unit_number ? ` (send back WU #${r.attributed_unit_number})` : ""}${Array.isArray(r.retry_reasons) && r.retry_reasons.length ? ` · ${r.retry_reasons.map((reason) => `retried: ${reason}`).join("; ")}` : ""}`);
1365
1379
  out.print(`Merge train for ${res.project} (target ${res.target_branch}, merged_by ${res.policy?.merged_by ?? "owner"}, auto_enqueue ${res.policy?.auto_enqueue ? "yes" : "no"})\n${activeLine}\n${queueRows.length ? table(queueRows, ["unit", "status", "target", "head", "source", "owner", "title"]) : "(train queue is empty)"}${historyLines.length ? `\nRecent runs:\n${historyLines.join("\n")}` : ""}`, res);
1366
1380
  return;
1367
1381
  }
@@ -1648,7 +1662,7 @@ export async function wu(p, out) {
1648
1662
  return;
1649
1663
  }
1650
1664
  default:
1651
- throw new CliError("usage", "wu open|assign|lands-with|branch|start [--branch b|--here]|decline|submit|approve|changes|classify|tags|merge <n>|merge status <n>|train <list|status|enqueue|remove|run>|done [--keep-worktree]|abandon|note|ask|rule|sendback-rule|propose|show|list|stalled");
1665
+ throw new CliError("usage", "wu open|assign|lands-with|branch|start [--branch b|--here]|decline|submit|approve|changes|classify|tags|pr <n> [--auto-merge]|merge <n>|merge status <n>|train <list|status|enqueue|remove|run>|done [--keep-worktree]|abandon|note|ask|rule|sendback-rule|propose|show|list|stalled");
1652
1666
  }
1653
1667
  }
1654
1668
  /** Queued units have no owner; ask the API to reject before any local worktree is made. */
package/dist/help.js CHANGED
@@ -29,7 +29,7 @@ Mac capacity/signing API (profiles, leases, signer-only references, TestFlight a
29
29
  Standing rules are resolved by account, project, role, and exact-agent scope. GET /agents/me/standing-rules and GET /projects/:p/standing-rules return complete authorized sets and fingerprints; their separate ack endpoints accept only a current fingerprint after complete delivery. Operators and authorized assigners manage rules through the API; limits, compatibility confirmation, audit, and authorization are in packages/skill/references/api.md. Console management and chat promotion are WU #313.
30
30
  Claude Code, Codex, and Antigravity SessionStart hooks retrieve the complete effective rules at fresh start, resume, compaction, and clear into a new thread. They acknowledge only after complete output; an unavailable or over-budget payload points to b9s process without acknowledgment. b9s me shows concise rule text and acknowledgment, b9s process shows the full project rules and acknowledges that fingerprint after display, and b9s resume includes the effective rulesets.
31
31
 
32
- GitHub connection and repository status are available in the console and through b9s-admin github status and b9s-admin project github <project> status|unlink. A repository link enables agent credentials without requiring a ruleset. An agent can inspect its effective repository permission with GET /projects/:p/git-credentials; a project admin can inspect a named agent with GET /projects/:p/git-credentials?agent=<name-or-id>. Each issuance records its permission reason without storing the token. Verify an exact target ruleset in Account -> GitHub connection before enabling hosted merge; the CLI cannot perform this owner OAuth step. Disconnect an installation with b9s-admin github disconnect <installation-id>. Hosted merge execution and status use b9s wu merge <n> and b9s wu merge status <n>; they call POST/GET /projects/:p/work-units/:n/merge and never inspect local Git state. API role checks use merge.merged_by and operator override; operator_hold is checked, merges serialize in MergeTargetDO, and retries reconcile idempotently. Manual wu done remains disabled for enabled linked targets. Enable with b9s-admin project hosted-merge <project> enable --confirm-bypass-signal only after ruleset verification and the live GitHub bypass-change check; disable with b9s-admin project hosted-merge <project> disable. The console control is WU #196. App setup steps are in packages/skill-admin/references/setup.md.
32
+ GitHub connection and repository status are available in the console and through b9s-admin github status and b9s-admin project github <project> status|unlink. A repository link enables agent credentials without requiring a ruleset. An agent can inspect its effective repository permission with GET /projects/:p/git-credentials; a project admin can inspect a named agent with GET /projects/:p/git-credentials?agent=<name-or-id>. Each issuance records its permission reason without storing the token. Open or reuse a PR for a unit's pushed branch with b9s wu pr <n>; add --auto-merge to ask GitHub to merge it after required checks pass. The API scopes its installation token to the linked repository, stores the PR URL on the unit, and never prints or persists the token. Verify an exact target ruleset in Account -> GitHub connection before enabling hosted merge; the CLI cannot perform this owner OAuth step. Disconnect an installation with b9s-admin github disconnect <installation-id>. Hosted merge execution and status use b9s wu merge <n> and b9s wu merge status <n>; they call POST/GET /projects/:p/work-units/:n/merge and never inspect local Git state. API role checks use merge.merged_by and operator override; operator_hold is checked, merges serialize in MergeTargetDO, and retries reconcile idempotently. Manual wu done remains disabled for enabled linked targets. Enable with b9s-admin project hosted-merge <project> enable --confirm-bypass-signal only after ruleset verification and the live GitHub bypass-change check; disable with b9s-admin project hosted-merge <project> disable. The console control is WU #196. App setup steps are in packages/skill-admin/references/setup.md.
33
33
 
34
34
  Environment problems: agents report bounded, redacted observations with b9s environment report; reports use scoped project or machine access, account-scoped evidence, and only the agent's own blocked units. Agents can append observations but cannot claim, diagnose, or resolve issues. Operators and agents whose role has own_environment_problems can manage visible issues. Operators use Account → Environment in the console to filter and inspect issues, claim/assign/reassign, record diagnoses, and resolve with a note and verification. Manual diagnoses use source agent; doctor/daemon provenance is for actual check results. Banner links open the same issue detail with impact context. Issue detail links active notices in the same scope and current machine-session faults related to its machine or explicitly linked unit owner. The read-only steward summary lists active linked issues and currently waiting linked units, without publishing notices or creating work. Machine issue views respect linked-project access. Spending impact is unknown and creates no banner until unit-attributed telemetry lands in WU #236; see packages/skill/references/api.md.
35
35
 
@@ -201,6 +201,7 @@ Machine placement enforces configured session slots and reports machine pressure
201
201
  b9s wu evidence replace <n> <old> <new> [--note ".."] owner replaces attached evidence; old id is retained in the unit history
202
202
  b9s wu done <n> --merged <sha> | --no-source --evidence id[,id...] [--keep-worktree] after approval; checks its branch has no commits beyond the target for no-source; requires a passing lock-run gate receipt for the commit or matching tree
203
203
  Antigravity workspace-write queues the exact closed worktree for cleanup outside the sandbox at turn finalization; branches are kept
204
+ b9s wu pr <n> [--auto-merge] open or reuse a pull request for the linked repository and unit branch
204
205
  b9s wu merge <n> [--note "..."] role-checked hosted merge through the API; never inspects local Git credentials or state
205
206
  b9s wu merge status <n> operation status and non-secret audit trail for a hosted merge
206
207
  b9s wu train list [--target <branch>] [--limit <n>] list active merge train queue and recent train runs
@@ -327,9 +328,9 @@ Machine placement enforces configured session slots and reports machine pressure
327
328
  queue a remote seeded browser task or ux:compare on an account machine labeled ux-host or browser
328
329
  b9s ux job <id> [--log] inspect remote browser job diagnostics; --log prints its full log
329
330
  b9s ux jobs [--unit <n>] [--limit n] list remote browser jobs in this project
330
- b9s gate run <n> [--merge-candidate <sha>] --on <machine>
331
+ b9s gate run <n> [--merge-candidate <sha>] [--on <machine>]
331
332
  b9s gate run --train [--target <branch>] [--on <machine>]
332
- queue a complete-suite gate run (or merge-train run) on a machine; records the receipt and posts the log as evidence
333
+ queue a complete-suite gate run (or merge-train run); auto-selects a qualified free gate machine unless --on is given, records the receipt and posts the log as evidence
333
334
  b9s gate job <id> [--log] inspect remote gate diagnostics; --log prints its full log
334
335
  b9s gate jobs [--unit <n>] [--limit n] list remote gate jobs in this project
335
336
  b9s retire --title t (--body b | --body-file f) [--handoff-to @x|@role:y] [--evidence id,id] --yes
@@ -88,6 +88,18 @@ export function failingTestText(output) {
88
88
  blocks.push(current.join("\n"));
89
89
  return blocks.join("\n");
90
90
  }
91
+ /** Classify only explicit baseline races and known gate-harness failure signatures. */
92
+ export function classifyRetryableGateFailure(output, exitCode) {
93
+ if (/^gate:\s+stale baseline:/im.test(output))
94
+ return "stale baseline";
95
+ const assertionFailure = /\bAssertionError\b|\bTests?\s+\d+\s+failed\b|\bTest Files?\s+\d+\s+failed\b/i.test(output);
96
+ const setupFailure = /\b(?:test setup error|setup file(?:s)?[^\n]*(?:failed|error)|failed (?:during|while) (?:the )?test setup|error (?:during|while) (?:the )?test setup)\b/i.test(output);
97
+ const localD1Failure = /\bD1_ERROR:\s*[^\n]*\binternal error\b|\binternal error in Durable Object storage\b/i.test(output);
98
+ const watchdogTimeout = (exitCode === 124 || /^gate:\s+.+\s+exit 124(?:\s+in\s+\d+\s+s)?\s*$/im.test(output)) && !assertionFailure;
99
+ if (setupFailure || localD1Failure || watchdogTimeout)
100
+ return "infrastructure";
101
+ return null;
102
+ }
91
103
  export function detectUnitAttributedFailureFromOutput(output, entries) {
92
104
  const unitSet = new Set(entries.map((e) => e.work_unit_number));
93
105
  const matches = new Set();
@@ -212,6 +224,7 @@ export async function runMergeTrainWorkflow(job, trainRun, h) {
212
224
  const activeEntries = trainRun.entries.map((entry) => ({ entry }));
213
225
  const skippedUnits = [];
214
226
  let retryCount = 0;
227
+ const retryReasons = [];
215
228
  while (true) {
216
229
  // 1. Fetch origin and check out current remote target.
217
230
  const { baseSha } = await h.runStep("fetch target", async () => {
@@ -290,6 +303,7 @@ export async function runMergeTrainWorkflow(job, trainRun, h) {
290
303
  attribution_method: null,
291
304
  attribution_reason: null,
292
305
  retry_count: retryCount,
306
+ ...(retryReasons.length ? { retry_reasons: [...retryReasons] } : {}),
293
307
  },
294
308
  };
295
309
  }
@@ -321,6 +335,7 @@ export async function runMergeTrainWorkflow(job, trainRun, h) {
321
335
  let attributedUnitNumber = null;
322
336
  let attributionMethod = null;
323
337
  let attributionReason = null;
338
+ let retryGateReason = null;
324
339
  let gateExitCode = 0;
325
340
  if (gateSpec) {
326
341
  try {
@@ -430,10 +445,31 @@ export async function runMergeTrainWorkflow(job, trainRun, h) {
430
445
  writeFileSync(join(logDir, `gate-train-${candidateSha.slice(0, 9)}.log`), mainRun.output || `exit ${mainRun.status}\n`);
431
446
  if (mainRun.status !== 0) {
432
447
  failedStep = parseFailedGateStep(mainRun.output, h.stepTimeline);
433
- if (included.length === 1) {
434
- attributedUnitNumber = included[0].entry.work_unit_number;
435
- attributionMethod = "single_unit";
436
- attributionReason = `only WU #${attributedUnitNumber} was included when ${failedStep} failed`;
448
+ retryGateReason = classifyRetryableGateFailure(mainRun.output, mainRun.status);
449
+ if (retryGateReason) {
450
+ h.onLogLine(`merge-train ${trainRun.id}: gate failed with retryable ${retryGateReason} signature`);
451
+ }
452
+ else if (included.length === 1) {
453
+ // A failed candidate alone does not establish that this unit broke the
454
+ // gate: the target may already be failing. Verify the exact target before
455
+ // assigning a single-unit failure.
456
+ await resetCleanWorktree(h.worktreeDir, baseSha, h.runner, gitEnv);
457
+ const baseProbe = await runGateAtHead(`verify target ${baseSha.slice(0, 9)}`, anchorUnit, baseSha);
458
+ if (baseProbe.status !== 0) {
459
+ retryGateReason = classifyRetryableGateFailure(baseProbe.output, baseProbe.status);
460
+ if (retryGateReason) {
461
+ h.onLogLine(`merge-train ${trainRun.id}: target-only verification had retryable ${retryGateReason} signature`);
462
+ }
463
+ else {
464
+ attributionMethod = "unattributed";
465
+ attributionReason = `target branch ${trainRun.target_branch} at ${baseSha.slice(0, 9)} already failed ${failedStep}`;
466
+ }
467
+ }
468
+ else {
469
+ attributedUnitNumber = included[0].entry.work_unit_number;
470
+ attributionMethod = "single_unit";
471
+ attributionReason = `verified ${trainRun.target_branch} passes and only WU #${attributedUnitNumber} fails ${failedStep}`;
472
+ }
437
473
  }
438
474
  else {
439
475
  const outputHint = detectUnitAttributedFailureFromOutput(mainRun.output, included.map((i) => i.entry));
@@ -460,19 +496,29 @@ export async function runMergeTrainWorkflow(job, trainRun, h) {
460
496
  });
461
497
  const midSha = midRev.stdout.trim().toLowerCase();
462
498
  const probe = await runGateAtHead(`bisect WU #${included.slice(0, mid + 1).map((x) => x.entry.work_unit_number).join(",#")}`, included[0].entry.work_unit_number, midSha);
499
+ if (probe.status !== 0)
500
+ retryGateReason = classifyRetryableGateFailure(probe.output, probe.status);
501
+ if (retryGateReason)
502
+ break;
463
503
  if (probe.status === 0)
464
504
  lo = mid + 1;
465
505
  else
466
506
  hi = mid;
467
507
  }
468
- if (lo === 0) {
508
+ if (!retryGateReason && lo === 0) {
469
509
  // Verify baseline target wasn't already broken before blaming the first unit.
470
510
  await resetCleanWorktree(h.worktreeDir, baseSha, h.runner, gitEnv);
471
511
  const baseProbe = await runGateAtHead(`bisect target ${baseSha.slice(0, 9)}`, anchorUnit, baseSha);
472
512
  if (baseProbe.status !== 0) {
473
- attributedUnitNumber = null;
474
- attributionMethod = "unattributed";
475
- attributionReason = `target branch ${trainRun.target_branch} at ${baseSha.slice(0, 9)} already failed ${failedStep}`;
513
+ retryGateReason = classifyRetryableGateFailure(baseProbe.output, baseProbe.status);
514
+ if (retryGateReason) {
515
+ h.onLogLine(`merge-train ${trainRun.id}: target-only verification had retryable ${retryGateReason} signature`);
516
+ }
517
+ else {
518
+ attributedUnitNumber = null;
519
+ attributionMethod = "unattributed";
520
+ attributionReason = `target branch ${trainRun.target_branch} at ${baseSha.slice(0, 9)} already failed ${failedStep}`;
521
+ }
476
522
  }
477
523
  else {
478
524
  attributedUnitNumber = included[0].entry.work_unit_number;
@@ -480,7 +526,7 @@ export async function runMergeTrainWorkflow(job, trainRun, h) {
480
526
  attributionReason = `bisect confirmed ${trainRun.target_branch} passes and WU #${attributedUnitNumber} fails ${failedStep}`;
481
527
  }
482
528
  }
483
- else {
529
+ else if (!retryGateReason) {
484
530
  attributedUnitNumber = included[lo].entry.work_unit_number;
485
531
  attributionMethod = "bisect";
486
532
  attributionReason = `bisect isolated failure at ${failedStep} to WU #${attributedUnitNumber}`;
@@ -526,6 +572,40 @@ export async function runMergeTrainWorkflow(job, trainRun, h) {
526
572
  };
527
573
  }
528
574
  }
575
+ if (retryGateReason) {
576
+ retryCount++;
577
+ if (!retryReasons.includes(retryGateReason))
578
+ retryReasons.push(retryGateReason);
579
+ const retryLine = `merge-train ${trainRun.id}: retried: ${retryGateReason} (${retryCount}/${MAX_RE_GATE_ATTEMPTS})`;
580
+ h.onLogLine(retryLine);
581
+ if (retryCount >= MAX_RE_GATE_ATTEMPTS) {
582
+ const reasonText = `merge train exhausted ${MAX_RE_GATE_ATTEMPTS} attempts after retryable ${retryGateReason} failures`;
583
+ return {
584
+ status: "failed",
585
+ resolvedHead: candidateSha,
586
+ error: reasonText,
587
+ trainResult: {
588
+ target_branch: trainRun.target_branch,
589
+ base_sha: baseSha,
590
+ merged_sha: candidateSha,
591
+ tested_tree_sha: gateTestedTree,
592
+ verified_baseline_sha: gateVerifiedBaseline,
593
+ push_verified: false,
594
+ included_units: included.map((i) => i.entry.work_unit_number),
595
+ landed_units: [],
596
+ skipped_units: skippedUnits,
597
+ failed_step: failedStep ?? "gate",
598
+ attributed_unit_number: null,
599
+ attribution_method: "unattributed",
600
+ attribution_reason: reasonText,
601
+ retry_count: retryCount,
602
+ retry_reasons: [...retryReasons],
603
+ retry_exhausted: true,
604
+ },
605
+ };
606
+ }
607
+ continue;
608
+ }
529
609
  if (gateExitCode !== 0) {
530
610
  const stepLabel = failedStep ?? parseFailedGateStep(gateOutputText, h.stepTimeline);
531
611
  const errText = `merge train failed at ${stepLabel}${attributedUnitNumber ? `; attributed to WU #${attributedUnitNumber} (${attributionMethod})` : ""}`;
@@ -548,6 +628,7 @@ export async function runMergeTrainWorkflow(job, trainRun, h) {
548
628
  attribution_method: attributionMethod ?? "unattributed",
549
629
  attribution_reason: attributionReason ?? errText,
550
630
  retry_count: retryCount,
631
+ ...(retryReasons.length ? { retry_reasons: [...retryReasons] } : {}),
551
632
  },
552
633
  };
553
634
  }
@@ -735,6 +816,7 @@ export async function runMergeTrainWorkflow(job, trainRun, h) {
735
816
  attribution_method: "unattributed",
736
817
  attribution_reason: pushStep.error.slice(0, 500),
737
818
  retry_count: retryCount,
819
+ ...(retryReasons.length ? { retry_reasons: [...retryReasons] } : {}),
738
820
  },
739
821
  };
740
822
  }
@@ -764,6 +846,7 @@ export async function runMergeTrainWorkflow(job, trainRun, h) {
764
846
  attribution_method: "unattributed",
765
847
  attribution_reason: msg,
766
848
  retry_count: retryCount,
849
+ ...(retryReasons.length ? { retry_reasons: [...retryReasons] } : {}),
767
850
  },
768
851
  };
769
852
  }
@@ -790,6 +873,7 @@ export async function runMergeTrainWorkflow(job, trainRun, h) {
790
873
  attribution_method: "unattributed",
791
874
  attribution_reason: errMsg.slice(0, 500),
792
875
  retry_count: retryCount,
876
+ ...(retryReasons.length ? { retry_reasons: [...retryReasons] } : {}),
793
877
  },
794
878
  };
795
879
  }
@@ -813,6 +897,7 @@ export async function runMergeTrainWorkflow(job, trainRun, h) {
813
897
  attribution_method: null,
814
898
  attribution_reason: null,
815
899
  retry_count: retryCount,
900
+ ...(retryReasons.length ? { retry_reasons: [...retryReasons] } : {}),
816
901
  },
817
902
  };
818
903
  }
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLI_VERSION = "0.12.159";
1
+ export const CLI_VERSION = "0.12.160";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "benignswarm",
3
- "version": "0.12.159",
3
+ "version": "0.12.160",
4
4
  "description": "b9s: chat, status board and evidence store for coding agents (benignswarm.org)",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {