@tablation/crew 0.168.0 → 0.169.1

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.
Files changed (2) hide show
  1. package/dist/cli.js +159 -91
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -3640,7 +3640,7 @@ var VERSIONINGS = ["auto", "none"];
3640
3640
  var CI_KEYS = /* @__PURE__ */ new Set(["provider", "ref"]);
3641
3641
  var VERIFY_KEYS = /* @__PURE__ */ new Set(["match", "timeoutSeconds", "intervalSeconds"]);
3642
3642
  var ISOLATE_KEYS = /* @__PURE__ */ new Set(["maxCandidates"]);
3643
- var DEFAULT_ISOLATE_MAX_CANDIDATES = 4;
3643
+ var DEFAULT_ISOLATE_MAX_CANDIDATES = 8;
3644
3644
  var DEFAULT_RIGHT_OF_WAY_MINUTES = 60;
3645
3645
  function parseRebuildPrimary(raw, fail2) {
3646
3646
  if (raw === void 0 || raw === null) return void 0;
@@ -6102,13 +6102,17 @@ function removeLaunchdUnit(unit, dryRun, log) {
6102
6102
  if (existsSync16(unit.plistPath)) unlinkSync2(unit.plistPath);
6103
6103
  log.emit(`removed ${unit.label} (${unit.plistPath})`);
6104
6104
  }
6105
+ function foreignInstallRefusal(blocking, ownProgram) {
6106
+ const found = blocking.map((u) => `${u.label} runs ${u.program ?? "an unreadable ProgramArguments"}`).join("; ");
6107
+ const others = [...new Set(blocking.map((u) => u.program).filter((p) => p !== null))];
6108
+ const uninstall = others.length > 0 ? `Or remove only that copy's units by running ${others.map((p) => `\`${p} uninstall\``).join(" / ")} instead (the copy at ${ownProgram} is not changed).` : "The unit has no readable program, so only --replace can remove it.";
6109
+ return `scheduler units on this machine start a different copy of crew than this one (${ownProgram}): ${found}. Nothing was changed. Two sets of units would run two crews against the same board, so install stopped. \`crew install --replace\` removes the other copy's scheduler units and installs this copy's, so this ship keeps serving the same routes from this copy. ${uninstall} Neither command touches crew.yaml, routes or tickets.`;
6110
+ }
6105
6111
  function clearForeignLaunchdUnits(crewHome, replace, dryRun, log, dir, loaded) {
6106
6112
  const foreign = foreignLaunchdUnits(crewHome, dir, loaded);
6107
6113
  const blocking = foreign.filter((u) => !u.orphan && (u.program === null || u.programExists));
6108
6114
  if (blocking.length > 0 && !replace) {
6109
- log.warn(
6110
- `two crew installs target this machine: ${blocking.map((u) => `${u.label} runs ${u.program ?? "an unreadable ProgramArguments"}`).join("; ")}. Run \`crew uninstall\` from the other one, or pass --replace.`
6111
- );
6115
+ log.warn(foreignInstallRefusal(blocking, crewInvocation(crewHome).at(-1) ?? crewHome));
6112
6116
  return false;
6113
6117
  }
6114
6118
  for (const unit of foreign) {
@@ -23072,9 +23076,13 @@ async function runRelease(o) {
23072
23076
  const movedPast2 = [];
23073
23077
  const localRefSkips = [];
23074
23078
  const rightOfWay = { deferrals: [], lapsed: [] };
23075
- const out = await runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay);
23079
+ const batch = { deferred: [], reason: "capped" };
23080
+ const out = await runReleaseCycle({ ...o, batch }, movedPast2, localRefSkips, rightOfWay);
23081
+ const gateFailed = out.stopped === "tests failed" || out.stopped === "build failed";
23076
23082
  return {
23077
23083
  ...out,
23084
+ ...batch.deferred.length ? { batchDeferral: batch } : {},
23085
+ ...gateFailed && !out.buildCulprits?.length && out.merged.length ? { unisolatedFailure: true } : {},
23078
23086
  ...movedPast2.length ? { movedPast: movedPast2 } : {},
23079
23087
  ...localRefSkips.length ? { localRefSkips } : {},
23080
23088
  ...rightOfWay.deferrals.length || rightOfWay.lapsed.length ? { rightOfWay } : {}
@@ -23165,7 +23173,7 @@ async function runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay) {
23165
23173
  const { remote, base } = o.repo.branch;
23166
23174
  const inPlace = o.dryRun || !!o.mergeOnly || !remoteBranchExists(o.cwd, remote, base);
23167
23175
  const remoteRef = `${remote}/${base}`;
23168
- const decision = decideRelease(o.cwd, releasable, o.contract, {
23176
+ const decided = decideRelease(o.cwd, releasable, o.contract, {
23169
23177
  tagPattern,
23170
23178
  base,
23171
23179
  blockerInfo: o.blockerInfo,
@@ -23175,6 +23183,13 @@ async function runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay) {
23175
23183
  // A dry run only looks.
23176
23184
  branchFor: (t) => o.dryRun ? locateBranchForTicket(o.cwd, o.repo, t)?.branch ?? null : materializeBranchForTicket(o.cwd, o.repo, t)
23177
23185
  });
23186
+ let decision = decided;
23187
+ if (o.batchCapped && !o.dryRun && !o.mergeOnly && !o.force) {
23188
+ const cap = isolateCap(o);
23189
+ const trimmed = trimBatch(decided, cap);
23190
+ decision = trimmed.decision;
23191
+ noteDeferred(o, trimmed.left, "capped", cap);
23192
+ }
23178
23193
  reportHeld(o, decision.held);
23179
23194
  if (!fresh.ok) {
23180
23195
  o.emit.error(scoped(`refusing to release \u2014 ${fresh.why}; a person has to reconcile the two`));
@@ -23267,24 +23282,36 @@ async function runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay) {
23267
23282
  }
23268
23283
  return rebuild ? { ...outcome, primaryRebuild: rebuild } : outcome;
23269
23284
  }
23270
- var MAX_ISOLATE_PAIRS = 10;
23271
- function pairOrder(n, max = MAX_ISOLATE_PAIRS) {
23272
- const pairs = [];
23273
- let truncated = false;
23274
- outer: for (let j = 1; j < n; j++) {
23275
- for (let i = 0; i < j; i++) {
23276
- if (pairs.length >= max) {
23277
- truncated = true;
23278
- break outer;
23279
- }
23280
- pairs.push([i, j]);
23281
- }
23282
- }
23283
- return { pairs, truncated };
23285
+ var MAX_ISOLATE_ROUNDS = 2;
23286
+ var BATCH_CAPPED_EVENT = "release_capped";
23287
+ var BATCH_CAP_CLEARED_EVENT = "release_cap_cleared";
23288
+ function batchCapActive(events, scope) {
23289
+ const at = (e) => Date.parse(e.occurred_at ?? e.created_at ?? "") || 0;
23290
+ const mine = events.filter((e) => e.metadata?.scope === scope && (e.event_type === BATCH_CAPPED_EVENT || e.event_type === BATCH_CAP_CLEARED_EVENT));
23291
+ if (!mine.length) return false;
23292
+ const newest = mine.reduce((a, b) => at(b) > at(a) ? b : a);
23293
+ return newest.event_type === BATCH_CAPPED_EVENT;
23294
+ }
23295
+ var isMergeable = (c) => !!c.branch && !c.mergedSha;
23296
+ function trimBatch(decision, cap) {
23297
+ const mergeable = decision.merges.filter(isMergeable);
23298
+ if (cap <= 0 || mergeable.length <= cap) return { decision, left: [] };
23299
+ const left = mergeable.slice(cap);
23300
+ return { decision: { ...decision, merges: decision.merges.filter((c) => !left.includes(c)) }, left };
23301
+ }
23302
+ function noteDeferred(o, left, reason, limit) {
23303
+ if (!left.length) return;
23304
+ const why = reason === "capped" ? `the last release failed its gate and was not isolated, so a batch is capped at ${limit}` : `the gate failed on a batch over release.isolateFailures.maxCandidates (${limit}), so the oldest ${limit} are tried first`;
23305
+ o.emit.warn(
23306
+ `${left.length} verified branch${left.length === 1 ? "" : "es"} left for a later cycle: ${why}`,
23307
+ { step: "release", data: { deferred: left.length, reason, limit } }
23308
+ );
23309
+ o.batch?.deferred.push(...left.map((c) => c.ticket));
23310
+ if (o.batch) o.batch.reason = reason;
23284
23311
  }
23285
23312
  function selfRepairLine(maxCandidates) {
23286
23313
  const cap = maxCandidates ?? DEFAULT_ISOLATE_MAX_CANDIDATES;
23287
- return cap === 0 ? "culprit isolation is off (release.isolateFailures.maxCandidates: 0); a failed gate files an alert" : `culprit isolation up to ${cap} merged branches, ${MAX_ISOLATE_PAIRS} pairs before bisecting; a ticket handed back twice after a push escalates with an alert`;
23314
+ return cap === 0 ? "culprit isolation is off (release.isolateFailures.maxCandidates: 0); a failed gate files an alert" : `culprit isolation bisects up to ${cap} merged branches (a larger failing batch is shrunk to the oldest ${cap}, and the next batch is capped at ${cap} until a release ships); a ticket handed back twice after a push escalates with an alert`;
23288
23315
  }
23289
23316
  var isolateCap = (o) => o.repo.release.isolateFailures?.maxCandidates ?? DEFAULT_ISOLATE_MAX_CANDIDATES;
23290
23317
  async function redBase(o, name, applied, cap, preMerge, head, decision, fresh, releaseBranch) {
@@ -23313,14 +23340,71 @@ async function redBase(o, name, applied, cap, preMerge, head, decision, fresh, r
23313
23340
  o.emit.emit(`${keep.map((c) => c.branch).join(", ")} make the ${name} hook pass on a red ${base} \u2014 releasing ${keep.length === 1 ? "it" : "them"}, the rest stay verified`);
23314
23341
  gitOk(o.cwd, ["reset", "--hard", preMerge]);
23315
23342
  const rest = decision.merges.filter((c) => !applied.includes(c) || keep.includes(c));
23316
- const retried = await mergeAndRelease(o, { ...decision, merges: rest }, fresh, releaseBranch, true);
23343
+ const retried = await mergeAndRelease(o, { ...decision, merges: rest }, fresh, releaseBranch, MAX_ISOLATE_ROUNDS);
23317
23344
  return retried.isolation ? retried : { ...retried, isolation: tried };
23318
23345
  }
23319
- async function isolateAndRetry(o, name, output, merged, preMerge, decision, fresh, releaseBranch) {
23346
+ async function bisectCulprit(o, name, applied, output, preMerge) {
23347
+ const gate = async (group) => {
23348
+ gitOk(o.cwd, ["reset", "--hard", preMerge]);
23349
+ for (const c of group) if (mergeFailed(mergeOne(o, c))) return { failed: false, output: "" };
23350
+ const r = await hook(o, name);
23351
+ return { failed: !!r && r.code !== 0, output: r?.output ?? "" };
23352
+ };
23353
+ let lo = 1, hi = applied.length, tail3 = output;
23354
+ while (lo < hi) {
23355
+ const mid = Math.floor((lo + hi) / 2);
23356
+ const g = await gate(applied.slice(0, mid));
23357
+ if (g.failed) {
23358
+ hi = mid;
23359
+ tail3 = g.output;
23360
+ } else lo = mid + 1;
23361
+ }
23362
+ const owner = applied[hi - 1];
23363
+ if (hi === 1) return { c: owner, how: "solo", output: tail3 };
23364
+ const alone = await gate([owner]);
23365
+ if (alone.failed) return { c: owner, how: "solo", output: alone.output };
23366
+ const earlier = applied.slice(0, hi - 1);
23367
+ let from = 1, to = earlier.length;
23368
+ while (from < to) {
23369
+ const mid = Math.floor((from + to) / 2);
23370
+ const g = await gate([...earlier.slice(0, mid), owner]);
23371
+ if (g.failed) {
23372
+ to = mid;
23373
+ tail3 = g.output;
23374
+ } else from = mid + 1;
23375
+ }
23376
+ const sibling = earlier[to - 1];
23377
+ if (earlier.length > 1) {
23378
+ const pair = await gate([sibling, owner]);
23379
+ if (!pair.failed) return null;
23380
+ tail3 = pair.output;
23381
+ }
23382
+ return { c: owner, how: "pair", sibling, output: tail3 };
23383
+ }
23384
+ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fresh, releaseBranch, rounds) {
23320
23385
  const applied = merged.filter((c) => c.sha && c.branch);
23321
23386
  const cap = isolateCap(o);
23322
23387
  if (o.dryRun || !preMerge || applied.length < 1 || cap === 0) return null;
23323
23388
  const head = headSha(o.cwd);
23389
+ if (applied.length > cap) {
23390
+ const named = failingPaths(output, o.cwd);
23391
+ const changed2 = (c) => new Set(
23392
+ (gitOk(o.cwd, ["diff", "--name-only", `${preMerge}...${c.branch}`]) ?? "").split("\n").filter(Boolean)
23393
+ );
23394
+ if (!culpritByFiles(applied.map((c) => ({ c, changed: changed2(c) })), named)) {
23395
+ const { decision: smaller, left } = trimBatch(decision, cap);
23396
+ noteDeferred(o, left, "shrunk", cap);
23397
+ for (const c of left) {
23398
+ if (!o.onUnclaim || o.dryRun) break;
23399
+ try {
23400
+ await o.onUnclaim(c.ticket);
23401
+ } catch {
23402
+ }
23403
+ }
23404
+ gitOk(o.cwd, ["reset", "--hard", preMerge]);
23405
+ return mergeAndRelease(o, smaller, fresh, releaseBranch, rounds);
23406
+ }
23407
+ }
23324
23408
  gitOk(o.cwd, ["reset", "--hard", preMerge]);
23325
23409
  const baseRun = await hook(o, name);
23326
23410
  if (baseRun && baseRun.code !== 0) {
@@ -23341,75 +23425,29 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
23341
23425
  const only = applied[0];
23342
23426
  o.emit.warn(`${name} failed with only ${only.branch} merged and passes without it \u2014 treating it as the culprit`, { ticket: only.ticket.issue_id });
23343
23427
  culprits.push({ c: only, how: "solo", output, paths: failingPaths(output, o.cwd) });
23344
- } else if (applied.length > cap) {
23345
- o.emit.warn(`${name} failed with ${applied.length} branches merged, over release.isolateFailures.maxCandidates (${cap}) \u2014 not isolating`);
23346
- return { tried: `Isolation was skipped: ${applied.length} branches were merged, over release.isolateFailures.maxCandidates (${cap}).` };
23347
23428
  } else {
23348
- o.emit.warn(`${name} failed with ${applied.length} branches merged \u2014 building each alone to find the culprit`);
23349
- for (const c of applied) {
23350
- gitOk(o.cwd, ["reset", "--hard", preMerge]);
23351
- const m = mergeOne(o, c);
23352
- if (mergeFailed(m)) continue;
23353
- const r = await hook(o, name);
23354
- if (r && r.code !== 0) {
23355
- o.emit.warn(`${c.branch} fails the ${name} hook on its own`, { ticket: c.ticket.issue_id });
23356
- culprits.push({ c, how: "solo", output: r.output, paths: failingPaths(r.output, o.cwd) });
23357
- }
23358
- }
23359
- if (culprits.length === 0) {
23360
- const { pairs, truncated } = pairOrder(applied.length);
23361
- for (const [i, j] of pairs) {
23362
- gitOk(o.cwd, ["reset", "--hard", preMerge]);
23363
- const a = mergeOne(o, applied[i]);
23364
- const b = mergeFailed(a) ? a : mergeOne(o, applied[j]);
23365
- if (mergeFailed(b)) continue;
23366
- const r = await hook(o, name);
23367
- if (r && r.code !== 0) {
23368
- o.emit.warn(`${applied[j].branch} fails the ${name} hook together with ${applied[i].branch}`, { ticket: applied[j].ticket.issue_id });
23369
- culprits.push({ c: applied[j], how: "pair", sibling: applied[i], output: r.output, paths: failingPaths(r.output, o.cwd) });
23370
- break;
23371
- }
23372
- }
23373
- if (culprits.length === 0 && truncated) {
23374
- let lo = 2, hi = applied.length;
23375
- let tailOut = output;
23376
- let paths = failingPaths(output, o.cwd);
23377
- while (lo < hi) {
23378
- const mid = Math.floor((lo + hi) / 2);
23379
- gitOk(o.cwd, ["reset", "--hard", preMerge]);
23380
- let clean = true;
23381
- for (const c of applied.slice(0, mid)) {
23382
- const m = mergeOne(o, c);
23383
- if (mergeFailed(m)) {
23384
- clean = false;
23385
- break;
23386
- }
23387
- }
23388
- const r = clean ? await hook(o, name) : null;
23389
- if (r && r.code !== 0) {
23390
- hi = mid;
23391
- tailOut = r.output;
23392
- paths = failingPaths(r.output, o.cwd);
23393
- } else lo = mid + 1;
23394
- }
23395
- const owner = applied[hi - 1];
23396
- o.emit.warn(`${owner.branch} is the first branch whose prefix fails the ${name} hook (bisected over ${applied.length})`, { ticket: owner.ticket.issue_id });
23397
- culprits.push({ c: owner, how: "pair", sibling: applied[hi - 2], output: tailOut, paths });
23398
- }
23429
+ o.emit.warn(`${name} failed with ${applied.length} branches merged \u2014 bisecting to find the culprit`);
23430
+ const found = await bisectCulprit(o, name, applied, output, preMerge);
23431
+ if (found) {
23432
+ o.emit.warn(
23433
+ found.how === "solo" ? `${found.c.branch} fails the ${name} hook on its own` : `${found.c.branch} fails the ${name} hook together with ${found.sibling.branch}`,
23434
+ { ticket: found.c.ticket.issue_id }
23435
+ );
23436
+ culprits.push({ ...found, paths: failingPaths(found.output, o.cwd) });
23399
23437
  }
23400
23438
  }
23401
23439
  gitOk(o.cwd, ["reset", "--hard", preMerge]);
23402
23440
  if (culprits.length === 0) {
23403
23441
  o.emit.warn("no single branch could be blamed \u2014 failing the release as a whole");
23404
23442
  gitOk(o.cwd, ["reset", "--hard", head]);
23405
- return { tried: `Isolation found no culprit: each of the ${applied.length} merged branches passes the ${name} hook alone and no pair among them fails it.` };
23443
+ return { tried: `Isolation found no culprit: bisecting the ${applied.length} merged branches named no single branch, and no pair among them, that fails the ${name} hook.` };
23406
23444
  }
23407
23445
  const out = new Set(culprits.map((x) => x.c.ticket.id));
23408
23446
  const rest = decision.merges.filter((c) => !out.has(c.ticket.id));
23409
- const retried = await mergeAndRelease(o, { ...decision, merges: rest }, fresh, releaseBranch, true);
23447
+ const retried = await mergeAndRelease(o, { ...decision, merges: rest }, fresh, releaseBranch, rounds + 1);
23410
23448
  return {
23411
23449
  ...retried,
23412
- buildCulprits: culprits.map((x) => {
23450
+ buildCulprits: [...culprits.map((x) => {
23413
23451
  const ex = failureExcerpt(x.output, x.paths, HOOK_FAILURE_TAIL_LINES);
23414
23452
  const tip = gitOk(o.cwd, ["rev-parse", x.c.branch])?.trim();
23415
23453
  const logPath = saveGateOutput(x.c.ticket.issue_tag ?? x.c.ticket.issue_id, name, x.output);
@@ -23427,15 +23465,15 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
23427
23465
  inBranch: x.paths.length === 0 ? null : x.paths.some((p) => withFiles.find((w) => w.c === x.c)?.changed.has(p) ?? false),
23428
23466
  ...x.sibling ? { sibling: { key: x.sibling.ticket.issue_tag ?? x.sibling.ticket.issue_id, branch: x.sibling.branch } } : {}
23429
23467
  };
23430
- })
23468
+ }), ...retried.buildCulprits ?? []]
23431
23469
  };
23432
23470
  }
23433
- async function mergeAndRelease(o, decision, fresh, releaseBranch, isolated = false) {
23471
+ async function mergeAndRelease(o, decision, fresh, releaseBranch, isolationRounds = 0) {
23434
23472
  const flakeLog = o.flakeLog ?? [];
23435
- const outcome = await mergeAndReleaseBody({ ...o, flakeLog }, decision, fresh, releaseBranch, isolated);
23473
+ const outcome = await mergeAndReleaseBody({ ...o, flakeLog }, decision, fresh, releaseBranch, isolationRounds);
23436
23474
  return flakeLog.length ? { ...outcome, flakes: [...flakeLog] } : outcome;
23437
23475
  }
23438
- async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated = false) {
23476
+ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolationRounds = 0) {
23439
23477
  o.emit.enter("merge");
23440
23478
  const preMerge = o.dryRun ? "" : headSha(o.cwd);
23441
23479
  const merged = [];
@@ -23614,8 +23652,8 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
23614
23652
  const settleTest = async (first) => {
23615
23653
  let r = first;
23616
23654
  if (r && r.code !== 0 && !o.dryRun) r = await rerunOnce(o, "test", r);
23617
- if (r && r.code !== 0 && !isolated) {
23618
- const out = await isolateAndRetry(o, "test", r.output, merged, preMerge, decision, fresh, releaseBranch);
23655
+ if (r && r.code !== 0 && isolationRounds < MAX_ISOLATE_ROUNDS) {
23656
+ const out = await isolateAndRetry(o, "test", r.output, merged, preMerge, decision, fresh, releaseBranch, isolationRounds);
23619
23657
  if (out && "tried" in out) isolation = out.tried;
23620
23658
  else if (out) return out;
23621
23659
  }
@@ -23647,8 +23685,8 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
23647
23685
  const settleBuild = async (first) => {
23648
23686
  let r = first;
23649
23687
  if (r && r.code !== 0) r = await rerunOnce(o, "build", r);
23650
- if (r && r.code !== 0 && !isolated) {
23651
- const out = await isolateAndRetry(o, "build", r.output, merged, preMerge, decision, fresh, releaseBranch);
23688
+ if (r && r.code !== 0 && isolationRounds < MAX_ISOLATE_ROUNDS) {
23689
+ const out = await isolateAndRetry(o, "build", r.output, merged, preMerge, decision, fresh, releaseBranch, isolationRounds);
23652
23690
  if (out && "tried" in out) isolation = out.tried;
23653
23691
  else if (out) return out;
23654
23692
  }
@@ -23681,7 +23719,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
23681
23719
  o.emit.emit(`would run: ${hookLabel(o.repo, "build")}`);
23682
23720
  if (applied >= 1) {
23683
23721
  o.emit.emit(
23684
- `if it fails, would find the one of ${applied} merged branches that broke it (by the files it names, else by building each alone, up to ${isolateCap(o)}), hand that back to the dev lane and ship the rest`
23722
+ `if it fails, would find the one of ${applied} merged branches that broke it (by the files it names, else by bisecting up to ${isolateCap(o)} branches), hand that back to the dev lane and ship the rest`
23685
23723
  );
23686
23724
  }
23687
23725
  } else {
@@ -29788,7 +29826,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
29788
29826
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
29789
29827
  import { join as join61 } from "path";
29790
29828
  function builtVersion() {
29791
- return true ? "0.168.0" : null;
29829
+ return true ? "0.169.1" : null;
29792
29830
  }
29793
29831
  var REBUILD_HINT = "rebuild with npm run build";
29794
29832
  function newestMtime(path) {
@@ -32637,7 +32675,8 @@ if (command === "passenger-sync-daemon") {
32637
32675
  const DAEMON_SUBCOMMANDS = /* @__PURE__ */ new Set(["start", "stop", "status", "restart"]);
32638
32676
  const worktreeArgs = command === "worktree" ? splitWorktreeArgs(positional, cfg.routes.map((r) => r.route)) : void 0;
32639
32677
  const named = worktreeArgs ? worktreeArgs.route : command === "daemon" && DAEMON_SUBCOMMANDS.has(positional[1] ?? "") ? positional[2] : positional[1];
32640
- const fleetWide = command === "inbox" || command === "connect" || command === "disconnect" || command === "deprovision" || command === "agents" || command === "skills" || command === "logbook" || command === "repos" || command === "ship" || command === "projects" || command === "periscope" || command === "whoami" || command === "sandbox" || releaseFleetWide || command === "pause" || command === "resume" || command === "reload" || FLEET_CAPABLE.has(command) && !named && cfg.routes.length > 1 || worktreeArgs !== void 0 && !named && cfg.routes.length > 1;
32678
+ const fleetWide = command === "inbox" || command === "connect" || command === "disconnect" || command === "deprovision" || command === "agents" || command === "skills" || command === "logbook" || command === "repos" || command === "ship" || command === "projects" || command === "periscope" || command === "whoami" || command === "sandbox" || releaseFleetWide || // CREW-3875: the scheduler units are per ship and name no route, so a route given is ignored.
32679
+ command === "install" || command === "uninstall" || command === "pause" || command === "resume" || command === "reload" || FLEET_CAPABLE.has(command) && !named && cfg.routes.length > 1 || worktreeArgs !== void 0 && !named && cfg.routes.length > 1;
32641
32680
  let route2;
32642
32681
  try {
32643
32682
  route2 = fleetWide ? cfg.routes[0] : findRoute(cfg, named);
@@ -33607,11 +33646,21 @@ ${changed2.map((c) => ` - ${c}
33607
33646
  remit.warn(`could not read hand-back events; not deferring any branch: ${e.message}`);
33608
33647
  }
33609
33648
  }
33649
+ let capEvents = [];
33650
+ if (verifiedTickets.length >= 1 && repo.release.mode !== "external") {
33651
+ try {
33652
+ capEvents = [...await tracker.events(BATCH_CAPPED_EVENT), ...await tracker.events(BATCH_CAP_CLEARED_EVENT)];
33653
+ } catch (e) {
33654
+ remit.warn(`could not read the release cap from the board; not capping this batch: ${e.message}`);
33655
+ }
33656
+ }
33657
+ const batchCapped = batchCapActive(capEvents, scope);
33610
33658
  const claimed = /* @__PURE__ */ new Map();
33611
33659
  const outcome = await runRelease({
33612
33660
  cwd: target.dir,
33613
33661
  repo,
33614
33662
  rightOfWayEvents,
33663
+ batchCapped,
33615
33664
  reloadRepo: (dir) => resolveRepoConfig(loadRepoConfig(dir), {
33616
33665
  hooks: { ...c.hooks, ...o?.hooks },
33617
33666
  labels: { ...c.labels, ...o?.labels },
@@ -33758,6 +33807,25 @@ ${changed2.map((c) => ` - ${c}
33758
33807
  remit.warn(`could not note the red test gate on the board: ${e.message}`, { step: "merge" });
33759
33808
  }
33760
33809
  }
33810
+ if (!dryRun) {
33811
+ const shipped = outcome.deployed || outcome.integrated;
33812
+ const note = outcome.merged[0]?.ticket ?? outcome.batchDeferral?.deferred[0];
33813
+ try {
33814
+ if (outcome.unisolatedFailure && !batchCapped && note) {
33815
+ await tracker.postEvent(
33816
+ note.id,
33817
+ `${scope}: the release gate failed and no branch was isolated \u2014 the next release takes at most ${repo.release.isolateFailures?.maxCandidates ?? DEFAULT_ISOLATE_MAX_CANDIDATES} branches until one ships`,
33818
+ releaseSeat(c),
33819
+ BATCH_CAPPED_EVENT,
33820
+ { scope }
33821
+ );
33822
+ } else if (shipped && batchCapped && note) {
33823
+ await tracker.postEvent(note.id, `${scope}: a release shipped \u2014 the batch cap is lifted`, releaseSeat(c), BATCH_CAP_CLEARED_EVENT, { scope });
33824
+ }
33825
+ } catch (e) {
33826
+ remit.warn(`could not record the release batch cap on the board: ${e.message}`, { step: "release" });
33827
+ }
33828
+ }
33761
33829
  if (outcome.localRefSkips?.length && !dryRun) {
33762
33830
  try {
33763
33831
  const reported2 = await tracker.events("local_ref_skip");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.168.0",
3
+ "version": "0.169.1",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",