@futurelastic/colab-handbook 1.12.0-rc.43 → 1.12.0-rc.45

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/package.json CHANGED
@@ -27,5 +27,5 @@
27
27
  "engines": {
28
28
  "node": ">=18"
29
29
  },
30
- "version": "1.12.0-rc.43"
30
+ "version": "1.12.0-rc.45"
31
31
  }
@@ -361,6 +361,15 @@ jobs:
361
361
  if: steps.scripts.outputs.lint == 'true'
362
362
  run: npm run lint
363
363
 
364
+ # EDIT: cap your test runner's workers in CI, in its own config (#478). vitest,
365
+ # jest, node:test and playwright start one worker per CPU the job can SEE. On a
366
+ # self-hosted pool slot that is often the whole host's count, while the slot
367
+ # caps only memory. A host upgrade then adds workers until the slot is
368
+ # throttled. There is no OOM, the tests time out, and trunk goes red with no
369
+ # code change. Use a fixed number sized to the slot's memory, e.g. vitest
370
+ # `maxWorkers: process.env.CI ? 4 : undefined`, jest `--maxWorkers=4`,
371
+ # node:test `--test-concurrency=4`. GitHub Actions sets CI=true. Why and how
372
+ # to size it: CONVENTIONS.md §7, "Self-hosted runners".
364
373
  - name: Test
365
374
  if: steps.scripts.outputs.test == 'true'
366
375
  run: npm test
