@intentius/chant 0.124.40 → 0.124.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__fixtures__/oidc-emulator.d.ts +49 -0
- package/dist/__fixtures__/oidc-emulator.d.ts.map +1 -0
- package/dist/__fixtures__/oidc-emulator.js +89 -0
- package/dist/ci-handover.d.ts +117 -0
- package/dist/ci-handover.d.ts.map +1 -0
- package/dist/ci-handover.js +217 -0
- package/dist/ci-identity.d.ts +190 -0
- package/dist/ci-identity.d.ts.map +1 -0
- package/dist/ci-identity.js +219 -0
- package/dist/cli/handlers/approve.d.ts +2 -1
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +20 -6
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +15 -1
- package/dist/cli/handlers/fan-out.js +16 -3
- package/dist/cli/handlers/gate-resume.d.ts +3 -0
- package/dist/cli/handlers/gate-resume.d.ts.map +1 -1
- package/dist/cli/handlers/gate-resume.js +15 -2
- package/dist/cli/handlers/lock.d.ts +8 -0
- package/dist/cli/handlers/lock.d.ts.map +1 -0
- package/dist/cli/handlers/lock.js +197 -0
- package/dist/cli/handlers/pr-env.d.ts +34 -0
- package/dist/cli/handlers/pr-env.d.ts.map +1 -0
- package/dist/cli/handlers/pr-env.js +436 -0
- package/dist/cli/handlers/pr.d.ts +74 -0
- package/dist/cli/handlers/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +503 -53
- package/dist/cli/handlers/promote.d.ts.map +1 -1
- package/dist/cli/handlers/promote.js +9 -0
- package/dist/cli/handlers/query.d.ts +6 -0
- package/dist/cli/handlers/query.d.ts.map +1 -0
- package/dist/cli/handlers/query.js +80 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +41 -2
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +31 -2
- package/dist/cli/registry.d.ts +12 -2
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/fan-out-run.d.ts +28 -0
- package/dist/components/fan-out-run.d.ts.map +1 -1
- package/dist/components/fan-out-run.js +27 -3
- package/dist/components/pr-environment.d.ts +298 -0
- package/dist/components/pr-environment.d.ts.map +1 -0
- package/dist/components/pr-environment.js +406 -0
- package/dist/components/pr-hooks.d.ts +66 -0
- package/dist/components/pr-hooks.d.ts.map +1 -0
- package/dist/components/pr-hooks.js +119 -0
- package/dist/components/pr-pipeline.d.ts +72 -2
- package/dist/components/pr-pipeline.d.ts.map +1 -1
- package/dist/components/pr-pipeline.js +96 -5
- package/dist/components/pr-policy.d.ts +109 -0
- package/dist/components/pr-policy.d.ts.map +1 -0
- package/dist/components/pr-policy.js +150 -0
- package/dist/components/pr-run.d.ts.map +1 -1
- package/dist/components/pr-run.js +5 -3
- package/dist/gate-decision.d.ts +15 -2
- package/dist/gate-decision.d.ts.map +1 -1
- package/dist/gate-decision.js +17 -2
- package/dist/gate-policy.d.ts +140 -0
- package/dist/gate-policy.d.ts.map +1 -0
- package/dist/gate-policy.js +242 -0
- package/dist/lifecycle/gate-checkpoint.d.ts +1 -1
- package/dist/lifecycle/gate-checkpoint.js +1 -1
- package/dist/{workspace/trust → lifecycle}/gate-seal.d.ts +1 -1
- package/dist/lifecycle/gate-seal.d.ts.map +1 -0
- package/dist/lifecycle/query.d.ts +68 -0
- package/dist/lifecycle/query.d.ts.map +1 -0
- package/dist/lifecycle/query.js +246 -0
- package/dist/lifecycle/run-ledger.d.ts +13 -0
- package/dist/lifecycle/run-ledger.d.ts.map +1 -1
- package/dist/lifecycle/run-ledger.js +16 -0
- package/dist/lifecycle/target-lock.d.ts +97 -0
- package/dist/lifecycle/target-lock.d.ts.map +1 -0
- package/dist/lifecycle/target-lock.js +286 -0
- package/dist/op/activities/activity-contracts.d.ts +30 -0
- package/dist/op/activities/activity-contracts.d.ts.map +1 -1
- package/dist/op/activities/activity-contracts.js +26 -0
- package/dist/op/activities/index.d.ts +2 -0
- package/dist/op/activities/index.d.ts.map +1 -1
- package/dist/op/activities/index.js +4 -0
- package/dist/op/activities/review-agent.d.ts +137 -0
- package/dist/op/activities/review-agent.d.ts.map +1 -0
- package/dist/op/activities/review-agent.js +266 -0
- package/dist/op/builders.d.ts +9 -0
- package/dist/op/builders.d.ts.map +1 -1
- package/dist/op/builders.js +11 -0
- package/dist/op/cron.d.ts +8 -0
- package/dist/op/cron.d.ts.map +1 -1
- package/dist/op/cron.js +51 -0
- package/dist/op/gate-approval.d.ts +20 -13
- package/dist/op/gate-approval.d.ts.map +1 -1
- package/dist/op/gate-approval.js +13 -18
- package/dist/op/gate-quorum.d.ts +131 -0
- package/dist/op/gate-quorum.d.ts.map +1 -0
- package/dist/op/gate-quorum.js +183 -0
- package/dist/op/gate-resume.d.ts +4 -2
- package/dist/op/gate-resume.d.ts.map +1 -1
- package/dist/op/gate-resume.js +5 -4
- package/dist/op/gate-review.js +1 -1
- package/dist/op/gate.d.ts +32 -4
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +40 -24
- package/dist/op/index.d.ts +6 -4
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +4 -3
- package/dist/op/local-executor.d.ts.map +1 -1
- package/dist/op/local-executor.js +9 -3
- package/dist/op/op-waves-run.d.ts +62 -1
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +190 -11
- package/dist/op/op-waves.d.ts +55 -3
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +63 -8
- package/dist/op/schedule-overdue.d.ts +57 -0
- package/dist/op/schedule-overdue.d.ts.map +1 -0
- package/dist/op/schedule-overdue.js +138 -0
- package/dist/override-gate.d.ts +2 -2
- package/dist/override-gate.d.ts.map +1 -1
- package/dist/override-gate.js +1 -1
- package/dist/pr-forge.d.ts +36 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +82 -0
- package/dist/pr-loop.d.ts +90 -1
- package/dist/pr-loop.d.ts.map +1 -1
- package/dist/pr-loop.js +77 -3
- package/dist/pr-post.d.ts +72 -0
- package/dist/pr-post.d.ts.map +1 -0
- package/dist/pr-post.js +134 -0
- package/dist/wave-blocked.d.ts +79 -0
- package/dist/wave-blocked.d.ts.map +1 -0
- package/dist/wave-blocked.js +245 -0
- package/dist/wave-engine.d.ts +6 -0
- package/dist/wave-engine.d.ts.map +1 -1
- package/dist/wave-engine.js +2 -0
- package/dist/wave-runtime.mjs +242 -242
- package/dist/workspace/__fixtures__/two-member-workspace.d.ts +1 -0
- package/dist/workspace/__fixtures__/two-member-workspace.d.ts.map +1 -1
- package/dist/workspace/__fixtures__/two-member-workspace.js +1 -1
- package/dist/workspace/ci-branches.d.ts +51 -0
- package/dist/workspace/ci-branches.d.ts.map +1 -0
- package/dist/workspace/ci-branches.js +69 -0
- package/dist/workspace/ci-cloud-identity.d.ts +11 -0
- package/dist/workspace/ci-cloud-identity.d.ts.map +1 -0
- package/dist/workspace/ci-cloud-identity.js +24 -0
- package/dist/workspace/ci-locks.d.ts +12 -0
- package/dist/workspace/ci-locks.d.ts.map +1 -0
- package/dist/workspace/ci-locks.js +6 -0
- package/dist/workspace/ci-run.d.ts +17 -1
- package/dist/workspace/ci-run.d.ts.map +1 -1
- package/dist/workspace/ci-run.js +64 -3
- package/dist/workspace/declaration.d.ts +63 -0
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +72 -1
- package/dist/workspace/declaration.schema.json +147 -0
- package/dist/workspace/identity-gate-rule.d.ts +1 -1
- package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
- package/dist/workspace/identity-gate-rule.js +1 -1
- package/dist/workspace/identity.d.ts +1 -1
- package/dist/workspace/identity.d.ts.map +1 -1
- package/dist/workspace/lineage-upgrade.d.ts.map +1 -1
- package/dist/workspace/lineage-upgrade.js +8 -5
- package/dist/workspace/member-pipeline.d.ts +6 -0
- package/dist/workspace/member-pipeline.d.ts.map +1 -1
- package/dist/workspace/member-pipeline.js +23 -0
- package/dist/workspace/pr-report.schema.json +73 -2
- package/dist/workspace/security.d.ts.map +1 -1
- package/dist/workspace/security.js +4 -0
- package/dist/workspace/status-gates.d.ts +3 -2
- package/dist/workspace/status-gates.d.ts.map +1 -1
- package/dist/workspace/status-gates.js +8 -7
- package/dist/workspace/status.d.ts.map +1 -1
- package/dist/workspace/status.js +4 -1
- package/dist/workspace/trust/seal.d.ts +2 -2
- package/dist/workspace/trust/seal.d.ts.map +1 -1
- package/dist/workspace/trust/seal.js +2 -2
- package/package.json +1 -1
- package/src/__fixtures__/oidc-emulator.ts +118 -0
- package/src/ci-handover.test.ts +209 -0
- package/src/ci-handover.ts +237 -0
- package/src/ci-identity.test.ts +201 -0
- package/src/ci-identity.ts +310 -0
- package/src/cli/handlers/approve.ts +18 -5
- package/src/cli/handlers/build.ts +15 -1
- package/src/cli/handlers/fan-out.ts +17 -4
- package/src/cli/handlers/gate-resume.ts +16 -2
- package/src/cli/handlers/lock.test.ts +98 -0
- package/src/cli/handlers/lock.ts +202 -0
- package/src/cli/handlers/operator.test.ts +3 -1
- package/src/cli/handlers/pr-env.ts +462 -0
- package/src/cli/handlers/pr-waves-blocked.test.ts +247 -0
- package/src/cli/handlers/pr.test.ts +184 -0
- package/src/cli/handlers/pr.ts +496 -59
- package/src/cli/handlers/promote.ts +9 -0
- package/src/cli/handlers/query.ts +78 -0
- package/src/cli/main.ts +41 -2
- package/src/cli/parse-args.ts +23 -2
- package/src/cli/registry.ts +12 -2
- package/src/components/fan-out-run.ts +39 -2
- package/src/components/fan-out-waves.test.ts +45 -1
- package/src/components/pr-environment.test.ts +249 -0
- package/src/components/pr-environment.ts +538 -0
- package/src/components/pr-hooks.test.ts +118 -0
- package/src/components/pr-hooks.ts +157 -0
- package/src/components/pr-pipeline.ts +130 -5
- package/src/components/pr-policy.test.ts +145 -0
- package/src/components/pr-policy.ts +211 -0
- package/src/components/pr-run.ts +5 -2
- package/src/gate-decision-bundle.test.ts +4 -3
- package/src/gate-decision.ts +39 -2
- package/src/gate-policy-bundle.test.ts +28 -0
- package/src/gate-policy.test.ts +162 -0
- package/src/gate-policy.ts +298 -0
- package/src/lifecycle/gate-checkpoint.ts +1 -1
- package/src/{workspace/trust → lifecycle}/gate-seal.ts +1 -1
- package/src/lifecycle/query.test.ts +91 -0
- package/src/lifecycle/query.ts +315 -0
- package/src/lifecycle/run-ledger.ts +18 -0
- package/src/lifecycle/target-lock.test.ts +195 -0
- package/src/lifecycle/target-lock.ts +347 -0
- package/src/op/activities/activity-contracts.ts +31 -0
- package/src/op/activities/index.ts +6 -0
- package/src/op/activities/review-agent.test.ts +240 -0
- package/src/op/activities/review-agent.ts +355 -0
- package/src/op/builders.ts +13 -0
- package/src/op/cron.ts +44 -0
- package/src/op/gate-alias.test.ts +2 -2
- package/src/op/gate-approval.test.ts +30 -9
- package/src/op/gate-approval.ts +23 -26
- package/src/op/gate-quorum.test.ts +139 -0
- package/src/op/gate-quorum.ts +248 -0
- package/src/op/gate-resume.ts +6 -3
- package/src/op/gate-review.ts +1 -1
- package/src/op/gate.ts +64 -23
- package/src/op/index.ts +13 -1
- package/src/op/local-executor.ts +9 -2
- package/src/op/op-waves-hook-targets.test.ts +126 -0
- package/src/op/op-waves-policy-hold.test.ts +66 -0
- package/src/op/op-waves-quorum.test.ts +101 -0
- package/src/op/op-waves-run.ts +233 -11
- package/src/op/op-waves.ts +83 -10
- package/src/op/schedule-overdue.test.ts +220 -0
- package/src/op/schedule-overdue.ts +161 -0
- package/src/override-gate-bundle.test.ts +1 -1
- package/src/override-gate.ts +2 -2
- package/src/pr-forge-bundle.test.ts +2 -2
- package/src/pr-forge.test.ts +33 -0
- package/src/pr-forge.ts +114 -0
- package/src/pr-loop-bundle.test.ts +2 -2
- package/src/pr-loop.test.ts +58 -0
- package/src/pr-loop.ts +146 -4
- package/src/pr-post.test.ts +141 -0
- package/src/pr-post.ts +159 -0
- package/src/wave-blocked-bundle.test.ts +25 -0
- package/src/wave-blocked.test.ts +146 -0
- package/src/wave-blocked.ts +271 -0
- package/src/wave-engine.ts +8 -0
- package/src/workspace/__fixtures__/two-member-workspace.ts +2 -2
- package/src/workspace/ci-branches.test.ts +62 -0
- package/src/workspace/ci-branches.ts +79 -0
- package/src/workspace/ci-cloud-identity.test.ts +53 -0
- package/src/workspace/ci-cloud-identity.ts +23 -0
- package/src/workspace/ci-locks.ts +16 -0
- package/src/workspace/ci-run-index.test.ts +2 -1
- package/src/workspace/ci-run.test.ts +107 -8
- package/src/workspace/ci-run.ts +72 -4
- package/src/workspace/declaration.schema.json +147 -0
- package/src/workspace/declaration.test.ts +76 -0
- package/src/workspace/declaration.ts +134 -2
- package/src/workspace/identity-gate-rule.ts +1 -1
- package/src/workspace/identity.ts +1 -1
- package/src/workspace/lineage-upgrade.ts +11 -8
- package/src/workspace/member-pipeline.test.ts +29 -0
- package/src/workspace/member-pipeline.ts +30 -0
- package/src/workspace/pr-report.schema.json +73 -2
- package/src/workspace/security.ts +4 -0
- package/src/workspace/status-gates.ts +9 -6
- package/src/workspace/status.ts +4 -1
- package/src/workspace/trust/gate-seal.test.ts +1 -1
- package/src/workspace/trust/seal.ts +2 -2
- package/dist/workspace/trust/gate-seal.d.ts.map +0 -1
- /package/dist/{workspace/trust → lifecycle}/gate-seal.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-decision.d.ts","sourceRoot":"","sources":["../src/gate-decision.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gate-decision.d.ts","sourceRoot":"","sources":["../src/gate-decision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAWH,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAmB,KAAK,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAQnG,OAAO,EAA+B,KAAK,UAAU,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E,UAAU,CAAC;IAAC,GAAG,EAAE,QAAQ,CAAC;IAAC,UAAU,EAAE,oBAAoB,CAAA;CAAE,GACvE;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;CAAE,GAC1E;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,wHAAwH;IACxH,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,yGAAyG;IACzG,UAAU,CAAC,EAAE,oBAAoB,CAAC;IAClC,iFAAiF;IACjF,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,yDAAyD;IACzD,MAAM,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IAClC,wHAAwH;IACxH,KAAK,CAAC,EAAE,oBAAoB,CAAC;CAC9B,CAAC;AAIN;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,oBAAoB,CA6CjF"}
|
package/dist/gate-decision.js
CHANGED
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
* counts for nothing, as terragucci's wave gate has it: the caller hands in
|
|
28
28
|
* the lines of `_gates/<op>/applied.jsonl` ({@link parseAppliedGateLines}).
|
|
29
29
|
*
|
|
30
|
+
* Approval rules (#4290), a quorum as a list of `{ targets, count, roles,
|
|
31
|
+
* notAuthor }`, are judged with `./op/gate-quorum.ts`, re-exported here:
|
|
32
|
+
* {@link trustRolesAt} and {@link gateSignersAt} read what
|
|
33
|
+
* `trustQuorumJudge` judges by, at base.
|
|
34
|
+
*
|
|
30
35
|
* The module reads the ledger lines and the review it is handed; reading
|
|
31
36
|
* them is the caller's. It imports no TypeScript, esbuild, zod, ajv, lint,
|
|
32
37
|
* fold or codegen module, no package's code, and none of chant's git ledger
|
|
@@ -41,17 +46,18 @@ import { join, posix } from "node:path";
|
|
|
41
46
|
import { isPendingGateExpired, latestPendingGate, latestResolutionForPlan, } from "./lifecycle/gate-ledger-select.js";
|
|
42
47
|
import { samePlanDigest } from "./lifecycle/plan-digest.js";
|
|
43
48
|
import { isApprovalSpent } from "./lifecycle/gate-applied.js";
|
|
44
|
-
import { gateSealRefusal } from "./
|
|
49
|
+
import { gateSealRefusal } from "./lifecycle/gate-seal.js";
|
|
45
50
|
import { DEFAULT_SIGNERS_PATH, TRUST_CONFIG_PATH, parseAllowedSigners, trustConfigProblems, } from "./workspace/trust/trust-files.js";
|
|
46
51
|
import { parseJsonText } from "./workspace/jsonc.js";
|
|
47
52
|
import { CORE_CLASSES, admitApprover } from "./workspace/identity-gate-rule.js";
|
|
48
53
|
import { diskFiles, findInstalledPackage, mergePinClasses, parseClassDataByHand, readClassFiles } from "./workspace/class-data.js";
|
|
49
54
|
export { GATE_APPROVAL_SOURCES } from "./op/op-waves.js";
|
|
50
55
|
export { isPendingGateExpired, latestPendingGate, latestResolutionForPlan, latestResolutionSince, } from "./lifecycle/gate-ledger-select.js";
|
|
51
|
-
export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealRefusal, gateSealVersion, sealedFieldsOf, sshKeyFingerprint, verifySshSignatureWith, } from "./
|
|
56
|
+
export { GATE_SEAL_NAMESPACE, gateSealPayload, gateSealRefusal, gateSealVersion, sealedFieldsOf, sshKeyFingerprint, verifySshSignatureWith, } from "./lifecycle/gate-seal.js";
|
|
52
57
|
export { DEFAULT_SIGNERS_PATH, TRUST_CONFIG_PATH, parseAllowedSigners, trustConfigProblems, } from "./workspace/trust/trust-files.js";
|
|
53
58
|
export { CORE_CLASSES, admitApprover, grantedClasses, } from "./workspace/identity-gate-rule.js";
|
|
54
59
|
export { appliedGateApplies, appliedGatePath, isApprovalSpent, parseAppliedGateLines, } from "./lifecycle/gate-applied.js";
|
|
60
|
+
export { quorumNeed, quorumProblems, quorumRuleLine, quorumRuleProgress, quorumRules, quorumRulesFor, quorumWaiting, rolesOf, ruleNeedsProof, samePrincipal, targetGlobMatch, trustQuorumJudge, UNPROVEN_JUDGE, } from "./op/gate-quorum.js";
|
|
55
61
|
// ── reading at base ──────────────────────────────────────────────────────
|
|
56
62
|
function git(repo, args) {
|
|
57
63
|
return spawnSync("git", args, { cwd: repo, encoding: "utf-8" });
|
|
@@ -118,6 +124,15 @@ function trustAt(repo, base) {
|
|
|
118
124
|
export function gateSignersAt(repo, base) {
|
|
119
125
|
return trustAt(repo, base).signers;
|
|
120
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* The role grants of `.chant/trust.json` at `base` (#4290): role name to the
|
|
129
|
+
* principals that hold it, as chant reads them. A missing file gives none,
|
|
130
|
+
* and so does one that is not valid, which turns chant's trust off.
|
|
131
|
+
* {@link trustQuorumJudge} takes them with {@link gateSignersAt}'s signers.
|
|
132
|
+
*/
|
|
133
|
+
export function trustRolesAt(repo, base) {
|
|
134
|
+
return trustAt(repo, base).roles;
|
|
135
|
+
}
|
|
121
136
|
/** The declaration at `base`, parsed, or null when there is none. Throws when it cannot be parsed. */
|
|
122
137
|
function declarationAt(repo, base) {
|
|
123
138
|
for (const file of ["chant.workspace.json", "chant.workspace.jsonc"]) {
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate-time policy (#4294): a policy engine run over a plan's change set,
|
|
3
|
+
* with the policy read at base, whose rules deny a plan or hold it for a
|
|
4
|
+
* person.
|
|
5
|
+
*
|
|
6
|
+
* The engine is any command that prints conftest's JSON result
|
|
7
|
+
* (`conftest test --output json`) or OPA's (`opa eval --format json`). The
|
|
8
|
+
* rules are counted as conftest counts them:
|
|
9
|
+
*
|
|
10
|
+
* - `deny`, `violation`, `deny_<name>` and `violation_<name>` deny the plan.
|
|
11
|
+
* A denied plan applies only under an override that counts
|
|
12
|
+
* (`./override-gate.ts`), on top of the gate's own approval.
|
|
13
|
+
* - `hold` and `hold_<name>` hold the plan: it waits for a person's approval
|
|
14
|
+
* of its digest, even where the gate would let it through without one.
|
|
15
|
+
* conftest runs only deny and warn rules, so a hold needs the opa shape.
|
|
16
|
+
* - `warn` and `warn_<name>` are advice. They fail nothing.
|
|
17
|
+
*
|
|
18
|
+
* There is no outcome that lets a plan apply with nobody approving it: a
|
|
19
|
+
* non-empty change set always waits for a person (ws-104, ws-080). A rule
|
|
20
|
+
* named `allow_unattended` is read as no rule at all.
|
|
21
|
+
*
|
|
22
|
+
* A policy that cannot run, or gives no answer this module can read, is an
|
|
23
|
+
* error, and the caller stops the apply: no path waives a policy.
|
|
24
|
+
*
|
|
25
|
+
* Like `./override-gate.ts` this module reads what it is handed and imports
|
|
26
|
+
* only node built-ins, so a product can bundle it into one file
|
|
27
|
+
* (`gate-policy-bundle.test.ts`). The pull-request jobs' use of it is in
|
|
28
|
+
* `./components/pr-policy.ts`.
|
|
29
|
+
*/
|
|
30
|
+
/** The result shapes chant reads: conftest's and OPA's. */
|
|
31
|
+
export declare const GATE_POLICY_ENGINES: readonly ["conftest", "opa"];
|
|
32
|
+
export type GatePolicyEngine = (typeof GATE_POLICY_ENGINES)[number];
|
|
33
|
+
/** Where the policy is read when the settings name no `path`. */
|
|
34
|
+
export declare const DEFAULT_POLICY_PATH = "policy";
|
|
35
|
+
/** The settings of one policy step, read at base. */
|
|
36
|
+
export interface GatePolicySettings {
|
|
37
|
+
/** The result shape, and the default command. Default `conftest`. */
|
|
38
|
+
engine?: GatePolicyEngine;
|
|
39
|
+
/** The policy directory, relative to the declaration at base. Default {@link DEFAULT_POLICY_PATH}. */
|
|
40
|
+
path?: string;
|
|
41
|
+
/** The package to read. conftest default: every namespace. opa default: `main`. */
|
|
42
|
+
namespace?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The command to run instead of the engine's own, as argv. `{policy}` is
|
|
45
|
+
* the policy directory exported from base and `{input}` the input file. It
|
|
46
|
+
* prints the result shape `engine` names.
|
|
47
|
+
*/
|
|
48
|
+
command?: string[];
|
|
49
|
+
}
|
|
50
|
+
/** A rule that matched, and what it said. */
|
|
51
|
+
export interface GatePolicyFinding {
|
|
52
|
+
/** `<package>.<rule>`, such as `main.deny_public_bucket`. */
|
|
53
|
+
rule: string;
|
|
54
|
+
message: string;
|
|
55
|
+
}
|
|
56
|
+
/** What an engine's answer holds. */
|
|
57
|
+
export interface GatePolicyFindings {
|
|
58
|
+
denials: GatePolicyFinding[];
|
|
59
|
+
holds: GatePolicyFinding[];
|
|
60
|
+
warnings: string[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* One policy check's outcome. `denied` wins over `held`. `error`: the
|
|
64
|
+
* policy did not run or gave no readable answer, and the apply stops.
|
|
65
|
+
*/
|
|
66
|
+
export interface GatePolicyVerdict {
|
|
67
|
+
result: "passed" | "denied" | "held" | "error";
|
|
68
|
+
engine: GatePolicyEngine;
|
|
69
|
+
denials: GatePolicyFinding[];
|
|
70
|
+
/** The ids of the rules that denied, sorted, each once: what an override names. */
|
|
71
|
+
rules: string[];
|
|
72
|
+
holds: GatePolicyFinding[];
|
|
73
|
+
warnings: string[];
|
|
74
|
+
error?: string;
|
|
75
|
+
}
|
|
76
|
+
export declare const DENY_RULE: RegExp;
|
|
77
|
+
export declare const WARN_RULE: RegExp;
|
|
78
|
+
export declare const HOLD_RULE: RegExp;
|
|
79
|
+
/** The findings in `conftest test --output json`. Undefined when it is not that shape. */
|
|
80
|
+
export declare function conftestFindings(stdout: string): GatePolicyFindings | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* The findings in `opa eval --format json data.<namespace>`. The query's
|
|
83
|
+
* value is the package: its rules are read by name. An array value is a
|
|
84
|
+
* deny set named after the query. A query that is undefined has no rule
|
|
85
|
+
* that matched. Undefined when the output is not that shape.
|
|
86
|
+
*/
|
|
87
|
+
export declare function opaFindings(stdout: string, namespace?: string): GatePolicyFindings | undefined;
|
|
88
|
+
/** A verdict from what the engine found. */
|
|
89
|
+
export declare function gatePolicyVerdict(engine: GatePolicyEngine, found: GatePolicyFindings): GatePolicyVerdict;
|
|
90
|
+
/** The argv one check runs: the settings' `command` with its placeholders filled, or the engine's own. */
|
|
91
|
+
export declare function gatePolicyArgv(settings: GatePolicySettings, at: {
|
|
92
|
+
policy: string;
|
|
93
|
+
input: string;
|
|
94
|
+
}): string[];
|
|
95
|
+
/** What one run of the engine printed and how it exited. `status` is null when it did not start. */
|
|
96
|
+
export interface GatePolicyRun {
|
|
97
|
+
status: number | null;
|
|
98
|
+
stdout: string;
|
|
99
|
+
stderr: string;
|
|
100
|
+
}
|
|
101
|
+
export type GatePolicyExec = (argv: string[], cwd: string) => GatePolicyRun;
|
|
102
|
+
/** Runs the engine with the job's environment. */
|
|
103
|
+
export declare const defaultGatePolicyExec: GatePolicyExec;
|
|
104
|
+
export interface CheckGatePolicyOptions {
|
|
105
|
+
settings: GatePolicySettings;
|
|
106
|
+
/** The input document, or its JSON text. */
|
|
107
|
+
input: unknown;
|
|
108
|
+
/** The policy directory, already exported from base. */
|
|
109
|
+
policyDir: string;
|
|
110
|
+
/** Where the engine runs. Default the policy directory. */
|
|
111
|
+
cwd?: string;
|
|
112
|
+
exec?: GatePolicyExec;
|
|
113
|
+
}
|
|
114
|
+
/** Run the engine once over `input` and read its answer. */
|
|
115
|
+
export declare function checkGatePolicy(options: CheckGatePolicyOptions): GatePolicyVerdict;
|
|
116
|
+
/** The part of a tree a policy is exported from: a workspace tree at base fits. */
|
|
117
|
+
export interface GatePolicyTree {
|
|
118
|
+
stat(path: string): "file" | "dir" | undefined;
|
|
119
|
+
list(path: string): Array<{
|
|
120
|
+
name: string;
|
|
121
|
+
type: "file" | "dir";
|
|
122
|
+
}> | undefined;
|
|
123
|
+
read(path: string): string;
|
|
124
|
+
bytes?(path: string): Uint8Array;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Copy the policy directory `path` out of `tree` (the tree at base) into a
|
|
128
|
+
* new temporary directory, so the engine reads the policy as the base has
|
|
129
|
+
* it and never the change's copy. Returns the directory and how to remove
|
|
130
|
+
* it, or the reason there is no policy to read.
|
|
131
|
+
*/
|
|
132
|
+
export declare function exportGatePolicy(tree: GatePolicyTree, path: string): {
|
|
133
|
+
dir: string;
|
|
134
|
+
cleanup: () => void;
|
|
135
|
+
} | {
|
|
136
|
+
error: string;
|
|
137
|
+
};
|
|
138
|
+
/** The settings, checked. Throws with what is wrong. `where` names them, such as `ci.policy`. */
|
|
139
|
+
export declare function assertGatePolicySettings(where: string, raw: unknown): asserts raw is GatePolicySettings;
|
|
140
|
+
//# sourceMappingURL=gate-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate-policy.d.ts","sourceRoot":"","sources":["../src/gate-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAOH,2DAA2D;AAC3D,eAAO,MAAM,mBAAmB,YAAI,UAAU,EAAE,KAAK,CAAU,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAE5C,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,sGAAsG;IACtG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qCAAqC;AACrC,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE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AAsB;IACrC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,4CAA4C;IAC5C,KAAK,EAAE,OAAO,CAAC;IACf,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAID,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,iBAAiB,CAkBlF;AAED,mFAAmF;AACnF,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;IAC/C,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAA;KAAE,CAAC,GAAG,SAAS,CAAC;IAC9E,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,KAAK,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAClC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CA0B7H;AAED,iGAAiG;AACjG,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,IAAI,kBAAkB,CAiBvG"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gate-time policy (#4294): a policy engine run over a plan's change set,
|
|
3
|
+
* with the policy read at base, whose rules deny a plan or hold it for a
|
|
4
|
+
* person.
|
|
5
|
+
*
|
|
6
|
+
* The engine is any command that prints conftest's JSON result
|
|
7
|
+
* (`conftest test --output json`) or OPA's (`opa eval --format json`). The
|
|
8
|
+
* rules are counted as conftest counts them:
|
|
9
|
+
*
|
|
10
|
+
* - `deny`, `violation`, `deny_<name>` and `violation_<name>` deny the plan.
|
|
11
|
+
* A denied plan applies only under an override that counts
|
|
12
|
+
* (`./override-gate.ts`), on top of the gate's own approval.
|
|
13
|
+
* - `hold` and `hold_<name>` hold the plan: it waits for a person's approval
|
|
14
|
+
* of its digest, even where the gate would let it through without one.
|
|
15
|
+
* conftest runs only deny and warn rules, so a hold needs the opa shape.
|
|
16
|
+
* - `warn` and `warn_<name>` are advice. They fail nothing.
|
|
17
|
+
*
|
|
18
|
+
* There is no outcome that lets a plan apply with nobody approving it: a
|
|
19
|
+
* non-empty change set always waits for a person (ws-104, ws-080). A rule
|
|
20
|
+
* named `allow_unattended` is read as no rule at all.
|
|
21
|
+
*
|
|
22
|
+
* A policy that cannot run, or gives no answer this module can read, is an
|
|
23
|
+
* error, and the caller stops the apply: no path waives a policy.
|
|
24
|
+
*
|
|
25
|
+
* Like `./override-gate.ts` this module reads what it is handed and imports
|
|
26
|
+
* only node built-ins, so a product can bundle it into one file
|
|
27
|
+
* (`gate-policy-bundle.test.ts`). The pull-request jobs' use of it is in
|
|
28
|
+
* `./components/pr-policy.ts`.
|
|
29
|
+
*/
|
|
30
|
+
import { spawnSync } from "node:child_process";
|
|
31
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
32
|
+
import { tmpdir } from "node:os";
|
|
33
|
+
import { join } from "node:path";
|
|
34
|
+
/** The result shapes chant reads: conftest's and OPA's. */
|
|
35
|
+
export const GATE_POLICY_ENGINES = ["conftest", "opa"];
|
|
36
|
+
/** Where the policy is read when the settings name no `path`. */
|
|
37
|
+
export const DEFAULT_POLICY_PATH = "policy";
|
|
38
|
+
export const DENY_RULE = /^(deny|violation)(_[A-Za-z0-9]+)*$/;
|
|
39
|
+
export const WARN_RULE = /^warn(_[A-Za-z0-9]+)*$/;
|
|
40
|
+
export const HOLD_RULE = /^hold(_[A-Za-z0-9]+)*$/;
|
|
41
|
+
const ruleId = (query) => query.replace(/^data\./, "");
|
|
42
|
+
function messageOf(v) {
|
|
43
|
+
if (typeof v === "string")
|
|
44
|
+
return v;
|
|
45
|
+
if (v !== null && typeof v === "object" && typeof v.msg === "string")
|
|
46
|
+
return v.msg;
|
|
47
|
+
return JSON.stringify(v);
|
|
48
|
+
}
|
|
49
|
+
/** The findings in `conftest test --output json`. Undefined when it is not that shape. */
|
|
50
|
+
export function conftestFindings(stdout) {
|
|
51
|
+
let results;
|
|
52
|
+
try {
|
|
53
|
+
results = JSON.parse(stdout);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
if (!Array.isArray(results))
|
|
59
|
+
return undefined;
|
|
60
|
+
const out = { denials: [], holds: [], warnings: [] };
|
|
61
|
+
for (const r of results) {
|
|
62
|
+
if (r === null || typeof r !== "object")
|
|
63
|
+
return undefined;
|
|
64
|
+
for (const f of r.failures ?? []) {
|
|
65
|
+
// conftest names the query that denied in the failure's metadata; an older one gives only the namespace.
|
|
66
|
+
const rule = typeof f.metadata?.query === "string" ? ruleId(f.metadata.query) : `${r.namespace ?? "main"}.deny`;
|
|
67
|
+
out.denials.push({ rule, message: messageOf(f.msg) });
|
|
68
|
+
}
|
|
69
|
+
for (const w of r.warnings ?? [])
|
|
70
|
+
out.warnings.push(messageOf(w.msg));
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
/** The rules of one package's value, and with `nested` its child packages one level down. */
|
|
75
|
+
function packageFindings(doc, out, pkg, nested) {
|
|
76
|
+
for (const [name, value] of Object.entries(doc).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {
|
|
77
|
+
// A rule matches when its value is true, a message, or a non-empty set of messages.
|
|
78
|
+
const said = Array.isArray(value) ? value.map(messageOf) : value === true ? [name] : typeof value === "string" && value !== "" ? [value] : [];
|
|
79
|
+
if (DENY_RULE.test(name)) {
|
|
80
|
+
for (const message of said)
|
|
81
|
+
out.denials.push({ rule: `${pkg}.${name}`, message });
|
|
82
|
+
}
|
|
83
|
+
else if (HOLD_RULE.test(name)) {
|
|
84
|
+
for (const message of said)
|
|
85
|
+
out.holds.push({ rule: `${pkg}.${name}`, message });
|
|
86
|
+
}
|
|
87
|
+
else if (WARN_RULE.test(name)) {
|
|
88
|
+
out.warnings.push(...said);
|
|
89
|
+
}
|
|
90
|
+
else if (nested && value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
91
|
+
packageFindings(value, out, `${pkg}.${name}`, false);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The findings in `opa eval --format json data.<namespace>`. The query's
|
|
97
|
+
* value is the package: its rules are read by name. An array value is a
|
|
98
|
+
* deny set named after the query. A query that is undefined has no rule
|
|
99
|
+
* that matched. Undefined when the output is not that shape.
|
|
100
|
+
*/
|
|
101
|
+
export function opaFindings(stdout, namespace = "main") {
|
|
102
|
+
let parsed;
|
|
103
|
+
try {
|
|
104
|
+
parsed = JSON.parse(stdout);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed) || parsed.errors !== undefined)
|
|
110
|
+
return undefined;
|
|
111
|
+
const value = parsed.result?.[0]?.expressions?.[0]?.value;
|
|
112
|
+
const out = { denials: [], holds: [], warnings: [] };
|
|
113
|
+
if (value === undefined)
|
|
114
|
+
return out;
|
|
115
|
+
if (Array.isArray(value)) {
|
|
116
|
+
out.denials.push(...value.map((v) => ({ rule: namespace, message: messageOf(v) })));
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
if (value === null || typeof value !== "object")
|
|
120
|
+
return undefined;
|
|
121
|
+
packageFindings(value, out, namespace, true);
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
/** A verdict from what the engine found. */
|
|
125
|
+
export function gatePolicyVerdict(engine, found) {
|
|
126
|
+
const rules = [...new Set(found.denials.map((d) => d.rule))].sort();
|
|
127
|
+
return {
|
|
128
|
+
result: found.denials.length > 0 ? "denied" : found.holds.length > 0 ? "held" : "passed",
|
|
129
|
+
engine,
|
|
130
|
+
denials: found.denials,
|
|
131
|
+
rules,
|
|
132
|
+
holds: found.holds,
|
|
133
|
+
warnings: found.warnings,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const errorVerdict = (engine, error) => ({ result: "error", engine, denials: [], rules: [], holds: [], warnings: [], error });
|
|
137
|
+
/** The argv one check runs: the settings' `command` with its placeholders filled, or the engine's own. */
|
|
138
|
+
export function gatePolicyArgv(settings, at) {
|
|
139
|
+
if (settings.command)
|
|
140
|
+
return settings.command.map((a) => a.replaceAll("{policy}", at.policy).replaceAll("{input}", at.input));
|
|
141
|
+
if ((settings.engine ?? "conftest") === "opa") {
|
|
142
|
+
return ["opa", "eval", "--format", "json", "--data", at.policy, "--input", at.input, `data.${settings.namespace ?? "main"}`];
|
|
143
|
+
}
|
|
144
|
+
return ["conftest", "test", "--no-color", "--output", "json", "--policy", at.policy, ...(settings.namespace ? ["--namespace", settings.namespace] : ["--all-namespaces"]), at.input];
|
|
145
|
+
}
|
|
146
|
+
/** Runs the engine with the job's environment. */
|
|
147
|
+
export const defaultGatePolicyExec = (argv, cwd) => {
|
|
148
|
+
const r = spawnSync(argv[0], argv.slice(1), { cwd, encoding: "utf-8", maxBuffer: 64 * 1024 * 1024 });
|
|
149
|
+
return { status: r.error ? null : r.status, stdout: r.stdout ?? "", stderr: `${r.stderr ?? ""}${r.error ? r.error.message : ""}` };
|
|
150
|
+
};
|
|
151
|
+
const tail = (text) => text.trim().split("\n").slice(-3).join(" ");
|
|
152
|
+
/** Run the engine once over `input` and read its answer. */
|
|
153
|
+
export function checkGatePolicy(options) {
|
|
154
|
+
const { settings } = options;
|
|
155
|
+
const engine = settings.engine ?? "conftest";
|
|
156
|
+
const work = mkdtempSync(join(tmpdir(), "chant-policy-input-"));
|
|
157
|
+
try {
|
|
158
|
+
const file = join(work, "input.json");
|
|
159
|
+
writeFileSync(file, typeof options.input === "string" ? options.input : JSON.stringify(options.input));
|
|
160
|
+
const argv = gatePolicyArgv(settings, { policy: options.policyDir, input: file });
|
|
161
|
+
const r = (options.exec ?? defaultGatePolicyExec)(argv, options.cwd ?? options.policyDir);
|
|
162
|
+
if (r.status === null)
|
|
163
|
+
return errorVerdict(engine, `${argv[0]} did not run: ${tail(r.stderr) || "no such command"}`);
|
|
164
|
+
const found = engine === "opa" ? opaFindings(r.stdout, settings.namespace ?? "main") : conftestFindings(r.stdout);
|
|
165
|
+
if (found === undefined)
|
|
166
|
+
return errorVerdict(engine, `${argv[0]} gave no ${engine} result (exit ${r.status}): ${tail(r.stderr || r.stdout)}`);
|
|
167
|
+
// conftest exits 1 on a denial and 2 or more when it could not run; opa exits 0 on a query it ran.
|
|
168
|
+
if (found.denials.length === 0 && r.status !== 0)
|
|
169
|
+
return errorVerdict(engine, `${argv[0]} exited ${r.status}: ${tail(r.stderr)}`);
|
|
170
|
+
return gatePolicyVerdict(engine, found);
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
rmSync(work, { recursive: true, force: true });
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Copy the policy directory `path` out of `tree` (the tree at base) into a
|
|
178
|
+
* new temporary directory, so the engine reads the policy as the base has
|
|
179
|
+
* it and never the change's copy. Returns the directory and how to remove
|
|
180
|
+
* it, or the reason there is no policy to read.
|
|
181
|
+
*/
|
|
182
|
+
export function exportGatePolicy(tree, path) {
|
|
183
|
+
const root = path.replace(/^\.\/+/, "").replace(/\/+$/, "");
|
|
184
|
+
const kind = root === "" || root === "." ? "dir" : tree.stat(root);
|
|
185
|
+
if (kind === undefined)
|
|
186
|
+
return { error: `the policy directory ${path} does not exist at base` };
|
|
187
|
+
const dir = mkdtempSync(join(tmpdir(), "chant-policy-"));
|
|
188
|
+
const cleanup = () => rmSync(dir, { recursive: true, force: true });
|
|
189
|
+
const copy = (from, to) => {
|
|
190
|
+
for (const entry of tree.list(from) ?? []) {
|
|
191
|
+
const src = from === "" || from === "." ? entry.name : `${from}/${entry.name}`;
|
|
192
|
+
const dest = join(to, entry.name);
|
|
193
|
+
if (entry.type === "dir") {
|
|
194
|
+
mkdirSync(dest, { recursive: true });
|
|
195
|
+
copy(src, dest);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
writeFileSync(dest, tree.bytes ? tree.bytes(src) : tree.read(src));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
try {
|
|
203
|
+
if (kind === "file")
|
|
204
|
+
writeFileSync(join(dir, root.split("/").pop()), tree.bytes ? tree.bytes(root) : tree.read(root));
|
|
205
|
+
else
|
|
206
|
+
copy(root, dir);
|
|
207
|
+
}
|
|
208
|
+
catch (err) {
|
|
209
|
+
cleanup();
|
|
210
|
+
return { error: `the policy at ${path} could not be read at base: ${err instanceof Error ? err.message : String(err)}` };
|
|
211
|
+
}
|
|
212
|
+
return { dir, cleanup };
|
|
213
|
+
}
|
|
214
|
+
/** The settings, checked. Throws with what is wrong. `where` names them, such as `ci.policy`. */
|
|
215
|
+
export function assertGatePolicySettings(where, raw) {
|
|
216
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
217
|
+
throw new Error(`${where} must be { engine?, path?, namespace?, command? }`);
|
|
218
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
219
|
+
if (key === "engine") {
|
|
220
|
+
if (!GATE_POLICY_ENGINES.includes(value))
|
|
221
|
+
throw new Error(`${where}.engine must be ${GATE_POLICY_ENGINES.join(" or ")}, the result shape the command prints`);
|
|
222
|
+
}
|
|
223
|
+
else if (key === "path" || key === "namespace") {
|
|
224
|
+
if (typeof value !== "string" || value.trim() === "")
|
|
225
|
+
throw new Error(`${where}.${key} must be a non-empty string`);
|
|
226
|
+
if (key === "path" && (value.startsWith("/") || value.split("/").includes("..")))
|
|
227
|
+
throw new Error(`${where}.path must be a directory inside the workspace, relative to its declaration`);
|
|
228
|
+
}
|
|
229
|
+
else if (key === "command") {
|
|
230
|
+
if (!Array.isArray(value) || value.length === 0 || !value.every((a) => typeof a === "string" && a !== ""))
|
|
231
|
+
throw new Error(`${where}.command must be argv, a non-empty list of strings`);
|
|
232
|
+
if (!value.some((a) => a.includes("{input}")))
|
|
233
|
+
throw new Error(`${where}.command must pass the input file as {input}`);
|
|
234
|
+
}
|
|
235
|
+
else if (key === "outcomes" || key === "allow_unattended" || key === "allowUnattended") {
|
|
236
|
+
throw new Error(`${where}.${key}: chant's policy step denies and holds only; a non-empty plan always waits for a person (ws-104), so there is no unattended outcome`);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
throw new Error(`${where}.${key} is not a setting; the settings are engine, path, namespace and command`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* The run writes the file just before it appends the pending fact, and puts
|
|
7
7
|
* the file's digest on that fact as `checkpointDigest`. `chant approve`
|
|
8
8
|
* copies the digest onto the approval, the way it copies the plan digest, and
|
|
9
|
-
* a seal covers it (
|
|
9
|
+
* a seal covers it (`./gate-seal.ts`). A later run that
|
|
10
10
|
* resumes at the gate reads the file back and checks it against the digest
|
|
11
11
|
* the approver saw, so a value pushed onto the branch after the approval is
|
|
12
12
|
* refused rather than carried into the steps after the gate.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* The run writes the file just before it appends the pending fact, and puts
|
|
7
7
|
* the file's digest on that fact as `checkpointDigest`. `chant approve`
|
|
8
8
|
* copies the digest onto the approval, the way it copies the plan digest, and
|
|
9
|
-
* a seal covers it (
|
|
9
|
+
* a seal covers it (`./gate-seal.ts`). A later run that
|
|
10
10
|
* resumes at the gate reads the file back and checks it against the digest
|
|
11
11
|
* the approver saw, so a value pushed onto the branch after the approval is
|
|
12
12
|
* refused rather than carried into the steps after the gate.
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* signers line with no `no-touch-required` option (which the signers parser
|
|
18
18
|
* does not accept). An RSA signature over SHA-1 does not verify.
|
|
19
19
|
*/
|
|
20
|
-
import type { Signer } from "
|
|
20
|
+
import type { Signer } from "../workspace/trust/trust-files.js";
|
|
21
21
|
/**
|
|
22
22
|
* The ssh signature namespace of a gate approval's seal (#3163, ws-080), so a
|
|
23
23
|
* verdict, record or commit signature can't stand in for one.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate-seal.d.ts","sourceRoot":"","sources":["../../src/lifecycle/gate-seal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAEhD,kIAAkI;AAClI,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iGAAiG;IACjG,WAAW,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACzF,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;GAKG;AACH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;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,kBAAkB,GAAG,MAAM,GAAG,IAAI,CAmB1F"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { LedgerReadPort } from "./ledger-port.js";
|
|
2
|
+
/** The version of the table schema below. */
|
|
3
|
+
export declare const QUERY_SCHEMA_VERSION = 1;
|
|
4
|
+
/**
|
|
5
|
+
* Each table's columns, in order, with their SQLite type. A column named in
|
|
6
|
+
* the doc as JSON holds a JSON text, for `json_extract`. Every table starts
|
|
7
|
+
* with `member`: the workspace member whose ledger the row came from, or NULL
|
|
8
|
+
* for a project outside a workspace.
|
|
9
|
+
*/
|
|
10
|
+
export declare const QUERY_TABLES: {
|
|
11
|
+
/** One row per resource in each environment's newest snapshot. `attributes` is JSON. */
|
|
12
|
+
readonly resources: readonly [readonly ["member", "TEXT"], readonly ["env", "TEXT"], readonly ["stack", "TEXT"], readonly ["lexicon", "TEXT"], readonly ["name", "TEXT"], readonly ["type", "TEXT"], readonly ["physical_id", "TEXT"], readonly ["status", "TEXT"], readonly ["last_updated", "TEXT"], readonly ["ownership", "TEXT"], readonly ["attributes", "TEXT"], readonly ["git_sha", "TEXT"], readonly ["observed_at", "TEXT"]];
|
|
13
|
+
/** One row per snapshot file: what was observed, when, and how many resources it holds. */
|
|
14
|
+
readonly snapshots: readonly [readonly ["member", "TEXT"], readonly ["env", "TEXT"], readonly ["stack", "TEXT"], readonly ["lexicon", "TEXT"], readonly ["git_sha", "TEXT"], readonly ["observed_at", "TEXT"], readonly ["depth", "TEXT"], readonly ["resources", "INTEGER"], readonly ["unobserved", "INTEGER"]];
|
|
15
|
+
/** One row per Op run record. `labels` and `outcomes` are JSON. */
|
|
16
|
+
readonly runs: readonly [readonly ["member", "TEXT"], readonly ["id", "TEXT"], readonly ["op", "TEXT"], readonly ["env", "TEXT"], readonly ["started", "TEXT"], readonly ["ended", "TEXT"], readonly ["status", "TEXT"], readonly ["git_sha", "TEXT"], readonly ["forge", "TEXT"], readonly ["run_url", "TEXT"], readonly ["failure_code", "TEXT"], readonly ["failure_reason", "TEXT"], readonly ["failed_phase", "TEXT"], readonly ["gate", "TEXT"], readonly ["steward", "TEXT"], readonly ["labels", "TEXT"], readonly ["outcomes", "TEXT"]];
|
|
17
|
+
/** One row per gate ledger line: `kind` is `pending` or `resolution`. `signed` is 1 for a sealed approval. */
|
|
18
|
+
readonly gates: readonly [readonly ["member", "TEXT"], readonly ["op", "TEXT"], readonly ["gate", "TEXT"], readonly ["kind", "TEXT"], readonly ["timestamp", "TEXT"], readonly ["resolved_by", "TEXT"], readonly ["relayed_by", "TEXT"], readonly ["approver_kind", "TEXT"], readonly ["plan_digest", "TEXT"], readonly ["environment", "TEXT"], readonly ["release_digest", "TEXT"], readonly ["git_sha", "TEXT"], readonly ["run_id", "TEXT"], readonly ["url", "TEXT"], readonly ["note", "TEXT"], readonly ["expires_at", "TEXT"], readonly ["origin", "TEXT"], readonly ["empty", "INTEGER"], readonly ["signed", "INTEGER"]];
|
|
19
|
+
/** One row per deploy record in `<env>/releases.jsonl`. `promoted_from`, `restores` and `redeploys` are JSON. */
|
|
20
|
+
readonly deploys: readonly [readonly ["member", "TEXT"], readonly ["env", "TEXT"], readonly ["component", "TEXT"], readonly ["digest", "TEXT"], readonly ["git_sha", "TEXT"], readonly ["run_id", "TEXT"], readonly ["forge", "TEXT"], readonly ["run_url", "TEXT"], readonly ["timestamp", "TEXT"], readonly ["actor", "TEXT"], readonly ["approver", "TEXT"], readonly ["release_digest", "TEXT"], readonly ["digest_kind", "TEXT"], readonly ["promoted_from", "TEXT"], readonly ["restores", "TEXT"], readonly ["redeploys", "TEXT"]];
|
|
21
|
+
/** One row per release file whose content hashes to its digest. `envs` joins its targets' environments with commas; `artifacts` is JSON. */
|
|
22
|
+
readonly releases: readonly [readonly ["member", "TEXT"], readonly ["release_digest", "TEXT"], readonly ["release_member", "TEXT"], readonly ["git_sha", "TEXT"], readonly ["envs", "TEXT"], readonly ["artifacts", "TEXT"]];
|
|
23
|
+
/** One row per line of `_releases/cuts.jsonl`. `signed` is 1 for a signed cut. */
|
|
24
|
+
readonly cuts: readonly [readonly ["member", "TEXT"], readonly ["release_digest", "TEXT"], readonly ["label", "TEXT"], readonly ["actor", "TEXT"], readonly ["timestamp", "TEXT"], readonly ["run_id", "TEXT"], readonly ["forge", "TEXT"], readonly ["channel", "TEXT"], readonly ["signed", "INTEGER"], readonly ["composed_base", "TEXT"]];
|
|
25
|
+
};
|
|
26
|
+
export type QueryTable = keyof typeof QUERY_TABLES;
|
|
27
|
+
/** The table that describes the others: one row per column, with the schema version. */
|
|
28
|
+
export declare const SCHEMA_TABLE = "chant_schema";
|
|
29
|
+
type Value = string | number | null;
|
|
30
|
+
export type QueryRow = Record<string, Value>;
|
|
31
|
+
/** The rows of each table, as loaded. */
|
|
32
|
+
export type QueryData = Record<QueryTable, QueryRow[]>;
|
|
33
|
+
/** One ledger to read: a member's, or the project's own with `member` null. */
|
|
34
|
+
export interface QueryLedger {
|
|
35
|
+
member: string | null;
|
|
36
|
+
port: LedgerReadPort;
|
|
37
|
+
}
|
|
38
|
+
export interface QueryLoad {
|
|
39
|
+
data: QueryData;
|
|
40
|
+
/** Lines and files that could not be read as their kind, per table. Left out of the rows. */
|
|
41
|
+
malformed: Record<QueryTable, number>;
|
|
42
|
+
}
|
|
43
|
+
export interface QueryResult {
|
|
44
|
+
schemaVersion: number;
|
|
45
|
+
columns: string[];
|
|
46
|
+
rows: QueryRow[];
|
|
47
|
+
/** How many rows each table held. */
|
|
48
|
+
tables: Record<QueryTable, number>;
|
|
49
|
+
malformed: Record<QueryTable, number>;
|
|
50
|
+
}
|
|
51
|
+
/** A statement that can't run, or a Node.js with no SQLite. The message is for a person. */
|
|
52
|
+
export declare class QueryError extends Error {
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Read every table's rows from the ledgers, in the order given. A ledger
|
|
56
|
+
* whose branch is absent reads as no rows. A line or file that is not its
|
|
57
|
+
* kind is counted in `malformed` and left out, as each ledger's own reader
|
|
58
|
+
* does.
|
|
59
|
+
*/
|
|
60
|
+
export declare function loadQueryData(ledgers: readonly QueryLedger[]): Promise<QueryLoad>;
|
|
61
|
+
/** The first word of a statement, past whitespace and comments. */
|
|
62
|
+
export declare function firstWord(sql: string): string;
|
|
63
|
+
/** Run one read-only statement over the tables. */
|
|
64
|
+
export declare function runQuery(sql: string, load: QueryLoad): Promise<QueryResult>;
|
|
65
|
+
/** The rows as an aligned table, a header and a count. */
|
|
66
|
+
export declare function formatQueryResult(r: QueryResult): string;
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/lifecycle/query.ts"],"names":[],"mappings":"AA+BA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAMpD,6CAA6C;AAC7C,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAItC;;;;;GAKG;AACH,eAAO,MAAM,YAAY;IACvB,wFAAwF;;IAExF,2FAA2F;;IAE3F,mEAAmE;;IAEnE,8GAA8G;;IAE9G,iHAAiH;;IAEjH,4IAA4I;;IAE5I,kFAAkF;;CAEH,CAAC;AAElF,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,YAAY,CAAC;AAEnD,wFAAwF;AACxF,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,KAAK,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AACpC,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE7C,yCAAyC;AACzC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;AAEvD,+EAA+E;AAC/E,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,GAAG,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