@intentius/chant 0.124.85 → 0.124.87
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/bundle-check.d.ts +102 -0
- package/dist/bundle-check.d.ts.map +1 -0
- package/dist/bundle-check.js +310 -0
- package/dist/chant-install.d.ts +100 -0
- package/dist/chant-install.d.ts.map +1 -0
- package/dist/chant-install.js +158 -0
- package/dist/ci-commit.d.ts +19 -6
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +23 -4
- package/dist/ci-evidence-jobs.d.ts +78 -0
- package/dist/ci-evidence-jobs.d.ts.map +1 -0
- package/dist/ci-evidence-jobs.js +85 -0
- package/dist/ci-image.d.ts +274 -0
- package/dist/ci-image.d.ts.map +1 -0
- package/dist/ci-image.js +635 -0
- package/dist/ci-login.d.ts +150 -0
- package/dist/ci-login.d.ts.map +1 -0
- package/dist/ci-login.js +240 -0
- package/dist/ci-product.d.ts +16 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +17 -0
- package/dist/cli/commands/import-index.js +2 -2
- package/dist/cli/handlers/build.d.ts +8 -0
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +22 -4
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +61 -2
- package/dist/cli/handlers/ci-evidence.d.ts +3 -0
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -0
- package/dist/cli/handlers/ci-evidence.js +174 -0
- package/dist/cli/handlers/components.js +3 -3
- package/dist/cli/handlers/dead-guards.d.ts +3 -0
- package/dist/cli/handlers/dead-guards.d.ts.map +1 -0
- package/dist/cli/handlers/dead-guards.js +35 -0
- package/dist/cli/handlers/graph.js +4 -4
- package/dist/cli/handlers/lifecycle.d.ts +2 -1
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +5 -4
- package/dist/cli/handlers/local-chant.d.ts +16 -0
- package/dist/cli/handlers/local-chant.d.ts.map +1 -0
- package/dist/cli/handlers/local-chant.js +109 -0
- package/dist/cli/handlers/operator.js +2 -2
- package/dist/cli/handlers/search.js +5 -5
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +38 -0
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +28 -0
- package/dist/cli/registry.d.ts +16 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/check-hooks.d.ts +49 -0
- package/dist/components/check-hooks.d.ts.map +1 -1
- package/dist/components/check-hooks.js +64 -4
- package/dist/components/check-steps.d.ts +17 -0
- package/dist/components/check-steps.d.ts.map +1 -1
- package/dist/components/check-steps.js +37 -5
- package/dist/components/product-pipeline.d.ts +23 -0
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +6 -2
- package/dist/components/product-plan.d.ts +143 -0
- package/dist/components/product-plan.d.ts.map +1 -0
- package/dist/components/product-plan.js +145 -0
- package/dist/components/release-compile.d.ts.map +1 -1
- package/dist/components/release-compile.js +2 -2
- package/dist/config.d.ts +39 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -3
- package/dist/dead-guards.d.ts +82 -0
- package/dist/dead-guards.d.ts.map +1 -0
- package/dist/dead-guards.js +436 -0
- package/dist/discovery/files.d.ts +3 -1
- package/dist/discovery/files.d.ts.map +1 -1
- package/dist/discovery/files.js +5 -3
- package/dist/drift-issue.d.ts +152 -0
- package/dist/drift-issue.d.ts.map +1 -0
- package/dist/drift-issue.js +167 -0
- package/dist/floor-table.d.ts +30 -0
- package/dist/floor-table.d.ts.map +1 -0
- package/dist/floor-table.data.d.ts +3 -0
- package/dist/floor-table.data.d.ts.map +1 -0
- package/dist/floor-table.data.js +179 -0
- package/dist/floor-table.js +56 -0
- package/dist/forge-flags.d.ts +90 -0
- package/dist/forge-flags.d.ts.map +1 -0
- package/dist/forge-flags.js +184 -0
- package/dist/lexicon.d.ts +69 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gated-op.d.ts +7 -1
- package/dist/lifecycle/gated-op.d.ts.map +1 -1
- package/dist/lifecycle/gated-op.js +7 -4
- package/dist/local-chant.d.ts +98 -0
- package/dist/local-chant.d.ts.map +1 -0
- package/dist/local-chant.js +307 -0
- package/dist/op/activities/predict-behaviour.js +2 -2
- package/dist/op/op-waves-evidence-spec.d.ts +13 -0
- package/dist/op/op-waves-evidence-spec.d.ts.map +1 -0
- package/dist/op/op-waves-evidence-spec.js +21 -0
- package/dist/op/op-waves-evidence.d.ts +40 -0
- package/dist/op/op-waves-evidence.d.ts.map +1 -0
- package/dist/op/op-waves-evidence.js +58 -0
- package/dist/op/op-waves-run.d.ts +4 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +24 -1
- package/dist/op/op-waves.d.ts +17 -1
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +23 -0
- package/dist/op/schedule-overdue.d.ts +41 -9
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +154 -25
- package/dist/plan-summary.d.ts +25 -0
- package/dist/plan-summary.d.ts.map +1 -1
- package/dist/plan-summary.js +31 -0
- package/dist/pr-plan-note.d.ts +35 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +10 -0
- package/dist/pr-post.d.ts +23 -0
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +125 -3
- package/dist/release-floors.d.ts +33 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +33 -1
- package/dist/state-migration.d.ts +24 -0
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +100 -5
- package/dist/wave-runtime.mjs +309 -302
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +4 -3
- package/dist/workspace/lexicon-outputs.d.ts.map +1 -1
- package/dist/workspace/lexicon-outputs.js +21 -7
- package/dist/workspace/reason-codes.d.ts +3 -0
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/reason-codes.js +4 -0
- package/dist/workspace/ref-gate.schema.json +85 -0
- package/dist/workspace/search-contract.d.ts +1 -1
- package/dist/workspace/search-contract.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.d.ts +58 -0
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -0
- package/dist/workspace/trust/check-evidence-report.js +109 -0
- package/dist/workspace/trust/check-evidence.d.ts +160 -0
- package/dist/workspace/trust/check-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/check-evidence.js +309 -0
- package/dist/workspace/trust/ci-tag-statement.d.ts +2 -2
- package/dist/workspace/trust/ci-tag-statement.d.ts.map +1 -1
- package/dist/workspace/trust/dsse.d.ts +40 -2
- package/dist/workspace/trust/dsse.d.ts.map +1 -1
- package/dist/workspace/trust/dsse.js +34 -2
- package/dist/workspace/trust/evidence.d.ts +2 -2
- package/dist/workspace/trust/evidence.d.ts.map +1 -1
- package/dist/workspace/trust/keyless-fixture.d.ts +41 -0
- package/dist/workspace/trust/keyless-fixture.d.ts.map +1 -0
- package/dist/workspace/trust/keyless-fixture.js +161 -0
- package/dist/workspace/trust/keyless.d.ts +202 -0
- package/dist/workspace/trust/keyless.d.ts.map +1 -0
- package/dist/workspace/trust/keyless.js +488 -0
- package/dist/workspace/trust/local-evidence.d.ts +123 -0
- package/dist/workspace/trust/local-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/local-evidence.js +259 -0
- package/dist/workspace/trust/op-run-statement.d.ts +2 -2
- package/dist/workspace/trust/op-run-statement.d.ts.map +1 -1
- package/dist/workspace/trust/policy.d.ts +140 -1
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +197 -3
- package/dist/workspace/trust/ref-gate-cli.d.ts +33 -0
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate-cli.js +234 -0
- package/dist/workspace/trust/ref-gate-fixture.d.ts +38 -0
- package/dist/workspace/trust/ref-gate-fixture.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate-fixture.js +97 -0
- package/dist/workspace/trust/ref-gate.d.ts +187 -0
- package/dist/workspace/trust/ref-gate.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate.js +432 -0
- package/dist/workspace/trust/run-statement.d.ts +3 -3
- package/dist/workspace/trust/run-statement.d.ts.map +1 -1
- package/dist/workspace/trust/runner-identity.d.ts +56 -0
- package/dist/workspace/trust/runner-identity.d.ts.map +1 -0
- package/dist/workspace/trust/runner-identity.js +65 -0
- package/dist/workspace/trust/trust-files.d.ts.map +1 -1
- package/dist/workspace/trust/trust-files.js +25 -1
- package/package.json +1 -1
- package/src/bundle-check.test.ts +140 -0
- package/src/bundle-check.ts +352 -0
- package/src/chant-install.test.ts +112 -0
- package/src/chant-install.ts +179 -0
- package/src/ci-commit.test.ts +45 -0
- package/src/ci-commit.ts +38 -4
- package/src/ci-evidence-jobs.ts +105 -0
- package/src/ci-image.test.ts +506 -0
- package/src/ci-image.ts +822 -0
- package/src/ci-login.test.ts +235 -0
- package/src/ci-login.ts +307 -0
- package/src/ci-product.ts +18 -0
- package/src/cli/commands/__fixtures__/source-dir-include/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-include/infra.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-include/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-root/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/infra.test.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/infra.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/app.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/infra/net.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/import-index.ts +2 -2
- package/src/cli/handlers/build-source-dir.test.ts +64 -0
- package/src/cli/handlers/build.ts +21 -4
- package/src/cli/handlers/ci-check.ts +60 -3
- package/src/cli/handlers/ci-evidence.ts +167 -0
- package/src/cli/handlers/components.ts +3 -3
- package/src/cli/handlers/dead-guards.ts +37 -0
- package/src/cli/handlers/graph.ts +4 -4
- package/src/cli/handlers/lifecycle.ts +5 -4
- package/src/cli/handlers/local-chant.ts +106 -0
- package/src/cli/handlers/operator.ts +2 -2
- package/src/cli/handlers/search.ts +5 -5
- package/src/cli/main.test.ts +7 -0
- package/src/cli/main.ts +38 -0
- package/src/cli/parse-args.ts +21 -0
- package/src/cli/registry.ts +16 -0
- package/src/components/check-evidence-stage.test.ts +80 -0
- package/src/components/check-hooks.ts +84 -4
- package/src/components/check-local-evidence-stage.test.ts +141 -0
- package/src/components/check-steps.ts +56 -6
- package/src/components/product-pipeline.ts +28 -3
- package/src/components/product-plan.test.ts +87 -0
- package/src/components/product-plan.ts +230 -0
- package/src/components/release-compile.ts +2 -2
- package/src/config.ts +44 -3
- package/src/dead-guards.test.ts +206 -0
- package/src/dead-guards.ts +446 -0
- package/src/discovery/files.ts +5 -3
- package/src/drift-issue-bundle.test.ts +31 -0
- package/src/drift-issue.test.ts +206 -0
- package/src/drift-issue.ts +274 -0
- package/src/fit-note.test.ts +44 -0
- package/src/floor-table.data.ts +181 -0
- package/src/floor-table.ts +77 -0
- package/src/forge-flags.test.ts +110 -0
- package/src/forge-flags.ts +208 -0
- package/src/gate-decision-bundle.test.ts +1 -0
- package/src/lexicon.ts +68 -0
- package/src/lifecycle/gated-op.ts +10 -5
- package/src/local-chant.e2e.test.ts +94 -0
- package/src/local-chant.test.ts +162 -0
- package/src/local-chant.ts +341 -0
- package/src/op/activities/predict-behaviour.ts +2 -2
- package/src/op/op-waves-evidence-spec.ts +24 -0
- package/src/op/op-waves-evidence.test.ts +130 -0
- package/src/op/op-waves-evidence.ts +58 -0
- package/src/op/op-waves-run.ts +25 -1
- package/src/op/op-waves.ts +31 -1
- package/src/op/schedule-overdue.test.ts +85 -0
- package/src/op/schedule-overdue.ts +162 -26
- package/src/plan-summary.ts +40 -0
- package/src/pr-plan-note.ts +34 -0
- package/src/pr-post-plan-note.test.ts +146 -0
- package/src/pr-post.ts +127 -3
- package/src/release-floors.ts +47 -1
- package/src/stage-hooks-bundle.test.ts +1 -0
- package/src/state-migration.test.ts +52 -1
- package/src/state-migration.ts +107 -5
- package/src/workspace/ci-green.ts +4 -3
- package/src/workspace/lexicon-outputs.ts +23 -6
- package/src/workspace/reason-codes.test.ts +3 -0
- package/src/workspace/reason-codes.ts +4 -0
- package/src/workspace/ref-gate.schema.json +85 -0
- package/src/workspace/trust/check-evidence-report.ts +115 -0
- package/src/workspace/trust/check-evidence.test.ts +133 -0
- package/src/workspace/trust/check-evidence.ts +327 -0
- package/src/workspace/trust/ci-tag-statement.ts +2 -2
- package/src/workspace/trust/dsse.ts +48 -4
- package/src/workspace/trust/evidence.ts +2 -2
- package/src/workspace/trust/keyless-fixture.ts +214 -0
- package/src/workspace/trust/keyless.test.ts +220 -0
- package/src/workspace/trust/keyless.ts +557 -0
- package/src/workspace/trust/local-evidence.test.ts +127 -0
- package/src/workspace/trust/local-evidence.ts +268 -0
- package/src/workspace/trust/op-run-statement.ts +2 -2
- package/src/workspace/trust/policy.ts +263 -3
- package/src/workspace/trust/ref-gate-cli.ts +244 -0
- package/src/workspace/trust/ref-gate-fixture.ts +125 -0
- package/src/workspace/trust/ref-gate.e2e.test.ts +76 -0
- package/src/workspace/trust/ref-gate.test.ts +247 -0
- package/src/workspace/trust/ref-gate.ts +539 -0
- package/src/workspace/trust/run-statement.ts +3 -3
- package/src/workspace/trust/runner-identity.ts +92 -0
- package/src/workspace/trust/trust-files.test.ts +22 -0
- package/src/workspace/trust/trust-files.ts +54 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test support for the ref gate (#4867): a checkout and a bare remote, a
|
|
3
|
+
* runner key, fake runner evidence signed with it, and override lines on
|
|
4
|
+
* `chant/lifecycle`. Isolated from the user's git config. The temporary
|
|
5
|
+
* directories are left in the system's temp directory.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { execFileSync } from "node:child_process";
|
|
9
|
+
import { generateKeyPairSync } from "node:crypto";
|
|
10
|
+
import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
import { dirname, join } from "node:path";
|
|
13
|
+
import { loadRunnerKey } from "./dsse";
|
|
14
|
+
import { buildStatement, signEvidence } from "./evidence";
|
|
15
|
+
import { attachEvidence, EVIDENCE_NOTES_REF, refGateSubject } from "./ref-gate";
|
|
16
|
+
import { OVERRIDE_OP, overrideDigest } from "../../override-gate";
|
|
17
|
+
|
|
18
|
+
export interface RunnerKeyPair {
|
|
19
|
+
pem: string;
|
|
20
|
+
pub: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function runnerKey(): RunnerKeyPair {
|
|
24
|
+
const { privateKey } = generateKeyPairSync("ed25519");
|
|
25
|
+
const pem = privateKey.export({ format: "pem", type: "pkcs8" }).toString();
|
|
26
|
+
return { pem, pub: loadRunnerKey(pem).publicKey };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const RUNNER = "ci@example.test";
|
|
30
|
+
|
|
31
|
+
export class GateRepos {
|
|
32
|
+
readonly root: string;
|
|
33
|
+
readonly work: string;
|
|
34
|
+
readonly origin: string;
|
|
35
|
+
readonly home: string;
|
|
36
|
+
|
|
37
|
+
constructor(label: string) {
|
|
38
|
+
this.root = mkdtempSync(join(tmpdir(), `chant-4867-${label}-`));
|
|
39
|
+
this.work = join(this.root, "work");
|
|
40
|
+
this.origin = join(this.root, "origin.git");
|
|
41
|
+
this.home = join(this.root, "home");
|
|
42
|
+
mkdirSync(this.home);
|
|
43
|
+
this.run(this.root, ["init", "-q", "--bare", "-b", "main", this.origin]);
|
|
44
|
+
this.run(this.root, ["init", "-q", "-b", "main", this.work]);
|
|
45
|
+
this.git(["remote", "add", "origin", this.origin]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
env(): NodeJS.ProcessEnv {
|
|
49
|
+
return {
|
|
50
|
+
PATH: process.env.PATH ?? "",
|
|
51
|
+
HOME: this.home,
|
|
52
|
+
GIT_CONFIG_GLOBAL: join(this.home, "gitconfig"),
|
|
53
|
+
GIT_CONFIG_NOSYSTEM: "1",
|
|
54
|
+
GIT_AUTHOR_NAME: "t",
|
|
55
|
+
GIT_AUTHOR_EMAIL: "t@example.test",
|
|
56
|
+
GIT_COMMITTER_NAME: "t",
|
|
57
|
+
GIT_COMMITTER_EMAIL: "t@example.test",
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
run(cwd: string, args: string[], input?: string): string {
|
|
62
|
+
return execFileSync("git", args, { cwd, env: this.env(), input, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
git(args: string[], input?: string): string {
|
|
66
|
+
return this.run(this.work, args, input);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
write(path: string, text: string): void {
|
|
70
|
+
mkdirSync(dirname(join(this.work, path)), { recursive: true });
|
|
71
|
+
writeFileSync(join(this.work, path), text);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
commit(message: string): string {
|
|
75
|
+
this.git(["add", "-A"]);
|
|
76
|
+
this.git(["commit", "-q", "--no-gpg-sign", "--allow-empty", "-m", message]);
|
|
77
|
+
return this.git(["rev-parse", "HEAD"]).trim();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Push `refspecs` to the bare remote with no hook in the way, and return git's output. */
|
|
81
|
+
push(...refspecs: string[]): string {
|
|
82
|
+
return this.run(this.work, ["push", "-q", "origin", ...refspecs]);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Sign evidence for `check` at `at` over `paths`, with `key`, and attach it to `to` (default `at`). */
|
|
86
|
+
sign(key: RunnerKeyPair, check: string, at: string, paths: string[], to = at): unknown {
|
|
87
|
+
const statement = buildStatement({ repo: this.work, commit: at, paths, runner: RUNNER, check });
|
|
88
|
+
const { key: k, publicKey } = loadRunnerKey(key.pem);
|
|
89
|
+
const envelope = signEvidence(statement, k, publicKey);
|
|
90
|
+
attachEvidence(this.work, to, envelope);
|
|
91
|
+
return envelope;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
notesTip(): string {
|
|
95
|
+
return this.git(["rev-parse", EVIDENCE_NOTES_REF]).trim();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Write `chant/lifecycle` holding a request for an override of `check` on `commit` and `by`'s override of it. */
|
|
99
|
+
override(commit: string, check: string, by: string, reason: string, at = "2026-11-09T10:00:00.000Z"): string {
|
|
100
|
+
const subject = refGateSubject(commit, check);
|
|
101
|
+
const digest = overrideDigest(subject, commit, [check]);
|
|
102
|
+
const pending = { version: 1, kind: "pending", op: OVERRIDE_OP, gate: subject, timestamp: "2026-11-09T09:00:00.000Z", expiresAt: "2026-11-12T09:00:00.000Z", planDigest: digest, plan: commit, rules: [check] };
|
|
103
|
+
const resolution = { version: 1, kind: "resolution", op: OVERRIDE_OP, gate: subject, resolvedBy: by, timestamp: at, note: reason, planDigest: digest };
|
|
104
|
+
const blob = this.git(["hash-object", "-w", "--stdin"], `${JSON.stringify(pending)}\n${JSON.stringify(resolution)}\n`).trim();
|
|
105
|
+
const gates = this.git(["mktree"], `100644 blob ${blob}\t${OVERRIDE_OP}.jsonl\n`).trim();
|
|
106
|
+
const tree = this.git(["mktree"], `040000 tree ${gates}\t_gates\n`).trim();
|
|
107
|
+
const c = this.git(["commit-tree", tree, "-m", "ledger"]).trim();
|
|
108
|
+
this.git(["update-ref", "refs/heads/chant/lifecycle", c]);
|
|
109
|
+
return c;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** `.chant/trust.json` with one runner and a ref rule for `refs/heads/main` and `refs/heads/release/*`. */
|
|
114
|
+
export function trustJson(runner: RunnerKeyPair, checks: Array<{ check: string; action?: "block" | "warn"; command: string }>, extra: Record<string, unknown> = {}): string {
|
|
115
|
+
return JSON.stringify(
|
|
116
|
+
{
|
|
117
|
+
schema: 1,
|
|
118
|
+
runners: [{ principal: RUNNER, class: "runner", key: runner.pub }],
|
|
119
|
+
refs: [{ ref: "refs/heads/main", checks }, { ref: "refs/heads/release/*", checks }],
|
|
120
|
+
...extra,
|
|
121
|
+
},
|
|
122
|
+
null,
|
|
123
|
+
2,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4867, end to end: chant's hooks on a bare repository and a checkout, with
|
|
3
|
+
* real `git push`. The pre-receive hook refuses a push to a protected ref
|
|
4
|
+
* whose commit has no current evidence for a `block` check, naming the check
|
|
5
|
+
* and its command, and admits it once the evidence is pushed with it. The
|
|
6
|
+
* pre-push hook refuses the same push before it leaves the checkout.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { spawnSync } from "node:child_process";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { pathToFileURL } from "node:url";
|
|
12
|
+
import { describe, expect, test } from "vitest";
|
|
13
|
+
import { REPO } from "../__fixtures__/contract-repo";
|
|
14
|
+
import { EVIDENCE_NOTES_REF } from "./ref-gate";
|
|
15
|
+
import { GateRepos, runnerKey, trustJson } from "./ref-gate-fixture";
|
|
16
|
+
|
|
17
|
+
const CHANT = `${process.execPath} --import ${pathToFileURL(join(REPO, "node_modules/tsx/dist/loader.mjs")).href} ${join(REPO, "packages/core/src/cli/main.ts")}`;
|
|
18
|
+
|
|
19
|
+
function chant(r: GateRepos, cwd: string, argv: string[]) {
|
|
20
|
+
return spawnSync("/bin/sh", ["-c", `${CHANT} "$@"`, "chant", ...argv], { cwd, env: r.env(), encoding: "utf-8" });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function setup(label: string) {
|
|
24
|
+
const r = new GateRepos(label);
|
|
25
|
+
const ci = runnerKey();
|
|
26
|
+
r.write(".chant/trust.json", trustJson(ci, [{ check: "plan", command: "chant ci run plan" }, { check: "policy", command: "chant ci run policy" }]));
|
|
27
|
+
r.write("records/n1.md", "one\n");
|
|
28
|
+
const base = r.commit("policy");
|
|
29
|
+
r.push("main");
|
|
30
|
+
r.write("app/a.txt", "change\n");
|
|
31
|
+
const head = r.commit("a change");
|
|
32
|
+
return { r, ci, base, head };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const push = (r: GateRepos, ...refspecs: string[]) => spawnSync("git", ["push", "origin", ...refspecs], { cwd: r.work, env: r.env(), encoding: "utf-8" });
|
|
36
|
+
|
|
37
|
+
describe("the ref gate's hooks", () => {
|
|
38
|
+
test("a bare repository with chant's pre-receive hook refuses a push without evidence and admits it with", () => {
|
|
39
|
+
const { r, ci, base, head } = setup("e2e-receive");
|
|
40
|
+
const installed = chant(r, r.work, ["workspace", "ref-gate", "install", "--hook", "pre-receive", "--git-dir", r.origin, "--chant", CHANT]);
|
|
41
|
+
expect(installed.status, installed.stderr).toBe(0);
|
|
42
|
+
|
|
43
|
+
const refused = push(r, `${head}:refs/heads/main`);
|
|
44
|
+
expect(refused.status).not.toBe(0);
|
|
45
|
+
expect(refused.stderr).toContain("refused refs/heads/main");
|
|
46
|
+
expect(refused.stderr).toContain("plan (missing)");
|
|
47
|
+
expect(refused.stderr).toContain("run: chant ci run plan");
|
|
48
|
+
expect(refused.stderr).toContain("run: chant ci run policy");
|
|
49
|
+
expect(r.run(r.origin, ["rev-parse", "main"]).trim()).toBe(base);
|
|
50
|
+
|
|
51
|
+
r.sign(ci, "plan", head, ["records/n1.md"]);
|
|
52
|
+
const half = push(r, EVIDENCE_NOTES_REF, `${head}:refs/heads/main`);
|
|
53
|
+
expect(half.status).not.toBe(0);
|
|
54
|
+
expect(half.stderr).toContain("run: chant ci run policy");
|
|
55
|
+
expect(half.stderr).not.toContain("run: chant ci run plan");
|
|
56
|
+
|
|
57
|
+
r.sign(ci, "policy", head, ["records/n1.md"]);
|
|
58
|
+
const admitted = push(r, EVIDENCE_NOTES_REF, `${head}:refs/heads/main`);
|
|
59
|
+
expect(admitted.status, admitted.stderr).toBe(0);
|
|
60
|
+
expect(r.run(r.origin, ["rev-parse", "main"]).trim()).toBe(head);
|
|
61
|
+
}, 60_000);
|
|
62
|
+
|
|
63
|
+
test("chant's pre-push hook refuses the same push before the network", () => {
|
|
64
|
+
const { r, ci, base, head } = setup("e2e-push");
|
|
65
|
+
const installed = chant(r, r.work, ["workspace", "ref-gate", "install", "--hook", "pre-push", "--chant", CHANT]);
|
|
66
|
+
expect(installed.status, installed.stderr).toBe(0);
|
|
67
|
+
const refused = push(r, `${head}:refs/heads/main`);
|
|
68
|
+
expect(refused.status).not.toBe(0);
|
|
69
|
+
expect(refused.stderr).toContain("run: chant ci run plan");
|
|
70
|
+
expect(r.run(r.origin, ["rev-parse", "main"]).trim()).toBe(base);
|
|
71
|
+
r.sign(ci, "plan", head, ["records/n1.md"]);
|
|
72
|
+
r.sign(ci, "policy", head, ["records/n1.md"]);
|
|
73
|
+
const admitted = push(r, EVIDENCE_NOTES_REF, `${head}:refs/heads/main`);
|
|
74
|
+
expect(admitted.status, admitted.stderr).toBe(0);
|
|
75
|
+
}, 60_000);
|
|
76
|
+
});
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4867: the ref gate refuses a ref update whose commit lacks current runner
|
|
3
|
+
* evidence for a check the policy at base requires, and admits it once the
|
|
4
|
+
* evidence is attached. The attacker controls the change: records edited
|
|
5
|
+
* after signing, a runner key the change itself adds, a policy the change
|
|
6
|
+
* loosens, and one override used for two updates. Evidence is fake: signed
|
|
7
|
+
* here with a throwaway runner key, never by a real CI job.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { describe, expect, test } from "vitest";
|
|
12
|
+
import { contract } from "../__fixtures__/contract-repo";
|
|
13
|
+
import refGateSchema from "../ref-gate.schema.json";
|
|
14
|
+
import { REF_GATE_OUTPUT_SCHEMA_ID, postRefGateStatus, refGateHook } from "./ref-gate-cli";
|
|
15
|
+
import {
|
|
16
|
+
decideRefUpdate,
|
|
17
|
+
describeDecision,
|
|
18
|
+
EVIDENCE_NOTES_REF,
|
|
19
|
+
parsePrePush,
|
|
20
|
+
parsePreReceive,
|
|
21
|
+
readRefGateLedger,
|
|
22
|
+
refPatternRegExp,
|
|
23
|
+
RefUpdateInputError,
|
|
24
|
+
rulesFor,
|
|
25
|
+
runPrePush,
|
|
26
|
+
runPreReceive,
|
|
27
|
+
} from "./ref-gate";
|
|
28
|
+
import { GateRepos, runnerKey, trustJson } from "./ref-gate-fixture";
|
|
29
|
+
|
|
30
|
+
const NOW = "2026-11-09T12:00:00.000Z";
|
|
31
|
+
const CHECKS = [
|
|
32
|
+
{ check: "plan", command: "chant ci run plan" },
|
|
33
|
+
{ check: "lint", action: "warn" as const, command: "npm run lint" },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
/** main at the remote holds the policy and two records; `head` is a change on top, pushed to a side branch so the remote holds its objects. */
|
|
37
|
+
function setup(label: string, opts: { overriders?: string } = {}) {
|
|
38
|
+
const r = new GateRepos(label);
|
|
39
|
+
const ci = runnerKey();
|
|
40
|
+
r.write(".chant/trust.json", trustJson(ci, CHECKS));
|
|
41
|
+
if (opts.overriders) r.write(".chant/overriders", `${opts.overriders}\n`);
|
|
42
|
+
r.write("records/n1.md", "one\n");
|
|
43
|
+
r.write("records/n2.md", "two\n");
|
|
44
|
+
const base = r.commit("policy and records");
|
|
45
|
+
r.push("main");
|
|
46
|
+
r.write("app/a.txt", "change\n");
|
|
47
|
+
const head = r.commit("a change");
|
|
48
|
+
r.push(`${head}:refs/heads/side`);
|
|
49
|
+
return { r, ci, base, head };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const line = (old: string, nu: string, ref: string) => `${old} ${nu} ${ref}\n`;
|
|
53
|
+
|
|
54
|
+
describe("ref patterns and rules", () => {
|
|
55
|
+
test("* matches within a segment and ** across them", () => {
|
|
56
|
+
expect(refPatternRegExp("refs/heads/release/*").test("refs/heads/release/1")).toBe(true);
|
|
57
|
+
expect(refPatternRegExp("refs/heads/release/*").test("refs/heads/release/1/x")).toBe(false);
|
|
58
|
+
expect(refPatternRegExp("refs/heads/**").test("refs/heads/a/b")).toBe(true);
|
|
59
|
+
expect(refPatternRegExp("refs/heads/main").test("refs/heads/mainline")).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("a check two rules name blocks when either blocks it", () => {
|
|
63
|
+
const r = rulesFor({ refs: [
|
|
64
|
+
{ ref: "refs/heads/*", checks: [{ check: "plan", action: "warn", command: "a" }] },
|
|
65
|
+
{ ref: "refs/heads/main", checks: [{ check: "plan", action: "block", command: "b" }], status: "acme/gate" },
|
|
66
|
+
] }, "refs/heads/main");
|
|
67
|
+
expect(r.checks).toEqual([{ check: "plan", action: "block", command: "a" }]);
|
|
68
|
+
expect(r.status).toBe("acme/gate");
|
|
69
|
+
expect(rulesFor({ refs: [] }, "refs/heads/main").matched).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("hook input is read strictly", () => {
|
|
73
|
+
const a = "a".repeat(40);
|
|
74
|
+
const z = "0".repeat(40);
|
|
75
|
+
expect(parsePreReceive(line(z, a, "refs/heads/main"))).toEqual([{ ref: "refs/heads/main", old: null, new: a }]);
|
|
76
|
+
expect(parsePrePush(`refs/heads/x ${a} refs/heads/main ${z}\n`)).toEqual([{ ref: "refs/heads/main", old: null, new: a }]);
|
|
77
|
+
expect(() => parsePreReceive("nonsense\n")).toThrow(RefUpdateInputError);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("the pre-receive decision", () => {
|
|
82
|
+
test("a block check with no evidence is refused, naming the check and its command, and admitted once evidence is attached", () => {
|
|
83
|
+
const { r, ci, base, head } = setup("admit");
|
|
84
|
+
const refused = runPreReceive(r.origin, line(base, head, "refs/heads/main"), { now: NOW });
|
|
85
|
+
expect(refused.ok).toBe(false);
|
|
86
|
+
const d = refused.decisions[0];
|
|
87
|
+
expect(d.base).toBe(base);
|
|
88
|
+
expect(d.checks.map((c) => [c.check, c.status, c.code])).toEqual([["plan", "missing", "ref-evidence-missing"], ["lint", "missing", "ref-evidence-missing"]]);
|
|
89
|
+
const text = describeDecision(d).join("\n");
|
|
90
|
+
expect(text).toContain("refused refs/heads/main");
|
|
91
|
+
expect(text).toContain("run: chant ci run plan");
|
|
92
|
+
expect(text).toContain("run: npm run lint");
|
|
93
|
+
expect(text).toMatch(/chant approve policy-override ref-gate-[0-9a-f]{12}-plan --rule plan --reason/);
|
|
94
|
+
|
|
95
|
+
// The warn check alone stays missing: it is said, and the update goes through.
|
|
96
|
+
r.sign(ci, "plan", head, ["records/n1.md", "records/n2.md"]);
|
|
97
|
+
r.push(EVIDENCE_NOTES_REF);
|
|
98
|
+
const admitted = runPreReceive(r.origin, line(base, head, "refs/heads/main"), { now: NOW });
|
|
99
|
+
expect(admitted.ok).toBe(true);
|
|
100
|
+
expect(admitted.decisions[0].checks.map((c) => [c.check, c.status])).toEqual([["plan", "current"], ["lint", "missing"]]);
|
|
101
|
+
expect(admitted.decisions[0].checks[0].runner).toBe("ci@example.test");
|
|
102
|
+
|
|
103
|
+
const ledger = readRefGateLedger(admitted.ledger);
|
|
104
|
+
expect(ledger.map((l) => [l.site, l.decision, l.push ?? null])).toEqual([["pre-receive", "refuse", "refused"], ["pre-receive", "admit", null]]);
|
|
105
|
+
expect(admitted.ledger).toBe(join(r.origin, "chant", "ref-gate.jsonl"));
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
test("evidence pushed with the ref, in the same push, counts", () => {
|
|
109
|
+
const { r, ci, base, head } = setup("same-push");
|
|
110
|
+
r.sign(ci, "plan", head, ["records/n1.md"]);
|
|
111
|
+
const notes = r.notesTip();
|
|
112
|
+
r.push(`${notes}:refs/heads/notes-objects`);
|
|
113
|
+
const d = runPreReceive(r.origin, line(base, head, "refs/heads/main") + line("0".repeat(40), notes, EVIDENCE_NOTES_REF), { now: NOW });
|
|
114
|
+
expect(d.ok).toBe(true);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("evidence whose records changed after signing is stale and refused", () => {
|
|
118
|
+
const { r, ci, base, head } = setup("stale");
|
|
119
|
+
r.write("records/n1.md", "one, edited\n");
|
|
120
|
+
const edited = r.commit("edit a record after the check ran");
|
|
121
|
+
r.push(`${edited}:refs/heads/side`);
|
|
122
|
+
// The envelope signed at `head` is carried to `edited`, as a pipeline that copies evidence forward would.
|
|
123
|
+
r.sign(ci, "plan", head, ["records/n1.md", "records/n2.md"], edited);
|
|
124
|
+
r.push(EVIDENCE_NOTES_REF);
|
|
125
|
+
const d = runPreReceive(r.origin, line(base, edited, "refs/heads/main"), { now: NOW }).decisions[0];
|
|
126
|
+
expect(d.decision).toBe("refuse");
|
|
127
|
+
expect(d.checks[0]).toMatchObject({ check: "plan", status: "stale", code: "ref-evidence-stale" });
|
|
128
|
+
expect(d.checks[0].reason).toContain("records/n1.md changed");
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
test("evidence over no records counts only for the tree it was signed over", () => {
|
|
132
|
+
const { r, ci, base, head } = setup("no-records");
|
|
133
|
+
r.write("app/a.txt", "changed again\n");
|
|
134
|
+
const next = r.commit("another change");
|
|
135
|
+
r.push(`${next}:refs/heads/side`);
|
|
136
|
+
r.sign(ci, "plan", head, [], next);
|
|
137
|
+
r.push(EVIDENCE_NOTES_REF);
|
|
138
|
+
expect(runPreReceive(r.origin, line(base, next, "refs/heads/main"), { now: NOW }).decisions[0].checks[0]).toMatchObject({ status: "stale", code: "ref-evidence-stale" });
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("a runner key the change itself adds signs nothing the gate counts", () => {
|
|
142
|
+
const { r, ci, base } = setup("added-key");
|
|
143
|
+
const mine = runnerKey();
|
|
144
|
+
r.write(".chant/trust.json", JSON.stringify({ schema: 1, runners: [{ principal: "ci@example.test", class: "runner", key: mine.pub }], refs: [] }));
|
|
145
|
+
const change = r.commit("swap the runner key and drop the rule");
|
|
146
|
+
r.push(`${change}:refs/heads/side`);
|
|
147
|
+
r.sign(mine, "plan", change, ["records/n1.md"]);
|
|
148
|
+
r.push(EVIDENCE_NOTES_REF);
|
|
149
|
+
const d = runPreReceive(r.origin, line(base, change, "refs/heads/main"), { now: NOW }).decisions[0];
|
|
150
|
+
// Judged by the policy at base: the rule still holds and the change's key is not a runner there.
|
|
151
|
+
expect(d.decision).toBe("refuse");
|
|
152
|
+
expect(d.checks[0]).toMatchObject({ check: "plan", status: "missing", code: "envelope-untrusted" });
|
|
153
|
+
void ci;
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test("an override admits one commit for one check once, and is spent", () => {
|
|
157
|
+
const { r, base, head } = setup("override", { overriders: "alice" });
|
|
158
|
+
// `setup` committed .chant/overriders with the policy, so it is at base.
|
|
159
|
+
r.override(head, "plan", "alice", "the plan job is down and this is a docs change");
|
|
160
|
+
r.push("chant/lifecycle");
|
|
161
|
+
const first = runPreReceive(r.origin, line(base, head, "refs/heads/main"), { now: NOW });
|
|
162
|
+
expect(first.ok).toBe(true);
|
|
163
|
+
expect(first.decisions[0].checks[0]).toMatchObject({ check: "plan", status: "overridden", override: { by: "alice" } });
|
|
164
|
+
|
|
165
|
+
const again = runPreReceive(r.origin, line("0".repeat(40), head, "refs/heads/release/1"), { now: NOW });
|
|
166
|
+
expect(again.ok).toBe(false);
|
|
167
|
+
expect(again.decisions[0].checks[0].status).toBe("missing");
|
|
168
|
+
expect(again.decisions[0].checks[0].reason).toMatch(/is spent/);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("one push may not spend an override on two refs", () => {
|
|
172
|
+
const { r, base, head } = setup("override-twice", { overriders: "alice" });
|
|
173
|
+
r.override(head, "plan", "alice", "docs only");
|
|
174
|
+
r.push("chant/lifecycle");
|
|
175
|
+
const both = runPreReceive(r.origin, line(base, head, "refs/heads/main") + line("0".repeat(40), head, "refs/heads/release/1"), { now: NOW });
|
|
176
|
+
expect(both.decisions.map((d) => d.decision)).toEqual(["admit", "refuse"]);
|
|
177
|
+
expect(both.ok).toBe(false);
|
|
178
|
+
// The push was refused as a whole, so the override is still unspent.
|
|
179
|
+
expect(runPreReceive(r.origin, line(base, head, "refs/heads/main"), { now: NOW }).ok).toBe(true);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test("an override by someone the overriders file does not list counts for nothing", () => {
|
|
183
|
+
const { r, base, head } = setup("override-unlisted", { overriders: "alice" });
|
|
184
|
+
r.override(head, "plan", "mallory", "trust me");
|
|
185
|
+
r.push("chant/lifecycle");
|
|
186
|
+
const d = runPreReceive(r.origin, line(base, head, "refs/heads/main"), { now: NOW }).decisions[0];
|
|
187
|
+
expect(d.decision).toBe("refuse");
|
|
188
|
+
expect(d.checks[0].reason).toContain("mallory is not listed in .chant/overriders");
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test("an unprotected ref, a deletion and a repository without a policy are admitted", () => {
|
|
192
|
+
const { r, base, head } = setup("unprotected");
|
|
193
|
+
expect(runPreReceive(r.origin, line(base, head, "refs/heads/feature"), { now: NOW }).ok).toBe(true);
|
|
194
|
+
expect(runPreReceive(r.origin, line(base, "0".repeat(40), "refs/heads/main"), { now: NOW }).ok).toBe(true);
|
|
195
|
+
expect(decideRefUpdate({ repo: r.work, update: { ref: "refs/heads/main", old: null, new: head }, base: null }).decision).toBe("admit");
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test("a policy at base that can't be read refuses every update", () => {
|
|
199
|
+
const r = new GateRepos("unreadable");
|
|
200
|
+
r.write(".chant/trust.json", "{ not json");
|
|
201
|
+
const base = r.commit("broken policy");
|
|
202
|
+
const d = decideRefUpdate({ repo: r.work, update: { ref: "refs/heads/main", old: base, new: base }, base });
|
|
203
|
+
expect(d.decision).toBe("refuse");
|
|
204
|
+
expect(d.error?.code).toBe("trust-policy-unreadable");
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
describe("the developer's side and the forge", () => {
|
|
209
|
+
test("pre-push refuses before the network, reading the policy at the remote's tip", () => {
|
|
210
|
+
const { r, ci, base, head } = setup("pre-push");
|
|
211
|
+
const input = `refs/heads/main ${head} refs/heads/main ${base}\n`;
|
|
212
|
+
const refused = runPrePush(r.work, input, { now: NOW });
|
|
213
|
+
expect(refused.ok).toBe(false);
|
|
214
|
+
expect(refused.decisions[0].base).toBe(base);
|
|
215
|
+
r.sign(ci, "plan", head, ["records/n1.md"]);
|
|
216
|
+
expect(runPrePush(r.work, input, { now: NOW }).ok).toBe(true);
|
|
217
|
+
// A pre-push spends nothing and is a line of the checkout's own ledger.
|
|
218
|
+
expect(readRefGateLedger(refused.ledger).map((l) => l.site)).toEqual(["pre-push", "pre-push"]);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
test("the same decision sets the required status: failure naming the missing check, then success", async () => {
|
|
222
|
+
const { r, ci, base, head } = setup("status");
|
|
223
|
+
const posted: Array<{ sha: string; context: string; state: string; description: string }> = [];
|
|
224
|
+
const forge = { setStatus: async (sha: string, s: { context: string; state: string; description: string }) => void posted.push({ sha, ...s }) };
|
|
225
|
+
const decide = () => decideRefUpdate({ repo: r.work, update: { ref: "refs/heads/main", old: base, new: head }, base, now: NOW });
|
|
226
|
+
await postRefGateStatus(forge, decide());
|
|
227
|
+
r.sign(ci, "plan", head, ["records/n1.md"]);
|
|
228
|
+
await postRefGateStatus(forge, decide());
|
|
229
|
+
expect(posted).toEqual([
|
|
230
|
+
{ sha: head, context: "chant/ref-gate", state: "failure", description: "missing evidence: plan (run chant ci run plan)" },
|
|
231
|
+
{ sha: head, context: "chant/ref-gate", state: "success", description: "evidence current" },
|
|
232
|
+
]);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
test("the hooks run chant with git's arguments and input", () => {
|
|
236
|
+
expect(refGateHook("pre-receive")).toBe('#!/bin/sh\n# chant ref gate (#4867)\nexec chant workspace ref-gate pre-receive "$@"\n');
|
|
237
|
+
expect(refGateHook("pre-push", "npx chant")).toContain("exec npx chant workspace ref-gate pre-push");
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
test("the --json document matches ref-gate.schema.json", () => {
|
|
241
|
+
const { r, base, head } = setup("schema");
|
|
242
|
+
const { expectValid } = contract(refGateSchema);
|
|
243
|
+
const decisions = runPreReceive(r.origin, line(base, head, "refs/heads/main"), { now: NOW }).decisions;
|
|
244
|
+
expectValid({ $schema: REF_GATE_OUTPUT_SCHEMA_ID, contract: 1, chant: "0.0.0", ok: false, decisions });
|
|
245
|
+
expectValid({ $schema: REF_GATE_OUTPUT_SCHEMA_ID, contract: 1, chant: "0.0.0", error: { code: "ref-update-invalid", message: "m" } });
|
|
246
|
+
});
|
|
247
|
+
});
|