package/tools/colab CHANGED
@@ -10142,13 +10142,58 @@ function descriptorHolds(doc) {
10142
10142
  * caller can build the --dry --json `ciGrant`/`ciCure` payloads from the SAME verdicts the prose
10143
10143
  * detail string was built from — see ciGrantPayload/ciCurePayload, below.
10144
10144
  */
10145
- function shipCiCheck(repoAbs, gh, target, trunk, grantThunk, cureThunk) {
10145
+ function shipCiCheck(repoAbs, gh, target, trunk, grantThunk, cureThunk, branch = null) {
10146
10146
  const name = `${target === trunk ? 'trunk' : 'line'} CI green`;
10147
10147
  const r = readCiVerdict(repoAbs, gh, target, trunk);
10148
+ const nw = noWorkflowTrunkDoor(repoAbs, r, target, trunk, branch);
10149
+ if (nw) return { name, ...nw, grantVerdict: null, cureVerdict: null };
10148
10150
  if (r.final) return { name, ...r.verdict, grantVerdict: null, cureVerdict: null };
10149
10151
  return applyRedTrunkExemptions({ name, ...r.verdict }, target, trunk, r.run.sha, grantThunk, cureThunk);
10150
10152
  }
10151
10153
 
10154
+ /**
10155
+ * #482: a trunk with NO repo-owned workflow file at its head sha (a freshly adopted repo whose
10156
+ * adoption branch is what adds CI) can never draw a run, so its `none` is not a gap in CI — there is
10157
+ * no CI there to be red. It reads `none` and gets Branch CI's `none`-that-cannot-arrive treatment
10158
+ * (CONVENTIONS.md §4): the candidate's OWN run at its remote head decides. Green there → the row
10159
+ * passes; anything else → the ordinary refusal stands, with the reason appended.
10160
+ *
10161
+ * Fails closed: only a trunk sha present locally whose tree demonstrably has no
10162
+ * `.github/workflows/*.yml|yaml` qualifies. A trunk that HAS workflows but no run at its sha is a
10163
+ * real gap (CI not wired, or never started) and still blocks exactly as before. Runs ahead of the
10164
+ * #413 grace window too: a run that can never exist is not worth waiting ten minutes for. Returns null when
10165
+ * the door does not apply, or a `{ok, class, detail}` verdict when it does.
10166
+ */
10167
+ function noWorkflowTrunkDoor(repoAbs, r, target, trunk, branch) {
10168
+ if (target !== trunk || !branch || !r.run || r.run.status !== 'none' || !r.run.sha || r.verdict.ok) return null;
10169
+ if (trunkWorkflowFiles(repoAbs, r.run.sha) !== 0) return null;
10170
+ const at = `${trunk}@${shortSha(r.run.sha)}`;
10171
+ const own = git.ghRunForSha(repoAbs, branch);
10172
+ // Branch not on the remote, or its runs unreadable: nothing to decide with — the prior verdict stands.
10173
+ if (!own) return null;
10174
+ const ownAt = own.sha ? `${branch}@${shortSha(own.sha)}` : branch;
10175
+ if (own && own.status === 'completed' && own.conclusion === 'success') {
10176
+ const n = own.runCount == null ? 1 : own.runCount;
10177
+ return { ok: true, class: null,
10178
+ detail: `none — ${at} has no repo-owned workflow, so nothing there can be red (#482); the branch's own run decides: ${n} run${n === 1 ? '' : 's'} at ${ownAt}: ${n === 1 ? 'success' : 'all success'}${excludedRunsNote(r.run)}` };
10179
+ }
10180
+ const why = own.status === 'none' ? 'has no run' : `is status=${own.status} conclusion=${own.conclusion || 'none'}`;
10181
+ return { ok: false, class: own.status !== 'completed' && own.status !== 'none' ? SELF_CLEARING : HUMAN_GATED,
10182
+ detail: `none — ${at} has no repo-owned workflow (#482), so the branch's own run decides, and ${ownAt} ${why}${excludedRunsNote(r.run)}` };
10183
+ }
10184
+
10185
+ /** Number of workflow files in `.github/workflows` at `sha`, or null when the tree cannot be read. */
10186
+ function trunkWorkflowFiles(repoAbs, sha) {
10187
+ if (!git.git(['cat-file', '-e', `${sha}^{commit}`], repoAbs).ok) return null;
10188
+ const ls = git.git(['ls-tree', '--name-only', `${sha}:.github/workflows`], repoAbs);
10189
+ if (!ls.ok) {
10190
+ // No such directory is a real zero; any other failure is unknown (fail closed).
10191
+ const dir = git.git(['ls-tree', '--name-only', sha, '.github/workflows'], repoAbs);
10192
+ return dir.ok && dir.stdout.trim() === '' ? 0 : null;
10193
+ }
10194
+ return ls.stdout.split('\n').map((x) => x.trim()).filter((f) => /\.ya?ml$/.test(f)).length;
10195
+ }
10196
+
10152
10197
  /**
10153
10198
  * The CI read and its classification, BEFORE any exemption door (#463) — the one function both
10154
10199
  * `shipCiCheck` above and `colab trunk-ci` (cmdTrunkCi) call, so code-triage's "is trunk red?" and
@@ -10925,7 +10970,7 @@ function cmdShipDryJson(opts) {
10925
10970
  const gh = isGhUsable(repoAbs);
10926
10971
  const ciResultJson = shipCiCheck(repoAbs, gh, target, trunk,
10927
10972
  (redSha) => shipCiGrants(repoAbs, gh, sess.issues, sess.branch, trunk, redSha),
10928
- (redSha) => shipCiCure(repoAbs, gh, target, trunk, redSha, sess.branch));
10973
+ (redSha) => shipCiCure(repoAbs, gh, target, trunk, redSha, sess.branch), sess.branch);
10929
10974
  ciGrantPayloadVal = ciGrantPayload(ciResultJson);
10930
10975
  ciCurePayloadVal = ciCurePayload(ciResultJson);
10931
10976
  checks.push({ name: ciResultJson.name, ok: ciResultJson.ok, class: ciResultJson.class, detail: ciResultJson.detail });
@@ -11907,7 +11952,7 @@ function cmdShip(argv) {
11907
11952
  // ordinary green-trunk ship makes zero extra `gh` reads for a door nobody needs.
11908
11953
  const ciResult = shipCiCheck(repoAbs, gh, target, trunk,
11909
11954
  (redSha) => shipCiGrants(repoAbs, gh, sess.issues, sess.branch, trunk, redSha),
11910
- (redSha) => shipCiCure(repoAbs, gh, target, trunk, redSha, sess.branch));
11955
+ (redSha) => shipCiCure(repoAbs, gh, target, trunk, redSha, sess.branch), sess.branch);
11911
11956
  const ciOk = ciResult.ok;
11912
11957
  checks.push([ciResult.ok ? '✓' : '✗', ciResult.name, ciResult.detail]);
11913
11958
 
@@ -12368,7 +12413,7 @@ function cmdShip(argv) {
12368
12413
  if (gh) {
12369
12414
  const ciResultB1 = shipCiCheck(repoAbs, gh, target, trunk,
12370
12415
  (redSha) => shipCiGrants(repoAbs, gh, sess.issues, sess.branch, trunk, redSha),
12371
- (redSha) => shipCiCure(repoAbs, gh, target, trunk, redSha, sess.branch));
12416
+ (redSha) => shipCiCure(repoAbs, gh, target, trunk, redSha, sess.branch), sess.branch);
12372
12417
  if (!ciResultB1.ok) {
12373
12418
  cleanupEphemeral();
12374
12419
  process.stderr.write(`✗ B1: CI for ${target} is no longer green — aborting before merge. Nothing pushed. (${ciResultB1.detail})\n`);