@intentius/chant 0.124.109 → 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/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/trust/seal.d.ts +7 -0
- package/dist/workspace/trust/seal.js +9 -0
- package/package.json +5 -1
|
@@ -74,6 +74,11 @@ import { type DriverComponent } from "../../components/driver.js";
|
|
|
74
74
|
import { type CapabilityRegistry } from "../../components/capability.js";
|
|
75
75
|
import type { ComponentEnvironmentDeclaration } from "../../components/component.js";
|
|
76
76
|
import { type PrHookPlace, type PrLoopHooks } from "../../components/pr-hooks.js";
|
|
77
|
+
import { type PrLoopCost } from "../../components/pr-cost.js";
|
|
78
|
+
import { type CostEstimate } from "../../cost-estimate.js";
|
|
79
|
+
import { type PrLoopRisk } from "../../components/pr-risk.js";
|
|
80
|
+
import type { ChangeRisk } from "../../change-risk.js";
|
|
81
|
+
import type { PolicyReview } from "../../components/pr-policy.js";
|
|
77
82
|
import { type PrLoopPolicy } from "../../components/pr-policy.js";
|
|
78
83
|
import type { OpWaveHookMoment } from "../../op/op-waves.js";
|
|
79
84
|
import type { PrHookOutcome } from "../../pr-loop.js";
|
|
@@ -124,6 +129,21 @@ export interface Prepared {
|
|
|
124
129
|
policy: PrLoopPolicy;
|
|
125
130
|
/** What the policy said about the plan, for the report's `policy`. */
|
|
126
131
|
policyReport?: PrPolicyReport;
|
|
132
|
+
/** `ci.cost` from the declaration at base (#5334). */
|
|
133
|
+
cost: PrLoopCost;
|
|
134
|
+
/** The plan's estimate under it, for the report's `cost` and the policy's `input.cost`. */
|
|
135
|
+
costEstimate?: CostEstimate;
|
|
136
|
+
/** `ci.risk` from the declaration at base (#5325). */
|
|
137
|
+
risk: PrLoopRisk;
|
|
138
|
+
/** The change risk under it, for the report's `risk`, the stored change set and the policy's `input.risk`, with the digest it scored. */
|
|
139
|
+
riskRecord?: {
|
|
140
|
+
digest: string;
|
|
141
|
+
risk: ChangeRisk;
|
|
142
|
+
};
|
|
143
|
+
/** The pull request's review, read once per job. */
|
|
144
|
+
review?: PolicyReview;
|
|
145
|
+
/** The `chant graph` flags the job's graph reads take: its `--param` and `--params-file`. */
|
|
146
|
+
graphArgs: string[];
|
|
127
147
|
/** `pr-apply --before-merge` (#4301): the requires checks, for the report's `beforeMerge`. */
|
|
128
148
|
beforeMerge?: PrBeforeMerge;
|
|
129
149
|
}
|
package/dist/cli/handlers/pr.js
CHANGED
|
@@ -105,6 +105,9 @@ import { PLAN_FLAG_ARGS, PlanFlagRefusedError, TargetsRefusedError } from "../..
|
|
|
105
105
|
import { prPlanTargets } from "../../components/pr-targets.js";
|
|
106
106
|
import { PREVIEW_COMMENT_ENV } from "../../components/pr-pipeline.js";
|
|
107
107
|
import { prLoopHooksAt, runPrHooks } from "../../components/pr-hooks.js";
|
|
108
|
+
import { estimatePrSet, prLoopCostAt } from "../../components/pr-cost.js";
|
|
109
|
+
import { policyCost, signedAmount } from "../../cost-estimate.js";
|
|
110
|
+
import { prLoopRiskAt, prRiskDependents, scorePrSet } from "../../components/pr-risk.js";
|
|
108
111
|
import { decidePrPolicyOverride, policyReviewOf, prLoopPolicyAt, preparePrPolicyEngine, prPolicyReport, runPrPolicy, spendPrPolicyOverride } from "../../components/pr-policy.js";
|
|
109
112
|
import { lexiconNames } from "../../lexicon-module.js";
|
|
110
113
|
import { actorFromEnv } from "../../actor.js";
|
|
@@ -183,6 +186,7 @@ export async function prepare(ctx, stage) {
|
|
|
183
186
|
buildParams: paramsResolution.provenance,
|
|
184
187
|
config,
|
|
185
188
|
registry,
|
|
189
|
+
env: args.env ?? "local",
|
|
186
190
|
});
|
|
187
191
|
}
|
|
188
192
|
catch (err) {
|
|
@@ -225,6 +229,26 @@ export async function prepare(ctx, stage) {
|
|
|
225
229
|
}
|
|
226
230
|
if (policy.note)
|
|
227
231
|
console.error(formatInfo(policy.note));
|
|
232
|
+
// #5334: the cost estimate, read from the declaration at base like the policy.
|
|
233
|
+
let cost;
|
|
234
|
+
try {
|
|
235
|
+
cost = prLoopCostAt(projectPath, base);
|
|
236
|
+
}
|
|
237
|
+
catch (err) {
|
|
238
|
+
return fail(err instanceof Error ? err.message : String(err));
|
|
239
|
+
}
|
|
240
|
+
if (cost.note)
|
|
241
|
+
console.error(formatInfo(cost.note));
|
|
242
|
+
// #5325: the change risk, read from the declaration at base like the cost.
|
|
243
|
+
let risk;
|
|
244
|
+
try {
|
|
245
|
+
risk = prLoopRiskAt(projectPath, base);
|
|
246
|
+
}
|
|
247
|
+
catch (err) {
|
|
248
|
+
return fail(err instanceof Error ? err.message : String(err));
|
|
249
|
+
}
|
|
250
|
+
if (risk.note)
|
|
251
|
+
console.error(formatInfo(risk.note));
|
|
228
252
|
const env = args.env ?? "local";
|
|
229
253
|
const routedAway = member ? await routing(ctx, stage, projectPath, member, base, forge) : undefined;
|
|
230
254
|
if (routedAway)
|
|
@@ -257,6 +281,9 @@ export async function prepare(ctx, stage) {
|
|
|
257
281
|
hookOutcomes: [],
|
|
258
282
|
...(routedAway ? { routedAway } : {}),
|
|
259
283
|
policy,
|
|
284
|
+
cost,
|
|
285
|
+
risk,
|
|
286
|
+
graphArgs: [...(args.param ?? []).flatMap((kv) => ["--param", kv]), ...(args.paramsFile ? ["--params-file", args.paramsFile] : [])],
|
|
260
287
|
};
|
|
261
288
|
}
|
|
262
289
|
/** Set where `p`'s hooks run, once the stage knows its op (#4288). */
|
|
@@ -668,6 +695,10 @@ async function finish(ctx, p, report, upload) {
|
|
|
668
695
|
report = { ...report, message: p.routedAway };
|
|
669
696
|
if (p.policyReport)
|
|
670
697
|
report = { ...report, policy: p.policyReport };
|
|
698
|
+
if (p.costEstimate)
|
|
699
|
+
report = { ...report, cost: p.costEstimate };
|
|
700
|
+
if (p.riskRecord && p.riskRecord.digest === report.digest)
|
|
701
|
+
report = { ...report, risk: p.riskRecord.risk };
|
|
671
702
|
if (p.beforeMerge)
|
|
672
703
|
report = { ...report, beforeMerge: p.beforeMerge };
|
|
673
704
|
// #4617: with a checkout of the control repo named, its entries and apply records mark the cross-stack edges.
|
|
@@ -731,11 +762,69 @@ function openUpload(events, stage, pr, p) {
|
|
|
731
762
|
* read only at the plan stage, and recorded for an override at the apply.
|
|
732
763
|
*/
|
|
733
764
|
async function judgePolicy(p, at) {
|
|
765
|
+
// #5334: the cost estimate first, so the policy reads it as input.cost. It only ever adds a hold.
|
|
766
|
+
const costHeld = priceSet(p, at.set);
|
|
767
|
+
// #5325: then the change risk, so the policy reads it as input.risk. It only ever adds a hold.
|
|
768
|
+
const risk = await riskOfSet(p, at.set.doc, at.pr);
|
|
769
|
+
const riskHeld = risk?.over ? `the change risk (${risk.score.toFixed(2)}, ${risk.level}) is over ci.risk: ${risk.overBy.join("; ")}, so the plan needs an approval of its own digest` : undefined;
|
|
770
|
+
if (riskHeld)
|
|
771
|
+
console.error(formatInfo(riskHeld));
|
|
772
|
+
const judged = await judgePolicyOnly(p, at);
|
|
773
|
+
const added = [costHeld, riskHeld].filter((w) => w !== undefined);
|
|
774
|
+
if (added.length === 0)
|
|
775
|
+
return judged;
|
|
776
|
+
return { ...judged, held: true, heldBy: [...(judged.heldBy ?? []), ...added] };
|
|
777
|
+
}
|
|
778
|
+
/** The pull request's review, read once per job (#4326). */
|
|
779
|
+
async function reviewOnce(p, pr) {
|
|
780
|
+
p.review ?? (p.review = await policyReviewOf(p.forge, pr));
|
|
781
|
+
return p.review;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* The change risk of a planned change set under `ci.risk` at base (#5325),
|
|
785
|
+
* scored once per digest and kept on `p`: the review's level and answers,
|
|
786
|
+
* the new migration files, and the dependents in the member's graph.
|
|
787
|
+
* Undefined when the base sets no `ci.risk`.
|
|
788
|
+
*/
|
|
789
|
+
async function riskOfSet(p, doc, pr) {
|
|
790
|
+
if (!p.risk.settings)
|
|
791
|
+
return undefined;
|
|
792
|
+
if (p.riskRecord?.digest === doc.digest)
|
|
793
|
+
return p.riskRecord.risk;
|
|
794
|
+
const review = await reviewOnce(p, pr);
|
|
795
|
+
const migrations = await newMigrations(p);
|
|
796
|
+
const { gateGraphReader } = await import("../../lifecycle/gate-change-set.js");
|
|
797
|
+
const graph = await prRiskDependents(doc, resolve("."), gateGraphReader(p.graphArgs));
|
|
798
|
+
if ("error" in graph)
|
|
799
|
+
console.error(formatInfo(`risk: the graph could not be read, so no dependents count: ${graph.error}`));
|
|
800
|
+
const risk = scorePrSet(p.risk, { doc, env: p.env, review, migrations, ...("dependents" in graph ? { dependents: graph.dependents } : {}) });
|
|
801
|
+
if (!risk)
|
|
802
|
+
return undefined;
|
|
803
|
+
p.riskRecord = { digest: doc.digest, risk };
|
|
804
|
+
console.error(formatInfo(`risk: ${risk.score.toFixed(2)} (${risk.level})`));
|
|
805
|
+
return risk;
|
|
806
|
+
}
|
|
807
|
+
/** Price the planned set under `ci.cost` at base (#5334), keeping the estimate on `p`. The hold's reason when the plan is over `approveAbove`. */
|
|
808
|
+
function priceSet(p, set) {
|
|
809
|
+
const estimate = estimatePrSet(p.cost, set, resolve("."));
|
|
810
|
+
if (!estimate)
|
|
811
|
+
return undefined;
|
|
812
|
+
p.costEstimate = estimate;
|
|
813
|
+
const unpriced = estimate.unestimated.length > 0 ? `; not estimated: ${estimate.unestimated.join(", ")}` : "";
|
|
814
|
+
console.error(formatInfo(`cost (${estimate.estimator}): ${signedAmount(estimate.monthlyDelta, estimate.currency)} a month${unpriced}`));
|
|
815
|
+
if (!estimate.over)
|
|
816
|
+
return undefined;
|
|
817
|
+
const why = `the cost estimate (${signedAmount(estimate.monthlyDelta, estimate.currency)} a month${unpriced}) is over ci.cost.approveAbove (${estimate.approveAbove} ${estimate.currency}), so the plan needs an approval of its own digest`;
|
|
818
|
+
console.error(formatInfo(why));
|
|
819
|
+
return why;
|
|
820
|
+
}
|
|
821
|
+
async function judgePolicyOnly(p, at) {
|
|
734
822
|
// The review is read only when a policy will run: a workspace with no policy makes no forge call for it.
|
|
735
|
-
const review = p.policy.settings ? await
|
|
823
|
+
const review = p.policy.settings ? await reviewOnce(p, at.pr) : undefined;
|
|
736
824
|
// #4774: with ci.policy.install, the engine is fetched here, once, and only for a stage that runs the policy.
|
|
737
825
|
p.policy = await preparePrPolicyEngine(p.policy);
|
|
738
|
-
const
|
|
826
|
+
const cost = p.costEstimate ? policyCost(p.costEstimate) : undefined;
|
|
827
|
+
const verdict = runPrPolicy(p.policy, { version: 1, stage: at.stage, op: at.op, gate: p.gate, env: p.env, pr: at.pr, base: p.base, head: p.head, changeSet: at.set.doc, ...(review ? { review } : {}), ...(cost ? { cost } : {}), ...(p.riskRecord?.digest === at.set.doc.digest ? { risk: p.riskRecord.risk } : {}) });
|
|
739
828
|
if (!verdict)
|
|
740
829
|
return { held: false };
|
|
741
830
|
const report = prPolicyReport(verdict, p.policy.base);
|
|
@@ -749,7 +838,7 @@ async function judgePolicy(p, at) {
|
|
|
749
838
|
for (const h of verdict.holds)
|
|
750
839
|
console.error(formatInfo(`policy holds the plan for a person's approval (${h.rule}): ${h.message}`));
|
|
751
840
|
if (verdict.result !== "denied")
|
|
752
|
-
return { held };
|
|
841
|
+
return held ? { held, heldBy: ["the policy holds this plan for an approval of its own digest"] } : { held };
|
|
753
842
|
const denied = verdict.denials.map((d) => `${d.rule}: ${d.message}`).join("; ");
|
|
754
843
|
let decided;
|
|
755
844
|
try {
|
|
@@ -1122,7 +1211,7 @@ async function prApply(ctx, stage, beforeMerge) {
|
|
|
1122
1211
|
// #4022: keep the change set the gate binds on chant/lifecycle under its
|
|
1123
1212
|
// digest before deciding the gate, so the plan an approval bound, or the
|
|
1124
1213
|
// one a pending fact waits on, can be read once this job is gone.
|
|
1125
|
-
await storeChangeSetForGate(ctx, p, set.doc);
|
|
1214
|
+
await storeChangeSetForGate(ctx, p, set.doc, pr);
|
|
1126
1215
|
let approval;
|
|
1127
1216
|
let via = "gate";
|
|
1128
1217
|
// #4294: the policy at base, before the gate. A resume runs under the decision of the attempt it finishes.
|
|
@@ -1134,7 +1223,7 @@ async function prApply(ctx, stage, beforeMerge) {
|
|
|
1134
1223
|
judged = await judgePolicy(p, { stage: "apply", op, pr, set });
|
|
1135
1224
|
if (judged.stop)
|
|
1136
1225
|
return stop(prReport({ ...base, approval: { status: "pending" }, status: "refused", refusal: judged.stop.refusal, message: judged.stop.message }), judged.stop.code);
|
|
1137
|
-
const decided = await decideApplyGate(p, { op, pr, set, events, held: judged.held, ...(green ? { green } : {}) });
|
|
1226
|
+
const decided = await decideApplyGate(p, { op, pr, set, events, held: judged.held, ...(judged.heldBy ? { heldBy: judged.heldBy } : {}), ...(green ? { green } : {}) });
|
|
1138
1227
|
approval = decided.approval;
|
|
1139
1228
|
// #4323: the after-gate hooks hear the decision, a refusal too; only a failure that would have applied changes the outcome.
|
|
1140
1229
|
const afterGate = await runGateHook(p, { op, digest: set.doc.digest, satisfied: decided.satisfied }, p.plan.order);
|
|
@@ -1712,8 +1801,10 @@ async function decideApplyGate(p, at) {
|
|
|
1712
1801
|
let uncovered = [];
|
|
1713
1802
|
// #4294: a plan the policy holds needs an approval of its own digest, so the merges' approvals do not cover it.
|
|
1714
1803
|
if (green && at.held) {
|
|
1715
|
-
|
|
1716
|
-
|
|
1804
|
+
// #5334: the cost over ci.cost.approveAbove holds it the same way.
|
|
1805
|
+
const why = at.heldBy?.length ? [...at.heldBy] : ["the policy holds this plan for an approval of its own digest"];
|
|
1806
|
+
console.error(formatInfo(`${why.join("; ")}: the plan at ${green.commit.slice(0, 12)} needs an approval of its own digest and does not apply under the merges' approvals`));
|
|
1807
|
+
uncovered = why;
|
|
1717
1808
|
}
|
|
1718
1809
|
else if (green) {
|
|
1719
1810
|
const cover = coverByMerges(set.doc, green.approved);
|
|
@@ -1824,8 +1915,17 @@ async function respondApply(ctx, p, report) {
|
|
|
1824
1915
|
console.error(formatWarning({ message: `no response was posted: ${given.error}` }));
|
|
1825
1916
|
return;
|
|
1826
1917
|
}
|
|
1827
|
-
const { respondPrApply } = await import("../../ci-respond-run.js");
|
|
1918
|
+
const { respondPrApply, triageOfPrReport } = await import("../../ci-respond-run.js");
|
|
1828
1919
|
await respondPrApply(p.forge, report, given);
|
|
1920
|
+
// #5357: with CHANT_AGENT_FACTS=apply-failed, a failed apply records its facts for the failed-apply agent, beside its triage.
|
|
1921
|
+
const { agentFactsOn, recordApplyFailed } = await import("../../ci-agent-triggers.js");
|
|
1922
|
+
const failed = agentFactsOn(process.env, "apply-failed") ? triageOfPrReport(report) : undefined;
|
|
1923
|
+
if (failed) {
|
|
1924
|
+
const { activeProductWords } = await import("../../ci-product-words.js");
|
|
1925
|
+
const line = await recordApplyFailed(failed, { op: report.op, product: activeProductWords().product });
|
|
1926
|
+
if (line)
|
|
1927
|
+
console.error(line);
|
|
1928
|
+
}
|
|
1829
1929
|
}
|
|
1830
1930
|
catch (err) {
|
|
1831
1931
|
console.error(formatWarning({ message: `the apply's responses were not posted: ${err instanceof Error ? err.message : String(err)}` }));
|
|
@@ -1955,7 +2055,10 @@ function emitReviewStop(events, message) {
|
|
|
1955
2055
|
* way. A change set that never reaches the remote throws
|
|
1956
2056
|
* `LifecyclePushLostError`, which stops the stage.
|
|
1957
2057
|
*/
|
|
1958
|
-
async function storeChangeSetForGate(ctx, p,
|
|
2058
|
+
async function storeChangeSetForGate(ctx, p, planned, pr) {
|
|
2059
|
+
// #5325: with ci.risk at base, the change set is stored with its risk record (not part of its digest).
|
|
2060
|
+
const risk = pr !== undefined ? await riskOfSet(p, planned, pr) : undefined;
|
|
2061
|
+
const doc = risk ? { ...planned, risk } : planned;
|
|
1959
2062
|
const { storeGateChangeSet, gateGraphReader } = await import("../../lifecycle/gate-change-set.js");
|
|
1960
2063
|
const { pushLifecycleRebasing, LifecyclePushLostError } = await import("../../lifecycle/git.js");
|
|
1961
2064
|
const graphArgs = [
|
|
@@ -2231,12 +2334,12 @@ async function prApplyWaves(ctx, p, at) {
|
|
|
2231
2334
|
return stop(report({ status: "plan-failed", message: "The policy denied a member's plan, so nothing was applied." }), CHANT_EXIT.denied);
|
|
2232
2335
|
return stop(report({ status: "plan-failed", message: "A member failed to plan, so there is no plan to compare with the approved one. Nothing was applied." }), 1);
|
|
2233
2336
|
}
|
|
2234
|
-
await storeChangeSetForGate(ctx, p, set.doc);
|
|
2337
|
+
await storeChangeSetForGate(ctx, p, set.doc, pr);
|
|
2235
2338
|
// #4294: the policy at base judges the whole change set, before the pull request's gate.
|
|
2236
2339
|
judged = await judgePolicy(p, { stage: "apply", op, pr, set });
|
|
2237
2340
|
if (judged.stop)
|
|
2238
2341
|
return stop(report({ status: "refused", refusal: judged.stop.refusal, message: judged.stop.message }), judged.stop.code);
|
|
2239
|
-
const decided = await decideApplyGate(p, { op, pr, set, events, held: judged.held, ...(green ? { green } : {}) });
|
|
2342
|
+
const decided = await decideApplyGate(p, { op, pr, set, events, held: judged.held, ...(judged.heldBy ? { heldBy: judged.heldBy } : {}), ...(green ? { green } : {}) });
|
|
2240
2343
|
approval = decided.approval;
|
|
2241
2344
|
// #4323: the after-gate hooks hear the decision, a refusal too.
|
|
2242
2345
|
const afterGate = await runGateHook(p, { op, digest: set.doc.digest, satisfied: decided.satisfied }, p.plan.order);
|