@futurelastic/colab-handbook 1.16.0-rc.19 → 1.16.0-rc.20

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
@@ -33,5 +33,5 @@
33
33
  "engines": {
34
34
  "node": ">=18"
35
35
  },
36
- "version": "1.16.0-rc.19"
36
+ "version": "1.16.0-rc.20"
37
37
  }
package/tools/colab CHANGED
@@ -11790,7 +11790,16 @@ function treeGreenVerdict(repoAbs, run, verdict) {
11790
11790
  */
11791
11791
  function classifyCiRun(repoAbs, run, at) {
11792
11792
  const v = classifyCiRunRaw(repoAbs, run, at);
11793
- return { ...v, detail: v.detail + excludedRunsNote(run) + supersededRunsNote(run) + verifyRuns.setAsideNote(run && run.setAside) + verifyRuns.dispatchCountedNote(run && run.dispatchCounted) };
11793
+ return { ...v, detail: v.detail + excludedRunsNote(run) + supersededRunsNote(run) + verifyRuns.setAsideNote(run && run.setAside) + verifyRuns.dispatchCountedNote(run && run.dispatchCounted) + readViaNote(run) };
11794
+ }
11795
+
11796
+ /**
11797
+ * #651: the runs were read from the unfiltered `actions/runs` listing because the forge's filtered
11798
+ * queries (`head_sha=` / `branch=`) answered nothing. The verdict is judged as usual. The note says
11799
+ * how it was read, so nobody takes an empty filter index for missing CI. '' otherwise.
11800
+ */
11801
+ function readViaNote(run) {
11802
+ return run && run.readVia === 'unfiltered-listing' ? ' — read via unfiltered listing (forge filter index empty, #651)' : '';
11794
11803
  }
11795
11804
 
11796
11805
  /**
@@ -15949,8 +15958,10 @@ passed an identical tree (#493) names that run in its detail ("relied on <url>")
15949
15958
  head is local and its tree differs from trunk's, the read is RED: trunk is untested.
15950
15959
 
15951
15960
  Cost (#495): one REST read of the runs at the sha (\`actions/runs?head_sha=\`), plus one
15952
- check-runs read on a GREEN. No auth probe in front of it — the read is the probe, and an
15953
- UNREADABLE explains which credential/remote condition failed. The verdict is cached per
15961
+ check-runs read on a GREEN. An EMPTY filtered answer is re-read from the unfiltered listing
15962
+ (#651: the forge's filter index was measured empty for hours while the runs existed) — at most 3
15963
+ pages, usually 1 — and a verdict found that way says "read via unfiltered listing". No auth
15964
+ probe in front of it — the read is the probe, and an UNREADABLE explains which credential/remote condition failed. The verdict is cached per
15954
15965
  trunk+sha for ${TRUNK_CI_TTL_DEFAULT_SEC}s in the repo's git dir, shared by every session on the
15955
15966
  checkout (COLAB_TRUNK_CI_TTL=<sec> overrides, 0 disables; --fresh skips the cache for one read).
15956
15967
  To WAIT for CI, use \`colab ci-wait\` — never a loop around this command.
package/tools/lib/git.js CHANGED
@@ -1059,6 +1059,14 @@ function fullSha(repo, sha) {
1059
1059
  * Every workflow run at `sha` in ONE REST call (#495) — `actions/runs?head_sha=<sha>[&branch=<b>]`,
1060
1060
  * rows in `gh run list --json` shape. Returns `{ rows }` on success, `{ rateLimited: true }` on a
1061
1061
  * rate limit, `{}` on any other failure (the caller decides whether to fall back).
1062
+ *
1063
+ * #651: an EMPTY filtered answer is not believed on its own. The forge's filter index was measured
1064
+ * returning `total_count: 0` for both `head_sha=` and `branch=` about 10 hours after the runs
1065
+ * finished, while the unfiltered listing held them (green). Read that way, a green trunk is "CI is
1066
+ * not wired" (HUMAN_GATED). So an empty answer is re-read from the unfiltered listing, filtered
1067
+ * here by the same two keys (UNFILTERED_RUN_PAGES pages at most). Rows found that way carry
1068
+ * `readVia: 'unfiltered-listing'`, so the verdict can say how it was read. Nothing found either:
1069
+ * the empty set stands, and the read still fails closed.
1062
1070
  */
1063
1071
  function ghRunsAtShaRest(repo, sha, branch) {
1064
1072
  sha = fullSha(repo, sha); // #529: the API's head_sha is 40-hex; an abbreviated one matches no row
@@ -1068,7 +1076,51 @@ function ghRunsAtShaRest(repo, sha, branch) {
1068
1076
  const r = ghApiConditional(repo, `repos/{owner}/{repo}/actions/runs?${q}`);
1069
1077
  if (r.kind === 'rate-limited') return { rateLimited: true, detail: r.detail };
1070
1078
  if (r.kind !== 'ok' || !r.json || !Array.isArray(r.json.workflow_runs)) return {};
1071
- return { rows: r.json.workflow_runs.map(ciWait.restRow).filter((x) => x.headSha === sha) };
1079
+ const rows = r.json.workflow_runs.map(ciWait.restRow).filter((x) => x.headSha === sha);
1080
+ if (rows.length) return { rows };
1081
+ const fb = ghRunsAtShaUnfiltered(repo, sha, branch);
1082
+ if (fb.rateLimited) return fb;
1083
+ return { rows: fb.rows && fb.rows.length ? fb.rows : rows };
1084
+ }
1085
+
1086
+ /** #651: how many pages (100 runs each, newest first) the unfiltered re-read may spend. */
1087
+ const UNFILTERED_RUN_PAGES = 3;
1088
+ /** #651: a run is never created before its commit. This margin absorbs committer-clock skew. */
1089
+ const UNFILTERED_SKEW_MS = 60 * 60 * 1000;
1090
+
1091
+ /**
1092
+ * #651: the runs at `sha` (and on `branch`, when given) read from the UNFILTERED `actions/runs`
1093
+ * listing, filtered here by the same keys the server filter would have used. Bounded: at most
1094
+ * UNFILTERED_RUN_PAGES pages. It stops early on a short page, and on a page whose oldest run was
1095
+ * created before the commit, with UNFILTERED_SKEW_MS of margin. A sha with no run yet usually
1096
+ * costs one extra read, because page 1 already reaches back past the commit. Returns `{ rows }`
1097
+ * (possibly empty), `{ rateLimited: true }`, or `{}` when no page could be read.
1098
+ */
1099
+ function ghRunsAtShaUnfiltered(repo, sha, branch) {
1100
+ const ciWait = require('./ci-wait');
1101
+ const born = commitTimeMs(repo, sha);
1102
+ const floor = born == null ? null : born - UNFILTERED_SKEW_MS;
1103
+ const found = [];
1104
+ let readAny = false;
1105
+ for (let page = 1; page <= UNFILTERED_RUN_PAGES; page++) {
1106
+ const r = ghApiConditional(repo, `repos/{owner}/{repo}/actions/runs?per_page=100&page=${page}`);
1107
+ if (r.kind === 'rate-limited') return { rateLimited: true, detail: r.detail };
1108
+ if (r.kind !== 'ok' || !r.json || !Array.isArray(r.json.workflow_runs)) break;
1109
+ readAny = true;
1110
+ const raw = r.json.workflow_runs;
1111
+ for (const x of raw) {
1112
+ if (!x || x.head_sha !== sha) continue;
1113
+ if (branch && x.head_branch !== branch) continue;
1114
+ found.push({ ...ciWait.restRow(x), readVia: 'unfiltered-listing' });
1115
+ }
1116
+ if (raw.length < 100) break;
1117
+ const oldest = raw.reduce((m, x) => {
1118
+ const t = x && x.created_at ? Date.parse(x.created_at) : NaN;
1119
+ return Number.isFinite(t) && (m === null || t < m) ? t : m;
1120
+ }, null);
1121
+ if (floor != null && oldest != null && oldest < floor) break;
1122
+ }
1123
+ return readAny ? { rows: found } : {};
1072
1124
  }
1073
1125
 
1074
1126
  /** Is a `gh` binary on PATH (#495)? No API call — cached per process. The credential is proven by
@@ -1211,6 +1263,8 @@ function summarizeRunsForCommit(allForSha, sha, opts = {}) {
1211
1263
  ...(superseded.length ? { superseded: excludedRunSummary(superseded) } : {}),
1212
1264
  ...(setAside.length ? { setAside: excludedRunSummary(setAside) } : {}),
1213
1265
  ...(dispatchCounted.length ? { dispatchCounted: excludedRunSummary(dispatchCounted) } : {}),
1266
+ // #651: the rows came from the unfiltered listing because the forge's filter index was empty.
1267
+ ...(allForSha.some((x) => x && x.readVia === 'unfiltered-listing') ? { readVia: 'unfiltered-listing' } : {}),
1214
1268
  };
1215
1269
  const r = summarizeRepoOwnedRuns(heads, sha);
1216
1270
  return { ...r, ...extra };