@futurelastic/colab-handbook 1.12.0-rc.61 → 1.12.0-rc.63
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/audit/audit.mjs +13 -0
- package/package.json +2 -1
- package/tools/colab +193 -12
- package/tools/lib/ci-grant.js +272 -3
- package/tools/lib/codec/grants.d.ts +24 -0
- package/tools/lib/codec/grants.js +85 -17
- package/tools/lib/codec/samples.json +54 -0
- package/tools/lib/tracker-fake.js +195 -0
- package/tools/lib/tracker-scenarios.json +206 -0
- package/tools/lib/tracker.js +7 -4
package/audit/audit.mjs
CHANGED
|
@@ -103,6 +103,8 @@ const shipBatch = require("../tools/lib/ship-batch.js");
|
|
|
103
103
|
const migrationPaths = require("../tools/lib/migration-paths.js");
|
|
104
104
|
// #398: the `migration-grant:` policy key — read through the same module `colab migration-grant` uses.
|
|
105
105
|
const migrationGrant = require("../tools/lib/migration-grant.js");
|
|
106
|
+
// #504: the `ci-grant:` policy key — read through the same module `colab ci-grant` uses.
|
|
107
|
+
const ciGrantLib = require("../tools/lib/ci-grant.js");
|
|
106
108
|
// #407: the optional `trust-humans` list — read through the same module every grant reader uses.
|
|
107
109
|
const trustHumansLib = require("../tools/lib/trust-humans.js");
|
|
108
110
|
// #403: the `live-env:` key — read through the same module `colab gate-hermetic` uses.
|
|
@@ -1332,6 +1334,17 @@ function auditRepo(target, ctx) {
|
|
|
1332
1334
|
if (!pol.valid) fail(pol.reason);
|
|
1333
1335
|
}
|
|
1334
1336
|
|
|
1337
|
+
// ---- ci-grant (#504) -------------------------------------------------------
|
|
1338
|
+
// Who may open the red-trunk door when the cure rule refuses: `human` (absent) or `reviewer`, the
|
|
1339
|
+
// coordinator agent minting `colab ci-grant --role ci-reviewer` without COLAB_HUMAN=1.
|
|
1340
|
+
// tools/lib/ci-grant.js parseGrantPolicy is the one reading. Always reported (info.ciGrant); an
|
|
1341
|
+
// invalid value fails, because the reader then falls back to `human` silently.
|
|
1342
|
+
{
|
|
1343
|
+
const pol = ciGrantLib.parseGrantPolicy(cfg);
|
|
1344
|
+
info.ciGrant = pol.policy;
|
|
1345
|
+
if (!pol.valid) fail(pol.reason);
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1335
1348
|
// ---- trust-humans (#407) --------------------------------------------------
|
|
1336
1349
|
// Which logins count as HUMAN for a grant or a ruling. Absent = the association class, as
|
|
1337
1350
|
// before. tools/lib/trust-humans.js parseTrustHumans is the one reading. A malformed value
|
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"tools/colab",
|
|
18
18
|
"tools/lib/*.js",
|
|
19
19
|
"!tools/lib/*.test.js",
|
|
20
|
+
"tools/lib/tracker-scenarios.json",
|
|
20
21
|
"tools/lib/codec/*.js",
|
|
21
22
|
"tools/lib/codec/*.d.ts",
|
|
22
23
|
"tools/lib/codec/samples.json",
|
|
@@ -31,5 +32,5 @@
|
|
|
31
32
|
"engines": {
|
|
32
33
|
"node": ">=18"
|
|
33
34
|
},
|
|
34
|
-
"version": "1.12.0-rc.
|
|
35
|
+
"version": "1.12.0-rc.63"
|
|
35
36
|
}
|
package/tools/colab
CHANGED
|
@@ -4348,6 +4348,7 @@ function cmdDecisionList(opts) {
|
|
|
4348
4348
|
// ---------------------------------------------------------------------------
|
|
4349
4349
|
|
|
4350
4350
|
const HELP_CI_GRANT = `colab ci-grant <issue> --branch <branch> [--evidence-run <sha-or-url>] [--repo <path>]
|
|
4351
|
+
colab ci-grant <issue> --branch <branch> --role ci-reviewer --reviewer <id> --verdict pass --cures <checks> [--repo <path>]
|
|
4351
4352
|
colab ci-grant <issue> --revoke [--repo <path>]
|
|
4352
4353
|
colab ci-grant --list [--json] [--repo <path>]
|
|
4353
4354
|
|
|
@@ -4386,8 +4387,9 @@ CI grant merges into a repo whose own test suite is known-failing:
|
|
|
4386
4387
|
\`ship\` would never consult it for, reading live in \`--list\` while doing nothing.
|
|
4387
4388
|
|
|
4388
4389
|
HUMAN-ONLY, ENFORCED: both grant and revoke REFUSE (exit 1) unless COLAB_HUMAN=1 is set in the
|
|
4389
|
-
environment — the identical bar \`colab promote\`/\`colab migration-grant\` already hold.
|
|
4390
|
-
|
|
4390
|
+
environment — the identical bar \`colab promote\`/\`colab migration-grant\` already hold. This check
|
|
4391
|
+
runs BEFORE any network call. The ONE exception is the reviewer role below, and only on a repo whose
|
|
4392
|
+
trunk opts in.
|
|
4391
4393
|
|
|
4392
4394
|
The marker is TWO parts, both required for a grant to read as live:
|
|
4393
4395
|
- the \`${labels.CI_GRANT_LABEL}\` label — applying it requires GitHub write/triage permission, so
|
|
@@ -4415,8 +4417,30 @@ Revoking removes the label FIRST (the gate is restored the same minute) and post
|
|
|
4415
4417
|
There is deliberately no local-only fallback: without a usable \`gh\`, every subcommand here REFUSES
|
|
4416
4418
|
rather than write (or read) something invisible to the machine \`ship\` might later run on.
|
|
4417
4419
|
|
|
4420
|
+
THE REVIEWER ROLE (#504). On a repo whose TRUNK declares \`ci-grant: reviewer\` in project.yml,
|
|
4421
|
+
--role ${ciGrant.REVIEWER_ROLE} mints a \`${ciGrant.REVIEW_GRANT_MARK}\` WITHOUT COLAB_HUMAN=1 — the coordinator
|
|
4422
|
+
agent's door through a red trunk the cure rule refuses (maintainer ruling 2026-10-05). It is the only
|
|
4423
|
+
path past the human bar above, and only that opt-in opens it; revoking stays human. Every guard is
|
|
4424
|
+
measured, nothing is taken from the flags:
|
|
4425
|
+
- local, before any network call: the opt-in on trunk as committed (a branch cannot opt itself
|
|
4426
|
+
in) · the record is well-formed with --verdict pass and at least one cure · the branch is
|
|
4427
|
+
pushed and --head (if given) is origin's tip · the branch's trailing number group carries #N;
|
|
4428
|
+
- #N is open and its title starts "${ciGrant.TRUNK_RED_TITLE_PREFIX}" · trunk is red in ship's sense ·
|
|
4429
|
+
never stacks (guard 2 above) · the branch's own CI is green at that EXACT head · every
|
|
4430
|
+
check in --cures is red on trunk at the red sha.
|
|
4431
|
+
The comment carries a fenced \`ci-review\` record (verdict, head, red sha, cures) and binds that
|
|
4432
|
+
HEAD and that red sha: a new commit on either voids it. \`colab ship\` re-measures all of it, reads
|
|
4433
|
+
the opt-in at the merge target, and reads a grant with \`not-before\` in the future as not yet usable.
|
|
4434
|
+
|
|
4418
4435
|
Options:
|
|
4419
4436
|
--branch <branch> required for a grant; never inferred from HEAD
|
|
4437
|
+
--role <role> human (default) | ${ciGrant.REVIEWER_ROLE}
|
|
4438
|
+
--reviewer <id> (reviewer) the reviewer's declared identity (letters, digits, . _ @ -)
|
|
4439
|
+
--verdict <v> (reviewer) pass | fail — only pass is minted
|
|
4440
|
+
--cures <checks> (reviewer) the red checks the branch cures, "workflow / job; …"
|
|
4441
|
+
--head <sha> (reviewer) optional; must equal the pushed branch tip
|
|
4442
|
+
--not-before <iso> (reviewer) optional; a revoke window the host imposes
|
|
4443
|
+
--ci-run <id-or-url> (reviewer) optional; recorded only
|
|
4420
4444
|
--evidence-run <ref> recording-only note for the audit trail — never substitutes for the
|
|
4421
4445
|
measured branch-head run this command itself checks
|
|
4422
4446
|
--revoke revoke instead of grant
|
|
@@ -4473,7 +4497,12 @@ function computeAntiStacking(repoAbs, trunk, trunkIsRed) {
|
|
|
4473
4497
|
|
|
4474
4498
|
function cmdCiGrant(argv) {
|
|
4475
4499
|
const opts = parseArgs(argv, {
|
|
4476
|
-
values: {
|
|
4500
|
+
values: {
|
|
4501
|
+
'--repo': 'repo', '--branch': 'branch', '--evidence-run': 'evidenceRun',
|
|
4502
|
+
// #504 reviewer-grant record flags
|
|
4503
|
+
'--role': 'role', '--reviewer': 'reviewer', '--verdict': 'verdict', '--cures': 'cures',
|
|
4504
|
+
'--head': 'head', '--not-before': 'notBefore', '--ci-run': 'ciRun',
|
|
4505
|
+
},
|
|
4477
4506
|
flags: { '--revoke': 'revoke', '--list': 'list', '--json': 'json', '-h': 'help', '--help': 'help' },
|
|
4478
4507
|
});
|
|
4479
4508
|
if (opts.help) return print(HELP_CI_GRANT);
|
|
@@ -4481,11 +4510,27 @@ function cmdCiGrant(argv) {
|
|
|
4481
4510
|
if (opts._.length === 0) return print(HELP_CI_GRANT);
|
|
4482
4511
|
const num = normIssueNum(opts._[0]);
|
|
4483
4512
|
|
|
4513
|
+
// #504: the reviewer role is the ONE path past the human bar below, and only on a repo whose
|
|
4514
|
+
// TRUNK declares `ci-grant: reviewer`. Decided from local git alone, before any network call.
|
|
4515
|
+
const role = opts.role === undefined ? 'human' : String(opts.role);
|
|
4516
|
+
if (!ciGrant.GRANT_ROLES.includes(role)) {
|
|
4517
|
+
throw new UserError(`--role is "${role}", expected ${ciGrant.GRANT_ROLES.join(' | ')}`);
|
|
4518
|
+
}
|
|
4519
|
+
if (opts.revoke && opts.role !== undefined) {
|
|
4520
|
+
throw new UserError('--revoke takes no --role — a revoke cancels every live grant on the issue, whatever its role');
|
|
4521
|
+
}
|
|
4522
|
+
if (role === ciGrant.REVIEWER_ROLE && !opts.revoke) return cmdCiGrantReviewer(num, opts);
|
|
4523
|
+
const stray = ['reviewer', 'verdict', 'cures', 'head', 'notBefore', 'ciRun'].filter((k) => opts[k] !== undefined);
|
|
4524
|
+
if (stray.length) {
|
|
4525
|
+
throw new UserError(`review-record flags (${stray.map((k) => '--' + k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase())).join(', ')}) need --role ${ciGrant.REVIEWER_ROLE} — a human grant carries no record`);
|
|
4526
|
+
}
|
|
4527
|
+
|
|
4484
4528
|
// HUMAN-ONLY, first — identical posture and identical reason to cmdMigrationGrant's check above:
|
|
4485
4529
|
// assertable by a test against a fixture with no `gh` at all (tools/lib/ship-ci-grant.test.js).
|
|
4486
4530
|
if (process.env.COLAB_HUMAN !== '1') {
|
|
4487
4531
|
process.stderr.write(`✗ Refusing: ${opts.revoke ? 'revoking' : 'creating'} a CI grant requires a human.\n`);
|
|
4488
4532
|
process.stderr.write(' Re-run with COLAB_HUMAN=1. (No field, flag or project.yml value can lower this bar.)\n');
|
|
4533
|
+
if (!opts.revoke) process.stderr.write(` The ${ciGrant.REVIEWER_ROLE} role is a different grant, open only where trunk declares ci-grant: reviewer — colab ci-grant --help.\n`);
|
|
4489
4534
|
return 1;
|
|
4490
4535
|
}
|
|
4491
4536
|
|
|
@@ -4509,6 +4554,121 @@ function cmdCiGrant(argv) {
|
|
|
4509
4554
|
return opts.revoke ? cmdCiGrantRevoke(repoAbs, num) : cmdCiGrantCreate(repoAbs, num, opts);
|
|
4510
4555
|
}
|
|
4511
4556
|
|
|
4557
|
+
/**
|
|
4558
|
+
* #504: `colab ci-grant <N> --role ci-reviewer` — the coordinator agent's door through a red trunk the
|
|
4559
|
+
* cure rule refuses. Needs no COLAB_HUMAN=1, and that is the whole point; what replaces the human is
|
|
4560
|
+
* the opt-in on trunk plus guards that are all MEASURED here, never taken from the flags:
|
|
4561
|
+
* local (before any network call): `ci-grant: reviewer` committed on trunk · the record is
|
|
4562
|
+
* well-formed with verdict pass and at least one cure · the branch is pushed and --head (if
|
|
4563
|
+
* given) is its remote tip · the branch name's trailing number group carries #N;
|
|
4564
|
+
* tracker/CI: #N is open and titled `TRUNK RED:` · trunk is red in the sense ship checks · never
|
|
4565
|
+
* stacks (computeAntiStacking, same as the human grant) · the branch's own CI is green at that
|
|
4566
|
+
* EXACT head · every claimed cure is a red check on trunk at the red sha.
|
|
4567
|
+
* Nothing is written until all of them pass.
|
|
4568
|
+
*/
|
|
4569
|
+
function cmdCiGrantReviewer(num, opts) {
|
|
4570
|
+
const repoAbs = resolveRepoOrCwd(opts);
|
|
4571
|
+
if (!repoAbs) throw new UserError('not inside a git repo — pass --repo <path>');
|
|
4572
|
+
if (!opts.branch) {
|
|
4573
|
+
throw new UserError('--branch <branch> is required — a grant is bound to one branch, never inferred from the current checkout');
|
|
4574
|
+
}
|
|
4575
|
+
const trunk = resolveTrunk(repoAbs, projectDoc(repoAbs));
|
|
4576
|
+
if (!trunk) throw new UserError('Could not determine trunk branch (set project.yml trunk:)');
|
|
4577
|
+
|
|
4578
|
+
// The opt-in, read from TRUNK as committed — never this checkout or the branch, so a branch cannot
|
|
4579
|
+
// grant itself the policy it would then use.
|
|
4580
|
+
const pol = ciGrant.parseGrantPolicy(projectDocAt(repoAbs, trunk));
|
|
4581
|
+
if (!pol.valid) throw new UserError(`${pol.reason} — fix project.yml on ${trunk} before minting a reviewer grant`);
|
|
4582
|
+
if (pol.policy !== 'reviewer') {
|
|
4583
|
+
process.stderr.write(`✗ Refusing: ${trunk}'s project.yml says ci-grant: ${pol.policy}${pol.declared ? '' : ' (absent = human)'} — a ${ciGrant.REVIEWER_ROLE} grant is minted only where trunk declares ci-grant: reviewer.\n`);
|
|
4584
|
+
process.stderr.write(' Without that opt-in a CI grant is human-only: COLAB_HUMAN=1 colab ci-grant <N> --branch <b>.\n');
|
|
4585
|
+
return 1;
|
|
4586
|
+
}
|
|
4587
|
+
|
|
4588
|
+
if (!branchName.branchIssueNumbers(opts.branch).includes(num)) {
|
|
4589
|
+
throw new UserError(`branch "${opts.branch}" does not carry #${num} in its trailing number group — a reviewer grant needs the branch to close the TRUNK RED issue it is posted on`);
|
|
4590
|
+
}
|
|
4591
|
+
const refs = git.branchRefs(repoAbs, opts.branch);
|
|
4592
|
+
if (!refs.remoteSha) {
|
|
4593
|
+
throw new UserError(`branch "${opts.branch}" is not on origin — a reviewer grant binds the pushed HEAD, so push it first`);
|
|
4594
|
+
}
|
|
4595
|
+
const head = refs.remoteSha.toLowerCase();
|
|
4596
|
+
if (opts.head !== undefined && String(opts.head).toLowerCase() !== head) {
|
|
4597
|
+
throw new UserError(`--head ${String(opts.head).slice(0, 12)} is not origin's tip of "${opts.branch}" (${head.slice(0, 12)}) — the review covers a commit the grant would not bind; re-review the tip`);
|
|
4598
|
+
}
|
|
4599
|
+
const rec = {
|
|
4600
|
+
v: '1', role: ciGrant.REVIEWER_ROLE, reviewer: opts.reviewer, head, red: '0'.repeat(40),
|
|
4601
|
+
verdict: opts.verdict, cures: opts.cures === undefined ? undefined : ciGrant.formatCures(ciGrant.parseCures(opts.cures)),
|
|
4602
|
+
'not-before': opts.notBefore, 'ci-run': opts.ciRun,
|
|
4603
|
+
};
|
|
4604
|
+
for (const k of Object.keys(rec)) if (rec[k] === undefined || rec[k] === '') delete rec[k];
|
|
4605
|
+
const v0 = ciGrant.validateReviewRecord(rec);
|
|
4606
|
+
if (!v0.valid) throw new UserError(`the review record is invalid: ${v0.problems.join('; ')}`);
|
|
4607
|
+
if (!v0.passing) throw new UserError(`the review says verdict ${rec.verdict} — a grant carrying a failing review is a contradiction; nothing was posted`);
|
|
4608
|
+
|
|
4609
|
+
if (!isGhUsable(repoAbs)) {
|
|
4610
|
+
throw new UserError(`gh not usable here (${ghUnusableWhy(repoAbs)}) — a CI grant lives on the tracker, visible from any machine to the gate that reads it, and there is deliberately no local-only fallback`);
|
|
4611
|
+
}
|
|
4612
|
+
|
|
4613
|
+
const info = git.ghIssueView(repoAbs, num, ['state', 'labels', 'title']);
|
|
4614
|
+
if (!info) throw new UserError(`could not read #${num} from the tracker — refusing to write a grant blind`);
|
|
4615
|
+
if (info.state !== 'OPEN') throw new UserError(`#${num} is ${info.state} — a grant expires the instant its issue closes`);
|
|
4616
|
+
if (!ciGrant.titleIsTrunkRed(info.title)) {
|
|
4617
|
+
throw new UserError(`#${num}'s title does not start "${ciGrant.TRUNK_RED_TITLE_PREFIX}" — a reviewer CI grant covers only work that is the red trunk's repair`);
|
|
4618
|
+
}
|
|
4619
|
+
const present = git.ghListLabels(repoAbs);
|
|
4620
|
+
if (present && !present.includes(labels.CI_GRANT_LABEL)) {
|
|
4621
|
+
throw new UserError(labels.ciGrantMissingLabelHint(present) || `this repo has no \`${labels.CI_GRANT_LABEL}\` label`);
|
|
4622
|
+
}
|
|
4623
|
+
|
|
4624
|
+
// Trunk red, in ship's sense — the identical classification cmdCiGrantCreate uses (#155).
|
|
4625
|
+
git.git(['fetch', git.remoteFor(repoAbs), trunk], repoAbs);
|
|
4626
|
+
const trunkRun = git.ghRunForSha(repoAbs, trunk);
|
|
4627
|
+
if (!trunkRun) throw new UserError(`could not read ${trunk}'s CI status (gh run list failed) — refusing to grant blind`);
|
|
4628
|
+
const trunkVerdict = classifyCiRun(repoAbs, trunkRun, `${trunk}@${shortSha(trunkRun.sha)}`);
|
|
4629
|
+
if (trunkVerdict.class !== HUMAN_GATED) {
|
|
4630
|
+
throw new UserError(`${trunk} is not red in the sense \`ship\` checks — ${trunkVerdict.detail || 'green'}. Nothing for a grant to exempt.`);
|
|
4631
|
+
}
|
|
4632
|
+
const redSha = trunkRun.sha;
|
|
4633
|
+
const stacking = computeAntiStacking(repoAbs, trunk, true);
|
|
4634
|
+
if (!stacking.ok) throw new UserError(stacking.reason);
|
|
4635
|
+
|
|
4636
|
+
// The branch's own CI, green at the EXACT head the review covers.
|
|
4637
|
+
const evRun = git.ghRunForSha(repoAbs, opts.branch);
|
|
4638
|
+
if (!evRun) throw new UserError(`could not read "${opts.branch}"'s CI status (gh run list failed) — refusing to grant blind`);
|
|
4639
|
+
if (String(evRun.sha || '').toLowerCase() !== head) {
|
|
4640
|
+
throw new UserError(`"${opts.branch}"'s newest CI run is for ${shortSha(evRun.sha)}, not the reviewed head ${shortSha(head)} — wait for CI on the head, then re-run`);
|
|
4641
|
+
}
|
|
4642
|
+
if (!(evRun.status === 'completed' && evRun.conclusion === 'success')) {
|
|
4643
|
+
throw new UserError(`"${opts.branch}" has no completed, successful CI run at ${shortSha(head)} (status=${evRun.status} conclusion=${evRun.conclusion || 'none'}) — a reviewer grant needs the branch green at its exact head`);
|
|
4644
|
+
}
|
|
4645
|
+
|
|
4646
|
+
// Every claimed cure is a red check on trunk at the red sha.
|
|
4647
|
+
const redRunJobs = trunkRedRunJobs(repoAbs, trunk, redSha);
|
|
4648
|
+
const redJobs = redRunJobs === null ? null : ciCure.redJobSet(redRunJobs);
|
|
4649
|
+
const cr = ciGrant.curesAreRed(ciGrant.parseCures(rec.cures), redJobs);
|
|
4650
|
+
if (!cr.ok) throw new UserError(`${cr.reason}; nothing was posted`);
|
|
4651
|
+
|
|
4652
|
+
rec.red = redSha.toLowerCase();
|
|
4653
|
+
const v = ciGrant.validateReviewRecord(rec);
|
|
4654
|
+
if (!v.passing) throw new UserError(`the review record is invalid: ${v.problems.join('; ')}`);
|
|
4655
|
+
|
|
4656
|
+
const editR = git.ghIssueEdit(repoAbs, num, labels.ciGrantLabelArgs({}));
|
|
4657
|
+
if (!editR.ok) throw new UserError(`gh edit #${num} failed (${editR.stderr.split('\n')[0] || editR.code})`);
|
|
4658
|
+
const commentR = git.ghIssueComment(repoAbs, num,
|
|
4659
|
+
ciGrant.reviewGrantCommentBody(opts.branch, trunk, commentHost(repoAbs), nowISO(), rec));
|
|
4660
|
+
if (!commentR.ok) {
|
|
4661
|
+
git.ghIssueEdit(repoAbs, num, labels.ciGrantLabelArgs({ clear: true }));
|
|
4662
|
+
throw new UserError(`label applied but the grant comment failed to post (${commentR.stderr.split('\n')[0] || commentR.code}) — rolled the label back so this does not read as granted. Re-run.`);
|
|
4663
|
+
}
|
|
4664
|
+
|
|
4665
|
+
print(`Recorded a ${ciGrant.REVIEWER_ROLE} CI grant on #${num} in ${shortRepo(repoAbs)} — reviewer "${rec.reviewer}", branch "${opts.branch}" @ ${head.slice(0, 12)}.`);
|
|
4666
|
+
print(` Bound to that HEAD and to red ${trunk}@${shortSha(redSha)}: a new commit on either voids it. Cures: ${rec.cures}.`);
|
|
4667
|
+
if (rec['not-before']) print(` Not usable before ${rec['not-before']} (revoke window).`);
|
|
4668
|
+
print(` Revoke any time: COLAB_HUMAN=1 colab ci-grant ${num} --revoke`);
|
|
4669
|
+
return 0;
|
|
4670
|
+
}
|
|
4671
|
+
|
|
4512
4672
|
function cmdCiGrantCreate(repoAbs, num, opts) {
|
|
4513
4673
|
if (!opts.branch) {
|
|
4514
4674
|
throw new UserError('--branch <branch> is required — a grant is bound to one branch, never inferred from the current checkout');
|
|
@@ -4589,7 +4749,8 @@ function cmdCiGrantRevoke(repoAbs, num) {
|
|
|
4589
4749
|
if (!info) throw new UserError(`could not read #${num} from the tracker`);
|
|
4590
4750
|
const labelNames = (info.labels || []).map((l) => (l && typeof l === 'object' ? l.name : l));
|
|
4591
4751
|
const hasLabel = labelNames.includes(labels.CI_GRANT_LABEL);
|
|
4592
|
-
|
|
4752
|
+
// Every role (#504): a revoke cancels reviewer grants too, so a reviewer-only issue is not "nothing to revoke".
|
|
4753
|
+
const live = ciGrant.liveGrantRecords(info.comments);
|
|
4593
4754
|
|
|
4594
4755
|
if (!hasLabel && live.length === 0) {
|
|
4595
4756
|
print(`No live CI grant on #${num} in ${shortRepo(repoAbs)} — nothing to revoke.`);
|
|
@@ -4635,14 +4796,15 @@ function cmdCiGrantList(opts) {
|
|
|
4635
4796
|
const stale = [];
|
|
4636
4797
|
for (const h of hits) {
|
|
4637
4798
|
const info = git.ghIssueView(repoAbs, h.number, ['state', 'labels', 'comments']);
|
|
4638
|
-
const live = info ? ciGrant.
|
|
4799
|
+
const live = info ? ciGrant.liveGrantRecords(info.comments) : [];
|
|
4639
4800
|
if (live.length === 0) { stale.push(h.number); continue; }
|
|
4640
4801
|
const g = live[live.length - 1];
|
|
4641
4802
|
// Spent: the normal post-ship state — trunk's head has moved past the sha this grant named.
|
|
4642
4803
|
// Not an error, just informative — distinguishes "still live, awaiting a ship" from "already
|
|
4643
4804
|
// used (or overtaken by an unrelated trunk change) and inert" without anyone revoking it.
|
|
4644
4805
|
const spent = currentTrunkSha !== null && g.redSha !== currentTrunkSha;
|
|
4645
|
-
|
|
4806
|
+
const reviewer = g.role !== 'human' ? { role: g.role, reviewer: g.reviewer, head: g.head } : {};
|
|
4807
|
+
grants.push({ issue: h.number, title: h.title, branch: g.branch, redSha: g.redSha, evidenceSha: g.role === 'human' ? g.evidenceSha : g.head, by: g.login, authorAssociation: g.authorAssociation, at: g.at, spent, ...reviewer });
|
|
4646
4808
|
}
|
|
4647
4809
|
|
|
4648
4810
|
if (opts.json) {
|
|
@@ -4654,7 +4816,7 @@ function cmdCiGrantList(opts) {
|
|
|
4654
4816
|
return 0;
|
|
4655
4817
|
}
|
|
4656
4818
|
print(table(
|
|
4657
|
-
grants.map((g) => [String(g.issue), g.branch, shortSha(g.redSha), g.spent ? 'spent' : 'live', g.by || '(unknown)', g.title]),
|
|
4819
|
+
grants.map((g) => [String(g.issue), g.branch, shortSha(g.redSha), g.spent ? 'spent' : 'live', (g.by || '(unknown)') + (g.role ? ` (${g.role} ${g.reviewer})` : ''), g.title]),
|
|
4658
4820
|
['ISSUE', 'BRANCH', 'RED SHA', 'STATE', 'GRANTED BY', 'TITLE'],
|
|
4659
4821
|
));
|
|
4660
4822
|
if (stale.length) {
|
|
@@ -9643,7 +9805,11 @@ function ciGrantTrailerLine(grantVerdict, branch, trunk) {
|
|
|
9643
9805
|
if (!grantVerdict || !grantVerdict.ok || !grantVerdict.granted.length) return null;
|
|
9644
9806
|
const g = grantVerdict.granted[0]; // redSha/evidenceSha are identical across the whole granted set (evaluateShipSet)
|
|
9645
9807
|
const issues = grantVerdict.granted.map((x) => '#' + x.issue).join(' ');
|
|
9646
|
-
|
|
9808
|
+
// #504: a reviewer grant appends who reviewed it; the `over-red <trunk>@<sha>` part the anti-stacking
|
|
9809
|
+
// scan (ci-cure.js priorRedShaFromMessage) reads is unchanged.
|
|
9810
|
+
const rv = grantVerdict.granted.filter((x) => x.role && x.role !== 'human');
|
|
9811
|
+
const via = rv.length ? ` via ${rv[0].role} ${[...new Set(rv.map((x) => x.reviewer))].join(',')}` : '';
|
|
9812
|
+
return `CI-Grant: ${issues} branch ${branch} over-red ${trunk}@${shortSha(g.redSha)} evidence ${shortSha(g.evidenceSha)}${via}`;
|
|
9647
9813
|
}
|
|
9648
9814
|
|
|
9649
9815
|
/**
|
|
@@ -10747,9 +10913,14 @@ function applyRedTrunkExemptions(raw, target, trunk, redSha, grantThunk, cureThu
|
|
|
10747
10913
|
const grantVerdict = grantThunk ? grantThunk(redSha) : null;
|
|
10748
10914
|
if (grantVerdict && grantVerdict.ok) {
|
|
10749
10915
|
const by = grantVerdict.granted.map((g) => '#' + g.issue).join(' ');
|
|
10916
|
+
// #504: a reviewer grant says so — it must never render as a human's decision.
|
|
10917
|
+
const rv = grantVerdict.granted.filter((g) => g.role && g.role !== 'human');
|
|
10918
|
+
const who = rv.length
|
|
10919
|
+
? `a ${rv[0].role} ci-grant (reviewer ${[...new Set(rv.map((g) => g.reviewer))].join(', ')}, cures ${[...new Set(rv.flatMap((g) => g.cures || []))].join('; ')})`
|
|
10920
|
+
: 'a human ci-grant';
|
|
10750
10921
|
return {
|
|
10751
10922
|
name: raw.name, ok: true, class: null,
|
|
10752
|
-
detail: `PRECONDITION OVERRIDDEN by
|
|
10923
|
+
detail: `PRECONDITION OVERRIDDEN by ${who} on ${by} — trunk was red at ${shortSha(redSha)} (raw: ${raw.detail})`,
|
|
10753
10924
|
grantVerdict, cureVerdict,
|
|
10754
10925
|
};
|
|
10755
10926
|
}
|
|
@@ -10772,12 +10943,21 @@ function shipCiGrants(repoAbs, gh, issues, branch, trunk, redSha) {
|
|
|
10772
10943
|
missing: [{ issue: null, reason: `gh not usable (${ghUnusableWhy(repoAbs)}) — a CI grant lives on the tracker and cannot be confirmed` }] };
|
|
10773
10944
|
}
|
|
10774
10945
|
const records = {};
|
|
10775
|
-
|
|
10946
|
+
// `title` (#504): a reviewer grant requires its issue to be titled `TRUNK RED:`.
|
|
10947
|
+
for (const n of issues) records[n] = git.ghIssueView(repoAbs, n, ['state', 'labels', 'comments', 'title']);
|
|
10776
10948
|
const evRun = git.ghRunForSha(repoAbs, branch);
|
|
10777
10949
|
const evidence = !evRun ? null : { ok: evRun.status === 'completed' && evRun.conclusion === 'success', sha: evRun.sha };
|
|
10778
10950
|
return ciGrant.evaluateShipSet(issues, records, branch, trunk, redSha, evidence, labels.CI_GRANT_LABEL, {
|
|
10779
10951
|
trust: trustAt(repoAbs, trunk),
|
|
10780
10952
|
labelActors: (n) => git.ghIssueLabelActors(repoAbs, n, labels.CI_GRANT_LABEL),
|
|
10953
|
+
// #504 — the reviewer role: the opt-in as committed on TRUNK (never the branch), the clock for a
|
|
10954
|
+
// host's revoke window, and trunk's red checks at redSha, read lazily and at most once.
|
|
10955
|
+
policy: ciGrant.parseGrantPolicy(projectDocAt(repoAbs, trunk)).policy,
|
|
10956
|
+
now: Date.now(),
|
|
10957
|
+
redJobs: () => {
|
|
10958
|
+
const jobs = trunkRedRunJobs(repoAbs, trunk, redSha);
|
|
10959
|
+
return jobs === null ? null : ciCure.redJobSet(jobs);
|
|
10960
|
+
},
|
|
10781
10961
|
});
|
|
10782
10962
|
}
|
|
10783
10963
|
|
|
@@ -10792,7 +10972,8 @@ function ciGrantPayload(ciResult) {
|
|
|
10792
10972
|
const g = ciResult.grantVerdict;
|
|
10793
10973
|
return {
|
|
10794
10974
|
ok: g.ok,
|
|
10795
|
-
granted: g.granted.map((x) => ({ issue: x.issue, by: x.by, at: x.at, redSha: x.redSha, evidenceSha: x.evidenceSha
|
|
10975
|
+
granted: g.granted.map((x) => ({ issue: x.issue, by: x.by, at: x.at, redSha: x.redSha, evidenceSha: x.evidenceSha,
|
|
10976
|
+
...(x.role ? { role: x.role, reviewer: x.reviewer, head: x.head, cures: x.cures } : {}) })),
|
|
10796
10977
|
missing: g.missing.map((m) => ({ issue: m.issue, reason: m.reason })),
|
|
10797
10978
|
};
|
|
10798
10979
|
}
|
|
@@ -14692,7 +14873,7 @@ Commands:
|
|
|
14692
14873
|
migration-grant <issue> --branch B | --revoke | --list [--json] human-only ship migration exemption (#98)
|
|
14693
14874
|
decision <issue> --record --ruled-by N | --reopen --ruled-by N | --list [--json]
|
|
14694
14875
|
record/reopen a needs-decision answer (#121, #122)
|
|
14695
|
-
ci-grant <issue> --branch B | --revoke | --list [--json]
|
|
14876
|
+
ci-grant <issue> --branch B | --revoke | --list [--json] ship trunk-CI-green exemption: human, or ci-reviewer under opt-in (#105, #504)
|
|
14696
14877
|
claims [--json] [--sync] list / reconcile with GitHub
|
|
14697
14878
|
|
|
14698
14879
|
port alloc [--count N] [--range A-B] [--worktree N|--claim I|--label S]
|