@futurelastic/colab-handbook 1.14.0-rc.2 → 1.14.0-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 +13 -5
- package/tools/lib/ci-cure.js +10 -1
- package/tools/lib/cure-diff.js +27 -1
package/package.json
CHANGED
package/tools/colab
CHANGED
|
@@ -11819,12 +11819,14 @@ function ciGrantPayload(ciResult) {
|
|
|
11819
11819
|
* on its own.
|
|
11820
11820
|
*
|
|
11821
11821
|
* Measures, in order:
|
|
11822
|
-
* 1. containment — `git merge-base --is-ancestor <redSha> <
|
|
11822
|
+
* 1. containment — cure-diff's `cureContainment`: `git merge-base --is-ancestor <redSha> <ref>`
|
|
11823
|
+
* against the ref ship lands (local branch, else `<remote>/<branch>` — #589), translated to
|
|
11824
|
+
* true/false, or null ("could not resolve") when the ref or the red sha does not resolve.
|
|
11823
11825
|
* 2. evidence — a completed, successful CI run for `branch`'s CURRENT head, via the identical
|
|
11824
11826
|
* `ghRunForSha` the raw CI check and `shipCiGrants` both use.
|
|
11825
11827
|
* 3. anti-stacking — `computeAntiStacking`, the SAME function `cmdCiGrantCreate` calls, so a cure
|
|
11826
11828
|
* and a human grant can never independently disagree about whether trunk is mid-stack.
|
|
11827
|
-
* 4. the diff signals — tools/lib/cure-diff.js's `cureDiffSignals` over `<trunk>...<
|
|
11829
|
+
* 4. the diff signals — tools/lib/cure-diff.js's `cureDiffSignals` over `<trunk>...<ref>` (same ref)
|
|
11828
11830
|
* (merge-base-relative, the tree a squash lands), `--no-renames` so a workflow file or
|
|
11829
11831
|
* manifest MOVED away still counts (#297 — the old `--name-only` read listed only a rename's
|
|
11830
11832
|
* new path). It yields `workflowsTouched` (condition 4) and `manifestScriptsTouched`
|
|
@@ -11860,11 +11862,17 @@ function shipCiCure(repoAbs, gh, target, trunk, redSha, branch) {
|
|
|
11860
11862
|
if (!gh) {
|
|
11861
11863
|
return { ok: false, reason: `gh not usable (${ghUnusableWhy(repoAbs)}) — the cure rule needs a measured CI run`, redSha, evidenceSha: null };
|
|
11862
11864
|
}
|
|
11863
|
-
|
|
11865
|
+
// #589: containment and the diff read the ref ship lands — the local branch, else its remote-tracking
|
|
11866
|
+
// ref (a --handoff land has no local branch). The bare name failed there and read as "not an
|
|
11867
|
+
// ancestor"; an unresolvable ref now refuses as "could not resolve", never as "does not contain".
|
|
11868
|
+
// The CI read keeps the NAME: ghRunForSha resolves the remote head itself (ls-remote).
|
|
11869
|
+
const containment = cureDiff.cureContainment(git, repoAbs, redSha, branch);
|
|
11870
|
+
const containsRedSha = containment.contains;
|
|
11871
|
+
const branchRef = containment.ref || branch;
|
|
11864
11872
|
const evRun = git.ghRunForSha(repoAbs, branch);
|
|
11865
11873
|
const evidence = !evRun ? null : { ok: evRun.status === 'completed' && evRun.conclusion === 'success', sha: evRun.sha };
|
|
11866
11874
|
const stacking = computeAntiStacking(repoAbs, trunk, true /* trunkIsRed: shipCiCure is only ever reached from a HUMAN_GATED raw verdict */);
|
|
11867
|
-
const diff = cureDiff.cureDiffSignals(git, repoAbs, trunk,
|
|
11875
|
+
const diff = cureDiff.cureDiffSignals(git, repoAbs, trunk, branchRef);
|
|
11868
11876
|
// Measured only past containment + 2a: a verdict that already refuses on either never reads it,
|
|
11869
11877
|
// so a branch that cannot cure pays no job-level `gh` calls for it.
|
|
11870
11878
|
const jobEvidence = (containsRedSha && evidence && evidence.ok)
|
|
@@ -11876,7 +11884,7 @@ function shipCiCure(repoAbs, gh, target, trunk, redSha, branch) {
|
|
|
11876
11884
|
const dispatchable = jobEvidence && evidence ? dispatchableWorkflows(repoAbs, evidence.sha) : [];
|
|
11877
11885
|
// #477: a stacked refusal may be lifted by progress — measure the prior red set only then.
|
|
11878
11886
|
const priorRedJobs = jobEvidence && stacking && stacking.stacked ? priorExemptionRedJobs(repoAbs, trunk, stacking) : null;
|
|
11879
|
-
const verdict = ciCure.cureVerdict({ containsRedSha, evidence, redSha, stacking, jobEvidence, priorRedJobs,
|
|
11887
|
+
const verdict = ciCure.cureVerdict({ containsRedSha, containmentReason: containment.reason, evidence, redSha, stacking, jobEvidence, priorRedJobs,
|
|
11880
11888
|
workflowsTouched: diff.workflowsTouched,
|
|
11881
11889
|
manifestScriptsTouched: diff.manifestScriptsTouched, manifestPaths: diff.manifestPaths,
|
|
11882
11890
|
manifestScriptsAddOnly: diff.manifestScriptsAddOnly,
|
package/tools/lib/ci-cure.js
CHANGED
|
@@ -820,6 +820,8 @@ function stackingWithProgress(stacking, priorRedJobs, jobEvidence) {
|
|
|
820
820
|
* `containsRedSha` — bool, whether the branch's tree contains the red trunk sha as an ancestor
|
|
821
821
|
* (the caller's `git merge-base --is-ancestor <redSha> <branch>`, translated to a bool — never
|
|
822
822
|
* re-derived here, this module does not touch git).
|
|
823
|
+
* `null` (#589) means the caller could NOT measure it — the ref did not resolve, or git failed —
|
|
824
|
+
* and refuses with `containmentReason` ("could not resolve …"), never as "does not contain".
|
|
823
825
|
*
|
|
824
826
|
* `evidence` — `{ok, sha}` for a completed, successful CI run measured on the branch's CURRENT
|
|
825
827
|
* head, or `null` when the caller's own read of it FAILED. Passing `evidence: null` means "the
|
|
@@ -886,7 +888,14 @@ function stackingWithProgress(stacking, priorRedJobs, jobEvidence) {
|
|
|
886
888
|
*/
|
|
887
889
|
function cureVerdict({ containsRedSha, evidence, redSha, stacking, workflowsTouched, jobEvidence,
|
|
888
890
|
manifestScriptsTouched, manifestPaths, manifestScriptsAddOnly, pythonManifestTouched, pythonManifestPaths,
|
|
889
|
-
pythonPinOnly, dryRunCapable, dispatchable, branchRuns, priorRedJobs }) {
|
|
891
|
+
pythonPinOnly, dryRunCapable, dispatchable, branchRuns, priorRedJobs, containmentReason }) {
|
|
892
|
+
// #589: `null` = containment could not be MEASURED (an unresolvable ref, a failed git read) — a
|
|
893
|
+
// different fact from "not an ancestor", whose remedy (rebase onto the red) would be wrong advice.
|
|
894
|
+
if (containsRedSha === null) {
|
|
895
|
+
return { ok: false,
|
|
896
|
+
reason: `${containmentReason || `could not resolve the branch or trunk's red head \`${redSha}\``} — ` +
|
|
897
|
+
'containment was not measured, so this cannot prove a cure (an unmeasured read is never a cure)' };
|
|
898
|
+
}
|
|
890
899
|
if (!containsRedSha) {
|
|
891
900
|
return { ok: false,
|
|
892
901
|
reason: `branch does not contain trunk's current red head \`${redSha}\` as an ancestor — ` +
|
package/tools/lib/cure-diff.js
CHANGED
|
@@ -358,6 +358,32 @@ function sideText(git, repo, sha) {
|
|
|
358
358
|
return r.ok ? r.stdout : null;
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
+
/**
|
|
362
|
+
* The cure rule's containment read (#281 condition 1), against the ref `ship` actually lands (#589).
|
|
363
|
+
*
|
|
364
|
+
* A `--handoff` land usually has no local branch — only `<remote>/<branch>` — so asking git about
|
|
365
|
+
* the bare name failed, and that failure read as "not an ancestor": a real cure refused until a
|
|
366
|
+
* local ref was made by hand. The ref is resolved here exactly as `shipRefFor` does (local branch,
|
|
367
|
+
* else its remote-tracking ref), and the three outcomes are kept apart:
|
|
368
|
+
* `{ref, contains: true}` · `{ref, contains: false}` (git exit 1 — genuinely not an ancestor) ·
|
|
369
|
+
* `{ref, contains: null, reason}` — the branch or the red sha could not be resolved, or git failed.
|
|
370
|
+
* `null` refuses in `cureVerdict` with the "could not resolve" reason, never "does not contain".
|
|
371
|
+
* Never throws.
|
|
372
|
+
*/
|
|
373
|
+
function cureContainment(git, repo, redSha, branch, remote) {
|
|
374
|
+
const refs = git.branchRefs(repo, branch, ...(remote ? [remote] : []));
|
|
375
|
+
const ref = refs.localSha || refs.remoteSha;
|
|
376
|
+
if (!ref) {
|
|
377
|
+
return { ref: null, contains: null,
|
|
378
|
+
reason: `could not resolve ${branch} — no local branch and no remote-tracking ref (fetch it first)` };
|
|
379
|
+
}
|
|
380
|
+
const r = git.git(['merge-base', '--is-ancestor', redSha, ref], repo);
|
|
381
|
+
if (r.ok) return { ref, contains: true, reason: '' };
|
|
382
|
+
if (r.code === 1) return { ref, contains: false, reason: '' };
|
|
383
|
+
return { ref, contains: null,
|
|
384
|
+
reason: `could not resolve trunk's red head \`${redSha}\` against ${branch} (${ref.slice(0, 7)}): ${(r.stderr || '').split('\n')[0] || `git exit ${r.code}`}` };
|
|
385
|
+
}
|
|
386
|
+
|
|
361
387
|
/**
|
|
362
388
|
* The diff signals for one branch against trunk, over the merge-base range (`trunk...branch` — the
|
|
363
389
|
* same tree a squash lands). Returns `{ ok, reason, workflowsTouched, manifestScriptsTouched,
|
|
@@ -452,5 +478,5 @@ function pythonSignal(git, repo, trunk, branch, entries) {
|
|
|
452
478
|
return { touched: paths.length > 0, paths, reason: '' };
|
|
453
479
|
}
|
|
454
480
|
|
|
455
|
-
module.exports = { cureDiffSignals, scriptsBlockDiffers, scriptsAddition, pythonPinChange, parseRequirement,
|
|
481
|
+
module.exports = { cureDiffSignals, cureContainment, scriptsBlockDiffers, scriptsAddition, pythonPinChange, parseRequirement,
|
|
456
482
|
isPythonManifest, pythonIncludes, ABSENT };
|