@tablation/crew 0.151.1 → 0.151.3

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 +156 -87
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -9801,7 +9801,7 @@ var Tracker = class {
9801
9801
  ...auth.shipId || extra ? { metadata: { ...auth.shipId ? { ship_id: auth.shipId } : {}, ...extra } } : {}
9802
9802
  });
9803
9803
  if (res.status === 404) throw new ConfigError(EVENT_LOG_MISSING);
9804
- if (!res.ok) throw new Error(`posting a ${type} event failed: HTTP ${res.status}`);
9804
+ if (!res.ok) throw new Error(`posting a ${type} event failed: HTTP ${res.status}${await refusalReason(res)}`);
9805
9805
  }
9806
9806
  /** A ticket comment under a seat's identity (CREW-2363: the replayed hand-off comment). */
9807
9807
  async postComment(ticketId, body, memberId) {
@@ -10221,6 +10221,22 @@ var Tracker = class {
10221
10221
  });
10222
10222
  }
10223
10223
  };
10224
+ async function refusalReason(res) {
10225
+ try {
10226
+ const text2 = (await res.text()).trim();
10227
+ if (!text2) return "";
10228
+ let msg = text2;
10229
+ try {
10230
+ const j = JSON.parse(text2);
10231
+ if (typeof j.message === "string") msg = j.message;
10232
+ else if (Array.isArray(j.message)) msg = j.message.join("; ");
10233
+ } catch {
10234
+ }
10235
+ return `: ${msg.replace(/\s+/g, " ").slice(0, 300)}`;
10236
+ } catch {
10237
+ return "";
10238
+ }
10239
+ }
10224
10240
 
10225
10241
  // src/ticket-branch.ts
10226
10242
  function branchRenderer(t, role, lowercase) {
@@ -10324,14 +10340,14 @@ async function replayPendingHandoffs(i) {
10324
10340
  const t = await i.writer.ticket(rec.ticketRecordId);
10325
10341
  const st = i.contract.statuses;
10326
10342
  if (!seatId || t.status !== st.building || rec.patch.status !== st.handoff) {
10327
- i.log.emit(`${t.issue_id}: pending hand-off no longer applies (ticket is at ${t.status}) \u2014 dropped`, at);
10343
+ i.log.emit(`${displayKey(t)}: pending hand-off no longer applies (ticket is at ${t.status}) \u2014 dropped`, at);
10328
10344
  removePendingHandoff(i.stateDir, rec.ticketRecordId);
10329
10345
  continue;
10330
10346
  }
10331
10347
  const co = i.checkout(t);
10332
10348
  const v = co ? inspectHandoff(co.dir, co.cfg, t, rec.role) : null;
10333
10349
  if (!v || v.kind === "bounce") {
10334
- i.log.warn(`${t.issue_id}: pending hand-off dropped \u2014 ${v ? v.reason : "this ship has no checkout of the ticket's repo"}`, at);
10350
+ i.log.warn(`${displayKey(t)}: pending hand-off dropped \u2014 ${v ? v.reason : "this ship has no checkout of the ticket's repo"}`, at);
10335
10351
  removePendingHandoff(i.stateDir, rec.ticketRecordId);
10336
10352
  continue;
10337
10353
  }
@@ -10349,7 +10365,7 @@ async function replayPendingHandoffs(i) {
10349
10365
  await i.writer.postEvent(t.id, pushedEventBody(v.sha, v.remote, v.branch), seatId, "pushed");
10350
10366
  await i.writer.updateTicket(t.id, rec.patch);
10351
10367
  removePendingHandoff(i.stateDir, rec.ticketRecordId);
10352
- i.log.emit(`${t.issue_id}: replayed a pending hand-off at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, at);
10368
+ i.log.emit(`${displayKey(t)}: replayed a pending hand-off at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, at);
10353
10369
  landed.push(t.id);
10354
10370
  } catch (e) {
10355
10371
  const attempts = rec.attempts + 1;
@@ -10469,9 +10485,9 @@ function holdWarnings(tickets, ships, contract, humanHolds, now = Date.now()) {
10469
10485
  if (t.assignee_id && humanHolds.has(t.assignee_id)) continue;
10470
10486
  const holder = ticketHolderShipId(t, contract);
10471
10487
  if (!holder) {
10472
- out.push(`${t.issue_id} (${t.status}) has no ${contract.columns.heldBy} \u2014 any ship may take it`);
10488
+ out.push(`${displayKey(t)} (${t.status}) has no ${contract.columns.heldBy} \u2014 any ship may take it`);
10473
10489
  } else if (!shipIsAlive(ships.find((s) => s.id === holder), now)) {
10474
- out.push(`${t.issue_id} (${t.status}) is held by ${shipName(ships, holder)}, which has not been seen for ${SHIP_DEAD_AFTER_CYCLES}+ cycles`);
10490
+ out.push(`${displayKey(t)} (${t.status}) is held by ${shipName(ships, holder)}, which has not been seen for ${SHIP_DEAD_AFTER_CYCLES}+ cycles`);
10475
10491
  }
10476
10492
  }
10477
10493
  return out;
@@ -10729,6 +10745,33 @@ ${shipName2 ? `Ship: ${shipName2}
10729
10745
 
10730
10746
  ${v.reason[0].toUpperCase()}${v.reason.slice(1)}. ${pushError ? ` The runner tried a plain push and git refused it: \`${pushError}\`.` : ""} Set back to \`in_progress\`, still held by this ship; push with a plain \`git push --set-upstream ${v.remote} <branch>\` (never \`--force\`) and set \`fixed\` again. Your brief authorizes this push: it is the hand-off, not a release, so do it now rather than asking for permission.`;
10731
10747
  }
10748
+ var NOTE_BUDGET = 4800;
10749
+ function boundNote(note, budget = NOTE_BUDGET) {
10750
+ if (note.length <= budget) return note;
10751
+ const tail3 = "\n\n(note cut: it was longer than the event log accepts)";
10752
+ return note.slice(0, budget - tail3.length) + tail3;
10753
+ }
10754
+ async function deliverNote(i, ticketId, note, type, log) {
10755
+ const body = boundNote(note);
10756
+ try {
10757
+ await i.writer.postEvent(ticketId, body, i.seatId, type);
10758
+ return true;
10759
+ } catch (e) {
10760
+ const eventWhy = e.message;
10761
+ if (!i.writer.postComment) {
10762
+ i.log.warn(`the ${type} note could not be posted: ${eventWhy}`, log);
10763
+ return false;
10764
+ }
10765
+ try {
10766
+ await i.writer.postComment(ticketId, body, i.seatId);
10767
+ i.log.warn(`the ${type} note was refused by the event log (${eventWhy}); posted it as a comment instead`, log);
10768
+ return true;
10769
+ } catch (c) {
10770
+ i.log.warn(`the ${type} note could not be posted as an event (${eventWhy}) or as a comment (${c.message})`, log);
10771
+ return false;
10772
+ }
10773
+ }
10774
+ }
10732
10775
  async function postPushed(i, ticketId, sha, remote, branch, log) {
10733
10776
  await i.writer.postEvent(ticketId, pushedEventBody(sha, remote, branch), i.seatId, "pushed");
10734
10777
  const url = i.branchLink?.url(branch);
@@ -10768,7 +10811,13 @@ async function missingAcceptance(i, t) {
10768
10811
  return best;
10769
10812
  }
10770
10813
  function acceptanceBounceComment(missing, shipName2, judged, all = []) {
10771
- return `${ACCEPTANCE_BOUNCED_MARKER}
10814
+ const quotedNone = all.length > 0 && missing.length >= all.length;
10815
+ const build = (cut) => {
10816
+ const shown = (ls) => {
10817
+ const kept = cut > 0 ? ls.slice(0, Math.max(1, ls.length - cut)).map((l) => l.length > 200 ? `${l.slice(0, 200)}\u2026` : l) : ls;
10818
+ return kept.length < ls.length ? [...kept, `(\u2026 ${ls.length - kept.length} more in the ticket's Acceptance section)`] : kept;
10819
+ };
10820
+ const head = `${ACCEPTANCE_BOUNCED_MARKER}
10772
10821
 
10773
10822
  **Hand-off bounced: the hand-off comment does not quote every line of the ticket's Acceptance section.**
10774
10823
 
@@ -10776,16 +10825,27 @@ ${shipName2 ? `Ship: ${shipName2}
10776
10825
 
10777
10826
  ` : ""}${judged ? `Judged the comment posted at ${judged}; no comment this run quoted every line.
10778
10827
 
10779
- ` : "This seat has no comment on the ticket.\n\n"}Not quoted verbatim:
10780
- ${missing.map((l) => `- ${l}`).join("\n")}
10828
+ ` : "This seat has no comment on the ticket.\n\n"}`;
10829
+ const list = quotedNone ? "" : `Not quoted verbatim:
10830
+ ${shown(missing).map((l) => `- ${l}`).join("\n")}
10781
10831
 
10782
- Set back to \`in_progress\`. Post a comment that lists every Acceptance line verbatim, each followed by the test, command or manual check that exercised it in this run and its result (a line you could not exercise is listed with the reason, never omitted), then set \`fixed\` again. The branch is already pushed.${all.length > 0 ? `
10832
+ `;
10833
+ const act = `Set back to \`in_progress\`. Post a comment that lists every Acceptance line verbatim, each followed by the test, command or manual check that exercised it in this run and its result (a line you could not exercise is listed with the reason, never omitted), then set \`fixed\` again. The branch is already pushed.`;
10834
+ const block = all.length > 0 ? `
10783
10835
 
10784
- Copy this block into the comment and fill in each result:
10836
+ ${quotedNone ? "No line was quoted. " : ""}Copy this block into the comment and fill in each result:
10785
10837
 
10786
10838
  \`\`\`
10787
- ${acceptanceChecklistBlock(all)}
10788
- \`\`\`` : ""}`;
10839
+ ${acceptanceChecklistBlock(shown(all))}
10840
+ \`\`\`` : "";
10841
+ return `${head}${list}${act}${block}`;
10842
+ };
10843
+ const most = Math.max(all.length, missing.length);
10844
+ for (let cut = 0; cut < most; cut++) {
10845
+ const note = build(cut === 0 ? 0 : cut);
10846
+ if (note.length <= NOTE_BUDGET) return note;
10847
+ }
10848
+ return boundNote(build(most));
10789
10849
  }
