@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
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4693: a release cut of a commit that is not green, under a person's
|
|
3
|
+
* override on the override gate's ledger. The cut records the request, a
|
|
4
|
+
* person the overriders file at base lists answers it with a reason, and the
|
|
5
|
+
* next cut spends it and records who and why on the cut line.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, test, expect } from "vitest";
|
|
9
|
+
import { withTestDir } from "@intentius/chant-test-utils";
|
|
10
|
+
import { spawnSync } from "node:child_process";
|
|
11
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { cutRelease, greenOverrideSubject, planRelease, ReleaseCutError } from "./release-cut";
|
|
14
|
+
import { readCuts, type ReleaseArtifact } from "./release-store";
|
|
15
|
+
import { appendGateResolution } from "./gate-ledger";
|
|
16
|
+
import { readOverrideLedger } from "./override-ledger";
|
|
17
|
+
import { overrideDigest, OVERRIDE_OP } from "../override-gate";
|
|
18
|
+
import type { CompiledTarget, TargetCompiler } from "../components/release-compile";
|
|
19
|
+
import { releasesDocument } from "../workspace/releases";
|
|
20
|
+
import { contract } from "../workspace/__fixtures__/contract-repo";
|
|
21
|
+
import releasesSchema from "../workspace/releases.schema.json";
|
|
22
|
+
|
|
23
|
+
function git(dir: string, ...args: string[]): string {
|
|
24
|
+
const r = spawnSync("git", args, { cwd: dir, encoding: "utf-8" });
|
|
25
|
+
if (r.status !== 0) throw new Error(`git ${args.join(" ")}: ${r.stderr}`);
|
|
26
|
+
return r.stdout.trim();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A project on main with two environments, and `.chant/overriders` listing `overriders` when given. */
|
|
30
|
+
function project(dir: string, overriders: string[] | null = ["github:alice"]): string {
|
|
31
|
+
git(dir, "init", "-q", "-b", "main");
|
|
32
|
+
git(dir, "config", "user.email", "test@chant.dev");
|
|
33
|
+
git(dir, "config", "user.name", "Test");
|
|
34
|
+
writeFileSync(join(dir, "chant.config.ts"), `export default { environments: ["dev", "prod"] };\n`);
|
|
35
|
+
mkdirSync(join(dir, "api"), { recursive: true });
|
|
36
|
+
writeFileSync(join(dir, "api", "Dockerfile"), "FROM scratch\n");
|
|
37
|
+
writeFileSync(join(dir, "api.component.ts"), "export const api = {};\n");
|
|
38
|
+
if (overriders) {
|
|
39
|
+
mkdirSync(join(dir, ".chant"), { recursive: true });
|
|
40
|
+
writeFileSync(join(dir, ".chant", "overriders"), `# who may override\n${overriders.join("\n")}\n`);
|
|
41
|
+
}
|
|
42
|
+
git(dir, "add", ".");
|
|
43
|
+
git(dir, "commit", "-q", "-m", "init");
|
|
44
|
+
return git(dir, "rev-parse", "HEAD");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function compiler(): TargetCompiler {
|
|
48
|
+
return {
|
|
49
|
+
async compile(env): Promise<CompiledTarget> {
|
|
50
|
+
return {
|
|
51
|
+
env,
|
|
52
|
+
params: [],
|
|
53
|
+
components: ["api"],
|
|
54
|
+
buildSteps: { api: [{ kind: "docker-build", context: "api", into: "api.tar" }] },
|
|
55
|
+
buildInputs: { api: ["api"] },
|
|
56
|
+
componentFiles: { api: "api.component.ts" },
|
|
57
|
+
templates: [{ component: "api", path: "dist/api.json", content: `{"env":"${env}"}\n` }],
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
async buildArtifacts(_env, components): Promise<ReleaseArtifact[]> {
|
|
61
|
+
return components.map((c) => ({ component: c, kind: "image" as const, path: `${c}.tar`, digest: `sha256:${"b".repeat(64)}` }));
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const T0 = "2026-11-01T10:00:00.000Z";
|
|
67
|
+
const T1 = "2026-11-01T10:05:00.000Z";
|
|
68
|
+
const T2 = "2026-11-01T10:10:00.000Z";
|
|
69
|
+
const request = (dir: string, at: string, opts: { label?: string | null; overrideGreen?: boolean } = {}) => ({
|
|
70
|
+
cwd: dir,
|
|
71
|
+
compiler: compiler(),
|
|
72
|
+
label: opts.label === undefined ? "v1.0.1" : opts.label,
|
|
73
|
+
actor: "ci-bot",
|
|
74
|
+
env: {},
|
|
75
|
+
now: () => new Date(at),
|
|
76
|
+
...(opts.overrideGreen === false ? {} : { overrideGreen: true }),
|
|
77
|
+
});
|
|
78
|
+
const refusal = async (p: Promise<unknown>): Promise<ReleaseCutError> => {
|
|
79
|
+
const err = await p.catch((e: unknown) => e);
|
|
80
|
+
expect(err).toBeInstanceOf(ReleaseCutError);
|
|
81
|
+
return err as ReleaseCutError;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/** Write an override of the cut of `sha`, as `chant approve policy-override` would. */
|
|
85
|
+
async function override(dir: string, sha: string, by: string, opts: { reason?: string; agent?: boolean; rule?: string } = {}): Promise<void> {
|
|
86
|
+
const subject = greenOverrideSubject(sha);
|
|
87
|
+
await appendGateResolution(
|
|
88
|
+
{
|
|
89
|
+
op: OVERRIDE_OP,
|
|
90
|
+
gate: subject,
|
|
91
|
+
resolvedBy: by,
|
|
92
|
+
timestamp: T1,
|
|
93
|
+
planDigest: overrideDigest(subject, sha, [opts.rule ?? "ci-green"]),
|
|
94
|
+
...(opts.reason !== "" ? { note: opts.reason ?? "windows runners are down; server phases passed" } : {}),
|
|
95
|
+
approver: { kind: opts.agent ? "agent" : "human" },
|
|
96
|
+
},
|
|
97
|
+
{ cwd: dir },
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
describe("a cut of a commit that is not green, under an override (#4693)", () => {
|
|
102
|
+
test("the cut records the request, a listed person overrides it, and the next cut spends it and records who and why", async () => {
|
|
103
|
+
await withTestDir(async (dir) => {
|
|
104
|
+
const sha = project(dir);
|
|
105
|
+
const subject = greenOverrideSubject(sha);
|
|
106
|
+
|
|
107
|
+
// A dry run decides and writes nothing.
|
|
108
|
+
const dry = await refusal(planRelease(request(dir, T0)));
|
|
109
|
+
expect(dry.code).toBe("release-commit-not-green");
|
|
110
|
+
expect(dry.recorded).toBe(false);
|
|
111
|
+
expect(dry.message).toContain(`a cut with --yes records the request for an override of ${subject}`);
|
|
112
|
+
expect((await readOverrideLedger({ cwd: dir })).pending).toEqual([]);
|
|
113
|
+
|
|
114
|
+
// The cut records the request and names the command that answers it.
|
|
115
|
+
const first = await refusal(cutRelease(request(dir, T0)));
|
|
116
|
+
expect(first.code).toBe("release-commit-not-green");
|
|
117
|
+
expect(first.recorded).toBe(true);
|
|
118
|
+
expect(first.message).toContain(`has no ci/green tag, so no release is cut from it; the request for an override of ${subject} is recorded`);
|
|
119
|
+
expect(first.fix).toContain(`github:alice may override it with: chant approve policy-override ${subject} --rule ci-green --reason "<why>"`);
|
|
120
|
+
const { pending } = await readOverrideLedger({ cwd: dir });
|
|
121
|
+
expect(pending).toHaveLength(1);
|
|
122
|
+
expect(pending[0]).toMatchObject({ op: OVERRIDE_OP, gate: subject, plan: sha, rules: ["ci-green"] });
|
|
123
|
+
// A second refused cut finds the request standing and records no other.
|
|
124
|
+
const again = await refusal(cutRelease(request(dir, T0)));
|
|
125
|
+
expect(again.recorded).toBe(false);
|
|
126
|
+
expect(again.message).toContain(`the request for an override of ${subject} has stood since ${T0}`);
|
|
127
|
+
|
|
128
|
+
await override(dir, sha, "github:alice");
|
|
129
|
+
const plan = await planRelease(request(dir, T2));
|
|
130
|
+
expect(plan.override).toMatchObject({ green: false, tag: `ci/green/${sha}`, by: "github:alice", reason: "windows runners are down; server phases passed", sealed: false });
|
|
131
|
+
|
|
132
|
+
const result = await cutRelease(request(dir, T2));
|
|
133
|
+
expect(result.cut?.override).toEqual({
|
|
134
|
+
green: false,
|
|
135
|
+
tag: `ci/green/${sha}`,
|
|
136
|
+
by: "github:alice",
|
|
137
|
+
at: T1,
|
|
138
|
+
reason: "windows runners are down; server phases passed",
|
|
139
|
+
digest: overrideDigest(subject, sha, ["ci-green"]),
|
|
140
|
+
sealed: false,
|
|
141
|
+
});
|
|
142
|
+
expect(result.cut?.actor).toBe("ci-bot");
|
|
143
|
+
const { applied } = await readOverrideLedger({ cwd: dir });
|
|
144
|
+
expect(applied).toMatchObject([{ gate: subject, approvedBy: "github:alice", approvedAt: T1, timestamp: T2, commit: sha }]);
|
|
145
|
+
|
|
146
|
+
const doc = await releasesDocument({ cwd: dir });
|
|
147
|
+
if ("error" in doc) throw new Error(doc.error.message);
|
|
148
|
+
expect(doc.releases[0].cuts[0].override?.by).toBe("github:alice");
|
|
149
|
+
contract(releasesSchema).expectValid(doc);
|
|
150
|
+
|
|
151
|
+
// The override is spent: another label needs its own.
|
|
152
|
+
const spent = await refusal(cutRelease(request(dir, T2, { label: "v1.0.2" })));
|
|
153
|
+
expect(spent.code).toBe("release-commit-not-green");
|
|
154
|
+
expect(spent.message).toContain("is spent");
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test("an override counts only from a listed person, with a reason, and not from an agent", async () => {
|
|
159
|
+
await withTestDir(async (dir) => {
|
|
160
|
+
const sha = project(dir);
|
|
161
|
+
await refusal(cutRelease(request(dir, T0)));
|
|
162
|
+
await override(dir, sha, "github:mallory");
|
|
163
|
+
expect((await refusal(cutRelease(request(dir, T2)))).message).toContain("github:mallory is not listed in .chant/overriders at base (github:alice)");
|
|
164
|
+
});
|
|
165
|
+
await withTestDir(async (dir) => {
|
|
166
|
+
const sha = project(dir);
|
|
167
|
+
await refusal(cutRelease(request(dir, T0)));
|
|
168
|
+
await override(dir, sha, "github:alice", { agent: true });
|
|
169
|
+
expect((await refusal(cutRelease(request(dir, T2)))).message).toContain("was recorded by an agent, and an override is a person's");
|
|
170
|
+
});
|
|
171
|
+
await withTestDir(async (dir) => {
|
|
172
|
+
const sha = project(dir);
|
|
173
|
+
await refusal(cutRelease(request(dir, T0)));
|
|
174
|
+
await override(dir, sha, "github:alice", { reason: "" });
|
|
175
|
+
expect((await refusal(cutRelease(request(dir, T2)))).message).toContain("gives no reason");
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test("with no overriders file nobody may override, and the refusal says so", async () => {
|
|
180
|
+
await withTestDir(async (dir) => {
|
|
181
|
+
project(dir, null);
|
|
182
|
+
const err = await refusal(cutRelease(request(dir, T0)));
|
|
183
|
+
expect(err.fix).toContain(".chant/overriders at base does not exist, so nobody may override it yet");
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("without --override-green a standing override is not used, and a revoked commit is never cut", async () => {
|
|
188
|
+
await withTestDir(async (dir) => {
|
|
189
|
+
const sha = project(dir);
|
|
190
|
+
await refusal(cutRelease(request(dir, T0)));
|
|
191
|
+
await override(dir, sha, "github:alice");
|
|
192
|
+
const plain = await refusal(cutRelease(request(dir, T2, { overrideGreen: false })));
|
|
193
|
+
expect(plain.code).toBe("release-commit-not-green");
|
|
194
|
+
expect(plain.message).not.toContain("override");
|
|
195
|
+
|
|
196
|
+
git(dir, "tag", `ci/revoked/${sha}`, sha);
|
|
197
|
+
const revoked = await refusal(cutRelease(request(dir, T2)));
|
|
198
|
+
expect(revoked.code).toBe("release-commit-revoked");
|
|
199
|
+
expect(revoked.message).toContain("an override does not cut a revoked commit");
|
|
200
|
+
expect((await readCuts({ cwd: dir })).cuts).toEqual([]);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test("a green commit cuts as before and writes no override", async () => {
|
|
205
|
+
await withTestDir(async (dir) => {
|
|
206
|
+
const sha = project(dir);
|
|
207
|
+
git(dir, "tag", `ci/green/${sha}`, sha);
|
|
208
|
+
const result = await cutRelease(request(dir, T0));
|
|
209
|
+
expect(result.cut).not.toHaveProperty("override");
|
|
210
|
+
expect((await readOverrideLedger({ cwd: dir })).pending).toEqual([]);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
});
|
|
@@ -31,6 +31,21 @@
|
|
|
31
31
|
* all the same, and readers report whether the signature verifies. With
|
|
32
32
|
* `ci.green.signedSince` declared, a green tag counts only with a valid
|
|
33
33
|
* statement (`../workspace/ci-green.ts`), so a hand-pushed tag cuts nothing.
|
|
34
|
+
*
|
|
35
|
+
* A lane (#4692): a cut given a lane `ci.green.lanes` declares checks that
|
|
36
|
+
* lane's tags, `ci/green-<lane>/<sha>` and `ci/revoked-<lane>/<sha>`, in place
|
|
37
|
+
* of `ci/green/<sha>` and `ci/revoked/<sha>`, and the cut line names the lane.
|
|
38
|
+
*
|
|
39
|
+
* An override (#4693): a commit with no green tag that counts is cut when the
|
|
40
|
+
* cut asks for it (`overrideGreen`) and a person's override of it stands on
|
|
41
|
+
* the override ledger, `_gates/policy-override.jsonl` (`../override-gate.ts`).
|
|
42
|
+
* The subject is `release-<sha12>`, the plan the commit, and the rule
|
|
43
|
+
* `ci-green` (or `ci-green-<lane>`). It counts when a person the overriders
|
|
44
|
+
* file at base lists wrote it with a reason, sealed under a `release` gate in
|
|
45
|
+
* `identity.gates`. The cut spends it and records it on the cut line. With no
|
|
46
|
+
* override that counts, a cut (not a dry run) records the request for one,
|
|
47
|
+
* which `chant approve policy-override` answers. A revoked commit is never
|
|
48
|
+
* cut, override or not.
|
|
34
49
|
*/
|
|
35
50
|
|
|
36
51
|
import { execFileSync } from "node:child_process";
|
|
@@ -53,11 +68,31 @@ import {
|
|
|
53
68
|
type Release,
|
|
54
69
|
type ReleaseArtifact,
|
|
55
70
|
type ReleaseCut,
|
|
71
|
+
type ReleaseCutOverride,
|
|
56
72
|
type ReleaseTarget,
|
|
57
73
|
templateBytesDigest,
|
|
58
74
|
type TemplateContent,
|
|
59
75
|
} from "./release-store";
|
|
60
76
|
import type { CompiledTarget, TargetCompiler } from "../components/release-compile";
|
|
77
|
+
import { NEXT_RELEASE } from "../release-floors";
|
|
78
|
+
|
|
79
|
+
/** The first chant that cuts from a lane's green tag and writes `lane` on the cut line (#4692). */
|
|
80
|
+
export const RELEASE_CUT_LANE_FLOOR = NEXT_RELEASE;
|
|
81
|
+
/** The first chant that cuts a commit that is not green under an override and writes `override` on the cut line (#4693). */
|
|
82
|
+
export const RELEASE_CUT_OVERRIDE_FLOOR = NEXT_RELEASE;
|
|
83
|
+
|
|
84
|
+
/** The override gate's subject for a cut of `commit` (#4693): `release-<sha12>`. */
|
|
85
|
+
export function greenOverrideSubject(commit: string): string {
|
|
86
|
+
return `release-${commit.slice(0, 12)}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The rule an override of a cut names (#4693): `ci-green`, or `ci-green-<lane>` for a lane's tag. */
|
|
90
|
+
export function greenOverrideRule(lane: string | null): string {
|
|
91
|
+
return lane !== null ? `ci-green-${lane}` : "ci-green";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** How long a recorded request for an override stands before a cut records a fresh one. */
|
|
95
|
+
const OVERRIDE_REQUEST_HOURS = 48;
|
|
61
96
|
|
|
62
97
|
/** The stable codes a cut refuses with. */
|
|
63
98
|
export type ReleaseCutCode =
|
|
@@ -77,6 +112,8 @@ export class ReleaseCutError extends Error {
|
|
|
77
112
|
readonly code: ReleaseCutCode,
|
|
78
113
|
message: string,
|
|
79
114
|
readonly fix?: string,
|
|
115
|
+
/** The cut recorded a request for an override on `chant/lifecycle` (#4693), which the caller pushes. */
|
|
116
|
+
readonly recorded = false,
|
|
80
117
|
) {
|
|
81
118
|
super(message);
|
|
82
119
|
this.name = "ReleaseCutError";
|
|
@@ -106,6 +143,19 @@ export interface CutRequest {
|
|
|
106
143
|
composed?: { branch: string; base: string; sources: string[] };
|
|
107
144
|
/** The publish channel recorded on the cut (#4168 4.3), in place of `latest`. */
|
|
108
145
|
channel?: string;
|
|
146
|
+
/**
|
|
147
|
+
* The green lane to check (#4692), one `ci.green.lanes` declares at base:
|
|
148
|
+
* the commit must carry `ci/green-<lane>/<sha>` and no
|
|
149
|
+
* `ci/revoked-<lane>/<sha>`. Recorded on the cut. Absent, the full
|
|
150
|
+
* `ci/green/<sha>` tag is checked.
|
|
151
|
+
*/
|
|
152
|
+
lane?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Cut the commit when it has no green tag that counts, under a person's
|
|
155
|
+
* override of it (#4693). Without an override that counts the cut is
|
|
156
|
+
* refused, and a cut that is not a dry run records the request for one.
|
|
157
|
+
*/
|
|
158
|
+
overrideGreen?: boolean;
|
|
109
159
|
}
|
|
110
160
|
|
|
111
161
|
export interface CutResult {
|
|
@@ -137,17 +187,18 @@ function tryGit(top: string, args: string[]): string | null {
|
|
|
137
187
|
* and the tags on it that were ignored for want of a valid statement
|
|
138
188
|
* (#4031). The tags are judged by `green`, the declaration's `ci.green` at
|
|
139
189
|
* base, with the runner keys read at its branch's tip; with no `ci.green`,
|
|
140
|
-
* every tag counts.
|
|
190
|
+
* every tag counts. With `lane` (#4692), that lane's tags are read.
|
|
141
191
|
*/
|
|
142
192
|
export async function greenState(
|
|
143
193
|
top: string,
|
|
144
194
|
sha: string,
|
|
145
195
|
green: import("../workspace/declaration").CiGreen | null = null,
|
|
196
|
+
lane?: string,
|
|
146
197
|
): Promise<{ state: "green" | "revoked" | "none"; ignored: Array<{ tag: string; status: string; reason: string }> }> {
|
|
147
198
|
const { judgedCiTags } = await import("./release-revocation");
|
|
148
199
|
let tags: Awaited<ReturnType<typeof judgedCiTags>>;
|
|
149
200
|
try {
|
|
150
|
-
tags = await judgedCiTags(top, green);
|
|
201
|
+
tags = await judgedCiTags(top, green, lane);
|
|
151
202
|
} catch (err) {
|
|
152
203
|
const { WorkspaceReadError } = await import("../workspace/declaration");
|
|
153
204
|
if (err instanceof WorkspaceReadError) throw new ReleaseCutError("declaration-invalid", err.message);
|
|
@@ -202,6 +253,104 @@ interface Prepared {
|
|
|
202
253
|
carried: ReleaseArtifact[];
|
|
203
254
|
reused: CutResult["reused"];
|
|
204
255
|
member: string | null;
|
|
256
|
+
/** The lane the commit was checked in, or null for the full green tag. */
|
|
257
|
+
lane: string | null;
|
|
258
|
+
/** The override the commit is cut under when it is not green (#4693), or null. */
|
|
259
|
+
override: ReleaseCutOverride | null;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Decide the override of a cut of `commit`, which has no green tag that
|
|
264
|
+
* counts (#4693), as `decideOverride` decides any: against the overriders
|
|
265
|
+
* file and, when `sealed`, the signers at base. With none that counts and
|
|
266
|
+
* `record`, the request for one is appended unless one stands.
|
|
267
|
+
*/
|
|
268
|
+
async function greenOverride(req: {
|
|
269
|
+
top: string;
|
|
270
|
+
cwd: string;
|
|
271
|
+
commit: string;
|
|
272
|
+
lane: string | null;
|
|
273
|
+
sealed: boolean;
|
|
274
|
+
record: boolean;
|
|
275
|
+
now: string;
|
|
276
|
+
}): Promise<{ override: Omit<ReleaseCutOverride, "green" | "tag"> } | { override: null; why: string; fix: string; recorded: boolean }> {
|
|
277
|
+
const og = await import("../override-gate");
|
|
278
|
+
const { readOverrideLedger, recordOverrideDenial } = await import("./override-ledger");
|
|
279
|
+
const { resolveBase } = await import("../workspace/trust/provenance");
|
|
280
|
+
const subject = greenOverrideSubject(req.commit);
|
|
281
|
+
const rules = [greenOverrideRule(req.lane)];
|
|
282
|
+
const base = resolveBase(req.top).commit;
|
|
283
|
+
const overriders = base ? og.overridersAt(req.top, base) : null;
|
|
284
|
+
const signers = req.sealed && base ? (await import("../gate-decision")).gateSignersAt(req.top, base) : undefined;
|
|
285
|
+
const ledger = await readOverrideLedger({ cwd: req.cwd });
|
|
286
|
+
const verdict = og.decideOverride({
|
|
287
|
+
ledger,
|
|
288
|
+
applied: ledger.applied,
|
|
289
|
+
subject,
|
|
290
|
+
planDigest: req.commit,
|
|
291
|
+
rules,
|
|
292
|
+
overriders: overriders?.principals ?? [],
|
|
293
|
+
mode: req.sealed ? "sealed" : "ledger",
|
|
294
|
+
...(signers ? { signers } : {}),
|
|
295
|
+
now: req.now,
|
|
296
|
+
});
|
|
297
|
+
if (verdict.status === "overridden") {
|
|
298
|
+
const o = verdict.override;
|
|
299
|
+
return { override: { by: o.by, at: o.at, reason: o.reason, digest: o.digest, sealed: o.sealed } };
|
|
300
|
+
}
|
|
301
|
+
let recorded = false;
|
|
302
|
+
if (req.record && !verdict.standing) {
|
|
303
|
+
await recordOverrideDenial(
|
|
304
|
+
{
|
|
305
|
+
subject,
|
|
306
|
+
planDigest: req.commit,
|
|
307
|
+
rules,
|
|
308
|
+
timestamp: req.now,
|
|
309
|
+
expiresAt: new Date(Date.parse(req.now) + OVERRIDE_REQUEST_HOURS * 3_600_000).toISOString(),
|
|
310
|
+
description: `release cut of commit ${req.commit.slice(0, 12)}, which has no ${req.lane !== null ? `ci/green-${req.lane}` : "ci/green"} tag that counts`,
|
|
311
|
+
},
|
|
312
|
+
{ cwd: req.cwd },
|
|
313
|
+
);
|
|
314
|
+
recorded = true;
|
|
315
|
+
}
|
|
316
|
+
const notes = [
|
|
317
|
+
...verdict.refusals.map((r) => `an override does not count: ${r}`),
|
|
318
|
+
...(verdict.status === "moved" ? [`${verdict.by} overrode another commit or rule (${verdict.was ?? "no digest"}), which counts for nothing here`] : []),
|
|
319
|
+
recorded
|
|
320
|
+
? `the request for an override of ${subject} is recorded on chant/lifecycle`
|
|
321
|
+
: verdict.standing
|
|
322
|
+
? `the request for an override of ${subject} has stood since ${verdict.standing.timestamp}`
|
|
323
|
+
: `a cut with --yes records the request for an override of ${subject}`,
|
|
324
|
+
];
|
|
325
|
+
const who = !overriders?.active
|
|
326
|
+
? `${og.OVERRIDERS_PATH} at base does not exist, so nobody may override it yet. Once it lists a person, they may`
|
|
327
|
+
: overriders.principals.length > 0
|
|
328
|
+
? `${overriders.principals.join(", ")} may`
|
|
329
|
+
: `${og.OVERRIDERS_PATH} at base lists nobody, so nobody may`;
|
|
330
|
+
return {
|
|
331
|
+
override: null,
|
|
332
|
+
why: notes.join("; "),
|
|
333
|
+
fix: `${who} override it with: ${og.overrideCommand(subject, rules, req.sealed)}, and then cut again with --override-green.`,
|
|
334
|
+
recorded,
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* The lane `name` as the declaration at base declares it (#4692), or a
|
|
340
|
+
* `declaration-invalid` refusal when there is no `ci.green` or it declares
|
|
341
|
+
* no such lane.
|
|
342
|
+
*/
|
|
343
|
+
async function declaredLane(green: import("../workspace/declaration").CiGreen | null, name: string): Promise<string> {
|
|
344
|
+
if (!green) {
|
|
345
|
+
throw new ReleaseCutError("declaration-invalid", `the cut asks for lane ${JSON.stringify(name)}, and chant.workspace.json at base declares no ci.green, so it has no lanes`);
|
|
346
|
+
}
|
|
347
|
+
const { laneOf, WorkspaceReadError } = await import("../workspace/declaration");
|
|
348
|
+
try {
|
|
349
|
+
return laneOf(green, name).name;
|
|
350
|
+
} catch (err) {
|
|
351
|
+
if (err instanceof WorkspaceReadError) throw new ReleaseCutError("declaration-invalid", err.message);
|
|
352
|
+
throw err;
|
|
353
|
+
}
|
|
205
354
|
}
|
|
206
355
|
|
|
207
356
|
/**
|
|
@@ -210,7 +359,7 @@ interface Prepared {
|
|
|
210
359
|
* asks, the tree is clean, every environment compiles with the same build
|
|
211
360
|
* steps, and which artifacts are carried from an earlier release.
|
|
212
361
|
*/
|
|
213
|
-
async function prepare(req: CutRequest): Promise<Prepared> {
|
|
362
|
+
async function prepare(req: CutRequest, record = false): Promise<Prepared> {
|
|
214
363
|
const cwd = resolve(req.cwd);
|
|
215
364
|
const top = tryGit(cwd, ["rev-parse", "--show-toplevel"]);
|
|
216
365
|
if (!top) throw new ReleaseCutError("not-a-git-repository", "a release is cut from a commit, and this directory is not in a git repository");
|
|
@@ -220,21 +369,34 @@ async function prepare(req: CutRequest): Promise<Prepared> {
|
|
|
220
369
|
const { scopeSource } = await import("../workspace/write-scope");
|
|
221
370
|
const { releaseRuleFrom } = await import("../workspace/identity");
|
|
222
371
|
const source = scopeSource(cwd);
|
|
223
|
-
const
|
|
372
|
+
const green = source.declaration?.ci?.green ?? null;
|
|
373
|
+
const lane = req.lane !== undefined ? await declaredLane(green, req.lane) : null;
|
|
374
|
+
const { state, ignored } = await greenState(top, commit, green, lane ?? undefined);
|
|
375
|
+
// Who may cut is the declaration's identity.gates.release, read at base.
|
|
376
|
+
const releaseRule = releaseRuleFrom(source);
|
|
377
|
+
let override: ReleaseCutOverride | null = null;
|
|
224
378
|
if (state !== "green") {
|
|
225
379
|
const why = ignored.length > 0 ? `; ignored: ${ignored.map((t) => `${t.tag} (${t.status}): ${t.reason}`).join("; ")}` : "";
|
|
226
|
-
|
|
227
|
-
|
|
380
|
+
// #4692: a lane's tags are ci/green-<lane>/ and ci/revoked-<lane>/.
|
|
381
|
+
const greenTag = lane !== null ? `ci/green-${lane}` : "ci/green";
|
|
382
|
+
const revokedTag = lane !== null ? `ci/revoked-${lane}` : "ci/revoked";
|
|
383
|
+
const message =
|
|
228
384
|
state === "revoked"
|
|
229
|
-
? `commit ${commit.slice(0, 12)} has a
|
|
230
|
-
: ignored.some((t) => t.tag.startsWith(
|
|
231
|
-
? `commit ${commit.slice(0, 12)} has no
|
|
232
|
-
: `commit ${commit.slice(0, 12)} has no
|
|
233
|
-
|
|
234
|
-
)
|
|
385
|
+
? `commit ${commit.slice(0, 12)} has a ${revokedTag} tag: it went red after it was green, so no release is cut from it`
|
|
386
|
+
: ignored.some((t) => t.tag.startsWith(`${greenTag}/`))
|
|
387
|
+
? `commit ${commit.slice(0, 12)} has no ${greenTag} tag that counts, so no release is cut from it${why}`
|
|
388
|
+
: `commit ${commit.slice(0, 12)} has no ${greenTag} tag, so no release is cut from it`;
|
|
389
|
+
const fix = `Check out a green commit (\`chant ci last-green${lane !== null ? ` --lane ${lane}` : ""}\` names the newest) after fetching the tags: git fetch origin --tags`;
|
|
390
|
+
if (state === "revoked") {
|
|
391
|
+
throw new ReleaseCutError("release-commit-revoked", req.overrideGreen ? `${message}, and an override does not cut a revoked commit` : message, fix);
|
|
392
|
+
}
|
|
393
|
+
if (!req.overrideGreen) throw new ReleaseCutError("release-commit-not-green", message, fix);
|
|
394
|
+
// #4693: a person's override of this commit lets it through.
|
|
395
|
+
const now = (req.now ?? (() => new Date()))().toISOString();
|
|
396
|
+
const decided = await greenOverride({ top, cwd, commit, lane, sealed: releaseRule.requirement !== null, record, now });
|
|
397
|
+
if (decided.override === null) throw new ReleaseCutError("release-commit-not-green", `${message}; ${decided.why}`, decided.fix, decided.recorded);
|
|
398
|
+
override = { green: false, tag: `${greenTag}/${commit}`, ...decided.override };
|
|
235
399
|
}
|
|
236
|
-
// Who may cut is the declaration's identity.gates.release, read at base.
|
|
237
|
-
const releaseRule = releaseRuleFrom(source);
|
|
238
400
|
if (releaseRule.requirement && req.sign === undefined) {
|
|
239
401
|
throw new ReleaseCutError(
|
|
240
402
|
"release-unsigned",
|
|
@@ -323,6 +485,8 @@ async function prepare(req: CutRequest): Promise<Prepared> {
|
|
|
323
485
|
carried: artifacts,
|
|
324
486
|
reused,
|
|
325
487
|
member: ledger.members.length > 0 ? ledger.members.join("/") : null,
|
|
488
|
+
lane,
|
|
489
|
+
override,
|
|
326
490
|
};
|
|
327
491
|
}
|
|
328
492
|
|
|
@@ -371,6 +535,10 @@ export interface CutPlan {
|
|
|
371
535
|
publishSteps: Array<{ component: string; kind: string; to: string | null; envs: string[] }>;
|
|
372
536
|
/** Whether the release gate in identity.gates requires a signed cut. */
|
|
373
537
|
signatureRequired: boolean;
|
|
538
|
+
/** The green lane the commit was checked in (#4692), or null for the full green tag. */
|
|
539
|
+
lane: string | null;
|
|
540
|
+
/** The override the cut would run under and spend (#4693), when the commit is not green; null when it is. */
|
|
541
|
+
override: ReleaseCutOverride | null;
|
|
374
542
|
}
|
|
375
543
|
|
|
376
544
|
/**
|
|
@@ -439,6 +607,8 @@ export async function planRelease(req: CutRequest): Promise<CutPlan> {
|
|
|
439
607
|
reused: p.reused,
|
|
440
608
|
publishSteps: [...steps.values()],
|
|
441
609
|
signatureRequired: p.releaseRule.requirement !== null,
|
|
610
|
+
lane: p.lane,
|
|
611
|
+
override: p.override,
|
|
442
612
|
};
|
|
443
613
|
}
|
|
444
614
|
|
|
@@ -448,14 +618,16 @@ export async function planRelease(req: CutRequest): Promise<CutPlan> {
|
|
|
448
618
|
* push. Throws {@link ReleaseCutError} before anything is written when the
|
|
449
619
|
* commit isn't green, the tree is dirty, or an environment can't be compiled
|
|
450
620
|
* to the same artifacts, and `ReleaseLabelError` (./release-store.ts) when the
|
|
451
|
-
* label is taken or the release already carries another one.
|
|
621
|
+
* label is taken or the release already carries another one. The one write
|
|
622
|
+
* before a refusal is the request for an override (#4693), when the cut asks
|
|
623
|
+
* for one and none stands; the error's `recorded` says so.
|
|
452
624
|
*
|
|
453
625
|
* The cut line names its run (#4027): the CI run's id and origin in CI, and
|
|
454
626
|
* outside CI an id minted from the cut's time, `local-<epoch ms>`, with the
|
|
455
627
|
* origin `{ forge: "local" }`.
|
|
456
628
|
*/
|
|
457
629
|
export async function cutRelease(req: CutRequest): Promise<CutResult> {
|
|
458
|
-
const p = await prepare(req);
|
|
630
|
+
const p = await prepare(req, true);
|
|
459
631
|
const { cwd, commit, compiled, releaseRule, reused } = p;
|
|
460
632
|
const artifacts = [...p.carried];
|
|
461
633
|
for (const env of p.envs) {
|
|
@@ -496,17 +668,26 @@ export async function cutRelease(req: CutRequest): Promise<CutResult> {
|
|
|
496
668
|
}
|
|
497
669
|
const stored = await persistRelease(release, templates, { cwd });
|
|
498
670
|
const ci = resolveCiRun(req.env ?? process.env);
|
|
671
|
+
const runId = ci?.runId ?? `local-${Date.parse(timestamp)}`;
|
|
672
|
+
// #4693: the override is spent before the cut line names it, so it lets one cut through.
|
|
673
|
+
if (p.override) {
|
|
674
|
+
const { appliedOverride } = await import("../override-gate");
|
|
675
|
+
const { recordOverridesApplied } = await import("./override-ledger");
|
|
676
|
+
await recordOverridesApplied([appliedOverride({ subject: greenOverrideSubject(commit), digest: p.override.digest, at: p.override.at, by: p.override.by }, { timestamp, runId, commit })], { cwd });
|
|
677
|
+
}
|
|
499
678
|
const outcome = await appendCut(
|
|
500
679
|
{
|
|
501
680
|
releaseDigest: release.releaseDigest,
|
|
502
681
|
label: req.label,
|
|
503
682
|
actor: req.actor,
|
|
504
683
|
timestamp,
|
|
505
|
-
runId
|
|
684
|
+
runId,
|
|
506
685
|
runOrigin: ci?.runOrigin ?? { forge: "local" },
|
|
507
686
|
signature,
|
|
508
687
|
...(req.composed ? { composed: req.composed } : {}),
|
|
509
688
|
...(req.channel ? { channel: req.channel } : {}),
|
|
689
|
+
...(p.lane !== null ? { lane: p.lane } : {}),
|
|
690
|
+
...(p.override ? { override: p.override } : {}),
|
|
510
691
|
},
|
|
511
692
|
{ cwd },
|
|
512
693
|
);
|
|
@@ -84,6 +84,8 @@ export interface PublishItem {
|
|
|
84
84
|
digest?: string;
|
|
85
85
|
/** True when the destination already held it, so nothing was uploaded. */
|
|
86
86
|
present?: boolean;
|
|
87
|
+
/** True when the destination refused it and the target turns a refusal into a warning (a marketplace's `onRefusal: "warn"`, #4698), so it was not published. */
|
|
88
|
+
refused?: boolean;
|
|
87
89
|
/** Set on a file attached to what the target publishes (#4049): an SBOM or the release's provenance statement. */
|
|
88
90
|
attachment?: "sbom" | "provenance";
|
|
89
91
|
/** The SBOM file an npm package carries at its root (#4049). */
|
|
@@ -121,14 +123,27 @@ export interface PublishedTarget {
|
|
|
121
123
|
destination: string;
|
|
122
124
|
/** Each thing published, in order. */
|
|
123
125
|
items: PublishItem[];
|
|
126
|
+
/**
|
|
127
|
+
* Set when the destination refused the reveal and the target declares that
|
|
128
|
+
* a warning (#4698): why, with the items `refused`. The publish goes on, and
|
|
129
|
+
* the target is not recorded as revealed, so the same publish run again
|
|
130
|
+
* reveals it again.
|
|
131
|
+
*/
|
|
132
|
+
warning?: string;
|
|
124
133
|
}
|
|
125
134
|
|
|
126
135
|
/** Injected into the targets, so tests drive them with fakes. */
|
|
127
136
|
export interface PublishDeps {
|
|
128
|
-
/** The HTTP client the OCI and
|
|
137
|
+
/** The HTTP client the OCI, forge, homebrew, marketplace and tauri-updater targets use. Default: the global `fetch`. */
|
|
129
138
|
fetch?: PublishFetch;
|
|
130
139
|
/** The npm executable. Default: `npm` on `PATH`. */
|
|
131
140
|
npm?: string;
|
|
141
|
+
/** The vsce executable the VS Code Marketplace target runs (#4676). Default: `vsce` on `PATH`. */
|
|
142
|
+
vsce?: string;
|
|
143
|
+
/** The git executable the homebrew target runs to push over SSH (#4699). Default: `git` on `PATH`. */
|
|
144
|
+
git?: string;
|
|
145
|
+
/** The ssh executable git runs for it (#4699). Default: `ssh` on `PATH`. */
|
|
146
|
+
ssh?: string;
|
|
132
147
|
/** How a target waits between polls of a registry (#4244). Default: a timer. */
|
|
133
148
|
sleep?: (ms: number) => Promise<void>;
|
|
134
149
|
/** The clock a target's wait reads (#4244). Default: `Date.now`. */
|
|
@@ -139,7 +154,7 @@ export interface PublishDeps {
|
|
|
139
154
|
export type PublishFetch = (
|
|
140
155
|
url: string,
|
|
141
156
|
init: { method: string; headers: Record<string, string>; body?: Uint8Array | string; redirect?: "follow" | "manual" },
|
|
142
|
-
) => Promise<{ ok: boolean; status: number; headers: { get(name: string): string | null }; text(): Promise<string> }>;
|
|
157
|
+
) => Promise<{ ok: boolean; status: number; headers: { get(name: string): string | null }; text(): Promise<string>; arrayBuffer?(): Promise<ArrayBuffer> }>;
|
|
143
158
|
|
|
144
159
|
/**
|
|
145
160
|
* The part of a target's context every kind of target is given, whatever it
|
|
@@ -200,7 +215,7 @@ export class PublishTargetError extends Error {
|
|
|
200
215
|
}
|
|
201
216
|
|
|
202
217
|
/** The kinds `release.publish` declares and `createPublishTargets` makes. */
|
|
203
|
-
export type ReleasePublishKind = "npm" | "oci" | "forge";
|
|
218
|
+
export type ReleasePublishKind = "npm" | "oci" | "forge" | "homebrew" | "marketplace" | "tauri-updater";
|
|
204
219
|
|
|
205
220
|
/** The npm dist-tag a set of packages is staged under before `latest` moves (#4048), as chant's own releases do (#3903). */
|
|
206
221
|
export const NPM_STAGE_TAG = "next";
|
|
@@ -611,6 +626,11 @@ export async function runPublish(req: {
|
|
|
611
626
|
return fail(err, target, "reveal", stagedNames, revealedNames);
|
|
612
627
|
}
|
|
613
628
|
published.push(p);
|
|
629
|
+
if (p.warning) {
|
|
630
|
+
// Refused, and the target makes that a warning (#4698): not recorded, so a run of the same publish tries it again.
|
|
631
|
+
say(` warning: ${target.name}: ${p.warning}`);
|
|
632
|
+
continue;
|
|
633
|
+
}
|
|
614
634
|
revealedNames.push(target.name);
|
|
615
635
|
await write(target, "revealed", p.items, {});
|
|
616
636
|
}
|
|
@@ -49,17 +49,18 @@ function tryGit(top: string, args: string[]): string | null {
|
|
|
49
49
|
/**
|
|
50
50
|
* The ci tags at `top`, judged against `green` at base: the green branch's
|
|
51
51
|
* tip on `origin`, else the local branch, else `HEAD`. With no `ci.green`
|
|
52
|
-
* every tag counts.
|
|
53
|
-
* `ci
|
|
52
|
+
* every tag counts. With `lane` (#4692), that lane's tags, `ci/green-<lane>/`
|
|
53
|
+
* and `ci/revoked-<lane>/`. Throws `WorkspaceReadError` (`declaration-invalid`)
|
|
54
|
+
* when `ci.green.signedSince` names no commit here.
|
|
54
55
|
*/
|
|
55
|
-
export async function judgedCiTags(top: string, green: CiGreen | null): Promise<CiTags> {
|
|
56
|
+
export async function judgedCiTags(top: string, green: CiGreen | null, lane?: string): Promise<CiTags> {
|
|
56
57
|
const { readCiTags } = await import("../workspace/ci-green");
|
|
57
58
|
const base = green
|
|
58
59
|
? (tryGit(top, ["rev-parse", "--verify", "--quiet", `refs/remotes/origin/${green.branch}^{commit}`]) ??
|
|
59
60
|
tryGit(top, ["rev-parse", "--verify", "--quiet", `refs/heads/${green.branch}^{commit}`]) ??
|
|
60
61
|
tryGit(top, ["rev-parse", "HEAD"]))
|
|
61
62
|
: null;
|
|
62
|
-
return readCiTags(top, green, base);
|
|
63
|
+
return readCiTags(top, green, base, lane);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|