@futurelastic/colab-handbook 1.12.0-rc.27 → 1.12.0-rc.30

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.27"
30
+ "version": "1.12.0-rc.30"
31
31
  }
@@ -403,7 +403,19 @@ jobs:
403
403
  *-*) KIND=(--prerelease --latest=false) ;;
404
404
  *) KIND=(--latest) ;;
405
405
  esac
406
- gh release create "$TAG" --verify-tag --title "$TAG" --notes-file "$NOTES" --generate-notes "${KIND[@]}"
406
+ # The view above is a check, not a lock: `colab release cut` publishes a candidate's
407
+ # pre-release itself, and the API can still answer 404 for it seconds later (#462 — a
408
+ # trunk went red on exactly that 422). So a create refused because the Release already
409
+ # exists is the skip case too, decided from the create's own answer.
410
+ ERR="$RUNNER_TEMP/create-$TAG.err"
411
+ if ! gh release create "$TAG" --verify-tag --title "$TAG" --notes-file "$NOTES" --generate-notes "${KIND[@]}" 2> "$ERR"; then
412
+ cat "$ERR" >&2
413
+ if grep -qiE 'already[ _]exists' "$ERR"; then
414
+ echo "$TAG already has a Release (published while this step ran) — skipping"
415
+ continue
416
+ fi
417
+ exit 1
418
+ fi
407
419
  echo "Published $TAG" | tee -a "$GITHUB_STEP_SUMMARY"
408
420
  done
409
421
 
package/tools/colab CHANGED
@@ -10179,7 +10179,19 @@ function shipCiCheck(repoAbs, gh, target, trunk, grantThunk, cureThunk) {
10179
10179
  */
10180
10180
  function classifyCiRun(repoAbs, run, at) {
10181
10181
  const v = classifyCiRunRaw(repoAbs, run, at);
10182
- return { ...v, detail: v.detail + excludedRunsNote(run) };
10182
+ return { ...v, detail: v.detail + excludedRunsNote(run) + supersededRunsNote(run) };
10183
+ }
10184
+
10185
+ /**
10186
+ * #461: earlier runs of the same workflow at this sha that a newer run of it superseded — set aside
10187
+ * by git.summarizeRunsForCommit before the verdict, and named here so the reader sees what the
10188
+ * verdict did not judge. '' when none.
10189
+ */
10190
+ function supersededRunsNote(run) {
10191
+ const sup = run && Array.isArray(run.superseded) ? run.superseded : [];
10192
+ if (!sup.length) return '';
10193
+ const names = sup.map((x) => `${x.workflowName || 'unnamed'} (${x.conclusion || x.status || '?'}${x.databaseId ? `, run ${x.databaseId}` : ''})`);
10194
+ return ` — set aside ${sup.length} superseded run${sup.length === 1 ? '' : 's'} (a newer run of the same workflow decides, #461): ${names.join(', ')}`;
10183
10195
  }
10184
10196
 
10185
10197
  /**
package/tools/lib/git.js CHANGED
@@ -984,16 +984,84 @@ function excludedRunSummary(rows) {
984
984
  * were, the result carries an additive `excluded` list naming them, so a caller can say what it
985
985
  * did not count. When nothing is left the sha reads `none`, exactly as if no run had existed —
986
986
  * a repo-owned red is never affected, since only `dynamic` rows are dropped.
987
+ *
988
+ * #461: the repo-owned rows are then reduced to the newest run per workflow (newestRunPerWorkflow,
989
+ * below); the rows that reduction set aside ride along as an additive `superseded` list, same shape
990
+ * as `excluded`, present only when non-empty. Every quantifier below runs over the reduced set.
987
991
  */
988
992
  function summarizeRunsForCommit(allForSha, sha) {
989
993
  if (allForSha === null) return null;
990
994
  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);
995
+ const owned = dropped.length ? allForSha.filter(isRepoOwnedRun) : allForSha;
996
+ const { heads, superseded } = newestRunPerWorkflow(owned);
997
+ const extra = {
998
+ ...(dropped.length ? { excluded: excludedRunSummary(dropped) } : {}),
999
+ ...(superseded.length ? { superseded: excludedRunSummary(superseded) } : {}),
1000
+ };
1001
+ const r = summarizeRepoOwnedRuns(heads, sha);
994
1002
  return { ...r, ...extra };
995
1003
  }