10790
10850
  async function enforceHandoff(i) {
10791
10851
  try {
@@ -10794,12 +10854,12 @@ async function enforceHandoff(i) {
10794
10854
  const log = { ticket: t.issue_id, step: "handoff" };
10795
10855
  const claimed = [st.verifying, st.verified, st.deployed].some((s) => s && t.status === s);
10796
10856
  if (t.status !== st.handoff && !claimed) {
10797
- i.log.emit(`${t.issue_id} is at ${t.status}, not handed off \u2014 nothing to check`, log);
10857
+ i.log.emit(`${displayKey(t)} is at ${t.status}, not handed off \u2014 nothing to check`, log);
10798
10858
  return { kind: "not-handed-off" };
10799
10859
  }
10800
10860
  const v = i.origin ? inspectRemoteHandoff(i.origin, i.cfg, t, i.role) : inspectHandoff(i.dir, i.cfg, t, i.role);
10801
10861
  if (v.kind === "unverified") {
10802
- i.log.warn(`${t.issue_id} is at ${t.status} but the push was not checked: ${v.why}`, log);
10862
+ i.log.warn(`${displayKey(t)} is at ${t.status} but the push was not checked: ${v.why}`, log);
10803
10863
  return { kind: "unverified", why: v.why };
10804
10864
  }
10805
10865
  if (v.kind === "pushed" && !claimed) {
@@ -10807,42 +10867,43 @@ async function enforceHandoff(i) {
10807
10867
  if (gap) {
10808
10868
  const heldNow = i.hold ? t[i.hold.column] : void 0;
10809
10869
  if (i.hold && heldNow && heldNow !== i.hold.shipId || await takenOverSince(i, t.id)) {
10810
- i.log.warn(`${t.issue_id} is held by another ship now \u2014 the acceptance check is stale, left alone`, log);
10870
+ i.log.warn(`${displayKey(t)} is held by another ship now \u2014 the acceptance check is stale, left alone`, log);
10811
10871
  return { kind: "unverified", why: "ticket is held by another ship" };
10812
10872
  }
10873
+ if (!await deliverNote(i, t.id, acceptanceBounceComment(gap.missing, i.shipName, gap.judged, gap.all), "bounced", log)) {
10874
+ i.log.warn(`${displayKey(t)} lacks the acceptance checklist but the bounce note could not be delivered \u2014 left at ${t.status}, guard outcome unverified`, log);
10875
+ return { kind: "unverified", why: "the acceptance bounce note could not be posted" };
10876
+ }
10813
10877
  await i.writer.updateTicket(t.id, {
10814
10878
  status: i.contract.statuses.building,
10815
10879
  // CREW-2962: the hand-off may have assigned QA's seat; a bounce is the building seat's again.
10816
10880
  assignee_id: i.seatId,
10817
10881
  ...i.hold && !heldNow ? { [i.hold.column]: i.hold.shipId } : {}
10818
10882
  });
10819
- await i.writer.postEvent(t.id, acceptanceBounceComment(gap.missing, i.shipName, gap.judged, gap.all), i.seatId, "bounced").catch(() => {
10820
- i.log.warn("bounced, but the note failed to post", log);
10821
- });
10822
- i.log.warn(`${t.issue_id} bounced back to ${i.contract.statuses.building}: hand-off comment lacks the acceptance checklist`, log);
10883
+ i.log.warn(`${displayKey(t)} bounced back to ${i.contract.statuses.building}: hand-off comment lacks the acceptance checklist`, log);
10823
10884
  return { kind: "bounced" };
10824
10885
  }
10825
10886
  }
10826
10887
  if (v.kind === "pushed") {
10827
10888
  await postPushed(i, t.id, v.sha, v.remote, v.branch, log);
10828
- i.log.emit(`${t.issue_id} pushed at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, log);
10889
+ i.log.emit(`${displayKey(t)} pushed at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, log);
10829
10890
  return { kind: "pushed", sha: v.sha };
10830
10891
  }
10831
10892
  if (claimed) {
10832
- i.log.warn(`${t.issue_id} is at ${t.status} but its branch is not on the remote at HEAD: ${v.reason}`, log);
10893
+ i.log.warn(`${displayKey(t)} is at ${t.status} but its branch is not on the remote at HEAD: ${v.reason}`, log);
10833
10894
  return { kind: "failed", why: v.reason };
10834
10895
  }
10835
10896
  const heldBy = i.hold ? t[i.hold.column] : void 0;
10836
10897
  if (i.hold && heldBy && heldBy !== i.hold.shipId) {
10837
- i.log.warn(`${t.issue_id} is held by another ship now \u2014 this run's hand-off check is stale, left alone`, log);
10898
+ i.log.warn(`${displayKey(t)} is held by another ship now \u2014 this run's hand-off check is stale, left alone`, log);
10838
10899
  return { kind: "unverified", why: "ticket is held by another ship" };
10839
10900
  }
10840
10901
  if (await takenOverSince(i, t.id)) {
10841
- i.log.warn(`${t.issue_id} was taken over by another ship during this run \u2014 left alone`, log);
10902
+ i.log.warn(`${displayKey(t)} was taken over by another ship during this run \u2014 left alone`, log);
10842
10903
  return { kind: "unverified", why: "ticket was taken over during this run" };
10843
10904
  }
10844
10905
  if (!v.local && !i.origin) {
10845
- i.log.warn(`${t.issue_id} has no local branch on this ship, so it is not this ship's hand-off to bounce: ${v.reason}`, log);
10906
+ i.log.warn(`${displayKey(t)} has no local branch on this ship, so it is not this ship's hand-off to bounce: ${v.reason}`, log);
10846
10907
  return { kind: "unverified", why: "no local branch on this ship" };
10847
10908
  }
10848
10909
  let pushError;
@@ -10858,25 +10919,26 @@ async function enforceHandoff(i) {
10858
10919
  `The runner pushed \`${again.branch}\` to \`${again.remote}\` on ${i.shipName ? `${i.shipName}'s` : "this ship's"} behalf: the ${i.role} seat set \`${i.contract.statuses.handoff}\` without pushing. Plain fast-forward push.${i.cfg.hooks.ci_status ? " The repo's `ci_status` hook was NOT run by the hand-off guard, so CI was not checked by the builder." : ""}`,
10859
10920
  i.seatId,
10860
10921
  "pushed_by_runner"
10861
- ).catch(() => i.log.warn("pushed, but the note failed to post", log));
10862
- i.log.emit(`${t.issue_id}: pushed ${again.branch} to ${again.remote} on the seat's behalf at ${again.sha.slice(0, 7)} \u2014 handed on to QA`, log);
10922
+ ).catch((e) => i.log.warn(`pushed, but the note failed to post: ${e.message}`, log));
10923
+ i.log.emit(`${displayKey(t)}: pushed ${again.branch} to ${again.remote} on the seat's behalf at ${again.sha.slice(0, 7)} \u2014 handed on to QA`, log);
10863
10924
  return { kind: "pushed", sha: again.sha };
10864
10925
  }
10865
10926
  pushError = `the push succeeded but ${again.kind === "bounce" ? again.reason : again.why}`;
10866
10927
  } catch (e) {
10867
10928
  pushError = e.message;
10868
10929
  }
10869
- i.log.warn(`${t.issue_id}: the runner's own push failed: ${pushError}`, log);
10930
+ i.log.warn(`${displayKey(t)}: the runner's own push failed: ${pushError}`, log);
10931
+ }
10932
+ if (!await deliverNote(i, t.id, bounceComment(v, i.shipName, pushError), "bounced", log)) {
10933
+ i.log.warn(`${displayKey(t)}: ${v.reason}, but the bounce note could not be delivered \u2014 left at ${t.status}, guard outcome unverified`, log);
10934
+ return { kind: "unverified", why: "the bounce note could not be posted" };
10870
10935
  }
