@intentius/chant 0.124.108 → 0.124.110
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/__golden__/wave-loop/fan-out-applied.json +12 -6
- package/dist/__golden__/wave-loop/fan-out-apply-fails.json +8 -4
- package/dist/__golden__/wave-loop/fan-out-gated.json +4 -2
- package/dist/__golden__/wave-loop/fan-out-no-members.json +16 -8
- package/dist/__golden__/wave-loop/fan-out-plan-fails.json +8 -4
- package/dist/__golden__/wave-loop/fan-out-same-root.json +4 -2
- package/dist/agent-facts.d.ts +130 -0
- package/dist/agent-facts.js +196 -0
- package/dist/change-risk.d.ts +216 -0
- package/dist/change-risk.js +304 -0
- package/dist/change-set.d.ts +8 -0
- package/dist/ci-agent-alert.d.ts +139 -0
- package/dist/ci-agent-alert.js +342 -0
- package/dist/ci-agent-triggers.d.ts +152 -0
- package/dist/ci-agent-triggers.js +232 -0
- package/dist/ci-agent-verify-failed.d.ts +149 -0
- package/dist/ci-agent-verify-failed.js +191 -0
- package/dist/ci-agent.d.ts +136 -8
- package/dist/ci-agent.js +353 -26
- package/dist/ci-comment-commands.d.ts +8 -0
- package/dist/ci-comment-commands.js +17 -1
- package/dist/ci-comment-reject.d.ts +70 -0
- package/dist/ci-comment-reject.js +135 -0
- package/dist/ci-comment-replies.d.ts +3 -1
- package/dist/ci-comment-replies.js +6 -0
- package/dist/ci-estate/delivery.d.ts +25 -3
- package/dist/ci-estate/delivery.js +28 -9
- package/dist/ci-estate/page.d.ts +7 -3
- package/dist/ci-estate/page.js +19 -4
- package/dist/ci-estate/rows.d.ts +14 -2
- package/dist/ci-estate/rows.js +9 -1
- package/dist/ci-estate.d.ts +5 -2
- package/dist/ci-estate.js +3 -2
- package/dist/ci-handover.d.ts +2 -7
- package/dist/ci-handover.js +3 -20
- package/dist/ci-jobs.d.ts +6 -0
- package/dist/ci-jobs.js +17 -0
- package/dist/ci-note-commands.d.ts +2 -0
- package/dist/ci-note-commands.js +12 -1
- package/dist/ci-product-words.d.ts +151 -1
- package/dist/ci-product-words.js +1390 -3
- package/dist/ci-product.d.ts +100 -4
- package/dist/ci-product.js +99 -3
- package/dist/ci-respond-run.d.ts +9 -0
- package/dist/ci-respond-run.js +35 -4
- package/dist/ci-respond-summary-env.d.ts +56 -0
- package/dist/ci-respond-summary-env.js +81 -0
- package/dist/ci-respond-summary.d.ts +103 -0
- package/dist/ci-respond-summary.js +243 -0
- package/dist/ci-respond.d.ts +4 -2
- package/dist/ci-respond.js +4 -2
- package/dist/cli/command-group.js +1 -1
- package/dist/cli/commands/lint.js +21 -3
- package/dist/cli/handlers/agent.js +49 -4
- package/dist/cli/handlers/approve.js +3 -1
- package/dist/cli/handlers/build.d.ts +97 -1
- package/dist/cli/handlers/build.js +251 -3
- package/dist/cli/handlers/fan-out.js +55 -0
- package/dist/cli/handlers/graph.d.ts +14 -0
- package/dist/cli/handlers/graph.js +58 -3
- package/dist/cli/handlers/lifecycle-health.d.ts +7 -0
- package/dist/cli/handlers/lifecycle-health.js +47 -9
- package/dist/cli/handlers/lifecycle.js +4 -1
- package/dist/cli/handlers/notify-relay.d.ts +2 -2
- package/dist/cli/handlers/notify-relay.js +67 -7
- package/dist/cli/handlers/pipeline-agent.d.ts +30 -0
- package/dist/cli/handlers/pipeline-agent.js +255 -0
- package/dist/cli/handlers/pipeline-artifacts.d.ts +39 -0
- package/dist/cli/handlers/pipeline-artifacts.js +203 -0
- package/dist/cli/handlers/pipeline.d.ts +16 -0
- package/dist/cli/handlers/pipeline.js +112 -0
- package/dist/cli/handlers/pr-comment.js +4 -0
- package/dist/cli/handlers/pr-notes.js +4 -1
- package/dist/cli/handlers/pr.d.ts +20 -0
- package/dist/cli/handlers/pr.js +114 -11
- package/dist/cli/handlers/promote.js +792 -47
- package/dist/cli/handlers/reject.d.ts +84 -0
- package/dist/cli/handlers/reject.js +216 -0
- package/dist/cli/handlers/release.js +4 -2
- package/dist/cli/handlers/replan.d.ts +54 -0
- package/dist/cli/handlers/replan.js +177 -0
- package/dist/cli/handlers/run-generate.d.ts +5 -0
- package/dist/cli/handlers/run-generate.js +31 -4
- package/dist/cli/handlers/run-wave.js +15 -2
- package/dist/cli/handlers/run.js +4 -2
- package/dist/cli/handlers/stage.d.ts +35 -0
- package/dist/cli/handlers/stage.js +90 -0
- package/dist/cli/lsp/server.js +4 -0
- package/dist/cli/main.js +88 -8
- package/dist/cli/parse-args.js +35 -2
- package/dist/cli/registry.d.ts +12 -0
- package/dist/components/auto-release.d.ts +2 -0
- package/dist/components/auto-release.js +1 -0
- package/dist/components/capability.d.ts +40 -0
- package/dist/components/cli-support.d.ts +21 -1
- package/dist/components/cli-support.js +28 -6
- package/dist/components/component.d.ts +23 -4
- package/dist/components/component.schema.json +28 -0
- package/dist/components/declared-reads.d.ts +44 -4
- package/dist/components/declared-reads.js +80 -3
- package/dist/components/discover.d.ts +8 -0
- package/dist/components/discover.js +1 -1
- package/dist/components/driver.d.ts +13 -0
- package/dist/components/driver.js +23 -2
- package/dist/components/environment-sets.d.ts +229 -0
- package/dist/components/environment-sets.js +338 -0
- package/dist/components/fan-out-canary.d.ts +47 -0
- package/dist/components/fan-out-canary.js +58 -0
- package/dist/components/fan-out-run.d.ts +17 -0
- package/dist/components/fan-out-run.js +14 -1
- package/dist/components/fan-out-support.d.ts +7 -0
- package/dist/components/fan-out-support.js +1 -1
- package/dist/components/groups.d.ts +8 -1
- package/dist/components/groups.js +19 -1
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.js +4 -1
- package/dist/components/pr-cost.d.ts +28 -0
- package/dist/components/pr-cost.js +53 -0
- package/dist/components/pr-pipeline.d.ts +33 -0
- package/dist/components/pr-pipeline.js +32 -5
- package/dist/components/pr-policy.d.ts +33 -2
- package/dist/components/pr-policy.js +5 -2
- package/dist/components/pr-risk.d.ts +42 -0
- package/dist/components/pr-risk.js +74 -0
- package/dist/components/product-pipeline.d.ts +43 -0
- package/dist/components/product-pipeline.js +67 -1
- package/dist/components/promote.d.ts +6 -0
- package/dist/components/promote.js +13 -0
- package/dist/components/release-compile.js +3 -1
- package/dist/components/release-gate.d.ts +6 -1
- package/dist/components/release-gate.js +10 -2
- package/dist/components/step-environments.d.ts +236 -0
- package/dist/components/step-environments.js +392 -0
- package/dist/components/upstream-replan.d.ts +201 -0
- package/dist/components/upstream-replan.js +249 -0
- package/dist/components/verify-step.d.ts +30 -0
- package/dist/components/verify-step.js +27 -0
- package/dist/components/wave-plan.js +6 -2
- package/dist/config-environments.d.ts +4 -2
- package/dist/control/dispatch.d.ts +15 -0
- package/dist/control/dispatch.js +28 -4
- package/dist/cost-estimate.d.ts +188 -0
- package/dist/cost-estimate.js +363 -0
- package/dist/drift-record.d.ts +36 -0
- package/dist/drift-record.js +44 -0
- package/dist/engine-facts.d.ts +105 -0
- package/dist/engine-facts.js +111 -0
- package/dist/exit-codes.d.ts +4 -3
- package/dist/exit-codes.js +4 -3
- package/dist/flag-params.d.ts +2 -2
- package/dist/flag-params.js +9 -4
- package/dist/floor-table.data.js +53 -0
- package/dist/forge-token-vars.d.ts +12 -0
- package/dist/forge-token-vars.js +25 -0
- package/dist/gate-decision.d.ts +3 -1
- package/dist/gate-decision.js +3 -1
- package/dist/gated-waves.d.ts +2 -0
- package/dist/gated-waves.js +1 -0
- package/dist/graph-ir.d.ts +30 -0
- package/dist/graph-ir.js +33 -1
- package/dist/graph-refs.d.ts +26 -0
- package/dist/graph-refs.js +34 -3
- package/dist/graph-schema/graph.schema.json +136 -0
- package/dist/health.d.ts +65 -0
- package/dist/health.js +62 -0
- package/dist/lexicon.d.ts +188 -1
- package/dist/lifecycle/disruption.d.ts +14 -1
- package/dist/lifecycle/disruption.js +5 -1
- package/dist/lifecycle/gate-change-set.d.ts +8 -0
- package/dist/lifecycle/gate-change-set.js +2 -1
- package/dist/lifecycle/gate-ledger.d.ts +26 -0
- package/dist/lifecycle/gate-rejection.d.ts +82 -0
- package/dist/lifecycle/gate-rejection.js +93 -0
- package/dist/lifecycle/gate-seal.d.ts +3 -3
- package/dist/lifecycle/gate-seal.js +5 -5
- package/dist/lifecycle/observe.d.ts +17 -0
- package/dist/lifecycle/observe.js +10 -1
- package/dist/lifecycle/release-cut.js +4 -0
- package/dist/lifecycle/release-ledger.d.ts +8 -0
- package/dist/lifecycle/release-risk.d.ts +137 -0
- package/dist/lifecycle/release-risk.js +214 -0
- package/dist/lifecycle/release-store.d.ts +9 -0
- package/dist/lifecycle/release-store.js +4 -0
- package/dist/lifecycle/stage-log.d.ts +85 -0
- package/dist/lifecycle/stage-log.js +141 -0
- package/dist/lint/canary-checks.d.ts +31 -0
- package/dist/lint/canary-checks.js +45 -0
- package/dist/lint/rule.d.ts +1 -0
- package/dist/lint/rules/evl012-pipeline-fold.d.ts +14 -0
- package/dist/lint/rules/evl012-pipeline-fold.js +30 -0
- package/dist/lint/rules/index.d.ts +1 -0
- package/dist/lint/rules/index.js +3 -0
- package/dist/notify-relay-repo.d.ts +54 -0
- package/dist/notify-relay-repo.js +84 -0
- package/dist/notify-relay.d.ts +53 -3
- package/dist/notify-relay.js +96 -3
- package/dist/notify.d.ts +57 -1
- package/dist/notify.js +7 -1
- package/dist/notify.schema.json +61 -3
- package/dist/observation.d.ts +34 -0
- package/dist/observation.js +14 -1
- package/dist/op/activities/review-agent.d.ts +39 -2
- package/dist/op/activities/review-agent.js +88 -5
- package/dist/op/agent-permit.d.ts +88 -0
- package/dist/op/agent-permit.js +97 -0
- package/dist/op/gate-approval-base.d.ts +8 -0
- package/dist/op/gate-approval-base.js +9 -0
- package/dist/op/gate-approval.d.ts +30 -1
- package/dist/op/gate-approval.js +23 -2
- package/dist/op/gate-quorum.d.ts +114 -8
- package/dist/op/gate-quorum.js +198 -21
- package/dist/op/gate-reject.d.ts +79 -0
- package/dist/op/gate-reject.js +96 -0
- package/dist/op/gate-summary.js +1 -1
- package/dist/op/gate.d.ts +28 -3
- package/dist/op/gate.js +55 -13
- package/dist/op/generate-pipeline.d.ts +15 -1
- package/dist/op/generate-pipeline.js +32 -5
- package/dist/op/index.d.ts +11 -6
- package/dist/op/index.js +10 -5
- package/dist/op/local-executor.d.ts +2 -0
- package/dist/op/local-executor.js +23 -4
- package/dist/op/op-waves-after-plan.d.ts +23 -0
- package/dist/op/op-waves-after-plan.js +12 -1
- package/dist/op/op-waves-capability-spec.d.ts +14 -0
- package/dist/op/op-waves-capability-spec.js +46 -6
- package/dist/op/op-waves-capability.d.ts +21 -13
- package/dist/op/op-waves-capability.js +22 -59
- package/dist/op/op-waves-environment-sets.d.ts +41 -0
- package/dist/op/op-waves-environment-sets.js +82 -0
- package/dist/op/op-waves-quorum-warnings.d.ts +53 -0
- package/dist/op/op-waves-quorum-warnings.js +90 -0
- package/dist/op/op-waves-release-port.d.ts +7 -0
- package/dist/op/op-waves-release-port.js +15 -3
- package/dist/op/op-waves-release.d.ts +15 -0
- package/dist/op/op-waves-release.js +15 -0
- package/dist/op/op-waves-run.d.ts +37 -3
- package/dist/op/op-waves-run.js +141 -18
- package/dist/op/op-waves-soak.d.ts +57 -0
- package/dist/op/op-waves-soak.js +111 -0
- package/dist/op/op-waves-split.d.ts +4 -0
- package/dist/op/op-waves-split.js +4 -0
- package/dist/op/op-waves.d.ts +67 -4
- package/dist/op/op-waves.js +71 -3
- package/dist/pipeline/agent-ajv.d.ts +4 -0
- package/dist/pipeline/agent-ajv.js +14 -0
- package/dist/pipeline/agent-steps.d.ts +329 -0
- package/dist/pipeline/agent-steps.js +602 -0
- package/dist/pipeline/artifacts.d.ts +264 -0
- package/dist/pipeline/artifacts.js +425 -0
- package/dist/pipeline/diff.d.ts +45 -0
- package/dist/pipeline/diff.js +177 -0
- package/dist/pipeline/fold.d.ts +43 -0
- package/dist/pipeline/fold.js +140 -0
- package/dist/pipeline/generate.d.ts +52 -0
- package/dist/pipeline/generate.js +120 -0
- package/dist/pipeline/product.d.ts +225 -0
- package/dist/pipeline/product.js +257 -0
- package/dist/pipeline/promote.d.ts +404 -0
- package/dist/pipeline/promote.js +694 -0
- package/dist/pipeline/read.d.ts +37 -0
- package/dist/pipeline/read.js +58 -0
- package/dist/pipeline/rendered.d.ts +25 -0
- package/dist/pipeline/rendered.js +53 -0
- package/dist/pipeline/soak-checks.d.ts +80 -0
- package/dist/pipeline/soak-checks.js +254 -0
- package/dist/pipeline/soak-gate.d.ts +97 -0
- package/dist/pipeline/soak-gate.js +176 -0
- package/dist/pipeline/soak-sources.d.ts +17 -0
- package/dist/pipeline/soak-sources.js +42 -0
- package/dist/pipeline/soak.d.ts +260 -0
- package/dist/pipeline/soak.js +378 -0
- package/dist/pipeline/spec.d.ts +724 -0
- package/dist/pipeline/spec.js +567 -0
- package/dist/pipeline/stage-ledger.d.ts +187 -0
- package/dist/pipeline/stage-ledger.js +185 -0
- package/dist/pipeline/stage-waves.d.ts +114 -0
- package/dist/pipeline/stage-waves.js +161 -0
- package/dist/pipeline/stages.d.ts +64 -0
- package/dist/pipeline/stages.js +174 -0
- package/dist/pipeline/verify-rollback.d.ts +277 -0
- package/dist/pipeline/verify-rollback.js +393 -0
- package/dist/pipeline.d.ts +142 -0
- package/dist/pipeline.js +143 -0
- package/dist/pr-loop.d.ts +22 -0
- package/dist/pr-loop.js +8 -0
- package/dist/pr-plan-note.d.ts +15 -1
- package/dist/pr-plan-note.js +8 -0
- package/dist/pr-post.d.ts +31 -0
- package/dist/pr-post.js +89 -0
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/report-store/audit.schema.json +50 -0
- package/dist/report-store/dora.schema.json +331 -0
- package/dist/report-store/estate.schema.json +96 -0
- package/dist/report-store/run.schema.json +14 -0
- package/dist/report-store.d.ts +151 -0
- package/dist/report-store.js +344 -0
- package/dist/run-event.d.ts +7 -2
- package/dist/wave-runtime.mjs +458 -404
- package/dist/workspace/catalog-edges.js +3 -3
- package/dist/workspace/change-set.schema.json +4 -0
- package/dist/workspace/ci-cloud-identity.d.ts +4 -0
- package/dist/workspace/ci-cloud-identity.js +30 -0
- package/dist/workspace/ci-run.js +17 -2
- package/dist/workspace/ci-secrets.d.ts +3 -1
- package/dist/workspace/ci-secrets.js +7 -1
- package/dist/workspace/compose-graph.d.ts +1 -1
- package/dist/workspace/compose-graph.js +3 -1
- package/dist/workspace/declaration.d.ts +27 -0
- package/dist/workspace/declaration.js +35 -0
- package/dist/workspace/declaration.schema.json +56 -0
- package/dist/workspace/graph-cli.js +26 -0
- package/dist/workspace/graph.schema.json +5 -1
- package/dist/workspace/identity-gate-rule.d.ts +4 -0
- package/dist/workspace/identity-gate-rule.js +2 -2
- package/dist/workspace/identity-reject-rule.d.ts +14 -0
- package/dist/workspace/identity-reject-rule.js +24 -0
- package/dist/workspace/identity.d.ts +3 -0
- package/dist/workspace/identity.js +2 -1
- package/dist/workspace/nested-graph.js +2 -0
- package/dist/workspace/pr-report.schema.json +65 -0
- package/dist/workspace/promotion-order.d.ts +19 -4
- package/dist/workspace/promotion-order.js +26 -4
- package/dist/workspace/release-train.d.ts +14 -0
- package/dist/workspace/release-train.js +32 -0
- package/dist/workspace/run-event.schema.json +2 -2
- package/dist/workspace/stack-read-edges.d.ts +19 -0
- package/dist/workspace/stack-read-edges.js +54 -0
- package/dist/workspace/status-gates.d.ts +51 -1
- package/dist/workspace/status-gates.js +60 -0
- package/dist/workspace/status-stages.d.ts +223 -0
- package/dist/workspace/status-stages.js +279 -0
- package/dist/workspace/status.d.ts +45 -1
- package/dist/workspace/status.js +109 -5
- package/dist/workspace/status.schema.json +283 -2
- package/dist/workspace/train-cut.js +5 -2
- package/dist/workspace/train-shell.d.ts +18 -0
- package/dist/workspace/train-shell.js +43 -0
- package/dist/workspace/trust/seal.d.ts +7 -0
- package/dist/workspace/trust/seal.js +9 -0
- package/package.json +5 -1
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The delivery pipeline's declaration and the spec it folds to (#5324).
|
|
3
|
+
*
|
|
4
|
+
* A pipeline is the whole path from merge to the last environment: its
|
|
5
|
+
* stages in promotion order, the waves inside each stage, a gate per stage,
|
|
6
|
+
* the stage's hooks, and its holds. "Stage" means an environment in
|
|
7
|
+
* promotion order, not a CI step.
|
|
8
|
+
*
|
|
9
|
+
* The declaration is written in `.chant/pipeline.ts` inside the
|
|
10
|
+
* TypeScript-as-data subset (`./fold.ts`), and `chant build` folds it to
|
|
11
|
+
* this spec without running it. The spec is plain data, so a reviewer, the
|
|
12
|
+
* gates and the plan note read it before anything runs. Each stage becomes
|
|
13
|
+
* an op-waves spec (`./stages.ts`) that `chant run wave` runs, and the stage
|
|
14
|
+
* order is the promotion order `chant components promote` follows.
|
|
15
|
+
*
|
|
16
|
+
* The shape stays open: a key a later pass adds to a stage, its gate or the
|
|
17
|
+
* pipeline is one line in {@link STAGE_KEYS}, {@link GATE_KEYS} or
|
|
18
|
+
* {@link PIPELINE_KEYS} and its own check. An unknown key is refused, so a
|
|
19
|
+
* folded spec never carries a setting no chant reads.
|
|
20
|
+
*/
|
|
21
|
+
import { opWavesControlProblems } from "../op/op-waves.js";
|
|
22
|
+
import { opWaveHoldsProblems } from "../op/op-waves-capability-spec.js";
|
|
23
|
+
import { quorumProblems, QUORUM_MAX_DEPTH } from "../op/gate-quorum.js";
|
|
24
|
+
import { stageArtifactsSpecProblems, stagePublishProblems, stageReadsProblems } from "./artifacts.js";
|
|
25
|
+
import { soakCheckCount, soakProblems } from "./soak.js";
|
|
26
|
+
import { stageAgentStepsProblems, stageAgentStepsSpecProblems } from "./agent-steps.js";
|
|
27
|
+
/** The `kind` a folded pipeline carries. A reader refuses any other. */
|
|
28
|
+
export const PIPELINE_SPEC_KIND = "chant.pipeline/v1";
|
|
29
|
+
/** Where a member keeps its pipeline declaration, from the member's directory (beside `chant.config.ts`). */
|
|
30
|
+
export const PIPELINE_FILE = ".chant/pipeline.ts";
|
|
31
|
+
/** Where `chant build` writes the folded spec, from the member's directory. */
|
|
32
|
+
export const PIPELINE_SPEC_FILE = ".chant/pipeline.json";
|
|
33
|
+
/** The values a stage's `onVerifyFail` takes (#5328). */
|
|
34
|
+
export const PIPELINE_ON_VERIFY_FAIL = ["hold", "rollback"];
|
|
35
|
+
/** The values a stage's `queue` takes (#5353). */
|
|
36
|
+
export const PIPELINE_STAGE_QUEUES = ["replace"];
|
|
37
|
+
const NAME = /^[a-z0-9][a-z0-9_-]*$/;
|
|
38
|
+
const TOLERANCE = /^(100|[1-9]?[0-9])%$/;
|
|
39
|
+
const CRON = /^\S+(\s+\S+){4}$/;
|
|
40
|
+
/** The keys a pipeline takes. A later pass adds its key here with its check. */
|
|
41
|
+
export const PIPELINE_KEYS = ["kind", "name", "stages", "defaults", "release", "control", "recheck"];
|
|
42
|
+
/** The keys a stage takes. */
|
|
43
|
+
export const STAGE_KEYS = ["name", "canary", "waves", "gate", "hooks", "hold", "freeze", "failureTolerance", "forgeEnvironment", "replanDependents", "publish", "reads", "after", "queue", "pauseAfterRollback", "soak", "agentSteps", "onVerifyFail"];
|
|
44
|
+
/** The keys a stage's gate takes. */
|
|
45
|
+
export const GATE_KEYS = ["policy", "approval", "quorum", "point", "holds", "urgent"];
|
|
46
|
+
const RELEASE_KEYS = ["cut", "label", "bin"];
|
|
47
|
+
const DEFAULTS_REFUSED = ["name", "waves", "control"];
|
|
48
|
+
const isMap = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
|
|
49
|
+
/** Whether `value` is an ISO 8601 time `Date` reads. */
|
|
50
|
+
function isTime(value) {
|
|
51
|
+
return typeof value === "string" && /^\d{4}-\d{2}-\d{2}T/.test(value) && !Number.isNaN(Date.parse(value));
|
|
52
|
+
}
|
|
53
|
+
/** What is wrong with a failure tolerance, or undefined. */
|
|
54
|
+
export function failureToleranceProblem(value, where) {
|
|
55
|
+
if (value === undefined)
|
|
56
|
+
return undefined;
|
|
57
|
+
if (typeof value === "number" && Number.isInteger(value) && value >= 0)
|
|
58
|
+
return undefined;
|
|
59
|
+
if (typeof value === "string" && TOLERANCE.test(value))
|
|
60
|
+
return undefined;
|
|
61
|
+
return `${where} must be a whole number of runs, or a share of the wave's runs such as "10%"`;
|
|
62
|
+
}
|
|
63
|
+
/** What is wrong with a `replanDependents` list, or undefined (#5345). */
|
|
64
|
+
export function replanDependentsProblem(value, where) {
|
|
65
|
+
if (value === undefined)
|
|
66
|
+
return undefined;
|
|
67
|
+
if (Array.isArray(value) && value.every((v) => typeof v === "string" && v.trim() !== ""))
|
|
68
|
+
return undefined;
|
|
69
|
+
return `${where} must be a list of member names or patterns`;
|
|
70
|
+
}
|
|
71
|
+
/** The members a stage plans the dependents of when their outputs change (#5345): the stage's list, else the pipeline's default, else none. */
|
|
72
|
+
export function stageReplanDependents(spec, stage) {
|
|
73
|
+
const own = spec.stages.find((s) => s.name === stage)?.replanDependents;
|
|
74
|
+
return [...(own ?? spec.defaults?.replanDependents ?? [])];
|
|
75
|
+
}
|
|
76
|
+
function unknownKeys(value, keys, where) {
|
|
77
|
+
return Object.keys(value).filter((k) => !keys.includes(k)).map((k) => `${where} has an unknown key "${k}"; it takes ${keys.join(", ")}`);
|
|
78
|
+
}
|
|
79
|
+
function holdProblems(hold, where) {
|
|
80
|
+
if (hold === undefined || hold === true)
|
|
81
|
+
return [];
|
|
82
|
+
if (!isMap(hold))
|
|
83
|
+
return [`${where}.hold must be true or { "reason"?, "until"?, "description"? }`];
|
|
84
|
+
const out = unknownKeys(hold, ["reason", "until", "description"], `${where}.hold`);
|
|
85
|
+
if (hold.reason !== undefined && typeof hold.reason !== "string")
|
|
86
|
+
out.push(`${where}.hold.reason must be text`);
|
|
87
|
+
if (hold.description !== undefined && (typeof hold.description !== "string" || hold.description.trim() === ""))
|
|
88
|
+
out.push(`${where}.hold.description must be text`);
|
|
89
|
+
if (hold.until !== undefined && !isTime(hold.until))
|
|
90
|
+
out.push(`${where}.hold.until must be an ISO 8601 time, such as "2026-12-01T00:00:00Z"`);
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
function freezeProblems(freeze, where) {
|
|
94
|
+
if (freeze === undefined)
|
|
95
|
+
return [];
|
|
96
|
+
if (!Array.isArray(freeze))
|
|
97
|
+
return [`${where}.freeze must be a list of { "from", "until", "reason"? }`];
|
|
98
|
+
const out = [];
|
|
99
|
+
freeze.forEach((w, i) => {
|
|
100
|
+
const at = `${where}.freeze[${i}]`;
|
|
101
|
+
if (!isMap(w)) {
|
|
102
|
+
out.push(`${at} must be { "from", "until", "reason"? }`);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
out.push(...unknownKeys(w, ["from", "until", "reason"], at));
|
|
106
|
+
if (!isTime(w.from))
|
|
107
|
+
out.push(`${at}.from must be an ISO 8601 time`);
|
|
108
|
+
if (!isTime(w.until))
|
|
109
|
+
out.push(`${at}.until must be an ISO 8601 time`);
|
|
110
|
+
if (isTime(w.from) && isTime(w.until) && Date.parse(w.until) <= Date.parse(w.from))
|
|
111
|
+
out.push(`${at} ends before it starts`);
|
|
112
|
+
if (w.reason !== undefined && typeof w.reason !== "string")
|
|
113
|
+
out.push(`${at}.reason must be text`);
|
|
114
|
+
});
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
function gateProblems(gate, where) {
|
|
118
|
+
if (gate === undefined)
|
|
119
|
+
return [];
|
|
120
|
+
if (!isMap(gate))
|
|
121
|
+
return [`${where}.gate must be { "policy"?, "approval"?, "quorum"?, "point"?, "holds"?, "urgent"? }`];
|
|
122
|
+
const out = unknownKeys(gate, GATE_KEYS, `${where}.gate`);
|
|
123
|
+
if (gate.policy !== undefined && !["always", "on-destructive", "never"].includes(gate.policy))
|
|
124
|
+
out.push(`${where}.gate.policy is always, on-destructive or never`);
|
|
125
|
+
if (gate.approval !== undefined && !["ledger", "pr-review", "sealed", "pull-request"].includes(gate.approval))
|
|
126
|
+
out.push(`${where}.gate.approval is ledger, pr-review, sealed or pull-request`);
|
|
127
|
+
if (gate.quorum !== undefined && !Array.isArray(gate.quorum))
|
|
128
|
+
out.push(`${where}.gate.quorum must be a list of rules`);
|
|
129
|
+
else if (gate.quorum !== undefined)
|
|
130
|
+
out.push(...quorumProblems(gate.quorum, `${where}.gate.quorum`, { notAuthor: true, proven: true, combine: true }).map((p) => p.replace(/`/g, "")));
|
|
131
|
+
if (gate.point !== undefined && typeof gate.point !== "string" && !isMap(gate.point))
|
|
132
|
+
out.push(`${where}.gate.point must name a decision point`);
|
|
133
|
+
if (gate.holds !== undefined && !isMap(gate.holds))
|
|
134
|
+
out.push(`${where}.gate.holds must be { "policy"?, "cost"?, "risk"? }`);
|
|
135
|
+
// #5387: a later stage's holds are read at promote, where no op-waves spec checks them, so they are checked here.
|
|
136
|
+
else if (gate.holds !== undefined)
|
|
137
|
+
out.push(...opWaveHoldsProblems(gate.holds).map((p) => `${where}.gate: ${p}`));
|
|
138
|
+
if (gate.urgent !== undefined) {
|
|
139
|
+
if (!isMap(gate.urgent))
|
|
140
|
+
out.push(`${where}.gate.urgent must be { "role" }`);
|
|
141
|
+
else {
|
|
142
|
+
out.push(...unknownKeys(gate.urgent, ["role"], `${where}.gate.urgent`));
|
|
143
|
+
if (typeof gate.urgent.role !== "string" || gate.urgent.role.trim() === "")
|
|
144
|
+
out.push(`${where}.gate.urgent.role must name a role in .chant/trust.json`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return out;
|
|
148
|
+
}
|
|
149
|
+
function stageProblems(stage, i, seen) {
|
|
150
|
+
const where = `stages[${i}]`;
|
|
151
|
+
if (!isMap(stage))
|
|
152
|
+
return [`${where} must be a stage: { "name", "waves", ... }`];
|
|
153
|
+
const name = typeof stage.name === "string" ? stage.name : undefined;
|
|
154
|
+
const at = name ? `stage "${name}"` : where;
|
|
155
|
+
const out = unknownKeys(stage, STAGE_KEYS, at);
|
|
156
|
+
if (name === undefined || !NAME.test(name))
|
|
157
|
+
out.push(`${where}.name must be an environment's name: lowercase letters, digits, "-" and "_"`);
|
|
158
|
+
else if (seen.has(name))
|
|
159
|
+
out.push(`${at} is named twice; each environment is one stage`);
|
|
160
|
+
else
|
|
161
|
+
seen.add(name);
|
|
162
|
+
if (stage.canary !== undefined && typeof stage.canary !== "boolean")
|
|
163
|
+
out.push(`${at}.canary must be true or false`);
|
|
164
|
+
if (stage.pauseAfterRollback !== undefined && typeof stage.pauseAfterRollback !== "boolean")
|
|
165
|
+
out.push(`${at}.pauseAfterRollback must be true or false`);
|
|
166
|
+
if (!Array.isArray(stage.waves) || stage.waves.length === 0)
|
|
167
|
+
out.push(`${at}.waves must list at least one wave`);
|
|
168
|
+
else {
|
|
169
|
+
const waveNames = new Set();
|
|
170
|
+
stage.waves.forEach((w, k) => {
|
|
171
|
+
if (!isMap(w) || typeof w.name !== "string" || !NAME.test(w.name))
|
|
172
|
+
out.push(`${at}.waves[${k}] must be a wave with a name of lowercase letters, digits, "-" and "_"`);
|
|
173
|
+
else if (waveNames.has(w.name))
|
|
174
|
+
out.push(`${at} has two waves named "${w.name}"`);
|
|
175
|
+
else
|
|
176
|
+
waveNames.add(w.name);
|
|
177
|
+
if (isMap(w)) {
|
|
178
|
+
const p = failureToleranceProblem(w.failureTolerance, `${at}.waves[${k}].failureTolerance`);
|
|
179
|
+
if (p)
|
|
180
|
+
out.push(p);
|
|
181
|
+
out.push(...soakProblems(w.soak, `${at}.waves[${k}]`));
|
|
182
|
+
if (w.soak !== undefined && w.rest === true)
|
|
183
|
+
out.push(`${at}.waves[${k}] has soak and rest; the waves a rest wave walks run in its one job, so none of them can wait for a soak`);
|
|
184
|
+
if (w.soak !== undefined && k === stage.waves.length - 1)
|
|
185
|
+
out.push(`${at}.waves[${k}] has soak and is the stage's last wave; a wave's soak holds the wave after it, so the last wave's goes on the stage (${at}.soak)`);
|
|
186
|
+
out.push(...canaryWaveProblems(w, k, stage.waves.length, stage.soak, at));
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
// #5327: a canary holds the stages after it through its soak, so a canary with no check holds nothing.
|
|
191
|
+
if (stage.canary === true && soakCheckCount(isMap(stage.soak) ? stage.soak : undefined) === 0) {
|
|
192
|
+
out.push(`${at} is the canary and its soak has no checks; the canary's soak holds every stage after it, so give the stage a soak with at least one check (${at}.soak.checks)`);
|
|
193
|
+
}
|
|
194
|
+
out.push(...gateProblems(stage.gate, at));
|
|
195
|
+
if (stage.hooks !== undefined && !isMap(stage.hooks))
|
|
196
|
+
out.push(`${at}.hooks must be { "before"?, "after"?, "apply"? }`);
|
|
197
|
+
out.push(...holdProblems(stage.hold, at), ...freezeProblems(stage.freeze, at));
|
|
198
|
+
if (stage.forgeEnvironment !== undefined && (!isMap(stage.forgeEnvironment) || typeof stage.forgeEnvironment.name !== "string" || stage.forgeEnvironment.name === ""))
|
|
199
|
+
out.push(`${at}.forgeEnvironment must be { "name", "url"? }`);
|
|
200
|
+
const tolerance = failureToleranceProblem(stage.failureTolerance, `${at}.failureTolerance`);
|
|
201
|
+
if (tolerance)
|
|
202
|
+
out.push(tolerance);
|
|
203
|
+
const replan = replanDependentsProblem(stage.replanDependents, `${at}.replanDependents`);
|
|
204
|
+
if (replan)
|
|
205
|
+
out.push(replan);
|
|
206
|
+
out.push(...stagePublishProblems(stage.publish, at), ...stageReadsProblems(stage.reads, at), ...stageAgentStepsProblems(stage.agentSteps, at));
|
|
207
|
+
if (stage.after !== undefined) {
|
|
208
|
+
if (!Array.isArray(stage.after) || stage.after.length === 0 || !stage.after.every((n) => typeof n === "string" && NAME.test(n)))
|
|
209
|
+
out.push(`${at}.after must list the names of one or more stages`);
|
|
210
|
+
else {
|
|
211
|
+
if (i === 0)
|
|
212
|
+
out.push(`${at} is the first stage, the one a merge applies, so it takes no after`);
|
|
213
|
+
if (name !== undefined && stage.after.includes(name))
|
|
214
|
+
out.push(`${at}.after names the stage itself`);
|
|
215
|
+
const twice = stage.after.filter((n, k) => stage.after !== undefined && stage.after.indexOf(n) !== k);
|
|
216
|
+
if (twice.length > 0)
|
|
217
|
+
out.push(`${at}.after names ${[...new Set(twice)].join(", ")} twice`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (stage.queue !== undefined && !PIPELINE_STAGE_QUEUES.includes(stage.queue))
|
|
221
|
+
out.push(`${at}.queue is ${PIPELINE_STAGE_QUEUES.join(", ")}`);
|
|
222
|
+
out.push(...soakProblems(stage.soak, at));
|
|
223
|
+
if (stage.onVerifyFail !== undefined && !PIPELINE_ON_VERIFY_FAIL.includes(stage.onVerifyFail))
|
|
224
|
+
out.push(`${at}.onVerifyFail is ${PIPELINE_ON_VERIFY_FAIL.join(" or ")}`);
|
|
225
|
+
return out;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* A canary wave inside a stage (#5327): the stage's first wave, with a wave
|
|
229
|
+
* after it to hold, and soak checks of its own or, when it declares no
|
|
230
|
+
* soak, the stage's, which it then takes (`./stages.ts`).
|
|
231
|
+
*/
|
|
232
|
+
function canaryWaveProblems(w, k, count, stageSoak, at) {
|
|
233
|
+
if (w.canary === undefined)
|
|
234
|
+
return [];
|
|
235
|
+
if (typeof w.canary !== "boolean")
|
|
236
|
+
return [`${at}.waves[${k}].canary must be true or false`];
|
|
237
|
+
if (!w.canary)
|
|
238
|
+
return [];
|
|
239
|
+
const out = [];
|
|
240
|
+
if (k !== 0)
|
|
241
|
+
out.push(`${at}.waves[${k}] is a canary wave and not the stage's first wave; the canary applies before every other wave`);
|
|
242
|
+
if (count === 1)
|
|
243
|
+
out.push(`${at}.waves[${k}] is a canary wave and the stage's only wave, so no wave waits for it; mark the stage canary instead (${at}.canary)`);
|
|
244
|
+
if (w.rest === true)
|
|
245
|
+
out.push(`${at}.waves[${k}] is a canary wave and has rest; the waves a rest wave walks run in its one job, so none of them could wait for the canary's soak`);
|
|
246
|
+
const soak = w.soak !== undefined ? w.soak : stageSoak;
|
|
247
|
+
if (soakCheckCount(isMap(soak) ? soak : undefined) === 0) {
|
|
248
|
+
out.push(`${at}.waves[${k}] is a canary wave with no soak checks, of its own or the stage's; its soak holds the waves after it, so give it a soak with at least one check (${at}.waves[${k}].soak, or ${at}.soak)`);
|
|
249
|
+
}
|
|
250
|
+
return out;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* The canary stages a promote into `to` waits on (#5327), in pipeline
|
|
254
|
+
* order: each stage marked `canary` that `to` follows, directly or through
|
|
255
|
+
* the stages between ({@link stageUpstreams}). `to` itself is not one.
|
|
256
|
+
*/
|
|
257
|
+
export function canaryStagesBefore(spec, to) {
|
|
258
|
+
const seen = new Set();
|
|
259
|
+
const walk = (name) => {
|
|
260
|
+
for (const up of stageUpstreams(spec, name)) {
|
|
261
|
+
if (seen.has(up))
|
|
262
|
+
continue;
|
|
263
|
+
seen.add(up);
|
|
264
|
+
walk(up);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
walk(to);
|
|
268
|
+
return spec.stages.filter((s) => s.canary === true && s.name !== to && seen.has(s.name));
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* The stages each stage follows (#5353): its `after`, else the stage before
|
|
272
|
+
* it in the list, else none for the first.
|
|
273
|
+
*/
|
|
274
|
+
export function stageUpstreams(spec, name) {
|
|
275
|
+
const index = spec.stages.findIndex((s) => s.name === name);
|
|
276
|
+
if (index < 0)
|
|
277
|
+
return [];
|
|
278
|
+
const stage = spec.stages[index];
|
|
279
|
+
if (stage.after !== undefined)
|
|
280
|
+
return [...stage.after];
|
|
281
|
+
return index === 0 ? [] : [spec.stages[index - 1].name];
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* A cycle among the stages, as the stage names around it with the first
|
|
285
|
+
* repeated at the end, or undefined when there is none. Each stage follows
|
|
286
|
+
* {@link stageUpstreams}.
|
|
287
|
+
*/
|
|
288
|
+
export function stageCycle(spec) {
|
|
289
|
+
const state = new Map();
|
|
290
|
+
const path = [];
|
|
291
|
+
const visit = (name) => {
|
|
292
|
+
if (state.get(name) === "done")
|
|
293
|
+
return undefined;
|
|
294
|
+
if (state.get(name) === "open")
|
|
295
|
+
return [...path.slice(path.indexOf(name)), name];
|
|
296
|
+
state.set(name, "open");
|
|
297
|
+
path.push(name);
|
|
298
|
+
for (const up of stageUpstreams(spec, name)) {
|
|
299
|
+
if (!spec.stages.some((s) => s.name === up))
|
|
300
|
+
continue;
|
|
301
|
+
const found = visit(up);
|
|
302
|
+
if (found)
|
|
303
|
+
return found;
|
|
304
|
+
}
|
|
305
|
+
path.pop();
|
|
306
|
+
state.set(name, "done");
|
|
307
|
+
return undefined;
|
|
308
|
+
};
|
|
309
|
+
for (const s of spec.stages) {
|
|
310
|
+
const found = visit(s.name);
|
|
311
|
+
if (found)
|
|
312
|
+
return found.reverse();
|
|
313
|
+
}
|
|
314
|
+
return undefined;
|
|
315
|
+
}
|
|
316
|
+
/** Whether a promote records its stages in the stage log (#5353): some stage declares `after` or `queue`. */
|
|
317
|
+
export function pipelineTracksStages(spec) {
|
|
318
|
+
return spec.stages.some((s) => s.after !== undefined || s.queue !== undefined);
|
|
319
|
+
}
|
|
320
|
+
function graphProblems(stages) {
|
|
321
|
+
const named = stages.filter((s) => isMap(s) && typeof s.name === "string" && Array.isArray(s.waves));
|
|
322
|
+
const names = new Set(named.map((s) => s.name));
|
|
323
|
+
const out = [];
|
|
324
|
+
for (const s of named) {
|
|
325
|
+
if (!Array.isArray(s.after))
|
|
326
|
+
continue;
|
|
327
|
+
const unknown = s.after.filter((n) => typeof n === "string" && !names.has(n));
|
|
328
|
+
if (unknown.length > 0)
|
|
329
|
+
out.push(`stage "${s.name}".after names ${unknown.join(", ")}, which the pipeline has no stage for; its stages are ${[...names].join(", ")}`);
|
|
330
|
+
}
|
|
331
|
+
if (out.length > 0)
|
|
332
|
+
return out;
|
|
333
|
+
const cycle = stageCycle({ stages: named });
|
|
334
|
+
if (cycle)
|
|
335
|
+
out.push(`the stages ${cycle.join(" -> ")} form a cycle through after, so no release could open any of them; each stage follows its after, else the stage before it`);
|
|
336
|
+
return out;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* A later stage's `holds.risk` reads the score its release carries (#5387),
|
|
340
|
+
* and a release carries one only when the first stage's waves score it. A
|
|
341
|
+
* later stage that sets `holds.risk` while the first stage has none, of its
|
|
342
|
+
* own or from `defaults`, would never read a score, so it is refused.
|
|
343
|
+
*/
|
|
344
|
+
function laterRiskProblems(stages, defaults) {
|
|
345
|
+
const holdsOf = (s) => (isMap(s) && isMap(s.gate) ? s.gate.holds : undefined);
|
|
346
|
+
const riskIn = (holds) => isMap(holds) && holds.risk !== undefined;
|
|
347
|
+
const first = stages[0];
|
|
348
|
+
const own = holdsOf(first);
|
|
349
|
+
const firstScores = own !== undefined ? riskIn(own) : isMap(defaults) && riskIn(defaults.holds);
|
|
350
|
+
if (firstScores)
|
|
351
|
+
return [];
|
|
352
|
+
const firstName = isMap(first) && typeof first.name === "string" ? first.name : "the first stage";
|
|
353
|
+
return stages
|
|
354
|
+
.slice(1)
|
|
355
|
+
.filter((s) => riskIn(holdsOf(s) ?? (isMap(defaults) ? defaults.holds : undefined)))
|
|
356
|
+
.map((s) => `stage "${s.name}" reads holds.risk at its gate, and the first stage "${firstName}" sets no holds.risk, of its own or from defaults; the first stage must score with holds.risk for a release to carry a score that a later stage reads`);
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Everything wrong with a folded pipeline, one line each; empty when it
|
|
360
|
+
* reads. The stage-level checks are here; each stage's op-waves spec is
|
|
361
|
+
* checked again by `assertOpWavesSpec` when it is derived (`./stages.ts`).
|
|
362
|
+
*/
|
|
363
|
+
export function pipelineSpecProblems(value) {
|
|
364
|
+
if (!isMap(value))
|
|
365
|
+
return ["a pipeline is { \"name\", \"stages\": [...] }"];
|
|
366
|
+
const out = unknownKeys(value, PIPELINE_KEYS, "the pipeline");
|
|
367
|
+
if (value.kind !== undefined && value.kind !== PIPELINE_SPEC_KIND)
|
|
368
|
+
out.push(`the pipeline's kind is ${JSON.stringify(value.kind)}; this chant reads ${PIPELINE_SPEC_KIND}`);
|
|
369
|
+
if (typeof value.name !== "string" || !NAME.test(value.name))
|
|
370
|
+
out.push("the pipeline's name must be lowercase letters, digits, \"-\" and \"_\"");
|
|
371
|
+
if (!Array.isArray(value.stages) || value.stages.length === 0)
|
|
372
|
+
out.push("the pipeline must list at least one stage");
|
|
373
|
+
else {
|
|
374
|
+
const seen = new Set();
|
|
375
|
+
value.stages.forEach((s, i) => out.push(...stageProblems(s, i, seen)));
|
|
376
|
+
if (out.length === 0)
|
|
377
|
+
out.push(...graphProblems(value.stages));
|
|
378
|
+
if (out.length === 0)
|
|
379
|
+
out.push(...laterRiskProblems(value.stages, value.defaults));
|
|
380
|
+
out.push(...stageArtifactsSpecProblems(value), ...stageAgentStepsSpecProblems(value));
|
|
381
|
+
}
|
|
382
|
+
if (value.defaults !== undefined) {
|
|
383
|
+
if (!isMap(value.defaults))
|
|
384
|
+
out.push("the pipeline's defaults must be op-waves settings: { \"op\", \"step\", ... }");
|
|
385
|
+
else
|
|
386
|
+
for (const k of DEFAULTS_REFUSED)
|
|
387
|
+
if (k in value.defaults)
|
|
388
|
+
out.push(`defaults.${k} is set by the pipeline, not its defaults`);
|
|
389
|
+
}
|
|
390
|
+
if (value.release !== undefined) {
|
|
391
|
+
if (!isMap(value.release))
|
|
392
|
+
out.push("the pipeline's release must be { \"cut\"?, \"label\"?, \"bin\"? }");
|
|
393
|
+
else {
|
|
394
|
+
out.push(...unknownKeys(value.release, RELEASE_KEYS, "release"));
|
|
395
|
+
if (value.release.cut !== undefined && typeof value.release.cut !== "boolean")
|
|
396
|
+
out.push("release.cut must be true or false");
|
|
397
|
+
if (value.release.label !== undefined && (typeof value.release.label !== "string" || value.release.label.trim() === ""))
|
|
398
|
+
out.push("release.label must name the release, or be auto");
|
|
399
|
+
if (value.release.bin !== undefined && (!Array.isArray(value.release.bin) || value.release.bin.length === 0 || value.release.bin.some((w) => typeof w !== "string" || w === "")))
|
|
400
|
+
out.push("release.bin must be a list of words, such as [\"npx\", \"--no-install\", \"plywood\"]");
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (value.control !== undefined)
|
|
404
|
+
out.push(...opWavesControlProblems(value.control).map((p) => `the pipeline's ${p}`));
|
|
405
|
+
if (value.recheck !== undefined) {
|
|
406
|
+
if (!isMap(value.recheck))
|
|
407
|
+
out.push("the pipeline's recheck must be { \"schedule\" }");
|
|
408
|
+
else {
|
|
409
|
+
out.push(...unknownKeys(value.recheck, ["schedule"], "recheck"));
|
|
410
|
+
if (typeof value.recheck.schedule !== "string" || !CRON.test(value.recheck.schedule.trim()))
|
|
411
|
+
out.push("recheck.schedule must be a five-field cron line, such as \"*/30 * * * *\"");
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return out;
|
|
415
|
+
}
|
|
416
|
+
/** The spec, checked, with its kind. Throws naming every problem. */
|
|
417
|
+
export function asPipelineSpec(value, where = "the pipeline") {
|
|
418
|
+
const problems = pipelineSpecProblems(value);
|
|
419
|
+
if (problems.length > 0)
|
|
420
|
+
throw new Error(`${where}: ${problems.join("; ")}`);
|
|
421
|
+
return { ...value, kind: PIPELINE_SPEC_KIND };
|
|
422
|
+
}
|
|
423
|
+
/** Whether a parsed JSON document is a folded pipeline, by its kind. */
|
|
424
|
+
export function isPipelineSpecDocument(value) {
|
|
425
|
+
return isMap(value) && value.kind === PIPELINE_SPEC_KIND;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* The folded spec's JSON Schema, for an editor or a reader in another
|
|
429
|
+
* language. The stage's waves are op waves, checked in full when each
|
|
430
|
+
* stage's op-waves spec is derived.
|
|
431
|
+
*/
|
|
432
|
+
export const PIPELINE_SPEC_SCHEMA = {
|
|
433
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
434
|
+
$id: "https://intentius.io/chant/schemas/pipeline-v1.json",
|
|
435
|
+
title: "chant pipeline",
|
|
436
|
+
type: "object",
|
|
437
|
+
required: ["kind", "name", "stages"],
|
|
438
|
+
additionalProperties: false,
|
|
439
|
+
properties: {
|
|
440
|
+
kind: { const: PIPELINE_SPEC_KIND },
|
|
441
|
+
name: { type: "string", pattern: NAME.source },
|
|
442
|
+
defaults: { type: "object", not: { anyOf: DEFAULTS_REFUSED.map((k) => ({ required: [k] })) } },
|
|
443
|
+
release: {
|
|
444
|
+
type: "object",
|
|
445
|
+
additionalProperties: false,
|
|
446
|
+
properties: { cut: { type: "boolean" }, label: { type: "string", minLength: 1 }, bin: { type: "array", minItems: 1, items: { type: "string", minLength: 1 } } },
|
|
447
|
+
},
|
|
448
|
+
control: { type: "object" },
|
|
449
|
+
recheck: { type: "object", required: ["schedule"], additionalProperties: false, properties: { schedule: { type: "string", pattern: CRON.source } } },
|
|
450
|
+
stages: {
|
|
451
|
+
type: "array",
|
|
452
|
+
minItems: 1,
|
|
453
|
+
items: {
|
|
454
|
+
type: "object",
|
|
455
|
+
required: ["name", "waves"],
|
|
456
|
+
additionalProperties: false,
|
|
457
|
+
properties: {
|
|
458
|
+
name: { type: "string", pattern: NAME.source },
|
|
459
|
+
canary: { type: "boolean" },
|
|
460
|
+
waves: { type: "array", minItems: 1, items: { type: "object", required: ["name"], properties: { name: { type: "string", pattern: NAME.source }, failureTolerance: { $ref: "#/$defs/tolerance" }, soak: { $ref: "#/$defs/soak" }, canary: { type: "boolean" } } } },
|
|
461
|
+
gate: {
|
|
462
|
+
type: "object",
|
|
463
|
+
additionalProperties: false,
|
|
464
|
+
properties: {
|
|
465
|
+
policy: { enum: ["always", "on-destructive", "never"] },
|
|
466
|
+
approval: { enum: ["ledger", "pr-review", "sealed", "pull-request"] },
|
|
467
|
+
quorum: { type: "array", minItems: 1, items: { $ref: "#/$defs/quorumNode" } },
|
|
468
|
+
point: { type: ["string", "object"] },
|
|
469
|
+
holds: { type: "object" },
|
|
470
|
+
urgent: { type: "object", required: ["role"], additionalProperties: false, properties: { role: { type: "string", minLength: 1 } } },
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
hooks: { type: "object" },
|
|
474
|
+
hold: { oneOf: [{ const: true }, { type: "object", additionalProperties: false, properties: { reason: { type: "string" }, until: { type: "string", format: "date-time" }, description: { type: "string", minLength: 1 } } }] },
|
|
475
|
+
freeze: {
|
|
476
|
+
type: "array",
|
|
477
|
+
items: { type: "object", required: ["from", "until"], additionalProperties: false, properties: { from: { type: "string", format: "date-time" }, until: { type: "string", format: "date-time" }, reason: { type: "string" } } },
|
|
478
|
+
},
|
|
479
|
+
failureTolerance: { $ref: "#/$defs/tolerance" },
|
|
480
|
+
forgeEnvironment: { type: "object", required: ["name"], properties: { name: { type: "string", minLength: 1 }, url: { type: "string" } } },
|
|
481
|
+
replanDependents: { type: "array", items: { type: "string", minLength: 1 } },
|
|
482
|
+
publish: {
|
|
483
|
+
type: "object",
|
|
484
|
+
additionalProperties: {
|
|
485
|
+
oneOf: [
|
|
486
|
+
{ type: "object", required: ["member", "output"], additionalProperties: false, properties: { member: { type: "string", minLength: 1 }, output: { type: "string", minLength: 1 } } },
|
|
487
|
+
{ type: "object", required: ["secret"], additionalProperties: false, properties: { secret: { type: ["string", "object"] } } },
|
|
488
|
+
],
|
|
489
|
+
},
|
|
490
|
+
},
|
|
491
|
+
reads: {
|
|
492
|
+
type: "object",
|
|
493
|
+
additionalProperties: { type: "object", required: ["stage", "artifact"], additionalProperties: false, properties: { stage: { type: "string", pattern: NAME.source }, artifact: { type: "string", minLength: 1 } } },
|
|
494
|
+
},
|
|
495
|
+
after: { type: "array", minItems: 1, uniqueItems: true, items: { type: "string", pattern: NAME.source } },
|
|
496
|
+
queue: { enum: [...PIPELINE_STAGE_QUEUES] },
|
|
497
|
+
pauseAfterRollback: { type: "boolean" },
|
|
498
|
+
soak: { $ref: "#/$defs/soak" },
|
|
499
|
+
agentSteps: {
|
|
500
|
+
type: "object",
|
|
501
|
+
additionalProperties: {
|
|
502
|
+
type: "object",
|
|
503
|
+
required: ["prompt", "schema"],
|
|
504
|
+
additionalProperties: false,
|
|
505
|
+
properties: {
|
|
506
|
+
prompt: { type: "string", minLength: 1 },
|
|
507
|
+
schema: { type: "object" },
|
|
508
|
+
reads: {
|
|
509
|
+
type: "object",
|
|
510
|
+
additionalProperties: {
|
|
511
|
+
oneOf: [
|
|
512
|
+
{ type: "object", required: ["stage", "artifact"], additionalProperties: false, properties: { stage: { type: "string", pattern: NAME.source }, artifact: { type: "string", minLength: 1 } } },
|
|
513
|
+
{ type: "object", required: ["step"], additionalProperties: false, properties: { step: { type: "string", minLength: 1 } } },
|
|
514
|
+
],
|
|
515
|
+
},
|
|
516
|
+
},
|
|
517
|
+
command: { type: "string", minLength: 1 },
|
|
518
|
+
keyEnv: { type: "string", pattern: "^[A-Za-z_][A-Za-z0-9_]*$" },
|
|
519
|
+
timeout: { type: "integer", minimum: 1, maximum: 360 },
|
|
520
|
+
maxRuns: { type: "integer", minimum: 1 },
|
|
521
|
+
maxCostUsd: { type: "number", exclusiveMinimum: 0 },
|
|
522
|
+
},
|
|
523
|
+
},
|
|
524
|
+
},
|
|
525
|
+
onVerifyFail: { enum: [...PIPELINE_ON_VERIFY_FAIL] },
|
|
526
|
+
},
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
},
|
|
530
|
+
$defs: {
|
|
531
|
+
// #5354: a rule, or an all/any group of them; the depth (QUORUM_MAX_DEPTH) is checked when the spec is read.
|
|
532
|
+
quorumNode: {
|
|
533
|
+
type: "object",
|
|
534
|
+
properties: { name: { type: "string", pattern: "^[a-z0-9][a-z0-9_-]*$" }, all: { type: "array", minItems: 1, items: { $ref: "#/$defs/quorumNode" } }, any: { type: "array", minItems: 1, items: { $ref: "#/$defs/quorumNode" } } },
|
|
535
|
+
description: `a rule { name?, targets?, count, roles?, notAuthor?, proven? }, or a group { name?, all | any }, nested up to ${QUORUM_MAX_DEPTH} groups deep`,
|
|
536
|
+
},
|
|
537
|
+
tolerance: { oneOf: [{ type: "integer", minimum: 0 }, { type: "string", pattern: TOLERANCE.source }] },
|
|
538
|
+
duration: { type: "string", pattern: "^(0|\\d+[mhd])$" },
|
|
539
|
+
check: {
|
|
540
|
+
type: "object",
|
|
541
|
+
required: ["kind"],
|
|
542
|
+
properties: {
|
|
543
|
+
kind: { enum: ["drift", "apply", "policy", "http", "prometheus", "cloudwatch-alarm", "command", "health"] },
|
|
544
|
+
name: { type: "string", minLength: 1 },
|
|
545
|
+
onFail: { enum: ["restart", "hold"] },
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
soak: {
|
|
549
|
+
type: "object",
|
|
550
|
+
required: ["duration"],
|
|
551
|
+
additionalProperties: false,
|
|
552
|
+
properties: {
|
|
553
|
+
duration: { $ref: "#/$defs/duration" },
|
|
554
|
+
checks: { type: "array", items: { $ref: "#/$defs/check" } },
|
|
555
|
+
overrides: {
|
|
556
|
+
type: "array",
|
|
557
|
+
items: {
|
|
558
|
+
type: "object",
|
|
559
|
+
required: ["members"],
|
|
560
|
+
additionalProperties: false,
|
|
561
|
+
properties: { members: { type: "array", minItems: 1, items: { type: "string", minLength: 1 } }, duration: { $ref: "#/$defs/duration" }, checks: { type: "array", items: { $ref: "#/$defs/check" } } },
|
|
562
|
+
},
|
|
563
|
+
},
|
|
564
|
+
},
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
};
|