@futurelastic/colab-handbook 1.12.0-rc.25 → 1.12.0-rc.26

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.25"
30
+ "version": "1.12.0-rc.26"
31
31
  }
package/tools/colab CHANGED
@@ -10105,7 +10105,7 @@ function shipCiCheck(repoAbs, gh, target, trunk, grantThunk, cureThunk) {
10105
10105
  const fresh = ciVerdict.emptyReadVerdict(git.commitTimeMs(repoAbs, run.sha));
10106
10106
  if (fresh.fresh) {
10107
10107
  verdict = { ok: false, class: SELF_CLEARING,
10108
- detail: `no run yet for ${at} — committed ${fresh.minutes.toFixed(1)}m ago, inside the ${ciVerdict.EMPTY_READ_GRACE_MINUTES}m grace; retry later` };
10108
+ detail: `no run yet for ${at} — committed ${fresh.minutes.toFixed(1)}m ago, inside the ${ciVerdict.EMPTY_READ_GRACE_MINUTES}m grace; retry later${excludedRunsNote(run)}` };
10109
10109
  }
10110
10110
  }
10111
10111
  // #373: trunk's own run not there yet or still in flight (never a finished red) — a batch that landed
@@ -10142,6 +10142,23 @@ function shipCiCheck(repoAbs, gh, target, trunk, grantThunk, cureThunk) {
10142
10142
  * the detail string still reads sensibly rather than "undefined runs".
10143
10143
  */
10144
10144
  function classifyCiRun(repoAbs, run, at) {
10145
+ const v = classifyCiRunRaw(repoAbs, run, at);
10146
+ return { ...v, detail: v.detail + excludedRunsNote(run) };
10147
+ }
10148
+
10149
+ /**
10150
+ * #451: the runs a verdict did NOT count, named in its detail — runs from workflows the repo does
10151
+ * not own (`event: dynamic`, e.g. Dependabot Updates) are dropped by git.summarizeRunsForCommit
10152
+ * before the verdict is computed, and a reader must be able to see what was dropped. '' when none.
10153
+ */
10154
+ function excludedRunsNote(run) {
10155
+ const ex = run && Array.isArray(run.excluded) ? run.excluded : [];
10156
+ if (!ex.length) return '';
10157
+ const names = ex.map((x) => `${x.workflowName || 'unnamed'} (${x.conclusion || x.status || '?'}${x.databaseId ? `, run ${x.databaseId}` : ''})`);
10158
+ return ` — excluded ${ex.length} run${ex.length === 1 ? '' : 's'} from workflows this repo does not own (event: dynamic, #451): ${names.join(', ')}`;
10159
+ }
10160
+
10161
+ function classifyCiRunRaw(repoAbs, run, at) {
10145
10162
  if (run.status === 'completed') {
10146
10163
  if (run.conclusion === 'success') {
10147
10164
  const n = run.runCount == null ? 1 : run.runCount;
@@ -10476,7 +10493,10 @@ function shipCureJobEvidence(repoAbs, trunk, redSha, branch, evRun) {
10476
10493
  // ALL runs at the red sha, not the single row `ghRunForCommit` would pick: a red job can sit in a
10477
10494
  // sibling workflow the picker never returned, and admitting a carve-out while that job is still
10478
10495
  // red is exactly the failure this evidence exists to prevent.
10479
- const redRuns = git.ghRunsForCommit(repoAbs, trunk, redSha);
10496
+ // #451: a run from a workflow the repo does not own is not part of trunk's red — same drop the
10497
+ // verdict itself makes (git.summarizeRunsForCommit), so cure evidence never chases its jobs.
10498
+ const redRunsAll = git.ghRunsForCommit(repoAbs, trunk, redSha);
10499
+ const redRuns = redRunsAll === null ? null : redRunsAll.filter(git.isRepoOwnedRun);
10480
10500
  if (redRuns === null || redRuns.length === 0) return null;
10481
10501
 
10482
10502
  // Same inverted allowlist git.js uses at run level (#146/#165): only `success`/`cancelled` are
package/tools/lib/git.js CHANGED
@@ -865,7 +865,9 @@ function ghRunsForCommit(repo, branch, sha, limit = 10) {
865
865
  const r = run('gh', ['run', 'list', '--branch', branch, '-L', String(limit),
866
866
  // workflowName is additive (#338): `colab release cut`'s full-suite condition groups the rows by
867
867
  // workflow — a workflow whose only run at the sha was cancelled never ran its suite.
868
- '--json', 'headSha,status,conclusion,createdAt,databaseId,workflowName'], { cwd: repo });
868
+ // event is additive (#451): summarizeRunsForCommit drops `dynamic` rows (workflows the repo
869
+ // does not own) before it computes a verdict, and can only do that if the row says so.
870
+ '--json', 'headSha,status,conclusion,createdAt,databaseId,workflowName,event'], { cwd: repo });
869
871
  if (!r.ok) return null;
870
872
  let runs;
871
873
  try { runs = JSON.parse(r.stdout); } catch (_) { return null; }
@@ -956,9 +958,43 @@ function ghRunsSince(repo, branch, sinceDay, limit = 1000) {
956
958
  return { runs, truncated: runs.length >= limit };
957
959
  }
958
960
 
959
- /** ghRunForCommit's pick, over rows already read (null in -> null out). */
960
- function summarizeRunsForCommit(forSha, sha) {
961
- if (forSha === null) return null;
961
+ /**
962
+ * #451: a run whose `event` is `dynamic` comes from a workflow the repo does not own — GitHub's
963
+ * dynamic workflows (Dependabot Updates, code scanning default setup, …), which never execute the
964
+ * code at the sha they are filed against. Such a row is not evidence about that sha, so it is
965
+ * dropped before any verdict is computed. A row with no `event` field (an older read, a hand-built
966
+ * fixture) is kept: absence of the field never excludes anything.
967
+ */
968
+ function isRepoOwnedRun(x) {
969
+ return !(x && x.event === 'dynamic');
970
+ }
971
+
972
+ /** The dropped rows, in the compact shape a verdict detail names them by. */
973
+ function excludedRunSummary(rows) {
974
+ return rows.map((x) => ({
975
+ workflowName: x.workflowName || null, status: x.status || null,
976
+ conclusion: x.conclusion || null, databaseId: x.databaseId || null,
977
+ }));
978
+ }
979
+
980
+ /**
981
+ * ghRunForCommit's pick, over rows already read (null in -> null out).
982
+ *
983
+ * #451: rows from workflows the repo does not own (`event: dynamic`) are dropped first; when any
984
+ * were, the result carries an additive `excluded` list naming them, so a caller can say what it
985
+ * did not count. When nothing is left the sha reads `none`, exactly as if no run had existed —
986
+ * a repo-owned red is never affected, since only `dynamic` rows are dropped.
987
+ */
988
+ function summarizeRunsForCommit(allForSha, sha) {
989
+ if (allForSha === null) return null;
990
+ const dropped = allForSha.filter((x) => !isRepoOwnedRun(x));
991
+ const forSha = dropped.length ? allForSha.filter(isRepoOwnedRun) : allForSha;
992
+ const extra = dropped.length ? { excluded: excludedRunSummary(dropped) } : {};
993
+ const r = summarizeRepoOwnedRuns(forSha, sha);
994
+ return { ...r, ...extra };
995
+ }
996
+
997
+ function summarizeRepoOwnedRuns(forSha, sha) {
962
998
  if (forSha.length === 0) return { status: 'none', conclusion: null, sha, createdAt: null, databaseId: null, runCount: 0 };
963
999
 
964
1000
  // runCount (#176) is additive: how many sibling workflow rows exist at this sha, so a caller can
@@ -1070,7 +1106,7 @@ module.exports = {
1070
1106
  worktreeList, worktreeListDetailed, resolveWorktreePathForBranch, gitFailureLine,
1071
1107
  dirtyTracked, dirtyUntracked, dirtyAny,
1072
1108
  ghAvailable, ghState, ghIssueEdit, ghListLabels, ghOpenIssueNumbersByLabel, ghAssignedIssues,
1073
- ghCurrentLogin, ghIssueView, ghIssueComment, ghRunForSha, ghRunForCommit, ghRunsForCommit, ghRunsForRef, ghRunsAtCommit, ghRunForCommitAnyRef, commitTimeMs, ghRunsSince, summarizeRunsForCommit,
1109
+ ghCurrentLogin, ghIssueView, ghIssueComment, ghRunForSha, ghRunForCommit, ghRunsForCommit, ghRunsForRef, ghRunsAtCommit, ghRunForCommitAnyRef, commitTimeMs, ghRunsSince, summarizeRunsForCommit, isRepoOwnedRun,
1074
1110
  ghRunJobCount, ghRunJobs,
1075
1111
  ghIssueListByLabel, ghLabelDelete, ghLabelCreate, ghListLabelsDetailed, ghLabelEditDescription,
1076
1112
  ghApi, isGraphqlRateLimit, ghIssueRelease, ghClaimHolder, ghIssueLabelEvents, ghIssueLabelActors,