@futurelastic/colab-handbook 1.14.1-rc.2 → 1.14.1-rc.3
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 +1 -1
- package/tools/colab +12 -1
- package/tools/lib/ci-grant.js +34 -5
package/package.json
CHANGED
package/tools/colab
CHANGED
|
@@ -10588,7 +10588,10 @@ function ciGrantTrailerLine(grantVerdict, branch, trunk) {
|
|
|
10588
10588
|
// scan (ci-cure.js priorRedShaFromMessage) reads is unchanged.
|
|
10589
10589
|
const rv = grantVerdict.granted.filter((x) => x.role && x.role !== 'human');
|
|
10590
10590
|
const via = rv.length ? ` via ${rv[0].role} ${[...new Set(rv.map((x) => x.reviewer))].join(',')}` : '';
|
|
10591
|
-
|
|
10591
|
+
// #615: a grant that survived a pure trunk sync says so — the evidence sha is what the human
|
|
10592
|
+
// reviewed, the synced head is what CI ran green and what lands.
|
|
10593
|
+
const sy = g.syncedTo ? ` synced-to ${shortSha(g.syncedTo)} by ${g.syncMerges} trunk merge${g.syncMerges === 1 ? '' : 's'}` : '';
|
|
10594
|
+
return `CI-Grant: ${issues} branch ${branch} over-red ${trunk}@${shortSha(g.redSha)} evidence ${shortSha(g.evidenceSha)}${sy}${via}`;
|
|
10592
10595
|
}
|
|
10593
10596
|
|
|
10594
10597
|
/**
|
|
@@ -11964,6 +11967,14 @@ function shipCiGrants(repoAbs, gh, issues, branch, trunk, redSha) {
|
|
|
11964
11967
|
return ciGrant.evaluateShipSet(issues, records, branch, trunk, redSha, evidence, labels.CI_GRANT_LABEL, {
|
|
11965
11968
|
trust: trustAt(repoAbs, trunk),
|
|
11966
11969
|
labelActors: (n) => git.ghIssueLabelActors(repoAbs, n, labels.CI_GRANT_LABEL),
|
|
11970
|
+
// #615: the head's pure trunk-sync lineage, bounded by the RED sha (not trunk's tip) — a merge of
|
|
11971
|
+
// anything past what the human reviewed against is not a sync this grant covers.
|
|
11972
|
+
// The head may have been synced from another machine: fetch it when absent (a failed fetch just
|
|
11973
|
+
// yields an empty chain — the grant voids, as before #615).
|
|
11974
|
+
syncChain: (head, red) => {
|
|
11975
|
+
if (!git.git(['cat-file', '-e', `${head}^{commit}`], repoAbs).ok) git.git(['fetch', '--quiet', git.remoteFor(repoAbs) || 'origin', head], repoAbs);
|
|
11976
|
+
return shipHandoff.syncMergeChain((a) => git.git(a, repoAbs), head, red);
|
|
11977
|
+
},
|
|
11967
11978
|
// #504 — the reviewer role: the opt-in as committed on TRUNK (never the branch), the clock for a
|
|
11968
11979
|
// host's revoke window, and trunk's red checks at redSha, read lazily and at most once.
|
|
11969
11980
|
policy: ciGrant.parseGrantPolicy(projectDocAt(repoAbs, trunk)).policy,
|
package/tools/lib/ci-grant.js
CHANGED
|
@@ -159,7 +159,9 @@ const { TRUSTED_ASSOCIATIONS, authorIsHuman, labelApplierIsHuman } = require('./
|
|
|
159
159
|
*
|
|
160
160
|
* `opts` (#407) — OPTIONAL `{ trust, labelActors }`, the same contract as migration-grant.js's
|
|
161
161
|
* evaluateIssue: absent/undeclared trust keeps the association check byte-identical; declared, the
|
|
162
|
-
* grant author and the label's latest applier must both be listed in trust-humans.
|
|
162
|
+
* grant author and the label's latest applier must both be listed in trust-humans. `opts.syncChain`
|
|
163
|
+
* (#615) — `(headSha, redSha) => [sha…]`, see syncedFrom: lets the grant survive a pure trunk sync
|
|
164
|
+
* of the reviewed head; a granted verdict then carries `synced: { to, merges }` (else null).
|
|
163
165
|
*/
|
|
164
166
|
function evaluateIssue(record, branch, trunk, redTrunkSha, evidence, issueNum, labelName, opts) {
|
|
165
167
|
const trust = opts && opts.trust;
|
|
@@ -206,9 +208,19 @@ function evaluateIssue(record, branch, trunk, redTrunkSha, evidence, issueNum, l
|
|
|
206
208
|
return { issue, ok: false, grant: g,
|
|
207
209
|
reason: `#${issue}'s grant requires a completed, successful CI run on \`${branch}\`'s current head — none exists` };
|
|
208
210
|
}
|
|
211
|
+
let synced = null;
|
|
209
212
|
if (evidence.sha !== g.evidenceSha) {
|
|
210
|
-
|
|
211
|
-
|
|
213
|
+
// #615: the stale-base sync ship itself demands (#395) must not void the grant ship demands. A
|
|
214
|
+
// head that is the reviewed head plus nothing but PURE merges of trunk at-or-before the red sha
|
|
215
|
+
// (ship-handoff.js syncMergeChain, the #579 proof: two parents, the second already in the red
|
|
216
|
+
// sha, tree == git's own conflict-free merge) carries no content the human did not review —
|
|
217
|
+
// only trunk content the grant already exists to exempt. Anything else still voids it.
|
|
218
|
+
const at = syncedFrom(opts, evidence.sha, g.redSha, g.evidenceSha);
|
|
219
|
+
if (at < 0) {
|
|
220
|
+
return { issue, ok: false, grant: g,
|
|
221
|
+
reason: `#${issue}'s grant was reviewed against evidence run \`${g.evidenceSha}\`, but \`${branch}\`'s head is now \`${evidence.sha}\` — the branch moved since the human reviewed it by more than a clean merge of trunk up to the red sha` };
|
|
222
|
+
}
|
|
223
|
+
synced = { to: evidence.sha, merges: at + 1 };
|
|
212
224
|
}
|
|
213
225
|
if (trust && trust.declared) {
|
|
214
226
|
// #407 Wanted 2 — the label applier, read last: only once the grant would otherwise pass.
|
|
@@ -217,7 +229,23 @@ function evaluateIssue(record, branch, trunk, redTrunkSha, evidence, issueNum, l
|
|
|
217
229
|
const lab = labelApplierIsHuman(actors, trust, labelName);
|
|
218
230
|
if (!lab.ok) return { issue, ok: false, grant: g, reason: `#${issue}: ${lab.reason}` };
|
|
219
231
|
}
|
|
220
|
-
return { issue, ok: true, grant: g, reason: '' };
|
|
232
|
+
return { issue, ok: true, grant: g, synced, reason: '' };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* #615 — where in the head's pure-sync lineage the reviewed evidence sha sits: the 0-based index of
|
|
237
|
+
* the sync merge whose first parent is `evidenceSha` (so `+1` merges were added on top of it), or -1
|
|
238
|
+
* when it is not there or the lineage could not be measured. `opts.syncChain(headSha, redSha)` is the
|
|
239
|
+
* caller's git thunk returning ship-handoff.js syncMergeChain's nearest-first sha list (this module
|
|
240
|
+
* stays pure); absent, throwing or non-array reads as "no proof" — the grant voids, as before #615.
|
|
241
|
+
*/
|
|
242
|
+
function syncedFrom(opts, headSha, redSha, evidenceSha) {
|
|
243
|
+
let chain = null;
|
|
244
|
+
try { chain = opts && typeof opts.syncChain === 'function' ? opts.syncChain(headSha, redSha) : null; } catch (_) { chain = null; }
|
|
245
|
+
if (!Array.isArray(chain)) return -1;
|
|
246
|
+
const want = String(evidenceSha || '').toLowerCase();
|
|
247
|
+
if (!want) return -1;
|
|
248
|
+
return chain.findIndex((s) => String(s || '').toLowerCase() === want);
|
|
221
249
|
}
|
|
222
250
|
|
|
223
251
|
/**
|
|
@@ -257,7 +285,8 @@ function evaluateShipSet(issues, records, branch, trunk, redTrunkSha, evidence,
|
|
|
257
285
|
const rec = records ? records[n] : null;
|
|
258
286
|
const v = evaluateIssue(rec, branch, trunk, redTrunkSha, evidence, n, labelName, opts);
|
|
259
287
|
if (v.ok) {
|
|
260
|
-
granted.push({ issue: n, branch: v.grant.branch, by: v.grant.login, at: v.grant.at, redSha: v.grant.redSha, evidenceSha: v.grant.evidenceSha
|
|
288
|
+
granted.push({ issue: n, branch: v.grant.branch, by: v.grant.login, at: v.grant.at, redSha: v.grant.redSha, evidenceSha: v.grant.evidenceSha,
|
|
289
|
+
...(v.synced ? { syncedTo: v.synced.to, syncMerges: v.synced.merges } : {}) });
|
|
261
290
|
continue;
|
|
262
291
|
}
|
|
263
292
|
// #504: a reviewer grant is consulted only when the human one failed AND the issue carries a
|