@intentius/chant 0.124.62 → 0.124.64
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 +26 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +167 -18
- 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/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +2 -1
- package/dist/cli/handlers/release.d.ts +11 -7
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +93 -20
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +48 -7
- 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 +43 -0
- package/dist/cli/registry.d.ts +18 -2
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/config.d.ts +50 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- 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 +46 -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 +28 -5
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.js +6 -0
- package/dist/lifecycle/gate-seal.d.ts +59 -7
- package/dist/lifecycle/gate-seal.d.ts.map +1 -1
- package/dist/lifecycle/gate-seal.js +68 -15
- package/dist/lifecycle/gate-statement.d.ts +95 -0
- package/dist/lifecycle/gate-statement.d.ts.map +1 -0
- package/dist/lifecycle/gate-statement.js +110 -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 +120 -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 +107 -0
- package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
- package/dist/lifecycle/publish-declaration.js +110 -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 +13 -4
- package/dist/lifecycle/publish-git-ssh.d.ts +82 -0
- package/dist/lifecycle/publish-git-ssh.d.ts.map +1 -0
- package/dist/lifecycle/publish-git-ssh.js +180 -0
- 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 +77 -0
- package/dist/lifecycle/publish-homebrew.d.ts.map +1 -0
- package/dist/lifecycle/publish-homebrew.js +265 -0
- package/dist/lifecycle/publish-marketplace.d.ts +85 -0
- package/dist/lifecycle/publish-marketplace.d.ts.map +1 -0
- package/dist/lifecycle/publish-marketplace.js +398 -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 +181 -0
- package/dist/lifecycle/release-cut.d.ts +51 -5
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +165 -16
- package/dist/lifecycle/release-publish.d.ts +18 -2
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/lifecycle/release-publish.js +5 -0
- package/dist/lifecycle/release-revocation.d.ts +4 -3
- package/dist/lifecycle/release-revocation.d.ts.map +1 -1
- package/dist/lifecycle/release-revocation.js +5 -4
- package/dist/lifecycle/release-store.d.ts +32 -0
- package/dist/lifecycle/release-store.d.ts.map +1 -1
- package/dist/lifecycle/release-store.js +11 -0
- 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/gate.d.ts +1 -1
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +2 -1
- package/dist/pr-forge.d.ts +20 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +87 -8
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +333 -331
- 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 +123 -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 +204 -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 +170 -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 +2 -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 +42 -7
- package/dist/workspace/release-candidates.d.ts.map +1 -1
- package/dist/workspace/release-candidates.js +64 -23
- package/dist/workspace/release-candidates.schema.json +55 -2
- package/dist/workspace/releases.schema.json +47 -0
- 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 +328 -0
- package/src/cli/handlers/approve.ts +206 -18
- package/src/cli/handlers/plan.ts +74 -0
- package/src/cli/handlers/pr.ts +2 -1
- package/src/cli/handlers/release.ts +84 -20
- package/src/cli/main.ts +48 -7
- package/src/cli/mcp/workspace-tools.ts +2 -1
- package/src/cli/parse-args.ts +33 -0
- package/src/cli/registry.ts +18 -2
- package/src/config.ts +8 -0
- package/src/gate-decision-bundle.test.ts +4 -2
- package/src/gate-decision.ts +11 -2
- package/src/gate-statement.schema.json +46 -0
- package/src/lifecycle/__fixtures__/publish-fakes.ts +125 -5
- package/src/lifecycle/gate-ledger.ts +34 -5
- package/src/lifecycle/gate-seal.ts +86 -15
- package/src/lifecycle/gate-statement.ts +144 -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 +149 -0
- package/src/lifecycle/plan-stale.ts +172 -0
- package/src/lifecycle/publish-credentials.ts +2 -0
- package/src/lifecycle/publish-declaration.ts +116 -1
- package/src/lifecycle/publish-forge.ts +14 -4
- package/src/lifecycle/publish-git-ssh.ts +202 -0
- package/src/lifecycle/publish-github.ts +174 -0
- package/src/lifecycle/publish-homebrew.test.ts +358 -0
- package/src/lifecycle/publish-homebrew.ts +283 -0
- package/src/lifecycle/publish-marketplace.test.ts +406 -0
- package/src/lifecycle/publish-marketplace.ts +421 -0
- package/src/lifecycle/publish-resume.test.ts +40 -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 +198 -0
- package/src/lifecycle/release-cut-lane.test.ts +177 -0
- package/src/lifecycle/release-cut-override.test.ts +213 -0
- package/src/lifecycle/release-cut.ts +198 -17
- package/src/lifecycle/release-publish.ts +23 -3
- package/src/lifecycle/release-revocation.ts +5 -4
- package/src/lifecycle/release-store.ts +44 -0
- 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/op/gate.ts +2 -1
- 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 +93 -11
- package/src/pr-requires.test.ts +9 -0
- 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 +137 -6
- package/src/workspace/ci-quarantine-report.test.ts +145 -0
- package/src/workspace/ci-quarantine-report.ts +234 -0
- package/src/workspace/ci-quarantine.test.ts +160 -0
- package/src/workspace/ci-quarantine.ts +188 -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 +9 -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 +55 -2
- package/src/workspace/release-candidates.test.ts +77 -4
- package/src/workspace/release-candidates.ts +80 -23
- package/src/workspace/releases.schema.json +47 -0
- package/src/workspace/trust/gate-seal.test.ts +44 -0
- 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 });
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* latest deploy records name in `releaseDigest`, as the `releases` read
|
|
11
11
|
* (./releases.ts) says.
|
|
12
12
|
*
|
|
13
|
-
* Every green commit that is not revoked is a candidate.
|
|
13
|
+
* Every green commit that is not revoked is a candidate. With a lane (#4692),
|
|
14
|
+
* green and revoked are that lane's tags, `ci/green-<lane>/<sha>` and
|
|
15
|
+
* `ci/revoked-<lane>/<sha>`, as `release cut --lane` checks them. Its `changes` are
|
|
14
16
|
* the first-parent commits after the previous candidate up to and including
|
|
15
17
|
* it, so the candidates partition the walk. A revoked commit is listed under
|
|
16
18
|
* `skipped`, and its changes carry on into the next candidate. Commits after
|
|
@@ -29,19 +31,32 @@
|
|
|
29
31
|
* trailers name, or under no work item, and within that under its pull
|
|
30
32
|
* request, or under none for a commit that landed without one.
|
|
31
33
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
+
* Asked to (`forgeIssues`, `--forge-issues`, #4649), it also asks the forge
|
|
35
|
+
* which issues each change's pull request closes (./forge-work.ts), once per
|
|
36
|
+
* pull request, and puts the answer in the change's `closes`. A change no
|
|
37
|
+
* `Chant-Record` trailer gives a work item then lands under each issue its
|
|
38
|
+
* pull request closes. Without a forge or a token the pull request number
|
|
39
|
+
* stands alone, `resolved: false`.
|
|
40
|
+
*
|
|
41
|
+
* Otherwise it reads local refs and tags only and never fetches. Git is read
|
|
42
|
+
* through a local `git` subprocess.
|
|
34
43
|
*/
|
|
35
44
|
|
|
36
45
|
import { execFileSync } from "node:child_process";
|
|
37
46
|
import { relative, resolve, sep } from "node:path";
|
|
47
|
+
import { NEXT_RELEASE } from "../release-floors";
|
|
38
48
|
import { latestPerComponent, readReleaseLedger } from "../lifecycle/release-ledger";
|
|
39
49
|
import { readAllReleases, readCuts } from "../lifecycle/release-store";
|
|
40
50
|
import { resolveMemberLedger } from "../lifecycle/member-ledger";
|
|
41
51
|
import { readBlobFromPath } from "../lifecycle/git";
|
|
42
52
|
import { greenBranches, readerVersion } from "./declaration";
|
|
53
|
+
import type { ForgeWorkOptions, PullRequestCloses } from "./forge-work";
|
|
43
54
|
|
|
44
55
|
export const RELEASE_CANDIDATES_CONTRACT_VERSION = 1;
|
|
56
|
+
/** The first chant whose candidates carry `changes[].closes` and `groups[].issue` (#4649). */
|
|
57
|
+
export const RELEASE_CANDIDATES_CLOSES_FLOOR = "0.124.63";
|
|
58
|
+
/** The first chant whose candidates document carries `lane` and reads a lane's tags (#4692). */
|
|
59
|
+
export const RELEASE_CANDIDATES_LANE_FLOOR = NEXT_RELEASE;
|
|
45
60
|
export const RELEASE_CANDIDATES_SCHEMA_ID = "https://intentius.io/chant/schemas/workspace/release-candidates/v1/release-candidates.schema.json";
|
|
46
61
|
|
|
47
62
|
/** Why the read stopped. Closed; each code is in `reason-codes.ts`. */
|
|
@@ -79,6 +94,12 @@ export interface CandidateChange {
|
|
|
79
94
|
pr: number | null;
|
|
80
95
|
/** The merge record `_merges/<sha>.json` (#4168 4.1), as stored, or null when there is none. */
|
|
81
96
|
merge: Record<string, unknown> | null;
|
|
97
|
+
/**
|
|
98
|
+
* The issues the forge says `pr` closes (#4649), or null when the read was
|
|
99
|
+
* not asked to (`--forge-issues`) or the change has no pull request. Added
|
|
100
|
+
* within contract 1 by chant {@link RELEASE_CANDIDATES_CLOSES_FLOOR}.
|
|
101
|
+
*/
|
|
102
|
+
closes: PullRequestCloses | null;
|
|
82
103
|
}
|
|
83
104
|
|
|
84
105
|
/** A candidate's changes under one pull request, or under none (`pr: null`) for commits that landed without one. */
|
|
@@ -88,9 +109,16 @@ export interface CandidatePullRequestGroup {
|
|
|
88
109
|
commits: string[];
|
|
89
110
|
}
|
|
90
111
|
|
|
91
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* A candidate's changes under one work item: a `Chant-Record` work id
|
|
114
|
+
* (`work`), or an issue the change's pull request closes (`issue`, #4649), or
|
|
115
|
+
* under none (both null). Work ids come first, then issues, each in the order
|
|
116
|
+
* the oldest change names them.
|
|
117
|
+
*/
|
|
92
118
|
export interface CandidateGroup {
|
|
93
119
|
work: string | null;
|
|
120
|
+
/** The issue the forge says the changes' pull request closes, for changes with no work id; null otherwise. */
|
|
121
|
+
issue: number | null;
|
|
94
122
|
/** Pull requests in the order their oldest commit landed, then `pr: null`. */
|
|
95
123
|
pullRequests: CandidatePullRequestGroup[];
|
|
96
124
|
}
|
|
@@ -126,6 +154,8 @@ export type ReleaseCandidatesDocument =
|
|
|
126
154
|
chant: string;
|
|
127
155
|
member: string | null;
|
|
128
156
|
branch: string;
|
|
157
|
+
/** The green lane whose tags were read (#4692), or null for `ci/green/<sha>`. Added within contract 1 by chant {@link RELEASE_CANDIDATES_LANE_FLOOR}. */
|
|
158
|
+
lane: string | null;
|
|
129
159
|
/** The tip of the branch as this clone knows it. */
|
|
130
160
|
tip: string | null;
|
|
131
161
|
environments: CandidateEnvironment[];
|
|
@@ -147,6 +177,10 @@ export interface ReleaseCandidatesQuery {
|
|
|
147
177
|
limit?: number;
|
|
148
178
|
/** Walk this branch of `ci.green.branch` (#4325) instead of the first. */
|
|
149
179
|
branch?: string;
|
|
180
|
+
/** Read this lane's tags (#4692), one `ci.green.lanes` declares, in place of `ci/green/` and `ci/revoked/`. */
|
|
181
|
+
lane?: string;
|
|
182
|
+
/** Ask the forge which issues each pull request closes (#4649), with these options. Left out, the forge is not read. */
|
|
183
|
+
forgeIssues?: ForgeWorkOptions;
|
|
150
184
|
}
|
|
151
185
|
|
|
152
186
|
function git(top: string, args: string[]): string {
|
|
@@ -187,24 +221,34 @@ export function mergeRecordPr(merge: Record<string, unknown> | null): number | n
|
|
|
187
221
|
|
|
188
222
|
/**
|
|
189
223
|
* Group changes, given newest first, by work item, then pull request, then
|
|
190
|
-
* commit. A change with work
|
|
191
|
-
* in the
|
|
192
|
-
*
|
|
224
|
+
* commit. A change with work ids lands in each one's group; one without
|
|
225
|
+
* lands in the group of each issue its pull request closes (#4649); the rest
|
|
226
|
+
* land in the group of neither, last. Work ids come before issues. Within a
|
|
227
|
+
* group, pull requests come in the order their oldest commit landed, and
|
|
228
|
+
* commits without one last.
|
|
193
229
|
*/
|
|
194
230
|
export function groupChanges(changes: readonly CandidateChange[]): CandidateGroup[] {
|
|
195
231
|
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
|
-
|
|
232
|
+
const groups = new Map<string, { work: string | null; issue: number | null; byPr: Map<number | null, string[]> }>();
|
|
233
|
+
const add = (work: string | null, issue: number | null, pr: number | null, commit: string): void => {
|
|
234
|
+
const key = work !== null ? `work:${work}` : issue !== null ? `issue:${issue}` : "";
|
|
235
|
+
const g = groups.get(key) ?? { work, issue, byPr: new Map<number | null, string[]>() };
|
|
236
|
+
groups.set(key, g);
|
|
237
|
+
g.byPr.set(pr, [commit, ...(g.byPr.get(pr) ?? [])]);
|
|
201
238
|
};
|
|
202
|
-
for (const c of oldestFirst)
|
|
239
|
+
for (const c of oldestFirst) {
|
|
240
|
+
const issues = c.closes?.issues ?? [];
|
|
241
|
+
if (c.work.length > 0) for (const work of c.work) add(work, null, c.pr, c.commit);
|
|
242
|
+
else if (issues.length > 0) for (const issue of issues) add(null, issue, c.pr, c.commit);
|
|
243
|
+
else add(null, null, c.pr, c.commit);
|
|
244
|
+
}
|
|
203
245
|
const nullLast = <K>(keys: K[]): K[] => [...keys.filter((k) => k !== null), ...keys.filter((k) => k === null)];
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
246
|
+
const all = [...groups.values()];
|
|
247
|
+
return [...all.filter((g) => g.work !== null), ...all.filter((g) => g.issue !== null), ...all.filter((g) => g.work === null && g.issue === null)].map((g) => ({
|
|
248
|
+
work: g.work,
|
|
249
|
+
issue: g.issue,
|
|
250
|
+
pullRequests: nullLast([...g.byPr.keys()]).map((pr) => ({ pr, commits: g.byPr.get(pr)! })),
|
|
251
|
+
}));
|
|
208
252
|
}
|
|
209
253
|
|
|
210
254
|
/** Read the release candidates of the member at `query.cwd`. */
|
|
@@ -223,6 +267,13 @@ export async function releaseCandidatesDocument(query: ReleaseCandidatesQuery):
|
|
|
223
267
|
if (query.branch !== undefined && !(green && greenBranches(green).includes(query.branch))) {
|
|
224
268
|
throw new Error(`--branch ${query.branch} is not a branch ci.green judges${green ? ` (${greenBranches(green).join(", ")})` : ", and the declaration has no ci.green"}`);
|
|
225
269
|
}
|
|
270
|
+
// #4692: an unknown lane, or one with no ci.green, stops the read with the lanes declared.
|
|
271
|
+
let lane: string | null = null;
|
|
272
|
+
if (query.lane !== undefined) {
|
|
273
|
+
if (!green) throw new Error(`--lane ${query.lane} names a ci.green lane, and the declaration has no ci.green`);
|
|
274
|
+
const { laneOf } = await import("./declaration");
|
|
275
|
+
lane = laneOf(green, query.lane).name;
|
|
276
|
+
}
|
|
226
277
|
const trunk = resolveTrunk(top, query.branch ?? green?.branch ?? null);
|
|
227
278
|
const tip =
|
|
228
279
|
tryGit(top, ["rev-parse", "--verify", "--quiet", `refs/remotes/${trunk.remote}/${trunk.branch}^{commit}`]) ??
|
|
@@ -258,7 +309,7 @@ export async function releaseCandidatesDocument(query: ReleaseCandidatesQuery):
|
|
|
258
309
|
environments.push({ env, running });
|
|
259
310
|
}
|
|
260
311
|
|
|
261
|
-
const empty = { ...head, member: ledger.members.length > 0 ? ledger.members.join("/") : null, branch: trunk.branch, tip, environments, since: null, candidates: [], skipped: [], pending: [] };
|
|
312
|
+
const empty = { ...head, member: ledger.members.length > 0 ? ledger.members.join("/") : null, branch: trunk.branch, lane, tip, environments, since: null, candidates: [], skipped: [], pending: [] };
|
|
262
313
|
if (!tip) return empty;
|
|
263
314
|
|
|
264
315
|
// The oldest commit any environment runs bounds the walk, when every environment runs one.
|
|
@@ -277,7 +328,7 @@ export async function releaseCandidatesDocument(query: ReleaseCandidatesQuery):
|
|
|
277
328
|
// An environment's newest running commit on the line, by position (smaller is newer).
|
|
278
329
|
const newestRun = new Map(environments.map((e) => [e.env, Math.min(...runningCommits(e).map((c) => position.get(c)!), Number.POSITIVE_INFINITY)]));
|
|
279
330
|
|
|
280
|
-
const tags = await judgedCiTags(top, green);
|
|
331
|
+
const tags = await judgedCiTags(top, green, lane ?? undefined);
|
|
281
332
|
const details = commitDetails(top, walk);
|
|
282
333
|
const merges = new Map<string, Record<string, unknown>>();
|
|
283
334
|
for (const sha of walk) {
|
|
@@ -290,14 +341,20 @@ export async function releaseCandidatesDocument(query: ReleaseCandidatesQuery):
|
|
|
290
341
|
// A merge record that is not JSON is left out.
|
|
291
342
|
}
|
|
292
343
|
}
|
|
344
|
+
// The merge record names its pull request in `source` (../lifecycle/merge-record.ts).
|
|
345
|
+
const prOf = (sha: string): number | null => mergeRecordPr(merges.get(sha) ?? null) ?? prFromSubject(details.get(sha)?.subject ?? "");
|
|
346
|
+
// What each pull request closes, asked of the forge once each, when asked to (#4649).
|
|
347
|
+
let closed = new Map<number, PullRequestCloses>();
|
|
348
|
+
if (query.forgeIssues) {
|
|
349
|
+
const { forgeWorkReader } = await import("./forge-work");
|
|
350
|
+
closed = await forgeWorkReader(top, query.forgeIssues).closesAll(walk.map(prOf).filter((n): n is number => n !== null));
|
|
351
|
+
}
|
|
293
352
|
const change = (sha: string): CandidateChange => {
|
|
294
353
|
const d = details.get(sha);
|
|
295
354
|
const { work, records } = recordTrailers(d?.trailers ?? {});
|
|
296
355
|
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 };
|
|
356
|
+
const pr = prOf(sha);
|
|
357
|
+
return { commit: sha, subject: d?.subject ?? "", date: d?.date ?? "", work, records, pr, merge, closes: pr !== null ? (closed.get(pr) ?? null) : null };
|
|
301
358
|
};
|
|
302
359
|
|
|
303
360
|
const flagReader = await flagsReader(top, source.rootOnDisk);
|
|
@@ -393,6 +393,53 @@
|
|
|
393
393
|
"channel": {
|
|
394
394
|
"type": "string",
|
|
395
395
|
"description": "Added by #4168 4.3, written by chant 0.124.35 and newer. The tag release publish moves in place of latest (an npm dist-tag, an image tag), from release cut --channel. Absent for latest."
|
|
396
|
+
},
|
|
397
|
+
"lane": {
|
|
398
|
+
"type": "string",
|
|
399
|
+
"description": "Added by #4692, written by chant 0.124.64 and newer. The green lane the cut checked, from release cut --lane or release.lane in chant.config.ts: the commit carried ci/green-<lane>/<sha> and no ci/revoked-<lane>/<sha>. Absent on a cut that checked ci/green/<sha>."
|
|
400
|
+
},
|
|
401
|
+
"override": {
|
|
402
|
+
"type": "object",
|
|
403
|
+
"required": [
|
|
404
|
+
"green",
|
|
405
|
+
"tag",
|
|
406
|
+
"by",
|
|
407
|
+
"at",
|
|
408
|
+
"reason",
|
|
409
|
+
"digest",
|
|
410
|
+
"sealed"
|
|
411
|
+
],
|
|
412
|
+
"properties": {
|
|
413
|
+
"green": {
|
|
414
|
+
"const": false,
|
|
415
|
+
"description": "The commit was not green."
|
|
416
|
+
},
|
|
417
|
+
"tag": {
|
|
418
|
+
"type": "string",
|
|
419
|
+
"description": "The green tag it had none of that counts: ci/green/<sha>, or ci/green-<lane>/<sha>."
|
|
420
|
+
},
|
|
421
|
+
"by": {
|
|
422
|
+
"type": "string",
|
|
423
|
+
"description": "Who wrote the override, a person the overriders file at base lists."
|
|
424
|
+
},
|
|
425
|
+
"at": {
|
|
426
|
+
"type": "string",
|
|
427
|
+
"description": "When the override was written."
|
|
428
|
+
},
|
|
429
|
+
"reason": {
|
|
430
|
+
"type": "string",
|
|
431
|
+
"description": "Why, in the overrider's words."
|
|
432
|
+
},
|
|
433
|
+
"digest": {
|
|
434
|
+
"type": "string",
|
|
435
|
+
"description": "The override digest on _gates/policy-override.jsonl, binding the subject release-<sha12>, the commit and the rule."
|
|
436
|
+
},
|
|
437
|
+
"sealed": {
|
|
438
|
+
"type": "boolean",
|
|
439
|
+
"description": "Whether the override was sealed, as a release gate in identity.gates requires."
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
"description": "Added by #4693, written by chant 0.124.64 and newer. The commit was not green, and release cut --override-green cut it under a person's override, which it spent. Absent on a cut of a green commit."
|
|
396
443
|
}
|
|
397
444
|
}
|
|
398
445
|
},
|
|
@@ -164,6 +164,50 @@ describe("seal version 2 covers the checkpoint", () => {
|
|
|
164
164
|
});
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
+
// #4697: seal version 3 signs a relay's binding as the last line, after any
|
|
168
|
+
// checkpoint, and versions 1 and 2 sign what they did.
|
|
169
|
+
describe("seal version 3 covers the relay's binding", () => {
|
|
170
|
+
test("the payload adds a binding line last, only when the approval carries one", () => {
|
|
171
|
+
const a = approval({ relayedBy: "bot" });
|
|
172
|
+
const b = approval({ relayedBy: "bot", binding: "deploy dep_42 until 2026-11-01T12:00:00Z" });
|
|
173
|
+
expect(gateSealVersion(b)).toBe(3);
|
|
174
|
+
expect(gateSealPayload(b).toString()).toBe(`${gateSealPayload(a).toString()}\nbinding deploy dep_42 until 2026-11-01T12:00:00Z`);
|
|
175
|
+
const c = approval({ checkpointDigest: "jcs1-sha256:cp", binding: "x" });
|
|
176
|
+
expect(gateSealVersion(c)).toBe(3);
|
|
177
|
+
expect(gateSealPayload(c).toString()).toBe("migrations\nmigrations-wave-1\n\njcs1-sha256:abc\nalice\n2026-10-11T00:00:00.000Z\ncheckpoint jcs1-sha256:cp\nbinding x");
|
|
178
|
+
expect(gateSealPayload({ ...c, binding: undefined }).toString()).toBe(gateSealPayload(approval({ checkpointDigest: "jcs1-sha256:cp" })).toString());
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test("a carried approval signs the original's binding", () => {
|
|
182
|
+
const carried = approval({
|
|
183
|
+
gate: "new-name",
|
|
184
|
+
timestamp: "2026-10-12T00:00:00.000Z",
|
|
185
|
+
binding: "deploy dep_42",
|
|
186
|
+
carriedFrom: { op: "migrations", gate: "migrations-wave-1", timestamp: "2026-10-11T00:00:00.000Z", checkpointDigest: "jcs1-sha256:cp" },
|
|
187
|
+
});
|
|
188
|
+
expect(gateSealVersion(carried)).toBe(3);
|
|
189
|
+
expect(gateSealPayload(carried)).toEqual(gateSealPayload(approval({ checkpointDigest: "jcs1-sha256:cp", binding: "deploy dep_42" })));
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test.skipIf(!hasSshKeygen)("a version 3 seal verifies, and changing, removing or adding a binding stops it", () => {
|
|
193
|
+
const k = key("alice-binding", ["-t", "ed25519"]);
|
|
194
|
+
const a = approval({ binding: "deploy dep_42 until 2026-11-01T12:00:00Z" });
|
|
195
|
+
const seal = { signer: "alice", key: "SHA256:x", signature: sign(k, gateSealPayload(a)), version: 3 };
|
|
196
|
+
const policy = policyOf(`alice ${k.pub}\n`);
|
|
197
|
+
expect(both(policy, { ...a, seal })).toEqual({ ours: null, keygen: true });
|
|
198
|
+
for (const edited of [{ binding: "deploy dep_43 until 2026-11-01T12:00:00Z" }, { binding: undefined }]) {
|
|
199
|
+
const res = both(policy, { ...a, ...edited, seal });
|
|
200
|
+
expect(res.keygen).toBe(false);
|
|
201
|
+
expect(res.ours).toMatch(/does not verify for alice/);
|
|
202
|
+
}
|
|
203
|
+
// A seal made before #4697, with no binding, can't take one on afterwards.
|
|
204
|
+
const plain = approval();
|
|
205
|
+
const old = { signer: "alice", key: "SHA256:x", signature: sign(k, gateSealPayload(plain)) };
|
|
206
|
+
expect(both(policy, { ...plain, seal: old })).toEqual({ ours: null, keygen: true });
|
|
207
|
+
expect(both(policy, { ...plain, binding: "deploy dep_42", seal: old }).ours).toMatch(/does not verify for alice/);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
167
211
|
describe("the refusals that need no signature", () => {
|
|
168
212
|
const signers = (over: Partial<GateSigners> = {}): GateSigners => ({ base: "a".repeat(40), signersPath: ".chant/allowed_signers", active: true, signers: [], problems: [], ...over });
|
|
169
213
|
|
|
@@ -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) =>
|