10871
10936
  await i.writer.updateTicket(t.id, {
10872
10937
  status: i.contract.statuses.building,
10873
10938
  assignee_id: i.seatId,
10874
10939
  ...i.hold && !heldBy ? { [i.hold.column]: i.hold.shipId } : {}
10875
10940
  });
10876
- await i.writer.postEvent(t.id, bounceComment(v, i.shipName, pushError), i.seatId, "bounced").catch(() => {
10877
- i.log.warn("bounced, but the note failed to post", log);
10878
- });
10879
- i.log.warn(`${t.issue_id} bounced back to ${i.contract.statuses.building}: ${v.reason}`, log);
10941
+ i.log.warn(`${displayKey(t)} bounced back to ${i.contract.statuses.building}: ${v.reason}`, log);
10880
10942
  return { kind: "bounced" };
10881
10943
  } catch (e) {
10882
10944
  const why = describeGuardError(e, i.dir);
@@ -10907,7 +10969,7 @@ async function guardRunHandoff(route2, ship, tracker, role, workingId, log, sinc
10907
10969
  checkoutDir = target.dir;
10908
10970
  const lost = lostTicketReason(t, tracker.contract, (await tracker.claimAffinity())?.shipId);
10909
10971
  if (lost && role !== "qa") {
10910
- log.warn(`${t.issue_id}: run ended without a push \u2014 ${lost}`, { ticket: t.issue_id, step: "handoff" });
10972
+ log.warn(`${displayKey(t)}: run ended without a push \u2014 ${lost}`, { ticket: t.issue_id, step: "handoff" });
10911
10973
  return { kind: "unverified", why: lost };
10912
10974
  }
10913
10975
  if (role === "qa") {
@@ -10917,7 +10979,7 @@ async function guardRunHandoff(route2, ship, tracker, role, workingId, log, sinc
10917
10979
  const affinity = await tracker.claimAffinity();
10918
10980
  const origin = ship.runner === "sandbox" ? sandboxOriginFor(route2, target.name) : void 0;
10919
10981
  if (ship.runner === "sandbox" && !origin) {
10920
- log.warn(`${t.issue_id}: the push was not checked: this ship cannot place the remote of ${target.name}`, { ticket: t.issue_id, step: "handoff" });
10982
+ log.warn(`${displayKey(t)}: the push was not checked: this ship cannot place the remote of ${target.name}`, { ticket: t.issue_id, step: "handoff" });
10921
10983
  return null;
10922
10984
  }
10923
10985
  const outcome = replayed.includes(workingId) ? { kind: "pushed", sha: "" } : await enforceHandoff({
@@ -10943,7 +11005,7 @@ async function guardRunHandoff(route2, ship, tracker, role, workingId, log, sinc
10943
11005
  else {
10944
11006
  const branch = existingBranchForTicket(target.dir, cfg, t, role);
10945
11007
  if (branch && dropEmptyRunBranch(target.dir, cfg, branch)) {
10946
- log.emit(`${t.issue_id}: dropped ${branch} \u2014 the run made no commits beyond ${cfg.branch.base}`, { ticket: t.issue_id, step: "handoff" });
11008
+ log.emit(`${displayKey(t)}: dropped ${branch} \u2014 the run made no commits beyond ${cfg.branch.base}`, { ticket: t.issue_id, step: "handoff" });
10947
11009
  }
10948
11010
  }
10949
11011
  if (since2 && !origin) await guardRunStrays(route2, ship, tracker, role, workingId, since2, log);
@@ -10967,12 +11029,12 @@ async function retireRunWorktree(tracker, dir, cfg, t, role, seatId, shipName2,
10967
11029
  if (!branch) return;
10968
11030
  const o = await finishRunWorktree(dir, cfg, branch);
10969
11031
  const at = { ticket: t.issue_id, step: "handoff" };
10970
- if (o.kind === "removed") log.emit(`${t.issue_id}: removed the run's worktree ${o.path} \u2014 the branch is on ${cfg.branch.remote}`, at);
11032
+ if (o.kind === "removed") log.emit(`${displayKey(t)}: removed the run's worktree ${o.path} \u2014 the branch is on ${cfg.branch.remote}`, at);
10971
11033
  else if (o.kind === "kept-handoff") {
10972
- log.emit(`${t.issue_id}: kept worktree ${o.path} \u2014 this repo's handoff hook serves from it`, at);
11034
+ log.emit(`${displayKey(t)}: kept worktree ${o.path} \u2014 this repo's handoff hook serves from it`, at);
10973
11035
  await tracker.postEvent(t.id, `worktree kept on ship ${shipName2} at \`${o.path}\`: the repo's \`handoff\` hook serves from it. QA on another ship cuts its own from \`${cfg.branch.remote}/${branch}\` instead.`, seatId, "worktree_kept");
10974
- } else if (o.kind === "kept-dirty") log.warn(`${t.issue_id}: left worktree ${o.path} \u2014 it has uncommitted changes`, at);
10975
- else if (o.kind === "kept-unpushed") log.warn(`${t.issue_id}: left worktree ${o.path} \u2014 its branch has commits that are not on ${cfg.branch.remote}`, at);
11036
+ } else if (o.kind === "kept-dirty") log.warn(`${displayKey(t)}: left worktree ${o.path} \u2014 it has uncommitted changes`, at);
11037
+ else if (o.kind === "kept-unpushed") log.warn(`${displayKey(t)}: left worktree ${o.path} \u2014 its branch has commits that are not on ${cfg.branch.remote}`, at);
10976
11038
  } catch (e) {
10977
11039
  log.warn(`could not retire the run's worktree: ${e.message}`, { step: "handoff" });
10978
11040
  }
@@ -11018,37 +11080,44 @@ async function guardStrayHandoffs(i) {
11018
11080
  try {
11019
11081
  const holder = i.myShipId ? ticketHolderShipId(t, i.contract) : null;
11020
11082
  if (holder && holder !== i.myShipId) {
11021
- await i.writer.updateTicket(t.id, { status: st.building });
11022
- await i.writer.postEvent(
11083
+ const said = await deliverNote(
11084
+ i,
11023
11085
  t.id,
11024
11086
  `${STRAY_HANDOFF_MARKER}
11025
11087
 
11026
11088
  **Hand-off bounced: this ticket is held by another ship.**
11027
11089
 
11028
11090
  ${i.shipName ? `${i.shipName}'s ` : "A "}${i.role} run set it to \`${st.handoff}\` without having claimed it. Set back to \`${st.building}\`; the holding ship's own hand-off is the one that counts.`,
11029
- i.seatId,
11030
- "bounced"
11031
- ).catch(() => i.log.warn("bounced, but the note failed to post", at));
11032
- i.log.warn(`${t.issue_id} was handed off by a run that did not claim it, while held by another ship \u2014 bounced to ${st.building}`, at);
11091
+ "bounced",
11092
+ at
11093
+ );
11094
+ if (!said) {
11095
+ i.log.warn(`${displayKey(t)}: stray hand-off not bounced, its note could not be delivered`, at);
11096
+ continue;
11097
+ }
11098
+ await i.writer.updateTicket(t.id, { status: st.building });
11099
+ i.log.warn(`${displayKey(t)} was handed off by a run that did not claim it, while held by another ship \u2014 bounced to ${st.building}`, at);
11033
11100
  continue;
11034
11101
  }
11035
11102
  const co = i.checkout(t);
11036
11103
  if (!co || !existingBranchForTicket(co.dir, co.cfg, t, i.role)) {
11037
- i.log.warn(`${t.issue_id} moved to ${st.handoff} during a run that did not claim it; no local branch to verify, left alone`, at);
11104
+ i.log.warn(`${displayKey(t)} moved to ${st.handoff} during a run that did not claim it; no local branch to verify, left alone`, at);
11038
11105
  continue;
11039
11106
  }
11040
11107
  const v = inspectHandoff(co.dir, co.cfg, t, i.role);
11041
- i.log.warn(`${t.issue_id} was handed off by a run that did not claim it`, at);
11108
+ i.log.warn(`${displayKey(t)} was handed off by a run that did not claim it`, at);
11042
11109
  if (v.kind === "pushed") {
11043
11110
  await i.writer.postEvent(t.id, pushedEventBody(v.sha, v.remote, v.branch), i.seatId, "pushed");
11044
11111
  } else if (v.kind === "bounce") {
11045
11112
  if (v.origin && v.local && !isAncestor(co.dir, v.origin, v.local)) {
11046
- i.log.warn(`${t.issue_id}: \`${v.remote}/${v.branch}\` is at ${v.origin.slice(0, 7)}, not a tip this checkout built \u2014 left alone`, at);
11113
+ 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);
11114
+ continue;
11115
+ }
11116
+ if (!await deliverNote(i, t.id, bounceComment(v, i.shipName), "bounced", at)) {
11117
+ i.log.warn(`${displayKey(t)}: stray hand-off not bounced, its note could not be delivered`, at);
11047
11118
  continue;
11048
11119
  }
11049
11120
  await i.writer.updateTicket(t.id, { status: st.building, assignee_id: i.seatId });
11050
- await i.writer.postEvent(t.id, bounceComment(v, i.shipName), i.seatId, "bounced").catch(() => {
11051
- });
11052
11121
  }
11053
11122
  } catch (e) {
11054
11123
  i.log.warn(`could not check the stray hand-off: ${e.message}`, at);
@@ -17930,13 +17999,13 @@ function sweepDiagnostics(tickets, info) {
17930
17999
  const selfBlocked = [];
17931
18000
  for (const t of tickets) {
17932
18001
  for (const id of t.blocked_by ?? []) {
17933
- if (info[id] === void 0) dangling.push(`${t.issue_id} -> ${id}`);
17934
- if (id === t.id) selfBlocked.push(t.issue_id);
18002
+ if (info[id] === void 0) dangling.push(`${displayKey(t)} -> ${id}`);
18003
+ if (id === t.id) selfBlocked.push(displayKey(t));
17935
18004
  }
17936
18005
  }
17937
18006
  return { dangling, selfBlocked: [...new Set(selfBlocked)] };
17938
18007
  }
17939
- var describeBlockers = (t, info) => (t.blocked_by ?? []).map((id) => `${info[id]?.issue_id ?? "?"} (${info[id]?.status ?? "unknown"})`).join(", ");
18008
+ var describeBlockers = (t, info) => (t.blocked_by ?? []).map((id) => `${info[id]?.issue_tag ?? info[id]?.issue_id ?? "?"} (${info[id]?.status ?? "unknown"})`).join(", ");
17940
18009
  function planSweep(tickets, info, blocked, wm) {
17941
18010
  const steps = [];
17942
18011
  for (const t of withinWorkMode(tickets, wm)) {
@@ -18858,7 +18927,7 @@ function stalledComment(s, ships, now = Date.now()) {
18858
18927
  const who2 = s.holderShipId ? `Held by ${shipName(ships, s.holderShipId)}, which is not engaged on it. That ship has an attention item open; the ticket is otherwise left as it is, and resumes the moment the ship picks it back up.` : `No ship holds it and none is engaged on it. It is waiting for the next ship that polls its lane; its status and assignee are left as they are.`;
18859
18928
  return `${STALLED_MARKER}
18860
18929
 
18861
- **Stalled \u2014 no activity on \`${s.ticket.issue_id}\` for ${mins} minutes (\`${s.ticket.status}\`).**
18930
+ **Stalled \u2014 no activity on \`${displayKey(s.ticket)}\` for ${mins} minutes (\`${s.ticket.status}\`).**
18862
18931
 
18863
18932
  ${who2}`;
18864
18933
  }
@@ -18870,7 +18939,7 @@ async function applyStalled(writer, stalled, ships, memberId, myShipId, log, dry
18870
18939
  r.attention.push({
18871
18940
  kind: "stalled",
18872
18941
  key: stalledKey(s.ticket.issue_id),
18873
- message: `${s.ticket.issue_id} is held by this ship but has been quiet for ${Math.round((now - s.lastActivityAt) / 6e4)} minutes with nothing engaged on it`,
18942
+ message: `${displayKey(s.ticket)} is held by this ship but has been quiet for ${Math.round((now - s.lastActivityAt) / 6e4)} minutes with nothing engaged on it`,
18874
18943
  since: new Date(s.lastActivityAt + STALLED_AFTER_MS).toISOString()
18875
18944
  });
18876
18945
  }
@@ -19330,9 +19399,9 @@ async function claimStillHeld(tracker, t, buildingStatus, affinity) {
19330
19399
  }
19331
19400
  const holder = affinity ? now[affinity.column] : null;
19332
19401
  if (affinity && typeof holder === "string" && holder && holder !== affinity.shipId) {
19333
- return `${t.issue_id} is held by another ship now`;
19402
+ return `${displayKey(t)} is held by another ship now`;
19334
19403
  }
19335
- if (now.status !== buildingStatus) return `${t.issue_id} is at ${now.status}, not ${buildingStatus}`;
19404
+ if (now.status !== buildingStatus) return `${displayKey(t)} is at ${now.status}, not ${buildingStatus}`;
19336
19405
  return null;
19337
19406
  }
19338
19407
 
@@ -19559,7 +19628,7 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
19559
19628
  const t = { ticket: b.ticket.issue_id, step: "merge" };
19560
19629
  const absorbed = b.priorBounces > 0 && b.priorBounces < MAX_ABSORBED_HANDBACKS && !!b.priorBaseSha && isAncestor(b.worktree ?? b.cwd, b.priorBaseSha, b.branch);
19561
19630
  if (absorbed) {
19562
- log.emit(`${b.ticket.issue_id} conflicts again, but ${b.base} moved since the hand-back was answered \u2014 handing back again`, t);
19631
+ log.emit(`${displayKey(b.ticket)} conflicts again, but ${b.base} moved since the hand-back was answered \u2014 handing back again`, t);
19563
19632
  }
19564
19633
  if (b.priorBounces > 0 && !absorbed) {
19565
19634
  if (dryRun) {
@@ -19568,14 +19637,14 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
19568
19637
  }
19569
19638
  try {
19570
19639
  await writer.updateTicket(b.ticket.id, { status: contract.statuses.needsHuman }, b.ticket.updated_at);
19571
- await writer.postEvent(b.ticket.id, escalateComment(b), memberId, "conflict_escalated").catch(() => {
19572
- log.warn("escalated, but the note failed to post", t);
19640
+ await writer.postEvent(b.ticket.id, escalateComment(b), memberId, "conflict_escalated").catch((e) => {
19641
+ log.warn(`escalated, but the note failed to post: ${e.message}`, t);
19573
19642
  });
19574
19643
  log.warn(`conflicts again after a hand-back \u2014 escalated to ${contract.statuses.needsHuman}`, t);
19575
19644
  return { kind: "escalated" };
19576
19645
  } catch (e) {
19577
19646
  if (e instanceof StaleWriteError7) {
19578
- log.emit(`${b.ticket.issue_id} changed on the board since this run read it \u2014 not escalating over it`, t);
19647
+ log.emit(`${displayKey(b.ticket)} changed on the board since this run read it \u2014 not escalating over it`, t);
19579
19648
  return { kind: "stale" };
19580
19649
  }
19581
19650
  return { kind: "failed", why: e.message };
@@ -19596,7 +19665,7 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
19596
19665
  return { kind: "refreshed" };
19597
19666
  }
19598
19667
  if (r.behind) {
19599
- log.warn(`not handing ${b.ticket.issue_id} back: ${r.why}`, t);
19668
+ log.warn(`not handing ${displayKey(b.ticket)} back: ${r.why}`, t);
19600
19669
  return { kind: "failed", why: r.why ?? "branch behind its remote" };
19601
19670
  }
19602
19671
  merged = r.paths.length > 0;
@@ -19615,8 +19684,8 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
19615
19684
  memberId,
19616
19685
  "conflict_handed_back",
19617
19686
  b.baseSha ? { base_sha: b.baseSha } : void 0
19618
- ).catch(() => {
19619
- log.warn("handed back, but the note failed to post", t);
19687
+ ).catch((e) => {
19688
+ log.warn(`handed back, but the note failed to post: ${e.message}`, t);
19620
19689
  });
19621
19690
  log.emit(
19622
19691
  `handed back to ${contract.statuses.building} \u2014 conflicts with ${b.base}${b.paths.length ? ` in ${b.paths.join(", ")}` : ""}`,
@@ -19625,7 +19694,7 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
19625
19694
  return { kind: "handed-back" };
19626
19695
  } catch (e) {
19627
19696
  if (e instanceof StaleWriteError7) {
19628
- log.emit(`${b.ticket.issue_id} changed on the board since this run read it \u2014 not handing it back over it`, t);
19697
+ log.emit(`${displayKey(b.ticket)} changed on the board since this run read it \u2014 not handing it back over it`, t);
19629
19698
  return { kind: "stale" };
19630
19699
  }
19631
19700
  return { kind: "failed", why: e.message };
@@ -19750,7 +19819,7 @@ async function applyBuildFailureBounce(writer, b, contract, memberId, log, dryRu
19750
19819
  }
19751
19820
  }
19752
19821
  if (dryRun) {
19753
- log.emit(`would hand ${b.ticket.issue_id} back to ${contract.statuses.building} \u2014 its branch breaks the ${b.hook} hook`, t);
19822
+ log.emit(`would hand ${displayKey(b.ticket)} back to ${contract.statuses.building} \u2014 its branch breaks the ${b.hook} hook`, t);
19754
19823
  return { kind: "handed-back" };
19755
19824
  }
19756
19825
  try {
@@ -19773,7 +19842,7 @@ async function applyBuildFailureBounce(writer, b, contract, memberId, log, dryRu
19773
19842
  return { kind: "handed-back" };
19774
19843
  } catch (e) {
19775
19844
  if (e instanceof StaleWriteError8) {
19776
- log.emit(`${b.ticket.issue_id} changed on the board since this run read it \u2014 not handing it back over it`, t);
19845
+ log.emit(`${displayKey(b.ticket)} changed on the board since this run read it \u2014 not handing it back over it`, t);
19777
19846
  return { kind: "stale" };
19778
19847
  }
19779
19848
  return { kind: "failed", why: e.message };
@@ -21129,7 +21198,7 @@ Closes ${c.ticket.issue_id}.${trailer}`]);
21129
21198
  void o.attention.raise({
21130
21199
  kind: "release_merge_failed",
21131
21200
  key: `release_merge_failed:${o.scope ?? "release"}`,
21132
- message: `${o.scope ?? "release"}: could not merge ${c.branch} (${c.ticket.issue_id}) \u2014 not a conflict, so the ticket stays verified and is retried: ${message.slice(0, 400)}`,
21201
+ message: `${o.scope ?? "release"}: could not merge ${c.branch} (${displayKey(c.ticket)}) \u2014 not a conflict, so the ticket stays verified and is retried: ${message.slice(0, 400)}`,
21133
21202
  since: (/* @__PURE__ */ new Date()).toISOString()
21134
21203
  });
21135
21204
  }
@@ -21347,8 +21416,8 @@ async function runReleaseCycle(o, movedPast2, localRefSkips) {
21347
21416
  materializeBranchForTicket(o.cwd, o.repo, t, void 0, (problem) => {
21348
21417
  skipped.add(t.id);
21349
21418
  localRefSkips.push({ ticket: t, problem });
21350
- o.emit.error(`not releasing ${t.issue_id} this cycle: ${problem}`, { ticket: t.issue_id });
21351
- }, (note) => o.emit.emit(`${t.issue_id}: ${note}`, { ticket: t.issue_id }));
21419
+ o.emit.error(`not releasing ${displayKey(t)} this cycle: ${problem}`, { ticket: t.issue_id });
21420
+ }, (note) => o.emit.emit(`${displayKey(t)}: ${note}`, { ticket: t.issue_id }));
21352
21421
  }
21353
21422
  if (skipped.size) releasable = o.tickets.filter((t) => !skipped.has(t.id));
21354
21423
  }
@@ -21364,7 +21433,7 @@ async function runReleaseCycle(o, movedPast2, localRefSkips) {
21364
21433
  const remoteTip2 = branch ? gitOk(o.cwd, ["rev-parse", "-q", "--verify", `refs/remotes/${o.repo.branch.remote}/${branch}^{commit}`]) : null;
21365
21434
  if (remoteTip2 && remoteTip2 !== moved.tip) {
21366
21435
  o.emit.error(
21367
- `not releasing ${t.issue_id}: local ${branch} at ${moved.tip.slice(0, 8)} is not on ${o.repo.branch.remote}/${branch} (${remoteTip2.slice(0, 8)}); not requeuing it`,
21436
+ `not releasing ${displayKey(t)}: local ${branch} at ${moved.tip.slice(0, 8)} is not on ${o.repo.branch.remote}/${branch} (${remoteTip2.slice(0, 8)}); not requeuing it`,
21368
21437
  { ticket: t.issue_id }
21369
21438
  );
21370
21439
  localRefSkips.push({
@@ -21375,7 +21444,7 @@ async function runReleaseCycle(o, movedPast2, localRefSkips) {
21375
21444
  }
21376
21445
  movedPast2.push({ ticket: t, verified: moved.verified, head: moved.tip, branch: pushedBranchForTicket(o.repo, t) });
21377
21446
  o.emit.error(
21378
- `not releasing ${t.issue_id}: ${branch} is at ${moved.tip.slice(0, 8)}, past the ${moved.verified.slice(0, 8)} QA verified`,
21447
+ `not releasing ${displayKey(t)}: ${branch} is at ${moved.tip.slice(0, 8)}, past the ${moved.verified.slice(0, 8)} QA verified`,
21379
21448
  { ticket: t.issue_id }
21380
21449
  );
21381
21450
  }
@@ -24046,7 +24115,7 @@ async function runRoleAgentLocked(role, decision, ctx, hooks, held) {
24046
24115
  }
24047
24116
  } catch (e) {
24048
24117
  emit.error(
24049
- `could not check out ${target?.name ?? "(unknown repo)"} for ${result.ticket.issue_id}: ${e.message}`
24118
+ `could not check out ${target?.name ?? "(unknown repo)"} for ${displayKey(result.ticket)}: ${e.message}`
24050
24119
  );
24051
24120
  return;
24052
24121
  }
@@ -26967,7 +27036,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
26967
27036
  const when = held ? noteHeldWorktree(held.state, { repo: held.repo, path: a.path, ticket: a.ticket.issue_id, status: a.ticket.status, reason }) : "first";
26968
27037
  if (when) {
26969
27038
  log.warn(
26970
- `not removing worktree ${a.path} for ${a.ticket.issue_id} (${a.ticket.status}): ${detail}`,
27039
+ `not removing worktree ${a.path} for ${displayKey(a.ticket)} (${a.ticket.status}): ${detail}`,
26971
27040
  { ticket: a.ticket.issue_id, step: "worktree" }
26972
27041
  );
26973
27042
  }
@@ -26978,7 +27047,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
26978
27047
  if (!dryRun && base && !a.keepBranch && existsSync54(a.path) && isHandBackMerge(a.path, base)) {
26979
27048
  if (gitOk(a.path, ["merge", "--abort"]) !== null) {
26980
27049
  log.emit(
26981
- `abandoned the hand-back merge of ${base} in ${a.path}: ${a.ticket.issue_id} deployed without it`,
27050
+ `abandoned the hand-back merge of ${base} in ${a.path}: ${displayKey(a.ticket)} deployed without it`,
26982
27051
  { ticket: a.ticket.issue_id, step: "worktree" }
26983
27052
  );
26984
27053
  }
@@ -26988,7 +27057,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
26988
27057
  const liveRun = !!held && liveRuns(held.state.dir).some((r) => (r.ticket ?? "").replace(/^\D+/, "") === String(n));
26989
27058
  const defer = () => {
26990
27059
  log.emit(
26991
- `leaving ${a.path} for the next cycle: ${liveRun ? `${a.ticket.issue_id} has a run in progress on this ship` : `processes are still inside it (${pids.join(" ")})`}`,
27060
+ `leaving ${a.path} for the next cycle: ${liveRun ? `${displayKey(a.ticket)} has a run in progress on this ship` : `processes are still inside it (${pids.join(" ")})`}`,
26992
27061
  { ticket: a.ticket.issue_id, step: "worktree" }
26993
27062
  );
26994
27063
  };
@@ -27030,7 +27099,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
27030
27099
  if (a.keepBranch) keptBranches++;
27031
27100
  if (dryRun) {
27032
27101
  log.emit(
27033
- `would remove worktree ${a.path} for ${a.ticket.issue_id} (${a.ticket.status}); ${branchNote}`,
27102
+ `would remove worktree ${a.path} for ${displayKey(a.ticket)} (${a.ticket.status}); ${branchNote}`,
27034
27103
  { ticket: a.ticket.issue_id, step: "worktree" }
27035
27104
  );
27036
27105
  continue;
@@ -27053,7 +27122,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
27053
27122
  }
27054
27123
  }
27055
27124
  log.emit(
27056
- `removed worktree for ${a.ticket.issue_id} (${a.ticket.status}); ${branchNote}`,
27125
+ `removed worktree for ${displayKey(a.ticket)} (${a.ticket.status}); ${branchNote}`,
27057
27126
  { ticket: a.ticket.issue_id, step: "worktree" }
27058
27127
  );
27059
27128
  removed++;
@@ -27296,7 +27365,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
27296
27365
  import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
27297
27366
  import { join as join58 } from "path";
27298
27367
  function builtVersion() {
27299
- return true ? "0.151.1" : null;
27368
+ return true ? "0.151.3" : null;
27300
27369
  }
27301
27370
  var REBUILD_HINT = "rebuild with npm run build";
27302
27371
  function newestMtime(path) {
@@ -31258,7 +31327,7 @@ ${changed2.map((c) => ` - ${c}
31258
31327
  { count: priorBuildFailures(cu.ticket, prior), operatorId: c.resolved?.operator, previousNote: priorFailureNote(cu.ticket, prior) }
31259
31328
  );
31260
31329
  if (r.kind === "failed") {
31261
- remit.warn(`could not hand back ${cu.ticket.issue_id}: ${r.why}`, { step: "release" });
31330
+ remit.warn(`could not hand back ${displayKey(cu.ticket)}: ${r.why}`, { step: "release" });
31262
31331
  }
31263
31332
  if (r.kind === "escalated" && !dryRun) {
31264
31333
  const key = cu.ticket.issue_tag ?? cu.ticket.issue_id;
@@ -31275,7 +31344,7 @@ ${cu.tail.trimEnd()}
31275
31344
  });
31276
31345
  }
31277
31346
  } catch (e) {
31278
- remit.warn(`could not hand back ${cu.ticket.issue_id}: ${e.message}`, { step: "release" });
31347
+ remit.warn(`could not hand back ${displayKey(cu.ticket)}: ${e.message}`, { step: "release" });
31279
31348
  }
31280
31349
  }
31281
31350
  }
@@ -31313,11 +31382,11 @@ ${f.tail.trimEnd()}
31313
31382
  );
31314
31383
  const r = await applyConflictBounce(tracker, bounce, tracker.contract, seat, remit, dryRun);
31315
31384
  if (r.kind === "failed") {
31316
- remit.warn(`could not hand back ${f.candidate.ticket.issue_id}: ${r.why}`, { step: "merge" });
31385
+ remit.warn(`could not hand back ${displayKey(f.candidate.ticket)}: ${r.why}`, { step: "merge" });
31317
31386
  }
31318
31387
  } catch (e) {
31319
31388
  remit.warn(
31320
- `could not hand back ${f.candidate.ticket.issue_id}: ${e.message}`,
31389
+ `could not hand back ${displayKey(f.candidate.ticket)}: ${e.message}`,
31321
31390
  { step: "merge" }
31322
31391
  );
31323
31392
  }
@@ -31335,10 +31404,10 @@ ${f.tail.trimEnd()}
31335
31404
  dryRun
31336
31405
  );
31337
31406
  if (r.kind === "failed") {
31338
- remit.warn(`could not flag ${cand.ticket.issue_id}: ${r.why}`, { step: "merge" });
31407
+ remit.warn(`could not flag ${displayKey(cand.ticket)}: ${r.why}`, { step: "merge" });
31339
31408
  }
31340
31409
  } catch (e) {
31341
- remit.warn(`could not flag ${cand.ticket.issue_id}: ${e.message}`, { step: "merge" });
31410
+ remit.warn(`could not flag ${displayKey(cand.ticket)}: ${e.message}`, { step: "merge" });
31342
31411
  }
31343
31412
  }
31344
31413
  }
@@ -31576,7 +31645,7 @@ ${f.tail.trimEnd()}
31576
31645
  wemit.note(`cloned ${target.name} into ${target.dir}`, { step: "select", role: w.role });
31577
31646
  }
31578
31647
  } catch (e) {
31579
- wemit.error(`could not check out ${target?.name ?? "(unknown repo)"} for ${result.ticket.issue_id}: ${e.message}`);
31648
+ wemit.error(`could not check out ${target?.name ?? "(unknown repo)"} for ${displayKey(result.ticket)}: ${e.message}`);
31580
31649
  if (!skipInlineRelease) await releaseFleet();
31581
31650
  break;
31582
31651
  }
@@ -31798,7 +31867,7 @@ ${f.tail.trimEnd()}
31798
31867
  emit.note(`cloned ${target.name} into ${target.dir}`, { step: "select", role: current });
31799
31868
  }
31800
31869
  } catch (e) {
31801
- emit.error(`could not check out ${target?.name ?? "(unknown repo)"} for ${result.ticket.issue_id}: ${e.message}`);
31870
+ emit.error(`could not check out ${target?.name ?? "(unknown repo)"} for ${displayKey(result.ticket)}: ${e.message}`);
31802
31871
  dropLock();
31803
31872
  if (explicitRole) {
31804
31873
  current = void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.151.1",
3
+ "version": "0.151.3",
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",