@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
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which rejections stop a gate (#5354).
|
|
3
|
+
*
|
|
4
|
+
* `chant reject <op> <gate>` records a rejection of the digest a gate waits
|
|
5
|
+
* on (`../lifecycle/gate-rejection.ts`). At a stage's gate that digest is a
|
|
6
|
+
* release's, so a rejection turns that release down at that stage. A
|
|
7
|
+
* rejection that counts stops the gate before any approval is read: more
|
|
8
|
+
* approvals never clear it. Only a new release, with a new digest, goes
|
|
9
|
+
* through again.
|
|
10
|
+
*
|
|
11
|
+
* A rejection counts by the proof rules an approval of the same gate counts
|
|
12
|
+
* by:
|
|
13
|
+
*
|
|
14
|
+
* - it is a person's, as only a person's approval counts toward a quorum;
|
|
15
|
+
* - a gate whose `approval` mode is `sealed` counts only a rejection whose
|
|
16
|
+
* seal verifies against the signers at base, as it counts only sealed
|
|
17
|
+
* approvals. `ledger`, `pr-review` and `pull-request` take a plain
|
|
18
|
+
* `chant approve` line, so they take a plain `chant reject` line too;
|
|
19
|
+
* - a gate the workspace's `identity.gates` names counts only a rejection
|
|
20
|
+
* that rule admits (signed, from its class);
|
|
21
|
+
* - a gate with approval rules counts a rejection only from someone one of
|
|
22
|
+
* its rules would count as an approver: a rule with `proven` or `roles`
|
|
23
|
+
* counts only a proven approver, one holding a role it names.
|
|
24
|
+
*
|
|
25
|
+
* A rejection that does not count is listed with why, so the run says so.
|
|
26
|
+
* Pure: no git, no clock.
|
|
27
|
+
*/
|
|
28
|
+
import { isModelAuthored } from "../lifecycle/gate-origin.js";
|
|
29
|
+
import { samePlanDigest } from "../lifecycle/plan-digest.js";
|
|
30
|
+
import { rejectionSealRefusal } from "../lifecycle/gate-rejection.js";
|
|
31
|
+
import { quorumRules, rolesOf, ruleAdmits } from "./gate-quorum.js";
|
|
32
|
+
/**
|
|
33
|
+
* The first chant with `chant reject` (#5354): a rejection of the digest a
|
|
34
|
+
* gate waits on, which stops a release at a pipeline stage's gate by the
|
|
35
|
+
* proof rules the gate's approvals count by, and with approval rules that
|
|
36
|
+
* combine in `all` and `any` groups, nested up to three deep, each rule and
|
|
37
|
+
* group with a `name` the progress lines, the plan note and the ledger
|
|
38
|
+
* show, a stage hold's `description`, and a `reject` comment command a
|
|
39
|
+
* comment job records under the author's forge identity (`../ci-comment-reject.ts`).
|
|
40
|
+
*/
|
|
41
|
+
export const GATE_REJECTION_FLOOR = "0.124.110";
|
|
42
|
+
/** Whether `r` rejects this gate's digest: its gate, digest, environment and release. */
|
|
43
|
+
export function rejectsDigest(r, input) {
|
|
44
|
+
if (r.gate !== input.gate || !samePlanDigest(r.planDigest, input.planDigest))
|
|
45
|
+
return false;
|
|
46
|
+
if (r.environment !== undefined && input.environment !== undefined && r.environment !== input.environment)
|
|
47
|
+
return false;
|
|
48
|
+
if (r.releaseDigest !== undefined && r.releaseDigest !== input.releaseDigest)
|
|
49
|
+
return false;
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
/** Why `r` does not count at the gate, or null when it does. */
|
|
53
|
+
export function rejectionRefusal(r, input) {
|
|
54
|
+
if (r.approver?.kind === "agent" || (r.approver === undefined && isModelAuthored(r.origin))) {
|
|
55
|
+
return `${r.rejectedBy} is an agent, and only a person's rejection counts, as only a person's approval counts`;
|
|
56
|
+
}
|
|
57
|
+
const sealWhy = r.seal !== undefined ? rejectionSealRefusal(input.signers, r) : "it is not signed";
|
|
58
|
+
const proven = sealWhy === null;
|
|
59
|
+
if (input.identity) {
|
|
60
|
+
const why = input.identity(r);
|
|
61
|
+
if (why !== null)
|
|
62
|
+
return why;
|
|
63
|
+
}
|
|
64
|
+
if (input.mode === "sealed" && !proven)
|
|
65
|
+
return `gate ${input.gate} counts only sealed approvals, so it counts only a sealed rejection (chant reject --sign), and ${sealWhy}`;
|
|
66
|
+
const rules = quorumRules(input.quorum);
|
|
67
|
+
if (rules.length === 0)
|
|
68
|
+
return null;
|
|
69
|
+
const judged = { proven, roles: proven ? rolesOf(r.rejectedBy, input.roles) : [] };
|
|
70
|
+
if (rules.some((rule) => ruleAdmits(rule, judged)))
|
|
71
|
+
return null;
|
|
72
|
+
const roles = [...new Set(rules.flatMap((rule) => rule.roles ?? []))];
|
|
73
|
+
return proven
|
|
74
|
+
? `no approval rule of gate ${input.gate} counts ${r.rejectedBy}: .chant/trust.json at base gives them none of ${roles.join(", ")}`
|
|
75
|
+
: `every approval rule of gate ${input.gate} counts only a proven approver, so it counts only a sealed rejection (chant reject --sign), and ${sealWhy}`;
|
|
76
|
+
}
|
|
77
|
+
/** The rejections of the gate's digest, split into those that stop it and those that do not count. */
|
|
78
|
+
export function gateRejections(records, input) {
|
|
79
|
+
const at = (r) => Date.parse(r.timestamp);
|
|
80
|
+
const standing = [];
|
|
81
|
+
const ignored = [];
|
|
82
|
+
for (const r of [...records].sort((a, b) => at(a) - at(b))) {
|
|
83
|
+
if (!rejectsDigest(r, input))
|
|
84
|
+
continue;
|
|
85
|
+
const why = rejectionRefusal(r, input);
|
|
86
|
+
if (why === null)
|
|
87
|
+
standing.push(r);
|
|
88
|
+
else
|
|
89
|
+
ignored.push({ rejection: r, why });
|
|
90
|
+
}
|
|
91
|
+
return { standing, ignored };
|
|
92
|
+
}
|
|
93
|
+
/** The line a stopped gate prints for one rejection: who, when and why. */
|
|
94
|
+
export function rejectionLine(r) {
|
|
95
|
+
return `rejected by ${r.rejectedBy} at ${r.timestamp}${r.seal ? " (signed)" : ""}: ${r.reason}`;
|
|
96
|
+
}
|
package/dist/op/gate-summary.js
CHANGED
|
@@ -55,7 +55,7 @@ export function gatedRunSummaryMarkdown(summary) {
|
|
|
55
55
|
lines.push(`This approves one plan, \`${summary.planDigest}\`, and not the next run (#2300). ` +
|
|
56
56
|
"Change the configuration after approving and the next run refuses rather than applying.", "");
|
|
57
57
|
}
|
|
58
|
-
lines.push("Approve it, then re-run this workflow:", "", "```", `${approveCommand(summary.op, summary.gate, summary.environment,
|
|
58
|
+
lines.push("Approve it, then re-run this workflow:", "", "```", `${approveCommand(summary.op, summary.gate, summary.environment, summary.planDigest, summary.sealed === true)} --approver <you>`, "```", "", `Ledger: \`${gateLedgerPath(summary.op, summary.ledgerPrefix)}\` on the \`chant/lifecycle\` branch.`);
|
|
59
59
|
if (summary.expiresAt)
|
|
60
60
|
lines.push(`Expires: ${summary.expiresAt}`);
|
|
61
61
|
if (summary.url)
|
package/dist/op/gate.d.ts
CHANGED
|
@@ -33,9 +33,10 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import type { ChangeSetDocument } from "../change-set.js";
|
|
35
35
|
import { type GateResolutionInput, type GateResolutionRecord, type PendingGateInput, type PendingGateRecord } from "../lifecycle/gate-ledger.js";
|
|
36
|
+
import { type GateRejectionRecord } from "../lifecycle/gate-rejection.js";
|
|
36
37
|
import { type AppliedGateRecord, type FinishedGateRecord } from "../lifecycle/gate-applied.js";
|
|
37
38
|
import { type GateApprover, type GateBaseApproval, type ResolvedGateApproval } from "./gate-approval.js";
|
|
38
|
-
import { type GateQuorumJudge, type GateQuorumRuleProgress, type GateQuorumSpec } from "./gate-quorum.js";
|
|
39
|
+
import { type GateQuorumGroupProgress, type GateQuorumJudge, type GateQuorumRuleProgress, type GateQuorumSpec } from "./gate-quorum.js";
|
|
39
40
|
import { type GateCheckpoint } from "../lifecycle/gate-checkpoint.js";
|
|
40
41
|
import type { ResolvedGateAlias } from "./gate-alias.js";
|
|
41
42
|
/**
|
|
@@ -149,6 +150,13 @@ export interface GateLedgerPort {
|
|
|
149
150
|
* port that keeps none, and the fact then cites none.
|
|
150
151
|
*/
|
|
151
152
|
storeChangeSet?(doc: ChangeSetDocument): Promise<void>;
|
|
153
|
+
/** The rejections of `op`'s gates (#5354), from `_gates/<op>/rejected.jsonl`, oldest first. Absent on a port that keeps none. */
|
|
154
|
+
readRejections?(op: string): Promise<GateRejectionRecord[]>;
|
|
155
|
+
/** Append a rejection (#5354) and push it. */
|
|
156
|
+
appendRejection?(record: GateRejectionRecord): Promise<{
|
|
157
|
+
pushed: boolean;
|
|
158
|
+
pushWarning?: string;
|
|
159
|
+
}>;
|
|
152
160
|
}
|
|
153
161
|
/** A workspace's rule for which approvals of a gate count (#3163): a signed approval, from a class when it names one. */
|
|
154
162
|
export interface GateApprovalRule {
|
|
@@ -165,6 +173,12 @@ export interface GateApprovalRule {
|
|
|
165
173
|
} & GateBaseApproval;
|
|
166
174
|
/** Why `approval` doesn't count, or null when it does. */
|
|
167
175
|
refuses(approval: GateResolutionRecord): string | null;
|
|
176
|
+
/**
|
|
177
|
+
* Why a rejection (#5354) doesn't count, or null when it does: the same
|
|
178
|
+
* rule over the rejection's own seal. Absent on a rule that judges no
|
|
179
|
+
* rejection; a gate with such a rule then counts no rejection.
|
|
180
|
+
*/
|
|
181
|
+
refusesRejection?(rejection: GateRejectionRecord): string | null;
|
|
168
182
|
}
|
|
169
183
|
/**
|
|
170
184
|
* The real port: the `chant/lifecycle` orphan branch.
|
|
@@ -193,8 +207,11 @@ export declare function memoryGateLedgerPort(seed?: {
|
|
|
193
207
|
resolutions?: GateResolutionRecord[];
|
|
194
208
|
pending?: PendingGateRecord[];
|
|
195
209
|
applied?: AppliedGateRecord[];
|
|
210
|
+
rejections?: GateRejectionRecord[];
|
|
196
211
|
}): GateLedgerPort & {
|
|
197
212
|
appended: PendingGateRecord[];
|
|
213
|
+
/** The rejections, seeded and appended (#5354). */
|
|
214
|
+
rejections: GateRejectionRecord[];
|
|
198
215
|
resolved: GateResolutionRecord[];
|
|
199
216
|
applied: AppliedGateRecord[];
|
|
200
217
|
/** The finished lines appended (#4623). */
|
|
@@ -378,6 +395,8 @@ export interface GateQuorumProgress {
|
|
|
378
395
|
need: number;
|
|
379
396
|
/** Where each approval rule the gate takes stands (#4290). Absent when it takes none. */
|
|
380
397
|
rules?: GateQuorumRuleProgress[];
|
|
398
|
+
/** Where each `all`/`any` group stands (#5354). Absent when the rules have no group. */
|
|
399
|
+
groups?: Array<GateQuorumRuleProgress | GateQuorumGroupProgress>;
|
|
381
400
|
}
|
|
382
401
|
/** Either the gate is answered, or it is a standing fact. */
|
|
383
402
|
export type GateCheck = {
|
|
@@ -440,7 +459,9 @@ export interface GateTally {
|
|
|
440
459
|
met: boolean;
|
|
441
460
|
/** Where each rule stands (#4290). Absent when the gate takes no rule. */
|
|
442
461
|
rules?: GateQuorumRuleProgress[];
|
|
443
|
-
/**
|
|
462
|
+
/** Where each top-level rule and `all`/`any` group stands (#5354). Absent when the gate's rules have no group. */
|
|
463
|
+
groups?: Array<GateQuorumRuleProgress | GateQuorumGroupProgress>;
|
|
464
|
+
/** The newest approval whose recorded permit passes the gate. Only in `enforce` mode, only for a permit recorded under `enforce`, and only under the gate's current policy version and resolved context. An agent's counts alone only under `agentPassesAlone` (#5388), else beside a person's approval. */
|
|
444
465
|
permit?: GateResolutionRecord;
|
|
445
466
|
/** The newest approval of this gate for a different plan, when the gate binds one. */
|
|
446
467
|
mismatched?: GateResolutionRecord;
|
|
@@ -467,7 +488,11 @@ export interface GateTally {
|
|
|
467
488
|
* `enforce` (#2512), and evaluated under the context the gate resolves now
|
|
468
489
|
* (#3774). A `log-only` decision never changes the outcome, even
|
|
469
490
|
* after the gate switches to `enforce`, and a `deny` never removes a human's approval: a policy can add
|
|
470
|
-
* a way through the gate but cannot take one away.
|
|
491
|
+
* a way through the gate but cannot take one away. A permit that reads the change risk (#5325,
|
|
492
|
+
* {@link gatePermitReadsRisk}) counts only from a human `judge` proves: an agent's is refused.
|
|
493
|
+
* An agent's permit passes the gate alone only when `approval.agentPassesAlone`
|
|
494
|
+
* is set, which only `identity.gates.<gate>` at base sets (#5388); without it,
|
|
495
|
+
* it passes the gate only beside a person's approval of the same plan.
|
|
471
496
|
*/
|
|
472
497
|
export declare function tallyGateApprovals(records: GateResolutionRecord[], gate: string, sinceIso: string, planDigest: string | undefined, approval: ResolvedGateApproval, humansSinceIso?: string, judge?: GateQuorumJudge): GateTally;
|
|
473
498
|
/**
|
package/dist/op/gate.js
CHANGED
|
@@ -35,12 +35,13 @@ import { persistChangeSet } from "../lifecycle/change-set-store.js";
|
|
|
35
35
|
import { activeProductWords, approveLine, isChantWords } from "../ci-product-words.js";
|
|
36
36
|
import { appendGateResolution, appendPendingGate, isPendingGateExpired, latestPendingGate, latestResolutionForPlan, readGateLedger, resolveApprovalUrl, DEFAULT_GATE_EXPIRY, } from "../lifecycle/gate-ledger.js";
|
|
37
37
|
import { describePlanDigest, samePlanDigest } from "../lifecycle/plan-digest.js";
|
|
38
|
+
import { gateRejectionPath, parseGateRejections } from "../lifecycle/gate-rejection.js";
|
|
38
39
|
import { isModelAuthored } from "../lifecycle/gate-origin.js";
|
|
39
40
|
import { appliedGatePath, isApprovalSpent, parseAppliedGateFile, parseAppliedGateLines } from "../lifecycle/gate-applied.js";
|
|
40
41
|
import { gatedRequestAttachmentPath } from "../lifecycle/gated-request-digest.js";
|
|
41
42
|
import { sortedJsonReplacer } from "../utils.js";
|
|
42
|
-
import { gateContextDigest } from "./gate-approval.js";
|
|
43
|
-
import { quorumNeed,
|
|
43
|
+
import { gateContextDigest, gatePermitReadsRisk } from "./gate-approval.js";
|
|
44
|
+
import { quorumNeed, quorumNodes, quorumRules, quorumTreeProgress, ruleNeedsProof, samePrincipal, trustQuorumJudge, UNPROVEN_JUDGE, } from "./gate-quorum.js";
|
|
44
45
|
import { LifecyclePushLostError, pushLifecycleRebasing, readBlobBySha, readBlobFromPath, readPathSha, requireLifecycleLedger, writeBlobToPath, RefCASConflictError } from "../lifecycle/git.js";
|
|
45
46
|
import { parseDuration } from "./duration.js";
|
|
46
47
|
import { ciRunIdFromEnv, resolveGateRunLocator } from "./gate-run-locator.js";
|
|
@@ -118,6 +119,15 @@ export function gitGateLedgerPort(opts) {
|
|
|
118
119
|
async appendApplied(record) {
|
|
119
120
|
return appendAppliedFileLine(record.op, record, `Applied under ${record.gate}`);
|
|
120
121
|
},
|
|
122
|
+
async readRejections(op) {
|
|
123
|
+
await requireLifecycleLedger(opts);
|
|
124
|
+
const { dir, file } = gateRejectionPath(op);
|
|
125
|
+
const text = await readBlobFromPath(dir, file, opts);
|
|
126
|
+
return text ? parseGateRejections(text) : [];
|
|
127
|
+
},
|
|
128
|
+
async appendRejection(record) {
|
|
129
|
+
return appendAppliedFileLine(record.op, record, `Rejected at ${record.gate}`, gateRejectionPath(record.op));
|
|
130
|
+
},
|
|
121
131
|
async appendFinished(record) {
|
|
122
132
|
return appendAppliedFileLine(record.op, record, `Finished under ${record.gate}`);
|
|
123
133
|
},
|
|
@@ -142,8 +152,8 @@ export function gitGateLedgerPort(opts) {
|
|
|
142
152
|
},
|
|
143
153
|
};
|
|
144
154
|
/** Append one line to `_gates/<op>/applied.jsonl` on top of the remote's ledger, retrying on a concurrent writer, and push. */
|
|
145
|
-
async function appendAppliedFileLine(op, record, message) {
|
|
146
|
-
const { dir, file } =
|
|
155
|
+
async function appendAppliedFileLine(op, record, message, at = appliedGatePath(op)) {
|
|
156
|
+
const { dir, file } = at;
|
|
147
157
|
const line = JSON.stringify(record, sortedJsonReplacer);
|
|
148
158
|
// #3985: write on top of the remote's ledger, not a local copy another
|
|
149
159
|
// writer has since moved past, so the push that follows can land.
|
|
@@ -193,8 +203,17 @@ export function memoryGateLedgerPort(seed = {}) {
|
|
|
193
203
|
const finished = [];
|
|
194
204
|
const attachments = new Map();
|
|
195
205
|
const reports = new Map();
|
|
206
|
+
const rejections = [...(seed.rejections ?? [])];
|
|
196
207
|
return {
|
|
197
208
|
reports,
|
|
209
|
+
rejections,
|
|
210
|
+
async readRejections(op) {
|
|
211
|
+
return rejections.filter((r) => r.op === op);
|
|
212
|
+
},
|
|
213
|
+
async appendRejection(record) {
|
|
214
|
+
rejections.push(record);
|
|
215
|
+
return { pushed: true };
|
|
216
|
+
},
|
|
198
217
|
async storeGateReport(op, gate, digest, text) {
|
|
199
218
|
const at = opWaveGateReportPath(op, gate, digest);
|
|
200
219
|
if (!reports.has(at))
|
|
@@ -274,7 +293,7 @@ export function describeGateMismatch(op, gate, mismatch, sealed = false) {
|
|
|
274
293
|
return (`Gate "${gate}" is approved, but not for this plan. ` +
|
|
275
294
|
`approved: ${describePlanDigest(mismatch.approved)} (by ${mismatch.resolvedBy} at ${mismatch.timestamp}); ` +
|
|
276
295
|
`planned: ${mismatch.planned}. ` +
|
|
277
|
-
`${why} ${approveCommand(op, gate, mismatch.environment,
|
|
296
|
+
`${why} ${approveCommand(op, gate, mismatch.environment, mismatch.planned, sealed)}`);
|
|
278
297
|
}
|
|
279
298
|
/** How a recorded approval reads: its own `approver`, or for a record written before #2508, a human unless a model-authored channel wrote it. */
|
|
280
299
|
export function approverOf(record) {
|
|
@@ -304,17 +323,26 @@ export function approverOf(record) {
|
|
|
304
323
|
* `enforce` (#2512), and evaluated under the context the gate resolves now
|
|
305
324
|
* (#3774). A `log-only` decision never changes the outcome, even
|
|
306
325
|
* after the gate switches to `enforce`, and a `deny` never removes a human's approval: a policy can add
|
|
307
|
-
* a way through the gate but cannot take one away.
|
|
326
|
+
* a way through the gate but cannot take one away. A permit that reads the change risk (#5325,
|
|
327
|
+
* {@link gatePermitReadsRisk}) counts only from a human `judge` proves: an agent's is refused.
|
|
328
|
+
* An agent's permit passes the gate alone only when `approval.agentPassesAlone`
|
|
329
|
+
* is set, which only `identity.gates.<gate>` at base sets (#5388); without it,
|
|
330
|
+
* it passes the gate only beside a person's approval of the same plan.
|
|
308
331
|
*/
|
|
309
332
|
export function tallyGateApprovals(records, gate, sinceIso, planDigest, approval, humansSinceIso = sinceIso, judge = UNPROVEN_JUDGE) {
|
|
310
333
|
const since = new Date(sinceIso).getTime();
|
|
311
334
|
const humansSince = Math.min(since, new Date(humansSinceIso).getTime());
|
|
312
335
|
const at = (r) => new Date(r.timestamp).getTime();
|
|
336
|
+
// #5354: the rules a gate takes may be grouped with all and any; `rules` is every rule, for what any of them needs.
|
|
337
|
+
const nodes = quorumNodes(approval.quorum);
|
|
313
338
|
const rules = quorumRules(approval.quorum);
|
|
314
339
|
const context = gateContextDigest(approval.context);
|
|
340
|
+
const readsRisk = gatePermitReadsRisk(approval);
|
|
315
341
|
// Each human once: their newest approval, or their newest proven one when they have one.
|
|
316
342
|
const byActor = new Map();
|
|
343
|
+
// #5388: a person's permit and an agent's, kept apart until the humans are known.
|
|
317
344
|
let permit;
|
|
345
|
+
let agentPermit;
|
|
318
346
|
let mismatched;
|
|
319
347
|
for (const r of records) {
|
|
320
348
|
if (r.gate !== gate || at(r) < humansSince)
|
|
@@ -336,8 +364,15 @@ export function tallyGateApprovals(records, gate, sinceIso, planDigest, approval
|
|
|
336
364
|
// re-records the pending fact for a changed context.
|
|
337
365
|
if (sinceStanding && approval.mode === "enforce" && approval.policy && decision?.decision === "allow" &&
|
|
338
366
|
decision.mode === "enforce" && decision.version === approval.policy.version &&
|
|
339
|
-
decision.contextDigest === context &&
|
|
340
|
-
permit
|
|
367
|
+
decision.contextDigest === context &&
|
|
368
|
+
// #5325: a permit that reads the change risk counts only from a human the trust at base proves; an agent's is refused.
|
|
369
|
+
(!readsRisk || (approverOf(r).kind === "human" && judge(r).proven))) {
|
|
370
|
+
if (approverOf(r).kind === "human") {
|
|
371
|
+
if (!permit || at(r) >= at(permit))
|
|
372
|
+
permit = r;
|
|
373
|
+
}
|
|
374
|
+
else if (!agentPermit || at(r) >= at(agentPermit))
|
|
375
|
+
agentPermit = r;
|
|
341
376
|
}
|
|
342
377
|
if (approverOf(r).kind !== "human")
|
|
343
378
|
continue;
|
|
@@ -348,13 +383,18 @@ export function tallyGateApprovals(records, gate, sinceIso, planDigest, approval
|
|
|
348
383
|
byActor.set(key, { record: r, proven });
|
|
349
384
|
}
|
|
350
385
|
const humans = [...byActor.values()].map((v) => v.record).sort((a, b) => at(a) - at(b));
|
|
386
|
+
// #5388: an agent's permit passes the gate alone only when the entry at base
|
|
387
|
+
// sets agentPassesAlone. Without it, it counts beside a person's approval of this plan.
|
|
388
|
+
if (agentPermit && (approval.agentPassesAlone === true || humans.length > 0) && (!permit || at(agentPermit) >= at(permit)))
|
|
389
|
+
permit = agentPermit;
|
|
351
390
|
const extra = { ...(permit ? { permit } : {}), ...(mismatched ? { mismatched } : {}) };
|
|
352
391
|
if (rules.length === 0)
|
|
353
392
|
return { counted: humans, need: 1, met: humans.length >= 1, ...extra };
|
|
354
393
|
const approvers = humans.map((r) => ({ who: r.resolvedBy, at: r.timestamp, judged: judge(r) }));
|
|
355
|
-
const
|
|
394
|
+
const tree = quorumTreeProgress(nodes, approvers);
|
|
395
|
+
const progress = tree.rules;
|
|
356
396
|
const counted = humans.filter((r) => progress.some((p) => p.approvers.some((a) => samePrincipal(a, r.resolvedBy))));
|
|
357
|
-
return { counted, need: quorumNeed(rules), met:
|
|
397
|
+
return { counted, need: quorumNeed(rules), met: tree.met, rules: progress, ...(tree.groups ? { groups: tree.groups } : {}), ...extra };
|
|
358
398
|
}
|
|
359
399
|
/**
|
|
360
400
|
* Where a gate's human quorum starts counting (#3206): the oldest pending fact
|
|
@@ -595,7 +635,9 @@ export async function evaluateGate(port, input) {
|
|
|
595
635
|
: since;
|
|
596
636
|
// #4290: who an approval proves, and their roles at base, for rules that read them.
|
|
597
637
|
// #4333: a caller's judge applies to every rule, since it may leave out everyone involved in the change.
|
|
598
|
-
|
|
638
|
+
// #5325: a permit that reads the change risk needs the approver proven too.
|
|
639
|
+
const needsProof = quorumRules(input.approval.quorum).some(ruleNeedsProof) || gatePermitReadsRisk(input.approval);
|
|
640
|
+
const judge = input.judge ?? (needsProof ? ((await port.quorumJudge?.(input.gate)) ?? UNPROVEN_JUDGE) : UNPROVEN_JUDGE);
|
|
599
641
|
const tally = tallyGateApprovals(resolutions, input.gate, since, input.planDigest, input.approval, humansSince, judge);
|
|
600
642
|
if (tally.permit) {
|
|
601
643
|
return { satisfied: true, resolution: tally.permit, via: "policy", approvals: tally.counted };
|
|
@@ -609,7 +651,7 @@ export async function evaluateGate(port, input) {
|
|
|
609
651
|
};
|
|
610
652
|
}
|
|
611
653
|
mismatched = tally.mismatched;
|
|
612
|
-
quorum = { approvers: tally.counted.map((r) => r.resolvedBy), need: tally.need, ...(tally.rules ? { rules: tally.rules } : {}) };
|
|
654
|
+
quorum = { approvers: tally.counted.map((r) => r.resolvedBy), need: tally.need, ...(tally.rules ? { rules: tally.rules } : {}), ...(tally.groups ? { groups: tally.groups } : {}) };
|
|
613
655
|
// #3949: old and new approvals add up toward one quorum, each approver once.
|
|
614
656
|
const counted = new Set(tally.counted.map((r) => r.resolvedBy));
|
|
615
657
|
const extra = fromAliases.filter((r) => !counted.has(r.resolvedBy));
|
|
@@ -621,7 +663,7 @@ export async function evaluateGate(port, input) {
|
|
|
621
663
|
const approvals = [...combined.counted.filter((r) => !asCarried.has(r)), ...written];
|
|
622
664
|
return { satisfied: true, resolution: written[written.length - 1], via: "alias", approvals, carried: written };
|
|
623
665
|
}
|
|
624
|
-
quorum = { approvers: combined.counted.map((r) => r.resolvedBy), need: combined.need, ...(combined.rules ? { rules: combined.rules } : {}) };
|
|
666
|
+
quorum = { approvers: combined.counted.map((r) => r.resolvedBy), need: combined.need, ...(combined.rules ? { rules: combined.rules } : {}), ...(combined.groups ? { groups: combined.groups } : {}) };
|
|
625
667
|
}
|
|
626
668
|
}
|
|
627
669
|
else {
|
|
@@ -18,6 +18,14 @@
|
|
|
18
18
|
import { type DiscoveredOp } from "./discover.js";
|
|
19
19
|
import { type ComponentPipelineOptions, type ScheduledOpSpec, type OpPipelineFile, type OpPipelineJob, type OpWavesPipelineOptions } from "../lexicon.js";
|
|
20
20
|
import { type OpWaveJob, type OpWavesSpec } from "./op-waves.js";
|
|
21
|
+
import { type OpWavesProofSources } from "./op-waves-quorum-warnings.js";
|
|
22
|
+
/**
|
|
23
|
+
* What can prove an approver in the repository at `root` (#5349): the
|
|
24
|
+
* signers file `.chant/trust.json` names, and whether it, or the passkeys,
|
|
25
|
+
* list anyone. A policy that cannot be read lists nobody. The workspace
|
|
26
|
+
* modules load here, never at import, so level 0 stays free of them (#5219).
|
|
27
|
+
*/
|
|
28
|
+
export declare function opWavesProofSourcesAt(root: string): Promise<OpWavesProofSources>;
|
|
21
29
|
/**
|
|
22
30
|
* Copy each discovered Op's own `schedule` (#2120) onto its spec, so a CI
|
|
23
31
|
* generator can render the cron the Op already declares — `WatchOp({ name,
|
|
@@ -33,6 +41,8 @@ export interface GenerateOpsPipelineResult {
|
|
|
33
41
|
files?: OpPipelineFile[];
|
|
34
42
|
/** Every generated job, for a machine-readable view. */
|
|
35
43
|
jobs?: OpPipelineJob[];
|
|
44
|
+
/** The generator's warnings (#5329). */
|
|
45
|
+
warnings?: string[];
|
|
36
46
|
error?: string;
|
|
37
47
|
}
|
|
38
48
|
/**
|
|
@@ -52,10 +62,14 @@ export interface GenerateOpWavesPipelineResult {
|
|
|
52
62
|
files?: OpPipelineFile[];
|
|
53
63
|
jobs?: OpWaveJob[];
|
|
54
64
|
error?: string;
|
|
65
|
+
/** What the spec allows but should not rely on, one line each: `opWavesQuorumFindings` (#5349), then `opWavesCanaryWarnings` (#5327). */
|
|
66
|
+
warnings?: string[];
|
|
55
67
|
}
|
|
56
68
|
/**
|
|
57
69
|
* Render ordered waves of Op runs for `lexicon` (#3679, `./op-waves.ts`):
|
|
58
70
|
* check the spec, check that every Op it names exists, then hand it to the
|
|
59
71
|
* lexicon's `generateOpWavesPipeline`.
|
|
60
72
|
*/
|
|
61
|
-
export declare function generateOpWavesPipeline(spec: OpWavesSpec, lexicon: string, options: OpWavesPipelineOptions, cwd?: string
|
|
73
|
+
export declare function generateOpWavesPipeline(spec: OpWavesSpec, lexicon: string, options: OpWavesPipelineOptions, cwd?: string,
|
|
74
|
+
/** What can prove an approver (#5349). Default: read from the repository at `cwd`. */
|
|
75
|
+
proof?: OpWavesProofSources): Promise<GenerateOpWavesPipelineResult>;
|
|
@@ -18,7 +18,26 @@
|
|
|
18
18
|
import { discoverOps } from "./discover.js";
|
|
19
19
|
import { lexiconModulePath, importLexiconPackage } from "../lexicon-module.js";
|
|
20
20
|
import { isLexiconPlugin, } from "../lexicon.js";
|
|
21
|
-
import { assertOpWavesSpec } from "./op-waves.js";
|
|
21
|
+
import { assertOpWavesSpec, opWavesCanaryWarnings } from "./op-waves.js";
|
|
22
|
+
import { opWavesQuorumFindings } from "./op-waves-quorum-warnings.js";
|
|
23
|
+
/**
|
|
24
|
+
* What can prove an approver in the repository at `root` (#5349): the
|
|
25
|
+
* signers file `.chant/trust.json` names, and whether it, or the passkeys,
|
|
26
|
+
* list anyone. A policy that cannot be read lists nobody. The workspace
|
|
27
|
+
* modules load here, never at import, so level 0 stays free of them (#5219).
|
|
28
|
+
*/
|
|
29
|
+
export async function opWavesProofSourcesAt(root) {
|
|
30
|
+
const { DEFAULT_SIGNERS_PATH } = await import("../workspace/trust/trust-files.js");
|
|
31
|
+
try {
|
|
32
|
+
const { readTrustPolicy } = await import("../workspace/trust/policy.js");
|
|
33
|
+
const { workingTreeSource } = await import("../workspace/record-source.js");
|
|
34
|
+
const policy = readTrustPolicy(workingTreeSource(root), null);
|
|
35
|
+
return { signersPath: policy.signersPath, signersNamed: policy.active && (policy.signers.length > 0 || (policy.passkeys?.length ?? 0) > 0) };
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return { signersPath: DEFAULT_SIGNERS_PATH, signersNamed: false };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
22
41
|
import { activeProductWords } from "../ci-product-words.js";
|
|
23
42
|
/**
|
|
24
43
|
* Load a lexicon's plugin (`@intentius/chant-lexicon-<name>`) to reach its
|
|
@@ -84,15 +103,17 @@ export async function generateOpsPipeline(ops, lexicon, options, cwd) {
|
|
|
84
103
|
error: `Unknown Op(s): ${unknown.map((s) => s.name).join(", ")}.${known ? ` Known Ops: ${known}` : " No Ops discovered."}`,
|
|
85
104
|
};
|
|
86
105
|
}
|
|
87
|
-
const { files, jobs } = plugin.generateOpPipeline(withOpSchedules(ops, discovered.ops), options);
|
|
88
|
-
return { success: true, files, jobs };
|
|
106
|
+
const { files, jobs, warnings } = plugin.generateOpPipeline(withOpSchedules(ops, discovered.ops), options);
|
|
107
|
+
return { success: true, files, jobs, ...(warnings && warnings.length > 0 ? { warnings } : {}) };
|
|
89
108
|
}
|
|
90
109
|
/**
|
|
91
110
|
* Render ordered waves of Op runs for `lexicon` (#3679, `./op-waves.ts`):
|
|
92
111
|
* check the spec, check that every Op it names exists, then hand it to the
|
|
93
112
|
* lexicon's `generateOpWavesPipeline`.
|
|
94
113
|
*/
|
|
95
|
-
export async function generateOpWavesPipeline(spec, lexicon, options, cwd
|
|
114
|
+
export async function generateOpWavesPipeline(spec, lexicon, options, cwd,
|
|
115
|
+
/** What can prove an approver (#5349). Default: read from the repository at `cwd`. */
|
|
116
|
+
proof) {
|
|
96
117
|
const plugin = await loadLexiconPlugin(lexicon);
|
|
97
118
|
if (!plugin?.generateOpWavesPipeline) {
|
|
98
119
|
return {
|
|
@@ -106,6 +127,12 @@ export async function generateOpWavesPipeline(spec, lexicon, options, cwd) {
|
|
|
106
127
|
catch (err) {
|
|
107
128
|
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
|
108
129
|
}
|
|
130
|
+
// #5349: rules no approver can meet (refused, #5379), and counts plain lines can meet.
|
|
131
|
+
const findings = opWavesQuorumFindings(spec, proof ?? (await opWavesProofSourcesAt(cwd ?? process.cwd())));
|
|
132
|
+
if (findings.refusals.length > 0)
|
|
133
|
+
return { success: false, error: findings.refusals.join("\n") };
|
|
134
|
+
// #5327: a canary wave with no soak checks holds nothing; existing config warns.
|
|
135
|
+
const warnings = [...findings.warnings, ...opWavesCanaryWarnings(spec)];
|
|
109
136
|
const discovered = await discoverOps({ cwd });
|
|
110
137
|
if (discovered.errors.length > 0)
|
|
111
138
|
return { success: false, error: discovered.errors.join("\n") };
|
|
@@ -122,7 +149,7 @@ export async function generateOpWavesPipeline(spec, lexicon, options, cwd) {
|
|
|
122
149
|
// #4617: the control dispatch speaks in the product's words too.
|
|
123
150
|
const words = options.words ?? (spec.control ? active : undefined);
|
|
124
151
|
const { files, jobs } = plugin.generateOpWavesPipeline(spec, { ...options, ...(bin ? { bin } : {}), ...(words ? { words } : {}) });
|
|
125
|
-
return { success: true, files, jobs };
|
|
152
|
+
return { success: true, files, jobs, ...(warnings.length > 0 ? { warnings } : {}) };
|
|
126
153
|
}
|
|
127
154
|
catch (err) {
|
|
128
155
|
return { success: false, error: err instanceof Error ? err.message : String(err) };
|
package/dist/op/index.d.ts
CHANGED
|
@@ -18,11 +18,12 @@ export { receiptActivities, receiptCheckInput } from "./receipt-store.js";
|
|
|
18
18
|
export type { ReceiptStore, EffectReceiptRef, ReceiptCheckInput, ReceiptActivities, ReceiptActivityOptions, ReceiptReadArgs, ReceiptReadResult, ReceiptWriteArgs, ReceiptStalenessArgs, ReceiptStalenessResult, ReceiptStaleFinding, } from "./receipt-store.js";
|
|
19
19
|
export { discoverOps } from "./discover.js";
|
|
20
20
|
export type { DiscoveredOp, OpDiscoveryResult } from "./discover.js";
|
|
21
|
-
export { generateOpsPipeline, generateOpWavesPipeline, withOpSchedules } from "./generate-pipeline.js";
|
|
21
|
+
export { generateOpsPipeline, generateOpWavesPipeline, opWavesProofSourcesAt, withOpSchedules } from "./generate-pipeline.js";
|
|
22
22
|
export type { GenerateOpsPipelineResult, GenerateOpWavesPipelineResult } from "./generate-pipeline.js";
|
|
23
|
-
export { OP_WAVE_APPLY_HOOKS_RUNNERS, OP_WAVE_DEFAULT_APPLY, OP_WAVE_DEFAULT_GATE_NAME, OP_WAVE_GATE_POLICIES, OP_WAVE_HOOK_MOMENTS, PR_LOOP_HOOK_MOMENTS, assertOpWaveHooks, assertOpWavesSpec, assertPrLoopHooks, opWaveApplyHooksRunBy, opWaveGateName, opWaveHookRuns, opWaveHooksAt, opWaveJobs, opWaveRecordPath, opWaveShare, } from "./op-waves.js";
|
|
23
|
+
export { OP_WAVE_APPLY_HOOKS_RUNNERS, OP_WAVE_DEFAULT_APPLY, OP_WAVE_DEFAULT_GATE_NAME, OP_WAVE_GATE_POLICIES, OP_WAVE_HOOK_MOMENTS, PR_LOOP_HOOK_MOMENTS, assertOpWaveHooks, assertOpWavesSpec, assertPrLoopHooks, opWaveApplyHooksRunBy, opWaveGateName, opWaveHookRuns, opWaveHooksAt, opWaveJobs, opWaveRecordPath, opWaveShare, opWavesCanaryWarnings, } from "./op-waves.js";
|
|
24
|
+
export { opWavesQuorumFindings, opWavesQuorumWarnings, opWavesUnprovableQuorum, PLAIN_APPROVAL_MODES, UNPROVABLE_QUORUM_REFUSED, UNPROVABLE_QUORUM_REFUSED_FLOOR, type OpWavesProofSources } from "./op-waves-quorum-warnings.js";
|
|
24
25
|
export type { OpWave, OpWaveApplyHooksRunner, OpWaveGatePolicy, OpWaveHook, OpWaveHookFailure, OpWaveHookMoment, OpWaveHooks, OpWaveJob, OpWaveRun, OpWavesApprovals, OpWavesDigest, OpWavesInvolved, OpWavesOverride, OpWavesSpec } from "./op-waves.js";
|
|
25
|
-
export { OP_WAVE_APPLY_OUTCOMES, OP_WAVE_MAX_REPLANS, opWaveHooksAtBase, runStageHooks, runStageHooksAsync, spawnExecAsync, opWaveNeedsApproval, opWavePlanPath, opWavePlansPath, OP_WAVE_PLAN_PATH_FLOOR, OP_WAVES_PREVIEW_FLOOR, opWaveRunsPath, opWaveReportDir, opWaveSetDigest, parseOpWavesSpec, recordOpWaveHeadPlans, readOpWaveHooksFile, readOpWavePolicy, runOpWave, runOpWaveApplyHooks, opWaveResourceLines, } from "./op-waves-run.js";
|
|
26
|
+
export { OP_WAVE_APPLY_OUTCOMES, OP_WAVE_MAX_REPLANS, opWaveHooksAtBase, runStageHooks, runStageHooksAsync, spawnExecAsync, opWaveNeedsApproval, opWavePlanPath, opWavePlansPath, OP_WAVE_PLAN_PATH_FLOOR, OP_WAVES_PREVIEW_FLOOR, PROVEN_APPROVERS_FLOOR, opWaveRunsPath, opWaveReportDir, opWaveSetDigest, parseOpWavesSpec, recordOpWaveHeadPlans, readOpWaveHooksFile, readOpWavePolicy, runOpWave, runOpWaveApplyHooks, opWaveResourceLines, } from "./op-waves-run.js";
|
|
26
27
|
export { movedSincePreview, shortAddress, type PlannedRunDigests } from "./op-waves-preview.js";
|
|
27
28
|
export type { OpWaveBaseRules, OpWaveDecision, OpWaveApplyHooksRun, OpWaveApplyOutcome, OpWaveAsyncExec, OpWaveExec, OpWaveHeldOn, OpWaveHoldRequest, OpWaveHookOutcome, OpWaveHookRun, OpWaveInProcessHook, OpWaveInProcessHookCall, OpWaveHandedFinished, OpWaveHooksFile, OpWaveHooksResult, OpWaveMember, OpWavePlanFile, OpWavePlansFile, OpWavePolicySource, OpWaveRunsFile, OpWaveShowAtBase, RecordHeadPlansOptions, RunOpWaveApplyHooksOptions, RunStageHooksAsyncOptions, RunStageHooksOptions, StageHooksRun, RunOpWaveOptions, RunOpWaveResult, } from "./op-waves-run.js";
|
|
28
29
|
export { OP_WAVE_COST_FORMATS, OP_WAVE_COST_MEMBER, OP_WAVE_PARALLEL_STEP_FLOOR, OP_WAVE_STEP_WAVE_FLOOR, OP_WAVE_TOGETHER_MEMBER, opWaveCostVerdict, opWaveDiscoverInput, opWaveHoldsAt, opWaveHoldsProblems, opWaveStepInput, opWaveStepProblems, readCostEstimate, } from "./op-waves-capability.js";
|
|
@@ -63,10 +64,14 @@ export type { GateLedgerPort, GateCheck, GateCheckInput, PendingGatePush, GateDi
|
|
|
63
64
|
export { tallyGateApprovals, humanQuorumSince, approverOf } from "./gate.js";
|
|
64
65
|
export { planGateResumes, standingGateFacts } from "./gate-resume-plan.js";
|
|
65
66
|
export type { GateResumeCandidate, GateResumeReason, GateAnswering, PlanGateResumesInput } from "./gate-resume-plan.js";
|
|
66
|
-
export { gateApprovalProblems, gateContextDigest, gatePolicyRequest, gatePolicyVersion, isGatePolicyRef, loadGatePolicyEvaluator, GATE_APPROVAL_MODES, } from "./gate-approval.js";
|
|
67
|
+
export { gateApprovalProblems, gateContextDigest, gatePolicyRequest, gatePolicyVersion, isGatePolicyRef, loadGatePolicyEvaluator, GATE_APPROVAL_MODES, AGENT_PASSES_ALONE_KEY, } from "./gate-approval.js";
|
|
68
|
+
export { AGENT_PASSES_ALONE_FLOOR, agentPermitBuildFindings, opGatesWithApproval, stageGateNames } from "./agent-permit.js";
|
|
69
|
+
export type { AgentPermitFindings, AgentPermitGateEntry, AgentPermitOpGate } from "./agent-permit.js";
|
|
67
70
|
export type { GateApproval, GateApprovalMode, GateApprover, GateContextValue, GatePolicyAnswer, GatePolicyDecision, GatePolicyEvaluator, GatePolicyRef, GatePolicyRequest, GateQuorum, ResolvedGateApproval, } from "./gate-approval.js";
|
|
68
|
-
export { quorumRules, quorumRulesFor, quorumNeed, quorumProblems, quorumRuleProgress, quorumRuleLine, quorumWaiting, rolesOf, trustQuorumJudge, UNPROVEN_JUDGE, changeInvolvement, involvedWhy, principalNames, recordedReviewApprovals, recordedReviewOf, requestedByTrailers, } from "./gate-quorum.js";
|
|
69
|
-
export type { GateQuorumRule, GateQuorumSpec, GateQuorumJudge, GateQuorumRuleProgress, QuorumJudgement, QuorumApprover, TrustQuorumInput, QuorumInvolvement, RecordedReview, } from "./gate-quorum.js";
|
|
71
|
+
export { quorumRules, quorumRulesFor, quorumNeed, quorumProblems, quorumRuleProgress, quorumRuleLine, quorumWaiting, rolesOf, trustQuorumJudge, UNPROVEN_JUDGE, changeInvolvement, involvedWhy, principalNames, recordedReviewApprovals, recordedReviewOf, requestedByTrailers, quorumNodes, quorumTreeProgress, quorumGroupLine, quorumGroupLines, quorumRuleSites, ruleAdmits, isQuorumAll, isQuorumAny, isQuorumGroup, QUORUM_MAX_DEPTH, } from "./gate-quorum.js";
|
|
72
|
+
export type { GateQuorumRule, GateQuorumSpec, GateQuorumJudge, GateQuorumRuleProgress, QuorumJudgement, QuorumApprover, TrustQuorumInput, QuorumInvolvement, RecordedReview, GateQuorumAll, GateQuorumAny, GateQuorumNode, GateQuorumGroupProgress, GateQuorumTreeProgress, } from "./gate-quorum.js";
|
|
73
|
+
export { GATE_REJECTION_FLOOR, gateRejections, rejectionRefusal, rejectionLine, rejectsDigest, type GateRejectionInput, type GateRejections } from "./gate-reject.js";
|
|
74
|
+
export { GATE_REJECTION_NAMESPACE, gateRejectionPath, gateRejectionPayload, parseGateRejections, rejectionReasonProblem, rejectionSealRefusal, type GateRejectionRecord, type SealedGateRejection } from "../lifecycle/gate-rejection.js";
|
|
70
75
|
export { gatePlanSummary, gatePlanSummaryOfResult, changeSetOfResult, GATE_PLAN_CONTEXT_KEY, GATE_PLAN_ADDRESS_LIMIT, } from "./gate-plan-context.js";
|
|
71
76
|
export type { GatePlanSummary } from "./gate-plan-context.js";
|
|
72
77
|
export { computePlanDigest, isPlanDigest, describePlanDigest, samePlanDigest, PLAN_DIGEST_ALGORITHM, PLAN_DIGEST_PREFIX, } from "../lifecycle/plan-digest.js";
|
package/dist/op/index.js
CHANGED
|
@@ -10,9 +10,10 @@ export { WatchOp, ReconcileOp, ApplyOp, ConvergeOp, WorkflowAuditOp, PipelineAud
|
|
|
10
10
|
export { parseResourceObservation, CONVERGE_RESOURCE_ENV } from "../lifecycle/symptoms.js";
|
|
11
11
|
export { receiptActivities, receiptCheckInput } from "./receipt-store.js";
|
|
12
12
|
export { discoverOps } from "./discover.js";
|
|
13
|
-
export { generateOpsPipeline, generateOpWavesPipeline, withOpSchedules } from "./generate-pipeline.js";
|
|
14
|
-
export { OP_WAVE_APPLY_HOOKS_RUNNERS, OP_WAVE_DEFAULT_APPLY, OP_WAVE_DEFAULT_GATE_NAME, OP_WAVE_GATE_POLICIES, OP_WAVE_HOOK_MOMENTS, PR_LOOP_HOOK_MOMENTS, assertOpWaveHooks, assertOpWavesSpec, assertPrLoopHooks, opWaveApplyHooksRunBy, opWaveGateName, opWaveHookRuns, opWaveHooksAt, opWaveJobs, opWaveRecordPath, opWaveShare, } from "./op-waves.js";
|
|
15
|
-
export {
|
|
13
|
+
export { generateOpsPipeline, generateOpWavesPipeline, opWavesProofSourcesAt, withOpSchedules } from "./generate-pipeline.js";
|
|
14
|
+
export { OP_WAVE_APPLY_HOOKS_RUNNERS, OP_WAVE_DEFAULT_APPLY, OP_WAVE_DEFAULT_GATE_NAME, OP_WAVE_GATE_POLICIES, OP_WAVE_HOOK_MOMENTS, PR_LOOP_HOOK_MOMENTS, assertOpWaveHooks, assertOpWavesSpec, assertPrLoopHooks, opWaveApplyHooksRunBy, opWaveGateName, opWaveHookRuns, opWaveHooksAt, opWaveJobs, opWaveRecordPath, opWaveShare, opWavesCanaryWarnings, } from "./op-waves.js";
|
|
15
|
+
export { opWavesQuorumFindings, opWavesQuorumWarnings, opWavesUnprovableQuorum, PLAIN_APPROVAL_MODES, UNPROVABLE_QUORUM_REFUSED, UNPROVABLE_QUORUM_REFUSED_FLOOR } from "./op-waves-quorum-warnings.js";
|
|
16
|
+
export { OP_WAVE_APPLY_OUTCOMES, OP_WAVE_MAX_REPLANS, opWaveHooksAtBase, runStageHooks, runStageHooksAsync, spawnExecAsync, opWaveNeedsApproval, opWavePlanPath, opWavePlansPath, OP_WAVE_PLAN_PATH_FLOOR, OP_WAVES_PREVIEW_FLOOR, PROVEN_APPROVERS_FLOOR, opWaveRunsPath, opWaveReportDir, opWaveSetDigest, parseOpWavesSpec, recordOpWaveHeadPlans, readOpWaveHooksFile, readOpWavePolicy, runOpWave, runOpWaveApplyHooks, opWaveResourceLines, } from "./op-waves-run.js";
|
|
16
17
|
export { movedSincePreview, shortAddress } from "./op-waves-preview.js";
|
|
17
18
|
export { OP_WAVE_COST_FORMATS, OP_WAVE_COST_MEMBER, OP_WAVE_PARALLEL_STEP_FLOOR, OP_WAVE_STEP_WAVE_FLOOR, OP_WAVE_TOGETHER_MEMBER, opWaveCostVerdict, opWaveDiscoverInput, opWaveHoldsAt, opWaveHoldsProblems, opWaveStepInput, opWaveStepProblems, readCostEstimate, } from "./op-waves-capability.js";
|
|
18
19
|
export { notifyOpWave, opWaveNotifyFields } from "./op-waves-notify.js";
|
|
@@ -34,8 +35,12 @@ export { currentOpRun, withOpRunContext } from "./run-context.js";
|
|
|
34
35
|
export { evaluateGate, gitGateLedgerPort, memoryGateLedgerPort, approveCommand, describeGateMismatch, gateIsSealed, opWaveGateReportPath } from "./gate.js";
|
|
35
36
|
export { tallyGateApprovals, humanQuorumSince, approverOf } from "./gate.js";
|
|
36
37
|
export { planGateResumes, standingGateFacts } from "./gate-resume-plan.js";
|
|
37
|
-
export { gateApprovalProblems, gateContextDigest, gatePolicyRequest, gatePolicyVersion, isGatePolicyRef, loadGatePolicyEvaluator, GATE_APPROVAL_MODES, } from "./gate-approval.js";
|
|
38
|
-
export {
|
|
38
|
+
export { gateApprovalProblems, gateContextDigest, gatePolicyRequest, gatePolicyVersion, isGatePolicyRef, loadGatePolicyEvaluator, GATE_APPROVAL_MODES, AGENT_PASSES_ALONE_KEY, } from "./gate-approval.js";
|
|
39
|
+
export { AGENT_PASSES_ALONE_FLOOR, agentPermitBuildFindings, opGatesWithApproval, stageGateNames } from "./agent-permit.js";
|
|
40
|
+
export { quorumRules, quorumRulesFor, quorumNeed, quorumProblems, quorumRuleProgress, quorumRuleLine, quorumWaiting, rolesOf, trustQuorumJudge, UNPROVEN_JUDGE, changeInvolvement, involvedWhy, principalNames, recordedReviewApprovals, recordedReviewOf, requestedByTrailers, quorumNodes, quorumTreeProgress, quorumGroupLine, quorumGroupLines, quorumRuleSites, ruleAdmits, isQuorumAll, isQuorumAny, isQuorumGroup, QUORUM_MAX_DEPTH, } from "./gate-quorum.js";
|
|
41
|
+
// #5354: rejecting the digest a gate waits on.
|
|
42
|
+
export { GATE_REJECTION_FLOOR, gateRejections, rejectionRefusal, rejectionLine, rejectsDigest } from "./gate-reject.js";
|
|
43
|
+
export { GATE_REJECTION_NAMESPACE, gateRejectionPath, gateRejectionPayload, parseGateRejections, rejectionReasonProblem, rejectionSealRefusal } from "../lifecycle/gate-rejection.js";
|
|
39
44
|
export { gatePlanSummary, gatePlanSummaryOfResult, changeSetOfResult, GATE_PLAN_CONTEXT_KEY, GATE_PLAN_ADDRESS_LIMIT, } from "./gate-plan-context.js";
|
|
40
45
|
export { computePlanDigest, isPlanDigest, describePlanDigest, samePlanDigest, PLAN_DIGEST_ALGORITHM, PLAN_DIGEST_PREFIX, } from "../lifecycle/plan-digest.js";
|
|
41
46
|
export { gateName, usesDeprecatedGateKey, DEPRECATED_GATE_KEY_WARNING } from "./gate-name.js";
|
|
@@ -257,6 +257,8 @@ export declare function findPolicyGateStep(config: OpConfig): ActivityStep | und
|
|
|
257
257
|
* key the entry declares, but a key only the Op declares (often a step output
|
|
258
258
|
* the run computes) still reaches the policy. A field the entry leaves out
|
|
259
259
|
* still comes from the Op, and `chant workspace check` (WSP153) reports it.
|
|
260
|
+
*
|
|
261
|
+
* #5388: `agentPassesAlone` comes from the entry alone, never from the Op.
|
|
260
262
|
*/
|
|
261
263
|
export declare function resolveGateApproval(step: GateStep, resultsById: ReadonlyMap<string, unknown>, env?: string, atBase?: GateQuorumSpec | null, baseApproval?: GateBaseApproval | null): ResolvedGateApproval | undefined;
|
|
262
264
|
/** How a run reaches the gate ledger, and what it calls itself there (#2119). */
|
|
@@ -39,7 +39,8 @@ import { resolveGateAliases } from "./gate-alias.js";
|
|
|
39
39
|
import { gatePointOf } from "./gate-point.js";
|
|
40
40
|
import { evaluatePointGate, workspaceGatePointAsker } from "./gate-point-run.js";
|
|
41
41
|
import { quorumRules, quorumRulesFor } from "./gate-quorum.js";
|
|
42
|
-
import { GATE_PLAN_CONTEXT_KEY, gatePlanSummaryOfResult } from "./gate-plan-context.js";
|
|
42
|
+
import { changeSetOfResult, GATE_PLAN_CONTEXT_KEY, gatePlanSummaryOfResult } from "./gate-plan-context.js";
|
|
43
|
+
import { CHANGE_RISK_CONTEXT_KEY, changeRiskContext, changeRiskQuorum, scoreChangeRisk } from "../change-risk.js";
|
|
43
44
|
import { withOpRunContext } from "./run-context.js";
|
|
44
45
|
import { isPointWait } from "./steward-points.js";
|
|
45
46
|
import { isGateWait } from "./gate-wait.js";
|
|
@@ -510,6 +511,8 @@ function gateFn(step) {
|
|
|
510
511
|
* key the entry declares, but a key only the Op declares (often a step output
|
|
511
512
|
* the run computes) still reaches the policy. A field the entry leaves out
|
|
512
513
|
* still comes from the Op, and `chant workspace check` (WSP153) reports it.
|
|
514
|
+
*
|
|
515
|
+
* #5388: `agentPassesAlone` comes from the entry alone, never from the Op.
|
|
513
516
|
*/
|
|
514
517
|
export function resolveGateApproval(step, resultsById, env, atBase, baseApproval) {
|
|
515
518
|
const baseQuorum = atBase ?? undefined;
|
|
@@ -546,16 +549,32 @@ export function resolveGateApproval(step, resultsById, env, atBase, baseApproval
|
|
|
546
549
|
if (summary)
|
|
547
550
|
context = { ...(context ?? {}), [GATE_PLAN_CONTEXT_KEY]: summary };
|
|
548
551
|
}
|
|
552
|
+
// #5325: with approval.risk, the plan's change set is scored and the record
|
|
553
|
+
// goes under context.changeRisk; over its threshold the gate takes the
|
|
554
|
+
// risk's rules on top of its own. It only ever adds an approval.
|
|
555
|
+
let riskRules = [];
|
|
556
|
+
if (authored.risk && isStepOutputRef(step.plan)) {
|
|
557
|
+
const changeSet = changeSetOfResult(resultsById.get(step.plan.step));
|
|
558
|
+
if (changeSet) {
|
|
559
|
+
const risk = scoreChangeRisk({ changeSet, ...(env !== undefined ? { environments: [env] } : {}) }, authored.risk);
|
|
560
|
+
context = { ...(context ?? {}), [CHANGE_RISK_CONTEXT_KEY]: changeRiskContext(risk) };
|
|
561
|
+
riskRules = changeRiskQuorum(risk, authored.risk);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
549
564
|
// #4290: the rules this run's gate takes, by its environment. A rule with
|
|
550
565
|
// `targets` never covers a run with no environment. One rule with no
|
|
551
566
|
// `targets` keeps its own shape, so a standing pending fact still matches.
|
|
552
|
-
const single = quorum !== undefined && !Array.isArray(quorum) && quorum.targets === undefined;
|
|
553
|
-
const rules = quorum ?
|
|
567
|
+
const single = riskRules.length === 0 && quorum !== undefined && !Array.isArray(quorum) && quorum.targets === undefined;
|
|
568
|
+
const rules = [...(quorum ? quorumRules(quorum) : []), ...riskRules];
|
|
569
|
+
const taken = rules.length > 0 ? quorumRulesFor(rules, env !== undefined ? [env] : []) : [];
|
|
554
570
|
return {
|
|
555
|
-
...(single ? { quorum } :
|
|
571
|
+
...(single ? { quorum } : taken.length > 0 ? { quorum: taken } : {}),
|
|
556
572
|
...(authored.policy ? { policy: authored.policy } : {}),
|
|
557
573
|
mode: authored.mode ?? "log-only",
|
|
558
574
|
...(context ? { context } : {}),
|
|
575
|
+
...(authored.risk ? { risk: authored.risk } : {}),
|
|
576
|
+
// #5388: only the entry at base lets an agent's permit pass the gate alone.
|
|
577
|
+
...(baseApproval?.agentPassesAlone === true ? { agentPassesAlone: true } : {}),
|
|
559
578
|
};
|
|
560
579
|
}
|
|
561
580
|
/**
|