@intentius/chant 0.124.75 → 0.124.77

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.
Files changed (147) hide show
  1. package/dist/__fixtures__/agent-guard/plywood.d.ts +8 -0
  2. package/dist/__fixtures__/agent-guard/plywood.d.ts.map +1 -0
  3. package/dist/__fixtures__/agent-guard/plywood.js +19 -0
  4. package/dist/__fixtures__/agent-guard/terragucci.d.ts +8 -0
  5. package/dist/__fixtures__/agent-guard/terragucci.d.ts.map +1 -0
  6. package/dist/__fixtures__/agent-guard/terragucci.js +30 -0
  7. package/dist/__fixtures__/gated-ledger.d.ts +10 -0
  8. package/dist/__fixtures__/gated-ledger.d.ts.map +1 -0
  9. package/dist/__fixtures__/gated-ledger.js +51 -0
  10. package/dist/agent-guard.d.ts +143 -0
  11. package/dist/agent-guard.d.ts.map +1 -0
  12. package/dist/agent-guard.js +456 -0
  13. package/dist/ci-commit.d.ts +54 -3
  14. package/dist/ci-commit.d.ts.map +1 -1
  15. package/dist/ci-commit.js +69 -7
  16. package/dist/ci-own-jobs.d.ts +81 -0
  17. package/dist/ci-own-jobs.d.ts.map +1 -0
  18. package/dist/ci-own-jobs.js +234 -0
  19. package/dist/ci-product.d.ts +39 -0
  20. package/dist/ci-product.d.ts.map +1 -1
  21. package/dist/ci-product.js +40 -0
  22. package/dist/cli/handlers/approve.d.ts +5 -1
  23. package/dist/cli/handlers/approve.d.ts.map +1 -1
  24. package/dist/cli/handlers/approve.js +17 -11
  25. package/dist/cli/handlers/build.d.ts +1 -1
  26. package/dist/cli/handlers/build.d.ts.map +1 -1
  27. package/dist/cli/handlers/build.js +88 -2
  28. package/dist/cli/handlers/commit.d.ts.map +1 -1
  29. package/dist/cli/handlers/commit.js +3 -1
  30. package/dist/cli/handlers/notify-relay.d.ts +18 -1
  31. package/dist/cli/handlers/notify-relay.d.ts.map +1 -1
  32. package/dist/cli/handlers/notify-relay.js +90 -14
  33. package/dist/cli/handlers/pr.d.ts.map +1 -1
  34. package/dist/cli/handlers/pr.js +3 -1
  35. package/dist/cli/handlers/release.d.ts +9 -1
  36. package/dist/cli/handlers/release.d.ts.map +1 -1
  37. package/dist/cli/handlers/release.js +34 -6
  38. package/dist/cli/handlers/run-generate.d.ts.map +1 -1
  39. package/dist/cli/handlers/run-generate.js +2 -1
  40. package/dist/cli/main.d.ts.map +1 -1
  41. package/dist/cli/main.js +21 -1
  42. package/dist/cli/parse-args.d.ts.map +1 -1
  43. package/dist/cli/parse-args.js +60 -4
  44. package/dist/cli/registry.d.ts +16 -0
  45. package/dist/cli/registry.d.ts.map +1 -1
  46. package/dist/components/pr-env-components.d.ts +65 -0
  47. package/dist/components/pr-env-components.d.ts.map +1 -0
  48. package/dist/components/pr-env-components.js +163 -0
  49. package/dist/components/pr-policy.d.ts +15 -0
  50. package/dist/components/pr-policy.d.ts.map +1 -1
  51. package/dist/components/pr-policy.js +24 -1
  52. package/dist/components/release-compile.d.ts +15 -3
  53. package/dist/components/release-compile.d.ts.map +1 -1
  54. package/dist/components/release-compile.js +66 -15
  55. package/dist/gate-policy.d.ts +14 -1
  56. package/dist/gate-policy.d.ts.map +1 -1
  57. package/dist/gate-policy.js +16 -6
  58. package/dist/lexicon.d.ts +17 -1
  59. package/dist/lexicon.d.ts.map +1 -1
  60. package/dist/lexicon.js +1 -0
  61. package/dist/lifecycle/gated-op.d.ts +95 -0
  62. package/dist/lifecycle/gated-op.d.ts.map +1 -0
  63. package/dist/lifecycle/gated-op.js +96 -0
  64. package/dist/lifecycle/git.d.ts.map +1 -1
  65. package/dist/lifecycle/git.js +83 -2
  66. package/dist/notify-relay-repo.d.ts +131 -0
  67. package/dist/notify-relay-repo.d.ts.map +1 -0
  68. package/dist/notify-relay-repo.js +202 -0
  69. package/dist/notify-relay.d.ts +25 -1
  70. package/dist/notify-relay.d.ts.map +1 -1
  71. package/dist/notify-relay.js +28 -2
  72. package/dist/op/op-waves-capability.js +2 -2
  73. package/dist/policy-engine.d.ts +95 -0
  74. package/dist/policy-engine.d.ts.map +1 -0
  75. package/dist/policy-engine.js +158 -0
  76. package/dist/release-floors.d.ts +1 -1
  77. package/dist/release-floors.js +1 -1
  78. package/dist/state-export.d.ts +126 -0
  79. package/dist/state-export.d.ts.map +1 -0
  80. package/dist/state-export.js +157 -0
  81. package/dist/state-migration.d.ts +148 -0
  82. package/dist/state-migration.d.ts.map +1 -0
  83. package/dist/state-migration.js +147 -0
  84. package/dist/state-unlock.d.ts +167 -0
  85. package/dist/state-unlock.d.ts.map +1 -0
  86. package/dist/state-unlock.js +197 -0
  87. package/dist/wave-runtime.mjs +329 -329
  88. package/dist/workspace/declaration.schema.json +1 -1
  89. package/dist/workspace/release-workflow.d.ts +10 -0
  90. package/dist/workspace/release-workflow.d.ts.map +1 -1
  91. package/dist/workspace/release-workflow.js +8 -3
  92. package/package.json +1 -1
  93. package/src/__fixtures__/agent-guard/plywood.ts +27 -0
  94. package/src/__fixtures__/agent-guard/terragucci.ts +39 -0
  95. package/src/__fixtures__/gated-ledger.ts +58 -0
  96. package/src/agent-guard.test.ts +320 -0
  97. package/src/agent-guard.ts +548 -0
  98. package/src/ci-commit.test.ts +50 -2
  99. package/src/ci-commit.ts +93 -9
  100. package/src/ci-own-jobs.test.ts +109 -0
  101. package/src/ci-own-jobs.ts +253 -0
  102. package/src/ci-product.ts +81 -0
  103. package/src/cli/handlers/approve-cwd.test.ts +112 -0
  104. package/src/cli/handlers/approve.ts +22 -11
  105. package/src/cli/handlers/build-own-jobs.test.ts +80 -0
  106. package/src/cli/handlers/build-pr-loop-control.test.ts +88 -0
  107. package/src/cli/handlers/build-run-group.test.ts +60 -0
  108. package/src/cli/handlers/build.ts +83 -3
  109. package/src/cli/handlers/commit.ts +3 -0
  110. package/src/cli/handlers/notify-relay.ts +99 -17
  111. package/src/cli/handlers/pr.ts +3 -1
  112. package/src/cli/handlers/release-cut-archives.test.ts +21 -0
  113. package/src/cli/handlers/release.ts +31 -6
  114. package/src/cli/handlers/run-generate.ts +2 -1
  115. package/src/cli/main.ts +21 -1
  116. package/src/cli/parse-args.ts +45 -3
  117. package/src/cli/registry.ts +16 -0
  118. package/src/components/pr-env-components.test.ts +138 -0
  119. package/src/components/pr-env-components.ts +214 -0
  120. package/src/components/pr-policy.test.ts +41 -1
  121. package/src/components/pr-policy.ts +25 -1
  122. package/src/components/release-compile.test.ts +47 -0
  123. package/src/components/release-compile.ts +70 -13
  124. package/src/gate-policy-bundle.test.ts +14 -0
  125. package/src/gate-policy.test.ts +7 -0
  126. package/src/gate-policy.ts +22 -7
  127. package/src/lexicon.ts +18 -1
  128. package/src/lifecycle/gated-op.ts +158 -0
  129. package/src/lifecycle/git.test.ts +92 -0
  130. package/src/lifecycle/git.ts +71 -2
  131. package/src/notify-relay-repo.test.ts +284 -0
  132. package/src/notify-relay-repo.ts +234 -0
  133. package/src/notify-relay.test.ts +12 -0
  134. package/src/notify-relay.ts +30 -3
  135. package/src/op/op-waves-capability.ts +2 -2
  136. package/src/policy-engine.test.ts +163 -0
  137. package/src/policy-engine.ts +201 -0
  138. package/src/release-floors.ts +1 -1
  139. package/src/state-export.test.ts +125 -0
  140. package/src/state-export.ts +228 -0
  141. package/src/state-migration.test.ts +134 -0
  142. package/src/state-migration.ts +237 -0
  143. package/src/state-unlock.test.ts +166 -0
  144. package/src/state-unlock.ts +294 -0
  145. package/src/workspace/declaration.schema.json +1 -1
  146. package/src/workspace/release-workflow.test.ts +34 -0
  147. package/src/workspace/release-workflow.ts +17 -3
