@tablation/crew 0.154.1 → 0.156.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/dist/cli.js CHANGED
@@ -569,13 +569,13 @@ function ensureMainIndex(d, s) {
569
569
  const p = serenaPaths(s.stateDir, s.route, String(s.ticket));
570
570
  const head = d.headOf(s.mainCheckout);
571
571
  if (!head) return "unavailable";
572
- const stamp = join5(p.mainProject, "indexed-commit");
573
- if (d.read(stamp)?.trim() === head) return "fresh";
572
+ const stamp2 = join5(p.mainProject, "indexed-commit");
573
+ if (d.read(stamp2)?.trim() === head) return "fresh";
574
574
  const pidFile = join5(p.mainProject, "indexing.pid");
575
575
  const running = Number(d.read(pidFile));
576
576
  if (running > 0 && d.alive(running)) return "running";
577
577
  prepareFolder(d, p.mainHome, p.mainProject, s.mainCheckout);
578
- const pid = d.spawnIndex(serenaIndexArgs(s.mainCheckout), { SERENA_HOME: p.mainHome }, join5(p.mainProject, "index.log"), stamp, head);
578
+ const pid = d.spawnIndex(serenaIndexArgs(s.mainCheckout), { SERENA_HOME: p.mainHome }, join5(p.mainProject, "index.log"), stamp2, head);
579
579
  d.write(pidFile, String(pid));
580
580
  return "started";
581
581
  }
@@ -638,7 +638,7 @@ function realSerenaDeps(onPath2, extraEnv = process.env) {
638
638
  },
639
639
  spawnDetached: detached,
640
640
  // `&&` so the stamp exists only for an index that finished; a killed one is retried next start.
641
- spawnIndex: (args, env, log, stamp, stampText) => detached("sh", ["-c", 'serena "$@" && printf %s "$STAMP_TEXT" > "$STAMP_FILE"', "serena", ...args], { ...env, STAMP_FILE: stamp, STAMP_TEXT: stampText }, log),
641
+ spawnIndex: (args, env, log, stamp2, stampText) => detached("sh", ["-c", 'serena "$@" && printf %s "$STAMP_TEXT" > "$STAMP_FILE"', "serena", ...args], { ...env, STAMP_FILE: stamp2, STAMP_TEXT: stampText }, log),
642
642
  link: (target, path) => symlinkSync(target, path),
