@futurelastic/colab-handbook 1.13.0-rc.4 → 1.13.0-rc.6

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/package.json +1 -1
  2. package/tools/colab +57 -5
package/package.json CHANGED
@@ -32,5 +32,5 @@
32
32
  "engines": {
33
33
  "node": ">=18"
34
34
  },
35
- "version": "1.13.0-rc.4"
35
+ "version": "1.13.0-rc.6"
36
36
  }
package/tools/colab CHANGED
@@ -11087,7 +11087,7 @@ function applyRedTrunkExemptions(raw, target, trunk, redSha, grantThunk, cureThu
11087
11087
  return {
11088
11088
  name: raw.name, ok: true, class: null,
11089
11089
  detail: `PRECONDITION OVERRIDDEN by the cure rule (#281) — branch contains red ${shortSha(redSha)} and is green at its own head${via}${viaDry} (raw: ${raw.detail})`,
11090
- grantVerdict: null, cureVerdict,
11090
+ grantVerdict: null, cureVerdict, redSha,
11091
11091
  };
11092
11092
  }
11093
11093
 
@@ -11102,10 +11102,45 @@ function applyRedTrunkExemptions(raw, target, trunk, redSha, grantThunk, cureThu
11102
11102
  return {
11103
11103
  name: raw.name, ok: true, class: null,
11104
11104
  detail: `PRECONDITION OVERRIDDEN by ${who} on ${by} — trunk was red at ${shortSha(redSha)} (raw: ${raw.detail})`,
11105
- grantVerdict, cureVerdict,
11105
+ grantVerdict, cureVerdict, redSha,
11106
11106
  };
11107
11107
  }
11108
- return { ...raw, grantVerdict, cureVerdict };
11108
+ // #534: both doors were consulted and both refused — say WHY on the row itself, so the prose table,
11109
+ // `--dry`, and B1's abort line all tell "needs a grant" from "missing evidence" from "stacked". The
11110
+ // JSON payload already carried `ciCure.reason`; the prose detail used to end at the raw trunk read.
11111
+ return { ...raw, detail: `${raw.detail}${doorRefusalNote(cureVerdict, grantVerdict)}`, grantVerdict, cureVerdict, redSha };
11112
+ }
11113
+
11114
+ /**
11115
+ * Which red-trunk door let a trunk-CI row pass — `'cure rule'`, `'ci-grant'`, or null for a row that
11116
+ * passed on its own (green) or did not pass (#538: B1 re-measures only a door the table relied on).
11117
+ */
11118
+ function doorThatAdmitted(ciResult) {
11119
+ if (!ciResult || !ciResult.ok) return null;
11120
+ if (ciResult.cureVerdict && ciResult.cureVerdict.ok) return 'cure rule';
11121
+ if (ciResult.grantVerdict && ciResult.grantVerdict.ok) return 'ci-grant';
11122
+ return null;
11123
+ }
11124
+
11125
+ /** #538: the pause before B1's one re-measure — long enough for a transient `gh` failure to clear. */
11126
+ const B1_REMEASURE_MS = Number.isFinite(Number(process.env.COLAB_B1_REMEASURE_MS))
11127
+ && process.env.COLAB_B1_REMEASURE_MS !== '' ? Number(process.env.COLAB_B1_REMEASURE_MS) : 3000;
11128
+
11129
+ /**
11130
+ * The " — cure rule (#281): …; ci-grant (#105): …" suffix of a refused trunk-CI row (#534). Empty
11131
+ * when neither door was consulted. One clause per door, each its own refusal reason verbatim — the
11132
+ * cure's `reason`, the grant's per-issue `missing[].reason` — never a re-wording, so the prose and
11133
+ * the `--dry --json` fields cannot read differently.
11134
+ */
11135
+ function doorRefusalNote(cureVerdict, grantVerdict) {
11136
+ const parts = [];
11137
+ if (cureVerdict && !cureVerdict.ok && cureVerdict.reason) parts.push(`cure rule (#281): ${cureVerdict.reason}`);
11138
+ if (grantVerdict && !grantVerdict.ok) {
11139
+ const why = (grantVerdict.missing || []).map((m) => (m.issue ? `#${m.issue}: ` : '') + m.reason)
11140
+ .map((s) => s.replace(/^(#\d+): \1/, '$1')).join('; ');
11141
+ if (why) parts.push(`ci-grant (#105): ${why}`);
11142
+ }
11143
+ return parts.length ? ` — ${parts.join(' · ')}` : '';
11109
11144
  }
11110
11145
 
11111
11146
  /**
@@ -13146,12 +13181,29 @@ function cmdShip(argv) {
13146
13181
  let ciGrantForTrailer = null; // #105: set below when B1 shipped UNDER a grant — read at commit-message time
13147
13182
  let ciCureForTrailer = null; // #281: set below when B1 shipped UNDER the cure rule — read at commit-message time
13148
13183
  if (gh) {
13149
- const ciResultB1 = shipCiCheck(repoAbs, gh, target, trunk,
13184
+ const measureB1 = () => shipCiCheck(repoAbs, gh, target, trunk,
13150
13185
  (redSha) => shipCiGrants(repoAbs, gh, sess.issues, sess.branch, trunk, redSha),
13151
13186
  (redSha) => shipCiCure(repoAbs, gh, target, trunk, redSha, sess.branch), sess.branch);
13187
+ let ciResultB1 = measureB1();
13188
+ // #538: the table admitted this branch through a door (cure or grant) at red sha X, and B1 —
13189
+ // seconds later, at the SAME red sha — refused. Nothing the door judges moved (trunk's head is
13190
+ // X in both reads), so the likeliest cause is one of the ~10 `gh` reads a door makes failing
13191
+ // once, which every door reads as a refusal (fail closed). Measured: `--dry` said READY and the
13192
+ // real ship aborted here with only the raw "conclusion=failure". Re-measure ONCE, in full —
13193
+ // never reuse the table's verdict (B1 exists to catch a change) — and if it refuses again, abort
13194
+ // saying it was the door, with the door's own reason.
13195
+ const tableDoor = doorThatAdmitted(ciResult);
13196
+ if (!ciResultB1.ok && tableDoor && ciResultB1.redSha && ciResultB1.redSha === ciResult.redSha) {
13197
+ warn(` B1: the ${tableDoor} admitted this branch in the table at ${target}@${shortSha(ciResult.redSha)} but refused on the re-check at the same sha — re-measuring once (a failed read refuses).`);
13198
+ ciWait.sleepSync(B1_REMEASURE_MS);
13199
+ ciResultB1 = measureB1();
13200
+ }
13152
13201
  if (!ciResultB1.ok) {
13153
13202
  cleanupEphemeral();
13154
- process.stderr.write(`✗ B1: CI for ${target} is no longer green — aborting before merge. Nothing pushed. (${ciResultB1.detail})\n`);
13203
+ const sameRed = tableDoor && ciResultB1.redSha && ciResultB1.redSha === ciResult.redSha;
13204
+ process.stderr.write(sameRed
13205
+ ? `✗ B1: the ${tableDoor} admitted this branch in the precondition table, then refused twice on the re-check at the same ${target}@${shortSha(ciResult.redSha)} — aborting before merge. Nothing pushed. (${ciResultB1.detail})\n`
13206
+ : `✗ B1: CI for ${target} is no longer green — aborting before merge. Nothing pushed. (${ciResultB1.detail})\n`);
13155
13207
  return 1;
13156
13208
  }
13157
13209
  if (ciResultB1.cureVerdict && ciResultB1.cureVerdict.ok) {