@@ -1 +1 @@
1
- {"version":3,"file":"notify-relay.d.ts","sourceRoot":"","sources":["../src/notify-relay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAGH,OAAO,EAAsC,KAAK,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAA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B,kBAAkB,CACtC,GAAG,EAAE,YAAY,EACjB,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,SAAS,EACf,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAC9E,OAAO,CAAC,aAAa,CAAC,CAwCxB;AAqBD,wGAAwG;AACxG,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,SAAS,EACf,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAAO,GAC9F,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CA4BtE"}
@@ -44,6 +44,7 @@
44
44
  import { createHmac, timingSafeEqual } from "node:crypto";
45
45
  import { createServer } from "node:http";
46
46
  import { readRelayToken, RELAY_APPROVE_ACTION, RELAY_DECLINE_ACTION } from "./notify.js";
47
+ import { NEXT_RELEASE } from "./release-floors.js";
47
48
  /**
48
49
  * The first chant whose relay answers a gate's decision point and whose
49
50
  * `sendNotify` hands a product's own render the signed buttons
@@ -51,6 +52,15 @@ import { readRelayToken, RELAY_APPROVE_ACTION, RELAY_DECLINE_ACTION } from "./no
51
52
  * its own (#4611). Products feature-detect on it.
52
53
  */
53
54
  export const NOTIFY_RELAY_POINTS_FLOOR = "0.124.72";
55
+ /**
56
+ * The first chant whose `chant notify relay --repo <url> --token-env <VAR>`
57
+ * refuses a token that is more than approve-only and clones the repo itself,
58
+ * whose `--host` listens where asked, which acknowledges a Slack link button's
59
+ * click, and which reads the signers at the default branch's current tip
60
+ * (#4759). A product whose relay container ran its own entrypoint for these
61
+ * feature-detects on it.
62
+ */
63
+ export const NOTIFY_RELAY_CLONE_FLOOR = NEXT_RELEASE;
54
64
  /** The relay's settings, by environment variable. */
55
65
  export const RELAY_ENV = {
56
66
  /** The key the notify buttons are signed with: the variable `notify.relay` names on the sending side. */
@@ -66,6 +76,15 @@ export const RELAY_ENV = {
66
76
  /** Comma-separated address prefixes a Slack response_url may have. */
67
77
  slackResponse: "CHANT_RELAY_SLACK_RESPONSE",
68
78
  };
79
+ /** The variables that stand in for `--repo`, the default `--token-env`, and `--forge` (#4759). */
80
+ export const RELAY_REPO_ENV = {
81
+ /** The repository's https clone address. */
82
+ repo: "CHANT_RELAY_REPO",
83
+ /** The variable `--token-env` reads by default: the approve-only token. */
84
+ token: "CHANT_RELAY_TOKEN",
85
+ /** github, gitlab or forgejo, for a host other than github.com and gitlab.com. */
86
+ forge: "CHANT_RELAY_FORGE",
87
+ };
69
88
  /** Slack's own reply hosts: hooks.slack.com, and GovSlack's. */
70
89
  export const SLACK_RESPONSE_PREFIXES = ["https://hooks.slack.com/", "https://hooks.slack-gov.com/"];
71
90
  const SLACK_WINDOW_S = 5 * 60;
@@ -104,7 +123,12 @@ export function verifyTeamsRequest(headers, raw, secret) {
104
123
  return "the request is not signed";
105
124
  return same(auth, teamsSignature(secret, raw)) ? null : "the signature does not verify";
106
125
  }
107
- /** A Slack `block_actions` payload (the form field `payload`), or why the relay does not read it. */
126
+ /**
127
+ * A Slack `block_actions` payload (the form field `payload`), or why the
128
+ * relay does not read it. `ignore` is set for a click on a link button (one
129
+ * with a `url`, such as a product's Re-plan link on the same message): Slack
130
+ * posts it too, and the relay acknowledges it and does nothing (#4759).
131
+ */
108
132
  export function slackRelayClick(raw) {
109
133
  let p;
110
134
  try {
@@ -121,6 +145,8 @@ export function slackRelayClick(raw) {
121
145
  return { error: "the click names no Slack user" };
122
146
  const a = Array.isArray(p.actions) ? p.actions[0] : undefined;
123
147
  const action = a?.action_id === RELAY_APPROVE_ACTION ? "approve" : a?.action_id === RELAY_DECLINE_ACTION ? "decline" : undefined;
148
+ if (!action && typeof a?.url === "string")
149
+ return { error: `the button ${String(a?.action_id)} is a link`, ignore: true };
124
150
  if (!action)
125
151
  return { error: `the button ${String(a?.action_id)} is not chant's` };
126
152
  if (typeof a.value !== "string" || !a.value)
@@ -274,7 +300,7 @@ export async function handleRelayRequest(req, settings, deps, options = {}) {
274
300
  }
275
301
  const click = slackRelayClick(req.body);
276
302
  if ("error" in click)
277
- return plain(400, click.error);
303
+ return click.ignore ? plain(200, "") : plain(400, click.error);
278
304
  const answer = await decideRelayClick(click, settings, deps);
279
305
  log(`slack: ${click.chatUser} ${click.action}: ${answer.outcome}: ${answer.text}`);
280
306
  if (click.responseUrl) {
@@ -223,8 +223,8 @@ export function opWaveStepChangeSet(plans) {
223
223
  * checkout names one, as the pull-request path does.
224
224
  */
225
225
  export async function opWavePolicyVerdicts(at, parts) {
226
- const { prLoopPolicyAt, runPrPolicy } = await import("../components/pr-policy.js");
227
- const read = prLoopPolicyAt(at.cwd, at.base);
226
+ const { prLoopPolicyAt, preparePrPolicyEngine, runPrPolicy } = await import("../components/pr-policy.js");
227
+ const read = await preparePrPolicyEngine(prLoopPolicyAt(at.cwd, at.base));
228
228
  if (!read.settings)
229
229
  return { note: read.note ?? `holds.policy: the declaration at ${at.base.slice(0, 12)} names no ci.policy, so no policy runs` };
230
230
  const verdicts = new Map();
@@ -0,0 +1,95 @@
1
+ /**
2
+ * The policy engine's binary (#4774): conftest or OPA at a pinned release,
3
+ * fetched once, checked against the sha256 chant records for it, and kept in
4
+ * a cache directory.
5
+ *
6
+ * `ci.policy.install: true` makes the pull-request jobs and Op waves use it
7
+ * (`./components/pr-policy.ts`). A product that runs the engine itself calls
8
+ * {@link policyEngineBinary} with its own `download`, `cache` and `exec`, so
9
+ * it keeps no download code. Tests pass `download`, so nothing reaches the
10
+ * network.
11
+ *
12
+ * The digests are the release's own: conftest's `checksums.txt` and OPA's
13
+ * `.sha256` files, checked against the archives themselves when the pins
14
+ * were set. A download that does not match its pin is never written to the
15
+ * cache. A caller pinning another release passes its `version` and the
16
+ * sha256 for the platform; chant fetches nothing without a pin.
17
+ *
18
+ * Like `./gate-policy.ts` this module imports only node built-ins (and the
19
+ * release-floor constant), so a product can bundle it.
20
+ */
21
+ /** The first chant with `ci.policy.install` and `@intentius/chant/policy-engine` (#4774). Products feature-detect on it. */
22
+ export declare const POLICY_ENGINE_INSTALL_FLOOR = "0.124.77";
23
+ export type PolicyEngineName = "conftest" | "opa";
24
+ /** The platforms chant has pins for. */
25
+ export type PolicyEnginePlatform = "linux-x64" | "linux-arm64" | "darwin-x64" | "darwin-arm64";
26
+ export declare const POLICY_ENGINE_PLATFORMS: readonly PolicyEnginePlatform[];
27
+ /** The conftest release chant installs. */
28
+ export declare const CONFTEST_VERSION = "0.71.1";
29
+ /** The OPA release chant installs. */
30
+ export declare const OPA_VERSION = "1.21.4";
31
+ /**
32
+ * The sha256 of each pinned release file, as `<engine>-<version>-<platform>`,
33
+ * copied from the release's checksums (conftest's `checksums.txt`, OPA's
34
+ * `<asset>.sha256`) and checked against the files. The files are conftest's
35
+ * `conftest_<v>_<OS>_<arch>.tar.gz` and OPA's static builds, except on
36
+ * darwin-x64, where OPA builds none and the file is `opa_darwin_amd64`. Add
37
+ * a release's lines when moving a default version.
38
+ */
39
+ export declare const POLICY_ENGINE_SHA256: Readonly<Record<string, string>>;
40
+ /** One release file of one engine for one platform. */
41
+ export interface PolicyEngineRelease {
42
+ engine: PolicyEngineName;
43
+ version: string;
44
+ platform: PolicyEnginePlatform;
45
+ /** The release file's name. OPA ships a bare binary, conftest a `.tar.gz` holding `conftest`. */
46
+ asset: string;
47
+ url: string;
48
+ /** Whether the file is a `.tar.gz` to unpack. */
49
+ archive: boolean;
50
+ }
51
+ /** The release file of `engine` at `version` for `platform`. A version is a plain semver. */
52
+ export declare function policyEngineRelease(engine: PolicyEngineName, platform: PolicyEnginePlatform, version?: string): PolicyEngineRelease;
53
+ /** The sha256 chant records for a release file, or undefined when it records none. */
54
+ export declare function pinnedPolicyEngineSha256(release: PolicyEngineRelease): string | undefined;
55
+ /** This process's platform as chant pins it. Throws on one with no pin. */
56
+ export declare function policyEnginePlatform(platform?: string, arch?: string): PolicyEnginePlatform;
57
+ /** Where installed engines are kept by default: `CHANT_TOOL_CACHE`, else `chant-tools` in the temp directory. */
58
+ export declare function defaultPolicyEngineCache(): string;
59
+ export interface InstallPolicyEngineOptions {
60
+ /** Fetches a release file. Default: Node's fetch. Tests pass their own. */
61
+ download?: (url: string) => Promise<Uint8Array>;
62
+ /** Where installed engines are kept. Default {@link defaultPolicyEngineCache}. */
63
+ cache?: string;
64
+ /** The platform to fetch for. Default this process's ({@link policyEnginePlatform}). */
65
+ platform?: PolicyEnginePlatform;
66
+ /** Another release than chant's default. Needs `sha256` for the platform. */
67
+ version?: string;
68
+ /** The release file's sha256 by platform, in place of {@link POLICY_ENGINE_SHA256}. */
69
+ sha256?: Partial<Record<PolicyEnginePlatform, string>>;
70
+ }
71
+ /** The bytes of the regular file `name` (at the top, or under `./`) in a tar stream. Undefined when it holds none. */
72
+ export declare function tarEntry(tar: Uint8Array, name: string): Uint8Array | undefined;
73
+ /**
74
+ * Install `engine` into the cache and return the binary's path. A binary
75
+ * already installed there for that release and platform is returned without
76
+ * a download. Throws when the platform has no pin, the download fails, or
77
+ * the file does not match its pin.
78
+ */
79
+ export declare function installPolicyEngine(engine: PolicyEngineName, options?: InstallPolicyEngineOptions): Promise<string>;
80
+ /** Whether the engine on PATH answers. Default: runs `conftest --version` or `opa version`. */
81
+ export type PolicyEngineProbe = (engine: PolicyEngineName) => boolean;
82
+ export declare const defaultPolicyEngineProbe: PolicyEngineProbe;
83
+ export interface PolicyEngineBinaryOptions extends InstallPolicyEngineOptions {
84
+ /** Checks the engine on PATH. Default {@link defaultPolicyEngineProbe}. */
85
+ probe?: PolicyEngineProbe;
86
+ /** Skip the PATH and always use the pinned release. Default false. */
87
+ pinnedOnly?: boolean;
88
+ }
89
+ /**
90
+ * The engine's executable: its name when the one on PATH answers (an image
91
+ * that carries the engine pays nothing), else the pinned release installed
92
+ * by {@link installPolicyEngine}.
93
+ */
94
+ export declare function policyEngineBinary(engine: PolicyEngineName, options?: PolicyEngineBinaryOptions): Promise<string>;
95
+ //# sourceMappingURL=policy-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-engine.d.ts","sourceRoot":"","sources":["../src/policy-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAUH,4HAA4H;AAC5H,eAAO,MAAM,2BAA2B,aAAe,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,KAAK,CAAC;AAElD,wCAAwC;AACxC,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,aAAa,GAAG,YAAY,GAAG,cAAc,CAAC;AAC/F,eAAO,MAAM,uBAAuB,EAAE,SAAS,oBAAoB,EAA+D,CAAC;AAEnI,2CAA2C;AAC3C,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC,sCAAsC;AACtC,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASjE,CAAC;AAEF,uDAAuD;AACvD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,iGAAiG;IACjG,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,iDAAiD;IACjD,OAAO,EAAE,OAAO,CAAC;CAClB;AAKD,6FAA6F;AAC7F,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,E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EAAE,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,MAAM,CAAC,CAG3H"}
@@ -0,0 +1,158 @@
1
+ /**
2
+ * The policy engine's binary (#4774): conftest or OPA at a pinned release,
3
+ * fetched once, checked against the sha256 chant records for it, and kept in
4
+ * a cache directory.
5
+ *
6
+ * `ci.policy.install: true` makes the pull-request jobs and Op waves use it
7
+ * (`./components/pr-policy.ts`). A product that runs the engine itself calls
8
+ * {@link policyEngineBinary} with its own `download`, `cache` and `exec`, so
9
+ * it keeps no download code. Tests pass `download`, so nothing reaches the
10
+ * network.
11
+ *
12
+ * The digests are the release's own: conftest's `checksums.txt` and OPA's
13
+ * `.sha256` files, checked against the archives themselves when the pins
14
+ * were set. A download that does not match its pin is never written to the
15
+ * cache. A caller pinning another release passes its `version` and the
16
+ * sha256 for the platform; chant fetches nothing without a pin.
17
+ *
18
+ * Like `./gate-policy.ts` this module imports only node built-ins (and the
19
+ * release-floor constant), so a product can bundle it.
20
+ */
21
+ import { spawnSync } from "node:child_process";
22
+ import { createHash, randomBytes } from "node:crypto";
23
+ import { chmodSync, existsSync, mkdirSync, renameSync, writeFileSync } from "node:fs";
24
+ import { tmpdir } from "node:os";
25
+ import { join } from "node:path";
26
+ import { gunzipSync } from "node:zlib";
27
+ import { NEXT_RELEASE } from "./release-floors.js";
28
+ /** The first chant with `ci.policy.install` and `@intentius/chant/policy-engine` (#4774). Products feature-detect on it. */
29
+ export const POLICY_ENGINE_INSTALL_FLOOR = NEXT_RELEASE;
30
+ export const POLICY_ENGINE_PLATFORMS = ["linux-x64", "linux-arm64", "darwin-x64", "darwin-arm64"];
31
+ /** The conftest release chant installs. */
32
+ export const CONFTEST_VERSION = "0.71.1";
33
+ /** The OPA release chant installs. */
34
+ export const OPA_VERSION = "1.21.4";
35
+ /**
36
+ * The sha256 of each pinned release file, as `<engine>-<version>-<platform>`,
37
+ * copied from the release's checksums (conftest's `checksums.txt`, OPA's
38
+ * `<asset>.sha256`) and checked against the files. The files are conftest's
39
+ * `conftest_<v>_<OS>_<arch>.tar.gz` and OPA's static builds, except on
40
+ * darwin-x64, where OPA builds none and the file is `opa_darwin_amd64`. Add
41
+ * a release's lines when moving a default version.
42
+ */
43
+ export const POLICY_ENGINE_SHA256 = {
44
+ "conftest-0.71.1-linux-x64": "c3f6b2a753bd56e377a1e51a95ae3e057f926f2e9139f7d5b5dfbbaf810f7985",
45
+ "conftest-0.71.1-linux-arm64": "218c682e110ae7e826dc14a746a6f9b43eb782643dbe730b771fd305634e3f47",
46
+ "conftest-0.71.1-darwin-x64": "a309853b5763c18486768157442d440248ee683b20a2aa1f6b28214e818bd780",
47
+ "conftest-0.71.1-darwin-arm64": "e1cc50d2590b6c5e3da6912666a71264bae82d60bdd62d7ae2b99971ccc8eedd",
48
+ "opa-1.21.4-linux-x64": "2ab571f367f293bb19523b76f92f1945bbf245003392c7f392903f95c2b9b630",
49
+ "opa-1.21.4-linux-arm64": "810aa96e44f1f852d044888cf830324e44eafd0f510345339011347ab4deaab1",
50
+ "opa-1.21.4-darwin-x64": "8802bd39bc14b58a705e6b3d4f4dd14f7f24ee657f0362c737338be243190c7e",
51
+ "opa-1.21.4-darwin-arm64": "4c105208a9282f590385bccbe600875c011f0894ccf9431782dfe855e1f99aa6",
52
+ };
53
+ const VERSION = /^\d+\.\d+\.\d+$/;
54
+ const SHA256 = /^[0-9a-f]{64}$/;
55
+ /** The release file of `engine` at `version` for `platform`. A version is a plain semver. */
56
+ export function policyEngineRelease(engine, platform, version = engine === "opa" ? OPA_VERSION : CONFTEST_VERSION) {
57
+ if (!VERSION.test(version))
58
+ throw new Error(`${engine} version ${JSON.stringify(version)} is not a release version such as ${engine === "opa" ? OPA_VERSION : CONFTEST_VERSION}`);
59
+ const [os, cpu] = platform.split("-");
60
+ if (engine === "conftest") {
61
+ const asset = `conftest_${version}_${os === "linux" ? "Linux" : "Darwin"}_${cpu === "x64" ? "x86_64" : "arm64"}.tar.gz`;
62
+ return { engine, version, platform, asset, url: `https://github.com/open-policy-agent/conftest/releases/download/v${version}/${asset}`, archive: true };
63
+ }
64
+ // OPA builds no static binary for darwin on amd64.
65
+ const asset = `opa_${os}_${cpu === "x64" ? "amd64" : "arm64"}${platform === "darwin-x64" ? "" : "_static"}`;
66
+ return { engine, version, platform, asset, url: `https://github.com/open-policy-agent/opa/releases/download/v${version}/${asset}`, archive: false };
67
+ }
68
+ /** The sha256 chant records for a release file, or undefined when it records none. */
69
+ export function pinnedPolicyEngineSha256(release) {
70
+ return POLICY_ENGINE_SHA256[`${release.engine}-${release.version}-${release.platform}`];
71
+ }
72
+ /** This process's platform as chant pins it. Throws on one with no pin. */
73
+ export function policyEnginePlatform(platform = process.platform, arch = process.arch) {
74
+ const os = platform === "linux" || platform === "darwin" ? platform : undefined;
75
+ const cpu = arch === "x64" || arch === "x86_64" || arch === "amd64" ? "x64" : arch === "arm64" || arch === "aarch64" ? "arm64" : undefined;
76
+ if (!os || !cpu)
77
+ throw new Error(`chant pins conftest and OPA for ${POLICY_ENGINE_PLATFORMS.join(", ")}, not ${platform}-${arch}; put the engine on PATH instead`);
78
+ return `${os}-${cpu}`;
79
+ }
80
+ /** Where installed engines are kept by default: `CHANT_TOOL_CACHE`, else `chant-tools` in the temp directory. */
81
+ export function defaultPolicyEngineCache() {
82
+ return process.env.CHANT_TOOL_CACHE || join(tmpdir(), "chant-tools");
83
+ }
84
+ async function fetchBytes(url) {
85
+ const res = await fetch(url);
86
+ if (!res.ok)
87
+ throw new Error(`${url}: HTTP ${res.status}`);
88
+ return new Uint8Array(await res.arrayBuffer());
89
+ }
90
+ /** The bytes of the regular file `name` (at the top, or under `./`) in a tar stream. Undefined when it holds none. */
91
+ export function tarEntry(tar, name) {
92
+ const text = (from, len) => {
93
+ const raw = Buffer.from(tar.subarray(from, from + len)).toString("utf-8");
94
+ const nul = raw.indexOf("\0");
95
+ return nul < 0 ? raw : raw.slice(0, nul);
96
+ };
97
+ let at = 0;
98
+ while (at + 512 <= tar.length) {
99
+ if (tar.subarray(at, at + 512).every((b) => b === 0))
100
+ return undefined;
101
+ const prefix = text(at + 345, 155);
102
+ const entry = (prefix ? `${prefix}/` : "") + text(at, 100);
103
+ const size = parseInt(text(at + 124, 12).trim() || "0", 8);
104
+ const type = text(at + 156, 1);
105
+ const body = at + 512;
106
+ if ((type === "" || type === "0") && entry.replace(/^\.\//, "") === name)
107
+ return tar.subarray(body, body + size);
108
+ at = body + Math.ceil(size / 512) * 512;
109
+ }
110
+ return undefined;
111
+ }
112
+ /**
113
+ * Install `engine` into the cache and return the binary's path. A binary
114
+ * already installed there for that release and platform is returned without
115
+ * a download. Throws when the platform has no pin, the download fails, or
116
+ * the file does not match its pin.
117
+ */
118
+ export async function installPolicyEngine(engine, options = {}) {
119
+ const platform = options.platform ?? policyEnginePlatform();
120
+ const release = policyEngineRelease(engine, platform, options.version);
121
+ const want = options.sha256 ? options.sha256[platform] : pinnedPolicyEngineSha256(release);
122
+ if (want === undefined)
123
+ throw new Error(`chant records no sha256 for ${engine} ${release.version} on ${platform} (${release.asset}); pass sha256 for it, or use ${engine === "opa" ? OPA_VERSION : CONFTEST_VERSION}`);
124
+ if (!SHA256.test(want))
125
+ throw new Error(`the sha256 for ${release.asset} is not 64 hex digits`);
126
+ const dir = join(options.cache ?? defaultPolicyEngineCache(), `${engine}-${release.version}-${platform}`);
127
+ const bin = join(dir, engine);
128
+ if (existsSync(bin))
129
+ return bin;
130
+ const body = await (options.download ?? fetchBytes)(release.url);
131
+ const sum = createHash("sha256").update(body).digest("hex");
132
+ if (sum !== want)
133
+ throw new Error(`${engine} ${release.version} from ${release.url} does not match its pinned sha256 (want ${want}, got ${sum}); not running it`);
134
+ const binary = release.archive ? tarEntry(gunzipSync(body), engine) : body;
135
+ if (!binary)
136
+ throw new Error(`${release.asset} holds no ${engine} binary`);
137
+ mkdirSync(dir, { recursive: true });
138
+ // Written beside its final name and renamed, so a job that stops halfway leaves no binary behind.
139
+ const part = join(dir, `.${engine}.${randomBytes(6).toString("hex")}`);
140
+ writeFileSync(part, binary);
141
+ chmodSync(part, 0o755);
142
+ renameSync(part, bin);
143
+ return bin;
144
+ }
145
+ export const defaultPolicyEngineProbe = (engine) => {
146
+ const r = spawnSync(engine, engine === "opa" ? ["version"] : ["--version"], { stdio: "ignore" });
147
+ return !r.error && r.status === 0;
148
+ };
149
+ /**
150
+ * The engine's executable: its name when the one on PATH answers (an image
151
+ * that carries the engine pays nothing), else the pinned release installed
152
+ * by {@link installPolicyEngine}.
153
+ */
154
+ export async function policyEngineBinary(engine, options = {}) {
155
+ if (!options.pinnedOnly && (options.probe ?? defaultPolicyEngineProbe)(engine))
156
+ return engine;
157
+ return installPolicyEngine(engine, options);
158
+ }
@@ -19,5 +19,5 @@
19
19
  * this constant to the next patch (#4501). The check fails while a floor
20
20
  * still names this constant after its version shipped.
21
21
  */
22
- export declare const NEXT_RELEASE = "0.124.74";
22
+ export declare const NEXT_RELEASE = "0.124.77";
23
23
  //# sourceMappingURL=release-floors.d.ts.map
@@ -19,4 +19,4 @@
19
19
  * this constant to the next patch (#4501). The check fails while a floor
20
20
  * still names this constant after its version shipped.
21
21
  */
22
- export const NEXT_RELEASE = "0.124.74";
22
+ export const NEXT_RELEASE = "0.124.77";
@@ -0,0 +1,126 @@
1
+ import { type GatedRequestLedger } from "./lifecycle/gated-op.js";
2
+ import type { GatedRequestRules } from "./lifecycle/gated-request.js";
3
+ /** The first chant with the engine-neutral state export (#4762). */
4
+ export declare const STATE_EXPORT_FLOOR = "0.124.77";
5
+ /** The version a store holds now. */
6
+ export interface StateVersion {
7
+ /** Whether there is a state at all. */
8
+ exists: boolean;
9
+ /** Its id, when the store keeps versions and can give this one back later. */
10
+ versionId?: string;
11
+ /** Why the store keeps no version of it, when it keeps none. */
12
+ off?: string;
13
+ }
14
+ /** An engine's state, read by version: the adapter a product's engine supplies. */
15
+ export interface StateVersionSource {
16
+ /** Where the state is, as messages and the record name it. Never a credential. */
17
+ readonly location: string;
18
+ /** The version the store holds now. */
19
+ current(): Promise<StateVersion>;
20
+ /** Whether the store holds that version, without reading it. */
21
+ hasVersion(id: string): Promise<boolean>;
22
+ /** That version's bytes, or undefined when the store holds no such version. */
23
+ readVersion(id: string): Promise<string | Uint8Array | undefined>;
24
+ }
25
+ /** The product's words for an export. */
26
+ export interface StateExportWords {
27
+ /** The op the requests wait at, such as `tf-state-export`. */
28
+ op: string;
29
+ /** The request's kind. Default `state-export`. */
30
+ kind?: string;
31
+ /** The command that approves a request, as the product prints it. Default chant's `chant approve <op> <subject> --plan <digest>`. */
32
+ approveCommand?: (subject: string, digest: string) => string;
33
+ /** The file's name in its directory. Default `<subject>.<version>.state`, each with what is not a word character replaced. */
34
+ fileName?: (subject: string, version: string) => string;
35
+ /** The prefix of the private directory a default destination is made in. Default `chant-export-`. */
36
+ tmpPrefix?: string;
37
+ }
38
+ /** The CI variables that mark a job, where an export would become an artifact. */
39
+ export declare const CI_MARKERS: readonly string[];
40
+ /** The CI marker set in `env`, or undefined when none is. */
41
+ export declare function ciMarker(env: NodeJS.ProcessEnv | Record<string, string | undefined>): string | undefined;
42
+ /** The git working tree `path` sits in, or undefined. */
43
+ export declare function enclosingWorkTree(path: string): string | undefined;
44
+ /** Why an export may not go to `out`, or undefined when it may. */
45
+ export declare function exportRefusal(out: string): string | undefined;
46
+ /** A refusal before anything is asked: a version the store does not have, a destination the export may not use. */
47
+ export declare class StateExportError extends Error {
48
+ constructor(message: string);
49
+ }
50
+ export interface StateExportInput {
51
+ /** What is exported, and the gate the request waits at: a root, a stack. */
52
+ subject: string;
53
+ /** The requester. Their own approval never counts. */
54
+ by: string;
55
+ source: StateVersionSource;
56
+ /** The version to export. Default the one the store holds now. */
57
+ version?: string;
58
+ /** Where the file goes. Default a new private directory in the system's temp dir. */
59
+ out?: string;
60
+ words: StateExportWords;
61
+ rules: GatedRequestRules;
62
+ /** Where the ledger is. Default the process's. */
63
+ cwd?: string;
64
+ base?: string;
65
+ /** How long a request waits for its approval. Default 48h. */
66
+ expiry?: string;
67
+ now?: string;
68
+ /** The environment the CI markers are read from. Default the process's. */
69
+ env?: NodeJS.ProcessEnv | Record<string, string | undefined>;
70
+ /** Export in a CI job too. Default false: a CI job refuses. */
71
+ allowCi?: boolean;
72
+ ledger?: GatedRequestLedger;
73
+ }
74
+ /** How an export ended. `exit` is the code its command exits with. */
75
+ export type StateExportOutcome = {
76
+ status: "written";
77
+ exit: 0;
78
+ digest: string;
79
+ version: string;
80
+ location: string;
81
+ file: string;
82
+ approvedBy: string;
83
+ contentDigest: string;
84
+ recorded: boolean;
85
+ } | {
86
+ status: "waiting";
87
+ exit: 3;
88
+ digest: string;
89
+ version: string;
90
+ location: string;
91
+ command: string;
92
+ }
93
+ /** An approval stands and does not count, such as the requester's own. The request still waits. */
94
+ | {
95
+ status: "refused";
96
+ exit: 3;
97
+ digest: string;
98
+ version: string;
99
+ location: string;
100
+ command: string;
101
+ by: string;
102
+ reason: string;
103
+ }
104
+ /** The request exported already; another export asks again. */
105
+ | {
106
+ status: "spent";
107
+ exit: 1;
108
+ digest: string;
109
+ version: string;
110
+ location: string;
111
+ } | {
112
+ status: "failed";
113
+ exit: 1;
114
+ digest: string;
115
+ version: string;
116
+ location: string;
117
+ error: Error;
118
+ recorded: boolean;
119
+ };
120
+ /**
121
+ * Ask for, or with an approval write, one version of a state. Throws
122
+ * {@link StateExportError} before anything is asked when the version or the
123
+ * destination is refused.
124
+ */
125
+ export declare function exportStateVersion(input: StateExportInput): Promise<StateExportOutcome>;
126
+ //# sourceMappingURL=state-export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-export.d.ts","sourceRoot":"","sources":["../src/state-export.ts"],"names":[],"mappings":"AAoCA,OAAO,EAAW,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC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