@intentius/chant 0.124.40 → 0.124.41
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/__fixtures__/oidc-emulator.d.ts +49 -0
- package/dist/__fixtures__/oidc-emulator.d.ts.map +1 -0
- package/dist/__fixtures__/oidc-emulator.js +89 -0
- package/dist/ci-handover.d.ts +117 -0
- package/dist/ci-handover.d.ts.map +1 -0
- package/dist/ci-handover.js +217 -0
- package/dist/ci-identity.d.ts +190 -0
- package/dist/ci-identity.d.ts.map +1 -0
- package/dist/ci-identity.js +219 -0
- package/dist/cli/handlers/approve.d.ts +2 -1
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +20 -6
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +15 -1
- package/dist/cli/handlers/fan-out.js +16 -3
- package/dist/cli/handlers/gate-resume.d.ts +3 -0
- package/dist/cli/handlers/gate-resume.d.ts.map +1 -1
- package/dist/cli/handlers/gate-resume.js +15 -2
- package/dist/cli/handlers/lock.d.ts +8 -0
- package/dist/cli/handlers/lock.d.ts.map +1 -0
- package/dist/cli/handlers/lock.js +197 -0
- package/dist/cli/handlers/pr-env.d.ts +34 -0
- package/dist/cli/handlers/pr-env.d.ts.map +1 -0
- package/dist/cli/handlers/pr-env.js +436 -0
- package/dist/cli/handlers/pr.d.ts +74 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +503 -53
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +9 -0
- package/dist/cli/handlers/query.d.ts +6 -0
- package/dist/cli/handlers/query.d.ts.map +1 -0
- package/dist/cli/handlers/query.js +80 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +41 -2
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +31 -2
- package/dist/cli/registry.d.ts +12 -2
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/fan-out-run.d.ts +28 -0
- package/dist/components/fan-out-run.d.ts.map +1 -1
- package/dist/components/fan-out-run.js +27 -3
- package/dist/components/pr-environment.d.ts +298 -0
- package/dist/components/pr-environment.d.ts.map +1 -0
- package/dist/components/pr-environment.js +406 -0
- package/dist/components/pr-hooks.d.ts +66 -0
- package/dist/components/pr-hooks.d.ts.map +1 -0
- package/dist/components/pr-hooks.js +119 -0
- package/dist/components/pr-pipeline.d.ts +72 -2
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +96 -5
- package/dist/components/pr-policy.d.ts +109 -0
- package/dist/components/pr-policy.d.ts.map +1 -0
- package/dist/components/pr-policy.js +150 -0
- package/dist/components/pr-run.d.ts.map +1 -1
- package/dist/components/pr-run.js +5 -3
- package/dist/gate-decision.d.ts +15 -2
- package/dist/gate-decision.d.ts.map +1 -1
- package/dist/gate-decision.js +17 -2
- package/dist/gate-policy.d.ts +140 -0
- package/dist/gate-policy.d.ts.map +1 -0
- package/dist/gate-policy.js +242 -0
- package/dist/lifecycle/gate-checkpoint.d.ts +1 -1
- package/dist/lifecycle/gate-checkpoint.js +1 -1
- package/dist/{workspace/trust → lifecycle}/gate-seal.d.ts +1 -1
- package/dist/lifecycle/gate-seal.d.ts.map +1 -0
- package/dist/lifecycle/query.d.ts +68 -0
- package/dist/lifecycle/query.d.ts.map +1 -0
- package/dist/lifecycle/query.js +246 -0
- package/dist/lifecycle/run-ledger.d.ts +13 -0
- package/dist/lifecycle/run-ledger.d.ts.map +1 -1
- package/dist/lifecycle/run-ledger.js +16 -0
- package/dist/lifecycle/target-lock.d.ts +97 -0
- package/dist/lifecycle/target-lock.d.ts.map +1 -0
- package/dist/lifecycle/target-lock.js +286 -0
- package/dist/op/activities/activity-contracts.d.ts +30 -0
- package/dist/op/activities/activity-contracts.d.ts.map +1 -1
- package/dist/op/activities/activity-contracts.js +26 -0
- package/dist/op/activities/index.d.ts +2 -0
- package/dist/op/activities/index.d.ts.map +1 -1
- package/dist/op/activities/index.js +4 -0
- package/dist/op/activities/review-agent.d.ts +137 -0
- package/dist/op/activities/review-agent.d.ts.map +1 -0
- package/dist/op/activities/review-agent.js +266 -0
- package/dist/op/builders.d.ts +9 -0
- package/dist/op/builders.d.ts.map +1 -1
- package/dist/op/builders.js +11 -0
- package/dist/op/cron.d.ts +8 -0
- package/dist/op/cron.d.ts.map +1 -1
- package/dist/op/cron.js +51 -0
- package/dist/op/gate-approval.d.ts +20 -13
- package/dist/op/gate-approval.d.ts.map +1 -1
- package/dist/op/gate-approval.js +13 -18
- package/dist/op/gate-quorum.d.ts +131 -0
- package/dist/op/gate-quorum.d.ts.map +1 -0
- package/dist/op/gate-quorum.js +183 -0
- package/dist/op/gate-resume.d.ts +4 -2
- package/dist/op/gate-resume.d.ts.map +1 -1
- package/dist/op/gate-resume.js +5 -4
- package/dist/op/gate-review.js +1 -1
- package/dist/op/gate.d.ts +32 -4
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +40 -24
- package/dist/op/index.d.ts +6 -4
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +4 -3
- package/dist/op/local-executor.d.ts.map +1 -1
- package/dist/op/local-executor.js +9 -3
- package/dist/op/op-waves-run.d.ts +62 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +190 -11
- package/dist/op/op-waves.d.ts +55 -3
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +63 -8
- package/dist/op/schedule-overdue.d.ts +57 -0
- package/dist/op/schedule-overdue.d.ts.map +1 -0
- package/dist/op/schedule-overdue.js +138 -0
- package/dist/override-gate.d.ts +2 -2
- package/dist/override-gate.d.ts.map +1 -1
- package/dist/override-gate.js +1 -1
- package/dist/pr-forge.d.ts +36 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +82 -0
- package/dist/pr-loop.d.ts +90 -1
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +77 -3
- package/dist/pr-post.d.ts +72 -0
- package/dist/pr-post.d.ts.map +1 -0
- package/dist/pr-post.js +134 -0
- package/dist/wave-blocked.d.ts +79 -0
- package/dist/wave-blocked.d.ts.map +1 -0
- package/dist/wave-blocked.js +245 -0
- package/dist/wave-engine.d.ts +6 -0
- package/dist/wave-engine.d.ts.map +1 -1
- package/dist/wave-engine.js +2 -0
- package/dist/wave-runtime.mjs +242 -242
- package/dist/workspace/__fixtures__/two-member-workspace.d.ts +1 -0
- package/dist/workspace/__fixtures__/two-member-workspace.d.ts.map +1 -1
- package/dist/workspace/__fixtures__/two-member-workspace.js +1 -1
- package/dist/workspace/ci-branches.d.ts +51 -0
- package/dist/workspace/ci-branches.d.ts.map +1 -0
- package/dist/workspace/ci-branches.js +69 -0
- package/dist/workspace/ci-cloud-identity.d.ts +11 -0
- package/dist/workspace/ci-cloud-identity.d.ts.map +1 -0
- package/dist/workspace/ci-cloud-identity.js +24 -0
- package/dist/workspace/ci-locks.d.ts +12 -0
- package/dist/workspace/ci-locks.d.ts.map +1 -0
- package/dist/workspace/ci-locks.js +6 -0
- package/dist/workspace/ci-run.d.ts +17 -1
- package/dist/workspace/ci-run.d.ts.map +1 -1
- package/dist/workspace/ci-run.js +64 -3
- package/dist/workspace/declaration.d.ts +63 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +72 -1
- package/dist/workspace/declaration.schema.json +147 -0
- package/dist/workspace/identity-gate-rule.d.ts +1 -1
- package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
- package/dist/workspace/identity-gate-rule.js +1 -1
- package/dist/workspace/identity.d.ts +1 -1
- package/dist/workspace/identity.d.ts.map +1 -1
- package/dist/workspace/lineage-upgrade.d.ts.map +1 -1
- package/dist/workspace/lineage-upgrade.js +8 -5
- package/dist/workspace/member-pipeline.d.ts +6 -0
- package/dist/workspace/member-pipeline.d.ts.map +1 -1
- package/dist/workspace/member-pipeline.js +23 -0
- package/dist/workspace/pr-report.schema.json +73 -2
- package/dist/workspace/security.d.ts.map +1 -1
- package/dist/workspace/security.js +4 -0
- package/dist/workspace/status-gates.d.ts +3 -2
- package/dist/workspace/status-gates.d.ts.map +1 -1
- package/dist/workspace/status-gates.js +8 -7
- package/dist/workspace/status.d.ts.map +1 -1
- package/dist/workspace/status.js +4 -1
- package/dist/workspace/trust/seal.d.ts +2 -2
- package/dist/workspace/trust/seal.d.ts.map +1 -1
- package/dist/workspace/trust/seal.js +2 -2
- package/package.json +1 -1
- package/src/__fixtures__/oidc-emulator.ts +118 -0
- package/src/ci-handover.test.ts +209 -0
- package/src/ci-handover.ts +237 -0
- package/src/ci-identity.test.ts +201 -0
- package/src/ci-identity.ts +310 -0
- package/src/cli/handlers/approve.ts +18 -5
- package/src/cli/handlers/build.ts +15 -1
- package/src/cli/handlers/fan-out.ts +17 -4
- package/src/cli/handlers/gate-resume.ts +16 -2
- package/src/cli/handlers/lock.test.ts +98 -0
- package/src/cli/handlers/lock.ts +202 -0
- package/src/cli/handlers/operator.test.ts +3 -1
- package/src/cli/handlers/pr-env.ts +462 -0
- package/src/cli/handlers/pr-waves-blocked.test.ts +247 -0
- package/src/cli/handlers/pr.test.ts +184 -0
- package/src/cli/handlers/pr.ts +496 -59
- package/src/cli/handlers/promote.ts +9 -0
- package/src/cli/handlers/query.ts +78 -0
- package/src/cli/main.ts +41 -2
- package/src/cli/parse-args.ts +23 -2
- package/src/cli/registry.ts +12 -2
- package/src/components/fan-out-run.ts +39 -2
- package/src/components/fan-out-waves.test.ts +45 -1
- package/src/components/pr-environment.test.ts +249 -0
- package/src/components/pr-environment.ts +538 -0
- package/src/components/pr-hooks.test.ts +118 -0
- package/src/components/pr-hooks.ts +157 -0
- package/src/components/pr-pipeline.ts +130 -5
- package/src/components/pr-policy.test.ts +145 -0
- package/src/components/pr-policy.ts +211 -0
- package/src/components/pr-run.ts +5 -2
- package/src/gate-decision-bundle.test.ts +4 -3
- package/src/gate-decision.ts +39 -2
- package/src/gate-policy-bundle.test.ts +28 -0
- package/src/gate-policy.test.ts +162 -0
- package/src/gate-policy.ts +298 -0
- package/src/lifecycle/gate-checkpoint.ts +1 -1
- package/src/{workspace/trust → lifecycle}/gate-seal.ts +1 -1
- package/src/lifecycle/query.test.ts +91 -0
- package/src/lifecycle/query.ts +315 -0
- package/src/lifecycle/run-ledger.ts +18 -0
- package/src/lifecycle/target-lock.test.ts +195 -0
- package/src/lifecycle/target-lock.ts +347 -0
- package/src/op/activities/activity-contracts.ts +31 -0
- package/src/op/activities/index.ts +6 -0
- package/src/op/activities/review-agent.test.ts +240 -0
- package/src/op/activities/review-agent.ts +355 -0
- package/src/op/builders.ts +13 -0
- package/src/op/cron.ts +44 -0
- package/src/op/gate-alias.test.ts +2 -2
- package/src/op/gate-approval.test.ts +30 -9
- package/src/op/gate-approval.ts +23 -26
- package/src/op/gate-quorum.test.ts +139 -0
- package/src/op/gate-quorum.ts +248 -0
- package/src/op/gate-resume.ts +6 -3
- package/src/op/gate-review.ts +1 -1
- package/src/op/gate.ts +64 -23
- package/src/op/index.ts +13 -1
- package/src/op/local-executor.ts +9 -2
- package/src/op/op-waves-hook-targets.test.ts +126 -0
- package/src/op/op-waves-policy-hold.test.ts +66 -0
- package/src/op/op-waves-quorum.test.ts +101 -0
- package/src/op/op-waves-run.ts +233 -11
- package/src/op/op-waves.ts +83 -10
- package/src/op/schedule-overdue.test.ts +220 -0
- package/src/op/schedule-overdue.ts +161 -0
- package/src/override-gate-bundle.test.ts +1 -1
- package/src/override-gate.ts +2 -2
- package/src/pr-forge-bundle.test.ts +2 -2
- package/src/pr-forge.test.ts +33 -0
- package/src/pr-forge.ts +114 -0
- package/src/pr-loop-bundle.test.ts +2 -2
- package/src/pr-loop.test.ts +58 -0
- package/src/pr-loop.ts +146 -4
- package/src/pr-post.test.ts +141 -0
- package/src/pr-post.ts +159 -0
- package/src/wave-blocked-bundle.test.ts +25 -0
- package/src/wave-blocked.test.ts +146 -0
- package/src/wave-blocked.ts +271 -0
- package/src/wave-engine.ts +8 -0
- package/src/workspace/__fixtures__/two-member-workspace.ts +2 -2
- package/src/workspace/ci-branches.test.ts +62 -0
- package/src/workspace/ci-branches.ts +79 -0
- package/src/workspace/ci-cloud-identity.test.ts +53 -0
- package/src/workspace/ci-cloud-identity.ts +23 -0
- package/src/workspace/ci-locks.ts +16 -0
- package/src/workspace/ci-run-index.test.ts +2 -1
- package/src/workspace/ci-run.test.ts +107 -8
- package/src/workspace/ci-run.ts +72 -4
- package/src/workspace/declaration.schema.json +147 -0
- package/src/workspace/declaration.test.ts +76 -0
- package/src/workspace/declaration.ts +134 -2
- package/src/workspace/identity-gate-rule.ts +1 -1
- package/src/workspace/identity.ts +1 -1
- package/src/workspace/lineage-upgrade.ts +11 -8
- package/src/workspace/member-pipeline.test.ts +29 -0
- package/src/workspace/member-pipeline.ts +30 -0
- package/src/workspace/pr-report.schema.json +73 -2
- package/src/workspace/security.ts +4 -0
- package/src/workspace/status-gates.ts +9 -6
- package/src/workspace/status.ts +4 -1
- package/src/workspace/trust/gate-seal.test.ts +1 -1
- package/src/workspace/trust/seal.ts +2 -2
- package/dist/workspace/trust/gate-seal.d.ts.map +0 -1
- /package/dist/{workspace/trust → lifecycle}/gate-seal.js +0 -0
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
* values they read from the forge live here so the three cannot disagree.
|
|
9
9
|
*
|
|
10
10
|
* - The plan job runs `chant components pr-plan` against the pull request's
|
|
11
|
-
* target commit. It
|
|
12
|
-
*
|
|
11
|
+
* target commit. It writes nothing to `chant/lifecycle` and holds no forge
|
|
12
|
+
* token, since it runs the pull request's code (#4295): it writes the note
|
|
13
|
+
* and the status into its report with `--no-status`, and the `plan-note`
|
|
14
|
+
* job after it posts them with `chant components pr-post`
|
|
15
|
+
* ({@link prLoopPostJob}, ../ci-handover.ts).
|
|
13
16
|
* - The record job (#4168 step 1, the default) runs `chant components
|
|
14
17
|
* pr-record` against the commit the push replaced. It plans the same
|
|
15
18
|
* members on the merged commit, stores the change set and writes the merge
|
|
@@ -80,6 +83,7 @@
|
|
|
80
83
|
import type { ForgeKind } from "../pr-forge.js";
|
|
81
84
|
import type { DriverComponent } from "./driver.js";
|
|
82
85
|
import type { GatedWavePipelineOptions } from "./gated-wave-pipeline.js";
|
|
86
|
+
import type { PipelineCloudIdentity } from "../ci-identity.js";
|
|
83
87
|
/** Where both jobs write their reports, kept as a CI artifact. */
|
|
84
88
|
export declare const PR_LOOP_REPORT_DIR = ".chant/pr";
|
|
85
89
|
/**
|
|
@@ -156,11 +160,27 @@ export interface PrLoopPipelineOptions {
|
|
|
156
160
|
* wave. Set from `--wave-gate` beside `--pr-loop` ({@link prLoopWithWaves}).
|
|
157
161
|
*/
|
|
158
162
|
waveGate?: string;
|
|
163
|
+
/**
|
|
164
|
+
* The plan and apply cloud identities (#4296), from `ci.identity.cloud`
|
|
165
|
+
* resolved for the pipeline's environment and member
|
|
166
|
+
* (`resolveCloudIdentity` in ../ci-identity.ts). The plan job trades its
|
|
167
|
+
* OIDC token for the plan identity before the checkout, the record job
|
|
168
|
+
* for the plan identity, and the apply jobs for the apply identity.
|
|
169
|
+
* Absent: no job requests an OIDC token.
|
|
170
|
+
*/
|
|
171
|
+
identity?: PipelineCloudIdentity;
|
|
159
172
|
/**
|
|
160
173
|
* Which GitHub-shaped forge the workflow is for. Set by the forgejo
|
|
161
174
|
* generator, which reuses the github one; a caller never needs to.
|
|
162
175
|
*/
|
|
163
176
|
forge?: "github" | "forgejo";
|
|
177
|
+
/**
|
|
178
|
+
* An environment per open pull request (#4298, `ci.prEnvironment`): an
|
|
179
|
+
* `env-up` job on each opened, updated or reopened pull request, an
|
|
180
|
+
* `env-down` job when it closes, and an `env-sweep` job on a schedule
|
|
181
|
+
* ({@link prEnvJobs}). Set from `--pr-env` beside `--pr-loop`. Default false.
|
|
182
|
+
*/
|
|
183
|
+
prEnvironment?: boolean;
|
|
164
184
|
}
|
|
165
185
|
/** One job's command and the forge values it reads, as environment variables for its step. */
|
|
166
186
|
export interface PrLoopJob {
|
|
@@ -215,6 +235,22 @@ export declare function prLoopBuildLines(env: string, options?: PrLoopPipelineOp
|
|
|
215
235
|
* the commands then run in its directory, so `--output` is relative to it.
|
|
216
236
|
*/
|
|
217
237
|
export declare function prLoopJobs(forge: ForgeKind, env: string, options?: PrLoopPipelineOptions, member?: string): PrLoopJob[];
|
|
238
|
+
/** The name of the job that posts the plan's note and status (#4295). */
|
|
239
|
+
export declare const PR_PLAN_NOTE_JOB = "plan-note";
|
|
240
|
+
/**
|
|
241
|
+
* The plan-note job's command and the values it reads (#4295). It runs in a
|
|
242
|
+
* fresh job after the plan, at the target branch's commit, and posts the
|
|
243
|
+
* note and the `chant/plan` status from the report the plan job handed on,
|
|
244
|
+
* with the forge token the plan job never held. `HEAD_SHA` is the commit
|
|
245
|
+
* the plan job checked out, `PR_NUMBER` the pull request, and on GitHub and
|
|
246
|
+
* Forgejo `PLAN_RESULT` the plan job's result, which fails the status when
|
|
247
|
+
* the plan job failed. `BASE_SHA` is the commit the note job checks out on
|
|
248
|
+
* GitLab, whose runner checks out the pipeline's own commit.
|
|
249
|
+
*/
|
|
250
|
+
export declare function prLoopPostJob(forge: ForgeKind, env: string, member?: string): {
|
|
251
|
+
command: string;
|
|
252
|
+
env: Record<string, string>;
|
|
253
|
+
};
|
|
218
254
|
/**
|
|
219
255
|
* What starts the apply under apply on merge (#4168 step 9): on GitHub the
|
|
220
256
|
* tick's workflow finishing (`workflow_run`, since tags its token pushes start
|
|
@@ -290,4 +326,38 @@ export declare function gitlabBaseFallback(branch?: string): string;
|
|
|
290
326
|
* generators' default.
|
|
291
327
|
*/
|
|
292
328
|
export declare function githubBaseFallback(branch?: string): string;
|
|
329
|
+
/** Where the pull request environment jobs (#4298) write their reports, kept as a CI artifact. */
|
|
330
|
+
export declare const PR_ENV_REPORT_DIR = ".chant/pr-env";
|
|
331
|
+
/** The cron the generated `env-sweep` job runs on (#4298): hourly, at a minute off the hour. */
|
|
332
|
+
export declare const PR_ENV_SWEEP_CRON = "17 * * * *";
|
|
333
|
+
/** One job of a pull request's environment (#4298): its command and the forge values it reads. */
|
|
334
|
+
export interface PrEnvJob {
|
|
335
|
+
jobName: "env-up" | "env-post" | "env-down" | "env-sweep";
|
|
336
|
+
/** The command line. `env-up` reads `$BASE_SHA` and `$PR_NUMBER`, `env-down` `$PR_NUMBER`. */
|
|
337
|
+
command: string;
|
|
338
|
+
/** Values the command reads, as the forge spells them. `CHANT_ENV` is the pull request's environment. */
|
|
339
|
+
env: Record<string, string>;
|
|
340
|
+
/** With `build`: the build and lint lines, run before the command. */
|
|
341
|
+
build?: string[];
|
|
342
|
+
}
|
|
343
|
+
/** The name of the job that keeps an environment's record and posts its note (#4298, #4295). */
|
|
344
|
+
export declare const PR_ENV_POST_JOB = "env-post";
|
|
345
|
+
/**
|
|
346
|
+
* The jobs of a pull request's environment (#4298), when `prEnvironment` is
|
|
347
|
+
* on, in this order:
|
|
348
|
+
*
|
|
349
|
+
* - `env-up` runs `chant components pr-env up --no-push`. It runs the
|
|
350
|
+
* change's code, so it gets no forge token (#4295): it passes no
|
|
351
|
+
* `--forge`, and it hands its report and its record on.
|
|
352
|
+
* - `env-post` runs `pr-env post` in a fresh job at the target branch's
|
|
353
|
+
* commit, with the token: it keeps the record on chant/lifecycle and posts
|
|
354
|
+
* the note and the `chant/pr-env` status. On GitHub and Forgejo it reads
|
|
355
|
+
* the up job's result as `UP_RESULT`.
|
|
356
|
+
* - `env-down` runs `pr-env down --reason closed`, and `env-sweep` runs
|
|
357
|
+
* `pr-env sweep`. Neither builds the change's code: a teardown reads the
|
|
358
|
+
* markers off the live resources.
|
|
359
|
+
*
|
|
360
|
+
* Each writes its report under {@link PR_ENV_REPORT_DIR}.
|
|
361
|
+
*/
|
|
362
|
+
export declare function prEnvJobs(forge: ForgeKind, options?: PrLoopPipelineOptions, member?: string): PrEnvJob[];
|
|
293
363
|
//# sourceMappingURL=pr-pipeline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr-pipeline.d.ts","sourceRoot":"","sources":["../../src/components/pr-pipeline.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"pr-pipeline.d.ts","sourceRoot":"","sources":["../../src/components/pr-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAM7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAK5D,kEAAkE;AAClE,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,eAAe,mCAAmC,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,YAAW,CAAC;AAEtC,8CAA8C;AAC9C,eAAO,MAAM,aAAa,UAEzB,CAAC;AAEF,mHAAmH;AACnH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEnD;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,yBAAqC,CAAC;AAErE,yEAAyE;AACzE,MAAM,WAAW,qBAAqB;IACpC,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sIAAsI;IACtI,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,2OAA2O;IAC3O,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,MA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M,CAAC,EAAE,MAAM,GAAG,MAAM,CAErF;AAoBD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1D;AAOD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,kGAAkG;AAClG,eAAO,MAAM,iBAAiB,kBAAkB,CAAC;AAEjD,gGAAgG;AAChG,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAE9C,kGAAkG;AAClG,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,QAAQ,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,CAAC;IAC1D,8FAA8F;IAC9F,OAAO,EAAE,MAAM,CAAC;IAChB,yGAAyG;IACzG,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,gGAAgG;AAChG,eAAO,MAAM,eAAe,aAAa,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,GAAE,qBAA0B,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,EAAE,CAkC5G"}
|
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
* values they read from the forge live here so the three cannot disagree.
|
|
9
9
|
*
|
|
10
10
|
* - The plan job runs `chant components pr-plan` against the pull request's
|
|
11
|
-
* target commit. It
|
|
12
|
-
*
|
|
11
|
+
* target commit. It writes nothing to `chant/lifecycle` and holds no forge
|
|
12
|
+
* token, since it runs the pull request's code (#4295): it writes the note
|
|
13
|
+
* and the status into its report with `--no-status`, and the `plan-note`
|
|
14
|
+
* job after it posts them with `chant components pr-post`
|
|
15
|
+
* ({@link prLoopPostJob}, ../ci-handover.ts).
|
|
13
16
|
* - The record job (#4168 step 1, the default) runs `chant components
|
|
14
17
|
* pr-record` against the commit the push replaced. It plans the same
|
|
15
18
|
* members on the merged commit, stores the change set and writes the merge
|
|
@@ -79,6 +82,7 @@
|
|
|
79
82
|
*/
|
|
80
83
|
import { PR_APPLY_GATE } from "../pr-loop.js";
|
|
81
84
|
import { CI_IMAGE, GITHUB_JOB_TOKEN } from "../ci-jobs.js";
|
|
85
|
+
import { withoutForgeTokens } from "../ci-handover.js";
|
|
82
86
|
import { EMPTY_TREE_SHA } from "./changed-files.js";
|
|
83
87
|
import { layerWaves } from "../gated-waves.js";
|
|
84
88
|
/** The variable `chant ci run` reads its runner key from (`RUNNER_KEY_ENV` in ../workspace/ci-green.ts). */
|
|
@@ -152,16 +156,18 @@ export function prLoopJobs(forge, env, options = {}, member) {
|
|
|
152
156
|
...(options.reportUrl ? ["--report-url", JSON.stringify(options.reportUrl)] : []),
|
|
153
157
|
];
|
|
154
158
|
const runEnv = (env) => (github ? { ...env, [RUNNER_KEY_ENV]: `\${{ secrets.${RUNNER_KEY_ENV} }}` } : env);
|
|
159
|
+
// #4295: the plan runs the pull request's code, so it gets no forge token. It writes the note and the
|
|
160
|
+
// status into its report (--no-status), and the plan-note job posts them (prLoopPostJob).
|
|
155
161
|
const planEnv = github
|
|
156
|
-
? { BASE_SHA: "${{ github.event.pull_request.base.sha }}", PR_NUMBER: "${{ github.event.pull_request.number }}", ...jobEnv }
|
|
157
|
-
: { BASE_SHA: "$CI_MERGE_REQUEST_DIFF_BASE_SHA", PR_NUMBER: "$CI_MERGE_REQUEST_IID", ...jobEnv };
|
|
162
|
+
? { BASE_SHA: "${{ github.event.pull_request.base.sha }}", PR_NUMBER: "${{ github.event.pull_request.number }}", ...withoutForgeTokens(jobEnv) }
|
|
163
|
+
: { BASE_SHA: "$CI_MERGE_REQUEST_DIFF_BASE_SHA", PR_NUMBER: "$CI_MERGE_REQUEST_IID", ...withoutForgeTokens(jobEnv) };
|
|
158
164
|
const greenBranch = github ? JSON.stringify(options.branch ?? "main") : options.branch ? JSON.stringify(options.branch) : "$CI_DEFAULT_BRANCH";
|
|
159
165
|
const applyEnv = github ? { BASE_SHA: "${{ github.event.before }}", ...jobEnv } : { BASE_SHA: "$CI_COMMIT_BEFORE_SHA", ...jobEnv };
|
|
160
166
|
return [
|
|
161
167
|
{
|
|
162
168
|
jobName: "plan",
|
|
163
169
|
// With `waveGate` the plan's note says the later waves may stop at their own gates (#4003).
|
|
164
|
-
command: ["chant", "components", "pr-plan", "--base", '"$BASE_SHA"', "--pr", '"$PR_NUMBER"', ...common, ...(options.waveGate ? ["--wave-gate", options.waveGate] : [])].join(" "),
|
|
170
|
+
command: ["chant", "components", "pr-plan", "--base", '"$BASE_SHA"', "--pr", '"$PR_NUMBER"', ...common, ...(options.waveGate ? ["--wave-gate", options.waveGate] : []), "--no-status"].join(" "),
|
|
165
171
|
env: planEnv,
|
|
166
172
|
...build,
|
|
167
173
|
run: { command: ciRun("plan").join(" "), env: runEnv(planEnv) },
|
|
@@ -191,6 +197,33 @@ export function prLoopJobs(forge, env, options = {}, member) {
|
|
|
191
197
|
},
|
|
192
198
|
];
|
|
193
199
|
}
|
|
200
|
+
/** The name of the job that posts the plan's note and status (#4295). */
|
|
201
|
+
export const PR_PLAN_NOTE_JOB = "plan-note";
|
|
202
|
+
/**
|
|
203
|
+
* The plan-note job's command and the values it reads (#4295). It runs in a
|
|
204
|
+
* fresh job after the plan, at the target branch's commit, and posts the
|
|
205
|
+
* note and the `chant/plan` status from the report the plan job handed on,
|
|
206
|
+
* with the forge token the plan job never held. `HEAD_SHA` is the commit
|
|
207
|
+
* the plan job checked out, `PR_NUMBER` the pull request, and on GitHub and
|
|
208
|
+
* Forgejo `PLAN_RESULT` the plan job's result, which fails the status when
|
|
209
|
+
* the plan job failed. `BASE_SHA` is the commit the note job checks out on
|
|
210
|
+
* GitLab, whose runner checks out the pipeline's own commit.
|
|
211
|
+
*/
|
|
212
|
+
export function prLoopPostJob(forge, env, member) {
|
|
213
|
+
const github = forge !== "gitlab";
|
|
214
|
+
const command = [
|
|
215
|
+
"chant", "components", "pr-post", "--pr", '"$PR_NUMBER"', "--head", '"$HEAD_SHA"',
|
|
216
|
+
"--env", env, "--output", PR_LOOP_REPORT_DIR, "--forge", forge,
|
|
217
|
+
...(member ? ["--member", member] : []),
|
|
218
|
+
...(github ? ["--result", '"$PLAN_RESULT"'] : []),
|
|
219
|
+
].join(" ");
|
|
220
|
+
return {
|
|
221
|
+
command,
|
|
222
|
+
env: github
|
|
223
|
+
? { PR_NUMBER: "${{ github.event.pull_request.number }}", HEAD_SHA: "${{ github.sha }}", PLAN_RESULT: "${{ needs.plan.result }}", GITHUB_TOKEN: GITHUB_JOB_TOKEN }
|
|
224
|
+
: { PR_NUMBER: "$CI_MERGE_REQUEST_IID", HEAD_SHA: "$CI_COMMIT_SHA", BASE_SHA: "$CI_MERGE_REQUEST_DIFF_BASE_SHA" },
|
|
225
|
+
};
|
|
226
|
+
}
|
|
194
227
|
/**
|
|
195
228
|
* What starts the apply under apply on merge (#4168 step 9): on GitHub the
|
|
196
229
|
* tick's workflow finishing (`workflow_run`, since tags its token pushes start
|
|
@@ -324,3 +357,61 @@ export function gitlabBaseFallback(branch) {
|
|
|
324
357
|
export function githubBaseFallback(branch) {
|
|
325
358
|
return pushBaseFallback(JSON.stringify(branch ?? "main"), "$GITHUB_SHA");
|
|
326
359
|
}
|
|
360
|
+
/** Where the pull request environment jobs (#4298) write their reports, kept as a CI artifact. */
|
|
361
|
+
export const PR_ENV_REPORT_DIR = ".chant/pr-env";
|
|
362
|
+
/** The cron the generated `env-sweep` job runs on (#4298): hourly, at a minute off the hour. */
|
|
363
|
+
export const PR_ENV_SWEEP_CRON = "17 * * * *";
|
|
364
|
+
/** The name of the job that keeps an environment's record and posts its note (#4298, #4295). */
|
|
365
|
+
export const PR_ENV_POST_JOB = "env-post";
|
|
366
|
+
/**
|
|
367
|
+
* The jobs of a pull request's environment (#4298), when `prEnvironment` is
|
|
368
|
+
* on, in this order:
|
|
369
|
+
*
|
|
370
|
+
* - `env-up` runs `chant components pr-env up --no-push`. It runs the
|
|
371
|
+
* change's code, so it gets no forge token (#4295): it passes no
|
|
372
|
+
* `--forge`, and it hands its report and its record on.
|
|
373
|
+
* - `env-post` runs `pr-env post` in a fresh job at the target branch's
|
|
374
|
+
* commit, with the token: it keeps the record on chant/lifecycle and posts
|
|
375
|
+
* the note and the `chant/pr-env` status. On GitHub and Forgejo it reads
|
|
376
|
+
* the up job's result as `UP_RESULT`.
|
|
377
|
+
* - `env-down` runs `pr-env down --reason closed`, and `env-sweep` runs
|
|
378
|
+
* `pr-env sweep`. Neither builds the change's code: a teardown reads the
|
|
379
|
+
* markers off the live resources.
|
|
380
|
+
*
|
|
381
|
+
* Each writes its report under {@link PR_ENV_REPORT_DIR}.
|
|
382
|
+
*/
|
|
383
|
+
export function prEnvJobs(forge, options = {}, member) {
|
|
384
|
+
const github = forge !== "gitlab";
|
|
385
|
+
const out = ["--output", PR_ENV_REPORT_DIR, ...(member ? ["--member", member] : [])];
|
|
386
|
+
const common = ["--forge", forge, ...out];
|
|
387
|
+
const token = github ? { GITHUB_TOKEN: GITHUB_JOB_TOKEN } : {};
|
|
388
|
+
const prNumber = github ? "${{ github.event.pull_request.number }}" : "$CI_MERGE_REQUEST_IID";
|
|
389
|
+
const prEnv = { CHANT_ENV: `pr-${prNumber}` };
|
|
390
|
+
const buildLines = prLoopBuildLines('"$CHANT_ENV"', options);
|
|
391
|
+
return [
|
|
392
|
+
{
|
|
393
|
+
jobName: "env-up",
|
|
394
|
+
// #4295: no --forge and no token; the record stays in the report directory for env-post.
|
|
395
|
+
command: ["chant", "components", "pr-env", "up", "--base", '"$BASE_SHA"', "--pr", '"$PR_NUMBER"', ...out, "--no-push"].join(" "),
|
|
396
|
+
env: { BASE_SHA: github ? "${{ github.event.pull_request.base.sha }}" : "$CI_MERGE_REQUEST_DIFF_BASE_SHA", PR_NUMBER: prNumber, ...prEnv },
|
|
397
|
+
...(buildLines.length > 0 ? { build: buildLines } : {}),
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
jobName: PR_ENV_POST_JOB,
|
|
401
|
+
command: ["chant", "components", "pr-env", "post", "--pr", '"$PR_NUMBER"', "--head", '"$HEAD_SHA"', ...common, ...(github ? ["--result", '"$UP_RESULT"'] : [])].join(" "),
|
|
402
|
+
env: github
|
|
403
|
+
? { PR_NUMBER: prNumber, HEAD_SHA: "${{ github.sha }}", UP_RESULT: "${{ needs.env-up.result }}", ...token }
|
|
404
|
+
: { PR_NUMBER: prNumber, HEAD_SHA: "$CI_COMMIT_SHA", BASE_SHA: "$CI_MERGE_REQUEST_DIFF_BASE_SHA" },
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
jobName: "env-down",
|
|
408
|
+
command: ["chant", "components", "pr-env", "down", "--pr", '"$PR_NUMBER"', "--reason", "closed", ...common].join(" "),
|
|
409
|
+
env: { PR_NUMBER: prNumber, ...prEnv, ...token },
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
jobName: "env-sweep",
|
|
413
|
+
command: ["chant", "components", "pr-env", "sweep", ...common].join(" "),
|
|
414
|
+
env: { ...token },
|
|
415
|
+
},
|
|
416
|
+
];
|
|
417
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate-time policy on the pull-request path (#4294): `ci.policy` in the
|
|
3
|
+
* workspace declaration, run by `chant components pr-plan` and `pr-apply`
|
|
4
|
+
* over the change-set document the gate binds (`CapabilityPlan.changeSet`,
|
|
5
|
+
* composed by `planPrSet`).
|
|
6
|
+
*
|
|
7
|
+
* The settings and the policy directory are both read at the base the job
|
|
8
|
+
* measures the change from, so a pull request cannot loosen, edit or delete
|
|
9
|
+
* the policy that judges it. The engine and its result shapes are
|
|
10
|
+
* `../gate-policy.ts`.
|
|
11
|
+
*
|
|
12
|
+
* - deny: pr-apply applies nothing unless an override counts
|
|
13
|
+
* (`../override-gate.ts`, subject the gate's op, such as `pr-12`). The
|
|
14
|
+
* first refusal records the denial on `_gates/policy-override.jsonl`, so
|
|
15
|
+
* `chant approve policy-override <op> --rule <id> --reason <text>` can
|
|
16
|
+
* answer it. The gate's own approval is still needed. The override is
|
|
17
|
+
* spent just before anything applies.
|
|
18
|
+
* - hold: the plan needs a person's approval of its own digest. pr-apply
|
|
19
|
+
* always asks for one, so a hold changes one path: a green commit's plan
|
|
20
|
+
* no longer applies under the approvals of the merges it carries.
|
|
21
|
+
* - error: the policy did not run or gave no readable answer. pr-apply
|
|
22
|
+
* applies nothing.
|
|
23
|
+
*/
|
|
24
|
+
import type { WorkspaceTree } from "../workspace/tree.js";
|
|
25
|
+
import { type GatePolicyExec, type GatePolicySettings, type GatePolicyVerdict } from "../gate-policy.js";
|
|
26
|
+
import type { ChangeSetDocument } from "../change-set.js";
|
|
27
|
+
import type { GateLedgerPort } from "../op/gate.js";
|
|
28
|
+
import type { PrPolicyReport } from "../pr-loop.js";
|
|
29
|
+
/** `ci.policy` as read at base. */
|
|
30
|
+
export interface PrLoopPolicy {
|
|
31
|
+
/** Absent when the declaration at base sets none. */
|
|
32
|
+
settings?: GatePolicySettings;
|
|
33
|
+
/** The commit it was read at. */
|
|
34
|
+
base: string;
|
|
35
|
+
/** The tree of the declaration's directory at base, where the policy directory is read. */
|
|
36
|
+
tree?: WorkspaceTree;
|
|
37
|
+
/** A line for the log when no policy runs because the base has no declaration, or could not be read. */
|
|
38
|
+
note?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The policy a pull-request job in `cwd` runs, from the declaration at
|
|
42
|
+
* `base`. Throws when the declaration at base cannot be read and the
|
|
43
|
+
* working tree's names a policy: running none would let the change waive it.
|
|
44
|
+
*/
|
|
45
|
+
export declare function prLoopPolicyAt(cwd: string, base: string): PrLoopPolicy;
|
|
46
|
+
/** What the engine reads as `input`. */
|
|
47
|
+
export interface PrPolicyInput {
|
|
48
|
+
version: 1;
|
|
49
|
+
stage: "plan" | "apply";
|
|
50
|
+
/** The gate's op, `pr-<n>`. */
|
|
51
|
+
op: string;
|
|
52
|
+
gate: string;
|
|
53
|
+
env: string;
|
|
54
|
+
pr: number | null;
|
|
55
|
+
base: string;
|
|
56
|
+
head: string;
|
|
57
|
+
/** The change-set document the gate binds. Its `entries` are every change the plan proposes. */
|
|
58
|
+
changeSet: ChangeSetDocument;
|
|
59
|
+
}
|
|
60
|
+
/** Run the policy over `input`. Undefined when the base sets no policy. */
|
|
61
|
+
export declare function runPrPolicy(read: PrLoopPolicy, input: PrPolicyInput, exec?: GatePolicyExec): GatePolicyVerdict | undefined;
|
|
62
|
+
/** The verdict as the report keeps it. */
|
|
63
|
+
export declare function prPolicyReport(verdict: GatePolicyVerdict, base: string): PrPolicyReport;
|
|
64
|
+
export interface PrPolicyOverrideInput {
|
|
65
|
+
port: GateLedgerPort;
|
|
66
|
+
/** The override's subject: the gate's op. */
|
|
67
|
+
subject: string;
|
|
68
|
+
/** The digest the gate binds: the change-set document's. */
|
|
69
|
+
digest: string;
|
|
70
|
+
rules: readonly string[];
|
|
71
|
+
/** The commit the overriders and signers are read at. */
|
|
72
|
+
base: string;
|
|
73
|
+
cwd: string;
|
|
74
|
+
/** Count only sealed overrides, as a sealed gate counts only sealed approvals. */
|
|
75
|
+
sealed: boolean;
|
|
76
|
+
/** Record the denial when no override counts and none stands. The plan stage records nothing. */
|
|
77
|
+
record: boolean;
|
|
78
|
+
description?: string;
|
|
79
|
+
now?: string;
|
|
80
|
+
}
|
|
81
|
+
/** Where an override of a denial stands. */
|
|
82
|
+
export type PrPolicyOverride = {
|
|
83
|
+
status: "overridden";
|
|
84
|
+
override: NonNullable<PrPolicyReport["override"]>;
|
|
85
|
+
} | {
|
|
86
|
+
status: "none";
|
|
87
|
+
refusals: string[];
|
|
88
|
+
command: string;
|
|
89
|
+
overriders: string[];
|
|
90
|
+
recorded: boolean;
|
|
91
|
+
moved?: {
|
|
92
|
+
by: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Decide a denied plan against the override ledger, as an Op waves job
|
|
97
|
+
* decides a denied run (`settleDenials` in `../op/op-waves-run.ts`).
|
|
98
|
+
*/
|
|
99
|
+
export declare function decidePrPolicyOverride(input: PrPolicyOverrideInput): Promise<PrPolicyOverride>;
|
|
100
|
+
/**
|
|
101
|
+
* Spend the override the apply runs under: append its applied record before
|
|
102
|
+
* anything applies. Throws when it could not be written or did not reach the
|
|
103
|
+
* remote, and the caller applies nothing.
|
|
104
|
+
*/
|
|
105
|
+
export declare function spendPrPolicyOverride(port: GateLedgerPort, subject: string, override: NonNullable<PrPolicyReport["override"]>, at?: {
|
|
106
|
+
now?: string;
|
|
107
|
+
commit?: string;
|
|
108
|
+
}): Promise<void>;
|
|
109
|
+
//# sourceMappingURL=pr-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pr-policy.d.ts","sourceRoot":"","sources":["../../src/components/pr-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,mCAAmC;AACnC,MAAM,WAAW,YAAY;IAC3B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAC9B,iCAAiC;IACj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AAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,4CAA4C;AAC5C,MAAM,MAAM,gBAAgB,GACxB;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,QAAQ,EAAE,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAA;CAAE,GAC3E;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAE7H;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2CpG;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAS/L"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate-time policy on the pull-request path (#4294): `ci.policy` in the
|
|
3
|
+
* workspace declaration, run by `chant components pr-plan` and `pr-apply`
|
|
4
|
+
* over the change-set document the gate binds (`CapabilityPlan.changeSet`,
|
|
5
|
+
* composed by `planPrSet`).
|
|
6
|
+
*
|
|
7
|
+
* The settings and the policy directory are both read at the base the job
|
|
8
|
+
* measures the change from, so a pull request cannot loosen, edit or delete
|
|
9
|
+
* the policy that judges it. The engine and its result shapes are
|
|
10
|
+
* `../gate-policy.ts`.
|
|
11
|
+
*
|
|
12
|
+
* - deny: pr-apply applies nothing unless an override counts
|
|
13
|
+
* (`../override-gate.ts`, subject the gate's op, such as `pr-12`). The
|
|
14
|
+
* first refusal records the denial on `_gates/policy-override.jsonl`, so
|
|
15
|
+
* `chant approve policy-override <op> --rule <id> --reason <text>` can
|
|
16
|
+
* answer it. The gate's own approval is still needed. The override is
|
|
17
|
+
* spent just before anything applies.
|
|
18
|
+
* - hold: the plan needs a person's approval of its own digest. pr-apply
|
|
19
|
+
* always asks for one, so a hold changes one path: a green commit's plan
|
|
20
|
+
* no longer applies under the approvals of the merges it carries.
|
|
21
|
+
* - error: the policy did not run or gave no readable answer. pr-apply
|
|
22
|
+
* applies nothing.
|
|
23
|
+
*/
|
|
24
|
+
import { readDeclaration, WorkspaceReadError } from "../workspace/declaration.js";
|
|
25
|
+
import { locateWorkspace } from "../workspace/which-chant.js";
|
|
26
|
+
import { checkGatePolicy, DEFAULT_POLICY_PATH, exportGatePolicy, } from "../gate-policy.js";
|
|
27
|
+
/** Whether the working tree's declaration names a `ci.policy`. */
|
|
28
|
+
function checkoutNamesPolicy(cwd) {
|
|
29
|
+
try {
|
|
30
|
+
return readDeclaration(locateWorkspace(cwd).tree).ci?.policy !== undefined;
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The policy a pull-request job in `cwd` runs, from the declaration at
|
|
38
|
+
* `base`. Throws when the declaration at base cannot be read and the
|
|
39
|
+
* working tree's names a policy: running none would let the change waive it.
|
|
40
|
+
*/
|
|
41
|
+
export function prLoopPolicyAt(cwd, base) {
|
|
42
|
+
try {
|
|
43
|
+
const located = locateWorkspace(cwd, base);
|
|
44
|
+
const settings = readDeclaration(located.tree).ci?.policy;
|
|
45
|
+
return { base, ...(settings ? { settings, tree: located.tree } : {}) };
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
const missing = err instanceof WorkspaceReadError && (err.code === "declaration-missing" || err.code === "not-a-git-repository");
|
|
49
|
+
const why = err instanceof Error ? err.message : String(err);
|
|
50
|
+
if (checkoutNamesPolicy(cwd)) {
|
|
51
|
+
if (missing)
|
|
52
|
+
return { base, note: `ci.policy: the base ${base.slice(0, 12)} has no workspace declaration, so the policy this change declares runs once it merges` };
|
|
53
|
+
throw new Error(`ci.policy is read from the workspace declaration at ${base.slice(0, 12)}, and it could not be read (${why}), so the policy cannot be run`);
|
|
54
|
+
}
|
|
55
|
+
return missing ? { base } : { base, note: `ci.policy: the declaration at ${base.slice(0, 12)} could not be read (${why}); this checkout names no policy, so none runs` };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Run the policy over `input`. Undefined when the base sets no policy. */
|
|
59
|
+
export function runPrPolicy(read, input, exec) {
|
|
60
|
+
if (!read.settings || !read.tree)
|
|
61
|
+
return undefined;
|
|
62
|
+
const engine = read.settings.engine ?? "conftest";
|
|
63
|
+
const path = read.settings.path ?? DEFAULT_POLICY_PATH;
|
|
64
|
+
const exported = exportGatePolicy(read.tree, path);
|
|
65
|
+
if ("error" in exported)
|
|
66
|
+
return { result: "error", engine, denials: [], rules: [], holds: [], warnings: [], error: exported.error };
|
|
67
|
+
try {
|
|
68
|
+
return checkGatePolicy({ settings: read.settings, input, policyDir: exported.dir, cwd: process.cwd(), ...(exec ? { exec } : {}) });
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
exported.cleanup();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** The verdict as the report keeps it. */
|
|
75
|
+
export function prPolicyReport(verdict, base) {
|
|
76
|
+
return {
|
|
77
|
+
result: verdict.result,
|
|
78
|
+
engine: verdict.engine,
|
|
79
|
+
base,
|
|
80
|
+
denials: verdict.denials,
|
|
81
|
+
...(verdict.rules.length > 0 ? { rules: verdict.rules } : {}),
|
|
82
|
+
holds: verdict.holds,
|
|
83
|
+
warnings: verdict.warnings,
|
|
84
|
+
...(verdict.error !== undefined ? { error: verdict.error } : {}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Decide a denied plan against the override ledger, as an Op waves job
|
|
89
|
+
* decides a denied run (`settleDenials` in `../op/op-waves-run.ts`).
|
|
90
|
+
*/
|
|
91
|
+
export async function decidePrPolicyOverride(input) {
|
|
92
|
+
const og = await import("../override-gate.js");
|
|
93
|
+
const overriders = og.overridersAt(input.cwd, input.base).principals;
|
|
94
|
+
const signers = input.sealed ? (await import("../gate-decision.js")).gateSignersAt(input.cwd, input.base) : undefined;
|
|
95
|
+
const ledger = await input.port.read(og.OVERRIDE_OP);
|
|
96
|
+
const applied = ((await input.port.readApplied?.(og.OVERRIDE_OP)) ?? []);
|
|
97
|
+
const now = input.now ?? new Date().toISOString();
|
|
98
|
+
const verdict = og.decideOverride({
|
|
99
|
+
ledger,
|
|
100
|
+
applied,
|
|
101
|
+
subject: input.subject,
|
|
102
|
+
planDigest: input.digest,
|
|
103
|
+
rules: input.rules,
|
|
104
|
+
overriders,
|
|
105
|
+
mode: input.sealed ? "sealed" : "ledger",
|
|
106
|
+
...(signers ? { signers } : {}),
|
|
107
|
+
now,
|
|
108
|
+
});
|
|
109
|
+
if (verdict.status === "overridden") {
|
|
110
|
+
const o = verdict.override;
|
|
111
|
+
return { status: "overridden", override: { by: o.by, at: o.at, reason: o.reason, digest: o.digest } };
|
|
112
|
+
}
|
|
113
|
+
let recorded = false;
|
|
114
|
+
if (input.record && !verdict.standing) {
|
|
115
|
+
const { version: _v, kind: _k, ...fact } = og.overridePending({
|
|
116
|
+
subject: input.subject,
|
|
117
|
+
planDigest: input.digest,
|
|
118
|
+
rules: input.rules,
|
|
119
|
+
timestamp: now,
|
|
120
|
+
expiresAt: new Date(new Date(now).getTime() + 48 * 3600 * 1000).toISOString(),
|
|
121
|
+
...(input.description ? { description: input.description } : {}),
|
|
122
|
+
});
|
|
123
|
+
await input.port.appendPending(fact);
|
|
124
|
+
recorded = true;
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
status: "none",
|
|
128
|
+
refusals: verdict.refusals,
|
|
129
|
+
command: og.overrideCommand(input.subject, input.rules, input.sealed),
|
|
130
|
+
overriders,
|
|
131
|
+
recorded,
|
|
132
|
+
...(verdict.status === "moved" ? { moved: { by: verdict.by } } : {}),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Spend the override the apply runs under: append its applied record before
|
|
137
|
+
* anything applies. Throws when it could not be written or did not reach the
|
|
138
|
+
* remote, and the caller applies nothing.
|
|
139
|
+
*/
|
|
140
|
+
export async function spendPrPolicyOverride(port, subject, override, at = {}) {
|
|
141
|
+
const og = await import("../override-gate.js");
|
|
142
|
+
if (!port.appendApplied)
|
|
143
|
+
throw new Error("this gate ledger cannot record an applied override");
|
|
144
|
+
const record = og.appliedOverride({ subject, digest: override.digest, at: override.at, by: override.by }, { timestamp: at.now ?? new Date().toISOString(), ...(at.commit ? { commit: at.commit } : {}) });
|
|
145
|
+
const pushed = await port.appendApplied(record);
|
|
146
|
+
const { isLifecycleLocalNote } = await import("../lifecycle/local-note.js");
|
|
147
|
+
if (!pushed.pushed && !isLifecycleLocalNote(pushed.pushWarning)) {
|
|
148
|
+
throw new Error(`the applied record did not reach the remote the next run reads: ${pushed.pushWarning ?? "the push did not land"}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr-run.d.ts","sourceRoot":"","sources":["../../src/components/pr-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAEH,OAAO,EAA2C,KAAK,iBAAiB,EAA2C,MAAM,eAAe,CAAC;AACzI,OAAO,EAAgB,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAML,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK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|
const held = new Map((run.held ?? []).map((h) => [h.component, h]));
|
|
378
|
-
const blocked = new
|
|
378
|
+
const blocked = new Map(run.blocked.map((b) => [b.component, b.blockedBy]));
|
|
379
379
|
const errorOf = (component) => {
|
|
380
380
|
const result = [...run.results].reverse().find((r) => r.component === component);
|
|
381
381
|
if (result?.status === "gated")
|
|
@@ -395,8 +395,10 @@ export async function applyPrSet(options) {
|
|
|
395
395
|
return { ...asPlanned, status: "waiting", held: h.heldBy ? `${h.heldBy} is held: ${h.reason}` : h.reason };
|
|
396
396
|
if (fresh?.status === "plan-failed")
|
|
397
397
|
return { ...asPlanned, status: "plan-failed", ...(fresh.error ? { error: fresh.error } : {}) };
|
|
398
|
-
if (blocked.has(m.component))
|
|
399
|
-
|
|
398
|
+
if (blocked.has(m.component)) {
|
|
399
|
+
const by = blocked.get(m.component);
|
|
400
|
+
return { ...asPlanned, status: "blocked", ...(by ? { blockedBy: by } : {}) };
|
|
401
|
+
}
|
|
400
402
|
const error = errorOf(m.component);
|
|
401
403
|
return { ...asPlanned, status: "failed", ...(error ? { error } : {}) };
|
|
402
404
|
});
|
package/dist/gate-decision.d.ts
CHANGED
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
* counts for nothing, as terragucci's wave gate has it: the caller hands in
|
|
28
28
|
* the lines of `_gates/<op>/applied.jsonl` ({@link parseAppliedGateLines}).
|
|
29
29
|
*
|
|
30
|
+
* Approval rules (#4290), a quorum as a list of `{ targets, count, roles,
|
|
31
|
+
* notAuthor }`, are judged with `./op/gate-quorum.ts`, re-exported here:
|
|
32
|
+
* {@link trustRolesAt} and {@link gateSignersAt} read what
|
|
33
|
+
* `trustQuorumJudge` judges by, at base.
|
|
34
|
+
*
|
|
30
35
|
* The module reads the ledger lines and the review it is handed; reading
|
|
31
36
|
* them is the caller's. It imports no TypeScript, esbuild, zod, ajv, lint,
|
|
32
37
|
* fold or codegen module, no package's code, and none of chant's git ledger
|
|
@@ -36,19 +41,20 @@
|
|
|
36
41
|
* `gate-decision.test.ts` decides the same ledgers both ways.
|
|
37
42
|
*/
|
|
38
43
|
import { type AppliedGateRecord } from "./lifecycle/gate-applied.js";
|
|
39
|
-
import { type GateSigners, type SealedGateApproval } from "./
|
|
44
|
+
import { type GateSigners, type SealedGateApproval } from "./lifecycle/gate-seal.js";
|
|
40
45
|
import { type ClassGrant } from "./workspace/identity-gate-rule.js";
|
|
41
46
|
import type { GateResolutionRecord, PendingGateRecord } from "./lifecycle/gate-ledger.js";
|
|
42
47
|
import type { MergedReview } from "./op/gate-review.js";
|
|
43
48
|
import type { GateApprovalSource } from "./op/op-waves.js";
|
|
44
49
|
export { GATE_APPROVAL_SOURCES, type GateApprovalSource } from "./op/op-waves.js";
|
|
45
50
|
export { isPendingGateExpired, latestPendingGate, latestResolutionForPlan, latestResolutionSince, type PlanBoundResolution, } from "./lifecycle/gate-ledger-select.js";
|
|
46
|
-
export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealRefusal, gateSealVersion, sealedFieldsOf, sshKeyFingerprint, verifySshSignatureWith, type GateSigners, type SealedGateApproval, type SshSignatureCheck, } from "./
|
|
51
|
+
export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealRefusal, gateSealVersion, sealedFieldsOf, sshKeyFingerprint, verifySshSignatureWith, type GateSigners, type SealedGateApproval, type SshSignatureCheck, } from "./lifecycle/gate-seal.js";
|
|
47
52
|
export { DEFAULT_SIGNERS_PATH, TRUST_CONFIG_PATH, parseAllowedSigners, trustConfigProblems, type Signer, type SignerSet, } from "./workspace/trust/trust-files.js";
|
|
48
53
|
export type { GateResolutionRecord, PendingGateRecord } from "./lifecycle/gate-ledger.js";
|
|
49
54
|
export { CORE_CLASSES, admitApprover, grantedClasses, type ClassGrant, type GateAdmissionRule, type PrincipalClass, } from "./workspace/identity-gate-rule.js";
|
|
50
55
|
export { appliedGateApplies, appliedGatePath, isApprovalSpent, parseAppliedGateLines, type AppliedGateRecord, } from "./lifecycle/gate-applied.js";
|
|
51
56
|
export type { MergedReview } from "./op/gate-review.js";
|
|
57
|
+
export { quorumNeed, quorumProblems, quorumRuleLine, quorumRuleProgress, quorumRules, quorumRulesFor, quorumWaiting, rolesOf, ruleNeedsProof, samePrincipal, targetGlobMatch, trustQuorumJudge, UNPROVEN_JUDGE, type GateQuorumJudge, type GateQuorumRule, type GateQuorumRuleProgress, type GateQuorumSpec, type QuorumApprover, type QuorumJudgement, type TrustQuorumInput, } from "./op/gate-quorum.js";
|
|
52
58
|
/**
|
|
53
59
|
* The commit a gate's rule is read at when the default branch applies its
|
|
54
60
|
* own commit: the first parent of HEAD, the branch as it stood before the
|
|
@@ -65,6 +71,13 @@ export declare function baseCommit(repo: string): string;
|
|
|
65
71
|
* commit the repository holds, such as {@link baseCommit}'s answer.
|
|
66
72
|
*/
|
|
67
73
|
export declare function gateSignersAt(repo: string, base: string): GateSigners;
|
|
74
|
+
/**
|
|
75
|
+
* The role grants of `.chant/trust.json` at `base` (#4290): role name to the
|
|
76
|
+
* principals that hold it, as chant reads them. A missing file gives none,
|
|
77
|
+
* and so does one that is not valid, which turns chant's trust off.
|
|
78
|
+
* {@link trustQuorumJudge} takes them with {@link gateSignersAt}'s signers.
|
|
79
|
+
*/
|
|
80
|
+
export declare function trustRolesAt(repo: string, base: string): Record<string, string[]>;
|
|
68
81
|
/** A gate the declaration at base names under `identity.gates`, and the principal class its signer must be in, if any. */
|
|
69
82
|
export interface IdentityGate {
|
|
70
83
|
gate: string;
|