@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
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `chant plan stale <digest> [--member <name>] [--json]` (#4648): whether
|
|
3
|
+
* anything applied to a plan's targets after the plan was recorded, and
|
|
4
|
+
* which applies. The rule is `../../lifecycle/plan-stale.ts`; the ledgers
|
|
5
|
+
* are read as `chant ledger` reads them (`./query.ts` {@link queryLedgers}),
|
|
6
|
+
* from the local `chant/lifecycle` branch. It never fetches and never writes,
|
|
7
|
+
* so a platform can call it before it asks a person to approve. Exit 0 when
|
|
8
|
+
* the plan is current, 2 when it is stale, 1 when no pending gate fact
|
|
9
|
+
* records the digest or the ledger can't be read.
|
|
10
|
+
*/
|
|
11
|
+
import { execFileSync } from "node:child_process";
|
|
12
|
+
import { resolve } from "node:path";
|
|
13
|
+
import { formatError } from "../format";
|
|
14
|
+
import type { CommandContext } from "../registry";
|
|
15
|
+
import type { PlanStaleDocument } from "../../lifecycle/plan-stale";
|
|
16
|
+
import { queryLedgers } from "./query";
|
|
17
|
+
|
|
18
|
+
const USAGE = "chant plan stale <digest> [--member <name>] [--json]";
|
|
19
|
+
|
|
20
|
+
/** The `plan-stale` document for `digest`, read from the ledgers at `cwd`: every member's, or the ones `members` names. */
|
|
21
|
+
export async function planStaleDocument(req: { cwd: string; digest: string; members?: readonly string[] }): Promise<PlanStaleDocument> {
|
|
22
|
+
const { planStaleness, planStaleHead } = await import("../../lifecycle/plan-stale");
|
|
23
|
+
const { readerVersion } = await import("../../workspace/declaration");
|
|
24
|
+
const head = planStaleHead(readerVersion());
|
|
25
|
+
try {
|
|
26
|
+
execFileSync("git", ["rev-parse", "--git-dir"], { cwd: req.cwd, stdio: "ignore" });
|
|
27
|
+
} catch {
|
|
28
|
+
return { ...head, error: { code: "not-a-git-repository", message: "plans are read from the chant/lifecycle branch, and this directory is not in a git repository" } };
|
|
29
|
+
}
|
|
30
|
+
const { loadQueryData } = await import("../../lifecycle/query");
|
|
31
|
+
try {
|
|
32
|
+
// No snapshot is read: an empty snapshot port stands in, so the snapshot files on the branch are skipped too.
|
|
33
|
+
const none = { read: async () => null, list: async () => [], trees: async () => [] };
|
|
34
|
+
const ledgers = (await queryLedgers(req.cwd, req.members)).map((l) => ({ ...l, snapshots: none }));
|
|
35
|
+
return planStaleness((await loadQueryData(ledgers)).data, req.digest, readerVersion());
|
|
36
|
+
} catch (err) {
|
|
37
|
+
return { ...head, error: { code: "ledger-unreadable", message: `reading the ledger failed: ${err instanceof Error ? err.message : String(err)}` } };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function runPlanStale(ctx: CommandContext): Promise<number> {
|
|
42
|
+
const { args } = ctx;
|
|
43
|
+
const digest = args.extraPositional;
|
|
44
|
+
if (!digest || digest.startsWith("-")) {
|
|
45
|
+
console.error(formatError({ message: "plan stale needs the plan digest a gate's pending fact records", hint: USAGE }));
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
const doc = await planStaleDocument({ cwd: resolve("."), digest, members: args.members });
|
|
49
|
+
if (args.json) {
|
|
50
|
+
console.log(JSON.stringify(doc, null, 2));
|
|
51
|
+
return "error" in doc || doc.plan === null ? 1 : doc.stale ? 2 : 0;
|
|
52
|
+
}
|
|
53
|
+
if ("error" in doc) {
|
|
54
|
+
console.error(formatError({ message: `${doc.error.code}: ${doc.error.message}`, hint: USAGE }));
|
|
55
|
+
return 1;
|
|
56
|
+
}
|
|
57
|
+
if (doc.plan === null) {
|
|
58
|
+
console.error(formatError({ message: `no pending gate fact records the plan ${digest}`, hint: "Fetch chant/lifecycle first if the run that made the plan ran elsewhere: git fetch origin chant/lifecycle:chant/lifecycle" }));
|
|
59
|
+
return 1;
|
|
60
|
+
}
|
|
61
|
+
const where = doc.plan.targets.map((t) => `${t.member ? `${t.member}/` : ""}${t.op} at ${t.gate}${t.environment ? ` in ${t.environment}` : ""}`).join(", ");
|
|
62
|
+
console.log(`Plan ${digest}, recorded ${doc.plan.recordedAt} for ${where}.`);
|
|
63
|
+
if (!doc.stale) {
|
|
64
|
+
console.log("Nothing has applied to its targets since.");
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
console.log(`Stale: ${doc.applies.length} ${doc.applies.length === 1 ? "apply" : "applies"} since.`);
|
|
68
|
+
for (const a of doc.applies) {
|
|
69
|
+
const what = a.source === "deploys" ? `deploy of ${a.component} to ${a.environment}` : `apply under ${a.op}/${a.gate} of ${a.planDigest}`;
|
|
70
|
+
const who = [a.actor ? `by ${a.actor}` : null, a.approvedBy ? `approved by ${a.approvedBy}` : null, a.runId ? `run ${a.runId}` : null].filter(Boolean).join(", ");
|
|
71
|
+
console.log(` ${a.at} ${what}${who ? ` (${who})` : ""}${a.result ? `: ${a.result}` : ""}`);
|
|
72
|
+
}
|
|
73
|
+
return 2;
|
|
74
|
+
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* release verify <label|digest> [--json]
|
|
18
18
|
* check the release's signature offline against .chant/allowed_signers
|
|
19
19
|
* at the release's commit (#4049)
|
|
20
|
-
* release candidates [--env <env>] [--json]
|
|
20
|
+
* release candidates [--env <env>] [--forge-issues] [--json]
|
|
21
21
|
* the green commits of trunk a release can be cut from, each with what it
|
|
22
22
|
* would ship, and what each environment runs (#4168 4.2)
|
|
23
23
|
* release compose <name> [--base <label|sha>] (--pr <n> | --work <id>)... [--yes] [--json]
|
|
@@ -47,7 +47,7 @@ import { parseParamFlags } from "../build-params-cli";
|
|
|
47
47
|
import type { CommandContext } from "../registry";
|
|
48
48
|
|
|
49
49
|
const USAGE =
|
|
50
|
-
"chant release cut [<label>] [--at <sha>] [--yes] [--build <command>] [--param <k=v>] [--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>] [--actor <name>] [--sign [<key file>]] [--channel <tag>] [--json] | release publish <label|digest> [--yes] [--allow-unsigned] [--require-provenance] [--json] | release verify <label|digest> [--json] | release candidates [--env <env>] [--json] | release compose <name> [--base <label|sha>] (--pr <n> | --work <id>)... [--yes] [--json] | release list [--json] | release export <label|digest> --env <env> [-o <dir>] [--json]";
|
|
50
|
+
"chant release cut [<label>] [--at <sha>] [--yes] [--build <command>] [--param <k=v>] [--params-file <file>] [--src <dir>] [-o <file>] [--lexicon <name>] [--actor <name>] [--sign [<key file>]] [--channel <tag>] [--json] | release publish <label|digest> [--yes] [--allow-unsigned] [--require-provenance] [--json] | release verify <label|digest> [--json] | release candidates [--env <env>] [--forge-issues] [--json] | release compose <name> [--base <label|sha>] (--pr <n> | --work <id>)... [--yes] [--json] | release list [--json] | release export <label|digest> --env <env> [-o <dir>] [--json]";
|
|
51
51
|
|
|
52
52
|
/** The build inputs `release cut` and `release compile` share. */
|
|
53
53
|
function compileInputs(
|
|
@@ -550,14 +550,16 @@ export async function runReleaseVerify(ctx: CommandContext): Promise<number> {
|
|
|
550
550
|
}
|
|
551
551
|
|
|
552
552
|
/**
|
|
553
|
-
* `release candidates [--env <env>] [--json]` (#4168 4.2):
|
|
554
|
-
* of trunk a release can be cut from, newest first, each
|
|
555
|
-
* ship since the previous one, and what each environment
|
|
553
|
+
* `release candidates [--env <env>] [--forge-issues] [--json]` (#4168 4.2):
|
|
554
|
+
* the green commits of trunk a release can be cut from, newest first, each
|
|
555
|
+
* with what it would ship since the previous one, and what each environment
|
|
556
|
+
* runs. `--forge-issues` (#4649) asks the forge which issues each pull
|
|
557
|
+
* request closes and groups the changes no work id names by them. `--json`
|
|
556
558
|
* prints the read contract's `release-candidates` document.
|
|
557
559
|
*/
|
|
558
560
|
export async function runReleaseCandidates(ctx: CommandContext): Promise<number> {
|
|
559
561
|
const { releaseCandidatesDocument } = await import("../../workspace/release-candidates");
|
|
560
|
-
const doc = await releaseCandidatesDocument({ cwd: resolve("."), ...(ctx.args.env ? { env: ctx.args.env } : {}), ...(ctx.args.branch ? { branch: ctx.args.branch } : {}) });
|
|
562
|
+
const doc = await releaseCandidatesDocument({ cwd: resolve("."), ...(ctx.args.env ? { env: ctx.args.env } : {}), ...(ctx.args.branch ? { branch: ctx.args.branch } : {}), ...(ctx.args.forgeIssues ? { forgeIssues: {} } : {}) });
|
|
561
563
|
if (ctx.args.json) {
|
|
562
564
|
console.log(JSON.stringify(doc, null, 2));
|
|
563
565
|
return "error" in doc ? 1 : 0;
|
|
@@ -582,7 +584,7 @@ export async function runReleaseCandidates(ctx: CommandContext): Promise<number>
|
|
|
582
584
|
// #4168 4.4: by work item, then pull request, then commit.
|
|
583
585
|
const subjectOf = new Map(c.changes.map((ch) => [ch.commit, ch.subject]));
|
|
584
586
|
for (const g of c.groups) {
|
|
585
|
-
console.log(` ${g.work !== null ? `work:${g.work}` : "no work item"}`);
|
|
587
|
+
console.log(` ${g.work !== null ? `work:${g.work}` : g.issue !== null ? `issue #${g.issue}` : "no work item"}`);
|
|
586
588
|
for (const p of g.pullRequests) {
|
|
587
589
|
console.log(` ${p.pr !== null ? `#${p.pr}` : "no pull request"}`);
|
|
588
590
|
for (const sha of p.commits) console.log(` ${sha.slice(0, 12)} ${subjectOf.get(sha) ?? ""}`);
|
|
@@ -591,6 +593,9 @@ export async function runReleaseCandidates(ctx: CommandContext): Promise<number>
|
|
|
591
593
|
for (const f of c.flags) console.log(` flag ${f.id} (${f.member} ${f.param}) changed`);
|
|
592
594
|
}
|
|
593
595
|
for (const sk of doc.skipped) console.log(`skipped ${sk.commit.slice(0, 12)} ${sk.subject} (revoked)`);
|
|
596
|
+
// --forge-issues: why a pull request's issues were not read, once per reason.
|
|
597
|
+
const unread = new Set([...doc.candidates.flatMap((c) => c.changes), ...doc.pending].map((ch) => ch.closes?.reason).filter((r): r is string => typeof r === "string"));
|
|
598
|
+
for (const r of unread) console.error(`Issues not read from the forge: ${r}`);
|
|
594
599
|
if (doc.candidates.length > 0) console.error(`Cut one: chant release cut <label> --at <sha>`);
|
|
595
600
|
return 0;
|
|
596
601
|
}
|
package/src/cli/main.ts
CHANGED
|
@@ -326,6 +326,19 @@ CI:
|
|
|
326
326
|
one starts a bisect: a ci/build/<sha> tag the tick
|
|
327
327
|
starts the phase's workflow at. Each commit judged
|
|
328
328
|
gets a _ci/<sha>.json record on chant/lifecycle.
|
|
329
|
+
ci quarantine check Fail when an entry of ci.green.quarantine is past its
|
|
330
|
+
until, or its until is more than maxDays (14) out.
|
|
331
|
+
ci quarantine filter --phase <name> --runner nextest|playwright|list [--only] [--json]
|
|
332
|
+
What the phase's runner leaves out: a nextest
|
|
333
|
+
filterset for -E, a Playwright --grep-invert pattern,
|
|
334
|
+
or one test a line. Fails as check does for the
|
|
335
|
+
phase. --only selects the quarantined tests instead,
|
|
336
|
+
for the scheduled run, and doesn't fail on expiry.
|
|
337
|
+
ci quarantine report --phase <name> --junit <file>... [--commit <sha>] [--dry-run] [--json]
|
|
338
|
+
After the scheduled run of the quarantined tests:
|
|
339
|
+
each one's outcome from the run's JUnit XML, and
|
|
340
|
+
ci.quarantine-passed through ci.green.notify for each
|
|
341
|
+
that passed. Exits 0 whatever the tests did.
|
|
329
342
|
ci run plan|apply --env <env> --base <sha> [--pr <n>] [--commit <sha>]
|
|
330
343
|
[--forge github|gitlab|forgejo] [--gate <name>] [--wave-gate <name>]
|
|
331
344
|
[--branch <name>] [--events-json] [--report-url <url>] [--image <image>]
|
|
@@ -471,11 +484,12 @@ Releases:
|
|
|
471
484
|
that exists; stops on a conflict, naming the change
|
|
472
485
|
and files, and writes nothing. A dry run unless --yes,
|
|
473
486
|
which moves the branch and pushes it.
|
|
474
|
-
release candidates [--env <env>] [--json]
|
|
487
|
+
release candidates [--env <env>] [--forge-issues] [--json]
|
|
475
488
|
The green commits of trunk a release can be cut from,
|
|
476
489
|
newest first, each with the commits, work items, pull
|
|
477
490
|
requests and flags it would ship, and what each
|
|
478
|
-
environment runs.
|
|
491
|
+
environment runs. --forge-issues asks the forge which
|
|
492
|
+
issues each pull request closes, once per pull request
|
|
479
493
|
release publish <label|digest> [--yes] [--allow-unsigned]
|
|
480
494
|
[--require-provenance] [--json]
|
|
481
495
|
Publish a cut release to the targets release.publish
|
|
@@ -516,6 +530,10 @@ Change sets:
|
|
|
516
530
|
[--member <name>] [--json] bound, stored on
|
|
517
531
|
chant/lifecycle under its digest, each
|
|
518
532
|
entry with its graph node. Read-only.
|
|
533
|
+
plan stale <digest> Whether anything applied to the plan's op or
|
|
534
|
+
[--member <name>] [--json] environment after the
|
|
535
|
+
plan was recorded, and which applies.
|
|
536
|
+
Exit 2 when stale. Read-only.
|
|
519
537
|
|
|
520
538
|
Ops:
|
|
521
539
|
run <name> Run an Op on the resolved runtime (--on; local by default)
|
|
@@ -645,6 +663,12 @@ Ops:
|
|
|
645
663
|
file at base lists for --actor. --relayed-by
|
|
646
664
|
<principal> records who carried the approval to chant
|
|
647
665
|
for --actor (a follower, a bot); --sign covers it.
|
|
666
|
+
--statement prints the bytes an approval signs, at a
|
|
667
|
+
time it fixes, and records nothing; --signature
|
|
668
|
+
<file|-> --at <time> then records a signature made
|
|
669
|
+
elsewhere over them (an ssh signature, or a passkey's
|
|
670
|
+
WebAuthn assertion checked against .chant/trust.json's
|
|
671
|
+
passkeys), which counts as --sign does (#4646)
|
|
648
672
|
--resume then starts the CI job that waits at the
|
|
649
673
|
gate again (GitHub re-run, GitLab retry, Forgejo
|
|
650
674
|
dispatch) with CHANT_FORGE_TOKEN
|
|
@@ -1112,14 +1136,16 @@ Workspace (level 1, #2524):
|
|
|
1112
1136
|
Each composite instance the members declare, with the
|
|
1113
1137
|
components whose contract can deploy it; an instance
|
|
1114
1138
|
with none lists an empty set
|
|
1115
|
-
workspace graph --intent <path[:start-end]|path#symbol|member/node|sha> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--json]
|
|
1139
|
+
workspace graph --intent <path[:start-end]|path#symbol|member/node|sha> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--forge-issues] [--json]
|
|
1116
1140
|
The intent graph over one region: the commits that
|
|
1117
1141
|
touched it, the decisions whose constrains cover it,
|
|
1118
1142
|
the artifacts they pin, and findings with closed codes.
|
|
1119
1143
|
Without --kind, every record kind the declaration names.
|
|
1120
1144
|
--follow-squash follows a squash merge to its pull
|
|
1121
|
-
request's commits, fetching a missing ref from origin
|
|
1122
|
-
|
|
1145
|
+
request's commits, fetching a missing ref from origin.
|
|
1146
|
+
--forge-issues asks the forge which issues each
|
|
1147
|
+
commit's pull request closes
|
|
1148
|
+
workspace graph --intent --record <id> [--at <rev>] [--kind <kind file>...] [--follow-squash] [--forge-issues] [--json]
|
|
1123
1149
|
One decision's intent walk over every path: and member:
|
|
1124
1150
|
entry it constrains: the commits in its window, each
|
|
1125
1151
|
own, worked, within-other or unexplained, with counts
|
|
@@ -1808,6 +1834,7 @@ export const commandRegistry: CommandDef[] = [
|
|
|
1808
1834
|
// #4098: the run index at the report URL.
|
|
1809
1835
|
// #4147: a provisioner's signed word that it started a runner for one job, signed and checked.
|
|
1810
1836
|
{ name: "ci runner-start", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/ci-runner-start")).runCiRunnerStart(ctx) },
|
|
1837
|
+
{ name: "ci quarantine", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/ci-quarantine")).runCiQuarantine(ctx) },
|
|
1811
1838
|
{ name: "ci runs", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/ci-run-index")).runCiRuns(ctx) },
|
|
1812
1839
|
{ name: "ci serve", runsNoConfig: true, handler: async (ctx) => (await import("../workspace/ci-serve")).runCiServe(ctx) },
|
|
1813
1840
|
// #4026: the release cut from a green commit (ws-104). Imported on first use.
|
|
@@ -1827,6 +1854,8 @@ export const commandRegistry: CommandDef[] = [
|
|
|
1827
1854
|
{ name: "change-set summary", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/change-set")).runChangeSetSummary(ctx) },
|
|
1828
1855
|
// #4022: the change set a gate bound, read from chant/lifecycle by its digest.
|
|
1829
1856
|
{ name: "change-set show", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/change-set")).runChangeSetShow(ctx) },
|
|
1857
|
+
// #4648: whether anything applied to a plan's targets after it was recorded. Read-only, imported on first use.
|
|
1858
|
+
{ name: "plan stale", runsNoConfig: true, handler: async (ctx) => (await import("./handlers/plan")).runPlanStale(ctx) },
|
|
1830
1859
|
{ name: "init", handler: runInit, runsNoConfig: true },
|
|
1831
1860
|
{ name: "init lexicon", handler: runInitLexicon },
|
|
1832
1861
|
{ name: "update", handler: runUpdate },
|
|
@@ -118,6 +118,7 @@ export const workspaceReadTools: ToolDefinition[] = [
|
|
|
118
118
|
},
|
|
119
119
|
intent: { type: "string", description: "The region for the intent graph: a workspace path, path:line, path:start-end, or path#symbol for a TypeScript or JavaScript declaration such as src/server.ts#createApp (--intent). The document's why answers why the region is like this." },
|
|
120
120
|
followSquash: { type: "boolean", description: "With intent: follow squash merges to their pull requests' original commits (--follow-squash, #3035), fetching a pull request ref the clone lacks from origin. Off by default, so a read never reaches the network." },
|
|
121
|
+
forgeIssues: { type: "boolean", description: "With intent: ask the forge which issues each commit's pull request closes (--forge-issues, #4649), once per pull request. Off by default." },
|
|
121
122
|
composites: { type: "boolean", description: "The composites document instead (--composites). Takes no kind or intent." },
|
|
122
123
|
at: atProp,
|
|
123
124
|
},
|
|
@@ -419,7 +420,7 @@ export function readArgv(tool: string, params: Record<string, unknown>): string[
|
|
|
419
420
|
const composites = bool(params, "composites");
|
|
420
421
|
const kindArgs = kinds(params).flatMap((k) => ["--kind", k]);
|
|
421
422
|
if (composites) return ["workspace", "graph", "--composites", ...kindArgs, ...(intent !== undefined ? ["--intent", intent] : []), ...atArgs, "--json"];
|
|
422
|
-
if (intent !== undefined) return ["workspace", "graph", "--intent", intent, ...kindArgs, ...atArgs, ...(bool(params, "followSquash") ? ["--follow-squash"] : []), "--json"];
|
|
423
|
+
if (intent !== undefined) return ["workspace", "graph", "--intent", intent, ...kindArgs, ...atArgs, ...(bool(params, "followSquash") ? ["--follow-squash"] : []), ...(bool(params, "forgeIssues") ? ["--forge-issues"] : []), "--json"];
|
|
423
424
|
return ["workspace", "graph", ...kindArgs, ...atArgs, "--json"];
|
|
424
425
|
}
|
|
425
426
|
case "workspace-changes": {
|
package/src/cli/parse-args.ts
CHANGED
|
@@ -103,6 +103,7 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
103
103
|
"--loopback",
|
|
104
104
|
"--artifacts",
|
|
105
105
|
"--push",
|
|
106
|
+
"--only",
|
|
106
107
|
]);
|
|
107
108
|
|
|
108
109
|
/**
|
|
@@ -717,6 +718,9 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
717
718
|
} else if (arg === "--follow-squash") {
|
|
718
719
|
// `chant workspace graph --intent ... --follow-squash` and `chant workspace runs --follow-squash` (#3035)
|
|
719
720
|
result.followSquash = true;
|
|
721
|
+
} else if (arg === "--forge-issues") {
|
|
722
|
+
// `chant release candidates --forge-issues` and `chant workspace graph --intent ... --forge-issues` (#4649)
|
|
723
|
+
result.forgeIssues = true;
|
|
720
724
|
} else if (arg === "--record") {
|
|
721
725
|
// `chant workspace graph --intent --record <id>`
|
|
722
726
|
result.record = args[++i];
|
|
@@ -962,6 +966,15 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
962
966
|
result.actor = args[++i];
|
|
963
967
|
} else if (arg === "--approver") {
|
|
964
968
|
result.approver = args[++i];
|
|
969
|
+
} else if (arg === "--statement") {
|
|
970
|
+
// `chant approve <op> <gate> --statement` (#4646): print the bytes an approval signs, for a signature made elsewhere.
|
|
971
|
+
result.statement = true;
|
|
972
|
+
} else if (arg === "--signature") {
|
|
973
|
+
// `chant approve <op> <gate> --signature <file|-> --at <timestamp>` (#4646): an approval signed elsewhere.
|
|
974
|
+
result.signature = args[++i];
|
|
975
|
+
if (!result.signature || (result.signature.startsWith("-") && result.signature !== "-")) {
|
|
976
|
+
throw new Error("--signature needs a file holding the signature, or - for stdin: --signature <file|->");
|
|
977
|
+
}
|
|
965
978
|
} else if (arg === "--relayed-by") {
|
|
966
979
|
// `chant approve <op> <gate> --relayed-by <principal>` and `workspace points answer <id> --relayed-by <principal>` (#3402):
|
|
967
980
|
// who carried the approval or answer to chant for the person it names.
|
|
@@ -1201,6 +1214,17 @@ export function parseArgs(args: string[]): ParsedArgs {
|
|
|
1201
1214
|
} else if (arg === "--lane") {
|
|
1202
1215
|
// `chant ci last-green --lane <name>` and `chant ci base --lane <name>` (#4662): a green lane's tags and phases.
|
|
1203
1216
|
result.lane = args[++i];
|
|
1217
|
+
} else if (arg === "--runner") {
|
|
1218
|
+
// `chant ci quarantine filter --runner nextest|playwright|list` (#4677): the runner the filter is for.
|
|
1219
|
+
result.quarantineRunner = args[++i];
|
|
1220
|
+
} else if (arg === "--junit") {
|
|
1221
|
+
// `chant ci quarantine report --junit <file>`, repeatable (#4677): the scheduled run's JUnit XML.
|
|
1222
|
+
const value = args[++i];
|
|
1223
|
+
if (!value || value.startsWith("-")) throw new Error("--junit needs the JUnit XML file the run wrote: --junit <file>");
|
|
1224
|
+
(result.quarantineJunit ??= []).push(value);
|
|
1225
|
+
} else if (arg === "--only") {
|
|
1226
|
+
// `chant ci quarantine filter --only` (#4677): select the quarantined tests, for the scheduled run.
|
|
1227
|
+
result.quarantineOnly = true;
|
|
1204
1228
|
} else if (arg === "--phase") {
|
|
1205
1229
|
// `chant ci base --phase <name>` (#4643): the ci.green phase whose base to find.
|
|
1206
1230
|
result.phase = args[++i];
|
package/src/cli/registry.ts
CHANGED
|
@@ -595,6 +595,8 @@ export interface ParsedArgs {
|
|
|
595
595
|
intent?: string;
|
|
596
596
|
/** `chant workspace graph --intent` and `chant workspace runs` (#3035): follow squash merges to their pull requests' original commits, fetching missing pull request refs. */
|
|
597
597
|
followSquash?: boolean;
|
|
598
|
+
/** `chant release candidates --forge-issues` and `chant workspace graph --intent --forge-issues` (#4649): ask the forge which issues each squash-merged pull request closes, once per pull request. */
|
|
599
|
+
forgeIssues?: boolean;
|
|
598
600
|
/** `chant workspace graph --intent --record <id>`: walk one decision record over every entry its constrains lists. */
|
|
599
601
|
record?: string;
|
|
600
602
|
/** `chant workspace patch <range> --path <p>`: only these paths, from the workspace root. Repeatable. */
|
|
@@ -701,6 +703,10 @@ export interface ParsedArgs {
|
|
|
701
703
|
* On `chant approve` and `chant run approve`, the key that seals the gate approval (#3163).
|
|
702
704
|
*/
|
|
703
705
|
sign?: string | true;
|
|
706
|
+
/** `chant approve <op> <gate> --statement` (#4646): print the statement an approval signs, and record nothing. */
|
|
707
|
+
statement?: boolean;
|
|
708
|
+
/** `chant approve <op> <gate> --signature <file|->` (#4646): a signature made elsewhere over the statement. */
|
|
709
|
+
signature?: string;
|
|
704
710
|
/**
|
|
705
711
|
* `chant approve <op> <gate> --relayed-by <principal>` and `chant workspace
|
|
706
712
|
* points answer <id> --relayed-by <principal>` (#3402): the principal that
|
|
@@ -921,8 +927,14 @@ export interface ParsedArgs {
|
|
|
921
927
|
ciWait?: boolean;
|
|
922
928
|
/** `chant ci last-green --lane <name>` and `chant ci base --lane <name>` (#4662) — a ci.green lane. */
|
|
923
929
|
lane?: string;
|
|
924
|
-
/** `chant ci base --phase <name>` (#4643) — the ci.green phase whose base to find. */
|
|
930
|
+
/** `chant ci base --phase <name>` (#4643) — the ci.green phase whose base to find. `chant ci quarantine filter --phase <name>` (#4677) — the phase whose runner takes the filter. */
|
|
925
931
|
phase?: string;
|
|
932
|
+
/** `chant ci quarantine filter --runner nextest|playwright|list` (#4677). */
|
|
933
|
+
quarantineRunner?: string;
|
|
934
|
+
/** `chant ci quarantine filter --only` (#4677) — select the quarantined tests in place of leaving them out. */
|
|
935
|
+
quarantineOnly?: boolean;
|
|
936
|
+
/** `chant ci quarantine report --junit <file>`, repeatable (#4677) — the scheduled run's JUnit XML. */
|
|
937
|
+
quarantineJunit?: string[];
|
|
926
938
|
/** `chant audit-log attribute|unrecorded --audit-log aws[:<region>]` (#4632): the cloud audit log to read. */
|
|
927
939
|
auditLog?: string;
|
|
928
940
|
/** `chant ledger`, `chant workspace records` and `chant workspace runs --where <field><op><value>` (#4363): typed filters, repeatable, all of which have to hold. */
|
|
@@ -46,6 +46,8 @@ describe("the gate-decision bundle", () => {
|
|
|
46
46
|
"packages/core/src/lifecycle/gate-applied.ts",
|
|
47
47
|
"packages/core/src/lifecycle/gate-ledger-select.ts",
|
|
48
48
|
"packages/core/src/lifecycle/gate-seal.ts",
|
|
49
|
+
// A passkey's seal (#4646), checked with node:crypto.
|
|
50
|
+
"packages/core/src/lifecycle/gate-webauthn.ts",
|
|
49
51
|
// The gated-request digest (#4551) and its sorted-key replacer.
|
|
50
52
|
"packages/core/src/lifecycle/gated-request-digest.ts",
|
|
51
53
|
"packages/core/src/lifecycle/plan-digest.ts",
|
|
@@ -68,8 +70,8 @@ describe("the gate-decision bundle", () => {
|
|
|
68
70
|
"packages/core/src/workspace/jsonc.ts",
|
|
69
71
|
"packages/core/src/workspace/trust/trust-files.ts",
|
|
70
72
|
]);
|
|
71
|
-
// About 49 KB unminified today: 7 KB of it the pinned classes read as data (#3888), 6 KB the approval rules (#4290), and the base approval checks (#4404) bring it to about 55 KB.
|
|
73
|
+
// About 49 KB unminified today: 7 KB of it the pinned classes read as data (#3888), 6 KB the approval rules (#4290), and the base approval checks (#4404) bring it to about 55 KB, and the passkey seal check (#4646) to about 63 KB.
|
|
72
74
|
const bytes = result.outputFiles.reduce((n, f) => n + f.contents.byteLength, 0);
|
|
73
|
-
expect(bytes).toBeLessThan(
|
|
75
|
+
expect(bytes).toBeLessThan(66 * 1024);
|
|
74
76
|
});
|
|
75
77
|
});
|
package/src/gate-decision.ts
CHANGED
|
@@ -54,7 +54,7 @@ import {
|
|
|
54
54
|
} from "./lifecycle/gate-ledger-select";
|
|
55
55
|
import { samePlanDigest } from "./lifecycle/plan-digest";
|
|
56
56
|
import { isApprovalSpent, type AppliedGateRecord } from "./lifecycle/gate-applied";
|
|
57
|
-
import { gateSealRefusal, type GateSigners, type SealedGateApproval } from "./lifecycle/gate-seal";
|
|
57
|
+
import { gateSealRefusal, type GateSigners, type PasskeySigner, type SealedGateApproval } from "./lifecycle/gate-seal";
|
|
58
58
|
import {
|
|
59
59
|
DEFAULT_SIGNERS_PATH,
|
|
60
60
|
TRUST_CONFIG_PATH,
|
|
@@ -87,9 +87,16 @@ export {
|
|
|
87
87
|
sealedFieldsOf,
|
|
88
88
|
sshKeyFingerprint,
|
|
89
89
|
verifySshSignatureWith,
|
|
90
|
+
checkGateSignature,
|
|
91
|
+
verifyWebAuthnAssertion,
|
|
92
|
+
webAuthnChallenge,
|
|
93
|
+
WEBAUTHN_SEAL_KIND,
|
|
94
|
+
type GateSignatureCheck,
|
|
90
95
|
type GateSigners,
|
|
96
|
+
type PasskeySigner,
|
|
91
97
|
type SealedGateApproval,
|
|
92
98
|
type SshSignatureCheck,
|
|
99
|
+
type WebAuthnAssertion,
|
|
93
100
|
} from "./lifecycle/gate-seal";
|
|
94
101
|
export {
|
|
95
102
|
DEFAULT_SIGNERS_PATH,
|
|
@@ -186,6 +193,7 @@ function trustAt(repo: string, base: string): { signers: GateSigners; roles: Rec
|
|
|
186
193
|
const configText = showAt(repo, base, TRUST_CONFIG_PATH);
|
|
187
194
|
let signersPath = DEFAULT_SIGNERS_PATH;
|
|
188
195
|
let roles: Record<string, string[]> = {};
|
|
196
|
+
let passkeys: PasskeySigner[] = [];
|
|
189
197
|
if (configText !== undefined) {
|
|
190
198
|
let raw: unknown;
|
|
191
199
|
try {
|
|
@@ -197,9 +205,10 @@ function trustAt(repo: string, base: string): { signers: GateSigners; roles: Rec
|
|
|
197
205
|
if (problems.length > 0) return off([`${TRUST_CONFIG_PATH} is invalid: ${problems.join("; ")}`]);
|
|
198
206
|
signersPath = (raw as { signers?: string }).signers ?? DEFAULT_SIGNERS_PATH;
|
|
199
207
|
roles = (raw as { roles?: Record<string, string[]> }).roles ?? {};
|
|
208
|
+
passkeys = (raw as { passkeys?: PasskeySigner[] }).passkeys ?? [];
|
|
200
209
|
}
|
|
201
210
|
const text = showAt(repo, base, signersPath);
|
|
202
|
-
return { signers: { base, signersPath, active: text !== undefined, signers: text === undefined ? [] : parseAllowedSigners(text).signers, problems: [] }, roles };
|
|
211
|
+
return { signers: { base, signersPath, active: text !== undefined, signers: text === undefined ? [] : parseAllowedSigners(text).signers, passkeys, problems: [] }, roles };
|
|
203
212
|
}
|
|
204
213
|
|
|
205
214
|
/**
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://intentius.io/chant/schemas/gate-statement/v1/gate-statement.schema.json",
|
|
4
|
+
"title": "chant-gate-statement/v1",
|
|
5
|
+
"description": "What `chant approve <op> <gate> --statement` prints (#4646): the exact bytes an approval of the gate signs, for a signature made outside chant. Sign `statement` (the bytes of `text`) with an ssh key in the `chant-gate` namespace, or with a passkey whose WebAuthn challenge is `challenge`, then record it with `chant approve <op> <gate> --actor <resolvedBy> --at <timestamp> --signature <file>`, passing the same `--relayed-by`, `--plan` and `--env`. Written by chant 0.124.63 and newer. Readers ignore fields they do not know; a field is only ever added within a version.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": [
|
|
8
|
+
"schema",
|
|
9
|
+
"chantVersion",
|
|
10
|
+
"op",
|
|
11
|
+
"gate",
|
|
12
|
+
"environment",
|
|
13
|
+
"planDigest",
|
|
14
|
+
"resolvedBy",
|
|
15
|
+
"relayedBy",
|
|
16
|
+
"timestamp",
|
|
17
|
+
"checkpointDigest",
|
|
18
|
+
"sealVersion",
|
|
19
|
+
"namespace",
|
|
20
|
+
"text",
|
|
21
|
+
"statement",
|
|
22
|
+
"digest",
|
|
23
|
+
"challenge"
|
|
24
|
+
],
|
|
25
|
+
"properties": {
|
|
26
|
+
"schema": { "const": "chant-gate-statement/v1" },
|
|
27
|
+
"chantVersion": { "type": "string", "description": "The chant that printed the statement." },
|
|
28
|
+
"op": { "type": "string", "description": "The Op, or the component or command name the gate is recorded under. The statement's first line." },
|
|
29
|
+
"gate": { "type": "string", "description": "The gate. The second line." },
|
|
30
|
+
"environment": { "type": ["string", "null"], "description": "The environment the approval answers; null signs an empty third line." },
|
|
31
|
+
"planDigest": { "type": ["string", "null"], "description": "The plan the approval is for; null signs an empty fourth line." },
|
|
32
|
+
"resolvedBy": { "type": "string", "description": "The approver, as --actor names them: the principal the signature must be listed for at base. The fifth line." },
|
|
33
|
+
"relayedBy": { "type": ["string", "null"], "description": "Who relays the approval (--relayed-by). When not null the statement has a `relayed-by <principal>` line after the time." },
|
|
34
|
+
"timestamp": { "type": "string", "description": "The approval's time, ISO 8601 UTC with milliseconds. The sixth line. Pass it as --at when recording the signature." },
|
|
35
|
+
"checkpointDigest": { "type": ["string", "null"], "description": "The checkpoint a resumed run carries its outputs from. When not null the statement ends with a `checkpoint <digest>` line." },
|
|
36
|
+
"sealVersion": { "enum": [1, 2], "description": "2 when the statement signs a checkpoint digest, else 1." },
|
|
37
|
+
"namespace": { "const": "chant-gate", "description": "The ssh signature namespace (`ssh-keygen -Y sign -n chant-gate`)." },
|
|
38
|
+
"text": { "type": "string", "description": "The statement as UTF-8 text: the lines joined by LF, no final newline." },
|
|
39
|
+
"statement": { "type": "string", "contentEncoding": "base64", "description": "The same bytes, base64. These are what is signed." },
|
|
40
|
+
"digest": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$", "description": "SHA-256 of the bytes." },
|
|
41
|
+
"challenge": { "type": "string", "pattern": "^[A-Za-z0-9_-]{43}$", "description": "The WebAuthn challenge a passkey signs: base64url of the bytes' SHA-256, with no padding." }
|
|
42
|
+
},
|
|
43
|
+
"additionalProperties": true
|
|
44
|
+
}
|
|
@@ -251,6 +251,9 @@ export interface FakeForgeRelease {
|
|
|
251
251
|
draft: boolean;
|
|
252
252
|
target: string;
|
|
253
253
|
assets: Array<{ name: string; digest: string | null; bytes: string }>;
|
|
254
|
+
name?: string;
|
|
255
|
+
/** GitHub: the `make_latest` the release was published with. */
|
|
256
|
+
make_latest?: string;
|
|
254
257
|
}
|
|
255
258
|
|
|
256
259
|
/** A forge fake answering through `fetch`: GitHub or Forgejo with draft releases, or GitLab with releases, links and a generic package registry. */
|
|
@@ -264,11 +267,14 @@ export interface FakeForge {
|
|
|
264
267
|
visible(): Array<{ tag: string; assets: string[] }>;
|
|
265
268
|
/** Make the next request whose `METHOD url` starts with `prefix` answer 500. */
|
|
266
269
|
failOnce(prefix: string): void;
|
|
270
|
+
/** GitHub and Forgejo: the repository's tags, each the commit it names. Publishing a release makes its tag at its target when there is none. */
|
|
271
|
+
tags: Map<string, string>;
|
|
267
272
|
}
|
|
268
273
|
|
|
269
274
|
/** A forge fake at `api` for `repo`, which holds `releases` to begin with. */
|
|
270
275
|
export function startFakeForge(forge: "github" | "forgejo" | "gitlab", api: string, repo: string, releases: FakeForgeRelease[] = []): FakeForge {
|
|
271
276
|
const calls: FakeForge["calls"] = [];
|
|
277
|
+
const tags = new Map<string, string>(releases.filter((r) => !r.draft).map((r) => [r.tag_name, r.target]));
|
|
272
278
|
const packages = new Map<string, string>();
|
|
273
279
|
const failures: string[] = [];
|
|
274
280
|
let nextId = 100 + releases.length;
|
|
@@ -278,7 +284,7 @@ export function startFakeForge(forge: "github" | "forgejo" | "gitlab", api: stri
|
|
|
278
284
|
const view = (r: FakeForgeRelease) =>
|
|
279
285
|
forge === "gitlab"
|
|
280
286
|
? { tag_name: r.tag_name, assets: { links: r.assets.map((a) => ({ name: a.name })) } }
|
|
281
|
-
: { id: r.id, tag_name: r.tag_name, draft: r.draft, upload_url: `${uploads}/repos/${repo}/releases/${r.id}/assets{?name,label}`, assets: r.assets.map((a) => ({ name: a.name, ...(forge === "github" ? { digest: a.digest } : {}) })) };
|
|
287
|
+
: { id: r.id, tag_name: r.tag_name, name: r.name ?? r.tag_name, draft: r.draft, upload_url: `${uploads}/repos/${repo}/releases/${r.id}/assets{?name,label}`, assets: r.assets.map((a) => ({ name: a.name, ...(forge === "github" ? { digest: a.digest } : {}) })) };
|
|
282
288
|
const text = (b: Uint8Array | string | undefined) => (b === undefined ? "" : typeof b === "string" ? b : Buffer.from(b).toString("utf-8"));
|
|
283
289
|
const fetch: FakeForge["fetch"] = async (url, init) => {
|
|
284
290
|
calls.push({ method: init.method, url, headers: init.headers, ...(init.body !== undefined ? { body: init.body } : {}) });
|
|
@@ -316,8 +322,8 @@ export function startFakeForge(forge: "github" | "forgejo" | "gitlab", api: stri
|
|
|
316
322
|
}
|
|
317
323
|
if (init.method === "GET" && path === `${root}/releases`) return json(200, releases.map(view));
|
|
318
324
|
if (init.method === "POST" && path === `${root}/releases`) {
|
|
319
|
-
const b = JSON.parse(text(init.body)) as { tag_name: string; target_commitish: string; draft?: boolean };
|
|
320
|
-
const r: FakeForgeRelease = { id: nextId++, tag_name: b.tag_name, draft: b.draft === true, target: b.target_commitish, assets: [] };
|
|
325
|
+
const b = JSON.parse(text(init.body)) as { tag_name: string; target_commitish: string; draft?: boolean; name?: string };
|
|
326
|
+
const r: FakeForgeRelease = { id: nextId++, tag_name: b.tag_name, draft: b.draft === true, target: b.target_commitish, assets: [], ...(b.name ? { name: b.name } : {}) };
|
|
321
327
|
releases.push(r);
|
|
322
328
|
return json(201, view(r));
|
|
323
329
|
}
|
|
@@ -336,10 +342,27 @@ export function startFakeForge(forge: "github" | "forgejo" | "gitlab", api: stri
|
|
|
336
342
|
if (init.method === "PATCH" && edit) {
|
|
337
343
|
const r = releases.find((x) => x.id === Number(edit[1]));
|
|
338
344
|
if (!r) return json(404, { message: "Not Found" });
|
|
339
|
-
const b = JSON.parse(text(init.body)) as { draft?: boolean };
|
|
340
|
-
if (b.draft === false
|
|
345
|
+
const b = JSON.parse(text(init.body)) as { draft?: boolean; make_latest?: string };
|
|
346
|
+
if (b.draft === false && r.draft) {
|
|
347
|
+
if (releases.some((x) => x !== r && !x.draft && x.tag_name === r.tag_name)) return json(422, { message: "Validation Failed", errors: [{ code: "already_exists", field: "tag_name" }] });
|
|
348
|
+
r.draft = false;
|
|
349
|
+
if (!tags.has(r.tag_name)) tags.set(r.tag_name, r.target);
|
|
350
|
+
if (b.make_latest !== undefined) r.make_latest = b.make_latest;
|
|
351
|
+
}
|
|
341
352
|
return json(200, view(r));
|
|
342
353
|
}
|
|
354
|
+
if (init.method === "DELETE" && edit) {
|
|
355
|
+
const i = releases.findIndex((x) => x.id === Number(edit[1]));
|
|
356
|
+
if (i < 0) return json(404, { message: "Not Found" });
|
|
357
|
+
releases.splice(i, 1);
|
|
358
|
+
return json(204, undefined);
|
|
359
|
+
}
|
|
360
|
+
const tagRef = path.startsWith(`${root}/git/refs/tags/`) ? decodeURIComponent(path.slice(`${root}/git/refs/tags/`.length)) : null;
|
|
361
|
+
if (init.method === "DELETE" && tagRef !== null) {
|
|
362
|
+
if (!tags.has(tagRef)) return json(422, { message: "Reference does not exist" });
|
|
363
|
+
tags.delete(tagRef);
|
|
364
|
+
return json(204, undefined);
|
|
365
|
+
}
|
|
343
366
|
return json(404, { message: "Not Found" });
|
|
344
367
|
};
|
|
345
368
|
return {
|
|
@@ -349,6 +372,7 @@ export function startFakeForge(forge: "github" | "forgejo" | "gitlab", api: stri
|
|
|
349
372
|
packages,
|
|
350
373
|
visible: () => releases.filter((r) => !r.draft).map((r) => ({ tag: r.tag_name, assets: r.assets.map((a) => a.name) })),
|
|
351
374
|
failOnce: (prefix) => void failures.push(prefix),
|
|
375
|
+
tags,
|
|
352
376
|
};
|
|
353
377
|
}
|
|
354
378
|
|
|
@@ -372,3 +396,99 @@ export function writeLockfile(dir: string): void {
|
|
|
372
396
|
JSON.stringify({ name: "acme", lockfileVersion: 3, packages: { "": { name: "acme" }, "node_modules/left-pad": { version: "1.3.0" } } }, null, 2),
|
|
373
397
|
);
|
|
374
398
|
}
|
|
399
|
+
|
|
400
|
+
/** A GitHub repository fake answering through `fetch` (#4676): branches, commits of whole files, and the contents and refs APIs. */
|
|
401
|
+
export interface FakeGitHubRepo {
|
|
402
|
+
fetch: FakeForge["fetch"];
|
|
403
|
+
calls: FakeForge["calls"];
|
|
404
|
+
/** The branches, each the sha of its commit. */
|
|
405
|
+
branches: Map<string, string>;
|
|
406
|
+
/** The file `path` on `branch`, or undefined. */
|
|
407
|
+
read(branch: string, path: string): string | undefined;
|
|
408
|
+
/** Commit `files` onto `branch` as someone else would, moving it. */
|
|
409
|
+
push(branch: string, files: Record<string, string>): void;
|
|
410
|
+
/** Each commit's message, oldest first, on `branch`'s history. */
|
|
411
|
+
log(branch: string): string[];
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** A repository fake at `api` for `repo` whose `branch` holds `files`. */
|
|
415
|
+
export function startFakeGitHubRepo(api: string, repo: string, branch: string, files: Record<string, string>): FakeGitHubRepo {
|
|
416
|
+
const calls: FakeGitHubRepo["calls"] = [];
|
|
417
|
+
const commits = new Map<string, { parent: string | null; message: string; files: Map<string, string> }>();
|
|
418
|
+
const branches = new Map<string, string>();
|
|
419
|
+
let n = 0;
|
|
420
|
+
const commit = (parent: string | null, message: string, change: Record<string, string>) => {
|
|
421
|
+
const base = parent ? commits.get(parent)!.files : new Map<string, string>();
|
|
422
|
+
const sha = createHash("sha1").update(`commit ${n++}`).digest("hex");
|
|
423
|
+
commits.set(sha, { parent, message, files: new Map([...base, ...Object.entries(change)]) });
|
|
424
|
+
return sha;
|
|
425
|
+
};
|
|
426
|
+
branches.set(branch, commit(null, "init", files));
|
|
427
|
+
const blob = (text: string) => createHash("sha1").update(`blob ${text}`).digest("hex");
|
|
428
|
+
const ancestor = (a: string, b: string) => {
|
|
429
|
+
for (let c: string | null = b; c; c = commits.get(c)?.parent ?? null) if (c === a) return true;
|
|
430
|
+
return false;
|
|
431
|
+
};
|
|
432
|
+
const json = (status: number, body?: unknown) => ({ ok: status < 300, status, headers: { get: () => null }, text: async () => (body === undefined ? "" : JSON.stringify(body)) });
|
|
433
|
+
const root = `${api}/repos/${repo}`;
|
|
434
|
+
const fetch: FakeGitHubRepo["fetch"] = async (url, init) => {
|
|
435
|
+
calls.push({ method: init.method, url, headers: init.headers, ...(init.body !== undefined ? { body: init.body } : {}) });
|
|
436
|
+
const u = new URL(url);
|
|
437
|
+
const path = url.split("?")[0]!;
|
|
438
|
+
const body = typeof init.body === "string" ? (JSON.parse(init.body) as Record<string, unknown>) : {};
|
|
439
|
+
if (init.method === "GET" && path === root) return json(200, { default_branch: branch });
|
|
440
|
+
const ref = path.match(/\/git\/refs?\/heads\/(.+)$/);
|
|
441
|
+
if (ref && path.startsWith(root)) {
|
|
442
|
+
const name = decodeURIComponent(ref[1]!);
|
|
443
|
+
const at = branches.get(name);
|
|
444
|
+
if (init.method === "GET") return at ? json(200, { ref: `refs/heads/${name}`, object: { sha: at } }) : json(404, { message: "Not Found" });
|
|
445
|
+
if (!at) return json(422, { message: "Reference does not exist" });
|
|
446
|
+
if (init.method === "DELETE") return void branches.delete(name), json(204);
|
|
447
|
+
if (init.method === "PATCH") {
|
|
448
|
+
const to = String(body.sha);
|
|
449
|
+
if (!commits.has(to)) return json(422, { message: "Object does not exist" });
|
|
450
|
+
if (body.force !== true && !ancestor(at, to)) return json(422, { message: "Update is not a fast forward" });
|
|
451
|
+
branches.set(name, to);
|
|
452
|
+
return json(200, { object: { sha: to } });
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
if (init.method === "POST" && path === `${root}/git/refs`) {
|
|
456
|
+
const name = String(body.ref).replace(/^refs\/heads\//, "");
|
|
457
|
+
if (branches.has(name)) return json(422, { message: "Reference already exists" });
|
|
458
|
+
branches.set(name, String(body.sha));
|
|
459
|
+
return json(201, { ref: body.ref, object: { sha: body.sha } });
|
|
460
|
+
}
|
|
461
|
+
const contents = path.startsWith(`${root}/contents/`) ? path.slice(`${root}/contents/`.length).split("/").map(decodeURIComponent).join("/") : null;
|
|
462
|
+
if (contents !== null && init.method === "GET") {
|
|
463
|
+
const at = branches.get(u.searchParams.get("ref") ?? branch);
|
|
464
|
+
const text = at ? commits.get(at)!.files.get(contents) : undefined;
|
|
465
|
+
return text === undefined ? json(404, { message: "Not Found" }) : json(200, { sha: blob(text), encoding: "base64", content: Buffer.from(text).toString("base64") });
|
|
466
|
+
}
|
|
467
|
+
if (contents !== null && init.method === "PUT") {
|
|
468
|
+
const on = String(body.branch);
|
|
469
|
+
const at = branches.get(on);
|
|
470
|
+
if (!at) return json(404, { message: "Branch not found" });
|
|
471
|
+
const current = commits.get(at)!.files.get(contents);
|
|
472
|
+
if ((current === undefined ? undefined : blob(current)) !== body.sha) return json(409, { message: "sha does not match" });
|
|
473
|
+
const sha = commit(at, String(body.message), { [contents]: Buffer.from(String(body.content), "base64").toString("utf-8") });
|
|
474
|
+
branches.set(on, sha);
|
|
475
|
+
return json(current === undefined ? 201 : 200, { content: { sha: blob(contents) }, commit: { sha } });
|
|
476
|
+
}
|
|
477
|
+
return json(404, { message: "Not Found" });
|
|
478
|
+
};
|
|
479
|
+
return {
|
|
480
|
+
fetch,
|
|
481
|
+
calls,
|
|
482
|
+
branches,
|
|
483
|
+
read: (b, p) => {
|
|
484
|
+
const at = branches.get(b);
|
|
485
|
+
return at ? commits.get(at)!.files.get(p) : undefined;
|
|
486
|
+
},
|
|
487
|
+
push: (b, change) => void branches.set(b, commit(branches.get(b)!, "someone else", change)),
|
|
488
|
+
log: (b) => {
|
|
489
|
+
const out: string[] = [];
|
|
490
|
+
for (let c: string | null = branches.get(b) ?? null; c; c = commits.get(c)!.parent) out.unshift(commits.get(c)!.message);
|
|
491
|
+
return out;
|
|
492
|
+
},
|
|
493
|
+
};
|
|
494
|
+
}
|