@intentius/chant 0.124.40 → 0.124.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__fixtures__/oidc-emulator.d.ts +49 -0
- package/dist/__fixtures__/oidc-emulator.d.ts.map +1 -0
- package/dist/__fixtures__/oidc-emulator.js +89 -0
- package/dist/ci-handover.d.ts +117 -0
- package/dist/ci-handover.d.ts.map +1 -0
- package/dist/ci-handover.js +217 -0
- package/dist/ci-identity.d.ts +190 -0
- package/dist/ci-identity.d.ts.map +1 -0
- package/dist/ci-identity.js +219 -0
- package/dist/cli/handlers/approve.d.ts +2 -1
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +20 -6
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +18 -1
- package/dist/cli/handlers/fan-out.d.ts.map +1 -1
- package/dist/cli/handlers/fan-out.js +42 -5
- package/dist/cli/handlers/gate-resume.d.ts +3 -0
- package/dist/cli/handlers/gate-resume.d.ts.map +1 -1
- package/dist/cli/handlers/gate-resume.js +15 -2
- package/dist/cli/handlers/lock.d.ts +8 -0
- package/dist/cli/handlers/lock.d.ts.map +1 -0
- package/dist/cli/handlers/lock.js +197 -0
- package/dist/cli/handlers/pr-env.d.ts +34 -0
- package/dist/cli/handlers/pr-env.d.ts.map +1 -0
- package/dist/cli/handlers/pr-env.js +436 -0
- package/dist/cli/handlers/pr.d.ts +76 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +615 -55
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +9 -0
- package/dist/cli/handlers/query.d.ts +6 -0
- package/dist/cli/handlers/query.d.ts.map +1 -0
- package/dist/cli/handlers/query.js +80 -0
- package/dist/cli/handlers/run.d.ts.map +1 -1
- package/dist/cli/handlers/run.js +11 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +49 -4
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +46 -2
- package/dist/cli/registry.d.ts +31 -2
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/capability.d.ts +47 -0
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/components/capability.js +44 -0
- package/dist/components/cli-support.d.ts +6 -0
- package/dist/components/cli-support.d.ts.map +1 -1
- package/dist/components/cli-support.js +8 -1
- package/dist/components/driver.d.ts +10 -0
- package/dist/components/driver.d.ts.map +1 -1
- package/dist/components/driver.js +52 -2
- package/dist/components/fan-out-run.d.ts +37 -0
- package/dist/components/fan-out-run.d.ts.map +1 -1
- package/dist/components/fan-out-run.js +44 -4
- package/dist/components/gate-plan.d.ts +2 -0
- package/dist/components/gate-plan.d.ts.map +1 -1
- package/dist/components/gate-plan.js +1 -0
- package/dist/components/pr-environment.d.ts +298 -0
- package/dist/components/pr-environment.d.ts.map +1 -0
- package/dist/components/pr-environment.js +406 -0
- package/dist/components/pr-hooks.d.ts +66 -0
- package/dist/components/pr-hooks.d.ts.map +1 -0
- package/dist/components/pr-hooks.js +119 -0
- package/dist/components/pr-pipeline.d.ts +92 -2
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +150 -21
- package/dist/components/pr-policy.d.ts +109 -0
- package/dist/components/pr-policy.d.ts.map +1 -0
- package/dist/components/pr-policy.js +150 -0
- package/dist/components/pr-run.d.ts +6 -0
- package/dist/components/pr-run.d.ts.map +1 -1
- package/dist/components/pr-run.js +8 -3
- package/dist/components/wave-plan.d.ts +14 -1
- package/dist/components/wave-plan.d.ts.map +1 -1
- package/dist/components/wave-plan.js +34 -2
- package/dist/gate-decision.d.ts +15 -2
- package/dist/gate-decision.d.ts.map +1 -1
- package/dist/gate-decision.js +17 -2
- package/dist/gate-policy.d.ts +140 -0
- package/dist/gate-policy.d.ts.map +1 -0
- package/dist/gate-policy.js +242 -0
- package/dist/lifecycle/gate-checkpoint.d.ts +1 -1
- package/dist/lifecycle/gate-checkpoint.js +1 -1
- package/dist/{workspace/trust → lifecycle}/gate-seal.d.ts +1 -1
- package/dist/lifecycle/gate-seal.d.ts.map +1 -0
- package/dist/lifecycle/query.d.ts +68 -0
- package/dist/lifecycle/query.d.ts.map +1 -0
- package/dist/lifecycle/query.js +246 -0
- package/dist/lifecycle/run-ledger.d.ts +13 -0
- package/dist/lifecycle/run-ledger.d.ts.map +1 -1
- package/dist/lifecycle/run-ledger.js +16 -0
- package/dist/lifecycle/target-lock.d.ts +97 -0
- package/dist/lifecycle/target-lock.d.ts.map +1 -0
- package/dist/lifecycle/target-lock.js +286 -0
- package/dist/op/activities/activity-contracts.d.ts +30 -0
- package/dist/op/activities/activity-contracts.d.ts.map +1 -1
- package/dist/op/activities/activity-contracts.js +26 -0
- package/dist/op/activities/index.d.ts +2 -0
- package/dist/op/activities/index.d.ts.map +1 -1
- package/dist/op/activities/index.js +4 -0
- package/dist/op/activities/pr-refs.d.ts +10 -0
- package/dist/op/activities/pr-refs.d.ts.map +1 -0
- package/dist/op/activities/pr-refs.js +26 -0
- package/dist/op/activities/predict-behaviour.d.ts +2 -4
- package/dist/op/activities/predict-behaviour.d.ts.map +1 -1
- package/dist/op/activities/predict-behaviour.js +2 -21
- package/dist/op/activities/review-agent.d.ts +137 -0
- package/dist/op/activities/review-agent.d.ts.map +1 -0
- package/dist/op/activities/review-agent.js +266 -0
- package/dist/op/builders.d.ts +9 -0
- package/dist/op/builders.d.ts.map +1 -1
- package/dist/op/builders.js +11 -0
- package/dist/op/cron.d.ts +8 -0
- package/dist/op/cron.d.ts.map +1 -1
- package/dist/op/cron.js +51 -0
- package/dist/op/gate-approval.d.ts +20 -13
- package/dist/op/gate-approval.d.ts.map +1 -1
- package/dist/op/gate-approval.js +13 -18
- package/dist/op/gate-quorum.d.ts +131 -0
- package/dist/op/gate-quorum.d.ts.map +1 -0
- package/dist/op/gate-quorum.js +183 -0
- package/dist/op/gate-resume.d.ts +4 -2
- package/dist/op/gate-resume.d.ts.map +1 -1
- package/dist/op/gate-resume.js +5 -4
- package/dist/op/gate-review.js +1 -1
- package/dist/op/gate.d.ts +32 -4
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +40 -24
- package/dist/op/index.d.ts +6 -4
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +4 -3
- package/dist/op/local-executor.d.ts.map +1 -1
- package/dist/op/local-executor.js +9 -3
- package/dist/op/op-waves-run.d.ts +28 -43
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +170 -120
- package/dist/op/op-waves.d.ts +55 -3
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +63 -8
- package/dist/op/schedule-overdue.d.ts +57 -0
- package/dist/op/schedule-overdue.d.ts.map +1 -0
- package/dist/op/schedule-overdue.js +138 -0
- package/dist/op/stage-hooks.d.ts +132 -0
- package/dist/op/stage-hooks.d.ts.map +1 -0
- package/dist/op/stage-hooks.js +142 -0
- package/dist/override-gate.d.ts +2 -2
- package/dist/override-gate.d.ts.map +1 -1
- package/dist/override-gate.js +1 -1
- package/dist/pr-forge.d.ts +64 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +331 -44
- package/dist/pr-loop.d.ts +107 -1
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +84 -3
- package/dist/pr-post.d.ts +72 -0
- package/dist/pr-post.d.ts.map +1 -0
- package/dist/pr-post.js +134 -0
- package/dist/pr-requires.d.ts +38 -0
- package/dist/pr-requires.d.ts.map +1 -0
- package/dist/pr-requires.js +48 -0
- package/dist/wave-blocked.d.ts +79 -0
- package/dist/wave-blocked.d.ts.map +1 -0
- package/dist/wave-blocked.js +245 -0
- package/dist/wave-engine.d.ts +6 -0
- package/dist/wave-engine.d.ts.map +1 -1
- package/dist/wave-engine.js +2 -0
- package/dist/wave-runtime.mjs +243 -243
- package/dist/workspace/__fixtures__/two-member-workspace.d.ts +1 -0
- package/dist/workspace/__fixtures__/two-member-workspace.d.ts.map +1 -1
- package/dist/workspace/__fixtures__/two-member-workspace.js +1 -1
- package/dist/workspace/checks/ci-workflow.d.ts.map +1 -1
- package/dist/workspace/checks/ci-workflow.js +19 -4
- package/dist/workspace/ci-branches.d.ts +51 -0
- package/dist/workspace/ci-branches.d.ts.map +1 -0
- package/dist/workspace/ci-branches.js +69 -0
- package/dist/workspace/ci-cloud-identity.d.ts +11 -0
- package/dist/workspace/ci-cloud-identity.d.ts.map +1 -0
- package/dist/workspace/ci-cloud-identity.js +24 -0
- package/dist/workspace/ci-init.d.ts.map +1 -1
- package/dist/workspace/ci-init.js +5 -4
- package/dist/workspace/ci-locks.d.ts +12 -0
- package/dist/workspace/ci-locks.d.ts.map +1 -0
- package/dist/workspace/ci-locks.js +6 -0
- package/dist/workspace/ci-run.d.ts +17 -1
- package/dist/workspace/ci-run.d.ts.map +1 -1
- package/dist/workspace/ci-run.js +66 -4
- package/dist/workspace/ci-workflow-at.d.ts +14 -0
- package/dist/workspace/ci-workflow-at.d.ts.map +1 -0
- package/dist/workspace/ci-workflow-at.js +17 -0
- package/dist/workspace/ci-workflow.d.ts +11 -3
- package/dist/workspace/ci-workflow.d.ts.map +1 -1
- package/dist/workspace/ci-workflow.js +10 -2
- package/dist/workspace/declaration.d.ts +69 -3
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +72 -1
- package/dist/workspace/declaration.schema.json +149 -2
- package/dist/workspace/identity-gate-rule.d.ts +1 -1
- package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
- package/dist/workspace/identity-gate-rule.js +1 -1
- package/dist/workspace/identity.d.ts +1 -1
- package/dist/workspace/identity.d.ts.map +1 -1
- package/dist/workspace/lineage-upgrade.d.ts.map +1 -1
- package/dist/workspace/lineage-upgrade.js +8 -5
- package/dist/workspace/member-pipeline.d.ts +6 -0
- package/dist/workspace/member-pipeline.d.ts.map +1 -1
- package/dist/workspace/member-pipeline.js +23 -0
- package/dist/workspace/pr-report.schema.json +94 -3
- package/dist/workspace/reason-codes.d.ts +1 -1
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/reason-codes.js +1 -1
- package/dist/workspace/security.d.ts.map +1 -1
- package/dist/workspace/security.js +4 -0
- package/dist/workspace/status-gates.d.ts +3 -2
- package/dist/workspace/status-gates.d.ts.map +1 -1
- package/dist/workspace/status-gates.js +8 -7
- package/dist/workspace/status.d.ts.map +1 -1
- package/dist/workspace/status.js +4 -1
- package/dist/workspace/trust/seal.d.ts +2 -2
- package/dist/workspace/trust/seal.d.ts.map +1 -1
- package/dist/workspace/trust/seal.js +2 -2
- package/package.json +1 -1
- package/src/__fixtures__/oidc-emulator.ts +118 -0
- package/src/ci-handover.test.ts +209 -0
- package/src/ci-handover.ts +237 -0
- package/src/ci-identity.test.ts +201 -0
- package/src/ci-identity.ts +310 -0
- package/src/cli/handlers/approve.ts +18 -5
- package/src/cli/handlers/build.ts +18 -1
- package/src/cli/handlers/fan-out.ts +43 -6
- package/src/cli/handlers/gate-resume.ts +16 -2
- package/src/cli/handlers/lock.test.ts +98 -0
- package/src/cli/handlers/lock.ts +202 -0
- package/src/cli/handlers/operator.test.ts +3 -1
- package/src/cli/handlers/pr-before-merge.test.ts +276 -0
- package/src/cli/handlers/pr-env.ts +462 -0
- package/src/cli/handlers/pr-waves-blocked.test.ts +247 -0
- package/src/cli/handlers/pr.test.ts +184 -0
- package/src/cli/handlers/pr.ts +605 -61
- package/src/cli/handlers/promote.ts +9 -0
- package/src/cli/handlers/query.ts +78 -0
- package/src/cli/handlers/run.ts +10 -0
- package/src/cli/main.ts +49 -4
- package/src/cli/parse-args.ts +34 -2
- package/src/cli/registry.ts +31 -2
- package/src/components/capability-targets.test.ts +162 -0
- package/src/components/capability.ts +71 -0
- package/src/components/cli-support.ts +14 -1
- package/src/components/driver.ts +54 -3
- package/src/components/fan-out-run.ts +58 -3
- package/src/components/fan-out-waves.test.ts +45 -1
- package/src/components/gate-plan.ts +3 -0
- package/src/components/pr-environment.test.ts +249 -0
- package/src/components/pr-environment.ts +538 -0
- package/src/components/pr-hooks.test.ts +118 -0
- package/src/components/pr-hooks.ts +157 -0
- package/src/components/pr-pipeline.ts +194 -21
- package/src/components/pr-policy.test.ts +145 -0
- package/src/components/pr-policy.ts +211 -0
- package/src/components/pr-run.ts +14 -2
- package/src/components/wave-plan.ts +38 -3
- package/src/gate-decision-bundle.test.ts +4 -3
- package/src/gate-decision.ts +39 -2
- package/src/gate-policy-bundle.test.ts +28 -0
- package/src/gate-policy.test.ts +162 -0
- package/src/gate-policy.ts +298 -0
- package/src/lifecycle/gate-checkpoint.ts +1 -1
- package/src/{workspace/trust → lifecycle}/gate-seal.ts +1 -1
- package/src/lifecycle/query.test.ts +91 -0
- package/src/lifecycle/query.ts +315 -0
- package/src/lifecycle/run-ledger.ts +18 -0
- package/src/lifecycle/target-lock.test.ts +195 -0
- package/src/lifecycle/target-lock.ts +347 -0
- package/src/op/activities/activity-contracts.ts +31 -0
- package/src/op/activities/index.ts +6 -0
- package/src/op/activities/pr-refs.ts +28 -0
- package/src/op/activities/predict-behaviour.ts +3 -23
- package/src/op/activities/review-agent.test.ts +240 -0
- package/src/op/activities/review-agent.ts +355 -0
- package/src/op/builders.ts +13 -0
- package/src/op/cron.ts +44 -0
- package/src/op/gate-alias.test.ts +2 -2
- package/src/op/gate-approval.test.ts +30 -9
- package/src/op/gate-approval.ts +23 -26
- package/src/op/gate-quorum.test.ts +139 -0
- package/src/op/gate-quorum.ts +248 -0
- package/src/op/gate-resume.ts +6 -3
- package/src/op/gate-review.ts +1 -1
- package/src/op/gate.ts +64 -23
- package/src/op/index.ts +13 -1
- package/src/op/local-executor.ts +9 -2
- package/src/op/op-waves-hook-targets.test.ts +126 -0
- package/src/op/op-waves-policy-hold.test.ts +66 -0
- package/src/op/op-waves-quorum.test.ts +101 -0
- package/src/op/op-waves-run.ts +197 -183
- package/src/op/op-waves.ts +83 -10
- package/src/op/schedule-overdue.test.ts +220 -0
- package/src/op/schedule-overdue.ts +161 -0
- package/src/op/stage-hooks.ts +251 -0
- package/src/override-gate-bundle.test.ts +1 -1
- package/src/override-gate.ts +2 -2
- package/src/pr-forge-bundle.test.ts +2 -2
- package/src/pr-forge.test.ts +33 -0
- package/src/pr-forge.ts +347 -35
- package/src/pr-loop-bundle.test.ts +2 -2
- package/src/pr-loop.test.ts +58 -0
- package/src/pr-loop.ts +170 -4
- package/src/pr-post.test.ts +141 -0
- package/src/pr-post.ts +159 -0
- package/src/pr-requires.test.ts +184 -0
- package/src/pr-requires.ts +79 -0
- package/src/review-agent-bundle.test.ts +35 -0
- package/src/stage-hooks-bundle.test.ts +38 -0
- package/src/wave-blocked-bundle.test.ts +25 -0
- package/src/wave-blocked.test.ts +146 -0
- package/src/wave-blocked.ts +271 -0
- package/src/wave-engine.ts +8 -0
- package/src/workspace/__fixtures__/two-member-workspace.ts +2 -2
- package/src/workspace/checks/ci-workflow.test.ts +9 -0
- package/src/workspace/checks/ci-workflow.ts +18 -4
- package/src/workspace/ci-branches.test.ts +62 -0
- package/src/workspace/ci-branches.ts +79 -0
- package/src/workspace/ci-cloud-identity.test.ts +53 -0
- package/src/workspace/ci-cloud-identity.ts +23 -0
- package/src/workspace/ci-init.ts +5 -4
- package/src/workspace/ci-locks.ts +16 -0
- package/src/workspace/ci-run-index.test.ts +2 -1
- package/src/workspace/ci-run.test.ts +107 -8
- package/src/workspace/ci-run.ts +74 -5
- package/src/workspace/ci-workflow-at.ts +23 -0
- package/src/workspace/ci-workflow.ts +13 -2
- package/src/workspace/declaration.schema.json +149 -2
- package/src/workspace/declaration.test.ts +76 -0
- package/src/workspace/declaration.ts +140 -5
- package/src/workspace/identity-gate-rule.ts +1 -1
- package/src/workspace/identity.ts +1 -1
- package/src/workspace/lineage-upgrade.ts +11 -8
- package/src/workspace/member-pipeline.test.ts +29 -0
- package/src/workspace/member-pipeline.ts +30 -0
- package/src/workspace/pr-report.schema.json +94 -3
- package/src/workspace/reason-codes.ts +1 -1
- package/src/workspace/security.ts +4 -0
- package/src/workspace/status-gates.ts +9 -6
- package/src/workspace/status.ts +4 -1
- package/src/workspace/trust/gate-seal.test.ts +1 -1
- package/src/workspace/trust/seal.ts +2 -2
- package/dist/workspace/trust/gate-seal.d.ts.map +0 -1
- /package/dist/{workspace/trust → lifecycle}/gate-seal.js +0 -0
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* more than that, as data that survives into the build output:
|
|
6
6
|
*
|
|
7
7
|
* - `quorum`: how many distinct human approvers the gate needs, and
|
|
8
|
-
* optionally which roles count toward it.
|
|
8
|
+
* optionally which roles count toward it. Since #4290 it may be a list of
|
|
9
|
+
* rules, each scoped by `targets` globs over the run's environment
|
|
10
|
+
* (`./gate-quorum.ts`).
|
|
9
11
|
* - `policy`: a policy set a lexicon rendered (the cedar lexicon's
|
|
10
12
|
* `gatePolicy()`), evaluated for each approval as a `PassGate` request.
|
|
11
13
|
* - `mode`: `"log-only"` records the policy's decision next to the approval
|
|
@@ -30,11 +32,15 @@
|
|
|
30
32
|
* decision also records the digest of the context it was asked about, and a
|
|
31
33
|
* permit counts only while the run resolves that same context (#3774).
|
|
32
34
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
35
|
+
* A resolution is a local fact, not a signed one (`../lifecycle/gate-ledger.ts`).
|
|
36
|
+
* Roles on it are what the approver claimed, and since #4290 the quorum
|
|
37
|
+
* never reads them: a role counts only when `.chant/trust.json` at base
|
|
38
|
+
* grants it and a seal proves the approver (`./gate-quorum.ts`). A policy
|
|
39
|
+
* still sees the claimed roles in its request.
|
|
36
40
|
*/
|
|
37
41
|
import { type StepOutputRef } from "./step-output-ref.js";
|
|
42
|
+
import { type GateQuorumRule, type GateQuorumSpec } from "./gate-quorum.js";
|
|
43
|
+
export type { GateQuorumRule, GateQuorumSpec } from "./gate-quorum.js";
|
|
38
44
|
/** What a policy's decision does to the gate. */
|
|
39
45
|
export type GateApprovalMode = "log-only" | "enforce";
|
|
40
46
|
export declare const GATE_APPROVAL_MODES: readonly GateApprovalMode[];
|
|
@@ -54,18 +60,18 @@ export interface GatePolicyRef {
|
|
|
54
60
|
/** The policy set, in the lexicon's own language. */
|
|
55
61
|
text: string;
|
|
56
62
|
}
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
63
|
+
/**
|
|
64
|
+
* How many distinct human approvers a gate needs, and which roles count: one
|
|
65
|
+
* approval rule (#4290, `./gate-quorum.ts`). A role counts only when
|
|
66
|
+
* `.chant/trust.json` at base grants it to a proven approver.
|
|
67
|
+
*/
|
|
68
|
+
export type GateQuorum = GateQuorumRule;
|
|
64
69
|
/** A value a gate hands its policy as context. */
|
|
65
70
|
export type GateContextValue = string | number | boolean | string[] | StepOutputRef;
|
|
66
71
|
/** The `approval` block on a `gate` step. */
|
|
67
72
|
export interface GateApproval {
|
|
68
|
-
|
|
73
|
+
/** One rule, or a list of rules scoped by `targets` over the run's environment (#4290). */
|
|
74
|
+
quorum?: GateQuorumSpec;
|
|
69
75
|
policy?: GatePolicyRef;
|
|
70
76
|
/** Default `"log-only"`, so a new policy is observed against real gate traffic before it binds. */
|
|
71
77
|
mode?: GateApprovalMode;
|
|
@@ -85,7 +91,8 @@ export interface GateApproval {
|
|
|
85
91
|
* actually produced.
|
|
86
92
|
*/
|
|
87
93
|
export interface ResolvedGateApproval {
|
|
88
|
-
|
|
94
|
+
/** The rules this run's gate takes (#4290): a list, or one rule on a fact written before. */
|
|
95
|
+
quorum?: GateQuorumSpec;
|
|
89
96
|
policy?: GatePolicyRef;
|
|
90
97
|
mode: GateApprovalMode;
|
|
91
98
|
context?: Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-approval.d.ts","sourceRoot":"","sources":["../../src/op/gate-approval.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,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CAAC;CACrH;AAED,gJAAgJ;AAChJ,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,MAAM,CAEtF;AASD,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAUtE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,EAAE,CAyDhE;AASD,sHAAsH;AACtH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAgB3F;AAED,wDAAwD;AACxD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,GAAG,iBAAiB,CAUpB"}
|
package/dist/op/gate-approval.js
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* more than that, as data that survives into the build output:
|
|
6
6
|
*
|
|
7
7
|
* - `quorum`: how many distinct human approvers the gate needs, and
|
|
8
|
-
* optionally which roles count toward it.
|
|
8
|
+
* optionally which roles count toward it. Since #4290 it may be a list of
|
|
9
|
+
* rules, each scoped by `targets` globs over the run's environment
|
|
10
|
+
* (`./gate-quorum.ts`).
|
|
9
11
|
* - `policy`: a policy set a lexicon rendered (the cedar lexicon's
|
|
10
12
|
* `gatePolicy()`), evaluated for each approval as a `PassGate` request.
|
|
11
13
|
* - `mode`: `"log-only"` records the policy's decision next to the approval
|
|
@@ -30,14 +32,17 @@
|
|
|
30
32
|
* decision also records the digest of the context it was asked about, and a
|
|
31
33
|
* permit counts only while the run resolves that same context (#3774).
|
|
32
34
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
35
|
+
* A resolution is a local fact, not a signed one (`../lifecycle/gate-ledger.ts`).
|
|
36
|
+
* Roles on it are what the approver claimed, and since #4290 the quorum
|
|
37
|
+
* never reads them: a role counts only when `.chant/trust.json` at base
|
|
38
|
+
* grants it and a seal proves the approver (`./gate-quorum.ts`). A policy
|
|
39
|
+
* still sees the claimed roles in its request.
|
|
36
40
|
*/
|
|
37
41
|
import { createHash } from "node:crypto";
|
|
38
42
|
import { lexiconModulePath, importLexiconPackage } from "../lexicon-module.js";
|
|
39
43
|
import { isStepOutputRef } from "./step-output-ref.js";
|
|
40
44
|
import { GATE_PLAN_CONTEXT_KEY } from "./gate-plan-context.js";
|
|
45
|
+
import { quorumProblems } from "./gate-quorum.js";
|
|
41
46
|
export const GATE_APPROVAL_MODES = ["log-only", "enforce"];
|
|
42
47
|
/** The version of a gate policy: `sha256:` and the hex digest of its text. A lexicon's helper stamps it, and OPS015 checks it still matches. */
|
|
43
48
|
export function gatePolicyVersion(text) {
|
|
@@ -79,20 +84,10 @@ export function gateApprovalProblems(approval) {
|
|
|
79
84
|
const a = approval;
|
|
80
85
|
const problems = [];
|
|
81
86
|
if (a.quorum !== undefined) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
else {
|
|
87
|
-
if (typeof q.count !== "number" || !Number.isInteger(q.count) || q.count < 1) {
|
|
88
|
-
problems.push("`approval.quorum.count` must be an integer of at least 1");
|
|
89
|
-
}
|
|
90
|
-
if (q.roles !== undefined) {
|
|
91
|
-
if (!Array.isArray(q.roles) || q.roles.length === 0 || q.roles.some((r) => typeof r !== "string" || r === "")) {
|
|
92
|
-
problems.push("`approval.quorum.roles` must be a non-empty list of role names");
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
87
|
+
if (typeof a.quorum !== "object" || a.quorum === null)
|
|
88
|
+
problems.push("`approval.quorum` must be an object or a list of rules");
|
|
89
|
+
else
|
|
90
|
+
problems.push(...quorumProblems(a.quorum, "approval.quorum", { notAuthor: false }));
|
|
96
91
|
}
|
|
97
92
|
if (a.policy !== undefined) {
|
|
98
93
|
if (!isGatePolicyRef(a.policy)) {
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approval rules (#4290): a gate's quorum as a list of rules, each with the
|
|
3
|
+
* targets it covers, how many approvers it needs, the roles that count, and
|
|
4
|
+
* whether one of them must not be the change's author.
|
|
5
|
+
*
|
|
6
|
+
* quorum: [
|
|
7
|
+
* { targets: ["prod-*"], count: 2, roles: ["platform"], notAuthor: true },
|
|
8
|
+
* { count: 1 },
|
|
9
|
+
* ]
|
|
10
|
+
*
|
|
11
|
+
* A gate takes every rule whose `targets` glob matches one of its targets
|
|
12
|
+
* (a rule with no `targets` covers every target), and passes once each rule
|
|
13
|
+
* it takes is met by distinct human approvers of its plan. A gate that takes
|
|
14
|
+
* no rule needs one human approval, the rule every gate had before.
|
|
15
|
+
*
|
|
16
|
+
* Roles come from `.chant/trust.json` at base (`roles`: role name to the
|
|
17
|
+
* principals that hold it), never from the approver's own claim. An
|
|
18
|
+
* approver counts toward `roles`, and as someone who is not the author, only
|
|
19
|
+
* when the approval proves who they are: a seal that verifies against the
|
|
20
|
+
* signers file at base, or under `pr-review` the forge review of the merged
|
|
21
|
+
* pull request. The judge of a gate decides that ({@link GateQuorumJudge});
|
|
22
|
+
* with none, no approval proves anything, so a rule naming roles or
|
|
23
|
+
* `notAuthor` is never met.
|
|
24
|
+
*
|
|
25
|
+
* This module is pure: no git, no file reads, no package, so
|
|
26
|
+
* `@intentius/chant/gate-decision` bundles it. The judge is built by the
|
|
27
|
+
* caller from the trust policy it read at base ({@link trustQuorumJudge}).
|
|
28
|
+
*/
|
|
29
|
+
import { type GateSigners } from "../lifecycle/gate-seal.js";
|
|
30
|
+
import type { GateResolutionRecord } from "../lifecycle/gate-ledger.js";
|
|
31
|
+
/** One approval rule. */
|
|
32
|
+
export interface GateQuorumRule {
|
|
33
|
+
/** Globs over the gate's targets (an Op wave's run targets, an Op gate's environment). Absent, the rule covers every target. */
|
|
34
|
+
targets?: string[];
|
|
35
|
+
/** Distinct human approvers the rule needs. At least 1. */
|
|
36
|
+
count: number;
|
|
37
|
+
/** When set, only an approver `.chant/trust.json` at base gives one of these roles counts, and only with a proven approval. */
|
|
38
|
+
roles?: string[];
|
|
39
|
+
/** When true, at least one counted approver is proven and is not the change's author. */
|
|
40
|
+
notAuthor?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** A gate's quorum: one rule (the form before #4290), or a list of them. */
|
|
43
|
+
export type GateQuorumSpec = GateQuorumRule | readonly GateQuorumRule[];
|
|
44
|
+
/** What a judge says about one approval. */
|
|
45
|
+
export interface QuorumJudgement {
|
|
46
|
+
/** The approval proves who `resolvedBy` is: a verified seal, or the forge's review. */
|
|
47
|
+
proven: boolean;
|
|
48
|
+
/** The roles `.chant/trust.json` at base gives the approver. Empty unless `proven`. */
|
|
49
|
+
roles: string[];
|
|
50
|
+
/** Whether the approver is the change's author. Undefined when nobody knows who the author is. */
|
|
51
|
+
author?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/** Judges one approval for the rules. */
|
|
54
|
+
export type GateQuorumJudge = (approval: GateResolutionRecord) => QuorumJudgement;
|
|
55
|
+
/** The judge with nothing to judge by: no approval proves anyone, and nobody's author is known. */
|
|
56
|
+
export declare const UNPROVEN_JUDGE: GateQuorumJudge;
|
|
57
|
+
/** How far one rule is met. */
|
|
58
|
+
export interface GateQuorumRuleProgress {
|
|
59
|
+
targets?: string[];
|
|
60
|
+
count: number;
|
|
61
|
+
roles?: string[];
|
|
62
|
+
notAuthor?: boolean;
|
|
63
|
+
/** The approvers it counts, oldest first. */
|
|
64
|
+
approvers: string[];
|
|
65
|
+
met: boolean;
|
|
66
|
+
/** Why the author could not be told apart, when `notAuthor` is set and nobody knows the author. */
|
|
67
|
+
authorUnknown?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/** The rules of a quorum, as a list. Absent, none. */
|
|
70
|
+
export declare function quorumRules(quorum: GateQuorumSpec | undefined): GateQuorumRule[];
|
|
71
|
+
/**
|
|
72
|
+
* Whether `target` matches `glob`: `*` within a `/` segment, `**` across
|
|
73
|
+
* segments (and `a/**\/b` across none), `?` one character. The same reading
|
|
74
|
+
* as the terraform lexicon's unit globs, so a Terragrunt root's glob means
|
|
75
|
+
* one thing in both.
|
|
76
|
+
*/
|
|
77
|
+
export declare function targetGlobMatch(glob: string, target: string): boolean;
|
|
78
|
+
/** The rules a gate whose targets are `targets` takes: those with no `targets`, and those a glob of matches one. */
|
|
79
|
+
export declare function quorumRulesFor(rules: readonly GateQuorumRule[], targets: readonly string[]): GateQuorumRule[];
|
|
80
|
+
/** The most approvers any rule needs, 1 with none. */
|
|
81
|
+
export declare function quorumNeed(rules: readonly GateQuorumRule[]): number;
|
|
82
|
+
/**
|
|
83
|
+
* Everything wrong with a quorum, one line each. `where` names it
|
|
84
|
+
* (`approval.quorum`). With `notAuthor: false`, a rule naming `notAuthor` is
|
|
85
|
+
* refused, since that caller has no author to judge by.
|
|
86
|
+
*/
|
|
87
|
+
export declare function quorumProblems(value: unknown, where: string, opts: {
|
|
88
|
+
notAuthor: boolean;
|
|
89
|
+
}): string[];
|
|
90
|
+
/** Whether two principals name the same person, compared trimmed and lower-cased. */
|
|
91
|
+
export declare const samePrincipal: (a: string, b: string) => boolean;
|
|
92
|
+
/** The roles `roles` (`.chant/trust.json`'s role grants) gives `who`, sorted. */
|
|
93
|
+
export declare function rolesOf(who: string, roles: Readonly<Record<string, readonly string[]>>): string[];
|
|
94
|
+
/** One approver as a rule counts them. */
|
|
95
|
+
export interface QuorumApprover {
|
|
96
|
+
who: string;
|
|
97
|
+
at: string;
|
|
98
|
+
judged: QuorumJudgement;
|
|
99
|
+
}
|
|
100
|
+
/** How far `rule` is met by `approvers`: each counted once, by name, oldest first. */
|
|
101
|
+
export declare function quorumRuleProgress(rule: GateQuorumRule, approvers: readonly QuorumApprover[]): GateQuorumRuleProgress;
|
|
102
|
+
/**
|
|
103
|
+
* Where a rule stands, in one line: `prod-*: 1 of 2 approvals (github:alice),
|
|
104
|
+
* needs 1 more from platform`.
|
|
105
|
+
*/
|
|
106
|
+
export declare function quorumRuleLine(p: GateQuorumRuleProgress): string;
|
|
107
|
+
/** The rules that are not met, one line each joined by `; `. */
|
|
108
|
+
export declare function quorumWaiting(progress: readonly GateQuorumRuleProgress[]): string;
|
|
109
|
+
/** Whether a rule needs a proven approver: it names roles, or `notAuthor`. */
|
|
110
|
+
export declare const ruleNeedsProof: (rule: GateQuorumRule) => boolean;
|
|
111
|
+
/** What {@link trustQuorumJudge} judges by. */
|
|
112
|
+
export interface TrustQuorumInput {
|
|
113
|
+
/** The signers at base: an approval whose seal verifies for its approver against them is proven. */
|
|
114
|
+
signers: GateSigners;
|
|
115
|
+
/** `.chant/trust.json`'s role grants at base. */
|
|
116
|
+
roles: Readonly<Record<string, readonly string[]>>;
|
|
117
|
+
/** The change's authors, as principals. Absent, nobody knows who they are. */
|
|
118
|
+
authors?: readonly string[];
|
|
119
|
+
/**
|
|
120
|
+
* Under `pr-review`, the merged pull request's review, read from the forge
|
|
121
|
+
* in this run: a resolution that names this review's head and one of its
|
|
122
|
+
* approvers as `resolvedBy` is proven.
|
|
123
|
+
*/
|
|
124
|
+
review?: {
|
|
125
|
+
head: string;
|
|
126
|
+
approvers: readonly string[];
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/** The judge a gate's rules are met by: proof from a seal or the live review, roles from trust.json at base. */
|
|
130
|
+
export declare function trustQuorumJudge(input: TrustQuorumInput): GateQuorumJudge;
|
|
131
|
+
//# sourceMappingURL=gate-quorum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate-quorum.d.ts","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M,CAEjF;AAED,8EAA8E;AAC9E,eAAO,MAAM,cAAc,SAAU,cAAc,KAAG,OAAmE,CAAC;AAE1H,+CAA+C;AAC/C,MAAM,WAAW,gBAAgB;IAC/B,oGAAoG;IACpG,OAAO,EAAE,WAAW,CAAC;IACrB,iDAAiD;IACjD,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;IACnD,8EAA8E;IAC9E,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B;;;;OAIG;IACH,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,CAAC;CACzD;AAED,gHAAgH;AAChH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,eAAe,CAYzE"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Approval rules (#4290): a gate's quorum as a list of rules, each with the
|
|
3
|
+
* targets it covers, how many approvers it needs, the roles that count, and
|
|
4
|
+
* whether one of them must not be the change's author.
|
|
5
|
+
*
|
|
6
|
+
* quorum: [
|
|
7
|
+
* { targets: ["prod-*"], count: 2, roles: ["platform"], notAuthor: true },
|
|
8
|
+
* { count: 1 },
|
|
9
|
+
* ]
|
|
10
|
+
*
|
|
11
|
+
* A gate takes every rule whose `targets` glob matches one of its targets
|
|
12
|
+
* (a rule with no `targets` covers every target), and passes once each rule
|
|
13
|
+
* it takes is met by distinct human approvers of its plan. A gate that takes
|
|
14
|
+
* no rule needs one human approval, the rule every gate had before.
|
|
15
|
+
*
|
|
16
|
+
* Roles come from `.chant/trust.json` at base (`roles`: role name to the
|
|
17
|
+
* principals that hold it), never from the approver's own claim. An
|
|
18
|
+
* approver counts toward `roles`, and as someone who is not the author, only
|
|
19
|
+
* when the approval proves who they are: a seal that verifies against the
|
|
20
|
+
* signers file at base, or under `pr-review` the forge review of the merged
|
|
21
|
+
* pull request. The judge of a gate decides that ({@link GateQuorumJudge});
|
|
22
|
+
* with none, no approval proves anything, so a rule naming roles or
|
|
23
|
+
* `notAuthor` is never met.
|
|
24
|
+
*
|
|
25
|
+
* This module is pure: no git, no file reads, no package, so
|
|
26
|
+
* `@intentius/chant/gate-decision` bundles it. The judge is built by the
|
|
27
|
+
* caller from the trust policy it read at base ({@link trustQuorumJudge}).
|
|
28
|
+
*/
|
|
29
|
+
import { gateSealRefusal } from "../lifecycle/gate-seal.js";
|
|
30
|
+
/** The judge with nothing to judge by: no approval proves anyone, and nobody's author is known. */
|
|
31
|
+
export const UNPROVEN_JUDGE = () => ({ proven: false, roles: [] });
|
|
32
|
+
/** The rules of a quorum, as a list. Absent, none. */
|
|
33
|
+
export function quorumRules(quorum) {
|
|
34
|
+
if (quorum === undefined)
|
|
35
|
+
return [];
|
|
36
|
+
return Array.isArray(quorum) ? [...quorum] : [quorum];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Whether `target` matches `glob`: `*` within a `/` segment, `**` across
|
|
40
|
+
* segments (and `a/**\/b` across none), `?` one character. The same reading
|
|
41
|
+
* as the terraform lexicon's unit globs, so a Terragrunt root's glob means
|
|
42
|
+
* one thing in both.
|
|
43
|
+
*/
|
|
44
|
+
export function targetGlobMatch(glob, target) {
|
|
45
|
+
const g = glob.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
46
|
+
let re = "";
|
|
47
|
+
for (let i = 0; i < g.length; i++) {
|
|
48
|
+
const c = g[i];
|
|
49
|
+
if (c === "*" && g[i + 1] === "*") {
|
|
50
|
+
if (g[i + 2] === "/") {
|
|
51
|
+
re += "(?:.*/)?";
|
|
52
|
+
i += 2;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
re += ".*";
|
|
56
|
+
i += 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else if (c === "*")
|
|
60
|
+
re += "[^/]*";
|
|
61
|
+
else if (c === "?")
|
|
62
|
+
re += "[^/]";
|
|
63
|
+
else
|
|
64
|
+
re += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
65
|
+
}
|
|
66
|
+
return new RegExp(`^${re}$`).test(target.replace(/\\/g, "/").replace(/\/+$/, ""));
|
|
67
|
+
}
|
|
68
|
+
/** The rules a gate whose targets are `targets` takes: those with no `targets`, and those a glob of matches one. */
|
|
69
|
+
export function quorumRulesFor(rules, targets) {
|
|
70
|
+
return rules.filter((r) => r.targets === undefined || r.targets.some((g) => targets.some((t) => targetGlobMatch(g, t))));
|
|
71
|
+
}
|
|
72
|
+
/** The most approvers any rule needs, 1 with none. */
|
|
73
|
+
export function quorumNeed(rules) {
|
|
74
|
+
return rules.reduce((n, r) => Math.max(n, r.count), 1);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Everything wrong with a quorum, one line each. `where` names it
|
|
78
|
+
* (`approval.quorum`). With `notAuthor: false`, a rule naming `notAuthor` is
|
|
79
|
+
* refused, since that caller has no author to judge by.
|
|
80
|
+
*/
|
|
81
|
+
export function quorumProblems(value, where, opts) {
|
|
82
|
+
const list = Array.isArray(value) ? value : [value];
|
|
83
|
+
const problems = [];
|
|
84
|
+
if (Array.isArray(value) && value.length === 0)
|
|
85
|
+
problems.push(`\`${where}\` must name at least one rule`);
|
|
86
|
+
list.forEach((rule, i) => {
|
|
87
|
+
const at = Array.isArray(value) ? `${where}[${i}]` : where;
|
|
88
|
+
if (typeof rule !== "object" || rule === null || Array.isArray(rule)) {
|
|
89
|
+
problems.push(`\`${at}\` must be an object`);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const q = rule;
|
|
93
|
+
if (typeof q.count !== "number" || !Number.isInteger(q.count) || q.count < 1)
|
|
94
|
+
problems.push(`\`${at}.count\` must be an integer of at least 1`);
|
|
95
|
+
if (q.roles !== undefined && (!Array.isArray(q.roles) || q.roles.length === 0 || q.roles.some((r) => typeof r !== "string" || r === ""))) {
|
|
96
|
+
problems.push(`\`${at}.roles\` must be a non-empty list of role names`);
|
|
97
|
+
}
|
|
98
|
+
if (q.targets !== undefined && (!Array.isArray(q.targets) || q.targets.length === 0 || q.targets.some((t) => typeof t !== "string" || t === ""))) {
|
|
99
|
+
problems.push(`\`${at}.targets\` must be a non-empty list of globs`);
|
|
100
|
+
}
|
|
101
|
+
if (q.notAuthor !== undefined && typeof q.notAuthor !== "boolean")
|
|
102
|
+
problems.push(`\`${at}.notAuthor\` must be true or false`);
|
|
103
|
+
if (q.notAuthor === true && !opts.notAuthor) {
|
|
104
|
+
problems.push(`\`${at}.notAuthor\` is not read here: an Op gate has no author to judge by. An Op waves spec's \`approvals.quorum\` reads it from the merged pull request`);
|
|
105
|
+
}
|
|
106
|
+
const known = new Set(["targets", "count", "roles", "notAuthor"]);
|
|
107
|
+
for (const key of Object.keys(q))
|
|
108
|
+
if (!known.has(key))
|
|
109
|
+
problems.push(`\`${at}.${key}\` is not a quorum field; use targets, count, roles or notAuthor`);
|
|
110
|
+
});
|
|
111
|
+
return problems;
|
|
112
|
+
}
|
|
113
|
+
const norm = (s) => s.normalize("NFKC").trim().toLowerCase();
|
|
114
|
+
/** Whether two principals name the same person, compared trimmed and lower-cased. */
|
|
115
|
+
export const samePrincipal = (a, b) => norm(a) === norm(b);
|
|
116
|
+
/** The roles `roles` (`.chant/trust.json`'s role grants) gives `who`, sorted. */
|
|
117
|
+
export function rolesOf(who, roles) {
|
|
118
|
+
return Object.entries(roles)
|
|
119
|
+
.filter(([, principals]) => principals.some((p) => samePrincipal(p, who)))
|
|
120
|
+
.map(([role]) => role)
|
|
121
|
+
.sort();
|
|
122
|
+
}
|
|
123
|
+
/** How far `rule` is met by `approvers`: each counted once, by name, oldest first. */
|
|
124
|
+
export function quorumRuleProgress(rule, approvers) {
|
|
125
|
+
const seen = new Set();
|
|
126
|
+
const counted = [];
|
|
127
|
+
for (const a of [...approvers].sort((x, y) => Date.parse(x.at) - Date.parse(y.at))) {
|
|
128
|
+
if (seen.has(norm(a.who)))
|
|
129
|
+
continue;
|
|
130
|
+
if (rule.roles?.length && !(a.judged.proven && a.judged.roles.some((r) => rule.roles.includes(r))))
|
|
131
|
+
continue;
|
|
132
|
+
seen.add(norm(a.who));
|
|
133
|
+
counted.push(a);
|
|
134
|
+
}
|
|
135
|
+
const notAuthor = !rule.notAuthor || counted.some((a) => a.judged.proven && a.judged.author === false);
|
|
136
|
+
const authorUnknown = rule.notAuthor === true && !notAuthor && counted.some((a) => a.judged.proven && a.judged.author === undefined);
|
|
137
|
+
return {
|
|
138
|
+
...(rule.targets ? { targets: [...rule.targets] } : {}),
|
|
139
|
+
count: rule.count,
|
|
140
|
+
...(rule.roles?.length ? { roles: [...rule.roles] } : {}),
|
|
141
|
+
...(rule.notAuthor ? { notAuthor: true } : {}),
|
|
142
|
+
approvers: counted.map((a) => a.who),
|
|
143
|
+
met: counted.length >= rule.count && notAuthor,
|
|
144
|
+
...(authorUnknown ? { authorUnknown: true } : {}),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Where a rule stands, in one line: `prod-*: 1 of 2 approvals (github:alice),
|
|
149
|
+
* needs 1 more from platform`.
|
|
150
|
+
*/
|
|
151
|
+
export function quorumRuleLine(p) {
|
|
152
|
+
const scope = p.targets ? p.targets.join(", ") : "every target";
|
|
153
|
+
const have = `${p.approvers.length} of ${p.count} approval${p.count === 1 ? "" : "s"}${p.approvers.length ? ` (${p.approvers.join(", ")})` : ""}`;
|
|
154
|
+
if (p.met)
|
|
155
|
+
return `${scope}: ${have}, met`;
|
|
156
|
+
const more = p.count - p.approvers.length;
|
|
157
|
+
const needs = [];
|
|
158
|
+
if (more > 0)
|
|
159
|
+
needs.push(`${more} more${p.roles?.length ? ` from ${p.roles.join(" or ")}` : ""}`);
|
|
160
|
+
if (p.notAuthor)
|
|
161
|
+
needs.push(more > 0 ? "one of them not the author" : "an approver who is not the author");
|
|
162
|
+
const unknown = p.authorUnknown ? " (the change's author is not known, so no approver can show they are someone else)" : "";
|
|
163
|
+
return `${scope}: ${have}, needs ${needs.join(", ")}${unknown}`;
|
|
164
|
+
}
|
|
165
|
+
/** The rules that are not met, one line each joined by `; `. */
|
|
166
|
+
export function quorumWaiting(progress) {
|
|
167
|
+
return progress.filter((p) => !p.met).map(quorumRuleLine).join("; ");
|
|
168
|
+
}
|
|
169
|
+
/** Whether a rule needs a proven approver: it names roles, or `notAuthor`. */
|
|
170
|
+
export const ruleNeedsProof = (rule) => (rule.roles?.length ?? 0) > 0 || rule.notAuthor === true;
|
|
171
|
+
/** The judge a gate's rules are met by: proof from a seal or the live review, roles from trust.json at base. */
|
|
172
|
+
export function trustQuorumJudge(input) {
|
|
173
|
+
return (r) => {
|
|
174
|
+
const sealed = r.seal !== undefined && r.seal !== null && gateSealRefusal(input.signers, r) === null;
|
|
175
|
+
const reviewed = input.review !== undefined && r.review?.head === input.review.head && input.review.approvers.some((a) => samePrincipal(a, r.resolvedBy));
|
|
176
|
+
const proven = sealed || reviewed;
|
|
177
|
+
return {
|
|
178
|
+
proven,
|
|
179
|
+
roles: proven ? rolesOf(r.resolvedBy, input.roles) : [],
|
|
180
|
+
...(input.authors !== undefined ? { author: input.authors.some((a) => samePrincipal(a, r.resolvedBy)) } : {}),
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
}
|
package/dist/op/gate-resume.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* `./gate`'s quorum rules.
|
|
9
9
|
*/
|
|
10
10
|
import type { GateResolutionRecord, PendingGateRecord } from "../lifecycle/gate-ledger.js";
|
|
11
|
+
import type { GateQuorumJudge } from "./gate-quorum.js";
|
|
11
12
|
export { isGateRunLocator, resolveGateRunLocator, resumeGateRun, resumeTokenFromEnv, type GateResumeOutcome, type GateRunLocator, type ResumeGateRunOptions, } from "../gate-resume-run.js";
|
|
12
13
|
/**
|
|
13
14
|
* The resolution that answers `standing`, read the way a run decides the gate
|
|
@@ -15,7 +16,8 @@ export { isGateRunLocator, resolveGateRunLocator, resumeGateRun, resumeTokenFrom
|
|
|
15
16
|
* gate ledger's pending facts, which place the human quorum's anchor (#3206);
|
|
16
17
|
* without them it is `standing` itself. A workspace's
|
|
17
18
|
* `identity.gates` rule is not applied here: the resumed job applies it, and
|
|
18
|
-
* waits again when the approval does not count.
|
|
19
|
+
* waits again when the approval does not count. `judge` proves approvers
|
|
20
|
+
* for approval rules that name roles (#4290); absent, none is proven.
|
|
19
21
|
*/
|
|
20
|
-
export declare function resolutionAnswering(resolutions: readonly GateResolutionRecord[], standing: PendingGateRecord, pending?: readonly PendingGateRecord[]): GateResolutionRecord | undefined;
|
|
22
|
+
export declare function resolutionAnswering(resolutions: readonly GateResolutionRecord[], standing: PendingGateRecord, pending?: readonly PendingGateRecord[], judge?: GateQuorumJudge): GateResolutionRecord | undefined;
|
|
21
23
|
//# sourceMappingURL=gate-resume.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-resume.d.ts","sourceRoot":"","sources":["../../src/op/gate-resume.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"gate-resume.d.ts","sourceRoot":"","sources":["../../src/op/gate-resume.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,kBAAkB,EAClB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,SAAS,oBAAoB,EAAE,EAC5C,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,GAAE,SAAS,iBAAiB,EAAe,EAClD,KAAK,CAAC,EAAE,eAAe,GACtB,oBAAoB,GAAG,SAAS,CASlC"}
|
package/dist/op/gate-resume.js
CHANGED
|
@@ -16,16 +16,17 @@ export { isGateRunLocator, resolveGateRunLocator, resumeGateRun, resumeTokenFrom
|
|
|
16
16
|
* gate ledger's pending facts, which place the human quorum's anchor (#3206);
|
|
17
17
|
* without them it is `standing` itself. A workspace's
|
|
18
18
|
* `identity.gates` rule is not applied here: the resumed job applies it, and
|
|
19
|
-
* waits again when the approval does not count.
|
|
19
|
+
* waits again when the approval does not count. `judge` proves approvers
|
|
20
|
+
* for approval rules that name roles (#4290); absent, none is proven.
|
|
20
21
|
*/
|
|
21
|
-
export function resolutionAnswering(resolutions, standing, pending = [standing]) {
|
|
22
|
+
export function resolutionAnswering(resolutions, standing, pending = [standing], judge) {
|
|
22
23
|
const env = standing.environment;
|
|
23
24
|
const mine = resolutions.filter((r) => env === undefined || r.environment === env);
|
|
24
25
|
if (standing.approval) {
|
|
25
|
-
const tally = tallyGateApprovals(mine, standing.gate, standing.timestamp, standing.planDigest, standing.approval, humanQuorumSince(pending, standing));
|
|
26
|
+
const tally = tallyGateApprovals(mine, standing.gate, standing.timestamp, standing.planDigest, standing.approval, humanQuorumSince(pending, standing), judge);
|
|
26
27
|
if (tally.permit)
|
|
27
28
|
return tally.permit;
|
|
28
|
-
return tally.
|
|
29
|
+
return tally.met ? tally.counted[tally.counted.length - 1] : undefined;
|
|
29
30
|
}
|
|
30
31
|
return latestResolutionForPlan(mine, standing.gate, standing.timestamp, standing.planDigest).resolution;
|
|
31
32
|
}
|
package/dist/op/gate-review.js
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* back. The author's own review never counts.
|
|
30
30
|
*/
|
|
31
31
|
import { readFileSync } from "node:fs";
|
|
32
|
-
import { gateSealRefusal } from "../
|
|
32
|
+
import { gateSealRefusal } from "../lifecycle/gate-seal.js";
|
|
33
33
|
import { readTrustPolicy } from "../workspace/trust/policy.js";
|
|
34
34
|
import { gitRevisionSource } from "../workspace/record-source.js";
|
|
35
35
|
import { forgePrincipalOf, ForgeApiError } from "../pr-forge.js";
|
package/dist/op/gate.d.ts
CHANGED
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
import { type GateResolutionInput, type GateResolutionRecord, type PendingGateInput, type PendingGateRecord } from "../lifecycle/gate-ledger.js";
|
|
35
35
|
import { type AppliedGateRecord } from "../lifecycle/gate-applied.js";
|
|
36
36
|
import { type GateApprover, type ResolvedGateApproval } from "./gate-approval.js";
|
|
37
|
+
import { type GateQuorumJudge, type GateQuorumRuleProgress } from "./gate-quorum.js";
|
|
37
38
|
import { type GateCheckpoint } from "../lifecycle/gate-checkpoint.js";
|
|
38
39
|
import type { ResolvedGateAlias } from "./gate-alias.js";
|
|
39
40
|
/**
|
|
@@ -84,6 +85,16 @@ export interface GateLedgerPort {
|
|
|
84
85
|
approvalRule?(gate: string, at?: {
|
|
85
86
|
base?: string;
|
|
86
87
|
}): Promise<GateApprovalRule | null>;
|
|
88
|
+
/**
|
|
89
|
+
* The judge a gate's approval rules are met by (#4290): which approvals
|
|
90
|
+
* prove their approver (a seal verified against the signers at base) and
|
|
91
|
+
* the roles `.chant/trust.json` at base gives them. `at.base` as for
|
|
92
|
+
* {@link GateLedgerPort.approvalRule}. Absent, no approval proves anyone,
|
|
93
|
+
* so a rule naming roles is never met.
|
|
94
|
+
*/
|
|
95
|
+
quorumJudge?(gate: string, at?: {
|
|
96
|
+
base?: string;
|
|
97
|
+
}): Promise<GateQuorumJudge>;
|
|
87
98
|
/** The approvals a wave applied under (#3784), from `_gates/<op>/applied.jsonl`. Absent on a port that never spends approvals. */
|
|
88
99
|
readApplied?(op: string): Promise<AppliedGateRecord[]>;
|
|
89
100
|
/** Record that a wave is about to apply under an approval (#3784), which spends it. */
|
|
@@ -177,6 +188,13 @@ export interface GateCheckInput {
|
|
|
177
188
|
* it so `chant approve` can evaluate the policy.
|
|
178
189
|
*/
|
|
179
190
|
approval?: ResolvedGateApproval;
|
|
191
|
+
/**
|
|
192
|
+
* Judges approvals for `approval.quorum`'s rules (#4290). Absent, the
|
|
193
|
+
* port's {@link GateLedgerPort.quorumJudge} at its default base, else no
|
|
194
|
+
* approval proves anyone. A wave passes one that knows the change's author
|
|
195
|
+
* and the merged pull request's review.
|
|
196
|
+
*/
|
|
197
|
+
judge?: GateQuorumJudge;
|
|
180
198
|
/** ISO-8601 "now" — supplied by the caller, so the decision is deterministic under test. */
|
|
181
199
|
now?: string;
|
|
182
200
|
/**
|
|
@@ -264,6 +282,8 @@ export interface GateQuorumProgress {
|
|
|
264
282
|
/** Approvers whose approval counts toward the quorum, oldest first. */
|
|
265
283
|
approvers: string[];
|
|
266
284
|
need: number;
|
|
285
|
+
/** Where each approval rule the gate takes stands (#4290). Absent when it takes none. */
|
|
286
|
+
rules?: GateQuorumRuleProgress[];
|
|
267
287
|
}
|
|
268
288
|
/** Either the gate is answered, or it is a standing fact. */
|
|
269
289
|
export type GateCheck = {
|
|
@@ -319,8 +339,12 @@ export declare function approverOf(record: GateResolutionRecord): GateApprover;
|
|
|
319
339
|
export interface GateTally {
|
|
320
340
|
/** Distinct human approvers of this plan who count toward the quorum, one record each (their newest), oldest first. */
|
|
321
341
|
counted: GateResolutionRecord[];
|
|
322
|
-
/** The
|
|
342
|
+
/** The most approvers a rule needs, 1 when the gate declares none. */
|
|
323
343
|
need: number;
|
|
344
|
+
/** Every rule is met (#4290); with no rules, one human approved. */
|
|
345
|
+
met: boolean;
|
|
346
|
+
/** Where each rule stands (#4290). Absent when the gate takes no rule. */
|
|
347
|
+
rules?: GateQuorumRuleProgress[];
|
|
324
348
|
/** The newest approval whose recorded permit passes the gate on its own. Only in `enforce` mode, only for a permit recorded under `enforce`, and only under the gate's current policy version and resolved context. */
|
|
325
349
|
permit?: GateResolutionRecord;
|
|
326
350
|
/** The newest approval of this gate for a different plan, when the gate binds one. */
|
|
@@ -337,8 +361,12 @@ export interface GateTally {
|
|
|
337
361
|
* pending fact re-recorded for a changed mode or context keeps a partly
|
|
338
362
|
* filled quorum (#3206). It defaults to `sinceIso`.
|
|
339
363
|
*
|
|
340
|
-
* Of those, only a human's counts toward the quorum, once per `resolvedBy
|
|
341
|
-
*
|
|
364
|
+
* Of those, only a human's counts toward the quorum, once per `resolvedBy`.
|
|
365
|
+
* The quorum is a list of rules (#4290, `./gate-quorum.ts`), already the ones
|
|
366
|
+
* the gate takes: each is met by distinct humans, counting toward `roles`
|
|
367
|
+
* only an approver `judge` proves and gives one of them (roles from
|
|
368
|
+
* `.chant/trust.json` at base, never the approver's claim), and the gate
|
|
369
|
+
* passes when every rule is met. With no rule, one human passes it. An agent counts
|
|
342
370
|
* only through a recorded `allow` in `enforce` mode, evaluated under the
|
|
343
371
|
* policy version the gate declares now, recorded while the gate was in
|
|
344
372
|
* `enforce` (#2512), and evaluated under the context the gate resolves now
|
|
@@ -346,7 +374,7 @@ export interface GateTally {
|
|
|
346
374
|
* after the gate switches to `enforce`, and a `deny` never removes a human's approval: a policy can add
|
|
347
375
|
* a way through the gate but cannot take one away.
|
|
348
376
|
*/
|
|
349
|
-
export declare function tallyGateApprovals(records: GateResolutionRecord[], gate: string, sinceIso: string, planDigest: string | undefined, approval: ResolvedGateApproval, humansSinceIso?: string): GateTally;
|
|
377
|
+
export declare function tallyGateApprovals(records: GateResolutionRecord[], gate: string, sinceIso: string, planDigest: string | undefined, approval: ResolvedGateApproval, humansSinceIso?: string, judge?: GateQuorumJudge): GateTally;
|
|
350
378
|
/**
|
|
351
379
|
* Where a gate's human quorum starts counting (#3206): the oldest pending fact
|
|
352
380
|
* in the unbroken run of facts, newest first from `standing`, recorded for
|
package/dist/op/gate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../../src/op/gate.ts"],"names":[],"mappings":"AAAA;;;;;;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