@tablation/crew 0.151.2 → 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.
- package/dist/cli.js +96 -27
- 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) {
|
|
@@ -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
|
-
|
|
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"}
|
|
10780
|
-
|
|
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
|
-
|
|
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 {
|
|
@@ -10810,15 +10870,16 @@ async function enforceHandoff(i) {
|
|
|
10810
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
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
|
}
|
|
@@ -10858,7 +10919,7 @@ 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(
|
|
10922
|
+
).catch((e) => i.log.warn(`pushed, but the note failed to post: ${e.message}`, log));
|
|
10862
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
|
}
|
|
@@ -10868,14 +10929,15 @@ async function enforceHandoff(i) {
|
|
|
10868
10929
|
}
|
|
10869
10930
|
i.log.warn(`${displayKey(t)}: the runner's own push failed: ${pushError}`, log);
|
|
10870
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" };
|
|
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
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) {
|
|
@@ -11018,17 +11080,22 @@ 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
|
-
|
|
11022
|
-
|
|
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
|
-
|
|
11030
|
-
|
|
11031
|
-
)
|
|
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 });
|
|
11032
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
|
}
|
|
@@ -11046,9 +11113,11 @@ ${i.shipName ? `${i.shipName}'s ` : "A "}${i.role} run set it to \`${st.handoff}
|
|
|
11046
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);
|
|
11047
11114
|
continue;
|
|
11048
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);
|
|
11118
|
+
continue;
|
|
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);
|
|
@@ -19568,8 +19637,8 @@ 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(
|
|
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" };
|
|
@@ -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(
|
|
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(", ")}` : ""}`,
|
|
@@ -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.
|
|
27368
|
+
return true ? "0.151.3" : null;
|
|
27300
27369
|
}
|
|
27301
27370
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
27302
27371
|
function newestMtime(path) {
|
package/package.json
CHANGED