996
1004
 
1005
+ /** Sort key for "which run of one workflow is newer": createdAt, then databaseId; null = unknown. */
1006
+ function runRecency(x) {
1007
+ const t = x && x.createdAt ? Date.parse(x.createdAt) : NaN;
1008
+ const id = x && x.databaseId != null ? Number(x.databaseId) : NaN;
1009
+ return { t: Number.isFinite(t) ? t : null, id: Number.isFinite(id) ? id : null };
1010
+ }
1011
+
1012
+ /** True when `a` is provably newer than `b`; false when older OR when neither key can tell. */
1013
+ function isNewerRun(a, b) {
1014
+ const ra = runRecency(a); const rb = runRecency(b);
1015
+ if (ra.t !== null && rb.t !== null && ra.t !== rb.t) return ra.t > rb.t;
1016
+ if (ra.id !== null && rb.id !== null && ra.id !== rb.id) return ra.id > rb.id;
1017
+ return false;
1018
+ }
1019
+
1020
+ /**
1021
+ * #461: each workflow is judged by its NEWEST run at the sha — an earlier attempt of the SAME
1022
+ * workflow that a later one superseded no longer vetoes it. Measured: a `workflow_run`-triggered
1023
+ * workflow fired once per CI attempt at one trunk sha; the two red CI attempts gave it two
1024
+ * `skipped` runs, the green third attempt a `success`, and the two stale rows held the sha
1025
+ * not-green forever (a re-run replays the original payload and skips again).
1026
+ *
1027
+ * Grouped by `workflowName` ONLY. A row with no workflowName (an older read, a hand-built fixture)
1028
+ * is its own group — absence of the field never collapses anything, so every verdict that could be
1029
+ * computed before #461 without the field is computed identically now. Rows of DIFFERENT workflows
1030
+ * are never reduced: a failing workflow beside a passing one still reads not-green (#146/#162).
1031
+ *
1032
+ * `cancelled` never supersedes: a cancelled run executed nothing and has always been neutral here
1033
+ * (#92), so it cannot stand for its workflow while that workflow has any non-cancelled run at the
1034
+ * sha — otherwise a cancel-in-progress straggler created after the passing run would turn #92's
1035
+ * green back into "every run was cancelled". It still counts when it is all a workflow has.
1036
+ *
1037
+ * Newest = later createdAt, then higher databaseId; when neither key separates two rows, gh's
1038
+ * newest-first order decides (the first row seen is kept). An unfinished newest run still blocks
1039
+ * green (#307): it is the head, so the all-finished quantifier sees it.
1040
+ *
1041
+ * Returns the heads in their original order (callers' newest-first `forSha[0]` pick relies on it)
1042
+ * plus the rows they superseded.
1043
+ */
1044
+ function newestRunPerWorkflow(rows) {
1045
+ const best = new Map();
1046
+ rows.forEach((x, i) => {
1047
+ const name = x && x.workflowName;
1048
+ if (!name) return;
1049
+ const cur = best.get(name);
1050
+ if (cur === undefined) { best.set(name, i); return; }
1051
+ const c = rows[cur];
1052
+ const xCancelled = x.conclusion === 'cancelled';
1053
+ const cCancelled = c.conclusion === 'cancelled';
1054
+ if (xCancelled !== cCancelled) { if (cCancelled) best.set(name, i); return; }
1055
+ if (isNewerRun(x, c)) best.set(name, i);
1056
+ });
1057
+ const heads = []; const superseded = [];
1058
+ rows.forEach((x, i) => {
1059
+ const name = x && x.workflowName;
1060
+ if (!name || best.get(name) === i) heads.push(x); else superseded.push(x);
1061
+ });
1062
+ return { heads, superseded };
1063
+ }
1064
+
997
1065
  function summarizeRepoOwnedRuns(forSha, sha) {
998
1066
  if (forSha.length === 0) return { status: 'none', conclusion: null, sha, createdAt: null, databaseId: null, runCount: 0 };
999
1067
 
@@ -1001,6 +1069,8 @@ function summarizeRepoOwnedRuns(forSha, sha) {
1001
1069
  // report "N runs at <sha>: all success" instead of a singular verdict that hides how many
1002
1070
  // workflows actually agreed. It is the row count BEFORE any of the picks below, not "how many
1003
1071
  // succeeded" — the picked row already tells the caller the conclusion; this tells it the sample size.
1072
+ // Since #461 that is the count of rows JUDGED (one per named workflow, after superseded attempts
1073
+ // are set aside) — "3 runs: all success" must never count two skipped attempts it did not judge.
1004
1074
  const runCount = forSha.length;
1005
1075
 
1006
1076
  // A completed sibling whose conclusion is anything but success or cancelled makes the sha
@@ -592,7 +592,7 @@ function ownsHold(rec, session) {
592
592
  * (#317.)
593
593
  *
594
594
  * WHY THIS EXISTS. A ship session recovered an issue with a no-worktree claim, which minted a
595
- * checkout hold under the identity string `coding-dashboard-1545`. It then shipped, and every later
595
+ * checkout hold under the identity string `example-orchestrator-1545`. It then shipped, and every later
596
596
  * squash-merge was refused by ITS OWN hold: the identity `colab ship` resolves comes from the
597
597
  * worktree record or a branch-keyed claim, and a no-worktree claim carries `branch: null`, so the
598
598
  * session presented a blank one. `ownsHold` is exact string equality and blank never matches, so a
@@ -663,7 +663,7 @@ function ownsPlace(rec, session, anchorOpts = {}) {
663
663
  * no two consumers disagree (#317). Returns `{cls, rec, live, reason, remedy, conflict}`.
664
664
  *
665
665
  * The live specimen this closes was not a wrong answer; it was an UNCLASSIFIED one. `colab ship`
666
- * printed `place "…" is held by session "coding-dashboard-1545"` and stopped — true, and useless:
666
+ * printed `place "…" is held by session "example-orchestrator-1545"` and stopped — true, and useless:
667
667
  * the reader could not tell from it whether the holder was itself, a corpse, or a live sibling, and
668
668
  * those three need three different next moves. The refusal now names the class and the exact next
669
669
  * command, and two of the six classes are not refusals at all.
@@ -9,8 +9,8 @@
9
9
  * PURE BY CONSTRUCTION, the release-cut.js posture: no git, no network, no `gh`, no clock (`now` is
10
10
  * passed in). The CLI in tools/colab is the measuring half.
11
11
  *
12
- * WHERE PER-CANDIDATE STATE LIVES (the contract futurelastic/hangar#125 reads — change it and every
13
- * consumer breaks, so it is frozen here and documented in tools/README.md, *Release finalize*):
12
+ * WHERE PER-CANDIDATE STATE LIVES (the contract a downstream dashboard's release view reads — change
13
+ * it and every consumer breaks, so it is frozen here and documented in tools/README.md, *Release finalize*):
14
14
  *
15
15
  * - the candidates are the annotated `vX.Y.Z-rc.N` tags on origin that `colab release cut` made
16
16
  * (first line of the tag message ends `(colab release cut)`); nothing else stores them;
@@ -179,6 +179,9 @@ function wiring(fires) {
179
179
  * databaseId}`). Same all-runs rule as summarizeRunsForCommit: any finished not-green row (cancelled
180
180
  * aside) makes it red; any unfinished row keeps it pending; green needs every row finished and at
181
181
  * least one success. `attempt` is the highest run attempt seen — how many times it was re-run.
182
+ * Unlike summarizeRunsForCommit it does NOT reduce to the newest run per workflow (#461): a batch
183
+ * ref is built fresh and re-run in place (same run, higher `attempt`), so it carries no superseded
184
+ * attempts of a workflow for that reduction to set aside.
182
185
  */
183
186
  function combinedVerdict(rows) {
184
187
  const list = Array.isArray(rows) ? rows : null;