@intentius/chant 0.124.108 → 0.124.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__golden__/wave-loop/fan-out-applied.json +12 -6
- package/dist/__golden__/wave-loop/fan-out-apply-fails.json +8 -4
- package/dist/__golden__/wave-loop/fan-out-gated.json +4 -2
- package/dist/__golden__/wave-loop/fan-out-no-members.json +16 -8
- package/dist/__golden__/wave-loop/fan-out-plan-fails.json +8 -4
- package/dist/__golden__/wave-loop/fan-out-same-root.json +4 -2
- package/dist/agent-facts.d.ts +130 -0
- package/dist/agent-facts.js +196 -0
- package/dist/change-risk.d.ts +216 -0
- package/dist/change-risk.js +304 -0
- package/dist/change-set.d.ts +8 -0
- package/dist/ci-agent-alert.d.ts +139 -0
- package/dist/ci-agent-alert.js +342 -0
- package/dist/ci-agent-triggers.d.ts +152 -0
- package/dist/ci-agent-triggers.js +232 -0
- package/dist/ci-agent-verify-failed.d.ts +149 -0
- package/dist/ci-agent-verify-failed.js +191 -0
- package/dist/ci-agent.d.ts +136 -8
- package/dist/ci-agent.js +353 -26
- package/dist/ci-comment-commands.d.ts +8 -0
- package/dist/ci-comment-commands.js +17 -1
- package/dist/ci-comment-reject.d.ts +70 -0
- package/dist/ci-comment-reject.js +135 -0
- package/dist/ci-comment-replies.d.ts +3 -1
- package/dist/ci-comment-replies.js +6 -0
- package/dist/ci-estate/delivery.d.ts +25 -3
- package/dist/ci-estate/delivery.js +28 -9
- package/dist/ci-estate/page.d.ts +7 -3
- package/dist/ci-estate/page.js +19 -4
- package/dist/ci-estate/rows.d.ts +14 -2
- package/dist/ci-estate/rows.js +9 -1
- package/dist/ci-estate.d.ts +5 -2
- package/dist/ci-estate.js +3 -2
- package/dist/ci-handover.d.ts +2 -7
- package/dist/ci-handover.js +3 -20
- package/dist/ci-jobs.d.ts +6 -0
- package/dist/ci-jobs.js +17 -0
- package/dist/ci-note-commands.d.ts +2 -0
- package/dist/ci-note-commands.js +12 -1
- package/dist/ci-product-words.d.ts +151 -1
- package/dist/ci-product-words.js +1390 -3
- package/dist/ci-product.d.ts +100 -4
- package/dist/ci-product.js +99 -3
- package/dist/ci-respond-run.d.ts +9 -0
- package/dist/ci-respond-run.js +35 -4
- package/dist/ci-respond-summary-env.d.ts +56 -0
- package/dist/ci-respond-summary-env.js +81 -0
- package/dist/ci-respond-summary.d.ts +103 -0
- package/dist/ci-respond-summary.js +243 -0
- package/dist/ci-respond.d.ts +4 -2
- package/dist/ci-respond.js +4 -2
- package/dist/cli/command-group.js +1 -1
- package/dist/cli/commands/lint.js +21 -3
- package/dist/cli/handlers/agent.js +49 -4
- package/dist/cli/handlers/approve.js +3 -1
- package/dist/cli/handlers/build.d.ts +97 -1
- package/dist/cli/handlers/build.js +251 -3
- package/dist/cli/handlers/fan-out.js +55 -0
- package/dist/cli/handlers/graph.d.ts +14 -0
- package/dist/cli/handlers/graph.js +58 -3
- package/dist/cli/handlers/lifecycle-health.d.ts +7 -0
- package/dist/cli/handlers/lifecycle-health.js +47 -9
- package/dist/cli/handlers/lifecycle.js +4 -1
- package/dist/cli/handlers/notify-relay.d.ts +2 -2
- package/dist/cli/handlers/notify-relay.js +67 -7
- package/dist/cli/handlers/pipeline-agent.d.ts +30 -0
- package/dist/cli/handlers/pipeline-agent.js +255 -0
- package/dist/cli/handlers/pipeline-artifacts.d.ts +39 -0
- package/dist/cli/handlers/pipeline-artifacts.js +203 -0
- package/dist/cli/handlers/pipeline.d.ts +16 -0
- package/dist/cli/handlers/pipeline.js +112 -0
- package/dist/cli/handlers/pr-comment.js +4 -0
- package/dist/cli/handlers/pr-notes.js +4 -1
- package/dist/cli/handlers/pr.d.ts +20 -0
- package/dist/cli/handlers/pr.js +114 -11
- package/dist/cli/handlers/promote.js +792 -47
- package/dist/cli/handlers/reject.d.ts +84 -0
- package/dist/cli/handlers/reject.js +216 -0
- package/dist/cli/handlers/release.js +4 -2
- package/dist/cli/handlers/replan.d.ts +54 -0
- package/dist/cli/handlers/replan.js +177 -0
- package/dist/cli/handlers/run-generate.d.ts +5 -0
- package/dist/cli/handlers/run-generate.js +31 -4
- package/dist/cli/handlers/run-wave.js +15 -2
- package/dist/cli/handlers/run.js +4 -2
- package/dist/cli/handlers/stage.d.ts +35 -0
- package/dist/cli/handlers/stage.js +90 -0
- package/dist/cli/lsp/server.js +4 -0
- package/dist/cli/main.js +88 -8
- package/dist/cli/parse-args.js +35 -2
- package/dist/cli/registry.d.ts +12 -0
- package/dist/components/auto-release.d.ts +2 -0
- package/dist/components/auto-release.js +1 -0
- package/dist/components/capability.d.ts +40 -0
- package/dist/components/cli-support.d.ts +21 -1
- package/dist/components/cli-support.js +28 -6
- package/dist/components/component.d.ts +23 -4
- package/dist/components/component.schema.json +28 -0
- package/dist/components/declared-reads.d.ts +44 -4
- package/dist/components/declared-reads.js +80 -3
- package/dist/components/discover.d.ts +8 -0
- package/dist/components/discover.js +1 -1
- package/dist/components/driver.d.ts +13 -0
- package/dist/components/driver.js +23 -2
- package/dist/components/environment-sets.d.ts +229 -0
- package/dist/components/environment-sets.js +338 -0
- package/dist/components/fan-out-canary.d.ts +47 -0
- package/dist/components/fan-out-canary.js +58 -0
- package/dist/components/fan-out-run.d.ts +17 -0
- package/dist/components/fan-out-run.js +14 -1
- package/dist/components/fan-out-support.d.ts +7 -0
- package/dist/components/fan-out-support.js +1 -1
- package/dist/components/groups.d.ts +8 -1
- package/dist/components/groups.js +19 -1
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.js +4 -1
- package/dist/components/pr-cost.d.ts +28 -0
- package/dist/components/pr-cost.js +53 -0
- package/dist/components/pr-pipeline.d.ts +33 -0
- package/dist/components/pr-pipeline.js +32 -5
- package/dist/components/pr-policy.d.ts +33 -2
- package/dist/components/pr-policy.js +5 -2
- package/dist/components/pr-risk.d.ts +42 -0
- package/dist/components/pr-risk.js +74 -0
- package/dist/components/product-pipeline.d.ts +43 -0
- package/dist/components/product-pipeline.js +67 -1
- package/dist/components/promote.d.ts +6 -0
- package/dist/components/promote.js +13 -0
- package/dist/components/release-compile.js +3 -1
- package/dist/components/release-gate.d.ts +6 -1
- package/dist/components/release-gate.js +10 -2
- package/dist/components/step-environments.d.ts +236 -0
- package/dist/components/step-environments.js +392 -0
- package/dist/components/upstream-replan.d.ts +201 -0
- package/dist/components/upstream-replan.js +249 -0
- package/dist/components/verify-step.d.ts +30 -0
- package/dist/components/verify-step.js +27 -0
- package/dist/components/wave-plan.js +6 -2
- package/dist/config-environments.d.ts +4 -2
- package/dist/control/dispatch.d.ts +15 -0
- package/dist/control/dispatch.js +28 -4
- package/dist/cost-estimate.d.ts +188 -0
- package/dist/cost-estimate.js +363 -0
- package/dist/drift-record.d.ts +36 -0
- package/dist/drift-record.js +44 -0
- package/dist/engine-facts.d.ts +105 -0
- package/dist/engine-facts.js +111 -0
- package/dist/exit-codes.d.ts +4 -3
- package/dist/exit-codes.js +4 -3
- package/dist/flag-params.d.ts +2 -2
- package/dist/flag-params.js +9 -4
- package/dist/floor-table.data.js +53 -0
- package/dist/forge-token-vars.d.ts +12 -0
- package/dist/forge-token-vars.js +25 -0
- package/dist/gate-decision.d.ts +3 -1
- package/dist/gate-decision.js +3 -1
- package/dist/gated-waves.d.ts +2 -0
- package/dist/gated-waves.js +1 -0
- package/dist/graph-ir.d.ts +30 -0
- package/dist/graph-ir.js +33 -1
- package/dist/graph-refs.d.ts +26 -0
- package/dist/graph-refs.js +34 -3
- package/dist/graph-schema/graph.schema.json +136 -0
- package/dist/health.d.ts +65 -0
- package/dist/health.js +62 -0
- package/dist/lexicon.d.ts +188 -1
- package/dist/lifecycle/disruption.d.ts +14 -1
- package/dist/lifecycle/disruption.js +5 -1
- package/dist/lifecycle/gate-change-set.d.ts +8 -0
- package/dist/lifecycle/gate-change-set.js +2 -1
- package/dist/lifecycle/gate-ledger.d.ts +26 -0
- package/dist/lifecycle/gate-rejection.d.ts +82 -0
- package/dist/lifecycle/gate-rejection.js +93 -0
- package/dist/lifecycle/gate-seal.d.ts +3 -3
- package/dist/lifecycle/gate-seal.js +5 -5
- package/dist/lifecycle/observe.d.ts +17 -0
- package/dist/lifecycle/observe.js +10 -1
- package/dist/lifecycle/release-cut.js +4 -0
- package/dist/lifecycle/release-ledger.d.ts +8 -0
- package/dist/lifecycle/release-risk.d.ts +137 -0
- package/dist/lifecycle/release-risk.js +214 -0
- package/dist/lifecycle/release-store.d.ts +9 -0
- package/dist/lifecycle/release-store.js +4 -0
- package/dist/lifecycle/stage-log.d.ts +85 -0
- package/dist/lifecycle/stage-log.js +141 -0
- package/dist/lint/canary-checks.d.ts +31 -0
- package/dist/lint/canary-checks.js +45 -0
- package/dist/lint/rule.d.ts +1 -0
- package/dist/lint/rules/evl012-pipeline-fold.d.ts +14 -0
- package/dist/lint/rules/evl012-pipeline-fold.js +30 -0
- package/dist/lint/rules/index.d.ts +1 -0
- package/dist/lint/rules/index.js +3 -0
- package/dist/notify-relay-repo.d.ts +54 -0
- package/dist/notify-relay-repo.js +84 -0
- package/dist/notify-relay.d.ts +53 -3
- package/dist/notify-relay.js +96 -3
- package/dist/notify.d.ts +57 -1
- package/dist/notify.js +7 -1
- package/dist/notify.schema.json +61 -3
- package/dist/observation.d.ts +34 -0
- package/dist/observation.js +14 -1
- package/dist/op/activities/review-agent.d.ts +39 -2
- package/dist/op/activities/review-agent.js +88 -5
- package/dist/op/agent-permit.d.ts +88 -0
- package/dist/op/agent-permit.js +97 -0
- package/dist/op/gate-approval-base.d.ts +8 -0
- package/dist/op/gate-approval-base.js +9 -0
- package/dist/op/gate-approval.d.ts +30 -1
- package/dist/op/gate-approval.js +23 -2
- package/dist/op/gate-quorum.d.ts +114 -8
- package/dist/op/gate-quorum.js +198 -21
- package/dist/op/gate-reject.d.ts +79 -0
- package/dist/op/gate-reject.js +96 -0
- package/dist/op/gate-summary.js +1 -1
- package/dist/op/gate.d.ts +28 -3
- package/dist/op/gate.js +55 -13
- package/dist/op/generate-pipeline.d.ts +15 -1
- package/dist/op/generate-pipeline.js +32 -5
- package/dist/op/index.d.ts +11 -6
- package/dist/op/index.js +10 -5
- package/dist/op/local-executor.d.ts +2 -0
- package/dist/op/local-executor.js +23 -4
- package/dist/op/op-waves-after-plan.d.ts +23 -0
- package/dist/op/op-waves-after-plan.js +12 -1
- package/dist/op/op-waves-capability-spec.d.ts +14 -0
- package/dist/op/op-waves-capability-spec.js +46 -6
- package/dist/op/op-waves-capability.d.ts +21 -13
- package/dist/op/op-waves-capability.js +22 -59
- package/dist/op/op-waves-environment-sets.d.ts +41 -0
- package/dist/op/op-waves-environment-sets.js +82 -0
- package/dist/op/op-waves-quorum-warnings.d.ts +53 -0
- package/dist/op/op-waves-quorum-warnings.js +90 -0
- package/dist/op/op-waves-release-port.d.ts +7 -0
- package/dist/op/op-waves-release-port.js +15 -3
- package/dist/op/op-waves-release.d.ts +15 -0
- package/dist/op/op-waves-release.js +15 -0
- package/dist/op/op-waves-run.d.ts +37 -3
- package/dist/op/op-waves-run.js +141 -18
- package/dist/op/op-waves-soak.d.ts +57 -0
- package/dist/op/op-waves-soak.js +111 -0
- package/dist/op/op-waves-split.d.ts +4 -0
- package/dist/op/op-waves-split.js +4 -0
- package/dist/op/op-waves.d.ts +67 -4
- package/dist/op/op-waves.js +71 -3
- package/dist/pipeline/agent-ajv.d.ts +4 -0
- package/dist/pipeline/agent-ajv.js +14 -0
- package/dist/pipeline/agent-steps.d.ts +329 -0
- package/dist/pipeline/agent-steps.js +602 -0
- package/dist/pipeline/artifacts.d.ts +264 -0
- package/dist/pipeline/artifacts.js +425 -0
- package/dist/pipeline/diff.d.ts +45 -0
- package/dist/pipeline/diff.js +177 -0
- package/dist/pipeline/fold.d.ts +43 -0
- package/dist/pipeline/fold.js +140 -0
- package/dist/pipeline/generate.d.ts +52 -0
- package/dist/pipeline/generate.js +120 -0
- package/dist/pipeline/product.d.ts +225 -0
- package/dist/pipeline/product.js +257 -0
- package/dist/pipeline/promote.d.ts +404 -0
- package/dist/pipeline/promote.js +694 -0
- package/dist/pipeline/read.d.ts +37 -0
- package/dist/pipeline/read.js +58 -0
- package/dist/pipeline/rendered.d.ts +25 -0
- package/dist/pipeline/rendered.js +53 -0
- package/dist/pipeline/soak-checks.d.ts +80 -0
- package/dist/pipeline/soak-checks.js +254 -0
- package/dist/pipeline/soak-gate.d.ts +97 -0
- package/dist/pipeline/soak-gate.js +176 -0
- package/dist/pipeline/soak-sources.d.ts +17 -0
- package/dist/pipeline/soak-sources.js +42 -0
- package/dist/pipeline/soak.d.ts +260 -0
- package/dist/pipeline/soak.js +378 -0
- package/dist/pipeline/spec.d.ts +724 -0
- package/dist/pipeline/spec.js +567 -0
- package/dist/pipeline/stage-ledger.d.ts +187 -0
- package/dist/pipeline/stage-ledger.js +185 -0
- package/dist/pipeline/stage-waves.d.ts +114 -0
- package/dist/pipeline/stage-waves.js +161 -0
- package/dist/pipeline/stages.d.ts +64 -0
- package/dist/pipeline/stages.js +174 -0
- package/dist/pipeline/verify-rollback.d.ts +277 -0
- package/dist/pipeline/verify-rollback.js +393 -0
- package/dist/pipeline.d.ts +142 -0
- package/dist/pipeline.js +143 -0
- package/dist/pr-loop.d.ts +22 -0
- package/dist/pr-loop.js +8 -0
- package/dist/pr-plan-note.d.ts +15 -1
- package/dist/pr-plan-note.js +8 -0
- package/dist/pr-post.d.ts +31 -0
- package/dist/pr-post.js +89 -0
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/report-store/audit.schema.json +50 -0
- package/dist/report-store/dora.schema.json +331 -0
- package/dist/report-store/estate.schema.json +96 -0
- package/dist/report-store/run.schema.json +14 -0
- package/dist/report-store.d.ts +151 -0
- package/dist/report-store.js +344 -0
- package/dist/run-event.d.ts +7 -2
- package/dist/wave-runtime.mjs +458 -404
- package/dist/workspace/catalog-edges.js +3 -3
- package/dist/workspace/change-set.schema.json +4 -0
- package/dist/workspace/ci-cloud-identity.d.ts +4 -0
- package/dist/workspace/ci-cloud-identity.js +30 -0
- package/dist/workspace/ci-run.js +17 -2
- package/dist/workspace/ci-secrets.d.ts +3 -1
- package/dist/workspace/ci-secrets.js +7 -1
- package/dist/workspace/compose-graph.d.ts +1 -1
- package/dist/workspace/compose-graph.js +3 -1
- package/dist/workspace/declaration.d.ts +27 -0
- package/dist/workspace/declaration.js +35 -0
- package/dist/workspace/declaration.schema.json +56 -0
- package/dist/workspace/graph-cli.js +26 -0
- package/dist/workspace/graph.schema.json +5 -1
- package/dist/workspace/identity-gate-rule.d.ts +4 -0
- package/dist/workspace/identity-gate-rule.js +2 -2
- package/dist/workspace/identity-reject-rule.d.ts +14 -0
- package/dist/workspace/identity-reject-rule.js +24 -0
- package/dist/workspace/identity.d.ts +3 -0
- package/dist/workspace/identity.js +2 -1
- package/dist/workspace/nested-graph.js +2 -0
- package/dist/workspace/pr-report.schema.json +65 -0
- package/dist/workspace/promotion-order.d.ts +19 -4
- package/dist/workspace/promotion-order.js +26 -4
- package/dist/workspace/release-train.d.ts +14 -0
- package/dist/workspace/release-train.js +32 -0
- package/dist/workspace/run-event.schema.json +2 -2
- package/dist/workspace/stack-read-edges.d.ts +19 -0
- package/dist/workspace/stack-read-edges.js +54 -0
- package/dist/workspace/status-gates.d.ts +51 -1
- package/dist/workspace/status-gates.js +60 -0
- package/dist/workspace/status-stages.d.ts +223 -0
- package/dist/workspace/status-stages.js +279 -0
- package/dist/workspace/status.d.ts +45 -1
- package/dist/workspace/status.js +109 -5
- package/dist/workspace/status.schema.json +283 -2
- package/dist/workspace/train-cut.js +5 -2
- package/dist/workspace/train-shell.d.ts +18 -0
- package/dist/workspace/train-shell.js +43 -0
- package/dist/workspace/trust/seal.d.ts +7 -0
- package/dist/workspace/trust/seal.js +9 -0
- package/package.json +5 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A rejection from a comment (#5354): `/<product> reject [--stage <stage>]
|
|
3
|
+
* <reason>` on a pull or merge request records a rejection of the release a
|
|
4
|
+
* stage of the pipeline waits on, as `chant reject` does.
|
|
5
|
+
*
|
|
6
|
+
* A comment carries the forge's identity of its author and nothing that
|
|
7
|
+
* proves it further: no seal. So it records only where the stage's approval
|
|
8
|
+
* rules take an approver on that identity, by the rules #5349 sets for the
|
|
9
|
+
* stage's approval mode:
|
|
10
|
+
*
|
|
11
|
+
* - the comment job has already checked the author's permission on the
|
|
12
|
+
* forge (write access on GitHub and Forgejo, the poll's role on GitLab),
|
|
13
|
+
* the check the job makes before any command;
|
|
14
|
+
* - `ledger`, `pr-review` and `pull-request` take a plain approval line, so
|
|
15
|
+
* they take the author's forge identity (`github:<login>`) for a
|
|
16
|
+
* rejection;
|
|
17
|
+
* - `sealed` counts only a sealed rejection, a gate the workspace's
|
|
18
|
+
* `identity.gates` names only a signed one from its class, and a rule with
|
|
19
|
+
* `proven` or `roles` only a proven approver: a comment proves none of
|
|
20
|
+
* them, so the reply names the reject line to run, and why.
|
|
21
|
+
*
|
|
22
|
+
* The rejection is bound to the digest on the stage gate's standing pending
|
|
23
|
+
* fact, as `chant reject` binds it, with the comment's address as its `url`.
|
|
24
|
+
*/
|
|
25
|
+
import type { GateLedgerPort } from "./op/gate.js";
|
|
26
|
+
import type { PipelineSpec } from "./pipeline/spec.js";
|
|
27
|
+
import { type CiProductWords } from "./ci-product-words.js";
|
|
28
|
+
import type { GateRejectionOptions } from "./cli/handlers/reject.js";
|
|
29
|
+
/** What a comment job records a rejection with. Absent on a job: a reject comment is answered with the reject line. */
|
|
30
|
+
export interface CommentReject {
|
|
31
|
+
/** The pipeline as the default branch has it, whose stages' gates the comment rejects at. */
|
|
32
|
+
pipeline(): Promise<PipelineSpec | undefined>;
|
|
33
|
+
/** The gate ledger on `chant/lifecycle`. */
|
|
34
|
+
port: GateLedgerPort;
|
|
35
|
+
/** The forge principal of a login, such as `github:alice`. */
|
|
36
|
+
principal(login: string): string;
|
|
37
|
+
/** The declaration, trust policy and `identity.gates` rule at base for a gate. Default: read in `cwd`. */
|
|
38
|
+
scope?(gate: string): Promise<NonNullable<GateRejectionOptions["scope"]>>;
|
|
39
|
+
/** The repository the ledger and the trust policy are read in. */
|
|
40
|
+
cwd?: string;
|
|
41
|
+
/** "now", for which pending facts stand. */
|
|
42
|
+
now?: () => string;
|
|
43
|
+
}
|
|
44
|
+
/** What {@link decideCommentReject} answers: the reply, and whether a rejection was recorded. */
|
|
45
|
+
export type CommentRejectOutcome = {
|
|
46
|
+
kind: "recorded" | "reply";
|
|
47
|
+
text: string;
|
|
48
|
+
} | {
|
|
49
|
+
kind: "fail";
|
|
50
|
+
reason: string;
|
|
51
|
+
};
|
|
52
|
+
/** Decide a `/<product> reject` comment by `user`, whose permission the job has already checked. */
|
|
53
|
+
export declare function decideCommentReject(input: {
|
|
54
|
+
reject: CommentReject;
|
|
55
|
+
words: CiProductWords;
|
|
56
|
+
user: string;
|
|
57
|
+
reason: string;
|
|
58
|
+
stage?: string;
|
|
59
|
+
url?: string;
|
|
60
|
+
}): Promise<CommentRejectOutcome>;
|
|
61
|
+
/** The variable naming the member directory whose `.chant/pipeline.ts` a reject comment reads (#5354). Default: the job's directory. */
|
|
62
|
+
export declare const COMMENT_REJECT_DIR_ENV = "CHANT_PIPELINE_DIR";
|
|
63
|
+
/**
|
|
64
|
+
* What a comment job records a reject comment with (#5354), when the
|
|
65
|
+
* product's words map a comment command onto `reject`; undefined
|
|
66
|
+
* otherwise, and the reply names the reject line. The pipeline is folded as
|
|
67
|
+
* the default branch has it, the ledger is this checkout's
|
|
68
|
+
* `chant/lifecycle`, and the author is named by their forge principal.
|
|
69
|
+
*/
|
|
70
|
+
export declare function commentRejectFromEnv(words: CiProductWords, env?: Record<string, string | undefined>, cwd?: string): Promise<CommentReject | undefined>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A rejection from a comment (#5354): `/<product> reject [--stage <stage>]
|
|
3
|
+
* <reason>` on a pull or merge request records a rejection of the release a
|
|
4
|
+
* stage of the pipeline waits on, as `chant reject` does.
|
|
5
|
+
*
|
|
6
|
+
* A comment carries the forge's identity of its author and nothing that
|
|
7
|
+
* proves it further: no seal. So it records only where the stage's approval
|
|
8
|
+
* rules take an approver on that identity, by the rules #5349 sets for the
|
|
9
|
+
* stage's approval mode:
|
|
10
|
+
*
|
|
11
|
+
* - the comment job has already checked the author's permission on the
|
|
12
|
+
* forge (write access on GitHub and Forgejo, the poll's role on GitLab),
|
|
13
|
+
* the check the job makes before any command;
|
|
14
|
+
* - `ledger`, `pr-review` and `pull-request` take a plain approval line, so
|
|
15
|
+
* they take the author's forge identity (`github:<login>`) for a
|
|
16
|
+
* rejection;
|
|
17
|
+
* - `sealed` counts only a sealed rejection, a gate the workspace's
|
|
18
|
+
* `identity.gates` names only a signed one from its class, and a rule with
|
|
19
|
+
* `proven` or `roles` only a proven approver: a comment proves none of
|
|
20
|
+
* them, so the reply names the reject line to run, and why.
|
|
21
|
+
*
|
|
22
|
+
* The rejection is bound to the digest on the stage gate's standing pending
|
|
23
|
+
* fact, as `chant reject` binds it, with the comment's address as its `url`.
|
|
24
|
+
*/
|
|
25
|
+
import { latestPendingGate, isPendingGateExpired } from "./lifecycle/gate-ledger.js";
|
|
26
|
+
import { quorumRules, ruleAdmits } from "./op/gate-quorum.js";
|
|
27
|
+
import { rejectLine } from "./ci-product-words.js";
|
|
28
|
+
/** Decide a `/<product> reject` comment by `user`, whose permission the job has already checked. */
|
|
29
|
+
export async function decideCommentReject(input) {
|
|
30
|
+
const { reject, words } = input;
|
|
31
|
+
let spec;
|
|
32
|
+
try {
|
|
33
|
+
spec = await reject.pipeline();
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
return { kind: "fail", reason: `the pipeline at the default branch could not be read: ${err instanceof Error ? err.message : String(err)}` };
|
|
37
|
+
}
|
|
38
|
+
if (!spec)
|
|
39
|
+
return { kind: "reply", text: "this repository has no pipeline on its default branch, so no stage waits on a release to reject" };
|
|
40
|
+
const op = spec.name;
|
|
41
|
+
const now = (reject.now ?? (() => new Date().toISOString()))();
|
|
42
|
+
let pending;
|
|
43
|
+
try {
|
|
44
|
+
pending = (await reject.port.read(op)).pending;
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
return { kind: "fail", reason: `the gate ledger of ${op} could not be read: ${err instanceof Error ? err.message : String(err)}` };
|
|
48
|
+
}
|
|
49
|
+
const waiting = spec.stages
|
|
50
|
+
.map((s) => ({ stage: s, fact: latestPendingGate(pending.filter((p) => p.environment === undefined || p.environment === s.name), s.name) }))
|
|
51
|
+
.filter((w) => w.fact !== undefined && w.fact.planDigest !== undefined && !isPendingGateExpired(w.fact, now));
|
|
52
|
+
const line = (stage, digest) => rejectLine(words, { op, gate: stage, digest, reason: "<why>" });
|
|
53
|
+
let chosen = waiting[0];
|
|
54
|
+
if (input.stage !== undefined) {
|
|
55
|
+
if (!spec.stages.some((s) => s.name === input.stage))
|
|
56
|
+
return { kind: "reply", text: `${input.stage} is not a stage of ${op}; its stages are ${spec.stages.map((s) => `\`${s.name}\``).join(", ")}` };
|
|
57
|
+
chosen = waiting.find((w) => w.stage.name === input.stage);
|
|
58
|
+
if (!chosen)
|
|
59
|
+
return { kind: "reply", text: `no release waits at stage ${input.stage} of ${op}, so there is nothing to reject there` };
|
|
60
|
+
}
|
|
61
|
+
else if (waiting.length === 0) {
|
|
62
|
+
return { kind: "reply", text: `no release waits at a stage of ${op}, so there is nothing to reject` };
|
|
63
|
+
}
|
|
64
|
+
else if (waiting.length > 1) {
|
|
65
|
+
return { kind: "reply", text: `releases wait at ${waiting.map((w) => `\`${w.stage.name}\``).join(", ")}: name one with \`/${words.product} ${typedReject(words)} --stage <stage> <reason>\`` };
|
|
66
|
+
}
|
|
67
|
+
const { stage, fact } = chosen;
|
|
68
|
+
const digest = fact.planDigest;
|
|
69
|
+
const mode = stage.gate?.approval ?? "ledger";
|
|
70
|
+
if (mode === "sealed") {
|
|
71
|
+
return { kind: "reply", text: `stage ${stage.name} counts only sealed approvals, so it counts only a sealed rejection, which a comment cannot carry. Run \`${line(stage.name, digest)}\`` };
|
|
72
|
+
}
|
|
73
|
+
const rules = quorumRules(stage.gate?.quorum);
|
|
74
|
+
if (rules.length > 0 && !rules.some((r) => ruleAdmits(r, { proven: false, roles: [] }))) {
|
|
75
|
+
return { kind: "reply", text: `every approval rule of stage ${stage.name} counts only a proven approver, which a comment cannot show, so it counts only a sealed rejection. Run \`${line(stage.name, digest)}\`` };
|
|
76
|
+
}
|
|
77
|
+
const { recordGateRejection, scopeAt } = await import("./cli/handlers/reject.js");
|
|
78
|
+
const scope = reject.scope ? await reject.scope(stage.name) : await scopeAt(reject.cwd ?? process.cwd(), stage.name);
|
|
79
|
+
if (scope.rule) {
|
|
80
|
+
return { kind: "reply", text: `the workspace's identity.gates names gate ${stage.name}, so it counts only a signed rejection, which a comment cannot carry. Run \`${line(stage.name, digest)}\`` };
|
|
81
|
+
}
|
|
82
|
+
const who = reject.principal(input.user);
|
|
83
|
+
const out = await recordGateRejection(op, stage.name, {
|
|
84
|
+
reason: input.reason,
|
|
85
|
+
actor: who,
|
|
86
|
+
plan: digest,
|
|
87
|
+
...(fact.environment !== undefined ? { environment: fact.environment } : {}),
|
|
88
|
+
...(input.url !== undefined ? { url: input.url } : {}),
|
|
89
|
+
origin: "cli",
|
|
90
|
+
port: reject.port,
|
|
91
|
+
scope,
|
|
92
|
+
...(reject.cwd !== undefined ? { cwd: reject.cwd } : {}),
|
|
93
|
+
});
|
|
94
|
+
if ("statement" in out)
|
|
95
|
+
return { kind: "fail", reason: "the rejection was not recorded" };
|
|
96
|
+
if (!out.ok)
|
|
97
|
+
return { kind: "reply", text: out.message };
|
|
98
|
+
const pushed = out.pushed ? "" : " The ledger push did not land, so other jobs do not see it yet.";
|
|
99
|
+
return { kind: "recorded", text: `recorded ${who}'s rejection of ${digest} at ${op} ${stage.name}: ${input.reason}. It does not enter ${stage.name}, and more approvals do not clear it; a new release goes through again.${pushed}` };
|
|
100
|
+
}
|
|
101
|
+
function typedReject(words) {
|
|
102
|
+
return Object.entries(words.commands).find(([, c]) => c === "reject")?.[0] ?? "reject";
|
|
103
|
+
}
|
|
104
|
+
/** The variable naming the member directory whose `.chant/pipeline.ts` a reject comment reads (#5354). Default: the job's directory. */
|
|
105
|
+
export const COMMENT_REJECT_DIR_ENV = "CHANT_PIPELINE_DIR";
|
|
106
|
+
/**
|
|
107
|
+
* What a comment job records a reject comment with (#5354), when the
|
|
108
|
+
* product's words map a comment command onto `reject`; undefined
|
|
109
|
+
* otherwise, and the reply names the reject line. The pipeline is folded as
|
|
110
|
+
* the default branch has it, the ledger is this checkout's
|
|
111
|
+
* `chant/lifecycle`, and the author is named by their forge principal.
|
|
112
|
+
*/
|
|
113
|
+
export async function commentRejectFromEnv(words, env = process.env, cwd = process.cwd()) {
|
|
114
|
+
if (!Object.values(words.commands).includes("reject"))
|
|
115
|
+
return undefined;
|
|
116
|
+
const { resolve } = await import("node:path");
|
|
117
|
+
const dir = resolve(cwd, env[COMMENT_REJECT_DIR_ENV] ?? ".");
|
|
118
|
+
const { gitGateLedgerPort } = await import("./op/gate.js");
|
|
119
|
+
const { forgePrincipalFromEnv } = await import("./op/gate-review.js");
|
|
120
|
+
return {
|
|
121
|
+
async pipeline() {
|
|
122
|
+
const { promoteBase, readPipelineAt } = await import("./pipeline/read.js");
|
|
123
|
+
const base = promoteBase(dir);
|
|
124
|
+
if (!base)
|
|
125
|
+
return undefined;
|
|
126
|
+
const read = readPipelineAt(base, dir);
|
|
127
|
+
if (read.status === "refused")
|
|
128
|
+
throw new Error(read.line);
|
|
129
|
+
return read.status === "folded" ? read.spec : undefined;
|
|
130
|
+
},
|
|
131
|
+
port: gitGateLedgerPort({ cwd: dir }),
|
|
132
|
+
principal: forgePrincipalFromEnv(env),
|
|
133
|
+
cwd: dir,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* This module imports nothing at run time.
|
|
13
13
|
*/
|
|
14
|
-
import type
|
|
14
|
+
import { type CiProductCommand, type CiProductCommentReplies, type CiProductWords } from "./ci-product-words.js";
|
|
15
15
|
import type { ForgeKind } from "./pr-forge.js";
|
|
16
16
|
/** How a reply names the forge's things. */
|
|
17
17
|
export interface CommentTerms {
|
|
@@ -33,6 +33,8 @@ export type NotRunCommand = Exclude<keyof CiProductCommentReplies, "fork" | "mem
|
|
|
33
33
|
* sentence when its words give one, else chant's.
|
|
34
34
|
*/
|
|
35
35
|
export declare function notRunReply(words: CiProductWords, command: NotRunCommand, forge: ForgeKind): string;
|
|
36
|
+
/** The reply to a reject comment where the pipeline records none from a comment (#5354): the reject line to run. */
|
|
37
|
+
export declare function rejectNotRecorded(words: CiProductWords, forge: ForgeKind): string;
|
|
36
38
|
/** The reply to a command on a pull request from a fork. */
|
|
37
39
|
export declare function forkReply(words: CiProductWords, forge: ForgeKind): string;
|
|
38
40
|
/** The reply to a comment that names a member the pipeline was not written with. */
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* This module imports nothing at run time.
|
|
13
13
|
*/
|
|
14
|
+
import { rejectLine } from "./ci-product-words.js";
|
|
14
15
|
/** The terms for `forge`. */
|
|
15
16
|
export function commentTerms(forge) {
|
|
16
17
|
return forge === "gitlab"
|
|
@@ -44,6 +45,11 @@ export function notRunReply(words, command, forge) {
|
|
|
44
45
|
return `the agent command is off in this ${t.place}`;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
48
|
+
/** The reply to a reject comment where the pipeline records none from a comment (#5354): the reject line to run. */
|
|
49
|
+
export function rejectNotRecorded(words, forge) {
|
|
50
|
+
const line = rejectLine(words, { op: words.op ?? "<op>", gate: "<stage>", digest: "<digest>" });
|
|
51
|
+
return `this ${commentTerms(forge).place} records no rejection from a comment: run \`${line}\``;
|
|
52
|
+
}
|
|
47
53
|
/** The reply to a command on a pull request from a fork. */
|
|
48
54
|
export function forkReply(words, forge) {
|
|
49
55
|
const t = commentTerms(forge);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CiProductWords } from "../ci-product-words.js";
|
|
2
|
+
import { type ReportSchemaIds } from "../report-store.js";
|
|
2
3
|
import type { DriftRun, EstateRows, WaveJob } from "./rows.js";
|
|
3
4
|
/** How many weeks the metrics cover, the current one included. */
|
|
4
5
|
export declare const DORA_WEEKS = 8;
|
|
@@ -8,8 +9,16 @@ export declare const DRIFT_WINDOW_SECONDS: number;
|
|
|
8
9
|
export declare const DORA_MIN_SPAN_SECONDS = 86400;
|
|
9
10
|
/** The file beside the estate page. */
|
|
10
11
|
export declare const DORA_FILE = "dora.json";
|
|
11
|
-
/** `<product>.dora/v1`: terragucci's schema name under terragucci's words. */
|
|
12
|
-
export declare const doraSchema: (words?: Pick<CiProductWords, "product"
|
|
12
|
+
/** `<product>.dora/v1`: terragucci's schema name under terragucci's words; `chant.dora/v1`, the neutral id, under `schemas: "neutral"` (#5336). */
|
|
13
|
+
export declare const doraSchema: (words?: Pick<CiProductWords, "product">, schemas?: ReportSchemaIds) => string;
|
|
14
|
+
/** The release ledger's deploy records in the window, by the verb that wrote them (#5336). */
|
|
15
|
+
export interface DoraReleases {
|
|
16
|
+
/** Deploys no promote, rollback or redeploy wrote. */
|
|
17
|
+
deploys: number;
|
|
18
|
+
promotes: number;
|
|
19
|
+
rollbacks: number;
|
|
20
|
+
redeploys: number;
|
|
21
|
+
}
|
|
13
22
|
export interface DoraLeadTime {
|
|
14
23
|
/** Applied waves whose first plan was found. */
|
|
15
24
|
changes: number;
|
|
@@ -31,6 +40,9 @@ export interface DoraWeek {
|
|
|
31
40
|
failures: number;
|
|
32
41
|
lead_time_seconds: number | null;
|
|
33
42
|
restore_seconds: number | null;
|
|
43
|
+
/** Present when the metrics count releases: the week's promotes and rollbacks. */
|
|
44
|
+
promotes?: number;
|
|
45
|
+
rollbacks?: number;
|
|
34
46
|
}
|
|
35
47
|
export interface DoraMetrics {
|
|
36
48
|
/** Applied waves in the window, and per week over span_seconds. */
|
|
@@ -55,6 +67,8 @@ export interface DoraMetrics {
|
|
|
55
67
|
};
|
|
56
68
|
/** Oldest week first. */
|
|
57
69
|
trend: DoraWeek[];
|
|
70
|
+
/** The release ledger's promotes and rollbacks; absent when the ledger holds no deploy record. */
|
|
71
|
+
releases?: DoraReleases;
|
|
58
72
|
}
|
|
59
73
|
export interface DoraProject extends DoraMetrics {
|
|
60
74
|
/** The member. */
|
|
@@ -63,6 +77,8 @@ export interface DoraProject extends DoraMetrics {
|
|
|
63
77
|
export interface Dora {
|
|
64
78
|
/** {@link doraSchema}. */
|
|
65
79
|
schema: string;
|
|
80
|
+
/** The product, under the neutral id `chant.dora/v1`. */
|
|
81
|
+
product?: string;
|
|
66
82
|
generated: string;
|
|
67
83
|
weeks: number;
|
|
68
84
|
/** The first Monday the window holds, and when it ends. */
|
|
@@ -80,6 +96,8 @@ export interface Dora {
|
|
|
80
96
|
}
|
|
81
97
|
export interface DeliveryOptions {
|
|
82
98
|
words?: Pick<CiProductWords, "product">;
|
|
99
|
+
/** `neutral` writes `chant.dora/v1` with `product`. Default `product`, `<product>.dora/v1`. */
|
|
100
|
+
schemas?: ReportSchemaIds;
|
|
83
101
|
now?: Date;
|
|
84
102
|
/** The members to report, in order. Default every member the rows name. */
|
|
85
103
|
members?: readonly string[];
|
|
@@ -135,7 +153,9 @@ export declare function doraMetricNames(words?: Pick<CiProductWords, "product">)
|
|
|
135
153
|
export declare function deliveryGauges(dora: Dora, words?: Pick<CiProductWords, "product">): DeliveryGauge[];
|
|
136
154
|
/**
|
|
137
155
|
* One line of a product's audit trail, as terragucci's reports bucket keeps
|
|
138
|
-
* it (`audit.jsonl`)
|
|
156
|
+
* it (`audit.jsonl`), or a `chant.audit/v1` line of the report store
|
|
157
|
+
* (#5336), whose `applied` and `approved` are read as `apply` and
|
|
158
|
+
* `approval`. Three kinds are read: `apply` (an applied or failed
|
|
139
159
|
* wave: `detail.commit`, `detail.roots`, `detail.failed`, and the
|
|
140
160
|
* `detail.approval` entry it applied under), `approval-requested` (a wave
|
|
141
161
|
* reaching its gate) and `approval`. `what` is the gate. Other kinds and
|
|
@@ -181,6 +201,8 @@ export interface DeliveryRecordSource {
|
|
|
181
201
|
}
|
|
182
202
|
export interface RecordDeliveryOptions {
|
|
183
203
|
words?: Pick<CiProductWords, "product">;
|
|
204
|
+
/** `neutral` writes `chant.dora/v1` with `product`. Default `product`, `<product>.dora/v1`. */
|
|
205
|
+
schemas?: ReportSchemaIds;
|
|
184
206
|
now?: Date;
|
|
185
207
|
/** The index's stage names: `tf-plan` and `tf-drift` for terragucci. */
|
|
186
208
|
stages: {
|
|
@@ -32,11 +32,18 @@
|
|
|
32
32
|
* Time to restore a failed apply to the next apply of those targets;
|
|
33
33
|
* drift found to the next check that found none
|
|
34
34
|
*
|
|
35
|
+
* Promotes and rollbacks deploy records of the release ledger
|
|
36
|
+
* (`deploys`) that `chant components promote` and
|
|
37
|
+
* `rollback` wrote, counted beside the four (#5336),
|
|
38
|
+
* with redeploys and other deploys. Absent when the
|
|
39
|
+
* ledger holds no deploy record.
|
|
40
|
+
*
|
|
35
41
|
* Every number covers the newest DORA_WEEKS weeks, Monday to Sunday in UTC,
|
|
36
42
|
* with a row per week. Nothing is compared to DORA's performance tiers.
|
|
37
43
|
*/
|
|
38
44
|
import { samePlanDigest } from "../lifecycle/plan-digest.js";
|
|
39
45
|
import { CHANT_WORDS } from "../ci-product-words.js";
|
|
46
|
+
import { REPORT_SCHEMAS } from "../report-store.js";
|
|
40
47
|
/** How many weeks the metrics cover, the current one included. */
|
|
41
48
|
export const DORA_WEEKS = 8;
|
|
42
49
|
/** An applied wave whose targets drift within this long counts as a failed change. */
|
|
@@ -45,8 +52,8 @@ export const DRIFT_WINDOW_SECONDS = 7 * 86400;
|
|
|
45
52
|
export const DORA_MIN_SPAN_SECONDS = 86400;
|
|
46
53
|
/** The file beside the estate page. */
|
|
47
54
|
export const DORA_FILE = "dora.json";
|
|
48
|
-
/** `<product>.dora/v1`: terragucci's schema name under terragucci's words. */
|
|
49
|
-
export const doraSchema = (words = CHANT_WORDS) => `${words.product}.dora/v1
|
|
55
|
+
/** `<product>.dora/v1`: terragucci's schema name under terragucci's words; `chant.dora/v1`, the neutral id, under `schemas: "neutral"` (#5336). */
|
|
56
|
+
export const doraSchema = (words = CHANT_WORDS, schemas = "product") => (schemas === "neutral" ? REPORT_SCHEMAS.dora : `${words.product}.dora/v1`);
|
|
50
57
|
const at = (iso) => (iso ? Date.parse(iso) || 0 : 0);
|
|
51
58
|
const secs = (from, to) => Math.max(0, Math.round((to - from) / 1000));
|
|
52
59
|
const WEEK_MS = 7 * 86400 * 1000;
|
|
@@ -202,7 +209,7 @@ export function spanLabel(seconds) {
|
|
|
202
209
|
return unit(Math.round(seconds / 86400), "day");
|
|
203
210
|
return unit(Math.round((seconds / WEEK_SECONDS) * 10) / 10, "week");
|
|
204
211
|
}
|
|
205
|
-
function metricsOf(ev, from, now) {
|
|
212
|
+
function metricsOf(ev, from, now, releases) {
|
|
206
213
|
const inside = (xs) => xs.filter((x) => x.at >= from && x.at <= now);
|
|
207
214
|
const applies = inside(ev.applies);
|
|
208
215
|
const deployments = applies.filter((a) => a.applied).length;
|
|
@@ -211,6 +218,7 @@ function metricsOf(ev, from, now) {
|
|
|
211
218
|
const leads = inside(ev.leads);
|
|
212
219
|
const restores = inside(ev.restores);
|
|
213
220
|
const span = spanOf(ev.applies, from, now);
|
|
221
|
+
const deploysIn = inside((releases ?? []).map((d) => ({ verb: d.verb, at: at(d.timestamp) })));
|
|
214
222
|
const trend = [];
|
|
215
223
|
for (let w = 0; w < DORA_WEEKS; w++) {
|
|
216
224
|
const start = from + w * WEEK_MS;
|
|
@@ -223,6 +231,7 @@ function metricsOf(ev, from, now) {
|
|
|
223
231
|
failures: of(inside(ev.failures)).length,
|
|
224
232
|
lead_time_seconds: median(of(leads).map((l) => l.total)),
|
|
225
233
|
restore_seconds: median(of(restores).map((r) => r.seconds)),
|
|
234
|
+
...(releases ? { promotes: of(deploysIn).filter((d) => d.verb === "promote").length, rollbacks: of(deploysIn).filter((d) => d.verb === "rollback").length } : {}),
|
|
226
235
|
});
|
|
227
236
|
}
|
|
228
237
|
return {
|
|
@@ -245,8 +254,14 @@ function metricsOf(ev, from, now) {
|
|
|
245
254
|
drift_restored: restores.filter((r) => r.kind === "drift").length,
|
|
246
255
|
},
|
|
247
256
|
trend,
|
|
257
|
+
...(releases ? { releases: { deploys: deploysIn.filter((d) => d.verb === "deploy").length, promotes: deploysIn.filter((d) => d.verb === "promote").length, rollbacks: deploysIn.filter((d) => d.verb === "rollback").length, redeploys: deploysIn.filter((d) => d.verb === "redeploy").length } } : {}),
|
|
248
258
|
};
|
|
249
259
|
}
|
|
260
|
+
/** `schema`, and `product` under the neutral id. CHANT_WORDS' id is the neutral one, so it names its product too. */
|
|
261
|
+
function head(words, schemas) {
|
|
262
|
+
const schema = doraSchema(words, schemas);
|
|
263
|
+
return schema === REPORT_SCHEMAS.dora ? { schema, product: (words ?? CHANT_WORDS).product } : { schema };
|
|
264
|
+
}
|
|
250
265
|
/** The metrics of every member and of the estate, from the ledger rows. */
|
|
251
266
|
export function buildDelivery(rows, options = {}) {
|
|
252
267
|
const now = options.now ?? new Date();
|
|
@@ -255,16 +270,20 @@ export function buildDelivery(rows, options = {}) {
|
|
|
255
270
|
const members = options.members ?? rows.members;
|
|
256
271
|
const applies = appliesOf(rows.waves);
|
|
257
272
|
const events = members.map((m) => eventsOf(m, rows, applies, options.commitTime));
|
|
273
|
+
// Promotes and rollbacks count when the ledger holds a deploy record; a member's are its own, and the estate's every record of the members asked for.
|
|
274
|
+
const releases = rows.releases?.length ? rows.releases : undefined;
|
|
275
|
+
const asked = options.members ? new Set(members) : undefined;
|
|
276
|
+
const mine = (m) => releases?.filter((d) => d.member === m);
|
|
258
277
|
return {
|
|
259
|
-
|
|
278
|
+
...head(options.words, options.schemas),
|
|
260
279
|
generated: now.toISOString(),
|
|
261
280
|
weeks: DORA_WEEKS,
|
|
262
281
|
window: { from: new Date(from).toISOString(), to: now.toISOString() },
|
|
263
282
|
drift_window_seconds: DRIFT_WINDOW_SECONDS,
|
|
264
283
|
audit: applies.length > 0,
|
|
265
284
|
source: "ledger",
|
|
266
|
-
estate: metricsOf(merge(events), from, end),
|
|
267
|
-
projects: members.map((m, i) => ({ project: m, ...metricsOf(events[i], from, end) })),
|
|
285
|
+
estate: metricsOf(merge(events), from, end, asked ? releases?.filter((d) => asked.has(d.member)) : releases),
|
|
286
|
+
projects: members.map((m, i) => ({ project: m, ...metricsOf(events[i], from, end, mine(m)) })),
|
|
268
287
|
};
|
|
269
288
|
}
|
|
270
289
|
/** "3d 4h", "2h 10m", "5m", "40s": how long, to two units. */
|
|
@@ -314,7 +333,7 @@ function recordApplies(entries) {
|
|
|
314
333
|
const seen = new Set();
|
|
315
334
|
const out = [];
|
|
316
335
|
for (const e of entries) {
|
|
317
|
-
if (e.kind !== "apply" || (e.result !== "applied" && e.result !== "failed") || seen.has(e.id))
|
|
336
|
+
if ((e.kind !== "apply" && e.kind !== "applied") || (e.result !== "applied" && e.result !== "failed") || seen.has(e.id))
|
|
318
337
|
continue;
|
|
319
338
|
seen.add(e.id);
|
|
320
339
|
const d = e.detail ?? {};
|
|
@@ -405,7 +424,7 @@ function recordEventsOf(source, entries, stages) {
|
|
|
405
424
|
const plans = rows.filter((r) => r.stage === stages.plan);
|
|
406
425
|
const incidents = recordDriftIncidents(rows.filter((r) => r.stage === stages.drift));
|
|
407
426
|
const requests = mine.filter((e) => e.kind === "approval-requested");
|
|
408
|
-
const approvals = new Map(mine.filter((e) => e.kind === "approval").map((e) => [e.id, e]));
|
|
427
|
+
const approvals = new Map(mine.filter((e) => e.kind === "approval" || e.kind === "approved").map((e) => [e.id, e]));
|
|
409
428
|
const leads = applies.filter((a) => a.applied).flatMap((a) => recordLead(a, plans, requests, approvals) ?? []);
|
|
410
429
|
const drifted = driftedApplies(applies, incidents);
|
|
411
430
|
const failures = applies.filter((a) => !a.applied || drifted.has(a)).map((a) => ({ project: a.project, at: a.at }));
|
|
@@ -428,7 +447,7 @@ export function buildRecordDelivery(sources, entries, options) {
|
|
|
428
447
|
const from = weekStart(end) - (DORA_WEEKS - 1) * WEEK_MS;
|
|
429
448
|
const events = sources.map((s) => recordEventsOf(s, entries ?? [], options.stages));
|
|
430
449
|
return {
|
|
431
|
-
|
|
450
|
+
...head(options.words, options.schemas),
|
|
432
451
|
generated: now.toISOString(),
|
|
433
452
|
weeks: DORA_WEEKS,
|
|
434
453
|
window: { from: new Date(from).toISOString(), to: now.toISOString() },
|
package/dist/ci-estate/page.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type CiProductWords } from "../ci-product-words.js";
|
|
2
2
|
import { type Dora } from "./delivery.js";
|
|
3
3
|
import type { LedgerOverdue } from "./overdue.js";
|
|
4
|
+
import { type ReportSchemaIds } from "../report-store.js";
|
|
4
5
|
import type { EstateRows } from "./rows.js";
|
|
5
|
-
/** `<product>.estate/v1
|
|
6
|
-
export declare const estateSchema: (words?: Pick<CiProductWords, "product"
|
|
6
|
+
/** `<product>.estate/v1`, or `chant.estate/v1`, the neutral id, under `schemas: "neutral"` (#5336). */
|
|
7
|
+
export declare const estateSchema: (words?: Pick<CiProductWords, "product">, schemas?: ReportSchemaIds) => string;
|
|
7
8
|
/** How many of the newest runs the page lists. */
|
|
8
9
|
export declare const RECENT_RUNS = 20;
|
|
9
10
|
/** The files the page writes. */
|
|
@@ -79,6 +80,8 @@ export interface EstateProject {
|
|
|
79
80
|
export interface Estate {
|
|
80
81
|
/** {@link estateSchema}. */
|
|
81
82
|
schema: string;
|
|
83
|
+
/** The product, under the neutral id `chant.estate/v1`. */
|
|
84
|
+
product?: string;
|
|
82
85
|
generated: string;
|
|
83
86
|
source: "ledger";
|
|
84
87
|
totals: {
|
|
@@ -103,6 +106,8 @@ export interface Estate {
|
|
|
103
106
|
}
|
|
104
107
|
export interface EstateOptions {
|
|
105
108
|
words?: Pick<CiProductWords, "product">;
|
|
109
|
+
/** `neutral` writes `chant.estate/v1` with `product`. Default `product`, `<product>.estate/v1`. */
|
|
110
|
+
schemas?: ReportSchemaIds;
|
|
106
111
|
now?: Date;
|
|
107
112
|
/** The members, in order. Default every member the rows name. */
|
|
108
113
|
members?: readonly string[];
|
|
@@ -117,7 +122,6 @@ export declare function memberState(member: string, rows: EstateRows, now: Date,
|
|
|
117
122
|
export declare function buildEstate(rows: EstateRows, dora: Dora | undefined, options?: EstateOptions): Estate;
|
|
118
123
|
/** HTML text escaped. */
|
|
119
124
|
export declare const esc: (s: string) => string;
|
|
120
|
-
/** The delivery section: the definitions, each member's numbers and the estate's, and a row per week. terragucci's renderDoraSection. */
|
|
121
125
|
export declare function renderDeliverySection(dora: Dora, link?: (project: string) => string): string;
|
|
122
126
|
/** A section a product adds: under each member, or at the end of the page. */
|
|
123
127
|
export interface EstateSections {
|
package/dist/ci-estate/page.js
CHANGED
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
import { samePlanDigest } from "../lifecycle/plan-digest.js";
|
|
18
18
|
import { CHANT_WORDS } from "../ci-product-words.js";
|
|
19
19
|
import { duration, spanLabel, DORA_FILE } from "./delivery.js";
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
import { REPORT_SCHEMAS } from "../report-store.js";
|
|
21
|
+
/** `<product>.estate/v1`, or `chant.estate/v1`, the neutral id, under `schemas: "neutral"` (#5336). */
|
|
22
|
+
export const estateSchema = (words = CHANT_WORDS, schemas = "product") => (schemas === "neutral" ? REPORT_SCHEMAS.estate : `${words.product}.estate/v1`);
|
|
22
23
|
/** How many of the newest runs the page lists. */
|
|
23
24
|
export const RECENT_RUNS = 20;
|
|
24
25
|
/** The files the page writes. */
|
|
@@ -128,7 +129,8 @@ export function buildEstate(rows, dora, options = {}) {
|
|
|
128
129
|
.slice(0, RECENT_RUNS);
|
|
129
130
|
const ephemeral = projects.reduce((n, p) => n + (p.ephemeral?.length ?? 0), 0);
|
|
130
131
|
return {
|
|
131
|
-
schema: estateSchema(options.words),
|
|
132
|
+
schema: estateSchema(options.words, options.schemas),
|
|
133
|
+
...(estateSchema(options.words, options.schemas) === REPORT_SCHEMAS.estate ? { product: (options.words ?? CHANT_WORDS).product } : {}),
|
|
132
134
|
generated: now.toISOString(),
|
|
133
135
|
source: "ledger",
|
|
134
136
|
totals: {
|
|
@@ -158,6 +160,19 @@ function doraRow(name, m) {
|
|
|
158
160
|
return `<tr><td>${name}</td><td>${m.per_week} <small>(${m.deployments} in ${spanLabel(m.span_seconds)})</small></td><td>${duration(l.median_seconds)}${split}</td><td>${rate(c.rate)} <small>(${c.failed} failed, ${c.drifted} drifted, of ${c.applies})</small></td><td>${duration(r.median_seconds)} <small>(${r.restored} restored${r.open ? `, <span class="warn">${r.open} open</span>` : ""})</small></td></tr>`;
|
|
159
161
|
}
|
|
160
162
|
/** The delivery section: the definitions, each member's numbers and the estate's, and a row per week. terragucci's renderDoraSection. */
|
|
163
|
+
/** The release ledger's promotes and rollbacks per member (#5336), when the metrics count them. */
|
|
164
|
+
function renderReleases(dora) {
|
|
165
|
+
const r = dora.estate.releases;
|
|
166
|
+
if (!r)
|
|
167
|
+
return "";
|
|
168
|
+
const row = (name, x) => `<tr><td>${name}</td><td>${x?.promotes ?? 0}</td><td>${x?.rollbacks ?? 0}</td><td>${x?.redeploys ?? 0}</td><td>${x?.deploys ?? 0}</td></tr>`;
|
|
169
|
+
return `<h3>Releases</h3>
|
|
170
|
+
<p>Deploy records on the release ledger in the window, by the command that wrote them.</p>
|
|
171
|
+
<div class="scroll"><table id="dora-releases"><tr><th>Member</th><th>Promotes</th><th>Rollbacks</th><th>Redeploys</th><th>Other deploys</th></tr>
|
|
172
|
+
${[row("<b>Estate</b>", r), ...dora.projects.map((p) => row(esc(p.project), p.releases))].join("\n")}
|
|
173
|
+
</table></div>
|
|
174
|
+
`;
|
|
175
|
+
}
|
|
161
176
|
export function renderDeliverySection(dora, link = esc) {
|
|
162
177
|
const weeks = dora.estate.trend.map((w) => `<tr><td>${esc(w.week)}</td><td>${w.deployments}</td><td>${w.applies}</td><td>${w.failures}</td><td>${duration(w.lead_time_seconds)}</td><td>${duration(w.restore_seconds)}</td></tr>`);
|
|
163
178
|
return `<p>The newest ${dora.weeks} weeks, from the workspace ledger${dora.audit ? "" : `. <span class="warn">The ledger holds no apply record yet, so only drift counts.</span>`}</p>
|
|
@@ -170,7 +185,7 @@ export function renderDeliverySection(dora, link = esc) {
|
|
|
170
185
|
<div class="scroll"><table id="dora"><tr><th>Member</th><th>Deployments per week</th><th>Lead time</th><th>Change failure rate</th><th>Time to restore</th></tr>
|
|
171
186
|
${[doraRow("<b>Estate</b>", dora.estate), ...dora.projects.map((p) => doraRow(link(p.project), p))].join("\n")}
|
|
172
187
|
</table></div>
|
|
173
|
-
<h3>By week</h3>
|
|
188
|
+
${renderReleases(dora)}<h3>By week</h3>
|
|
174
189
|
<div class="scroll"><table id="dora-weeks"><tr><th>Week of</th><th>Deployments</th><th>Applies</th><th>Failed changes</th><th>Lead time</th><th>Time to restore</th></tr>
|
|
175
190
|
${weeks.join("\n")}
|
|
176
191
|
</table></div>`;
|
package/dist/ci-estate/rows.d.ts
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import type { QueryData } from "../lifecycle/query.js";
|
|
15
15
|
import { type OpRunWave } from "../op/runtime.js";
|
|
16
|
-
/** The tables the estate reads. A full `QueryData` is one. */
|
|
17
|
-
export type EstateTables = Pick<QueryData, "runs" | "gates" | "applies" | "pr_envs"
|
|
16
|
+
/** The tables the estate reads. A full `QueryData` is one. `deploys` (the release ledger) is read when given, for the promotes and rollbacks (#5336). */
|
|
17
|
+
export type EstateTables = Pick<QueryData, "runs" | "gates" | "applies" | "pr_envs"> & Partial<Pick<QueryData, "deploys">>;
|
|
18
18
|
/** How the rows are read. */
|
|
19
19
|
export interface EstateRowOptions {
|
|
20
20
|
/** The name of a ledger read outside a workspace, whose rows have `member` NULL. Default `default`. */
|
|
@@ -104,6 +104,16 @@ export interface PrEnvLine {
|
|
|
104
104
|
expiresAt?: string;
|
|
105
105
|
runUrl?: string;
|
|
106
106
|
}
|
|
107
|
+
/** One deploy record of the release ledger (`<env>/releases.jsonl`), and the verb that wrote it (#5336). */
|
|
108
|
+
export interface ReleaseDeploy {
|
|
109
|
+
member: string;
|
|
110
|
+
env: string;
|
|
111
|
+
component: string;
|
|
112
|
+
timestamp: string;
|
|
113
|
+
/** `promote` names the environment it came from, `rollback` the deploy it restores, `redeploy` the running release it put back; `deploy` is any other. */
|
|
114
|
+
verb: "deploy" | "promote" | "rollback" | "redeploy";
|
|
115
|
+
runId?: string;
|
|
116
|
+
}
|
|
107
117
|
/** The rows, read. */
|
|
108
118
|
export interface EstateRows {
|
|
109
119
|
members: string[];
|
|
@@ -112,6 +122,8 @@ export interface EstateRows {
|
|
|
112
122
|
gates: GateLine[];
|
|
113
123
|
approved: ApprovedApply[];
|
|
114
124
|
prEnvs: PrEnvLine[];
|
|
125
|
+
/** The release ledger's deploy records, when the tables hold `deploys`. */
|
|
126
|
+
releases?: ReleaseDeploy[];
|
|
115
127
|
}
|
|
116
128
|
/** Read the tables into the shapes the estate uses. Malformed JSON cells read as absent. */
|
|
117
129
|
export declare function estateRows(tables: EstateTables, options?: EstateRowOptions): EstateRows;
|
package/dist/ci-estate/rows.js
CHANGED
|
@@ -121,6 +121,14 @@ export function estateRows(tables, options = {}) {
|
|
|
121
121
|
...(str(p.expires_at) ? { expiresAt: str(p.expires_at) } : {}),
|
|
122
122
|
...(str(p.run_url) ? { runUrl: str(p.run_url) } : {}),
|
|
123
123
|
}));
|
|
124
|
+
const releases = (tables.deploys ?? []).map((d) => ({
|
|
125
|
+
member: memberOf(d, project),
|
|
126
|
+
env: String(d.env),
|
|
127
|
+
component: String(d.component),
|
|
128
|
+
timestamp: str(d.timestamp) ?? "",
|
|
129
|
+
verb: parsed(d.promoted_from) ? "promote" : parsed(d.restores) ? "rollback" : parsed(d.redeploys) ? "redeploy" : "deploy",
|
|
130
|
+
...(str(d.run_id) ? { runId: str(d.run_id) } : {}),
|
|
131
|
+
}));
|
|
124
132
|
const members = [...new Set([...waves, ...drift, ...gates, ...approved, ...prEnvs].map((x) => x.member))].sort();
|
|
125
|
-
return { members, waves, drift, gates, approved, prEnvs };
|
|
133
|
+
return { members, waves, drift, gates, approved, prEnvs, ...(tables.deploys ? { releases } : {}) };
|
|
126
134
|
}
|
package/dist/ci-estate.d.ts
CHANGED
|
@@ -30,13 +30,14 @@ import type { OtlpFetch } from "./otlp.js";
|
|
|
30
30
|
import { type Dora } from "./ci-estate/delivery.js";
|
|
31
31
|
import { type DriftSchedule, type LedgerOverdue } from "./ci-estate/overdue.js";
|
|
32
32
|
import { type Estate, type EstateSections } from "./ci-estate/page.js";
|
|
33
|
+
import type { ReportSchemaIds } from "./report-store.js";
|
|
33
34
|
import { type EstateRowOptions, type EstateRows, type EstateTables } from "./ci-estate/rows.js";
|
|
34
35
|
/** The first chant with `@intentius/chant/ci-estate` (#4612). */
|
|
35
36
|
export declare const CI_ESTATE_FLOOR = "0.124.55";
|
|
36
37
|
/** The first chant with `buildRecordDelivery`: delivery metrics from a product's report index and audit trail (#4612). Products feature-detect on it. */
|
|
37
38
|
export declare const CI_ESTATE_RECORDS_FLOOR = "0.124.72";
|
|
38
|
-
export { estateRows, type ApprovedApply, type DriftRun, type EstateRowOptions, type EstateRows, type EstateTables, type GateLine, type PrEnvLine, type WaveJob } from "./ci-estate/rows.js";
|
|
39
|
-
export { appliesOf, buildDelivery, buildRecordDelivery, recordDriftIncidents, deliveryGauges, doraMetricNames, doraSchema, driftIncidents, duration, median, spanLabel, weekStart, DORA_FILE, DORA_MIN_SPAN_SECONDS, DORA_WEEKS, DRIFT_WINDOW_SECONDS, type DeliveryAuditEntry, type DeliveryGauge, type DeliveryIndexRow, type DeliveryOptions, type DeliveryRecordSource, type RecordDeliveryOptions, type Dora, type DoraLeadTime, type DoraMetrics, type DoraProject, type DoraWeek, type DriftIncident, } from "./ci-estate/delivery.js";
|
|
39
|
+
export { estateRows, type ApprovedApply, type ReleaseDeploy, type DriftRun, type EstateRowOptions, type EstateRows, type EstateTables, type GateLine, type PrEnvLine, type WaveJob } from "./ci-estate/rows.js";
|
|
40
|
+
export { appliesOf, buildDelivery, buildRecordDelivery, recordDriftIncidents, deliveryGauges, doraMetricNames, doraSchema, driftIncidents, duration, median, spanLabel, weekStart, DORA_FILE, DORA_MIN_SPAN_SECONDS, DORA_WEEKS, DRIFT_WINDOW_SECONDS, type DeliveryAuditEntry, type DoraReleases, type DeliveryGauge, type DeliveryIndexRow, type DeliveryOptions, type DeliveryRecordSource, type RecordDeliveryOptions, type Dora, type DoraLeadTime, type DoraMetrics, type DoraProject, type DoraWeek, type DriftIncident, } from "./ci-estate/delivery.js";
|
|
40
41
|
export { ledgerOverdue, type DriftSchedule, type LedgerOverdue, type LedgerOverdueOptions } from "./ci-estate/overdue.js";
|
|
41
42
|
export { buildEstate, esc, estateSchema, memberState, renderDeliverySection, renderEstateHtml, ESTATE_FILES, RECENT_RUNS, type Estate, type EstateOptions, type EstatePrEnv, type EstateProject, type EstateRun, type EstateSections, type EstateWaiting, } from "./ci-estate/page.js";
|
|
42
43
|
export { otlpMetricsBody, otlpMetricsFromEnv, sendOtlpGauges, type OtlpGauge, type OtlpGaugesSent, type OtlpMetricsConfig } from "./otlp-metrics.js";
|
|
@@ -44,6 +45,8 @@ export interface LedgerEstateInput extends EstateRowOptions {
|
|
|
44
45
|
/** The tables, as `loadQueryData` returned them (a `QueryLoad`), or the tables alone. */
|
|
45
46
|
load: QueryLoad | EstateTables;
|
|
46
47
|
words?: Pick<CiProductWords, "product" | "stages" | "noun">;
|
|
48
|
+
/** `neutral` writes `chant.estate/v1` and `chant.dora/v1`, each with `product` (#5336). Default `product`, the product-named ids. */
|
|
49
|
+
schemas?: ReportSchemaIds;
|
|
47
50
|
now?: Date;
|
|
48
51
|
/** The members, in order. Default every member the ledger names. */
|
|
49
52
|
members?: readonly string[];
|
package/dist/ci-estate.js
CHANGED
|
@@ -46,8 +46,9 @@ export function buildLedgerEstate(input) {
|
|
|
46
46
|
const rows = estateRows(tables, { ...(input.project ? { project: input.project } : {}), ...(input.driftOps ? { driftOps: input.driftOps } : {}), ...(input.deployOps ? { deployOps: input.deployOps } : {}) });
|
|
47
47
|
const members = input.members ?? rows.members;
|
|
48
48
|
const overdue = ledgerOverdue(rows, input.schedules ?? [], { words, now, ...(input.added ? { added: input.added } : {}) });
|
|
49
|
-
const
|
|
50
|
-
const
|
|
49
|
+
const schemas = input.schemas ? { schemas: input.schemas } : {};
|
|
50
|
+
const dora = buildDelivery(rows, { words, now, members, ...schemas, ...(input.commitTime ? { commitTime: input.commitTime } : {}) });
|
|
51
|
+
const estate = buildEstate(rows, dora, { words, now, members, overdue, ...schemas, ...(malformed ? { malformed } : {}) });
|
|
51
52
|
return { rows, estate, dora, overdue };
|
|
52
53
|
}
|
|
53
54
|
/** The three files by name: `estate.json`, `estate.html` and `dora.json`. */
|