@tablation/crew 0.142.6 → 0.143.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 +77 -22
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -19196,6 +19196,13 @@ function culpritByFiles(candidates2, paths) {
|
|
|
19196
19196
|
function planBuildFailureBounce(cwd, c, base, remote) {
|
|
19197
19197
|
return { ...c, base, remote, worktree: worktreeForBranch(cwd, c.branch) };
|
|
19198
19198
|
}
|
|
19199
|
+
function outsideNote(b) {
|
|
19200
|
+
if (b.inBranch !== false || !b.failingFiles?.length) return "";
|
|
19201
|
+
const shown = b.failingFiles.slice(0, 5).map((f) => `\`${f}\``).join(", ");
|
|
19202
|
+
return `**None of the files the failure names (${shown}) are among this branch's changes**, so this may be a flake or a failure that already lives on \`${b.base ?? "the base"}\` rather than something the branch broke; check that before changing code.
|
|
19203
|
+
|
|
19204
|
+
`;
|
|
19205
|
+
}
|
|
19199
19206
|
function buildFailureComment(b) {
|
|
19200
19207
|
const how = b.how === "pair" && b.sibling ? `Each branch passes the hook alone; \`${b.branch}\` together with ${b.sibling.key} (\`${b.sibling.branch}\`) fails it. ${b.sibling.key} was verified first, so the fix belongs on this branch: \`git merge ${b.remote}/${b.sibling.branch}\` first, then fix what disagrees. Fix it on this branch, never a fresh one.` : b.how === "files" ? `The failing output names files that only \`${b.branch}\` changed among the branches in that release.` : `Built alone on the previous \`${b.base}\`, \`${b.branch}\` fails the same hook.`;
|
|
19201
19208
|
return `${BUILD_FAILURE_MARKER}
|
|
@@ -19204,7 +19211,7 @@ function buildFailureComment(b) {
|
|
|
19204
19211
|
|
|
19205
19212
|
\`${b.branch}\` was verified, but the release's \`${b.hook}\` hook failed once it was merged with the other branches in the same release. ${how}
|
|
19206
19213
|
|
|
19207
|
-
First step: \`git merge ${b.remote}/${b.base}\` in ${b.worktree ? `\`${b.worktree}\`` : "the branch's worktree"}, rebuild, and fix what disagrees \u2014 the merge is clean at the text level, so this is a semantic conflict (a duplicate identifier, a changed signature) with work that landed on \`${b.base}\` after this branch was cut. Push as a plain fast-forward and hand back to QA as usual.
|
|
19214
|
+
${outsideNote(b)}First step: \`git merge ${b.remote}/${b.base}\` in ${b.worktree ? `\`${b.worktree}\`` : "the branch's worktree"}, rebuild, and fix what disagrees \u2014 the merge is clean at the text level, so this is a semantic conflict (a duplicate identifier, a changed signature) with work that landed on \`${b.base}\` after this branch was cut. Push as a plain fast-forward and hand back to QA as usual.
|
|
19208
19215
|
|
|
19209
19216
|
\`\`\`
|
|
19210
19217
|
${b.tail.trimEnd()}
|
|
@@ -19218,13 +19225,32 @@ function priorBuildFailures(ticket, events) {
|
|
|
19218
19225
|
const pushes = mine.filter((e) => e.event_type === "pushed").map(stamp);
|
|
19219
19226
|
return mine.filter((e) => e.event_type === "build_failed" && pushes.some((p) => p > stamp(e))).length;
|
|
19220
19227
|
}
|
|
19221
|
-
function
|
|
19228
|
+
function priorFailureNote(ticket, events) {
|
|
19229
|
+
const stamp = (e) => e.occurred_at ?? e.created_at ?? "";
|
|
19230
|
+
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();
|
|
19231
|
+
}
|
|
19232
|
+
function failureComparison(b, previousNote) {
|
|
19233
|
+
const now = b.failingFiles ?? failingPaths(b.tail, b.cwd ?? "/\0");
|
|
19234
|
+
const before = previousNote ? failingPaths(previousNote, b.cwd ?? "/\0") : [];
|
|
19235
|
+
const lines2 = [];
|
|
19236
|
+
if (!before.length || !now.length) {
|
|
19237
|
+
lines2.push("- Same failure both times? Unknown: the output of at least one run names no file.");
|
|
19238
|
+
} else {
|
|
19239
|
+
const same = now.filter((f) => before.includes(f));
|
|
19240
|
+
lines2.push(same.length ? `- Same failure both times: yes, ${same.map((f) => `\`${f}\``).join(", ")} fails in both.` : `- Same failure both times: **no**. First ${before.slice(0, 3).map((f) => `\`${f}\``).join(", ")}, now ${now.slice(0, 3).map((f) => `\`${f}\``).join(", ")}. Two different failures look like a flake, not a branch that keeps breaking.`);
|
|
19241
|
+
}
|
|
19242
|
+
lines2.push(b.inBranch == null ? "- Failing files among the branch's changes? Unknown: the failure names no file." : b.inBranch ? "- Failing files among the branch's changes: yes." : "- Failing files among the branch's changes: **no**, none of them. Not proof, but the branch probably did not break it.");
|
|
19243
|
+
return lines2.join("\n");
|
|
19244
|
+
}
|
|
19245
|
+
function buildFailureEscalation(b, previousNote) {
|
|
19222
19246
|
return `${BUILD_FAILURE_MARKER}
|
|
19223
19247
|
|
|
19224
19248
|
**Failed the release gate again after a hand-back \u2014 stopping rather than looping.**
|
|
19225
19249
|
|
|
19226
19250
|
\`${b.branch}\` was handed back for breaking the \`${b.hook}\` hook, pushed, verified again, and breaks it once more. That is a call for a person, not another lap through the lanes.
|
|
19227
19251
|
|
|
19252
|
+
${failureComparison(b, previousNote)}
|
|
19253
|
+
|
|
19228
19254
|
\`\`\`
|
|
19229
19255
|
${b.tail.trimEnd()}
|
|
19230
19256
|
\`\`\``;
|
|
@@ -19242,7 +19268,7 @@ async function applyBuildFailureBounce(writer, b, contract, memberId, log, dryRu
|
|
|
19242
19268
|
{ status: contract.statuses.needsHuman, ...prior.operatorId ? { assignee_id: prior.operatorId } : {} },
|
|
19243
19269
|
b.ticket.updated_at
|
|
19244
19270
|
);
|
|
19245
|
-
await writer.postEvent(b.ticket.id, buildFailureEscalation(b), memberId, "build_failed_escalated").catch(() => {
|
|
19271
|
+
await writer.postEvent(b.ticket.id, buildFailureEscalation(b, prior.previousNote), memberId, "build_failed_escalated").catch(() => {
|
|
19246
19272
|
log.warn("escalated, but the note failed to post", t);
|
|
19247
19273
|
});
|
|
19248
19274
|
log.warn(`breaks the ${b.hook} hook again after a hand-back \u2014 escalated to ${contract.statuses.needsHuman}`, t);
|
|
@@ -20242,16 +20268,24 @@ var HOOK_FAILURE_TAIL_LINES = 15;
|
|
|
20242
20268
|
function hookFailure(o, name, output) {
|
|
20243
20269
|
return { hook: name, label: hookLabel(o.repo, name), tail: lastLines(output, HOOK_FAILURE_TAIL_LINES) };
|
|
20244
20270
|
}
|
|
20245
|
-
function looksLikeWorkerCrash(output) {
|
|
20246
|
-
const crashSignature = /worker process was terminated by another process|signal=SIG(SEGV|ABRT|BUS)/i;
|
|
20247
|
-
const assertionDiff = /(AssertionError|Expected:|Received:|✕|not ok \d)/;
|
|
20248
|
-
return crashSignature.test(output) && !assertionDiff.test(output);
|
|
20249
|
-
}
|
|
20250
20271
|
function looksLikeTransientResolveFailure(output) {
|
|
20251
20272
|
const resolveFailure = /Rolldown failed to resolve import|Could not resolve|\[vite\]: Failed to resolve import/i;
|
|
20252
20273
|
const realBuildError = /(TS\d{4}:|SyntaxError|error TS|Cannot find module '\.)/;
|
|
20253
20274
|
return resolveFailure.test(output) && !realBuildError.test(output);
|
|
20254
20275
|
}
|
|
20276
|
+
async function rerunOnce(o, name, first) {
|
|
20277
|
+
o.emit.warn(`${name} gate failed \u2014 rerunning once on the same composition before blaming a branch`);
|
|
20278
|
+
const again = await hook(o, name);
|
|
20279
|
+
if (!again || again.code !== 0) return again ?? first;
|
|
20280
|
+
o.emit.warn(`${name} gate passed on the rerun \u2014 treating the first failure as a flake and going on`);
|
|
20281
|
+
(o.flakeLog ??= []).push({
|
|
20282
|
+
hook: name,
|
|
20283
|
+
label: hookLabel(o.repo, name),
|
|
20284
|
+
tail: lastLines(first.output, HOOK_FAILURE_TAIL_LINES),
|
|
20285
|
+
files: failingPaths(first.output, o.cwd)
|
|
20286
|
+
});
|
|
20287
|
+
return again;
|
|
20288
|
+
}
|
|
20255
20289
|
var hook = async (o, name, env = {}) => {
|
|
20256
20290
|
const script = o.repo.hooks[name];
|
|
20257
20291
|
if (!script) return null;
|
|
@@ -20826,7 +20860,7 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
|
|
|
20826
20860
|
const byFile = culpritByFiles(withFiles, failingPaths(output, o.cwd));
|
|
20827
20861
|
if (byFile) {
|
|
20828
20862
|
o.emit.warn(`${name} failed; its output names files only ${byFile.c.branch} changed \u2014 treating it as the culprit`, { ticket: byFile.c.ticket.issue_id });
|
|
20829
|
-
culprits.push({ c: byFile.c, how: "files", tail: lastLines(output, HOOK_FAILURE_TAIL_LINES) });
|
|
20863
|
+
culprits.push({ c: byFile.c, how: "files", tail: lastLines(output, HOOK_FAILURE_TAIL_LINES), paths: failingPaths(output, o.cwd) });
|
|
20830
20864
|
} else if (applied.length === 1) {
|
|
20831
20865
|
const only = applied[0];
|
|
20832
20866
|
gitOk(o.cwd, ["reset", "--hard", preMerge]);
|
|
@@ -20837,7 +20871,7 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
|
|
|
20837
20871
|
return { tried: `Isolation found no culprit: the ${name} hook also fails on the base alone, without ${only.branch}, so there is no branch to hand back.` };
|
|
20838
20872
|
}
|
|
20839
20873
|
o.emit.warn(`${name} failed with only ${only.branch} merged and passes without it \u2014 treating it as the culprit`, { ticket: only.ticket.issue_id });
|
|
20840
|
-
culprits.push({ c: only, how: "solo", tail: lastLines(output, HOOK_FAILURE_TAIL_LINES) });
|
|
20874
|
+
culprits.push({ c: only, how: "solo", tail: lastLines(output, HOOK_FAILURE_TAIL_LINES), paths: failingPaths(output, o.cwd) });
|
|
20841
20875
|
} else if (applied.length > cap) {
|
|
20842
20876
|
o.emit.warn(`${name} failed with ${applied.length} branches merged, over release.isolateFailures.maxCandidates (${cap}) \u2014 not isolating`);
|
|
20843
20877
|
return { tried: `Isolation was skipped: ${applied.length} branches were merged, over release.isolateFailures.maxCandidates (${cap}).` };
|
|
@@ -20850,7 +20884,7 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
|
|
|
20850
20884
|
const r = await hook(o, name);
|
|
20851
20885
|
if (r && r.code !== 0) {
|
|
20852
20886
|
o.emit.warn(`${c.branch} fails the ${name} hook on its own`, { ticket: c.ticket.issue_id });
|
|
20853
|
-
culprits.push({ c, how: "solo", tail: lastLines(r.output, HOOK_FAILURE_TAIL_LINES) });
|
|
20887
|
+
culprits.push({ c, how: "solo", tail: lastLines(r.output, HOOK_FAILURE_TAIL_LINES), paths: failingPaths(r.output, o.cwd) });
|
|
20854
20888
|
}
|
|
20855
20889
|
}
|
|
20856
20890
|
if (culprits.length === 0) {
|
|
@@ -20863,13 +20897,14 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
|
|
|
20863
20897
|
const r = await hook(o, name);
|
|
20864
20898
|
if (r && r.code !== 0) {
|
|
20865
20899
|
o.emit.warn(`${applied[j].branch} fails the ${name} hook together with ${applied[i].branch}`, { ticket: applied[j].ticket.issue_id });
|
|
20866
|
-
culprits.push({ c: applied[j], how: "pair", sibling: applied[i], tail: lastLines(r.output, HOOK_FAILURE_TAIL_LINES) });
|
|
20900
|
+
culprits.push({ c: applied[j], how: "pair", sibling: applied[i], tail: lastLines(r.output, HOOK_FAILURE_TAIL_LINES), paths: failingPaths(r.output, o.cwd) });
|
|
20867
20901
|
break;
|
|
20868
20902
|
}
|
|
20869
20903
|
}
|
|
20870
20904
|
if (culprits.length === 0 && truncated) {
|
|
20871
20905
|
let lo = 2, hi = applied.length;
|
|
20872
20906
|
let tail3 = lastLines(output, HOOK_FAILURE_TAIL_LINES);
|
|
20907
|
+
let paths = failingPaths(output, o.cwd);
|
|
20873
20908
|
while (lo < hi) {
|
|
20874
20909
|
const mid = Math.floor((lo + hi) / 2);
|
|
20875
20910
|
gitOk(o.cwd, ["reset", "--hard", preMerge]);
|
|
@@ -20885,11 +20920,12 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
|
|
|
20885
20920
|
if (r && r.code !== 0) {
|
|
20886
20921
|
hi = mid;
|
|
20887
20922
|
tail3 = lastLines(r.output, HOOK_FAILURE_TAIL_LINES);
|
|
20923
|
+
paths = failingPaths(r.output, o.cwd);
|
|
20888
20924
|
} else lo = mid + 1;
|
|
20889
20925
|
}
|
|
20890
20926
|
const owner = applied[hi - 1];
|
|
20891
20927
|
o.emit.warn(`${owner.branch} is the first branch whose prefix fails the ${name} hook (bisected over ${applied.length})`, { ticket: owner.ticket.issue_id });
|
|
20892
|
-
culprits.push({ c: owner, how: "pair", sibling: applied[hi - 2], tail: tail3 });
|
|
20928
|
+
culprits.push({ c: owner, how: "pair", sibling: applied[hi - 2], tail: tail3, paths });
|
|
20893
20929
|
}
|
|
20894
20930
|
}
|
|
20895
20931
|
}
|
|
@@ -20910,11 +20946,19 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
|
|
|
20910
20946
|
hook: name,
|
|
20911
20947
|
tail: x.tail,
|
|
20912
20948
|
how: x.how,
|
|
20949
|
+
cwd: o.cwd,
|
|
20950
|
+
failingFiles: x.paths,
|
|
20951
|
+
inBranch: x.paths.length === 0 ? null : x.paths.some((p) => withFiles.find((w) => w.c === x.c)?.changed.has(p) ?? false),
|
|
20913
20952
|
...x.sibling ? { sibling: { key: x.sibling.ticket.issue_tag ?? x.sibling.ticket.issue_id, branch: x.sibling.branch } } : {}
|
|
20914
20953
|
}))
|
|
20915
20954
|
};
|
|
20916
20955
|
}
|
|
20917
20956
|
async function mergeAndRelease(o, decision, fresh, releaseBranch, isolated = false) {
|
|
20957
|
+
const flakeLog = o.flakeLog ?? [];
|
|
20958
|
+
const outcome = await mergeAndReleaseBody({ ...o, flakeLog }, decision, fresh, releaseBranch, isolated);
|
|
20959
|
+
return flakeLog.length ? { ...outcome, flakes: [...flakeLog] } : outcome;
|
|
20960
|
+
}
|
|
20961
|
+
async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated = false) {
|
|
20918
20962
|
o.emit.enter("merge");
|
|
20919
20963
|
const preMerge = o.dryRun ? "" : headSha(o.cwd);
|
|
20920
20964
|
const merged = [];
|
|
@@ -21047,10 +21091,7 @@ async function mergeAndRelease(o, decision, fresh, releaseBranch, isolated = fal
|
|
|
21047
21091
|
if (o.dryRun) o.emit.emit(`would run the test gate: ${hookLabel(o.repo, "test")}`);
|
|
21048
21092
|
else {
|
|
21049
21093
|
let r = await hook(o, "test");
|
|
21050
|
-
if (r && r.code !== 0 &&
|
|
21051
|
-
o.emit.warn("test gate failed with what looks like a worker crash, not a real failure \u2014 retrying once");
|
|
21052
|
-
r = await hook(o, "test");
|
|
21053
|
-
}
|
|
21094
|
+
if (r && r.code !== 0 && !o.dryRun) r = await rerunOnce(o, "test", r);
|
|
21054
21095
|
if (r && r.code !== 0 && !isolated) {
|
|
21055
21096
|
const out = await isolateAndRetry(o, "test", r.output, merged, preMerge, decision, fresh, releaseBranch);
|
|
21056
21097
|
if (out && "tried" in out) isolation = out.tried;
|
|
@@ -21108,10 +21149,7 @@ async function mergeAndRelease(o, decision, fresh, releaseBranch, isolated = fal
|
|
|
21108
21149
|
}
|
|
21109
21150
|
} else {
|
|
21110
21151
|
let r = await hook(o, "build");
|
|
21111
|
-
if (r && r.code !== 0
|
|
21112
|
-
o.emit.warn("build failed with what looks like a transient dependency-resolution glitch, not a real failure \u2014 retrying once");
|
|
21113
|
-
r = await hook(o, "build");
|
|
21114
|
-
}
|
|
21152
|
+
if (r && r.code !== 0) r = await rerunOnce(o, "build", r);
|
|
21115
21153
|
if (r && r.code !== 0 && !isolated) {
|
|
21116
21154
|
const out = await isolateAndRetry(o, "build", r.output, merged, preMerge, decision, fresh, releaseBranch);
|
|
21117
21155
|
if (out && "tried" in out) isolation = out.tried;
|
|
@@ -29881,7 +29919,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
29881
29919
|
seat,
|
|
29882
29920
|
remit,
|
|
29883
29921
|
dryRun,
|
|
29884
|
-
{ count: priorBuildFailures(cu.ticket, prior), operatorId: c.resolved?.operator }
|
|
29922
|
+
{ count: priorBuildFailures(cu.ticket, prior), operatorId: c.resolved?.operator, previousNote: priorFailureNote(cu.ticket, prior) }
|
|
29885
29923
|
);
|
|
29886
29924
|
if (r.kind === "failed") {
|
|
29887
29925
|
remit.warn(`could not hand back ${cu.ticket.issue_id}: ${r.why}`, { step: "release" });
|
|
@@ -29905,6 +29943,23 @@ ${cu.tail.trimEnd()}
|
|
|
29905
29943
|
}
|
|
29906
29944
|
}
|
|
29907
29945
|
}
|
|
29946
|
+
if (outcome.flakes?.length && !dryRun) {
|
|
29947
|
+
const seat = releaseSeat(c);
|
|
29948
|
+
for (const f of outcome.flakes) {
|
|
29949
|
+
const files = f.files.length ? f.files.map((p) => `\`${p}\``).join(", ") : "no file named in the output";
|
|
29950
|
+
await applyFailureAlert(tracker, {
|
|
29951
|
+
level: "warn",
|
|
29952
|
+
headline: `${scope}: flaky ${f.hook} gate`,
|
|
29953
|
+
detail: `The \`${f.hook}\` hook (${f.label}) failed once during a release and passed on an immediate rerun of the same composition, so no branch was blamed and the release went on. Failing: ${files}.
|
|
29954
|
+
|
|
29955
|
+
\`\`\`
|
|
29956
|
+
${f.tail.trimEnd()}
|
|
29957
|
+
\`\`\``
|
|
29958
|
+
}, scope, all, seat, remit, dryRun, await alertPlacement()).catch((e) => {
|
|
29959
|
+
remit.warn(`could not file/update a flaky-gate ticket: ${e.message}`, { step: "release" });
|
|
29960
|
+
});
|
|
29961
|
+
}
|
|
29962
|
+
}
|
|
29908
29963
|
if (outcome.conflicts?.length || outcome.unbuildable?.length) {
|
|
29909
29964
|
const handedBack = [...await tracker.events("conflict_handed_back"), ...await tracker.events("pushed")];
|
|
29910
29965
|
const flagged = await tracker.events("stranded_flagged");
|
package/package.json
CHANGED