@tablation/crew 0.167.1 → 0.169.0
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/dist/cli.js +238 -112
- package/dist/sandbox-intel-bridge.cjs +51 -14
- package/docs/repo-setup-prompt.md +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3512,11 +3512,35 @@ function parseDeniedRequests(log) {
|
|
|
3512
3512
|
return [...out.values()];
|
|
3513
3513
|
}
|
|
3514
3514
|
|
|
3515
|
+
// src/version-compare.ts
|
|
3516
|
+
function parseVersion(v) {
|
|
3517
|
+
const m = /^v?(\d+)\.(\d+)\.(\d+)/.exec(v.trim());
|
|
3518
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
3519
|
+
}
|
|
3520
|
+
function compareVersions(a, b) {
|
|
3521
|
+
const pa = parseVersion(a);
|
|
3522
|
+
const pb = parseVersion(b);
|
|
3523
|
+
if (!pa || !pb) return null;
|
|
3524
|
+
for (let i = 0; i < 3; i++) if (pa[i] !== pb[i]) return pa[i] - pb[i];
|
|
3525
|
+
return 0;
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3515
3528
|
// src/repo-config.ts
|
|
3516
3529
|
var SPEC_VERSION = 1;
|
|
3517
3530
|
var REPO_CONFIG_FILENAMES = [".crew.yaml", ".crew.yml", ".crew.json"];
|
|
3518
3531
|
var RepoConfigError = class extends Error {
|
|
3519
3532
|
};
|
|
3533
|
+
var NewerContractError = class extends RepoConfigError {
|
|
3534
|
+
};
|
|
3535
|
+
var NEWER_CONTRACT_PHRASE = "needs a newer crew";
|
|
3536
|
+
function newerContractSummary(n) {
|
|
3537
|
+
return `this contract was written for crew ${n.required} and this is crew ${n.running}; ignoring ${n.keys.join(", ")}. Upgrading crew clears this`;
|
|
3538
|
+
}
|
|
3539
|
+
var runningCrewVersion;
|
|
3540
|
+
function setRunningCrewVersion(v) {
|
|
3541
|
+
runningCrewVersion = v;
|
|
3542
|
+
}
|
|
3543
|
+
var IGNORABLE_UNKNOWN_KEY_GROUPS = /* @__PURE__ */ new Set(["release", "release.isolateFailures", "labels", "periscope", "docs"]);
|
|
3520
3544
|
function versionFileProblem(name, text2) {
|
|
3521
3545
|
const remedy = `a version file that is not a JSON object with a string "version" needs hooks.bump instead of release.versionFiles (docs/REPO_SPEC.md)`;
|
|
3522
3546
|
let doc;
|
|
@@ -3550,6 +3574,7 @@ var HOOK_NAMES = [
|
|
|
3550
3574
|
];
|
|
3551
3575
|
var TOP_LEVEL = /* @__PURE__ */ new Set([
|
|
3552
3576
|
"version",
|
|
3577
|
+
"minCrewVersion",
|
|
3553
3578
|
"platform",
|
|
3554
3579
|
"shell",
|
|
3555
3580
|
"branch",
|
|
@@ -3615,7 +3640,7 @@ var VERSIONINGS = ["auto", "none"];
|
|
|
3615
3640
|
var CI_KEYS = /* @__PURE__ */ new Set(["provider", "ref"]);
|
|
3616
3641
|
var VERIFY_KEYS = /* @__PURE__ */ new Set(["match", "timeoutSeconds", "intervalSeconds"]);
|
|
3617
3642
|
var ISOLATE_KEYS = /* @__PURE__ */ new Set(["maxCandidates"]);
|
|
3618
|
-
var DEFAULT_ISOLATE_MAX_CANDIDATES =
|
|
3643
|
+
var DEFAULT_ISOLATE_MAX_CANDIDATES = 8;
|
|
3619
3644
|
var DEFAULT_RIGHT_OF_WAY_MINUTES = 60;
|
|
3620
3645
|
function parseRebuildPrimary(raw, fail2) {
|
|
3621
3646
|
if (raw === void 0 || raw === null) return void 0;
|
|
@@ -3644,10 +3669,20 @@ function findRepoConfig(dir) {
|
|
|
3644
3669
|
}
|
|
3645
3670
|
return null;
|
|
3646
3671
|
}
|
|
3647
|
-
function rejectUnknown(obj, allowed, where, file) {
|
|
3672
|
+
function rejectUnknown(obj, allowed, where, file, newer) {
|
|
3648
3673
|
if (!obj || typeof obj !== "object") return;
|
|
3649
3674
|
const unknown = Object.keys(obj).filter((k) => !allowed.has(k));
|
|
3650
3675
|
if (unknown.length > 0) {
|
|
3676
|
+
if (newer) {
|
|
3677
|
+
const paths = unknown.map((k) => where === "top-level" ? k : `${where}.${k}`);
|
|
3678
|
+
if (IGNORABLE_UNKNOWN_KEY_GROUPS.has(where)) {
|
|
3679
|
+
newer.ignored.push(...paths);
|
|
3680
|
+
return;
|
|
3681
|
+
}
|
|
3682
|
+
throw new NewerContractError(
|
|
3683
|
+
`${file}: ${paths.join(", ")} ${paths.length === 1 ? "is" : "are"} not known to crew ${newer.running}, and the file declares minCrewVersion ${newer.required}: this repository ${NEWER_CONTRACT_PHRASE} (${newer.required} or later) and is skipped until crew is upgraded`
|
|
3684
|
+
);
|
|
3685
|
+
}
|
|
3651
3686
|
throw new RepoConfigError(
|
|
3652
3687
|
`${file}: unknown ${where} ${unknown.length === 1 ? "key" : "keys"}: ${unknown.join(", ")} (allowed: ${[...allowed].sort().join(", ")})`
|
|
3653
3688
|
);
|
|
@@ -3690,7 +3725,7 @@ function parseSandbox(raw, file) {
|
|
|
3690
3725
|
if (!image && packages.length === 0 && setup.length === 0 && warm.length === 0) return void 0;
|
|
3691
3726
|
return { ...image ? { image } : {}, packages, setup, warm };
|
|
3692
3727
|
}
|
|
3693
|
-
function parseRepoConfig(text2, file) {
|
|
3728
|
+
function parseRepoConfig(text2, file, opts = {}) {
|
|
3694
3729
|
let raw;
|
|
3695
3730
|
try {
|
|
3696
3731
|
raw = file.endsWith(".json") ? JSON.parse(text2) : parse(text2);
|
|
@@ -3698,18 +3733,25 @@ function parseRepoConfig(text2, file) {
|
|
|
3698
3733
|
throw new RepoConfigError(`${file}: could not be parsed \u2014 ${e.message}`);
|
|
3699
3734
|
}
|
|
3700
3735
|
if (!raw || typeof raw !== "object") throw new RepoConfigError(`${file} is empty or not a mapping`);
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
rejectUnknown(raw
|
|
3709
|
-
rejectUnknown(raw.
|
|
3710
|
-
rejectUnknown(raw.
|
|
3711
|
-
rejectUnknown(raw.
|
|
3712
|
-
rejectUnknown(raw.
|
|
3736
|
+
const minRaw = raw.minCrewVersion;
|
|
3737
|
+
if (minRaw !== void 0 && (typeof minRaw !== "string" || !/^\d+\.\d+\.\d+$/.test(minRaw.trim()))) {
|
|
3738
|
+
throw new RepoConfigError(`${file}: minCrewVersion must be a version like "0.167.0" (got "${String(minRaw)}")`);
|
|
3739
|
+
}
|
|
3740
|
+
const running = opts.crewVersion ?? runningCrewVersion;
|
|
3741
|
+
const newerThanRunning = typeof minRaw === "string" && running !== void 0 && parseVersion(running) !== null && (compareVersions(running, minRaw) ?? 0) < 0;
|
|
3742
|
+
const newer = newerThanRunning ? { required: minRaw.trim(), running, ignored: [] } : void 0;
|
|
3743
|
+
rejectUnknown(raw, TOP_LEVEL, "top-level", file, newer);
|
|
3744
|
+
rejectUnknown(raw.hooks, new Set(HOOK_NAMES), "hooks", file, newer);
|
|
3745
|
+
rejectUnknown(raw.labels, new Set(HOOK_NAMES), "labels", file, newer);
|
|
3746
|
+
rejectUnknown(raw.release, RELEASE_KEYS, "release", file, newer);
|
|
3747
|
+
rejectUnknown(raw.release?.ci, CI_KEYS, "release.ci", file, newer);
|
|
3748
|
+
rejectUnknown(raw.release?.verify, VERIFY_KEYS, "release.verify", file, newer);
|
|
3749
|
+
rejectUnknown(raw.release?.isolateFailures, ISOLATE_KEYS, "release.isolateFailures", file, newer);
|
|
3750
|
+
rejectUnknown(raw.branch, BRANCH_KEYS, "branch", file, newer);
|
|
3751
|
+
rejectUnknown(raw.worktrees, /* @__PURE__ */ new Set(["copy", "prefix", "name"]), "worktrees", file, newer);
|
|
3752
|
+
rejectUnknown(raw.periscope, /* @__PURE__ */ new Set(["inspector"]), "periscope", file, newer);
|
|
3753
|
+
rejectUnknown(raw.docs, /* @__PURE__ */ new Set(["triagePolicy", "designGuide"]), "docs", file, newer);
|
|
3754
|
+
rejectUnknown(raw.sandbox, SANDBOX_KEYS, "sandbox", file, newer);
|
|
3713
3755
|
const sandboxNetwork = parseSandboxNetwork(raw.sandbox, file, (m) => new RepoConfigError(m));
|
|
3714
3756
|
if (raw.version === void 0) throw new RepoConfigError(`${file}: version is required`);
|
|
3715
3757
|
if (raw.version !== SPEC_VERSION) {
|
|
@@ -3919,6 +3961,7 @@ function parseRepoConfig(text2, file) {
|
|
|
3919
3961
|
}
|
|
3920
3962
|
return {
|
|
3921
3963
|
version: SPEC_VERSION,
|
|
3964
|
+
...newer && newer.ignored.length > 0 ? { newerContract: { required: newer.required, running: newer.running, keys: newer.ignored } } : {},
|
|
3922
3965
|
branch,
|
|
3923
3966
|
worktrees: worktrees2,
|
|
3924
3967
|
...inspectorRaw ? { periscope: { inspector: inspectorRaw } } : {},
|
|
@@ -4055,6 +4098,7 @@ function resolveRepoConfig(repo, ship, dir) {
|
|
|
4055
4098
|
);
|
|
4056
4099
|
return {
|
|
4057
4100
|
version: SPEC_VERSION,
|
|
4101
|
+
...repo?.newerContract ? { newerContract: repo.newerContract } : {},
|
|
4058
4102
|
// Repo-only, like platform: what a repo needs installed is a fact about it.
|
|
4059
4103
|
...repo?.sandbox ? { sandbox: repo.sandbox } : {},
|
|
4060
4104
|
worktrees: {
|
|
@@ -6866,6 +6910,14 @@ function seatKeyUnreadableItem(route2, seat, storeError, nowIso = (/* @__PURE__
|
|
|
6866
6910
|
}
|
|
6867
6911
|
var repoContractRefusedKey = (repo) => `repo_contract_refused:${repo}`;
|
|
6868
6912
|
function repoContractRefusedItem(repo, detail, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
6913
|
+
if (detail.includes(NEWER_CONTRACT_PHRASE)) {
|
|
6914
|
+
return {
|
|
6915
|
+
kind: "repo_contract_refused",
|
|
6916
|
+
key: repoContractRefusedKey(repo),
|
|
6917
|
+
since: nowIso,
|
|
6918
|
+
message: `${repo}: this crew is older than its repo contract needs and the repository is skipped \u2014 ${detail}. Upgrade crew to resume; \`crew doctor\` names the versions`
|
|
6919
|
+
};
|
|
6920
|
+
}
|
|
6869
6921
|
return {
|
|
6870
6922
|
kind: "repo_contract_refused",
|
|
6871
6923
|
key: repoContractRefusedKey(repo),
|
|
@@ -6873,6 +6925,15 @@ function repoContractRefusedItem(repo, detail, nowIso = (/* @__PURE__ */ new Dat
|
|
|
6873
6925
|
message: `${repo}: its repo contract is refused and the repository is skipped \u2014 ${detail}. Resumes automatically once the file is valid on its base; \`crew doctor\` names the problem`
|
|
6874
6926
|
};
|
|
6875
6927
|
}
|
|
6928
|
+
var repoContractNewerKey = (repo) => `repo_contract_newer:${repo}`;
|
|
6929
|
+
function repoContractNewerItem(repo, note, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
6930
|
+
return {
|
|
6931
|
+
kind: "repo_contract_newer",
|
|
6932
|
+
key: repoContractNewerKey(repo),
|
|
6933
|
+
since: nowIso,
|
|
6934
|
+
message: `${repo}: ${newerContractSummary(note)}; the repository is still served`
|
|
6935
|
+
};
|
|
6936
|
+
}
|
|
6876
6937
|
var repoPlatformUnreleasableKey = (repo) => `repo_platform_unreleasable:${repo}`;
|
|
6877
6938
|
function repoPlatformUnreleasableItem(repo, detail, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
6878
6939
|
return {
|
|
@@ -19453,17 +19514,6 @@ function realPoolMemberDeps(o) {
|
|
|
19453
19514
|
// src/crew-floor.ts
|
|
19454
19515
|
import { TablationApiError as TablationApiError4 } from "@tablation/client";
|
|
19455
19516
|
var CREW_OUTDATED_KEY = "crew_outdated";
|
|
19456
|
-
function parseVersion(v) {
|
|
19457
|
-
const m = /^v?(\d+)\.(\d+)\.(\d+)/.exec(v.trim());
|
|
19458
|
-
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
19459
|
-
}
|
|
19460
|
-
function compareVersions(a, b) {
|
|
19461
|
-
const pa = parseVersion(a);
|
|
19462
|
-
const pb = parseVersion(b);
|
|
19463
|
-
if (!pa || !pb) return null;
|
|
19464
|
-
for (let i = 0; i < 3; i++) if (pa[i] !== pb[i]) return pa[i] - pb[i];
|
|
19465
|
-
return 0;
|
|
19466
|
-
}
|
|
19467
19517
|
function belowFloor(have, floor) {
|
|
19468
19518
|
if (!floor) return false;
|
|
19469
19519
|
const c = compareVersions(have, floor);
|
|
@@ -23022,9 +23072,13 @@ async function runRelease(o) {
|
|
|
23022
23072
|
const movedPast2 = [];
|
|
23023
23073
|
const localRefSkips = [];
|
|
23024
23074
|
const rightOfWay = { deferrals: [], lapsed: [] };
|
|
23025
|
-
const
|
|
23075
|
+
const batch = { deferred: [], reason: "capped" };
|
|
23076
|
+
const out = await runReleaseCycle({ ...o, batch }, movedPast2, localRefSkips, rightOfWay);
|
|
23077
|
+
const gateFailed = out.stopped === "tests failed" || out.stopped === "build failed";
|
|
23026
23078
|
return {
|
|
23027
23079
|
...out,
|
|
23080
|
+
...batch.deferred.length ? { batchDeferral: batch } : {},
|
|
23081
|
+
...gateFailed && !out.buildCulprits?.length && out.merged.length ? { unisolatedFailure: true } : {},
|
|
23028
23082
|
...movedPast2.length ? { movedPast: movedPast2 } : {},
|
|
23029
23083
|
...localRefSkips.length ? { localRefSkips } : {},
|
|
23030
23084
|
...rightOfWay.deferrals.length || rightOfWay.lapsed.length ? { rightOfWay } : {}
|
|
@@ -23115,7 +23169,7 @@ async function runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay) {
|
|
|
23115
23169
|
const { remote, base } = o.repo.branch;
|
|
23116
23170
|
const inPlace = o.dryRun || !!o.mergeOnly || !remoteBranchExists(o.cwd, remote, base);
|
|
23117
23171
|
const remoteRef = `${remote}/${base}`;
|
|
23118
|
-
const
|
|
23172
|
+
const decided = decideRelease(o.cwd, releasable, o.contract, {
|
|
23119
23173
|
tagPattern,
|
|
23120
23174
|
base,
|
|
23121
23175
|
blockerInfo: o.blockerInfo,
|
|
@@ -23125,6 +23179,13 @@ async function runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay) {
|
|
|
23125
23179
|
// A dry run only looks.
|
|
23126
23180
|
branchFor: (t) => o.dryRun ? locateBranchForTicket(o.cwd, o.repo, t)?.branch ?? null : materializeBranchForTicket(o.cwd, o.repo, t)
|
|
23127
23181
|
});
|
|
23182
|
+
let decision = decided;
|
|
23183
|
+
if (o.batchCapped && !o.dryRun && !o.mergeOnly && !o.force) {
|
|
23184
|
+
const cap = isolateCap(o);
|
|
23185
|
+
const trimmed = trimBatch(decided, cap);
|
|
23186
|
+
decision = trimmed.decision;
|
|
23187
|
+
noteDeferred(o, trimmed.left, "capped", cap);
|
|
23188
|
+
}
|
|
23128
23189
|
reportHeld(o, decision.held);
|
|
23129
23190
|
if (!fresh.ok) {
|
|
23130
23191
|
o.emit.error(scoped(`refusing to release \u2014 ${fresh.why}; a person has to reconcile the two`));
|
|
@@ -23217,24 +23278,36 @@ async function runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay) {
|
|
|
23217
23278
|
}
|
|
23218
23279
|
return rebuild ? { ...outcome, primaryRebuild: rebuild } : outcome;
|
|
23219
23280
|
}
|
|
23220
|
-
var
|
|
23221
|
-
|
|
23222
|
-
|
|
23223
|
-
|
|
23224
|
-
|
|
23225
|
-
|
|
23226
|
-
|
|
23227
|
-
|
|
23228
|
-
|
|
23229
|
-
|
|
23230
|
-
|
|
23231
|
-
|
|
23232
|
-
|
|
23233
|
-
return {
|
|
23281
|
+
var MAX_ISOLATE_ROUNDS = 2;
|
|
23282
|
+
var BATCH_CAPPED_EVENT = "release_capped";
|
|
23283
|
+
var BATCH_CAP_CLEARED_EVENT = "release_cap_cleared";
|
|
23284
|
+
function batchCapActive(events, scope) {
|
|
23285
|
+
const at = (e) => Date.parse(e.occurred_at ?? e.created_at ?? "") || 0;
|
|
23286
|
+
const mine = events.filter((e) => e.metadata?.scope === scope && (e.event_type === BATCH_CAPPED_EVENT || e.event_type === BATCH_CAP_CLEARED_EVENT));
|
|
23287
|
+
if (!mine.length) return false;
|
|
23288
|
+
const newest = mine.reduce((a, b) => at(b) > at(a) ? b : a);
|
|
23289
|
+
return newest.event_type === BATCH_CAPPED_EVENT;
|
|
23290
|
+
}
|
|
23291
|
+
var isMergeable = (c) => !!c.branch && !c.mergedSha;
|
|
23292
|
+
function trimBatch(decision, cap) {
|
|
23293
|
+
const mergeable = decision.merges.filter(isMergeable);
|
|
23294
|
+
if (cap <= 0 || mergeable.length <= cap) return { decision, left: [] };
|
|
23295
|
+
const left = mergeable.slice(cap);
|
|
23296
|
+
return { decision: { ...decision, merges: decision.merges.filter((c) => !left.includes(c)) }, left };
|
|
23297
|
+
}
|
|
23298
|
+
function noteDeferred(o, left, reason, limit) {
|
|
23299
|
+
if (!left.length) return;
|
|
23300
|
+
const why = reason === "capped" ? `the last release failed its gate and was not isolated, so a batch is capped at ${limit}` : `the gate failed on a batch over release.isolateFailures.maxCandidates (${limit}), so the oldest ${limit} are tried first`;
|
|
23301
|
+
o.emit.warn(
|
|
23302
|
+
`${left.length} verified branch${left.length === 1 ? "" : "es"} left for a later cycle: ${why}`,
|
|
23303
|
+
{ step: "release", data: { deferred: left.length, reason, limit } }
|
|
23304
|
+
);
|
|
23305
|
+
o.batch?.deferred.push(...left.map((c) => c.ticket));
|
|
23306
|
+
if (o.batch) o.batch.reason = reason;
|
|
23234
23307
|
}
|
|
23235
23308
|
function selfRepairLine(maxCandidates) {
|
|
23236
23309
|
const cap = maxCandidates ?? DEFAULT_ISOLATE_MAX_CANDIDATES;
|
|
23237
|
-
return cap === 0 ? "culprit isolation is off (release.isolateFailures.maxCandidates: 0); a failed gate files an alert" : `culprit isolation up to ${cap} merged branches, ${
|
|
23310
|
+
return cap === 0 ? "culprit isolation is off (release.isolateFailures.maxCandidates: 0); a failed gate files an alert" : `culprit isolation bisects up to ${cap} merged branches (a larger failing batch is shrunk to the oldest ${cap}, and the next batch is capped at ${cap} until a release ships); a ticket handed back twice after a push escalates with an alert`;
|
|
23238
23311
|
}
|
|
23239
23312
|
var isolateCap = (o) => o.repo.release.isolateFailures?.maxCandidates ?? DEFAULT_ISOLATE_MAX_CANDIDATES;
|
|
23240
23313
|
async function redBase(o, name, applied, cap, preMerge, head, decision, fresh, releaseBranch) {
|
|
@@ -23263,14 +23336,71 @@ async function redBase(o, name, applied, cap, preMerge, head, decision, fresh, r
|
|
|
23263
23336
|
o.emit.emit(`${keep.map((c) => c.branch).join(", ")} make the ${name} hook pass on a red ${base} \u2014 releasing ${keep.length === 1 ? "it" : "them"}, the rest stay verified`);
|
|
23264
23337
|
gitOk(o.cwd, ["reset", "--hard", preMerge]);
|
|
23265
23338
|
const rest = decision.merges.filter((c) => !applied.includes(c) || keep.includes(c));
|
|
23266
|
-
const retried = await mergeAndRelease(o, { ...decision, merges: rest }, fresh, releaseBranch,
|
|
23339
|
+
const retried = await mergeAndRelease(o, { ...decision, merges: rest }, fresh, releaseBranch, MAX_ISOLATE_ROUNDS);
|
|
23267
23340
|
return retried.isolation ? retried : { ...retried, isolation: tried };
|
|
23268
23341
|
}
|
|
23269
|
-
async function
|
|
23342
|
+
async function bisectCulprit(o, name, applied, output, preMerge) {
|
|
23343
|
+
const gate = async (group) => {
|
|
23344
|
+
gitOk(o.cwd, ["reset", "--hard", preMerge]);
|
|
23345
|
+
for (const c of group) if (mergeFailed(mergeOne(o, c))) return { failed: false, output: "" };
|
|
23346
|
+
const r = await hook(o, name);
|
|
23347
|
+
return { failed: !!r && r.code !== 0, output: r?.output ?? "" };
|
|
23348
|
+
};
|
|
23349
|
+
let lo = 1, hi = applied.length, tail3 = output;
|
|
23350
|
+
while (lo < hi) {
|
|
23351
|
+
const mid = Math.floor((lo + hi) / 2);
|
|
23352
|
+
const g = await gate(applied.slice(0, mid));
|
|
23353
|
+
if (g.failed) {
|
|
23354
|
+
hi = mid;
|
|
23355
|
+
tail3 = g.output;
|
|
23356
|
+
} else lo = mid + 1;
|
|
23357
|
+
}
|
|
23358
|
+
const owner = applied[hi - 1];
|
|
23359
|
+
if (hi === 1) return { c: owner, how: "solo", output: tail3 };
|
|
23360
|
+
const alone = await gate([owner]);
|
|
23361
|
+
if (alone.failed) return { c: owner, how: "solo", output: alone.output };
|
|
23362
|
+
const earlier = applied.slice(0, hi - 1);
|
|
23363
|
+
let from = 1, to = earlier.length;
|
|
23364
|
+
while (from < to) {
|
|
23365
|
+
const mid = Math.floor((from + to) / 2);
|
|
23366
|
+
const g = await gate([...earlier.slice(0, mid), owner]);
|
|
23367
|
+
if (g.failed) {
|
|
23368
|
+
to = mid;
|
|
23369
|
+
tail3 = g.output;
|
|
23370
|
+
} else from = mid + 1;
|
|
23371
|
+
}
|
|
23372
|
+
const sibling = earlier[to - 1];
|
|
23373
|
+
if (earlier.length > 1) {
|
|
23374
|
+
const pair = await gate([sibling, owner]);
|
|
23375
|
+
if (!pair.failed) return null;
|
|
23376
|
+
tail3 = pair.output;
|
|
23377
|
+
}
|
|
23378
|
+
return { c: owner, how: "pair", sibling, output: tail3 };
|
|
23379
|
+
}
|
|
23380
|
+
async function isolateAndRetry(o, name, output, merged, preMerge, decision, fresh, releaseBranch, rounds) {
|
|
23270
23381
|
const applied = merged.filter((c) => c.sha && c.branch);
|
|
23271
23382
|
const cap = isolateCap(o);
|
|
23272
23383
|
if (o.dryRun || !preMerge || applied.length < 1 || cap === 0) return null;
|
|
23273
23384
|
const head = headSha(o.cwd);
|
|
23385
|
+
if (applied.length > cap) {
|
|
23386
|
+
const named = failingPaths(output, o.cwd);
|
|
23387
|
+
const changed2 = (c) => new Set(
|
|
23388
|
+
(gitOk(o.cwd, ["diff", "--name-only", `${preMerge}...${c.branch}`]) ?? "").split("\n").filter(Boolean)
|
|
23389
|
+
);
|
|
23390
|
+
if (!culpritByFiles(applied.map((c) => ({ c, changed: changed2(c) })), named)) {
|
|
23391
|
+
const { decision: smaller, left } = trimBatch(decision, cap);
|
|
23392
|
+
noteDeferred(o, left, "shrunk", cap);
|
|
23393
|
+
for (const c of left) {
|
|
23394
|
+
if (!o.onUnclaim || o.dryRun) break;
|
|
23395
|
+
try {
|
|
23396
|
+
await o.onUnclaim(c.ticket);
|
|
23397
|
+
} catch {
|
|
23398
|
+
}
|
|
23399
|
+
}
|
|
23400
|
+
gitOk(o.cwd, ["reset", "--hard", preMerge]);
|
|
23401
|
+
return mergeAndRelease(o, smaller, fresh, releaseBranch, rounds);
|
|
23402
|
+
}
|
|
23403
|
+
}
|
|
23274
23404
|
gitOk(o.cwd, ["reset", "--hard", preMerge]);
|
|
23275
23405
|
const baseRun = await hook(o, name);
|
|
23276
23406
|
if (baseRun && baseRun.code !== 0) {
|
|
@@ -23291,75 +23421,29 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
|
|
|
23291
23421
|
const only = applied[0];
|
|
23292
23422
|
o.emit.warn(`${name} failed with only ${only.branch} merged and passes without it \u2014 treating it as the culprit`, { ticket: only.ticket.issue_id });
|
|
23293
23423
|
culprits.push({ c: only, how: "solo", output, paths: failingPaths(output, o.cwd) });
|
|
23294
|
-
} else if (applied.length > cap) {
|
|
23295
|
-
o.emit.warn(`${name} failed with ${applied.length} branches merged, over release.isolateFailures.maxCandidates (${cap}) \u2014 not isolating`);
|
|
23296
|
-
return { tried: `Isolation was skipped: ${applied.length} branches were merged, over release.isolateFailures.maxCandidates (${cap}).` };
|
|
23297
23424
|
} else {
|
|
23298
|
-
o.emit.warn(`${name} failed with ${applied.length} branches merged \u2014
|
|
23299
|
-
|
|
23300
|
-
|
|
23301
|
-
|
|
23302
|
-
|
|
23303
|
-
|
|
23304
|
-
|
|
23305
|
-
|
|
23306
|
-
culprits.push({ c, how: "solo", output: r.output, paths: failingPaths(r.output, o.cwd) });
|
|
23307
|
-
}
|
|
23308
|
-
}
|
|
23309
|
-
if (culprits.length === 0) {
|
|
23310
|
-
const { pairs, truncated } = pairOrder(applied.length);
|
|
23311
|
-
for (const [i, j] of pairs) {
|
|
23312
|
-
gitOk(o.cwd, ["reset", "--hard", preMerge]);
|
|
23313
|
-
const a = mergeOne(o, applied[i]);
|
|
23314
|
-
const b = mergeFailed(a) ? a : mergeOne(o, applied[j]);
|
|
23315
|
-
if (mergeFailed(b)) continue;
|
|
23316
|
-
const r = await hook(o, name);
|
|
23317
|
-
if (r && r.code !== 0) {
|
|
23318
|
-
o.emit.warn(`${applied[j].branch} fails the ${name} hook together with ${applied[i].branch}`, { ticket: applied[j].ticket.issue_id });
|
|
23319
|
-
culprits.push({ c: applied[j], how: "pair", sibling: applied[i], output: r.output, paths: failingPaths(r.output, o.cwd) });
|
|
23320
|
-
break;
|
|
23321
|
-
}
|
|
23322
|
-
}
|
|
23323
|
-
if (culprits.length === 0 && truncated) {
|
|
23324
|
-
let lo = 2, hi = applied.length;
|
|
23325
|
-
let tailOut = output;
|
|
23326
|
-
let paths = failingPaths(output, o.cwd);
|
|
23327
|
-
while (lo < hi) {
|
|
23328
|
-
const mid = Math.floor((lo + hi) / 2);
|
|
23329
|
-
gitOk(o.cwd, ["reset", "--hard", preMerge]);
|
|
23330
|
-
let clean = true;
|
|
23331
|
-
for (const c of applied.slice(0, mid)) {
|
|
23332
|
-
const m = mergeOne(o, c);
|
|
23333
|
-
if (mergeFailed(m)) {
|
|
23334
|
-
clean = false;
|
|
23335
|
-
break;
|
|
23336
|
-
}
|
|
23337
|
-
}
|
|
23338
|
-
const r = clean ? await hook(o, name) : null;
|
|
23339
|
-
if (r && r.code !== 0) {
|
|
23340
|
-
hi = mid;
|
|
23341
|
-
tailOut = r.output;
|
|
23342
|
-
paths = failingPaths(r.output, o.cwd);
|
|
23343
|
-
} else lo = mid + 1;
|
|
23344
|
-
}
|
|
23345
|
-
const owner = applied[hi - 1];
|
|
23346
|
-
o.emit.warn(`${owner.branch} is the first branch whose prefix fails the ${name} hook (bisected over ${applied.length})`, { ticket: owner.ticket.issue_id });
|
|
23347
|
-
culprits.push({ c: owner, how: "pair", sibling: applied[hi - 2], output: tailOut, paths });
|
|
23348
|
-
}
|
|
23425
|
+
o.emit.warn(`${name} failed with ${applied.length} branches merged \u2014 bisecting to find the culprit`);
|
|
23426
|
+
const found = await bisectCulprit(o, name, applied, output, preMerge);
|
|
23427
|
+
if (found) {
|
|
23428
|
+
o.emit.warn(
|
|
23429
|
+
found.how === "solo" ? `${found.c.branch} fails the ${name} hook on its own` : `${found.c.branch} fails the ${name} hook together with ${found.sibling.branch}`,
|
|
23430
|
+
{ ticket: found.c.ticket.issue_id }
|
|
23431
|
+
);
|
|
23432
|
+
culprits.push({ ...found, paths: failingPaths(found.output, o.cwd) });
|
|
23349
23433
|
}
|
|
23350
23434
|
}
|
|
23351
23435
|
gitOk(o.cwd, ["reset", "--hard", preMerge]);
|
|
23352
23436
|
if (culprits.length === 0) {
|
|
23353
23437
|
o.emit.warn("no single branch could be blamed \u2014 failing the release as a whole");
|
|
23354
23438
|
gitOk(o.cwd, ["reset", "--hard", head]);
|
|
23355
|
-
return { tried: `Isolation found no culprit:
|
|
23439
|
+
return { tried: `Isolation found no culprit: bisecting the ${applied.length} merged branches named no single branch, and no pair among them, that fails the ${name} hook.` };
|
|
23356
23440
|
}
|
|
23357
23441
|
const out = new Set(culprits.map((x) => x.c.ticket.id));
|
|
23358
23442
|
const rest = decision.merges.filter((c) => !out.has(c.ticket.id));
|
|
23359
|
-
const retried = await mergeAndRelease(o, { ...decision, merges: rest }, fresh, releaseBranch,
|
|
23443
|
+
const retried = await mergeAndRelease(o, { ...decision, merges: rest }, fresh, releaseBranch, rounds + 1);
|
|
23360
23444
|
return {
|
|
23361
23445
|
...retried,
|
|
23362
|
-
buildCulprits: culprits.map((x) => {
|
|
23446
|
+
buildCulprits: [...culprits.map((x) => {
|
|
23363
23447
|
const ex = failureExcerpt(x.output, x.paths, HOOK_FAILURE_TAIL_LINES);
|
|
23364
23448
|
const tip = gitOk(o.cwd, ["rev-parse", x.c.branch])?.trim();
|
|
23365
23449
|
const logPath = saveGateOutput(x.c.ticket.issue_tag ?? x.c.ticket.issue_id, name, x.output);
|
|
@@ -23377,15 +23461,15 @@ async function isolateAndRetry(o, name, output, merged, preMerge, decision, fres
|
|
|
23377
23461
|
inBranch: x.paths.length === 0 ? null : x.paths.some((p) => withFiles.find((w) => w.c === x.c)?.changed.has(p) ?? false),
|
|
23378
23462
|
...x.sibling ? { sibling: { key: x.sibling.ticket.issue_tag ?? x.sibling.ticket.issue_id, branch: x.sibling.branch } } : {}
|
|
23379
23463
|
};
|
|
23380
|
-
})
|
|
23464
|
+
}), ...retried.buildCulprits ?? []]
|
|
23381
23465
|
};
|
|
23382
23466
|
}
|
|
23383
|
-
async function mergeAndRelease(o, decision, fresh, releaseBranch,
|
|
23467
|
+
async function mergeAndRelease(o, decision, fresh, releaseBranch, isolationRounds = 0) {
|
|
23384
23468
|
const flakeLog = o.flakeLog ?? [];
|
|
23385
|
-
const outcome = await mergeAndReleaseBody({ ...o, flakeLog }, decision, fresh, releaseBranch,
|
|
23469
|
+
const outcome = await mergeAndReleaseBody({ ...o, flakeLog }, decision, fresh, releaseBranch, isolationRounds);
|
|
23386
23470
|
return flakeLog.length ? { ...outcome, flakes: [...flakeLog] } : outcome;
|
|
23387
23471
|
}
|
|
23388
|
-
async function mergeAndReleaseBody(o, decision, fresh, releaseBranch,
|
|
23472
|
+
async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolationRounds = 0) {
|
|
23389
23473
|
o.emit.enter("merge");
|
|
23390
23474
|
const preMerge = o.dryRun ? "" : headSha(o.cwd);
|
|
23391
23475
|
const merged = [];
|
|
@@ -23564,8 +23648,8 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
23564
23648
|
const settleTest = async (first) => {
|
|
23565
23649
|
let r = first;
|
|
23566
23650
|
if (r && r.code !== 0 && !o.dryRun) r = await rerunOnce(o, "test", r);
|
|
23567
|
-
if (r && r.code !== 0 &&
|
|
23568
|
-
const out = await isolateAndRetry(o, "test", r.output, merged, preMerge, decision, fresh, releaseBranch);
|
|
23651
|
+
if (r && r.code !== 0 && isolationRounds < MAX_ISOLATE_ROUNDS) {
|
|
23652
|
+
const out = await isolateAndRetry(o, "test", r.output, merged, preMerge, decision, fresh, releaseBranch, isolationRounds);
|
|
23569
23653
|
if (out && "tried" in out) isolation = out.tried;
|
|
23570
23654
|
else if (out) return out;
|
|
23571
23655
|
}
|
|
@@ -23597,8 +23681,8 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
23597
23681
|
const settleBuild = async (first) => {
|
|
23598
23682
|
let r = first;
|
|
23599
23683
|
if (r && r.code !== 0) r = await rerunOnce(o, "build", r);
|
|
23600
|
-
if (r && r.code !== 0 &&
|
|
23601
|
-
const out = await isolateAndRetry(o, "build", r.output, merged, preMerge, decision, fresh, releaseBranch);
|
|
23684
|
+
if (r && r.code !== 0 && isolationRounds < MAX_ISOLATE_ROUNDS) {
|
|
23685
|
+
const out = await isolateAndRetry(o, "build", r.output, merged, preMerge, decision, fresh, releaseBranch, isolationRounds);
|
|
23602
23686
|
if (out && "tried" in out) isolation = out.tried;
|
|
23603
23687
|
else if (out) return out;
|
|
23604
23688
|
}
|
|
@@ -23631,7 +23715,7 @@ async function mergeAndReleaseBody(o, decision, fresh, releaseBranch, isolated =
|
|
|
23631
23715
|
o.emit.emit(`would run: ${hookLabel(o.repo, "build")}`);
|
|
23632
23716
|
if (applied >= 1) {
|
|
23633
23717
|
o.emit.emit(
|
|
23634
|
-
`if it fails, would find the one of ${applied} merged branches that broke it (by the files it names, else by
|
|
23718
|
+
`if it fails, would find the one of ${applied} merged branches that broke it (by the files it names, else by bisecting up to ${isolateCap(o)} branches), hand that back to the dev lane and ship the rest`
|
|
23635
23719
|
);
|
|
23636
23720
|
}
|
|
23637
23721
|
} else {
|
|
@@ -28562,6 +28646,7 @@ function renderRepoCheck(r) {
|
|
|
28562
28646
|
` branch.name ${e.branch.name}`,
|
|
28563
28647
|
` branch.push ${e.branch.push}`
|
|
28564
28648
|
];
|
|
28649
|
+
if (e.newerContract) lines2.push(` newer contract: ${newerContractSummary(e.newerContract)}`);
|
|
28565
28650
|
for (const s of r.samples) lines2.push(` ${s.case}: branch ${s.branch}, worktree ../${s.worktree}`);
|
|
28566
28651
|
if (r.mapFile) {
|
|
28567
28652
|
const m = r.mapFile;
|
|
@@ -29737,7 +29822,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
29737
29822
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
29738
29823
|
import { join as join61 } from "path";
|
|
29739
29824
|
function builtVersion() {
|
|
29740
|
-
return true ? "0.
|
|
29825
|
+
return true ? "0.169.0" : null;
|
|
29741
29826
|
}
|
|
29742
29827
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
29743
29828
|
function newestMtime(path) {
|
|
@@ -31779,6 +31864,10 @@ function findPeriscope(sidecars, segment) {
|
|
|
31779
31864
|
|
|
31780
31865
|
// src/cli.ts
|
|
31781
31866
|
var CREW_HOME = isCompiledBinary(import.meta.url) ? dirname38(process.execPath) : resolve7(dirname38(fileURLToPath2(import.meta.url)), "..");
|
|
31867
|
+
{
|
|
31868
|
+
const v = crewVersion(CREW_HOME);
|
|
31869
|
+
if (v !== "0.0.0") setRunningCrewVersion(v);
|
|
31870
|
+
}
|
|
31782
31871
|
var RELEASE_LOCK_TTL_MS = 20 * 60 * 1e3;
|
|
31783
31872
|
var CYCLE_SECONDS2 = 120;
|
|
31784
31873
|
var STALE_CYCLES = 3;
|
|
@@ -33070,6 +33159,14 @@ ${changed2.map((c) => ` - ${c}
|
|
|
33070
33159
|
}
|
|
33071
33160
|
const refused = new Set(errors.map((e) => e.repo));
|
|
33072
33161
|
for (const t of reposOf(c)) if (!refused.has(t.name)) clearShipAttention(state, repoContractRefusedKey(t.name));
|
|
33162
|
+
const newer = new Map(settled.filter((r) => r.config.newerContract).map((r) => [r.name, r.config.newerContract]));
|
|
33163
|
+
for (const [repo, note] of newer) {
|
|
33164
|
+
try {
|
|
33165
|
+
await raiseShipAttention({ state, emit }, repoContractNewerItem(repo, note));
|
|
33166
|
+
} catch {
|
|
33167
|
+
}
|
|
33168
|
+
}
|
|
33169
|
+
for (const t of reposOf(c)) if (!newer.has(t.name)) clearShipAttention(state, repoContractNewerKey(t.name));
|
|
33073
33170
|
return { settled, errors };
|
|
33074
33171
|
}
|
|
33075
33172
|
async function shipNeedsDocker() {
|
|
@@ -33544,11 +33641,21 @@ ${changed2.map((c) => ` - ${c}
|
|
|
33544
33641
|
remit.warn(`could not read hand-back events; not deferring any branch: ${e.message}`);
|
|
33545
33642
|
}
|
|
33546
33643
|
}
|
|
33644
|
+
let capEvents = [];
|
|
33645
|
+
if (verifiedTickets.length >= 1 && repo.release.mode !== "external") {
|
|
33646
|
+
try {
|
|
33647
|
+
capEvents = [...await tracker.events(BATCH_CAPPED_EVENT), ...await tracker.events(BATCH_CAP_CLEARED_EVENT)];
|
|
33648
|
+
} catch (e) {
|
|
33649
|
+
remit.warn(`could not read the release cap from the board; not capping this batch: ${e.message}`);
|
|
33650
|
+
}
|
|
33651
|
+
}
|
|
33652
|
+
const batchCapped = batchCapActive(capEvents, scope);
|
|
33547
33653
|
const claimed = /* @__PURE__ */ new Map();
|
|
33548
33654
|
const outcome = await runRelease({
|
|
33549
33655
|
cwd: target.dir,
|
|
33550
33656
|
repo,
|
|
33551
33657
|
rightOfWayEvents,
|
|
33658
|
+
batchCapped,
|
|
33552
33659
|
reloadRepo: (dir) => resolveRepoConfig(loadRepoConfig(dir), {
|
|
33553
33660
|
hooks: { ...c.hooks, ...o?.hooks },
|
|
33554
33661
|
labels: { ...c.labels, ...o?.labels },
|
|
@@ -33695,6 +33802,25 @@ ${changed2.map((c) => ` - ${c}
|
|
|
33695
33802
|
remit.warn(`could not note the red test gate on the board: ${e.message}`, { step: "merge" });
|
|
33696
33803
|
}
|
|
33697
33804
|
}
|
|
33805
|
+
if (!dryRun) {
|
|
33806
|
+
const shipped = outcome.deployed || outcome.integrated;
|
|
33807
|
+
const note = outcome.merged[0]?.ticket ?? outcome.batchDeferral?.deferred[0];
|
|
33808
|
+
try {
|
|
33809
|
+
if (outcome.unisolatedFailure && !batchCapped && note) {
|
|
33810
|
+
await tracker.postEvent(
|
|
33811
|
+
note.id,
|
|
33812
|
+
`${scope}: the release gate failed and no branch was isolated \u2014 the next release takes at most ${repo.release.isolateFailures?.maxCandidates ?? DEFAULT_ISOLATE_MAX_CANDIDATES} branches until one ships`,
|
|
33813
|
+
releaseSeat(c),
|
|
33814
|
+
BATCH_CAPPED_EVENT,
|
|
33815
|
+
{ scope }
|
|
33816
|
+
);
|
|
33817
|
+
} else if (shipped && batchCapped && note) {
|
|
33818
|
+
await tracker.postEvent(note.id, `${scope}: a release shipped \u2014 the batch cap is lifted`, releaseSeat(c), BATCH_CAP_CLEARED_EVENT, { scope });
|
|
33819
|
+
}
|
|
33820
|
+
} catch (e) {
|
|
33821
|
+
remit.warn(`could not record the release batch cap on the board: ${e.message}`, { step: "release" });
|
|
33822
|
+
}
|
|
33823
|
+
}
|
|
33698
33824
|
if (outcome.localRefSkips?.length && !dryRun) {
|
|
33699
33825
|
try {
|
|
33700
33826
|
const reported2 = await tracker.events("local_ref_skip");
|
|
@@ -24714,6 +24714,19 @@ function parseSandboxNetwork(raw, file, fail2) {
|
|
|
24714
24714
|
return { hosts, toolchains };
|
|
24715
24715
|
}
|
|
24716
24716
|
|
|
24717
|
+
// src/version-compare.ts
|
|
24718
|
+
function parseVersion(v) {
|
|
24719
|
+
const m = /^v?(\d+)\.(\d+)\.(\d+)/.exec(v.trim());
|
|
24720
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
24721
|
+
}
|
|
24722
|
+
function compareVersions(a, b) {
|
|
24723
|
+
const pa = parseVersion(a);
|
|
24724
|
+
const pb = parseVersion(b);
|
|
24725
|
+
if (!pa || !pb) return null;
|
|
24726
|
+
for (let i = 0; i < 3; i++) if (pa[i] !== pb[i]) return pa[i] - pb[i];
|
|
24727
|
+
return 0;
|
|
24728
|
+
}
|
|
24729
|
+
|
|
24717
24730
|
// src/platform.ts
|
|
24718
24731
|
var PLATFORM_REQUIREMENTS = ["any", "unix", "macos", "linux", "windows"];
|
|
24719
24732
|
function isPlatformRequirement(v) {
|
|
@@ -24725,6 +24738,11 @@ var SPEC_VERSION = 1;
|
|
|
24725
24738
|
var REPO_CONFIG_FILENAMES = [".crew.yaml", ".crew.yml", ".crew.json"];
|
|
24726
24739
|
var RepoConfigError = class extends Error {
|
|
24727
24740
|
};
|
|
24741
|
+
var NewerContractError = class extends RepoConfigError {
|
|
24742
|
+
};
|
|
24743
|
+
var NEWER_CONTRACT_PHRASE = "needs a newer crew";
|
|
24744
|
+
var runningCrewVersion;
|
|
24745
|
+
var IGNORABLE_UNKNOWN_KEY_GROUPS = /* @__PURE__ */ new Set(["release", "release.isolateFailures", "labels", "periscope", "docs"]);
|
|
24728
24746
|
function versionFileProblem(name, text) {
|
|
24729
24747
|
const remedy = `a version file that is not a JSON object with a string "version" needs hooks.bump instead of release.versionFiles (docs/REPO_SPEC.md)`;
|
|
24730
24748
|
let doc;
|
|
@@ -24758,6 +24776,7 @@ var HOOK_NAMES = [
|
|
|
24758
24776
|
];
|
|
24759
24777
|
var TOP_LEVEL = /* @__PURE__ */ new Set([
|
|
24760
24778
|
"version",
|
|
24779
|
+
"minCrewVersion",
|
|
24761
24780
|
"platform",
|
|
24762
24781
|
"shell",
|
|
24763
24782
|
"branch",
|
|
@@ -24850,10 +24869,20 @@ function findRepoConfig(dir) {
|
|
|
24850
24869
|
}
|
|
24851
24870
|
return null;
|
|
24852
24871
|
}
|
|
24853
|
-
function rejectUnknown(obj, allowed, where, file) {
|
|
24872
|
+
function rejectUnknown(obj, allowed, where, file, newer) {
|
|
24854
24873
|
if (!obj || typeof obj !== "object") return;
|
|
24855
24874
|
const unknown2 = Object.keys(obj).filter((k) => !allowed.has(k));
|
|
24856
24875
|
if (unknown2.length > 0) {
|
|
24876
|
+
if (newer) {
|
|
24877
|
+
const paths = unknown2.map((k) => where === "top-level" ? k : `${where}.${k}`);
|
|
24878
|
+
if (IGNORABLE_UNKNOWN_KEY_GROUPS.has(where)) {
|
|
24879
|
+
newer.ignored.push(...paths);
|
|
24880
|
+
return;
|
|
24881
|
+
}
|
|
24882
|
+
throw new NewerContractError(
|
|
24883
|
+
`${file}: ${paths.join(", ")} ${paths.length === 1 ? "is" : "are"} not known to crew ${newer.running}, and the file declares minCrewVersion ${newer.required}: this repository ${NEWER_CONTRACT_PHRASE} (${newer.required} or later) and is skipped until crew is upgraded`
|
|
24884
|
+
);
|
|
24885
|
+
}
|
|
24857
24886
|
throw new RepoConfigError(
|
|
24858
24887
|
`${file}: unknown ${where} ${unknown2.length === 1 ? "key" : "keys"}: ${unknown2.join(", ")} (allowed: ${[...allowed].sort().join(", ")})`
|
|
24859
24888
|
);
|
|
@@ -24896,7 +24925,7 @@ function parseSandbox(raw, file) {
|
|
|
24896
24925
|
if (!image && packages.length === 0 && setup.length === 0 && warm.length === 0) return void 0;
|
|
24897
24926
|
return { ...image ? { image } : {}, packages, setup, warm };
|
|
24898
24927
|
}
|
|
24899
|
-
function parseRepoConfig(text, file) {
|
|
24928
|
+
function parseRepoConfig(text, file, opts = {}) {
|
|
24900
24929
|
let raw;
|
|
24901
24930
|
try {
|
|
24902
24931
|
raw = file.endsWith(".json") ? JSON.parse(text) : (0, import_yaml2.parse)(text);
|
|
@@ -24904,18 +24933,25 @@ function parseRepoConfig(text, file) {
|
|
|
24904
24933
|
throw new RepoConfigError(`${file}: could not be parsed \u2014 ${e.message}`);
|
|
24905
24934
|
}
|
|
24906
24935
|
if (!raw || typeof raw !== "object") throw new RepoConfigError(`${file} is empty or not a mapping`);
|
|
24907
|
-
|
|
24908
|
-
|
|
24909
|
-
|
|
24910
|
-
|
|
24911
|
-
|
|
24912
|
-
|
|
24913
|
-
|
|
24914
|
-
rejectUnknown(raw
|
|
24915
|
-
rejectUnknown(raw.
|
|
24916
|
-
rejectUnknown(raw.
|
|
24917
|
-
rejectUnknown(raw.
|
|
24918
|
-
rejectUnknown(raw.
|
|
24936
|
+
const minRaw = raw.minCrewVersion;
|
|
24937
|
+
if (minRaw !== void 0 && (typeof minRaw !== "string" || !/^\d+\.\d+\.\d+$/.test(minRaw.trim()))) {
|
|
24938
|
+
throw new RepoConfigError(`${file}: minCrewVersion must be a version like "0.167.0" (got "${String(minRaw)}")`);
|
|
24939
|
+
}
|
|
24940
|
+
const running = opts.crewVersion ?? runningCrewVersion;
|
|
24941
|
+
const newerThanRunning = typeof minRaw === "string" && running !== void 0 && parseVersion(running) !== null && (compareVersions(running, minRaw) ?? 0) < 0;
|
|
24942
|
+
const newer = newerThanRunning ? { required: minRaw.trim(), running, ignored: [] } : void 0;
|
|
24943
|
+
rejectUnknown(raw, TOP_LEVEL, "top-level", file, newer);
|
|
24944
|
+
rejectUnknown(raw.hooks, new Set(HOOK_NAMES), "hooks", file, newer);
|
|
24945
|
+
rejectUnknown(raw.labels, new Set(HOOK_NAMES), "labels", file, newer);
|
|
24946
|
+
rejectUnknown(raw.release, RELEASE_KEYS, "release", file, newer);
|
|
24947
|
+
rejectUnknown(raw.release?.ci, CI_KEYS, "release.ci", file, newer);
|
|
24948
|
+
rejectUnknown(raw.release?.verify, VERIFY_KEYS, "release.verify", file, newer);
|
|
24949
|
+
rejectUnknown(raw.release?.isolateFailures, ISOLATE_KEYS, "release.isolateFailures", file, newer);
|
|
24950
|
+
rejectUnknown(raw.branch, BRANCH_KEYS, "branch", file, newer);
|
|
24951
|
+
rejectUnknown(raw.worktrees, /* @__PURE__ */ new Set(["copy", "prefix", "name"]), "worktrees", file, newer);
|
|
24952
|
+
rejectUnknown(raw.periscope, /* @__PURE__ */ new Set(["inspector"]), "periscope", file, newer);
|
|
24953
|
+
rejectUnknown(raw.docs, /* @__PURE__ */ new Set(["triagePolicy", "designGuide"]), "docs", file, newer);
|
|
24954
|
+
rejectUnknown(raw.sandbox, SANDBOX_KEYS, "sandbox", file, newer);
|
|
24919
24955
|
const sandboxNetwork = parseSandboxNetwork(raw.sandbox, file, (m) => new RepoConfigError(m));
|
|
24920
24956
|
if (raw.version === void 0) throw new RepoConfigError(`${file}: version is required`);
|
|
24921
24957
|
if (raw.version !== SPEC_VERSION) {
|
|
@@ -25125,6 +25161,7 @@ function parseRepoConfig(text, file) {
|
|
|
25125
25161
|
}
|
|
25126
25162
|
return {
|
|
25127
25163
|
version: SPEC_VERSION,
|
|
25164
|
+
...newer && newer.ignored.length > 0 ? { newerContract: { required: newer.required, running: newer.running, keys: newer.ignored } } : {},
|
|
25128
25165
|
branch,
|
|
25129
25166
|
worktrees,
|
|
25130
25167
|
...inspectorRaw ? { periscope: { inspector: inspectorRaw } } : {},
|
|
@@ -158,7 +158,7 @@ Finish with a short report:
|
|
|
158
158
|
|
|
159
159
|
## Reference
|
|
160
160
|
|
|
161
|
-
Top-level keys: `version`, `platform`, `shell`, `branch`, `worktrees`, `docs`, `hooks`, `labels`, `release`, `sandbox`, `periscope`. Nothing else is accepted. The tables list the settings this task can need. The specification has the rest (branch and worktree naming, `shell`, `periscope`, `sandbox`, per-machine release settings); leave those unset unless I ask for them.
|
|
161
|
+
Top-level keys: `version`, `minCrewVersion` (leave it unset), `platform`, `shell`, `branch`, `worktrees`, `docs`, `hooks`, `labels`, `release`, `sandbox`, `periscope`. Nothing else is accepted. The tables list the settings this task can need. The specification has the rest (branch and worktree naming, `shell`, `periscope`, `sandbox`, per-machine release settings); leave those unset unless I ask for them.
|
|
162
162
|
|
|
163
163
|
| Key | Values and meaning |
|
|
164
164
|
| --- | --- |
|
package/package.json
CHANGED