643
643
  alive: (pid) => {
644
644
  try {
@@ -1222,9 +1222,9 @@ function rotateEventsFile(file, maxBytes, now = /* @__PURE__ */ new Date()) {
1222
1222
  }
1223
1223
  try {
1224
1224
  if (statSync2(file).size <= maxBytes) return void 0;
1225
- const stamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
1226
- let dest = join8(dirname4(file), `events.${stamp}.jsonl`);
1227
- for (let n = 1; existsSync9(dest); n++) dest = join8(dirname4(file), `events.${stamp}-${n}.jsonl`);
1225
+ const stamp2 = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
1226
+ let dest = join8(dirname4(file), `events.${stamp2}.jsonl`);
1227
+ for (let n = 1; existsSync9(dest); n++) dest = join8(dirname4(file), `events.${stamp2}-${n}.jsonl`);
1228
1228
  renameSync(file, dest);
1229
1229
  return dest;
1230
1230
  } finally {
@@ -3500,6 +3500,7 @@ var RELEASE_KEYS = /* @__PURE__ */ new Set([
3500
3500
  "ci",
3501
3501
  "verify",
3502
3502
  "isolateFailures",
3503
+ "rightOfWayMinutes",
3503
3504
  "versioning",
3504
3505
  "versionFiles",
3505
3506
  "changelog",
@@ -3511,6 +3512,13 @@ var CI_KEYS = /* @__PURE__ */ new Set(["provider", "ref"]);
3511
3512
  var VERIFY_KEYS = /* @__PURE__ */ new Set(["match", "timeoutSeconds", "intervalSeconds"]);
3512
3513
  var ISOLATE_KEYS = /* @__PURE__ */ new Set(["maxCandidates"]);
3513
3514
  var DEFAULT_ISOLATE_MAX_CANDIDATES = 4;
3515
+ var DEFAULT_RIGHT_OF_WAY_MINUTES = 60;
3516
+ function parseRightOfWayMinutes(raw, fail2) {
3517
+ if (raw === void 0 || raw === null) return void 0;
3518
+ const n = Number(raw);
3519
+ if (!Number.isInteger(n) || n < 0) throw fail2(`release.rightOfWayMinutes must be a non-negative integer (got "${raw}")`);
3520
+ return n;
3521
+ }
3514
3522
  function parseIsolateMax(raw, where, fail2) {
3515
3523
  if (raw === void 0 || raw === null) return void 0;
3516
3524
  const n = Number(raw);
@@ -3735,6 +3743,7 @@ function parseRepoConfig(text2, file) {
3735
3743
  "release.isolateFailures",
3736
3744
  (m) => new RepoConfigError(`${file}: ${m}`)
3737
3745
  );
3746
+ const rightOfWay = parseRightOfWayMinutes(raw.release?.rightOfWayMinutes, (m) => new RepoConfigError(`${file}: ${m}`));
3738
3747
  const versioning = String(raw.release?.versioning ?? "auto");
3739
3748
  if (!VERSIONINGS.includes(versioning)) {
3740
3749
  throw new RepoConfigError(`${file}: release.versioning must be auto|none (got "${versioning}")`);
@@ -3812,6 +3821,7 @@ function parseRepoConfig(text2, file) {
3812
3821
  ci: { provider, ref: raw.release?.ci?.ref ? String(raw.release.ci.ref) : void 0 },
3813
3822
  verify,
3814
3823
  isolateFailures: isolateMax === void 0 ? void 0 : { maxCandidates: isolateMax },
3824
+ rightOfWayMinutes: rightOfWay,
3815
3825
  versioning,
3816
3826
  versionFiles,
3817
3827
  tag,
@@ -4022,6 +4032,7 @@ function resolveRepoConfig(repo, ship, dir) {
4022
4032
  DEFAULT_ISOLATE_MAX_CANDIDATES
4023
4033
  )
4024
4034
  },
4035
+ rightOfWayMinutes: repo?.release.rightOfWayMinutes ?? ship?.release?.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES,
4025
4036
  versioning: pick(
4026
4037
  "release.versioning",
4027
4038
  repo?.release.versioning === "auto" ? void 0 : repo?.release.versioning,
@@ -10391,6 +10402,168 @@ function materializeBranchForTicket(dir, cfg, t, role, onProblem, onReset) {
10391
10402
  return loc.branch;
10392
10403
  }
10393
10404
 
10405
+ // src/footprint.ts
10406
+ var FOOTPRINT_DECLARED_EVENT = "footprint_declared";
10407
+ var LOCKFILES = /* @__PURE__ */ new Set([
10408
+ "package-lock.json",
10409
+ "npm-shrinkwrap.json",
10410
+ "pnpm-lock.yaml",
10411
+ "yarn.lock",
10412
+ "bun.lock",
10413
+ "bun.lockb",
10414
+ "Cargo.lock",
10415
+ "Gemfile.lock",
10416
+ "poetry.lock",
10417
+ "Pipfile.lock",
10418
+ "composer.lock",
10419
+ "go.sum",
10420
+ "uv.lock",
10421
+ "pdm.lock",
10422
+ "Podfile.lock",
10423
+ "Package.resolved"
10424
+ ]);
10425
+ var normalizePath = (p) => p.trim().replace(/\\/g, "/").replace(/^\.\//, "");
10426
+ function isIgnoredPath(path, extra = /* @__PURE__ */ new Set()) {
10427
+ const p = normalizePath(path);
10428
+ return extra.has(p) || LOCKFILES.has(p.slice(p.lastIndexOf("/") + 1));
10429
+ }
10430
+ function countedPaths(raw, extra) {
10431
+ const list = Array.isArray(raw) ? raw : typeof raw === "string" ? raw.split(/[\n,]/) : [];
10432
+ return [...new Set(list.map((p) => normalizePath(String(p))).filter((p) => p && !isIgnoredPath(p, extra)))];
10433
+ }
10434
+ var stamp = (e) => e.occurred_at ?? e.created_at ?? "";
10435
+ function declarations(events) {
10436
+ const out = /* @__PURE__ */ new Map();
10437
+ for (const e of events) {
10438
+ if (out.has(e.record_id)) continue;
10439
+ out.set(e.record_id, { paths: countedPaths(e.metadata?.paths), at: stamp(e) });
10440
+ }
10441
+ return out;
10442
+ }
10443
+ function pushes(events) {
10444
+ const out = /* @__PURE__ */ new Map();
10445
+ for (const e of events) {
10446
+ if (out.has(e.record_id)) continue;
10447
+ const raw = e.metadata?.paths;
10448
+ out.set(e.record_id, { at: stamp(e), ...Array.isArray(raw) ? { paths: raw.map((p) => normalizePath(String(p))).filter(Boolean) } : {} });
10449
+ }
10450
+ return out;
10451
+ }
10452
+ function isActive(t) {
10453
+ const s = String(t.status);
10454
+ return s === "in_progress" || s === "fixed" || s === "qa" || s === "verified" && !t.merged_at;
10455
+ }
10456
+ var isWaiting = (t) => t.status === "accepted" || t.status === "blocked";
10457
+ function footprintOf(t, declared, pushed, extra) {
10458
+ const actual = countedPaths(pushed.get(t.id)?.paths, extra);
10459
+ if (t.status === "in_progress") return [.../* @__PURE__ */ new Set([...countedPaths(declared.get(t.id)?.paths, extra), ...actual])];
10460
+ if (isWaiting(t)) return countedPaths(declared.get(t.id)?.paths, extra);
10461
+ return actual;
10462
+ }
10463
+ function byAge(a, b) {
10464
+ const n = (t) => Number(String(t.issue_id).replace(/\D/g, "")) || 0;
10465
+ return n(a) - n(b) || displayKey(a).localeCompare(displayKey(b));
10466
+ }
10467
+ var repoOf = (t) => t.repo_id ?? "";
10468
+ function planFootprints(input) {
10469
+ const waits = /* @__PURE__ */ new Map();
10470
+ const byRepo = /* @__PURE__ */ new Map();
10471
+ for (const t of input.tickets) byRepo.set(repoOf(t), [...byRepo.get(repoOf(t)) ?? [], t]);
10472
+ for (const [repoId, tickets] of byRepo) {
10473
+ const extra = input.ignoreByRepo?.get(repoId);
10474
+ const held = tickets.filter(isActive).map((t) => ({ ticket: t, files: new Set(footprintOf(t, input.declared, input.pushed, extra)) }));
10475
+ const candidates2 = tickets.filter((t) => isWaiting(t) && !input.dependencyBlocked?.has(t.id)).sort(byAge);
10476
+ for (const t of candidates2) {
10477
+ const mine = footprintOf(t, input.declared, input.pushed, extra);
10478
+ const hits = held.filter((h) => h.ticket.id !== t.id && mine.some((f) => h.files.has(f)));
10479
+ if (mine.length === 0 || hits.length === 0) {
10480
+ if (mine.length) held.push({ ticket: t, files: new Set(mine) });
10481
+ continue;
10482
+ }
10483
+ waits.set(t.id, {
10484
+ ticket: t,
10485
+ waitingFor: hits.map((h) => displayKey(h.ticket)),
10486
+ files: [...new Set(hits.flatMap((h) => mine.filter((f) => h.files.has(f))))].sort()
10487
+ });
10488
+ }
10489
+ }
10490
+ return { waits };
10491
+ }
10492
+ function mustYieldTo(self, input) {
10493
+ const extra = input.ignoreByRepo?.get(repoOf(self));
10494
+ const mine = footprintOf(self, input.declared, input.pushed, extra);
10495
+ if (mine.length === 0) return null;
10496
+ const newly = (t) => t.status === "in_progress" && input.declared.has(t.id) && !input.pushed.has(t.id);
10497
+ const number = (t) => Number(String(t.issue_id).replace(/\D/g, "")) || 0;
10498
+ const earlier = (a, b) => {
10499
+ const x = input.declared.get(a.id).at, y = input.declared.get(b.id).at;
10500
+ return x !== y ? x < y : number(a) < number(b);
10501
+ };
10502
+ const hits = input.tickets.filter((o) => o.id !== self.id && repoOf(o) === repoOf(self) && isActive(o)).filter((o) => !(newly(self) && newly(o) && earlier(self, o))).map((o) => ({ o, shared: footprintOf(o, input.declared, input.pushed, extra).filter((f) => mine.includes(f)) })).filter((h) => h.shared.length > 0);
10503
+ if (hits.length === 0) return null;
10504
+ return { waitingFor: hits.map((h) => displayKey(h.o)), files: [...new Set(hits.flatMap((h) => h.shared))].sort() };
10505
+ }
10506
+ function describeFiles(files, shown = 3) {
10507
+ const head = files.slice(0, shown).map((f) => `\`${f}\``).join(", ");
10508
+ return files.length > shown ? `${head} and ${files.length - shown} more` : head;
10509
+ }
10510
+ function footprintWaitNote(w) {
10511
+ return `waiting for ${w.waitingFor.join(", ")}, which changes the same ${w.files.length === 1 ? "file" : "files"}: ${describeFiles(w.files)}`;
10512
+ }
10513
+ function footprintDigestSection(recorded) {
10514
+ const lines2 = recorded.length ? recorded.map((r) => `- ${r.ticket}: ${r.paths.length ? describeFiles(r.paths, 8) : "none"}`).join("\n") : "- none recorded yet";
10515
+ return `### Footprint \u2014 declare before you build
10516
+
10517
+ The crew keeps tickets that would change the same files from being built at the same time. When you pick up a ticket that has **no branch or worktree yet**, before you cut a worktree or change anything:
10518
+
10519
+ 1. Read the ticket and the code and list the repo-relative files you expect to change, including files you expect to create. A guess is fine; an empty list is allowed when you cannot tell.
10520
+ 2. Run \`crew footprint <ticket number> <path>...\` (just \`crew footprint <ticket number>\` when a footprint is already recorded below). It records the list once, then checks it against the active work.
10521
+ 3. If it prints \`YIELD\`, stop there: set the ticket back to \`accepted\`, clear \`assignee_id\`, comment in one line that you declared a footprint and yielded, and end the run without a worktree. The crew parks the ticket as \`blocked\` and restores it when the tickets it waits for are released. If it prints \`PROCEED\`, or the command fails or is not available, go on: a ticket with no footprint simply runs.
10522
+
10523
+ Footprints already recorded:
10524
+
10525
+ ${lines2}
10526
+ `;
10527
+ }
10528
+ var MAX_PUSHED_PATHS = 2e3;
10529
+ function pushedMetadata(diffNameOnly) {
10530
+ if (diffNameOnly === null) return void 0;
10531
+ return { paths: [...new Set(diffNameOnly.split("\n").map(normalizePath).filter(Boolean))].slice(0, MAX_PUSHED_PATHS) };
10532
+ }
10533
+ function footprintVerdictText(ticket, y) {
10534
+ return y ? `YIELD ${ticket}: ${footprintWaitNote(y)}. Set the ticket back to accepted, clear assignee_id, comment in one line and end the run without a worktree; the crew parks it and restores it when they are released.` : `PROCEED ${ticket}: no active ticket shares its files.`;
10535
+ }
10536
+
10537
+ // src/footprint-run.ts
10538
+ async function readFootprintEvents(tracker) {
10539
+ return {
10540
+ declared: declarations(await tracker.events(FOOTPRINT_DECLARED_EVENT)),
10541
+ pushed: pushes(await tracker.events("pushed"))
10542
+ };
10543
+ }
10544
+ function ignoreByRepo(route2) {
10545
+ const out = /* @__PURE__ */ new Map();
10546
+ const names = route2.resolved?.repoNames ?? {};
10547
+ for (const target of reposOf(route2)) {
10548
+ let ignored;
10549
+ try {
10550
+ const cfg = resolveRepoConfig(loadRepoConfigTolerant(target.dir), void 0, target.dir);
10551
+ ignored = new Set([...cfg.release.versionFiles, ...cfg.release.changelog ? [cfg.release.changelog] : []].map(normalizePath));
10552
+ } catch {
10553
+ continue;
10554
+ }
10555
+ const ids = Object.entries(names).filter(([, n]) => n === target.name).map(([id]) => id);
10556
+ for (const id of ids.length ? ids : [""]) out.set(id, ignored);
10557
+ }
10558
+ return out;
10559
+ }
10560
+ function planFootprintsFor(route2, tickets, ev, dependencyBlocked) {
10561
+ return planFootprints({ tickets, ...ev, ignoreByRepo: ignoreByRepo(route2), dependencyBlocked });
10562
+ }
10563
+ function pushedEventExtra(dir, remote, base, sha) {
10564
+ return pushedMetadata(gitOk(dir, ["diff", "--no-renames", "--name-only", `${remote}/${base}...${sha}`]));
10565
+ }
10566
+
10394
10567
  // src/pending-handoff.ts
10395
10568
  import { existsSync as existsSync22, mkdirSync as mkdirSync17, readdirSync as readdirSync7, readFileSync as readFileSync24, rmSync as rmSync13, writeFileSync as writeFileSync18 } from "fs";
10396
10569
  import { join as join25 } from "path";
@@ -10460,7 +10633,7 @@ async function replayPendingHandoffs(i) {
10460
10633
  });
10461
10634
  if (!seen) await i.writer.postComment(t.id, text2, seatId);
10462
10635
  }
10463
- await i.writer.postEvent(t.id, pushedEventBody(v.sha, v.remote, v.branch), seatId, "pushed");
10636
+ await i.writer.postEvent(t.id, pushedEventBody(v.sha, v.remote, v.branch), seatId, "pushed", co ? pushedEventExtra(co.dir, v.remote, co.cfg.branch.base, v.sha) : void 0);
10464
10637
  await i.writer.updateTicket(t.id, rec.patch);
10465
10638
  removePendingHandoff(i.stateDir, rec.ticketRecordId);
10466
10639
  i.log.emit(`${displayKey(t)}: replayed a pending hand-off at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, at);
@@ -10932,7 +11105,7 @@ async function deliverNote(i, ticketId, note, type, log) {
10932
11105
  }
10933
11106
  }
10934
11107
  async function postPushed(i, ticketId, sha, remote, branch, log) {
10935
- await i.writer.postEvent(ticketId, pushedEventBody(sha, remote, branch), i.seatId, "pushed");
11108
+ await i.writer.postEvent(ticketId, pushedEventBody(sha, remote, branch), i.seatId, "pushed", pushedEventExtra(i.dir, remote, i.cfg.branch.base, sha));
10936
11109
  const url = i.branchLink?.url(branch);
10937
11110
  if (!i.branchLink || !url) return;
10938
11111
  try {
@@ -11289,7 +11462,7 @@ ${i.shipName ? `${i.shipName}'s ` : "A "}${i.role} run set it to \`${st.handoff}
11289
11462
  const v = inspectHandoff(co.dir, co.cfg, t, i.role);
11290
11463
  i.log.warn(`${displayKey(t)} was handed off by a run that did not claim it`, at);
11291
11464
  if (v.kind === "pushed") {
11292
- await i.writer.postEvent(t.id, pushedEventBody(v.sha, v.remote, v.branch), i.seatId, "pushed");
11465
+ await i.writer.postEvent(t.id, pushedEventBody(v.sha, v.remote, v.branch), i.seatId, "pushed", pushedEventExtra(co.dir, v.remote, co.cfg.branch.base, v.sha));
11293
11466
  } else if (v.kind === "bounce") {
11294
11467
  if (v.origin && v.local && !isAncestor(co.dir, v.origin, v.local)) {
11295
11468
  i.log.warn(`${displayKey(t)}: \`${v.remote}/${v.branch}\` is at ${v.origin.slice(0, 7)}, not a tip this checkout built \u2014 left alone`, at);
@@ -18204,11 +18377,19 @@ function sweepDiagnostics(tickets, info) {
18204
18377
  return { dangling, selfBlocked: [...new Set(selfBlocked)] };
18205
18378
  }
18206
18379
  var describeBlockers = (t, info) => (t.blocked_by ?? []).map((id) => `${info[id]?.issue_tag ?? info[id]?.issue_id ?? "?"} (${info[id]?.status ?? "unknown"})`).join(", ");
18207
- function planSweep(tickets, info, blocked, wm) {
18380
+ function planSweep(tickets, info, blocked, wm, footprintWaits) {
18208
18381
  const steps = [];
18209
18382
  for (const t of withinWorkMode(tickets, wm)) {
18210
18383
  if (t.status === "accepted" && blocked.has(t.id)) {
18211
- steps.push({ action: "park", ticket: t, blockers: describeBlockers(t, info), to: "blocked" });
18384
+ const fw = footprintWaits?.get(t.id);
18385
+ const byFiles = fw && unresolvedBlockers(t, info).length === 0;
18386
+ steps.push({
18387
+ action: "park",
18388
+ ticket: t,
18389
+ blockers: byFiles ? footprintWaitNote(fw) : describeBlockers(t, info),
18390
+ to: "blocked",
18391
+ ...byFiles ? { footprint: { waitingFor: fw.waitingFor, files: fw.files } } : {}
18392
+ });
18212
18393
  } else if (t.status === "blocked" && !blocked.has(t.id)) {
18213
18394
  steps.push({ action: "restore", ticket: t, blockers: describeBlockers(t, info), to: "accepted" });
18214
18395
  }
@@ -18265,9 +18446,14 @@ function unroutableChanges(unroutable, previous, tickets, externalIdColumn) {
18265
18446
  };
18266
18447
  }
18267
18448
  function sweepComment(step) {
18449
+ if (step.action === "park" && step.footprint) {
18450
+ return `Parked as **Blocked** by the crew \u2014 ${footprintWaitNote(step.footprint)}.
18451
+
18452
+ This is automatic and reversible: a ticket that would change a file another active ticket changes waits for it instead of being built in parallel and conflicting at release. The oldest waiting ticket starts first, and this one is restored on the first poll after the tickets it waits for are released, closed or parked for a person. Nothing else about the ticket changes.`;
18453
+ }
18268
18454
  return step.action === "park" ? `Parked as **Blocked** by the crew \u2014 waiting on: ${step.blockers}.
18269
18455
 
18270
- This is automatic and reversible: an approved ticket whose \`Blocked by\` entries are not all resolved is parked out of the queue, and restored on the first poll after the last one resolves. Nothing else about the ticket changes. A blocker counts as resolved at \`closed_deployed\`, \`closed_wont_fix\` or \`closed_duplicate\`, or at \`verified\` when it is in a different repository or already merged (\`merged_at\` set) \u2014 not at \`fixed\`, which is still an unmerged branch awaiting QA, and not at \`verified\` for a blocker in this ticket's own repository until the release has merged it, so nothing gets built stacked on an unmerged branch.` : `Restored to **Approved** by the crew \u2014 every blocker has resolved${step.blockers && step.blockers !== "\u2014" ? ` (${step.blockers})` : ""}.
18456
+ This is automatic and reversible: an approved ticket whose \`Blocked by\` entries are not all resolved is parked out of the queue, and restored on the first poll after the last one resolves. Nothing else about the ticket changes. A blocker counts as resolved at \`closed_deployed\`, \`closed_wont_fix\` or \`closed_duplicate\`, or at \`verified\` when it is in a different repository or already merged (\`merged_at\` set) \u2014 not at \`fixed\`, which is still an unmerged branch awaiting QA, and not at \`verified\` for a blocker in this ticket's own repository until the release has merged it, so nothing gets built stacked on an unmerged branch.` : `Restored to **Approved** by the crew \u2014 ${step.blockers ? "every blocker has resolved" : "nothing holds it back now (the tickets it waited for no longer hold its files)"}${step.blockers && step.blockers !== "\u2014" ? ` (${step.blockers})` : ""}.
18271
18457
 
18272
18458
  This restores the status it was approved at before being parked; it is back in the queue and a role may pick it up. If a blocker resolved as \`closed_wont_fix\` or \`closed_duplicate\` this ticket may still not be buildable as written \u2014 that is a call for a human, not the crew.`;
18273
18459
  }
@@ -19237,6 +19423,9 @@ async function decideCycle(o) {
19237
19423
  const extra = await tracker.ticketsByIds(missingBlockerIds(tickets));
19238
19424
  const info = blockerInfoMap(tickets, extra);
19239
19425
  const blocked = computeBlockedIds(tickets, info);
19426
+ const footprintEvents = await optional("footprint events", readFootprintEvents(tracker), { declared: /* @__PURE__ */ new Map(), pushed: /* @__PURE__ */ new Map() });
19427
+ const footprintPlan = planFootprintsFor(route2, tickets, footprintEvents, new Set(blocked));
19428
+ for (const id of footprintPlan.waits.keys()) blocked.add(id);
19240
19429
  emit.enter("sweep");
19241
19430
  const roster = buildRoster(configuredMembers(route2), crewRows);
19242
19431
  const holds2 = new Set(holdIds(roster));
@@ -19246,7 +19435,7 @@ async function decideCycle(o) {
19246
19435
  if (diag.selfBlocked.length) {
19247
19436
  emit.warn(`ticket(s) blocking themselves, parked permanently: ${diag.selfBlocked.join(", ")}`);
19248
19437
  }
19249
- const sweep = planSweep(tickets, info, blocked, workModes);
19438
+ const sweep = planSweep(tickets, info, blocked, workModes, footprintPlan.waits);
19250
19439
  const holdReleases = planHoldReleases(tickets, tracker.contract);
19251
19440
  const stalled = planStalled(tickets, comments, ships, tracker.contract, holds2, Date.now(), workModes, stalledEvents);
19252
19441
  const skipped = skippedByMode(tickets, workModes);
@@ -19361,6 +19550,8 @@ async function decideCycle(o) {
19361
19550
  roster,
19362
19551
  ships,
19363
19552
  blocked,
19553
+ footprints: footprintPlan,
19554
+ footprintEvents,
19364
19555
  info,
19365
19556
  sweep,
19366
19557
  epicSync,
@@ -19476,7 +19667,11 @@ function writeDigest(o, d, role, stateDir, runId, own) {
19476
19667
  blocked: d.blocked,
19477
19668
  blockerInfo: d.info
19478
19669
  };
19479
- const body = role === "qa" ? qaDigest(input) : buildingDigest(input);
19670
+ const fp = d.footprintEvents;
19671
+ const recorded = fp ? d.tickets.filter((t) => fp.declared.has(t.id) && !["fixed", "qa", "verified"].includes(String(t.status))).map((t) => ({ ticket: displayKey(t), paths: footprintOf(t, fp.declared, fp.pushed) })) : [];
19672
+ const body = role === "qa" ? qaDigest(input) : `${buildingDigest(input)}
19673
+
19674
+ ${footprintDigestSection(recorded)}`;
19480
19675
  const text2 = own ? `${ownRunBanner(own)}
19481
19676
 
19482
19677
  ${body}` : body;
@@ -19558,11 +19753,11 @@ async function resolveOne(tracker, t, seat, approvedStatus, buildingStatus, affi
19558
19753
  return { ticket: t, claimed: false, contended, unservable, held, reaccepted: false, tookOverFrom: null };
19559
19754
  }
19560
19755
  if (affinity && t[affinity.column] !== affinity.shipId) {
19561
- const stamp = await stampResumption(tracker, t, affinity);
19562
- if (stamp.outcome === "stamped") {
19563
- return { ticket: stamp.ticket, claimed: false, contended, unservable, held, reaccepted: false, tookOverFrom: displacedHolder(t, affinity) };
19756
+ const stamp2 = await stampResumption(tracker, t, affinity);
19757
+ if (stamp2.outcome === "stamped") {
19758
+ return { ticket: stamp2.ticket, claimed: false, contended, unservable, held, reaccepted: false, tookOverFrom: displacedHolder(t, affinity) };
19564
19759
  }
19565
- (stamp.outcome === "held" ? held : contended).push(t.issue_id);
19760
+ (stamp2.outcome === "held" ? held : contended).push(t.issue_id);
19566
19761
  return "walk";
19567
19762
  }
19568
19763
  return { ticket: t, claimed: false, contended, unservable, held, reaccepted: false, tookOverFrom: null };
@@ -19745,9 +19940,9 @@ function worktreeForBranch(cwd, branch) {
19745
19940
  var stampOf = (e) => e.occurred_at ?? e.created_at ?? "";
19746
19941
  var priorBounces = (ticket, events) => {
19747
19942
  const mine = events.filter((e) => e.record_id === ticket.id);
19748
- const pushes = mine.filter((e) => e.event_type === "pushed").map(stampOf);
19943
+ const pushes2 = mine.filter((e) => e.event_type === "pushed").map(stampOf);
19749
19944
  return mine.filter(
19750
- (e) => e.event_type === "conflict_handed_back" && pushes.some((p) => p > stampOf(e))
19945
+ (e) => e.event_type === "conflict_handed_back" && pushes2.some((p) => p > stampOf(e))
19751
19946
  ).length;
19752
19947
  };
19753
19948
  var baseShaOf = (e) => {
@@ -19757,8 +19952,8 @@ var baseShaOf = (e) => {
19757
19952
  };
19758
19953
  var lastActedHandBack = (ticket, events) => {
19759
19954
  const mine = events.filter((e) => e.record_id === ticket.id);
19760
- const pushes = mine.filter((e) => e.event_type === "pushed").map(stampOf);
19761
- return mine.filter((e) => e.event_type === "conflict_handed_back" && pushes.some((p) => p > stampOf(e))).sort((a, b) => stampOf(b).localeCompare(stampOf(a)))[0];
19955
+ const pushes2 = mine.filter((e) => e.event_type === "pushed").map(stampOf);
19956
+ return mine.filter((e) => e.event_type === "conflict_handed_back" && pushes2.some((p) => p > stampOf(e))).sort((a, b) => stampOf(b).localeCompare(stampOf(a)))[0];
19762
19957
  };
19763
19958
  var MAX_ABSORBED_HANDBACKS = 2;
19764
19959
  function planConflictBounce(cwd, ticket, branch, base, paths, events, merged = []) {
@@ -19881,7 +20076,7 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
19881
20076
  handBackComment(b, merged),
19882
20077
  memberId,
19883
20078
  "conflict_handed_back",
19884
- b.baseSha ? { base_sha: b.baseSha } : void 0
20079
+ { ...b.baseSha ? { base_sha: b.baseSha } : {}, ...b.paths.length ? { paths: b.paths } : {} }
19885
20080
  ).catch((e) => {
19886
20081
  log.warn(`handed back, but the note failed to post: ${e.message}`, t);
19887
20082
  });
@@ -19958,14 +20153,14 @@ ${b.tail.trimEnd()}
19958
20153
  Nothing was written to \`${b.base}\` for this ticket; the rest of the release shipped without it.`;
19959
20154
  }
19960
20155
  function priorBuildFailures(ticket, events) {
19961
- const stamp = (e) => e.occurred_at ?? e.created_at ?? "";
20156
+ const stamp2 = (e) => e.occurred_at ?? e.created_at ?? "";
19962
20157
  const mine = events.filter((e) => e.record_id === ticket.id);
19963
- const pushes = mine.filter((e) => e.event_type === "pushed").map(stamp);
19964
- return mine.filter((e) => e.event_type === "build_failed" && pushes.some((p) => p > stamp(e))).length;
20158
+ const pushes2 = mine.filter((e) => e.event_type === "pushed").map(stamp2);
20159
+ return mine.filter((e) => e.event_type === "build_failed" && pushes2.some((p) => p > stamp2(e))).length;
19965
20160
  }
19966
20161
  function priorFailureNote(ticket, events) {
19967
- const stamp = (e) => e.occurred_at ?? e.created_at ?? "";
19968
- return events.filter((e) => e.record_id === ticket.id && e.event_type === "build_failed").sort((a, b) => stamp(a).localeCompare(stamp(b))).map((e) => e.message ?? "").pop();
20162
+ const stamp2 = (e) => e.occurred_at ?? e.created_at ?? "";
20163
+ return events.filter((e) => e.record_id === ticket.id && e.event_type === "build_failed").sort((a, b) => stamp2(a).localeCompare(stamp2(b))).map((e) => e.message ?? "").pop();
19969
20164
  }
19970
20165
  function failureComparison(b, previousNote) {
19971
20166
  const now = b.failingFiles ?? failingPaths(b.tail, b.cwd ?? "/\0");
@@ -20146,6 +20341,80 @@ async function applyStrandedVerified(writer, s, contract, operatorId, memberId,
20146
20341
  }
20147
20342
  }
20148
20343
 
20344
+ // src/right-of-way.ts
20345
+ var RIGHT_OF_WAY_MARKER = calloutHeader("NOTE", "Waiting For A Conflict Fix");
20346
+ var DEFERRED_EVENT = "right_of_way_deferred";
20347
+ var stampMs = (e) => Date.parse(e.occurred_at ?? e.created_at ?? "") || 0;
20348
+ var pathsOf = (e) => {
20349
+ const p = e.metadata?.paths;
20350
+ return Array.isArray(p) ? p.filter((x) => typeof x === "string" && x !== "") : [];
20351
+ };
20352
+ function handBacks(tickets, events, contract, now, ttlMinutes) {
20353
+ const none = { open: [], lapsed: [] };
20354
+ if (ttlMinutes <= 0) return none;
20355
+ const s = contract.statuses;
20356
+ const live2 = /* @__PURE__ */ new Set([s.building, s.handoff, s.verifying, s.verified]);
20357
+ const byId = new Map(tickets.map((t) => [t.id, t]));
20358
+ const newest = /* @__PURE__ */ new Map();
20359
+ for (const e of events) {
20360
+ if (e.event_type !== "conflict_handed_back" || !pathsOf(e).length) continue;
20361
+ const prev = newest.get(e.record_id);
20362
+ if (!prev || stampMs(e) > stampMs(prev)) newest.set(e.record_id, e);
20363
+ }
20364
+ const out = { open: [], lapsed: [] };
20365
+ for (const [id, e] of newest) {
20366
+ const ticket = byId.get(id);
20367
+ if (!ticket || !live2.has(ticket.status)) continue;
20368
+ const at = stampMs(e);
20369
+ if (events.some((x) => x.record_id === id && x.event_type === "conflict_escalated" && stampMs(x) > at)) continue;
20370
+ const hb = { ticket, at, paths: pathsOf(e), expiresAt: at + ttlMinutes * 6e4 };
20371
+ (now >= hb.expiresAt ? out.lapsed : out.open).push(hb);
20372
+ }
20373
+ const order = (a, b) => a.at - b.at || a.ticket.issue_id.localeCompare(b.ticket.issue_id);
20374
+ out.open.sort(order);
20375
+ out.lapsed.sort(order);
20376
+ return out;
20377
+ }
20378
+ var overlap = (a, b) => {
20379
+ const set = new Set(b);
20380
+ return a.filter((p) => set.has(p));
20381
+ };
20382
+ function planRightOfWay(candidates2, tickets, events, contract, now, ttlMinutes) {
20383
+ const { open, lapsed } = handBacks(tickets, events, contract, now, ttlMinutes);
20384
+ const own = new Map(open.map((h) => [h.ticket.id, h]));
20385
+ const deferrals = [];
20386
+ for (const c of candidates2) {
20387
+ const mine = own.get(c.ticket.id);
20388
+ const first = open.find((h) => h.ticket.id !== c.ticket.id && (!mine || mine.at > h.at || mine.at === h.at && mine.ticket.issue_id > h.ticket.issue_id) && overlap(c.paths, h.paths).length > 0);
20389
+ if (first) deferrals.push({ ticket: c.ticket, waitingFor: first.ticket, paths: overlap(c.paths, first.paths), since: first.at });
20390
+ }
20391
+ const lapsedUsed = lapsed.filter((h) => candidates2.some((c) => c.ticket.id !== h.ticket.id && overlap(c.paths, h.paths).length > 0));
20392
+ return { deferrals, lapsed: lapsedUsed };
20393
+ }
20394
+ function branchPaths(cwd, base, branch) {
20395
+ return (gitOk(cwd, ["diff", "--name-only", `${base}...${branch}`]) ?? "").split("\n").filter(Boolean);
20396
+ }
20397
+ var deferralReported = (d, events) => events.some((e) => e.record_id === d.ticket.id && e.event_type === DEFERRED_EVENT && e.metadata?.waiting_for === d.waitingFor.id && stampMs(e) >= d.since);
20398
+ function deferralComment(d, base, ttlMinutes) {
20399
+ const list = d.paths.map((p) => `\`${p}\``).join(", ");
20400
+ return `${RIGHT_OF_WAY_MARKER}
20401
+
20402
+ **Verified, and waiting its turn \u2014 not handed back.**
20403
+
20404
+ ${displayKey(d.waitingFor)} was handed back for a merge conflict in ${list}, which this branch also changes. Releasing this branch first would move \`${base}\` under it again, so the release leaves this ticket at \`verified\` and retries it each cycle until ${displayKey(d.waitingFor)} is verified and released, or until its right of way lapses (${ttlMinutes} minutes after the hand-back). Nothing is needed from anyone.`;
20405
+ }
20406
+ function deferredFromLog(tickets, events, contract, now, ttlMinutes) {
20407
+ const { open } = handBacks(tickets, events, contract, now, ttlMinutes);
20408
+ const out = [];
20409
+ for (const t of tickets) {
20410
+ if (t.status !== contract.statuses.verified) continue;
20411
+ const last = events.filter((e) => e.record_id === t.id && e.event_type === DEFERRED_EVENT).sort((a, b) => stampMs(b) - stampMs(a))[0];
20412
+ const hb = last && open.find((h) => h.ticket.id === last.metadata?.waiting_for && h.at <= stampMs(last));
20413
+ if (hb) out.push({ ticket: t, waitingFor: hb.ticket });
20414
+ }
20415
+ return out;
20416
+ }
20417
+
20149
20418
  // src/local-ref-skip.ts
20150
20419
  var LOCAL_REF_SKIP_MARKER = calloutHeader("WARNING", "Release Skipped");
20151
20420
  function localRefSkipComment(shipName2, problem) {
@@ -20909,8 +21178,8 @@ async function discoverPullRequests(i) {
20909
21178
  for (const t of candidates2) {
20910
21179
  const mine = pushed.filter((e) => e.record_id === t.id);
20911
21180
  if (mine.length === 0) continue;
20912
- const stamp = (e) => e.occurred_at ?? e.created_at ?? "";
20913
- const ordered = [...mine].sort((a, b) => Date.parse(stamp(a)) - Date.parse(stamp(b)));
21181
+ const stamp2 = (e) => e.occurred_at ?? e.created_at ?? "";
21182
+ const ordered = [...mine].sort((a, b) => Date.parse(stamp2(a)) - Date.parse(stamp2(b)));
20914
21183
  const branch = pushedBranchOf(ordered[ordered.length - 1].message);
20915
21184
  if (!branch) continue;
20916
21185
  const target = repoTargetFor(i.route, t.repo_id);
@@ -20924,7 +21193,7 @@ async function discoverPullRequests(i) {
20924
21193
  }
20925
21194
  if (!token) continue;
20926
21195
  try {
20927
- const pull = selectPull(await listPulls(host, remote, branch, token, i.fetcher), stamp(ordered[0]) || null);
21196
+ const pull = selectPull(await listPulls(host, remote, branch, token, i.fetcher), stamp2(ordered[0]) || null);
20928
21197
  if (!pull) continue;
20929
21198
  const patch2 = { [cols.prUrl]: pull.url };
20930
21199
  if (have.prRef && blank(t[cols.prRef])) patch2[cols.prRef] = pull.url;
@@ -21619,14 +21888,16 @@ function reportHeld(o, held) {
21619
21888
  async function runRelease(o) {
21620
21889
  const movedPast2 = [];
21621
21890
  const localRefSkips = [];
21622
- const out = await runReleaseCycle(o, movedPast2, localRefSkips);
21891
+ const rightOfWay = { deferrals: [], lapsed: [] };
21892
+ const out = await runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay);
21623
21893
  return {
21624
21894
  ...out,
21625
21895
  ...movedPast2.length ? { movedPast: movedPast2 } : {},
21626
- ...localRefSkips.length ? { localRefSkips } : {}
21896
+ ...localRefSkips.length ? { localRefSkips } : {},
21897
+ ...rightOfWay.deferrals.length || rightOfWay.lapsed.length ? { rightOfWay } : {}
21627
21898
  };
21628
21899
  }
21629
- async function runReleaseCycle(o, movedPast2, localRefSkips) {
21900
+ async function runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay) {
21630
21901
  const scoped = (msg) => o.scope ? `${o.scope}: ${msg}` : msg;
21631
21902
  const tagPattern = o.repo.release.tagPattern ?? "v*";
21632
21903
  o.emit.enter("release");
@@ -21673,6 +21944,41 @@ async function runReleaseCycle(o, movedPast2, localRefSkips) {
21673
21944
  }
21674
21945
  if (drop.size) releasable = releasable.filter((t) => !drop.has(t.id));
21675
21946
  }
21947
+ if (o.rightOfWayEvents?.length && (o.repo.release.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES) > 0) {
21948
+ const baseRef = remoteBranchExists(o.cwd, o.repo.branch.remote, o.repo.branch.base) ? `${o.repo.branch.remote}/${o.repo.branch.base}` : o.repo.branch.base;
21949
+ const candidates2 = [];
21950
+ for (const t of releasable) {
21951
+ if (t.status !== o.contract.statuses.verified) continue;
21952
+ const branch = locateBranchForTicket(o.cwd, o.repo, t)?.branch;
21953
+ if (branch) candidates2.push({ ticket: t, paths: branchPaths(o.cwd, baseRef, branch) });
21954
+ }
21955
+ const plan = planRightOfWay(
21956
+ candidates2,
21957
+ o.tickets,
21958
+ o.rightOfWayEvents,
21959
+ o.contract,
21960
+ (o.now ?? Date.now)(),
21961
+ o.repo.release.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES
21962
+ );
21963
+ rightOfWay.deferrals.push(...plan.deferrals);
21964
+ rightOfWay.lapsed.push(...plan.lapsed);
21965
+ for (const h of plan.lapsed) {
21966
+ o.emit.warn(
21967
+ `${displayKey(h.ticket)}'s right of way over ${h.paths.join(", ")} lapsed after ${o.repo.release.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES} minutes without it coming back verified \u2014 not deferring other branches for it`,
21968
+ { ticket: h.ticket.issue_id, step: "release" }
21969
+ );
21970
+ }
21971
+ for (const d of plan.deferrals) {
21972
+ o.emit.emit(
21973
+ `not releasing ${displayKey(d.ticket)} this cycle: waiting for ${displayKey(d.waitingFor)}, handed back for a conflict in ${d.paths.join(", ")}`,
21974
+ { ticket: d.ticket.issue_id, step: "release" }
21975
+ );
21976
+ }
21977
+ if (plan.deferrals.length) {
21978
+ const waiting = new Set(plan.deferrals.map((d) => d.ticket.id));
21979
+ releasable = releasable.filter((t) => !waiting.has(t.id));
21980
+ }
21981
+ }
21676
21982
  const { remote, base } = o.repo.branch;
21677
21983
  const inPlace = o.dryRun || !!o.mergeOnly || !remoteBranchExists(o.cwd, remote, base);
21678
21984
  const remoteRef = `${remote}/${base}`;
@@ -25471,11 +25777,13 @@ function renderStatus(v, opts) {
25471
25777
  const own = byRecent(v.attention, (a) => a.since);
25472
25778
  const others = v.ships.filter((s) => s.name !== v.ship.name && s.attention.length);
25473
25779
  const unsafe = v.repos.filter((r) => r.unsafeDetail);
25474
- if (own.length || others.length || unsafe.length || v.heldReleases.length || v.starved) {
25780
+ const deferred = v.deferredReleases ?? [];
25781
+ if (own.length || others.length || unsafe.length || v.heldReleases.length || deferred.length || v.starved) {
25475
25782
  out.push("needs attention:");
25476
25783
  for (const i of own) out.push(` ${i.kind} \u2014 ${i.message}`);
25477
25784
  for (const r of unsafe) out.push(` base ${r.name} \u2014 UNSAFE, no worktree cuts or releases: ${r.unsafeDetail}`);
25478
25785
  for (const l of v.heldReleases) out.push(` release: ${l}`);
25786
+ for (const l of deferred) out.push(` deferred: ${l}`);
25479
25787
  if (v.starved) {
25480
25788
  out.push(` waiting: ${v.starved.ticket} for ${since(v.starved.since, now)} (passed over ${plural(v.starved.streak, "cycle")} running)`);
25481
25789
  }
@@ -25491,6 +25799,9 @@ function renderStatus(v, opts) {
25491
25799
  for (const t of shown) out.push(` ${waitingLine(t)}`);
25492
25800
  if (shown.length < sorted2.length) out.push(` \u2026 ${sorted2.length - shown.length} more (\`crew status --verbose\` lists all)`);
25493
25801
  }
25802
+ for (const w of v.waits ?? []) {
25803
+ out.push(`waiting: ${w.ticket} \u2014 for ${w.waitingFor.join(", ")} on ${describeFiles(w.files)}`);
25804
+ }
25494
25805
  const notable = v.repos.filter((r) => verbose || r.notable);
25495
25806
  for (const r of notable) out.push(`releaser: ${r.name} \u2014 ${r.releaser}`);
25496
25807
  const rest = v.repos.length - notable.length;
@@ -27710,7 +28021,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
27710
28021
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
27711
28022
  import { join as join60 } from "path";
27712
28023
  function builtVersion() {
27713
- return true ? "0.154.1" : null;
28024
+ return true ? "0.156.0" : null;
27714
28025
  }
27715
28026
  var REBUILD_HINT = "rebuild with npm run build";
27716
28027
  function newestMtime(path) {
@@ -29940,6 +30251,7 @@ function usage(problem, requested = false) {
29940
30251
  crew shell-init [--shell zsh|bash|fish] print the periscope shell function (install: eval "$(crew shell-init)")
29941
30252
  crew worktree [route] NNN cut (or refresh) this run's worktree for a ticket from the remote; prints its path
29942
30253
  crew unassign [route] NNN hand back a session's ticket \u2014 clears assignee, next cycle picks it up
30254
+ crew footprint [route] NNN [path...] record the files a ticket will change (once), then print PROCEED or YIELD against active work
29943
30255
  crew sandbox cache [--refresh|--prune|--reset] [--json] list the sandbox cache volume's mirrors; --refresh runs the daemon's cache pass once (creates missing mirrors), --prune drops unserved repositories, --reset recreates the volume
29944
30256
  crew sync [route] fast-forward the checkout and its worktrees from the remote
29945
30257
  crew pause|resume [route] [R|release] pause everything, one role, or releases only (merge/deploy/release; passengers keeps running).
@@ -30069,6 +30381,7 @@ var KNOWN_COMMANDS = /* @__PURE__ */ new Set([
30069
30381
  "status",
30070
30382
  "sync",
30071
30383
  "unassign",
30384
+ "footprint",
30072
30385
  "uninstall",
30073
30386
  "watch",
30074
30387
  "whoami",
@@ -31469,9 +31782,18 @@ ${changed2.map((c) => ` - ${c}
31469
31782
  if (sha) verifiedShas.set(t.id, sha);
31470
31783
  }
31471
31784
  }
31785
+ let rightOfWayEvents;
31786
+ if (verifiedTickets.length >= 1 && repo.release.mode !== "external") {
31787
+ try {
31788
+ rightOfWayEvents = [...await tracker.events("conflict_handed_back"), ...await tracker.events("conflict_escalated")];
31789
+ } catch (e) {
31790
+ remit.warn(`could not read hand-back events; not deferring any branch: ${e.message}`);
31791
+ }
31792
+ }
31472
31793
  const outcome = await runRelease({
31473
31794
  cwd: target.dir,
31474
31795
  repo,
31796
+ rightOfWayEvents,
31475
31797
  reloadRepo: (dir) => resolveRepoConfig(loadRepoConfig(dir), {
31476
31798
  hooks: { ...c.hooks, ...o?.hooks },
31477
31799
  labels: { ...c.labels, ...o?.labels },
@@ -31597,6 +31919,25 @@ ${changed2.map((c) => ` - ${c}
31597
31919
  remit.warn(`could not note the skipped release on the board: ${e.message}`, { step: "merge" });
31598
31920
  }
31599
31921
  }
31922
+ if (outcome.rightOfWay?.deferrals.length && !dryRun) {
31923
+ try {
31924
+ const reported2 = await tracker.events(DEFERRED_EVENT);
31925
+ const seat = releaseSeat(c);
31926
+ const minutes = repo.release.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES;
31927
+ for (const d of outcome.rightOfWay.deferrals) {
31928
+ if (deferralReported(d, reported2)) continue;
31929
+ await tracker.postEvent(
31930
+ d.ticket.id,
31931
+ deferralComment(d, repo.branch.base, minutes),
31932
+ seat,
31933
+ DEFERRED_EVENT,
31934
+ { waiting_for: d.waitingFor.id, paths: d.paths }
31935
+ );
31936
+ }
31937
+ } catch (e) {
31938
+ remit.warn(`could not note the deferred release on the board: ${e.message}`, { step: "release" });
31939
+ }
31940
+ }
31600
31941
  if (outcome.externalClosures?.length) {
31601
31942
  await applyExternalClosures(tracker, outcome.externalClosures, tracker.contract, remit, dryRun, target.dir);
31602
31943
  }
@@ -34585,7 +34926,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
34585
34926
  }
34586
34927
  await trD.updateTicket(id, patch2);
34587
34928
  },
34588
- postPushed: (id, sha, rem, branch) => trD.postEvent(id, pushedEventBody(sha, rem, branch), memberD, "pushed"),
34929
+ postPushed: (id, sha, rem, branch) => trD.postEvent(id, pushedEventBody(sha, rem, branch), memberD, "pushed", pushedEventExtra(repoD.dir, rem, base, sha)),
34589
34930
  stopTunnel: (id) => {
34590
34931
  const sc = readPeriscopeSidecars(cfg.ship.stateDir).find((x) => x.ticketRecordId === id);
34591
34932
  return sc && stopRecordedTunnel(sc) ? 1 : 0;
@@ -34922,6 +35263,43 @@ ${where.join("\n")}`);
34922
35263
  }
34923
35264
  break;
34924
35265
  }
35266
+ case "footprint": {
35267
+ const args = positional.slice(1);
35268
+ const at = args.findIndex((a) => parseTicketNumber(a) !== null);
35269
+ const n = at >= 0 ? parseTicketNumber(args[at]) : null;
35270
+ if (!n) {
35271
+ die("crew footprint", "need a ticket number (326, ISSUE-326, or TABL-326)", "`crew footprint 326 src/a.ts src/b.ts`");
35272
+ }
35273
+ const trF = new Tracker(route2, cfg.ship);
35274
+ const cF = trF.contract;
35275
+ const openF = await trF.openTickets();
35276
+ const ticketF = openF.find((t) => t[cF.columns.key] === `ISSUE-${n}`);
35277
+ if (!ticketF) {
35278
+ die("crew footprint", `no open ticket ISSUE-${n} on ${route2.route}`, "`crew inbox` to list open tickets");
35279
+ }
35280
+ let evF = await readFootprintEvents(trF);
35281
+ if (!evF.declared.has(ticketF.id)) {
35282
+ const listed = countedPaths(args.slice(at + 1));
35283
+ if (dryRun) {
35284
+ emit.emit(`would record a footprint of ${listed.length} file(s) on ${displayKey(ticketF)}`);
35285
+ break;
35286
+ }
35287
+ const seatF = route2.resolved?.seats.dev ?? route2.resolved?.operator ?? "";
35288
+ await trF.postEvent(
35289
+ ticketF.id,
35290
+ `footprint: ${listed.length ? listed.join(", ") : "none given"}`,
35291
+ seatF,
35292
+ FOOTPRINT_DECLARED_EVENT,
35293
+ { paths: listed }
35294
+ );
35295
+ evF = await readFootprintEvents(trF);
35296
+ if (!evF.declared.has(ticketF.id)) evF.declared.set(ticketF.id, { paths: listed, at: (/* @__PURE__ */ new Date()).toISOString() });
35297
+ }
35298
+ const verdictF = mustYieldTo(ticketF, { tickets: openF, ...evF, ignoreByRepo: ignoreByRepo(route2) });
35299
+ process.stdout.write(`${footprintVerdictText(displayKey(ticketF), verdictF)}
35300
+ `);
35301
+ break;
35302
+ }
34925
35303
  case "sync": {
34926
35304
  emit.enter("worktree");
34927
35305
  let tracked2 = 0;
@@ -35635,13 +36013,23 @@ ${where.join("\n")}`);
35635
36013
  }
35636
36014
  const shipAttention = openShipAttention(state);
35637
36015
  let heldReleases = [];
36016
+ let waitViews = [];
36017
+ let deferredReleases = [];
35638
36018
  try {
35639
36019
  const open = await statusTracker.openTickets();
35640
- heldReleases = describeHeld(heldByBlockers(
35641
- open,
35642
- statusTracker.contract.statuses.verified,
35643
- blockerInfoMap(open, await statusTracker.ticketsByIds(missingBlockerIds(open)))
35644
- ));
36020
+ const blockerInfo = blockerInfoMap(open, await statusTracker.ticketsByIds(missingBlockerIds(open)));
36021
+ heldReleases = describeHeld(heldByBlockers(open, statusTracker.contract.statuses.verified, blockerInfo));
36022
+ waitViews = [...planFootprintsFor(route2, open, await readFootprintEvents(statusTracker), computeBlockedIds(open, blockerInfo)).waits.values()].map((w) => ({ ticket: displayKey(w.ticket), waitingFor: w.waitingFor, files: w.files }));
36023
+ const minutes = Math.min(...(await resolvedRepos(route2)).map((r) => r.config.release.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES), DEFAULT_RIGHT_OF_WAY_MINUTES);
36024
+ if (open.some((t) => t.status === statusTracker.contract.statuses.verified)) {
36025
+ deferredReleases = deferredFromLog(
36026
+ open,
36027
+ [...await statusTracker.events(DEFERRED_EVENT), ...await statusTracker.events("conflict_handed_back"), ...await statusTracker.events("conflict_escalated")],
36028
+ statusTracker.contract,
36029
+ Date.now(),
36030
+ minutes
36031
+ ).map((d) => `${displayKey(d.ticket)} waits for ${displayKey(d.waitingFor)}, handed back for a merge conflict`);
36032
+ }
35645
36033
  } catch {
35646
36034
  }
35647
36035
  const repoViews = [];
@@ -35682,6 +36070,8 @@ ${where.join("\n")}`);
35682
36070
  })),
35683
36071
  repos: repoViews,
35684
36072
  heldReleases,
36073
+ waits: waitViews,
36074
+ deferredReleases,
35685
36075
  starved: waiting ? { ticket: waiting.ticket, since: waiting.since, streak: fairness.streak() } : void 0,
35686
36076
  ships: shipRows.map((s) => ({
35687
36077
  name: s.name ?? "(unnamed)",
@@ -24799,6 +24799,7 @@ var RELEASE_KEYS = /* @__PURE__ */ new Set([
24799
24799
  "ci",
24800
24800
  "verify",
24801
24801
  "isolateFailures",
24802
+ "rightOfWayMinutes",
24802
24803
  "versioning",
24803
24804
  "versionFiles",
24804
24805
  "changelog",
@@ -24809,6 +24810,12 @@ var VERSIONINGS = ["auto", "none"];
24809
24810
  var CI_KEYS = /* @__PURE__ */ new Set(["provider", "ref"]);
24810
24811
  var VERIFY_KEYS = /* @__PURE__ */ new Set(["match", "timeoutSeconds", "intervalSeconds"]);
24811
24812
  var ISOLATE_KEYS = /* @__PURE__ */ new Set(["maxCandidates"]);
24813
+ function parseRightOfWayMinutes(raw, fail2) {
24814
+ if (raw === void 0 || raw === null) return void 0;
24815
+ const n = Number(raw);
24816
+ if (!Number.isInteger(n) || n < 0) throw fail2(`release.rightOfWayMinutes must be a non-negative integer (got "${raw}")`);
24817
+ return n;
24818
+ }
24812
24819
  function parseIsolateMax(raw, where, fail2) {
24813
24820
  if (raw === void 0 || raw === null) return void 0;
24814
24821
  const n = Number(raw);
@@ -25033,6 +25040,7 @@ function parseRepoConfig(text, file) {
25033
25040
  "release.isolateFailures",
25034
25041
  (m) => new RepoConfigError(`${file}: ${m}`)
25035
25042
  );
25043
+ const rightOfWay = parseRightOfWayMinutes(raw.release?.rightOfWayMinutes, (m) => new RepoConfigError(`${file}: ${m}`));
25036
25044
  const versioning = String(raw.release?.versioning ?? "auto");
25037
25045
  if (!VERSIONINGS.includes(versioning)) {
25038
25046
  throw new RepoConfigError(`${file}: release.versioning must be auto|none (got "${versioning}")`);
@@ -25110,6 +25118,7 @@ function parseRepoConfig(text, file) {
25110
25118
  ci: { provider, ref: raw.release?.ci?.ref ? String(raw.release.ci.ref) : void 0 },
25111
25119
  verify,
25112
25120
  isolateFailures: isolateMax === void 0 ? void 0 : { maxCandidates: isolateMax },
25121
+ rightOfWayMinutes: rightOfWay,
25113
25122
  versioning,
25114
25123
  versionFiles,
25115
25124
  tag,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.154.1",
3
+ "version": "0.156.0",
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",