@intentius/chant 0.124.62 → 0.124.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/handlers/approve.d.ts +18 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +142 -16
- package/dist/cli/handlers/plan.d.ts +10 -0
- package/dist/cli/handlers/plan.d.ts.map +1 -0
- package/dist/cli/handlers/plan.js +71 -0
- package/dist/cli/handlers/release.d.ts +6 -4
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +13 -7
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +34 -5
- package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
- package/dist/cli/mcp/workspace-tools.js +2 -1
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +31 -0
- package/dist/cli/registry.d.ts +13 -1
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/config.d.ts +32 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/gate-decision.d.ts +1 -1
- package/dist/gate-decision.d.ts.map +1 -1
- package/dist/gate-decision.js +4 -2
- package/dist/gate-statement.schema.json +44 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +20 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -1
- package/dist/lifecycle/__fixtures__/publish-fakes.js +119 -3
- package/dist/lifecycle/gate-ledger.d.ts +17 -3
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/gate-seal.d.ts +39 -3
- package/dist/lifecycle/gate-seal.d.ts.map +1 -1
- package/dist/lifecycle/gate-seal.js +50 -10
- package/dist/lifecycle/gate-statement.d.ts +70 -0
- package/dist/lifecycle/gate-statement.d.ts.map +1 -0
- package/dist/lifecycle/gate-statement.js +74 -0
- package/dist/lifecycle/gate-webauthn.d.ts +79 -0
- package/dist/lifecycle/gate-webauthn.d.ts.map +1 -0
- package/dist/lifecycle/gate-webauthn.js +105 -0
- package/dist/lifecycle/git.d.ts +1 -1
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +24 -19
- package/dist/lifecycle/ledger-remote.d.ts +37 -0
- package/dist/lifecycle/ledger-remote.d.ts.map +1 -0
- package/dist/lifecycle/ledger-remote.js +42 -0
- package/dist/lifecycle/plan-stale.d.ts +76 -0
- package/dist/lifecycle/plan-stale.d.ts.map +1 -0
- package/dist/lifecycle/plan-stale.js +121 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.d.ts.map +1 -1
- package/dist/lifecycle/publish-credentials.js +2 -0
- package/dist/lifecycle/publish-declaration.d.ts +87 -0
- package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
- package/dist/lifecycle/publish-declaration.js +87 -1
- package/dist/lifecycle/publish-forge.d.ts +5 -1
- package/dist/lifecycle/publish-forge.d.ts.map +1 -1
- package/dist/lifecycle/publish-forge.js +14 -4
- package/dist/lifecycle/publish-github.d.ts +69 -0
- package/dist/lifecycle/publish-github.d.ts.map +1 -0
- package/dist/lifecycle/publish-github.js +153 -0
- package/dist/lifecycle/publish-homebrew.d.ts +66 -0
- package/dist/lifecycle/publish-homebrew.d.ts.map +1 -0
- package/dist/lifecycle/publish-homebrew.js +173 -0
- package/dist/lifecycle/publish-marketplace.d.ts +51 -0
- package/dist/lifecycle/publish-marketplace.d.ts.map +1 -0
- package/dist/lifecycle/publish-marketplace.js +254 -0
- package/dist/lifecycle/publish-targets.d.ts +6 -0
- package/dist/lifecycle/publish-targets.d.ts.map +1 -1
- package/dist/lifecycle/publish-targets.js +15 -0
- package/dist/lifecycle/publish-tauri.d.ts +61 -0
- package/dist/lifecycle/publish-tauri.d.ts.map +1 -0
- package/dist/lifecycle/publish-tauri.js +182 -0
- package/dist/lifecycle/release-publish.d.ts +5 -2
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/lifecycle/snapshot-store.d.ts.map +1 -1
- package/dist/lifecycle/snapshot-store.js +17 -9
- package/dist/lifecycle/test-passkey.d.ts +25 -0
- package/dist/lifecycle/test-passkey.d.ts.map +1 -0
- package/dist/lifecycle/test-passkey.js +39 -0
- package/dist/notify.d.ts +23 -3
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +8 -2
- package/dist/notify.schema.json +12 -3
- package/dist/op/activities/activity-contracts.d.ts +4 -4
- package/dist/pr-forge.d.ts +20 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +61 -2
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +331 -330
- package/dist/workspace/ci-builds.d.ts +21 -0
- package/dist/workspace/ci-builds.d.ts.map +1 -1
- package/dist/workspace/ci-builds.js +14 -0
- package/dist/workspace/ci-green.d.ts +45 -2
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +124 -5
- package/dist/workspace/ci-quarantine-report.d.ts +80 -0
- package/dist/workspace/ci-quarantine-report.d.ts.map +1 -0
- package/dist/workspace/ci-quarantine-report.js +205 -0
- package/dist/workspace/ci-quarantine.d.ts +73 -0
- package/dist/workspace/ci-quarantine.d.ts.map +1 -0
- package/dist/workspace/ci-quarantine.js +171 -0
- package/dist/workspace/ci-serve.d.ts.map +1 -1
- package/dist/workspace/ci-serve.js +7 -4
- package/dist/workspace/class-data.d.ts +3 -1
- package/dist/workspace/class-data.d.ts.map +1 -1
- package/dist/workspace/class-data.js +4 -1
- package/dist/workspace/declaration.d.ts +45 -2
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +45 -2
- package/dist/workspace/declaration.schema.json +51 -3
- package/dist/workspace/forge-work.d.ts +76 -0
- package/dist/workspace/forge-work.d.ts.map +1 -0
- package/dist/workspace/forge-work.js +160 -0
- package/dist/workspace/identity-gate-rule.d.ts +3 -2
- package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
- package/dist/workspace/identity-gate-rule.js +5 -7
- package/dist/workspace/identity.d.ts +3 -2
- package/dist/workspace/identity.d.ts.map +1 -1
- package/dist/workspace/identity.js +6 -3
- package/dist/workspace/intent-cli.d.ts +3 -2
- package/dist/workspace/intent-cli.d.ts.map +1 -1
- package/dist/workspace/intent-cli.js +26 -5
- package/dist/workspace/intent-record.d.ts +3 -0
- package/dist/workspace/intent-record.d.ts.map +1 -1
- package/dist/workspace/intent-record.schema.json +32 -0
- package/dist/workspace/intent.d.ts +9 -0
- package/dist/workspace/intent.d.ts.map +1 -1
- package/dist/workspace/intent.js +3 -0
- package/dist/workspace/intent.schema.json +32 -0
- package/dist/workspace/kind-readers.d.ts.map +1 -1
- package/dist/workspace/kind-readers.js +2 -1
- package/dist/workspace/kinds.d.ts +6 -1
- package/dist/workspace/kinds.d.ts.map +1 -1
- package/dist/workspace/kinds.js +8 -3
- package/dist/workspace/plan-stale.schema.json +286 -0
- package/dist/workspace/release-candidates.d.ts +33 -6
- package/dist/workspace/release-candidates.d.ts.map +1 -1
- package/dist/workspace/release-candidates.js +49 -20
- package/dist/workspace/release-candidates.schema.json +48 -2
- package/dist/workspace/trust/policy.d.ts +10 -0
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +19 -1
- package/dist/workspace/trust/run-commits.d.ts.map +1 -1
- package/dist/workspace/trust/run-commits.js +2 -1
- package/dist/workspace/trust/seal.d.ts.map +1 -1
- package/dist/workspace/trust/seal.js +34 -3
- package/dist/workspace/trust/trust-files.d.ts.map +1 -1
- package/dist/workspace/trust/trust-files.js +6 -1
- package/package.json +2 -1
- package/src/cli/handlers/approve-external-signature.test.ts +226 -0
- package/src/cli/handlers/approve.ts +174 -16
- package/src/cli/handlers/plan.ts +74 -0
- package/src/cli/handlers/release.ts +12 -7
- package/src/cli/main.ts +34 -5
- package/src/cli/mcp/workspace-tools.ts +2 -1
- package/src/cli/parse-args.ts +24 -0
- package/src/cli/registry.ts +13 -1
- package/src/gate-decision-bundle.test.ts +4 -2
- package/src/gate-decision.ts +11 -2
- package/src/gate-statement.schema.json +44 -0
- package/src/lifecycle/__fixtures__/publish-fakes.ts +125 -5
- package/src/lifecycle/gate-ledger.ts +17 -3
- package/src/lifecycle/gate-seal.ts +62 -9
- package/src/lifecycle/gate-statement.ts +107 -0
- package/src/lifecycle/gate-webauthn.test.ts +77 -0
- package/src/lifecycle/gate-webauthn.ts +133 -0
- package/src/lifecycle/git.ts +23 -19
- package/src/lifecycle/ledger-remote.test.ts +183 -0
- package/src/lifecycle/ledger-remote.ts +46 -0
- package/src/lifecycle/plan-stale.test.ts +150 -0
- package/src/lifecycle/plan-stale.ts +173 -0
- package/src/lifecycle/publish-credentials.ts +2 -0
- package/src/lifecycle/publish-declaration.ts +93 -1
- package/src/lifecycle/publish-forge.ts +15 -4
- package/src/lifecycle/publish-github.ts +174 -0
- package/src/lifecycle/publish-homebrew.test.ts +179 -0
- package/src/lifecycle/publish-homebrew.ts +187 -0
- package/src/lifecycle/publish-marketplace.test.ts +254 -0
- package/src/lifecycle/publish-marketplace.ts +259 -0
- package/src/lifecycle/publish-target-context.test.ts +2 -2
- package/src/lifecycle/publish-targets.test.ts +23 -0
- package/src/lifecycle/publish-targets.ts +15 -0
- package/src/lifecycle/publish-tauri.test.ts +163 -0
- package/src/lifecycle/publish-tauri.ts +199 -0
- package/src/lifecycle/release-publish.ts +5 -3
- package/src/lifecycle/snapshot-store.ts +16 -9
- package/src/lifecycle/test-passkey.ts +55 -0
- package/src/notify-bundle.test.ts +3 -1
- package/src/notify.schema.json +12 -3
- package/src/notify.ts +20 -3
- package/src/override-gate-bundle.test.ts +2 -0
- package/src/pr-forge-bundle.test.ts +2 -2
- package/src/pr-forge.test.ts +38 -0
- package/src/pr-forge.ts +68 -5
- package/src/release-floors.ts +1 -1
- package/src/stage-hooks-bundle.test.ts +2 -0
- package/src/wave-runtime-bundle.test.ts +3 -2
- package/src/workspace/ci-builds.ts +27 -0
- package/src/workspace/ci-green-stale.test.ts +193 -0
- package/src/workspace/ci-green.ts +138 -6
- package/src/workspace/ci-quarantine-report.test.ts +146 -0
- package/src/workspace/ci-quarantine-report.ts +235 -0
- package/src/workspace/ci-quarantine.test.ts +161 -0
- package/src/workspace/ci-quarantine.ts +189 -0
- package/src/workspace/ci-serve.ts +7 -4
- package/src/workspace/class-data.ts +5 -1
- package/src/workspace/declaration.schema.json +51 -3
- package/src/workspace/declaration.test.ts +1 -0
- package/src/workspace/declaration.ts +88 -5
- package/src/workspace/forge-work.test.ts +143 -0
- package/src/workspace/forge-work.ts +195 -0
- package/src/workspace/identity-gate-rule.ts +6 -8
- package/src/workspace/identity.ts +6 -3
- package/src/workspace/intent-cli.ts +24 -5
- package/src/workspace/intent-record.schema.json +32 -0
- package/src/workspace/intent-record.ts +3 -0
- package/src/workspace/intent.schema.json +32 -0
- package/src/workspace/intent.ts +10 -0
- package/src/workspace/kind-readers.ts +2 -1
- package/src/workspace/kinds.test.ts +13 -0
- package/src/workspace/kinds.ts +12 -3
- package/src/workspace/plan-stale.schema.json +286 -0
- package/src/workspace/release-candidates.schema.json +48 -2
- package/src/workspace/release-candidates.test.ts +77 -4
- package/src/workspace/release-candidates.ts +62 -20
- package/src/workspace/trust/policy.ts +24 -1
- package/src/workspace/trust/run-commits.ts +2 -1
- package/src/workspace/trust/seal.ts +35 -3
- package/src/workspace/trust/trust-files.test.ts +5 -0
- package/src/workspace/trust/trust-files.ts +15 -1
|
@@ -15,6 +15,7 @@ import { groupChanges, mergeRecordPr, prFromSubject, recordTrailers, releaseCand
|
|
|
15
15
|
import { appendCut, makeRelease, persistRelease } from "../lifecycle/release-store";
|
|
16
16
|
import { appendReleaseRecord } from "../lifecycle/release-ledger";
|
|
17
17
|
import { writeLedgerFiles } from "../lifecycle/git";
|
|
18
|
+
import type { ForgeFetch } from "../pr-forge";
|
|
18
19
|
|
|
19
20
|
const { expectValid } = contract(candidatesSchema);
|
|
20
21
|
|
|
@@ -47,7 +48,16 @@ describe("recordTrailers and prFromSubject", () => {
|
|
|
47
48
|
});
|
|
48
49
|
|
|
49
50
|
describe("groupChanges (#4168 4.4)", () => {
|
|
50
|
-
const change = (commit: string, work: string[], pr: number | null): CandidateChange => ({
|
|
51
|
+
const change = (commit: string, work: string[], pr: number | null, issues?: number[]): CandidateChange => ({
|
|
52
|
+
commit,
|
|
53
|
+
subject: commit,
|
|
54
|
+
date: "",
|
|
55
|
+
work,
|
|
56
|
+
records: work.map((w) => `work:${w}`),
|
|
57
|
+
pr,
|
|
58
|
+
merge: null,
|
|
59
|
+
closes: issues ? { resolved: true, issues, reason: null } : null,
|
|
60
|
+
});
|
|
51
61
|
|
|
52
62
|
test("groups by work item, then pull request, then commit, with the ungrouped last", () => {
|
|
53
63
|
// Newest first, as a candidate's changes are.
|
|
@@ -60,9 +70,25 @@ describe("groupChanges (#4168 4.4)", () => {
|
|
|
60
70
|
change("a", ["w-1"], 2),
|
|
61
71
|
]);
|
|
62
72
|
expect(groups).toEqual([
|
|
63
|
-
{ work: "w-1", pullRequests: [{ pr: 2, commits: ["b", "a"] }, { pr: 4, commits: ["d"] }] },
|
|
64
|
-
{ work: "w-2", pullRequests: [{ pr: 2, commits: ["b"] }, { pr: null, commits: ["e"] }] },
|
|
65
|
-
{ work: null, pullRequests: [{ pr: 3, commits: ["c"] }, { pr: null, commits: ["f"] }] },
|
|
73
|
+
{ work: "w-1", issue: null, pullRequests: [{ pr: 2, commits: ["b", "a"] }, { pr: 4, commits: ["d"] }] },
|
|
74
|
+
{ work: "w-2", issue: null, pullRequests: [{ pr: 2, commits: ["b"] }, { pr: null, commits: ["e"] }] },
|
|
75
|
+
{ work: null, issue: null, pullRequests: [{ pr: 3, commits: ["c"] }, { pr: null, commits: ["f"] }] },
|
|
76
|
+
]);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test("a change with no work id lands under each issue its pull request closes (#4649)", () => {
|
|
80
|
+
const groups = groupChanges([
|
|
81
|
+
change("d", [], 9, []),
|
|
82
|
+
change("c", ["w-1"], 8, [70]),
|
|
83
|
+
change("b", [], 7, [71, 70]),
|
|
84
|
+
change("a", [], 6, [70]),
|
|
85
|
+
]);
|
|
86
|
+
expect(groups).toEqual([
|
|
87
|
+
// A work id wins over the issues its pull request closes.
|
|
88
|
+
{ work: "w-1", issue: null, pullRequests: [{ pr: 8, commits: ["c"] }] },
|
|
89
|
+
{ work: null, issue: 70, pullRequests: [{ pr: 6, commits: ["a"] }, { pr: 7, commits: ["b"] }] },
|
|
90
|
+
{ work: null, issue: 71, pullRequests: [{ pr: 7, commits: ["b"] }] },
|
|
91
|
+
{ work: null, issue: null, pullRequests: [{ pr: 9, commits: ["d"] }] },
|
|
66
92
|
]);
|
|
67
93
|
});
|
|
68
94
|
|
|
@@ -123,6 +149,53 @@ describe("releaseCandidatesDocument", () => {
|
|
|
123
149
|
});
|
|
124
150
|
});
|
|
125
151
|
|
|
152
|
+
test("with forgeIssues, each change carries what its pull request closes, and groups by those issues (#4649)", async () => {
|
|
153
|
+
await withTestDir(async (dir) => {
|
|
154
|
+
const [init, a, b, c, d] = repo(dir, ["a (#11)", "b (#12)\n\nChant-Record: work:w-1", "c (#11)", "d"]);
|
|
155
|
+
for (const sha of [init, d]) git(dir, "tag", `ci/green/${sha}`);
|
|
156
|
+
const asked: number[] = [];
|
|
157
|
+
const fetch: ForgeFetch = async (_url, init) => {
|
|
158
|
+
const pr = (JSON.parse(init.body!) as { variables: { pr: number } }).variables.pr;
|
|
159
|
+
asked.push(pr);
|
|
160
|
+
const nodes = (pr === 11 ? [70, 71] : [72]).map((number) => ({ number, repository: { nameWithOwner: "acme/app" } }));
|
|
161
|
+
return { ok: true, status: 200, text: async () => JSON.stringify({ data: { repository: { pullRequest: { closingIssuesReferences: { nodes } } } } }) };
|
|
162
|
+
};
|
|
163
|
+
const forgeIssues = { env: { GH_TOKEN: "t" }, remoteUrl: "https://github.com/acme/app.git", fetch };
|
|
164
|
+
const doc = await releaseCandidatesDocument({ cwd: dir, forgeIssues });
|
|
165
|
+
expectValid(doc);
|
|
166
|
+
if ("error" in doc) throw new Error(doc.error.message);
|
|
167
|
+
// One call per pull request, though #11 squashed two commits.
|
|
168
|
+
expect(asked.sort()).toEqual([11, 12]);
|
|
169
|
+
const changes = doc.candidates[0].changes;
|
|
170
|
+
expect(changes.map((x) => [x.commit, x.pr, x.closes])).toEqual([
|
|
171
|
+
[d, null, null],
|
|
172
|
+
[c, 11, { resolved: true, issues: [70, 71], reason: null }],
|
|
173
|
+
[b, 12, { resolved: true, issues: [72], reason: null }],
|
|
174
|
+
[a, 11, { resolved: true, issues: [70, 71], reason: null }],
|
|
175
|
+
]);
|
|
176
|
+
expect(doc.candidates[0].groups).toEqual([
|
|
177
|
+
{ work: "w-1", issue: null, pullRequests: [{ pr: 12, commits: [b] }] },
|
|
178
|
+
{ work: null, issue: 70, pullRequests: [{ pr: 11, commits: [c, a] }] },
|
|
179
|
+
{ work: null, issue: 71, pullRequests: [{ pr: 11, commits: [c, a] }] },
|
|
180
|
+
{ work: null, issue: null, pullRequests: [{ pr: null, commits: [d] }] },
|
|
181
|
+
]);
|
|
182
|
+
|
|
183
|
+
// Without a token the pull request stands alone, unresolved, and nothing is asked.
|
|
184
|
+
asked.length = 0;
|
|
185
|
+
const offline = await releaseCandidatesDocument({ cwd: dir, forgeIssues: { ...forgeIssues, env: {}, ghToken: () => undefined } });
|
|
186
|
+
expectValid(offline);
|
|
187
|
+
if ("error" in offline) throw new Error(offline.error.message);
|
|
188
|
+
expect(asked).toEqual([]);
|
|
189
|
+
expect(offline.candidates[0].changes[1]).toMatchObject({ pr: 11, closes: { resolved: false, issues: [] } });
|
|
190
|
+
expect(offline.candidates[0].groups.map((g) => [g.work, g.issue])).toEqual([["w-1", null], [null, null]]);
|
|
191
|
+
|
|
192
|
+
// Not asked, closes is null.
|
|
193
|
+
const plain = await releaseCandidatesDocument({ cwd: dir });
|
|
194
|
+
if ("error" in plain) throw new Error(plain.error.message);
|
|
195
|
+
expect(plain.candidates[0].changes.every((x) => x.closes === null)).toBe(true);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
126
199
|
test("outside git it is the failure not-a-git-repository", async () => {
|
|
127
200
|
await withTestDir(async (dir) => {
|
|
128
201
|
const doc = await releaseCandidatesDocument({ cwd: dir });
|
|
@@ -29,19 +29,30 @@
|
|
|
29
29
|
* trailers name, or under no work item, and within that under its pull
|
|
30
30
|
* request, or under none for a commit that landed without one.
|
|
31
31
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
32
|
+
* Asked to (`forgeIssues`, `--forge-issues`, #4649), it also asks the forge
|
|
33
|
+
* which issues each change's pull request closes (./forge-work.ts), once per
|
|
34
|
+
* pull request, and puts the answer in the change's `closes`. A change no
|
|
35
|
+
* `Chant-Record` trailer gives a work item then lands under each issue its
|
|
36
|
+
* pull request closes. Without a forge or a token the pull request number
|
|
37
|
+
* stands alone, `resolved: false`.
|
|
38
|
+
*
|
|
39
|
+
* Otherwise it reads local refs and tags only and never fetches. Git is read
|
|
40
|
+
* through a local `git` subprocess.
|
|
34
41
|
*/
|
|
35
42
|
|
|
36
43
|
import { execFileSync } from "node:child_process";
|
|
37
44
|
import { relative, resolve, sep } from "node:path";
|
|
45
|
+
import { NEXT_RELEASE } from "../release-floors";
|
|
38
46
|
import { latestPerComponent, readReleaseLedger } from "../lifecycle/release-ledger";
|
|
39
47
|
import { readAllReleases, readCuts } from "../lifecycle/release-store";
|
|
40
48
|
import { resolveMemberLedger } from "../lifecycle/member-ledger";
|
|
41
49
|
import { readBlobFromPath } from "../lifecycle/git";
|
|
42
50
|
import { greenBranches, readerVersion } from "./declaration";
|
|
51
|
+
import type { ForgeWorkOptions, PullRequestCloses } from "./forge-work";
|
|
43
52
|
|
|
44
53
|
export const RELEASE_CANDIDATES_CONTRACT_VERSION = 1;
|
|
54
|
+
/** The first chant whose candidates carry `changes[].closes` and `groups[].issue` (#4649). */
|
|
55
|
+
export const RELEASE_CANDIDATES_CLOSES_FLOOR = NEXT_RELEASE;
|
|
45
56
|
export const RELEASE_CANDIDATES_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/release-candidates/v1/release-candidates.schema.json";
|
|
46
57
|
|
|
47
58
|
/** Why the read stopped. Closed; each code is in `reason-codes.ts`. */
|
|
@@ -79,6 +90,12 @@ export interface CandidateChange {
|
|
|
79
90
|
pr: number | null;
|
|
80
91
|
/** The merge record `_merges/<sha>.json` (#4168 4.1), as stored, or null when there is none. */
|
|
81
92
|
merge: Record<string, unknown> | null;
|
|
93
|
+
/**
|
|
94
|
+
* The issues the forge says `pr` closes (#4649), or null when the read was
|
|
95
|
+
* not asked to (`--forge-issues`) or the change has no pull request. Added
|
|
96
|
+
* within contract 1 by chant {@link RELEASE_CANDIDATES_CLOSES_FLOOR}.
|
|
97
|
+
*/
|
|
98
|
+
closes: PullRequestCloses | null;
|
|
82
99
|
}
|
|
83
100
|
|
|
84
101
|
/** A candidate's changes under one pull request, or under none (`pr: null`) for commits that landed without one. */
|
|
@@ -88,9 +105,16 @@ export interface CandidatePullRequestGroup {
|
|
|
88
105
|
commits: string[];
|
|
89
106
|
}
|
|
90
107
|
|
|
91
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* A candidate's changes under one work item: a `Chant-Record` work id
|
|
110
|
+
* (`work`), or an issue the change's pull request closes (`issue`, #4649), or
|
|
111
|
+
* under none (both null). Work ids come first, then issues, each in the order
|
|
112
|
+
* the oldest change names them.
|
|
113
|
+
*/
|
|
92
114
|
export interface CandidateGroup {
|
|
93
115
|
work: string | null;
|
|
116
|
+
/** The issue the forge says the changes' pull request closes, for changes with no work id; null otherwise. */
|
|
117
|
+
issue: number | null;
|
|
94
118
|
/** Pull requests in the order their oldest commit landed, then `pr: null`. */
|
|
95
119
|
pullRequests: CandidatePullRequestGroup[];
|
|
96
120
|
}
|
|
@@ -147,6 +171,8 @@ export interface ReleaseCandidatesQuery {
|
|
|
147
171
|
limit?: number;
|
|
148
172
|
/** Walk this branch of `ci.green.branch` (#4325) instead of the first. */
|
|
149
173
|
branch?: string;
|
|
174
|
+
/** Ask the forge which issues each pull request closes (#4649), with these options. Left out, the forge is not read. */
|
|
175
|
+
forgeIssues?: ForgeWorkOptions;
|
|
150
176
|
}
|
|
151
177
|
|
|
152
178
|
function git(top: string, args: string[]): string {
|
|
@@ -187,24 +213,34 @@ export function mergeRecordPr(merge: Record<string, unknown> | null): number | n
|
|
|
187
213
|
|
|
188
214
|
/**
|
|
189
215
|
* Group changes, given newest first, by work item, then pull request, then
|
|
190
|
-
* commit. A change with work
|
|
191
|
-
* in the
|
|
192
|
-
*
|
|
216
|
+
* commit. A change with work ids lands in each one's group; one without
|
|
217
|
+
* lands in the group of each issue its pull request closes (#4649); the rest
|
|
218
|
+
* land in the group of neither, last. Work ids come before issues. Within a
|
|
219
|
+
* group, pull requests come in the order their oldest commit landed, and
|
|
220
|
+
* commits without one last.
|
|
193
221
|
*/
|
|
194
222
|
export function groupChanges(changes: readonly CandidateChange[]): CandidateGroup[] {
|
|
195
223
|
const oldestFirst = [...changes].reverse();
|
|
196
|
-
const groups = new Map<string | null
|
|
197
|
-
const add = (work: string | null, pr: number | null, commit: string): void => {
|
|
198
|
-
const
|
|
199
|
-
groups.
|
|
200
|
-
|
|
224
|
+
const groups = new Map<string, { work: string | null; issue: number | null; byPr: Map<number | null, string[]> }>();
|
|
225
|
+
const add = (work: string | null, issue: number | null, pr: number | null, commit: string): void => {
|
|
226
|
+
const key = work !== null ? `work:${work}` : issue !== null ? `issue:${issue}` : "";
|
|
227
|
+
const g = groups.get(key) ?? { work, issue, byPr: new Map<number | null, string[]>() };
|
|
228
|
+
groups.set(key, g);
|
|
229
|
+
g.byPr.set(pr, [commit, ...(g.byPr.get(pr) ?? [])]);
|
|
201
230
|
};
|
|
202
|
-
for (const c of oldestFirst)
|
|
231
|
+
for (const c of oldestFirst) {
|
|
232
|
+
const issues = c.closes?.issues ?? [];
|
|
233
|
+
if (c.work.length > 0) for (const work of c.work) add(work, null, c.pr, c.commit);
|
|
234
|
+
else if (issues.length > 0) for (const issue of issues) add(null, issue, c.pr, c.commit);
|
|
235
|
+
else add(null, null, c.pr, c.commit);
|
|
236
|
+
}
|
|
203
237
|
const nullLast = <K>(keys: K[]): K[] => [...keys.filter((k) => k !== null), ...keys.filter((k) => k === null)];
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
238
|
+
const all = [...groups.values()];
|
|
239
|
+
return [...all.filter((g) => g.work !== null), ...all.filter((g) => g.issue !== null), ...all.filter((g) => g.work === null && g.issue === null)].map((g) => ({
|
|
240
|
+
work: g.work,
|
|
241
|
+
issue: g.issue,
|
|
242
|
+
pullRequests: nullLast([...g.byPr.keys()]).map((pr) => ({ pr, commits: g.byPr.get(pr)! })),
|
|
243
|
+
}));
|
|
208
244
|
}
|
|
209
245
|
|
|
210
246
|
/** Read the release candidates of the member at `query.cwd`. */
|
|
@@ -290,14 +326,20 @@ export async function releaseCandidatesDocument(query: ReleaseCandidatesQuery):
|
|
|
290
326
|
// A merge record that is not JSON is left out.
|
|
291
327
|
}
|
|
292
328
|
}
|
|
329
|
+
// The merge record names its pull request in `source` (../lifecycle/merge-record.ts).
|
|
330
|
+
const prOf = (sha: string): number | null => mergeRecordPr(merges.get(sha) ?? null) ?? prFromSubject(details.get(sha)?.subject ?? "");
|
|
331
|
+
// What each pull request closes, asked of the forge once each, when asked to (#4649).
|
|
332
|
+
let closed = new Map<number, PullRequestCloses>();
|
|
333
|
+
if (query.forgeIssues) {
|
|
334
|
+
const { forgeWorkReader } = await import("./forge-work");
|
|
335
|
+
closed = await forgeWorkReader(top, query.forgeIssues).closesAll(walk.map(prOf).filter((n): n is number => n !== null));
|
|
336
|
+
}
|
|
293
337
|
const change = (sha: string): CandidateChange => {
|
|
294
338
|
const d = details.get(sha);
|
|
295
339
|
const { work, records } = recordTrailers(d?.trailers ?? {});
|
|
296
340
|
const merge = merges.get(sha) ?? null;
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const subject = d?.subject ?? "";
|
|
300
|
-
return { commit: sha, subject, date: d?.date ?? "", work, records, pr: mergePr ?? prFromSubject(subject), merge };
|
|
341
|
+
const pr = prOf(sha);
|
|
342
|
+
return { commit: sha, subject: d?.subject ?? "", date: d?.date ?? "", work, records, pr, merge, closes: pr !== null ? (closed.get(pr) ?? null) : null };
|
|
301
343
|
};
|
|
302
344
|
|
|
303
345
|
const flagReader = await flagsReader(top, source.rootOnDisk);
|
|
@@ -25,6 +25,7 @@ import { posix } from "node:path";
|
|
|
25
25
|
import { z } from "zod";
|
|
26
26
|
import type { RecordSource } from "../record-source";
|
|
27
27
|
import { DEFAULT_SIGNERS_PATH, TRUST_CONFIG_PATH, parseAllowedSigners, type ExcludedSigner, type Signer } from "./trust-files";
|
|
28
|
+
import type { PasskeySigner } from "../../lifecycle/gate-webauthn";
|
|
28
29
|
|
|
29
30
|
export {
|
|
30
31
|
DEFAULT_SIGNERS_PATH,
|
|
@@ -80,6 +81,25 @@ export const trustConfigSchema = z
|
|
|
80
81
|
.strict(),
|
|
81
82
|
)
|
|
82
83
|
.optional(),
|
|
84
|
+
/**
|
|
85
|
+
* Passkeys that sign gate approvals for people (#4646): a WebAuthn
|
|
86
|
+
* credential's id, its public key as base64url DER SubjectPublicKeyInfo,
|
|
87
|
+
* the relying party id and the origins an assertion may come from. A
|
|
88
|
+
* passkey signs only a gate approval (`chant approve --signature`).
|
|
89
|
+
*/
|
|
90
|
+
passkeys: z
|
|
91
|
+
.array(
|
|
92
|
+
z
|
|
93
|
+
.object({
|
|
94
|
+
principal: z.string().min(1),
|
|
95
|
+
id: z.string().regex(/^[A-Za-z0-9_-]+$/, "a credential id, base64url with no padding"),
|
|
96
|
+
publicKey: z.string().regex(/^[A-Za-z0-9_-]+$/, "a DER SubjectPublicKeyInfo, base64url with no padding"),
|
|
97
|
+
rpId: z.string().min(1),
|
|
98
|
+
origins: z.array(z.string().min(1)).min(1),
|
|
99
|
+
})
|
|
100
|
+
.strict(),
|
|
101
|
+
)
|
|
102
|
+
.optional(),
|
|
83
103
|
/**
|
|
84
104
|
* Signers admitted for the work one return brought back (#2552, D10,
|
|
85
105
|
* ws-004). Each entry names the return by its id (the file
|
|
@@ -139,6 +159,8 @@ export interface TrustPolicy {
|
|
|
139
159
|
runners: RunnerKey[];
|
|
140
160
|
/** Runner entries that are not used, and why. */
|
|
141
161
|
excludedRunners: Array<{ principal: string; reason: string }>;
|
|
162
|
+
/** Passkeys that sign people's gate approvals (#4646). Absent on a policy built by hand: none. */
|
|
163
|
+
passkeys?: PasskeySigner[];
|
|
142
164
|
/** Signers admitted per return (#2552), keyed by return id. They verify that return's commits and seals only. */
|
|
143
165
|
admitted: Record<string, Signer[]>;
|
|
144
166
|
/**
|
|
@@ -172,7 +194,7 @@ export function policyWriters(policy: TrustPolicy): Set<string> {
|
|
|
172
194
|
|
|
173
195
|
/** A policy with nothing in it: attestation off. */
|
|
174
196
|
export function emptyPolicy(base: string | null, problems: string[] = []): TrustPolicy {
|
|
175
|
-
return { base, signersPath: DEFAULT_SIGNERS_PATH, active: false, signers: [], excluded: [], roles: {}, adopted: [], runners: [], excludedRunners: [], admitted: {}, problems };
|
|
197
|
+
return { base, signersPath: DEFAULT_SIGNERS_PATH, active: false, signers: [], excluded: [], roles: {}, adopted: [], runners: [], excludedRunners: [], passkeys: [], admitted: {}, problems };
|
|
176
198
|
}
|
|
177
199
|
|
|
178
200
|
/**
|
|
@@ -226,6 +248,7 @@ export function readTrustPolicy(source: RecordSource, base: string | null): Trus
|
|
|
226
248
|
adopted: config.adopted ?? [],
|
|
227
249
|
runners,
|
|
228
250
|
excludedRunners,
|
|
251
|
+
passkeys: config.passkeys ?? [],
|
|
229
252
|
admitted: admittedOf(config),
|
|
230
253
|
problems: [],
|
|
231
254
|
};
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { execFileSync } from "node:child_process";
|
|
14
14
|
import { AGENT_RUNS_DIR, LEDGER_BRANCH, foldRun, parseRunFile, readRunFiles, type RunView } from "../runs";
|
|
15
15
|
import { RUN_TRAILER } from "../trailers";
|
|
16
|
+
import { lifecycleRemoteOverride } from "../../lifecycle/ledger-remote";
|
|
16
17
|
import type { RunnerKey } from "./policy";
|
|
17
18
|
import { attestRun } from "./run-statement";
|
|
18
19
|
|
|
@@ -26,7 +27,7 @@ function git(repo: string, args: string[]): string | undefined {
|
|
|
26
27
|
|
|
27
28
|
/** Every run on the ledger, in every member's `_agent-runs`, and the ref and tip read. */
|
|
28
29
|
export function readLedgerRuns(repo: string): { ref: string | null; tip: string | null; runs: RunView[] } {
|
|
29
|
-
for (const ref of [`refs/heads/${LEDGER_BRANCH}`, `refs/remotes
|
|
30
|
+
for (const ref of [`refs/heads/${LEDGER_BRANCH}`, `refs/remotes/${lifecycleRemoteOverride() ?? "origin"}/${LEDGER_BRANCH}`]) {
|
|
30
31
|
const tip = git(repo, ["rev-parse", "--verify", "--quiet", `${ref}^{commit}`])?.trim();
|
|
31
32
|
if (!tip) continue;
|
|
32
33
|
const dirs = new Set<string>();
|
|
@@ -30,7 +30,7 @@ import type { SealCode } from "../records";
|
|
|
30
30
|
import { type TrustPolicy } from "./policy";
|
|
31
31
|
import type { Signer } from "./trust-files";
|
|
32
32
|
import { sshKeygen, verifySshSignature } from "./ssh-commit";
|
|
33
|
-
import { GATE_SEAL_NAMESPACE, gateSealPayload,
|
|
33
|
+
import { checkGateSignature, GATE_SEAL_NAMESPACE, gateSealPayload, sshSignatureKey, verifySshSignatureWith, WEBAUTHN_SEAL_KIND, type SealedGateApproval } from "../../lifecycle/gate-seal";
|
|
34
34
|
import { RELEASE_SEAL_NAMESPACE, releaseSealPayload } from "../identity-gate-rule";
|
|
35
35
|
|
|
36
36
|
export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealVersion, sealedFieldsOf, type SealedGateApproval } from "../../lifecycle/gate-seal";
|
|
@@ -166,6 +166,8 @@ export function checkRecordSeal(policy: TrustPolicy, r: SealedRecord): SealCheck
|
|
|
166
166
|
* when the signers file at base lists a key for the approver.
|
|
167
167
|
*/
|
|
168
168
|
export function checkGateSeal(policy: TrustPolicy, a: SealedGateApproval): SealCheck {
|
|
169
|
+
// #4646: a seal of kind webauthn is a passkey's assertion, listed in .chant/trust.json, not the signers file.
|
|
170
|
+
if (isWebAuthnSeal(a.seal)) return checkWebAuthnGateSeal(policy, a);
|
|
169
171
|
return checkSeal(policy, {
|
|
170
172
|
principal: a.resolvedBy,
|
|
171
173
|
what: `the approval of gate ${a.gate} by ${a.resolvedBy}`,
|
|
@@ -219,11 +221,41 @@ function checkSeal(policy: TrustPolicy, s: SealSubject): SealCheck {
|
|
|
219
221
|
|
|
220
222
|
/** A gate seal checked with node:crypto (#3785) against the keys `listed` for the approver in the gate namespace. */
|
|
221
223
|
function verifyGate(listed: Signer[], payload: Buffer, signature: string): { ok: true; principal: string; key: string; missing?: undefined } | { ok: false; missing?: false; reason: string } {
|
|
222
|
-
const
|
|
223
|
-
const r = verifySshSignatureWith(signature, payload, GATE_SEAL_NAMESPACE, keys);
|
|
224
|
+
const r = checkGateSignature({ signers: listed }, listed[0]!.principal, { signature }, payload);
|
|
224
225
|
return r.ok ? { ok: true, principal: listed[0]!.principal, key: r.key } : { ok: false, reason: r.reason };
|
|
225
226
|
}
|
|
226
227
|
|
|
228
|
+
const isWebAuthnSeal = (seal: unknown): boolean =>
|
|
229
|
+
typeof seal === "object" && seal !== null && !Array.isArray(seal) && (seal as { kind?: unknown }).kind === WEBAUTHN_SEAL_KIND;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* A passkey's seal on a gate approval (#4646), checked against the passkeys
|
|
233
|
+
* `.chant/trust.json` lists at base for the approver. As with an ssh seal,
|
|
234
|
+
* attestation is on only when the signers file exists at base; with none, a
|
|
235
|
+
* seal that verifies against a listed passkey is intact and unattested.
|
|
236
|
+
*/
|
|
237
|
+
function checkWebAuthnGateSeal(policy: TrustPolicy, a: SealedGateApproval): SealCheck {
|
|
238
|
+
const what = `the approval of gate ${a.gate} by ${a.resolvedBy}`;
|
|
239
|
+
const seal = a.seal as Partial<Record<string, unknown>>;
|
|
240
|
+
if (typeof seal.signer !== "string" || typeof seal.signature !== "string") {
|
|
241
|
+
return { attested: false, code: "seal-signature-invalid", message: `the seal on ${what} is malformed: it needs signer and signature` };
|
|
242
|
+
}
|
|
243
|
+
if (normalise(seal.signer) !== normalise(a.resolvedBy)) {
|
|
244
|
+
return { attested: false, code: "seal-signature-invalid", message: `the seal on ${what} is by ${seal.signer}, and its approver is ${a.resolvedBy || "empty"}` };
|
|
245
|
+
}
|
|
246
|
+
const r = checkGateSignature(policy, a.resolvedBy, seal as { signature: string }, gateSealPayload(a));
|
|
247
|
+
if (r.ok && !policy.active) {
|
|
248
|
+
return { attested: null, code: "seal-unverifiable", message: `the passkey signature is intact (${r.key}), and there is no signers file at base to turn attestation on`, key: r.key };
|
|
249
|
+
}
|
|
250
|
+
if (r.ok) return { attested: true, message: `sealed by ${a.resolvedBy} with passkey ${r.key}, which .chant/trust.json at base lists`, key: r.key };
|
|
251
|
+
if (r.unlisted) {
|
|
252
|
+
return policy.active
|
|
253
|
+
? { attested: false, code: "seal-signer-unlisted", message: `${a.resolvedBy} has no passkey in .chant/trust.json at base, so the seal can't count` }
|
|
254
|
+
: { attested: null, code: "seal-unverifiable", message: `the seal by ${a.resolvedBy} is a passkey's, and .chant/trust.json at base lists none for them` };
|
|
255
|
+
}
|
|
256
|
+
return { attested: false, code: "seal-signature-invalid", message: `the seal does not verify for ${a.resolvedBy} against .chant/trust.json at base: ${r.reason}` };
|
|
257
|
+
}
|
|
258
|
+
|
|
227
259
|
/** A seal checked with no signers file: is the signature over these bytes intact? */
|
|
228
260
|
function checkIntegrity(principal: string, payload: Buffer, signature: string, namespace: string): SealCheck {
|
|
229
261
|
if (namespace === GATE_SEAL_NAMESPACE) {
|
|
@@ -20,7 +20,12 @@ const cases: Array<[string, unknown]> = [
|
|
|
20
20
|
adopted: [{ to: commit }, { from: commit, to: "b".repeat(64), note: "import" }],
|
|
21
21
|
runners: [{ principal: "ci", class: "runner", key: ed }],
|
|
22
22
|
admitted: [{ return: "ret-0123456789ab", signers: [{ principal: "dana", key: "ssh-rsa AAAAB3Nza==" }], note: "n" }],
|
|
23
|
+
passkeys: [{ principal: "github:erin", id: "cred-1_x", publicKey: "MCowBQYDK2VwAyEA", rpId: "example.com", origins: ["https://example.com"] }],
|
|
23
24
|
}],
|
|
25
|
+
["a passkey with no origins", { schema: 1, passkeys: [{ principal: "e", id: "c", publicKey: "k", rpId: "example.com", origins: [] }] }],
|
|
26
|
+
["a passkey whose key is padded base64", { schema: 1, passkeys: [{ principal: "e", id: "c", publicKey: "k+/=", rpId: "example.com", origins: ["https://example.com"] }] }],
|
|
27
|
+
["a passkey with an extra key", { schema: 1, passkeys: [{ principal: "e", id: "c", publicKey: "k", rpId: "example.com", origins: ["https://example.com"], alg: -8 }] }],
|
|
28
|
+
["a passkey with no rpId", { schema: 1, passkeys: [{ principal: "e", id: "c", publicKey: "k", origins: ["https://example.com"] }] }],
|
|
24
29
|
["schema 2", { schema: 2 }],
|
|
25
30
|
["no schema", {}],
|
|
26
31
|
["not an object", [1]],
|
|
@@ -202,7 +202,7 @@ export function trustConfigProblems(raw: unknown): string[] {
|
|
|
202
202
|
const check = (field: string, ok: boolean, message: string) => {
|
|
203
203
|
if (!ok) problems.push(`${field}: ${message}`);
|
|
204
204
|
};
|
|
205
|
-
check("/", only(raw, ["schema", "signers", "roles", "adopted", "runners", "admitted"]), "unknown key");
|
|
205
|
+
check("/", only(raw, ["schema", "signers", "roles", "adopted", "runners", "passkeys", "admitted"]), "unknown key");
|
|
206
206
|
check("schema", raw.schema === 1, "expected 1");
|
|
207
207
|
check("signers", optional(raw.signers, isRepoPath), "a path inside the repository, with / separators and no ..");
|
|
208
208
|
check(
|
|
@@ -226,6 +226,20 @@ export function trustConfigProblems(raw: unknown): string[] {
|
|
|
226
226
|
),
|
|
227
227
|
"runner keys: a principal, a class and an ssh-ed25519 key",
|
|
228
228
|
);
|
|
229
|
+
const b64url = (v: unknown): boolean => typeof v === "string" && /^[A-Za-z0-9_-]+$/.test(v);
|
|
230
|
+
check(
|
|
231
|
+
"passkeys",
|
|
232
|
+
optional(raw.passkeys, (a) =>
|
|
233
|
+
Array.isArray(a) &&
|
|
234
|
+
a.every(
|
|
235
|
+
(e) =>
|
|
236
|
+
isObject(e) && only(e, ["principal", "id", "publicKey", "rpId", "origins"]) &&
|
|
237
|
+
nonEmpty(e.principal) && b64url(e.id) && b64url(e.publicKey) && nonEmpty(e.rpId) &&
|
|
238
|
+
Array.isArray(e.origins) && e.origins.length > 0 && e.origins.every(nonEmpty),
|
|
239
|
+
),
|
|
240
|
+
),
|
|
241
|
+
"passkeys: a principal, a credential id, a public key, an rpId and origins",
|
|
242
|
+
);
|
|
229
243
|
check(
|
|
230
244
|
"admitted",
|
|
231
245
|
optional(raw.admitted, (a) =>
|