toolroll 0.9.117 → 0.9.119
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/CHANGELOG.md +42 -0
- package/README.md +14 -14
- package/dist/agent-fence.js +54 -6
- package/dist/assignment.js +40 -29
- package/dist/browser/workspace.css +1 -1
- package/dist/browser/workspace.js +32 -31
- package/dist/builder.js +295 -237
- package/dist/central-recovery-stage.js +3 -3
- package/dist/check-failure.js +2 -2
- package/dist/check-levels.js +3 -0
- package/dist/check-report.js +58 -7
- package/dist/coding-context.js +16 -2
- package/dist/coding-provider.js +7 -3
- package/dist/coding-workspace.js +5 -5
- package/dist/contracts/console-api.js +4 -1
- package/dist/contracts/engine-api.js +1 -0
- package/dist/contracts/release-check.js +7 -4
- package/dist/contracts/release-terms.js +11 -2
- package/dist/contracts/verification-receipt.js +1 -1
- package/dist/deploy-gate.js +7 -1
- package/dist/direct-chat.js +3 -3
- package/dist/easy-start.js +8 -6
- package/dist/engine-reads.js +72 -0
- package/dist/flexible-conversation-schema.js +24 -0
- package/dist/flexible-conversation.js +162 -0
- package/dist/flexible-custody.js +3 -0
- package/dist/flexible-import.js +51 -0
- package/dist/flexible-session.js +84 -11
- package/dist/install-mode.js +1 -1
- package/dist/invoke.js +18 -6
- package/dist/local-landing.js +500 -0
- package/dist/local-owner.js +1 -0
- package/dist/operate.js +143 -22
- package/dist/passwordless.js +1 -1
- package/dist/planner.js +6 -1
- package/dist/project-delete.js +1 -0
- package/dist/project-skills.js +28 -13
- package/dist/rehearsal.js +27 -0
- package/dist/release-adapters.js +170 -2
- package/dist/release-approval.js +11 -8
- package/dist/release-card.js +7 -2
- package/dist/release-carry.js +1 -1
- package/dist/release-cli.js +115 -14
- package/dist/release-main-proof.js +49 -0
- package/dist/release-main.js +110 -0
- package/dist/release-recheck.js +10 -3
- package/dist/release.js +221 -33
- package/dist/reply-shape.js +6 -1
- package/dist/result-actions.js +7 -1
- package/dist/result-follow-ups.js +8 -4
- package/dist/scout.js +6 -2
- package/dist/serve.js +31 -14
- package/dist/server/direct-chat.js +88 -3
- package/dist/server/engine-api.js +43 -5
- package/dist/server/render-results.js +3 -1
- package/dist/server/render-tasks.js +10 -1
- package/dist/server/route-table.js +9 -0
- package/dist/server/settings.js +31 -7
- package/dist/server/task-views.js +15 -0
- package/dist/server/tasks.js +63 -3
- package/dist/settings-groups-ui.js +2 -2
- package/dist/skills-manifest.js +57 -0
- package/dist/store.js +29 -4
- package/dist/surface.js +9 -1
- package/dist/tui/darwin-arm64/toolroll-tui +0 -0
- package/dist/tui/darwin-x64/toolroll-tui +0 -0
- package/dist/tui/linux-arm64/toolroll-tui +0 -0
- package/dist/tui/linux-x64/toolroll-tui +0 -0
- package/dist/verification-evidence.js +17 -6
- package/dist/workspace-ui.js +1 -1
- package/package.json +3 -2
- package/scripts/release-proof.mjs +240 -0
package/dist/release-adapters.js
CHANGED
|
@@ -9,7 +9,9 @@ import { parse as parseYaml } from "yaml";
|
|
|
9
9
|
import { sleep } from "./sleep.js";
|
|
10
10
|
import { callLabel, readOnlyCall, retryCall, retryingExec, writeWithRecheck } from "./release-net.js";
|
|
11
11
|
const sqlite = () => createRequire(import.meta.url)("node:sqlite");
|
|
12
|
-
import { PROTECTION_MINIMUM_CHECKS, PROTECTION_REPORT_ONLY_CHECKS } from "./release.js";
|
|
12
|
+
import { PROTECTION_MINIMUM_CHECKS, PROTECTION_REPORT_ONLY_CHECKS, REQUIRED_PR_CHECKS_WORKFLOW } from "./release.js";
|
|
13
|
+
import { bumpVersion, changelogHas, changelogWith, firstParentAfter, releaseBranchFor } from "./release-main.js";
|
|
14
|
+
import { recordMainReleaseProof, recordMainReleaseProofFailure } from "./release-main-proof.js";
|
|
13
15
|
import { activeUpdateWork } from "./desktop-update-gate.js";
|
|
14
16
|
import { BEFORE_SWAP, deployActionOf, stoppedWhereNothingChanged } from "./deploy-phase.js";
|
|
15
17
|
import { gateOwner } from "./release-gate.js";
|
|
@@ -135,6 +137,7 @@ export function gateStateOf(answer, accounts = []) {
|
|
|
135
137
|
result: resultRun === null || textOr(result["digest"]) === null ? null : {
|
|
136
138
|
run: resultRun, head: textOr(result["head"]), receipt: String(result["digest"]), worktree: textOr(worktree),
|
|
137
139
|
level: textOr(checks["level"]),
|
|
140
|
+
...(textOr(checks["coverage"]) === null ? {} : { coverage: textOr(checks["coverage"]) }),
|
|
138
141
|
check: textOr(checks["running"]) !== null ? "running"
|
|
139
142
|
: checks["status"] === "passed" && checks["level"] !== "full" ? "not-full" : String(checks["status"] ?? "not-run"),
|
|
140
143
|
},
|
|
@@ -458,7 +461,8 @@ export function releaseAdapters(options) {
|
|
|
458
461
|
const added = await toolroll("task", "add", input.title, "--id", input.taskId, "--repo", input.checkout, "--checks", "full");
|
|
459
462
|
if (added["ok"] !== true)
|
|
460
463
|
throw new Error(`task add: ${refused(added)}`);
|
|
461
|
-
const scoped = await toolroll("task", "scope", input.taskId, "--candidate", input.candidate, "--goal", input.goal, "--acceptance", input.acceptance, ...(input.release === undefined ? [] : ["--release", `${input.release.version}:${input.release.pr}:${input.release.branch}`, ...(input.release.noCarry ? ["--no-carry"] : [])
|
|
464
|
+
const scoped = await toolroll("task", "scope", input.taskId, "--candidate", input.candidate, "--goal", input.goal, "--acceptance", input.acceptance, ...(input.release === undefined ? [] : ["--release", `${input.release.version}:${input.release.pr}:${input.release.branch}`, ...(input.release.noCarry ? ["--no-carry"] : []),
|
|
465
|
+
...(input.release.main === undefined ? [] : ["--from-main", ...(input.release.main.full ? ["--full-check"] : [])])]));
|
|
462
466
|
if (scoped["ok"] !== true)
|
|
463
467
|
throw new Error(`task scope: ${refused(scoped)}`);
|
|
464
468
|
const digest = gateStateOf(await toolroll("task", "show", input.taskId)).scopeDigest;
|
|
@@ -620,6 +624,7 @@ export function releaseAdapters(options) {
|
|
|
620
624
|
});
|
|
621
625
|
},
|
|
622
626
|
async release(repo, tag) { return (await gh("release", "view", tag, "--repo", repo, "--json", "tagName")).code === 0; },
|
|
627
|
+
main: mainReads(reads, ciGh),
|
|
623
628
|
},
|
|
624
629
|
registry: {
|
|
625
630
|
async published(name, version) {
|
|
@@ -865,6 +870,8 @@ export function storeReleaseAdapter(open, done, now, runner, auto, nightlyReads)
|
|
|
865
870
|
async stopped(input) { withStore(store => { noteReleaseStopped(store, { ...input, now: now() }); }); },
|
|
866
871
|
async verified(input) { withStore(store => { recordVerifiedRelease(store, { ...input, now: now() }); }); },
|
|
867
872
|
},
|
|
873
|
+
async proved(input) { withStore(store => { recordMainReleaseProof(store, { ...input, now: now() }); }); },
|
|
874
|
+
async proofFailed(input) { withStore(store => { recordMainReleaseProofFailure(store, { ...input, now: now() }); }); },
|
|
868
875
|
...(auto === undefined ? {} : {
|
|
869
876
|
async recheck(taskId) {
|
|
870
877
|
return withStore(store => {
|
|
@@ -1414,3 +1421,164 @@ async function macosCasesOf(run, gh, slug, sha) {
|
|
|
1414
1421
|
rmSync(folder, { recursive: true, force: true });
|
|
1415
1422
|
}
|
|
1416
1423
|
}
|
|
1424
|
+
export function githubJson(run, gh) {
|
|
1425
|
+
return async (path) => {
|
|
1426
|
+
if (!/^repos\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_./?&=%:+-]+$/.test(path) || path.includes(".."))
|
|
1427
|
+
throw new Error(`not a GitHub read this makes: ${path.slice(0, 120)}`);
|
|
1428
|
+
const out = await run(gh, ["api", "--hostname", "github.com", "--method", "GET", path], { cwd: "/", env: ciEnv() });
|
|
1429
|
+
if (out.code !== 0)
|
|
1430
|
+
throw new Error(`GitHub answered ${(out.stderr || out.stdout).trim().split("\n").slice(-1)[0]?.slice(0, 200) || `gh exited ${out.code}`} for ${path.replace(/\?.*/, "")}`);
|
|
1431
|
+
try {
|
|
1432
|
+
return JSON.parse(out.stdout);
|
|
1433
|
+
}
|
|
1434
|
+
catch {
|
|
1435
|
+
throw new Error(`GitHub's answer for ${path.replace(/\?.*/, "")} couldn't be read`);
|
|
1436
|
+
}
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
const proofModule = () => import(new URL("../scripts/release-proof.mjs", import.meta.url).href);
|
|
1440
|
+
export const FIRST_PARENT_PAGES = 5;
|
|
1441
|
+
export function mainReads(run, gh, proof = proofModule) {
|
|
1442
|
+
const api = githubJson(run, gh);
|
|
1443
|
+
const repoOk = (repo) => /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo);
|
|
1444
|
+
return {
|
|
1445
|
+
async pull(repo, version) {
|
|
1446
|
+
if (!repoOk(repo) || !/^\d+\.\d+\.\d+$/.test(version))
|
|
1447
|
+
return { kind: "none" };
|
|
1448
|
+
const branch = releaseBranchFor(version), owner = repo.split("/")[0];
|
|
1449
|
+
const rows = await api(`repos/${repo}/pulls?state=all&head=${encodeURIComponent(`${owner}:${branch}`)}&per_page=100`);
|
|
1450
|
+
if (!Array.isArray(rows))
|
|
1451
|
+
throw new Error("GitHub's pull requests couldn't be read");
|
|
1452
|
+
const own = rows.map(object).filter(pr => object(pr["base"])["ref"] === "main" && object(object(pr["base"])["repo"])["full_name"] === repo
|
|
1453
|
+
&& object(pr["head"])["ref"] === branch && object(object(pr["head"])["repo"])["full_name"] === repo && Number.isSafeInteger(pr["number"]));
|
|
1454
|
+
const merged = own.filter(pr => typeof pr["merged_at"] === "string" && typeof pr["merge_commit_sha"] === "string" && /^[0-9a-f]{40}$/.test(pr["merge_commit_sha"]))
|
|
1455
|
+
.sort((a, b) => Date.parse(String(b["merged_at"])) - Date.parse(String(a["merged_at"])));
|
|
1456
|
+
if (merged[0] !== undefined)
|
|
1457
|
+
return { kind: "merged", pr: Number(merged[0]["number"]), sha: String(merged[0]["merge_commit_sha"]) };
|
|
1458
|
+
const open = own.find(pr => pr["state"] === "open");
|
|
1459
|
+
return open === undefined ? { kind: "none" } : { kind: "open", pr: Number(open["number"]), head: String(object(open["head"])["sha"]) };
|
|
1460
|
+
},
|
|
1461
|
+
async prove(repo, sha) {
|
|
1462
|
+
const proven = await (await proof()).proveRelease({ repo, sha, required: { ...REQUIRED_PR_CHECKS_WORKFLOW } }, api);
|
|
1463
|
+
return proven.ok ? { ok: true, sha, tree: proven.tree, pr: proven.pr, head: proven.head, branch: proven.branch } : proven;
|
|
1464
|
+
},
|
|
1465
|
+
async firstParent(repo, sha) {
|
|
1466
|
+
if (!repoOk(repo) || !/^[0-9a-f]{40}$/.test(sha))
|
|
1467
|
+
return { ok: false, why: "not a commit GitHub can be asked about" };
|
|
1468
|
+
const head = await readMainHead(run, gh, repo);
|
|
1469
|
+
const parents = new Map();
|
|
1470
|
+
for (let page = 1; page <= FIRST_PARENT_PAGES; page++) {
|
|
1471
|
+
const rows = await api(`repos/${repo}/commits?sha=${head}&per_page=100&page=${page}`);
|
|
1472
|
+
if (!Array.isArray(rows))
|
|
1473
|
+
throw new Error("GitHub's commit list couldn't be read");
|
|
1474
|
+
for (const row of rows.map(object)) {
|
|
1475
|
+
const id = row["sha"], listed = Array.isArray(row["parents"]) ? row["parents"].map(one => object(one)["sha"]) : null;
|
|
1476
|
+
if (typeof id !== "string" || listed === null || listed.some(one => typeof one !== "string"))
|
|
1477
|
+
throw new Error("GitHub's commit list couldn't be read");
|
|
1478
|
+
parents.set(id, listed);
|
|
1479
|
+
}
|
|
1480
|
+
const after = firstParentAfter(head, sha, parents);
|
|
1481
|
+
if (after !== null)
|
|
1482
|
+
return { ok: true, after };
|
|
1483
|
+
if (rows.length < 100)
|
|
1484
|
+
break;
|
|
1485
|
+
}
|
|
1486
|
+
return { ok: false, why: `${sha.slice(0, 7)} isn't on main's first-parent history from ${head.slice(0, 7)}` };
|
|
1487
|
+
},
|
|
1488
|
+
async changedSince(repo, tag, sha) {
|
|
1489
|
+
if (!repoOk(repo) || !/^v\d+\.\d+\.\d+$/.test(tag) || !/^[0-9a-f]{40}$/.test(sha))
|
|
1490
|
+
return null;
|
|
1491
|
+
try {
|
|
1492
|
+
const compared = object(await api(`repos/${repo}/compare/${tag}...${sha}?per_page=100`));
|
|
1493
|
+
const files = Array.isArray(compared["files"]) ? compared["files"].map(one => object(one)["filename"]) : null;
|
|
1494
|
+
if (files === null || files.some(one => typeof one !== "string") || files.length >= 300)
|
|
1495
|
+
return null;
|
|
1496
|
+
return files;
|
|
1497
|
+
}
|
|
1498
|
+
catch {
|
|
1499
|
+
return null;
|
|
1500
|
+
}
|
|
1501
|
+
},
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
export async function prepareRelease(run, gh, input) {
|
|
1505
|
+
const { repo, version } = input;
|
|
1506
|
+
if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo) || !/^\d+\.\d+\.\d+$/.test(version))
|
|
1507
|
+
return { ok: false, why: "not a repository and version this prepares" };
|
|
1508
|
+
const api = githubJson(run, gh);
|
|
1509
|
+
const branch = releaseBranchFor(version);
|
|
1510
|
+
const exists = await run(gh, ["api", "--hostname", "github.com", "--method", "GET", `repos/${repo}/git/ref/heads/${branch}`], { cwd: "/", env: ciEnv() });
|
|
1511
|
+
if (exists.code === 0)
|
|
1512
|
+
return { ok: false, why: `${branch} already exists on GitHub; open its pull request or delete the branch first` };
|
|
1513
|
+
const head = await readMainHead(run, gh, repo);
|
|
1514
|
+
const commit = object(await api(`repos/${repo}/git/commits/${head}`));
|
|
1515
|
+
const baseTree = object(commit["tree"])["sha"];
|
|
1516
|
+
if (typeof baseTree !== "string" || !/^[0-9a-f]{40}$/.test(baseTree))
|
|
1517
|
+
return { ok: false, why: "GitHub didn't describe main's head" };
|
|
1518
|
+
const fileAt = async (path) => {
|
|
1519
|
+
const listed = await run(gh, ["api", "--hostname", "github.com", "--method", "GET", `repos/${repo}/contents/${path}?ref=${head}`, "--jq", ".sha"], { cwd: "/", env: ciEnv() });
|
|
1520
|
+
if (listed.code !== 0)
|
|
1521
|
+
return null;
|
|
1522
|
+
const blob = object(await api(`repos/${repo}/git/blobs/${listed.stdout.trim()}`));
|
|
1523
|
+
return blob["encoding"] === "base64" && typeof blob["content"] === "string" ? Buffer.from(blob["content"].replace(/\s/g, ""), "base64").toString("utf8") : null;
|
|
1524
|
+
};
|
|
1525
|
+
const manifest = await fileAt("package.json"), lock = await fileAt("package-lock.json"), changelog = await fileAt("CHANGELOG.md") ?? "# Changelog\n";
|
|
1526
|
+
if (manifest === null || lock === null)
|
|
1527
|
+
return { ok: false, why: "main's package.json or package-lock.json can't be read" };
|
|
1528
|
+
let from;
|
|
1529
|
+
try {
|
|
1530
|
+
from = String(object(JSON.parse(manifest))["version"]);
|
|
1531
|
+
}
|
|
1532
|
+
catch {
|
|
1533
|
+
return { ok: false, why: "main's package.json can't be read" };
|
|
1534
|
+
}
|
|
1535
|
+
if (versionAfter(from, version) || from === version)
|
|
1536
|
+
return { ok: false, why: `main is already at ${from}; ${version} must be later` };
|
|
1537
|
+
const nextManifest = bumpVersion("package.json", manifest, from, version), nextLock = bumpVersion("package-lock.json", lock, from, version);
|
|
1538
|
+
if (nextManifest === null || nextLock === null)
|
|
1539
|
+
return { ok: false, why: `main's ${nextManifest === null ? "package.json" : "package-lock.json"} doesn't have the shape whose version alone can be changed` };
|
|
1540
|
+
let nextChangelog = changelog;
|
|
1541
|
+
if (!changelogHas(changelog, version)) {
|
|
1542
|
+
if (input.notes === null || input.notes.trim() === "")
|
|
1543
|
+
return { ok: false, why: `CHANGELOG.md has no "## ${version}" entry: write it in a file and pass --notes <file>` };
|
|
1544
|
+
nextChangelog = changelogWith(changelog, version, input.notes, input.date);
|
|
1545
|
+
}
|
|
1546
|
+
const post = async (path, body) => {
|
|
1547
|
+
const out = await run(gh, ["api", "--hostname", "github.com", "--method", "POST", `repos/${repo}/${path}`, "--input", "-"], { cwd: "/", env: ciEnv(), input: JSON.stringify(body) });
|
|
1548
|
+
if (out.code !== 0)
|
|
1549
|
+
throw new Error(`GitHub refused ${path}: ${(out.stderr || out.stdout).trim().split("\n").slice(-1)[0]?.slice(0, 200)}`);
|
|
1550
|
+
return object(JSON.parse(out.stdout));
|
|
1551
|
+
};
|
|
1552
|
+
try {
|
|
1553
|
+
const blobs = await Promise.all([["package.json", nextManifest], ["package-lock.json", nextLock], ["CHANGELOG.md", nextChangelog]].map(async ([path, content]) => ({ path: path, mode: "100644", type: "blob", sha: String((await post("git/blobs", { content, encoding: "utf-8" }))["sha"]) })));
|
|
1554
|
+
const tree = String((await post("git/trees", { base_tree: baseTree, tree: blobs }))["sha"]);
|
|
1555
|
+
const made = String((await post("git/commits", { message: `Release ${version}`, tree, parents: [head] }))["sha"]);
|
|
1556
|
+
if (!/^[0-9a-f]{40}$/.test(made))
|
|
1557
|
+
return { ok: false, why: "GitHub made no commit" };
|
|
1558
|
+
await post("git/refs", { ref: `refs/heads/${branch}`, sha: made });
|
|
1559
|
+
const opened = await run(gh, ["pr", "create", "--repo", repo, "--head", branch, "--base", "main", "--title", `Release ${version}`,
|
|
1560
|
+
"--body", `The version and changelog for ${version}. Once its checks pass, merge it like any pull request, then run \`toolroll release ${version}\`.`], { cwd: "/", env: ciEnv() });
|
|
1561
|
+
if (opened.code !== 0)
|
|
1562
|
+
return { ok: false, why: `${branch} was pushed, but its pull request wasn't opened: ${(opened.stderr || opened.stdout).trim().split("\n").slice(-1)[0]}` };
|
|
1563
|
+
const pr = Number(/\/pull\/(\d+)/.exec(opened.stdout)?.[1]);
|
|
1564
|
+
return Number.isSafeInteger(pr) && pr > 0 ? { ok: true, pr, branch, commit: made } : { ok: false, why: "GitHub didn't name the pull request it opened" };
|
|
1565
|
+
}
|
|
1566
|
+
catch (error) {
|
|
1567
|
+
return { ok: false, why: String(error?.message ?? error) };
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
export async function readMainVersion(run, gh, repo) {
|
|
1571
|
+
if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo))
|
|
1572
|
+
return null;
|
|
1573
|
+
const head = await readMainHead(run, gh, repo);
|
|
1574
|
+
const out = await run(gh, ["api", "--hostname", "github.com", "--method", "GET", `repos/${repo}/contents/package.json?ref=${head}`, "--jq", ".content"], { cwd: "/", env: ciEnv() });
|
|
1575
|
+
if (out.code !== 0)
|
|
1576
|
+
return null;
|
|
1577
|
+
try {
|
|
1578
|
+
const version = object(JSON.parse(Buffer.from(out.stdout.replace(/\\n|\s/g, ""), "base64").toString("utf8")))["version"];
|
|
1579
|
+
return typeof version === "string" && /^\d+\.\d+\.\d+$/.test(version) ? version : null;
|
|
1580
|
+
}
|
|
1581
|
+
catch {
|
|
1582
|
+
return null;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
package/dist/release-approval.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mainJournalFile } from "./release-main.js";
|
|
1
2
|
import { createHash } from "node:crypto";
|
|
2
3
|
import { lstatSync, readdirSync, readFileSync, realpathSync } from "node:fs";
|
|
3
4
|
import { join } from "node:path";
|
|
@@ -179,7 +180,7 @@ export function releaseCardLines(card) {
|
|
|
179
180
|
const BRANCH = /^[A-Za-z0-9._/-]{1,255}$/;
|
|
180
181
|
const TASK_ID = /^[A-Za-z0-9._-]{1,200}$/;
|
|
181
182
|
const VERSION = /^\d+\.\d+\.\d+$/;
|
|
182
|
-
export function readWaitingJournal(file, raw, expectedFile) {
|
|
183
|
+
export function readWaitingJournal(file, raw, expectedFile, expectedMainFile) {
|
|
183
184
|
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
184
185
|
return null;
|
|
185
186
|
const j = raw;
|
|
@@ -197,7 +198,7 @@ export function readWaitingJournal(file, raw, expectedFile) {
|
|
|
197
198
|
return null;
|
|
198
199
|
if (candidate === null || typeof candidate !== "object" || typeof candidate["sha"] !== "string" || !SHA.test(candidate["sha"]))
|
|
199
200
|
return null;
|
|
200
|
-
if (expectedFile(j["branch"]) !== file)
|
|
201
|
+
if (j["mode"] === "main" ? expectedMainFile === undefined || expectedMainFile(j["packageVersion"]) !== file : expectedFile(j["branch"]) !== file)
|
|
201
202
|
return null;
|
|
202
203
|
return { file, branch: j["branch"], checkout: j["checkout"], taskId: task["id"], scopeDigest: task["scopeDigest"], candidate: candidate["sha"], version: j["packageVersion"], pr: j["pr"] };
|
|
203
204
|
}
|
|
@@ -226,15 +227,17 @@ export function journalMatchesPlane(store, journal, repo) {
|
|
|
226
227
|
}
|
|
227
228
|
export function waitingJournals(stateDir, expectedFile) {
|
|
228
229
|
const folder = join(stateDir, "releases");
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
names = readdirSync(folder).filter(name => name.endsWith(".json"));
|
|
230
|
+
const list = (dir, prefix) => { try {
|
|
231
|
+
return readdirSync(dir).filter(name => name.endsWith(".json")).sort().map(name => `${prefix}${name}`);
|
|
232
232
|
}
|
|
233
233
|
catch {
|
|
234
|
+
return [];
|
|
235
|
+
} };
|
|
236
|
+
const names = [...list(folder, ""), ...list(join(folder, "from-main"), "from-main/")];
|
|
237
|
+
if (names.length === 0)
|
|
234
238
|
return { journals: [], unreadable: [] };
|
|
235
|
-
}
|
|
236
239
|
const journals = [], unreadable = [];
|
|
237
|
-
for (const name of names
|
|
240
|
+
for (const name of names) {
|
|
238
241
|
const file = join(folder, name);
|
|
239
242
|
let raw;
|
|
240
243
|
try {
|
|
@@ -251,7 +254,7 @@ export function waitingJournals(stateDir, expectedFile) {
|
|
|
251
254
|
const step = raw?.step;
|
|
252
255
|
if (step !== "approval" && step !== "gate")
|
|
253
256
|
continue;
|
|
254
|
-
const read = readWaitingJournal(file, raw, expectedFile);
|
|
257
|
+
const read = readWaitingJournal(file, raw, expectedFile, version => mainJournalFile(stateDir, version));
|
|
255
258
|
if (read === null)
|
|
256
259
|
unreadable.push(name);
|
|
257
260
|
else
|
package/dist/release-card.js
CHANGED
|
@@ -65,7 +65,7 @@ export const RELEASE_TERM_LABELS = {
|
|
|
65
65
|
export const RELEASE_CHECK_LABELS = {
|
|
66
66
|
version: "Release check version", purpose: "Approved as", repo: "Repository", packageVersion: "Package version", branch: "Branch", pr: "Pull request",
|
|
67
67
|
base: "Base", approvedSha: "Approved commit", approvedTree: "Approved tree", "grant.id": "Release check grant", "grant.digest": "Release check grant digest",
|
|
68
|
-
access: "Release check access",
|
|
68
|
+
access: "Release check access", check: "Check on this Mac",
|
|
69
69
|
};
|
|
70
70
|
export function releaseSealOf(scope) {
|
|
71
71
|
if (scope === null)
|
|
@@ -134,7 +134,12 @@ export function approvalTermsOf(store, scope, words) {
|
|
|
134
134
|
if (terms === null && scope.releaseCheck != null) {
|
|
135
135
|
const purpose = scope.releaseCheck;
|
|
136
136
|
for (const path of schemaLeaves(releaseCheckPurposeSchema)) {
|
|
137
|
-
|
|
137
|
+
if (path === "check" && purpose.check === undefined)
|
|
138
|
+
continue;
|
|
139
|
+
const value = path === "pr" ? `#${purpose.pr}`
|
|
140
|
+
: path === "purpose" ? purpose.purpose === "main-release" ? "a release from main: this commit, proven again before the deploy and the tag" : "a release check: every later commit asks again"
|
|
141
|
+
: path === "check" ? purpose.check === "deploy" ? "the deploy check: build, upgrade a copy of your database, start against it (about 4 minutes)" : "the full release check (about 40 minutes)"
|
|
142
|
+
: path === "repo" ? where(purpose.repo) : said(valueAt(purpose, path));
|
|
138
143
|
lines.push({ key: `releaseCheck.${path}`, label: RELEASE_CHECK_LABELS[path] ?? path, value });
|
|
139
144
|
}
|
|
140
145
|
return lines;
|
package/dist/release-carry.js
CHANGED
|
@@ -129,7 +129,7 @@ export function releaseCheckPurposeFor(store, input) {
|
|
|
129
129
|
if (grant === null)
|
|
130
130
|
return { ok: false, why: "the project has no approved release check" };
|
|
131
131
|
return { ok: true, purpose: {
|
|
132
|
-
version: 1, purpose: "release-check", repo: input.repo, packageVersion: input.version, branch: input.branch, pr: input.pr, base: "main",
|
|
132
|
+
version: 1, ...(input.main === undefined ? { purpose: "release-check" } : { purpose: "main-release", check: input.main.check }), repo: input.repo, packageVersion: input.version, branch: input.branch, pr: input.pr, base: "main",
|
|
133
133
|
approvedSha: input.candidate, approvedTree: commit.value.tree, grant: { id: grant.id, digest: grant.digest }, access: store.projectCheckAccess(input.repo),
|
|
134
134
|
} };
|
|
135
135
|
}
|
package/dist/release-cli.js
CHANGED
|
@@ -5,11 +5,12 @@ import { createRequire } from "node:module";
|
|
|
5
5
|
const sqlite = () => createRequire(import.meta.url)("node:sqlite");
|
|
6
6
|
import { checkedEnvelopeJson } from "./contracts/cli.js";
|
|
7
7
|
import { RELEASE_LIMITS, runRelease } from "./release.js";
|
|
8
|
-
import { processes, releaseAdapters } from "./release-adapters.js";
|
|
8
|
+
import { exec, prepareRelease, processes, readMainVersion, recordedReleaseRepo, releaseAdapters, releaseTools } from "./release-adapters.js";
|
|
9
|
+
import { mainRunKey, releaseBranchFor } from "./release-main.js";
|
|
9
10
|
import { journals, releaseGate } from "./release-gate.js";
|
|
10
11
|
import { rescueDeployment } from "./deploy-rescue.js";
|
|
11
12
|
import { settleDeployment, takeReleaseRun } from "./release-next.js";
|
|
12
|
-
import { databasePath, elapsedSeconds, latestReleaseStepTask, openStore, releaseProgressFor, revokeRelease } from "./store.js";
|
|
13
|
+
import { databasePath, elapsedSeconds, latestReleaseStepTask, openStore, readSchemaVersion, releaseProgressFor, revokeRelease, SCHEMA_VERSION } from "./store.js";
|
|
13
14
|
import { dur, plural } from "./design/kit.js";
|
|
14
15
|
import { carryRefusalWords, proveCarry, setAskEveryReleaseCommit, setUnsandboxedCarry } from "./release-carry.js";
|
|
15
16
|
import { authenticateApprover, machineActing, personProof, proveCredential } from "./scope.js";
|
|
@@ -17,7 +18,25 @@ import { allowAutoPublish, setReleaseApproval } from "./release-auto.js";
|
|
|
17
18
|
import { createNightlyCheckFlow } from "./nightly-check.js";
|
|
18
19
|
import { aliasNightlyLane, optInGithubNightly, retireNightlyLane } from "./nightly-github.js";
|
|
19
20
|
import { parseSchedule } from "./flow-schedule.js";
|
|
20
|
-
export const RELEASE_HELP = `toolroll release <
|
|
21
|
+
export const RELEASE_HELP = `toolroll release [<version>] — release Toolroll from main: proves the version's release commit passed every
|
|
22
|
+
required check on its pull request, asks you, runs the deploy check on this Mac, deploys here, tags, publishes.
|
|
23
|
+
|
|
24
|
+
The release commit is main's squash merge of the release pull request from release-<version> (\`toolroll release
|
|
25
|
+
prepare\`). It is proven with publication's own proof before anything is filed, again right before the deploy and
|
|
26
|
+
again right before the tag; commits that land on main after it go in the next release. The deploy check builds it,
|
|
27
|
+
upgrades a copy of your database and starts it against that copy (about 4 minutes), after your approval: it runs
|
|
28
|
+
this commit's code with full access to this computer. With no version, main's own. Run the same command to go on
|
|
29
|
+
after any stop.
|
|
30
|
+
|
|
31
|
+
--full run the full release check on this Mac (about 40 minutes) instead of the deploy check
|
|
32
|
+
|
|
33
|
+
toolroll release prepare <version> [--notes <file>] — open the version pull request: a release-<version> branch from
|
|
34
|
+
main with only the version changed in package.json and package-lock.json, and the CHANGELOG entry (--notes, unless
|
|
35
|
+
CHANGELOG.md already has one). Merge it like any pull request once its checks pass, then run \`toolroll release
|
|
36
|
+
<version>\`.
|
|
37
|
+
|
|
38
|
+
toolroll release <branch> — the earlier way: release from a pushed branch with an open pull request (kept until the
|
|
39
|
+
releases it began are finished)
|
|
21
40
|
|
|
22
41
|
First looks at the pull request's checks: a required check that failed stops before anything is filed or sent for
|
|
23
42
|
approval, and checks not started or still running are named and waited for (stopping if they don't finish within
|
|
@@ -88,8 +107,9 @@ Options
|
|
|
88
107
|
A runner's lease is returned with \`toolroll worker release <lease>\`.`;
|
|
89
108
|
export const LEASE_SHAPED = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
90
109
|
export const LEASE_DEPRECATION = "`toolroll release <lease>` is now `toolroll worker release <lease>`; the old form goes in the next minor version.";
|
|
91
|
-
const VALUE_FLAGS = new Set(["--repo", "--limit", "--tap", "--release-gate", "--to", "--request", "--as", "--token", "--schedule", "--stage", "--lane-retire", "--branch"]);
|
|
92
|
-
const BARE_FLAGS = new Set(["--new", "--json", "--help", "--yes", "--no-carry", "--start", "--recover-deploy", "--github"]);
|
|
110
|
+
const VALUE_FLAGS = new Set(["--repo", "--limit", "--tap", "--release-gate", "--to", "--request", "--as", "--token", "--schedule", "--stage", "--lane-retire", "--branch", "--notes"]);
|
|
111
|
+
const BARE_FLAGS = new Set(["--new", "--json", "--help", "--yes", "--no-carry", "--start", "--recover-deploy", "--github", "--full"]);
|
|
112
|
+
const VERSION_ARG = /^\d+\.\d+\.\d+$/;
|
|
93
113
|
export async function runReleaseCommand(args, write, deps = {}) {
|
|
94
114
|
const bare = new Set(args.filter(one => BARE_FLAGS.has(one)));
|
|
95
115
|
const json = bare.has("--json");
|
|
@@ -102,7 +122,7 @@ export async function runReleaseCommand(args, write, deps = {}) {
|
|
|
102
122
|
let stage, laneRetire, laneAlias;
|
|
103
123
|
let branchFlag, literal = false, branchFlags = 0;
|
|
104
124
|
const literalArgs = [];
|
|
105
|
-
let repo, tap, gate, to, request, as, token, scheduleFlag;
|
|
125
|
+
let repo, tap, gate, to, request, as, token, scheduleFlag, notes;
|
|
106
126
|
for (let i = 0; i < args.length; i += 1) {
|
|
107
127
|
const raw = args[i];
|
|
108
128
|
if (raw === "--" && !literal) {
|
|
@@ -156,6 +176,8 @@ export async function runReleaseCommand(args, write, deps = {}) {
|
|
|
156
176
|
branchFlag = value;
|
|
157
177
|
branchFlags += 1;
|
|
158
178
|
}
|
|
179
|
+
else if (arg === "--notes")
|
|
180
|
+
notes = value;
|
|
159
181
|
else {
|
|
160
182
|
const match = /^([a-z]+)=([0-9]+)$/.exec(value);
|
|
161
183
|
if (match === null || !(match[1] in RELEASE_LIMITS) || Number(match[2]) < 1)
|
|
@@ -211,10 +233,23 @@ export async function runReleaseCommand(args, write, deps = {}) {
|
|
|
211
233
|
if (!named && ["carry", "revoke", "ask-every-commit", "unsandboxed-carry", "auto-approve", "publish-ok"].includes(positional[0] ?? "") && positional.length === 2) {
|
|
212
234
|
return runAuthorityCommand(positional[0], positional[1], { to, request, as, token, repo: repo === undefined ? undefined : resolve(deps.cwd ?? process.cwd(), repo) }, write, json, deps);
|
|
213
235
|
}
|
|
214
|
-
if (!named && positional
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
236
|
+
if (!named && positional[0] === "prepare") {
|
|
237
|
+
if (positional.length !== 2 || !VERSION_ARG.test(positional[1]))
|
|
238
|
+
return refuse("usage", "`toolroll release prepare <version>` takes one version (0.9.119, say).", 2);
|
|
239
|
+
return runPrepareCommand(positional[1], { repo: resolve(deps.cwd ?? process.cwd(), repo ?? "."), notes: notes === undefined ? undefined : resolve(deps.cwd ?? process.cwd(), notes) }, write, json, deps);
|
|
240
|
+
}
|
|
241
|
+
if (notes !== undefined)
|
|
242
|
+
return refuse("usage", "--notes goes with `toolroll release prepare <version>`.", 2);
|
|
243
|
+
const fromMain = !named && (positional.length === 0 || (positional.length === 1 && VERSION_ARG.test(positional[0])));
|
|
244
|
+
if (fromMain && bare.has("--no-carry"))
|
|
245
|
+
return refuse("usage", "--no-carry doesn't apply to releases from main: nothing carries, the release commit never moves.", 2);
|
|
246
|
+
if (!fromMain && bare.has("--full"))
|
|
247
|
+
return refuse("usage", "--full goes with `toolroll release <version>`.", 2);
|
|
248
|
+
if (!fromMain && !named && positional.length !== 1)
|
|
249
|
+
return refuse("usage", `Which version? \`toolroll release <version>\`.\n${RELEASE_HELP}`, 2);
|
|
250
|
+
let version = fromMain ? positional[0] : undefined;
|
|
251
|
+
const branch = fromMain ? "" : branchFlag ?? literalArgs[0] ?? positional[0];
|
|
252
|
+
if (!fromMain && !named && LEASE_SHAPED.test(branch)) {
|
|
218
253
|
const releaseOptions = args.filter(arg => VALUE_FLAGS.has(arg) || arg === "--new");
|
|
219
254
|
if (releaseOptions.length > 0)
|
|
220
255
|
return refuse("ambiguous", `${branch} looks like a lease id, but ${releaseOptions[0]} is a release option. Return a lease with \`toolroll worker release <lease>\`; a branch shaped like a lease id can't be released.`, 2);
|
|
@@ -223,10 +258,15 @@ export async function runReleaseCommand(args, write, deps = {}) {
|
|
|
223
258
|
return refuse("usage", "This build can't return leases from here: use `toolroll worker release <lease>`.", 2);
|
|
224
259
|
return deps.releaseLease(args);
|
|
225
260
|
}
|
|
226
|
-
if (!/^[A-Za-z0-9._/-]+$/.test(branch) || branch.startsWith("-") || branch.includes(".."))
|
|
261
|
+
if (!fromMain && (!/^[A-Za-z0-9._/-]+$/.test(branch) || branch.startsWith("-") || branch.includes("..")))
|
|
227
262
|
return refuse("usage", `${branch} is not a branch name this command takes.`, 2);
|
|
228
263
|
const checkout = resolve(deps.cwd ?? process.cwd(), repo ?? ".");
|
|
229
264
|
const stateDir = deps.stateDir ?? dirname(databasePath(process.env, homedir()));
|
|
265
|
+
if (fromMain && deps.adapters === undefined) {
|
|
266
|
+
const problem = liveSchemaProblem(deps.database ?? databasePath(process.env, homedir()));
|
|
267
|
+
if (problem !== null)
|
|
268
|
+
return refuse("mixed-runtime", problem, 3);
|
|
269
|
+
}
|
|
230
270
|
const lines = [];
|
|
231
271
|
const say = (line) => { if (json)
|
|
232
272
|
lines.push(line);
|
|
@@ -235,9 +275,21 @@ export async function runReleaseCommand(args, write, deps = {}) {
|
|
|
235
275
|
const adapters = deps.adapters === undefined
|
|
236
276
|
? releaseAdapters({ checkout, say, ...(tap === undefined ? {} : { tap }), ...(limits["deploy"] === undefined ? {} : { deployMinutes: limits["deploy"] }) })
|
|
237
277
|
: { ...deps.adapters, say };
|
|
238
|
-
|
|
278
|
+
if (fromMain && version === undefined) {
|
|
279
|
+
const read = deps.mainVersion ?? (async () => readMainVersion(exec, releaseTools("").gh, await adapters.repo.github()));
|
|
280
|
+
try {
|
|
281
|
+
version = await read() ?? undefined;
|
|
282
|
+
}
|
|
283
|
+
catch (error) {
|
|
284
|
+
return refuse("github", `Couldn't read main's version from GitHub: ${error.message}. Name it: \`toolroll release <version>\`.`, 3);
|
|
285
|
+
}
|
|
286
|
+
if (version === undefined)
|
|
287
|
+
return refuse("usage", "Main's package.json names no version. Name it: `toolroll release <version>`.", 2);
|
|
288
|
+
}
|
|
289
|
+
const lockKey = version === undefined ? branch : mainRunKey(version);
|
|
290
|
+
const taken = await takeReleaseRun(stateDir, lockKey, say, deps.runLock);
|
|
239
291
|
if (!taken.ok)
|
|
240
|
-
return refuse("running", `Another release of ${branch} is still running on ${taken.holder.host} (process ${taken.holder.pid}). Nothing was changed.`, 3);
|
|
292
|
+
return refuse("running", `Another release of ${version ?? branch} is still running on ${taken.holder.host} (process ${taken.holder.pid}). Nothing was changed.`, 3);
|
|
241
293
|
try {
|
|
242
294
|
const world = deps.settle ?? (deps.adapters === undefined ? { rescue: installedRescueWorld(checkout), gate: installedGateWorld() } : null);
|
|
243
295
|
if (world !== null) {
|
|
@@ -245,7 +297,8 @@ export async function runReleaseCommand(args, write, deps = {}) {
|
|
|
245
297
|
if (!settled.ok)
|
|
246
298
|
return refuse("deployment", settled.message, 3);
|
|
247
299
|
}
|
|
248
|
-
const outcome = await runRelease({ branch, checkout, stateDir, limits, fresh: bare.has("--new"), noCarry: bare.has("--no-carry")
|
|
300
|
+
const outcome = await runRelease({ branch: version === undefined ? branch : releaseBranchFor(version), checkout, stateDir, limits, fresh: bare.has("--new"), noCarry: bare.has("--no-carry"),
|
|
301
|
+
...(version === undefined ? {} : { version, full: bare.has("--full") }) }, adapters);
|
|
249
302
|
return report(outcome, write, json, lines);
|
|
250
303
|
}
|
|
251
304
|
finally {
|
|
@@ -561,3 +614,51 @@ async function runStatusCommand(task, write, json, deps) {
|
|
|
561
614
|
store.close();
|
|
562
615
|
}
|
|
563
616
|
}
|
|
617
|
+
export function liveSchemaProblem(database) {
|
|
618
|
+
if (!existsSync(database))
|
|
619
|
+
return null;
|
|
620
|
+
let version = null;
|
|
621
|
+
try {
|
|
622
|
+
const db = new (sqlite().DatabaseSync)(database, { readOnly: true });
|
|
623
|
+
try {
|
|
624
|
+
const read = readSchemaVersion(db);
|
|
625
|
+
version = read.ok ? read.version : null;
|
|
626
|
+
}
|
|
627
|
+
finally {
|
|
628
|
+
db.close();
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
catch {
|
|
632
|
+
return "This computer's Toolroll database can't be read, so no release starts. Check it, then run the installed `toolroll release` again.";
|
|
633
|
+
}
|
|
634
|
+
if (version === null || version === SCHEMA_VERSION)
|
|
635
|
+
return null;
|
|
636
|
+
return `This Toolroll build (database schema ${SCHEMA_VERSION}) isn't the one this computer's database belongs to (schema ${version}): coordinating a release with it would ${version < SCHEMA_VERSION ? "upgrade the live database under the running services" : "use a database written by a newer build"}. Nothing was changed. Run \`toolroll release\` with the build this database belongs to${version < SCHEMA_VERSION ? " (the installed one)" : " (the one a deploy already put in place)"}.`;
|
|
637
|
+
}
|
|
638
|
+
async function runPrepareCommand(version, flags, write, json, deps) {
|
|
639
|
+
const command = "release prepare";
|
|
640
|
+
const answer = (ok, fields, words, code) => { write(json ? checkedEnvelopeJson({ ok, command, ...fields }) : words); return code; };
|
|
641
|
+
let notes = null;
|
|
642
|
+
if (flags.notes !== undefined) {
|
|
643
|
+
try {
|
|
644
|
+
notes = readFileSync(flags.notes, "utf8");
|
|
645
|
+
}
|
|
646
|
+
catch {
|
|
647
|
+
return answer(false, { reason: "usage", message: `${flags.notes} can't be read.` }, `${flags.notes} can't be read.`, 2);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
const prepare = deps.prepare ?? (async (input) => {
|
|
651
|
+
const slug = recordedReleaseRepo(databasePath(process.env, homedir()), flags.repo).slug;
|
|
652
|
+
return { ...(await prepareRelease(exec, releaseTools("").gh, { repo: slug, version: input.version, notes: input.notes, date: new Date().toISOString().slice(0, 10) })), repo: slug };
|
|
653
|
+
});
|
|
654
|
+
let made;
|
|
655
|
+
try {
|
|
656
|
+
made = await prepare({ version, notes });
|
|
657
|
+
}
|
|
658
|
+
catch (error) {
|
|
659
|
+
return answer(false, { reason: "refused", message: error.message }, error.message, 1);
|
|
660
|
+
}
|
|
661
|
+
if (!made.ok)
|
|
662
|
+
return answer(false, { reason: "refused", message: `The release pull request for ${version} wasn't opened: ${made.why}.` }, `The release pull request for ${version} wasn't opened: ${made.why}.`, 1);
|
|
663
|
+
return answer(true, { version, pullRequest: made.pr, branch: made.branch, commit: made.commit }, `Opened pull request #${made.pr} (${made.branch}): the version and changelog for ${version}. Merge it like any pull request once its checks pass, then run \`toolroll release ${version}\`.`, 0);
|
|
664
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export const MAIN_PROOF_ACTION = "main release proved";
|
|
2
|
+
export const MAIN_PROOF_FAILED_ACTION = "main release proof failed";
|
|
3
|
+
export const MAIN_PROOF_VALID_MS = 30 * 60_000;
|
|
4
|
+
const SHA = /^[0-9a-f]{40}$/;
|
|
5
|
+
export function recordMainReleaseProof(store, input) {
|
|
6
|
+
const { proof } = input;
|
|
7
|
+
if (![proof.sha, proof.tree, proof.head].every(one => SHA.test(one)) || !Number.isSafeInteger(proof.pr) || proof.pr < 1 || !/^[A-Za-z0-9._/-]{1,100}$/.test(proof.branch))
|
|
8
|
+
throw new Error("not a release proof this plane keeps");
|
|
9
|
+
const ref = store.lookupRef(input.taskId);
|
|
10
|
+
if (ref === null)
|
|
11
|
+
throw new Error(`no task ${input.taskId}`);
|
|
12
|
+
store.recordAction({ at: input.now.toISOString(), actor: "toolroll release", repo: ref.repo, taskId: input.taskId, runId: null, action: MAIN_PROOF_ACTION, outcome: input.version,
|
|
13
|
+
source: "work", detail: JSON.stringify({ sha: proof.sha, tree: proof.tree, pr: proof.pr, head: proof.head, branch: proof.branch }) });
|
|
14
|
+
}
|
|
15
|
+
export function recordMainReleaseProofFailure(store, input) {
|
|
16
|
+
const ref = store.lookupRef(input.taskId);
|
|
17
|
+
if (ref === null)
|
|
18
|
+
throw new Error(`no task ${input.taskId}`);
|
|
19
|
+
store.recordAction({ at: input.now.toISOString(), actor: "toolroll release", repo: ref.repo, taskId: input.taskId, runId: null, action: MAIN_PROOF_FAILED_ACTION, outcome: input.version,
|
|
20
|
+
source: "work", detail: input.why });
|
|
21
|
+
}
|
|
22
|
+
export function mainReleaseProofProblem(store, taskId, scope, now) {
|
|
23
|
+
const purpose = scope?.releaseCheck ?? null;
|
|
24
|
+
if (scope === null || purpose === null || purpose.purpose !== "main-release")
|
|
25
|
+
return "only a release from main deploys on the deploy check";
|
|
26
|
+
if (scope.approvedAt === null)
|
|
27
|
+
return "the release isn't approved";
|
|
28
|
+
const row = store.handle.prepare("SELECT at, action, detail FROM action_ledger WHERE task_id = ? AND action IN (?, ?) ORDER BY id DESC LIMIT 1").get(taskId, MAIN_PROOF_ACTION, MAIN_PROOF_FAILED_ACTION);
|
|
29
|
+
if (row === undefined)
|
|
30
|
+
return "the release commit's proof isn't recorded: run `toolroll release` to prove it";
|
|
31
|
+
if (row["action"] === MAIN_PROOF_FAILED_ACTION)
|
|
32
|
+
return `the release commit's last proof failed (${String(row["detail"] ?? "no reason kept")})`;
|
|
33
|
+
const age = now.getTime() - Date.parse(String(row["at"]));
|
|
34
|
+
if (!(age >= 0 && age < MAIN_PROOF_VALID_MS))
|
|
35
|
+
return "the release commit's proof is older than 30 minutes: run `toolroll release` to prove it again";
|
|
36
|
+
let facts;
|
|
37
|
+
try {
|
|
38
|
+
facts = JSON.parse(String(row["detail"]));
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return "the release commit's proof can't be read";
|
|
42
|
+
}
|
|
43
|
+
if (Date.parse(String(row["at"])) < Date.parse(scope.approvedAt))
|
|
44
|
+
return "the release commit wasn't proven since it was approved: run `toolroll release` to prove it";
|
|
45
|
+
if (facts["sha"] !== purpose.approvedSha || facts["sha"] !== scope.candidate || facts["tree"] !== purpose.approvedTree || facts["pr"] !== purpose.pr || facts["branch"] !== purpose.branch) {
|
|
46
|
+
return "the recorded proof names another release commit than the one approved";
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|