@intentius/chant 0.124.77 → 0.124.79
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__/notify-messages/events.d.ts +9 -0
- package/dist/__fixtures__/notify-messages/events.d.ts.map +1 -0
- package/dist/__fixtures__/notify-messages/events.js +21 -0
- package/dist/__fixtures__/product-words.d.ts +14 -0
- package/dist/__fixtures__/product-words.d.ts.map +1 -1
- package/dist/__fixtures__/product-words.js +11 -0
- package/dist/__fixtures__/terragucci-notify.d.ts +66 -0
- package/dist/__fixtures__/terragucci-notify.d.ts.map +1 -0
- package/dist/__fixtures__/terragucci-notify.js +133 -0
- package/dist/action-pins.d.ts +8 -0
- package/dist/action-pins.d.ts.map +1 -1
- package/dist/action-pins.js +8 -0
- package/dist/agent-guard.d.ts.map +1 -1
- package/dist/agent-guard.js +1 -2
- package/dist/change-set.d.ts +10 -1
- package/dist/change-set.d.ts.map +1 -1
- package/dist/change-set.js +4 -1
- package/dist/ci-agent.d.ts +16 -2
- package/dist/ci-agent.d.ts.map +1 -1
- package/dist/ci-agent.js +6 -1
- package/dist/ci-commit.d.ts +66 -2
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +147 -19
- package/dist/ci-own-jobs.d.ts.map +1 -1
- package/dist/ci-own-jobs.js +1 -2
- package/dist/ci-product-words.d.ts +18 -4
- package/dist/ci-product-words.d.ts.map +1 -1
- package/dist/ci-product-words.js +26 -6
- package/dist/ci-product.d.ts +7 -3
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +8 -5
- package/dist/cli/handlers/release.d.ts +8 -0
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +68 -6
- package/dist/cli/handlers/run-wave.js +1 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +7 -0
- package/dist/cli/mcp/product-tools.d.ts +6 -0
- package/dist/cli/mcp/product-tools.d.ts.map +1 -1
- package/dist/cli/mcp/product-tools.js +7 -0
- package/dist/cli/mcp/read-only.d.ts +12 -0
- package/dist/cli/mcp/read-only.d.ts.map +1 -1
- package/dist/cli/mcp/read-only.js +16 -0
- package/dist/cli/mcp/server.d.ts +11 -0
- package/dist/cli/mcp/server.d.ts.map +1 -1
- package/dist/cli/mcp/server.js +26 -5
- package/dist/cli/mcp/types.d.ts +5 -1
- package/dist/cli/mcp/types.d.ts.map +1 -1
- package/dist/components/capability.d.ts +42 -0
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/components/group-digest.d.ts +17 -0
- package/dist/components/group-digest.d.ts.map +1 -0
- package/dist/components/group-digest.js +18 -0
- package/dist/components/groups.d.ts +2 -11
- package/dist/components/groups.d.ts.map +1 -1
- package/dist/components/groups.js +2 -12
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/pr-env-components.d.ts.map +1 -1
- package/dist/components/pr-env-components.js +1 -2
- package/dist/config.d.ts +28 -8
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +21 -1
- package/dist/lexicon.d.ts +8 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lexicon.js +8 -0
- package/dist/lifecycle/release-cut.d.ts +7 -1
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +1 -0
- package/dist/lifecycle/release-images.d.ts +86 -3
- package/dist/lifecycle/release-images.d.ts.map +1 -1
- package/dist/lifecycle/release-images.js +131 -6
- package/dist/lifecycle/release-publish.d.ts +8 -1
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/lifecycle/release-publish.js +30 -3
- package/dist/lifecycle/release-version.d.ts +86 -0
- package/dist/lifecycle/release-version.d.ts.map +1 -0
- package/dist/lifecycle/release-version.js +209 -0
- package/dist/mcp/types.d.ts +26 -0
- package/dist/mcp/types.d.ts.map +1 -1
- package/dist/notify-product.d.ts +11 -2
- package/dist/notify-product.d.ts.map +1 -1
- package/dist/notify-product.js +15 -4
- package/dist/notify-relay.d.ts.map +1 -1
- package/dist/notify-relay.js +1 -2
- package/dist/notify.d.ts +36 -4
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +31 -21
- package/dist/notify.schema.json +1 -0
- package/dist/op/activities/review-product.d.ts +111 -0
- package/dist/op/activities/review-product.d.ts.map +1 -0
- package/dist/op/activities/review-product.js +115 -0
- package/dist/op/gate.d.ts +17 -0
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +36 -0
- package/dist/op/index.d.ts +8 -6
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +5 -4
- package/dist/op/op-waves-after-plan.d.ts +76 -1
- package/dist/op/op-waves-after-plan.d.ts.map +1 -1
- package/dist/op/op-waves-after-plan.js +142 -3
- package/dist/op/op-waves-capability-spec.js +1 -2
- package/dist/op/op-waves-capability.d.ts +89 -2
- package/dist/op/op-waves-capability.d.ts.map +1 -1
- package/dist/op/op-waves-capability.js +215 -7
- package/dist/op/op-waves-run-hooks.d.ts +104 -0
- package/dist/op/op-waves-run-hooks.d.ts.map +1 -0
- package/dist/op/op-waves-run-hooks.js +146 -0
- package/dist/op/op-waves-run.d.ts +21 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +233 -13
- package/dist/op/op-waves.d.ts +11 -1
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +7 -1
- package/dist/op/runtime.d.ts +2 -0
- package/dist/op/runtime.d.ts.map +1 -1
- package/dist/policy-engine.d.ts.map +1 -1
- package/dist/policy-engine.js +1 -2
- package/dist/pr-forge-reads.d.ts +124 -0
- package/dist/pr-forge-reads.d.ts.map +1 -0
- package/dist/pr-forge-reads.js +322 -0
- package/dist/pr-forge.d.ts +14 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +21 -13
- package/dist/pr-plan-note.d.ts +293 -0
- package/dist/pr-plan-note.d.ts.map +1 -0
- package/dist/pr-plan-note.js +361 -0
- package/dist/release-floors.d.ts +13 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +13 -1
- package/dist/state-export.d.ts.map +1 -1
- package/dist/state-export.js +1 -2
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +1 -2
- package/dist/state-unlock.d.ts.map +1 -1
- package/dist/state-unlock.js +1 -2
- package/dist/wave-runtime.mjs +314 -314
- package/dist/workspace/change-set.schema.json +7 -0
- package/dist/workspace/release-workflow.d.ts +7 -0
- package/dist/workspace/release-workflow.d.ts.map +1 -1
- package/dist/workspace/release-workflow.js +13 -2
- package/package.json +1 -1
- package/src/__fixtures__/notify-messages/events.ts +23 -0
- package/src/__fixtures__/notify-messages/messages.json +50 -0
- package/src/__fixtures__/pr-loop/terragucci-plan.note.golden.md +53 -0
- package/src/__fixtures__/pr-loop/terragucci-plan.note.json +83 -0
- package/src/__fixtures__/product-words.ts +12 -0
- package/src/__fixtures__/review-agent/terragucci-review.json +94 -0
- package/src/__fixtures__/terragucci-notify.ts +170 -0
- package/src/action-pins.test.ts +11 -1
- package/src/action-pins.ts +9 -0
- package/src/agent-guard.test.ts +1 -2
- package/src/agent-guard.ts +1 -2
- package/src/change-set.test.ts +20 -0
- package/src/change-set.ts +11 -1
- package/src/ci-agent.test.ts +9 -0
- package/src/ci-agent.ts +15 -2
- package/src/ci-commit.test.ts +162 -0
- package/src/ci-commit.ts +167 -21
- package/src/ci-own-jobs.test.ts +1 -2
- package/src/ci-own-jobs.ts +1 -2
- package/src/ci-product-words.ts +35 -7
- package/src/ci-product.ts +9 -6
- package/src/cli/handlers/build-pr-loop-control.test.ts +1 -2
- package/src/cli/handlers/build-run-group.test.ts +1 -2
- package/src/cli/handlers/release.ts +60 -7
- package/src/cli/handlers/run-wave.ts +1 -0
- package/src/cli/main.ts +7 -0
- package/src/cli/mcp/product-tools.test.ts +50 -0
- package/src/cli/mcp/product-tools.ts +8 -0
- package/src/cli/mcp/read-only.ts +19 -0
- package/src/cli/mcp/server.test.ts +30 -0
- package/src/cli/mcp/server.ts +28 -5
- package/src/cli/mcp/types.ts +6 -1
- package/src/components/capability.ts +41 -0
- package/src/components/group-digest.ts +20 -0
- package/src/components/groups.ts +3 -13
- package/src/components/index.ts +2 -0
- package/src/components/pr-env-components.test.ts +1 -2
- package/src/components/pr-env-components.ts +1 -2
- package/src/config.ts +38 -3
- package/src/gate-policy-bundle.test.ts +1 -1
- package/src/lexicon.ts +9 -0
- package/src/lifecycle/release-cut.ts +11 -0
- package/src/lifecycle/release-images-dockerfile.test.ts +229 -0
- package/src/lifecycle/release-images.ts +171 -8
- package/src/lifecycle/release-publish.ts +34 -3
- package/src/lifecycle/release-version.test.ts +155 -0
- package/src/lifecycle/release-version.ts +227 -0
- package/src/mcp/types.ts +27 -0
- package/src/notify-message-words.test.ts +185 -0
- package/src/notify-product.ts +16 -4
- package/src/notify-relay.ts +1 -2
- package/src/notify.schema.json +1 -0
- package/src/notify.ts +59 -19
- package/src/op/activities/review-product.test.ts +116 -0
- package/src/op/activities/review-product.ts +199 -0
- package/src/op/gate.ts +46 -0
- package/src/op/index.ts +10 -4
- package/src/op/op-waves-after-plan-wave.test.ts +226 -0
- package/src/op/op-waves-after-plan.ts +170 -5
- package/src/op/op-waves-capability-spec.ts +1 -1
- package/src/op/op-waves-capability.test.ts +6 -0
- package/src/op/op-waves-capability.ts +243 -10
- package/src/op/op-waves-run-hooks.test.ts +184 -0
- package/src/op/op-waves-run-hooks.ts +195 -0
- package/src/op/op-waves-run.ts +240 -16
- package/src/op/op-waves-step-wave.test.ts +277 -0
- package/src/op/op-waves.ts +15 -2
- package/src/op/runtime.ts +2 -0
- package/src/op/schedule-overdue.test.ts +26 -0
- package/src/policy-engine.test.ts +1 -2
- package/src/policy-engine.ts +1 -2
- package/src/pr-forge-reads.test.ts +285 -0
- package/src/pr-forge-reads.ts +424 -0
- package/src/pr-forge.ts +30 -16
- package/src/pr-plan-note.test.ts +105 -0
- package/src/pr-plan-note.ts +520 -0
- package/src/release-floors.ts +19 -1
- package/src/state-export.test.ts +1 -2
- package/src/state-export.ts +1 -2
- package/src/state-migration.test.ts +1 -2
- package/src/state-migration.ts +1 -2
- package/src/state-unlock.test.ts +1 -2
- package/src/state-unlock.ts +1 -2
- package/src/workspace/change-set.schema.json +7 -0
- package/src/workspace/release-workflow.test.ts +18 -0
- package/src/workspace/release-workflow.ts +23 -2
|
@@ -0,0 +1,520 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A product's plan note (#4810): the pull-request note for a product whose
|
|
3
|
+
* plan job does not run chant's pr loop, rendered from a report the product
|
|
4
|
+
* builds from its own plan run, in the product's words.
|
|
5
|
+
*
|
|
6
|
+
* terragucci plans each root itself and writes its own report, so it has no
|
|
7
|
+
* `PrReport` for `renderPrNote` (./pr-loop.ts). It hands chant a
|
|
8
|
+
* {@link PrPlanNote} instead: the note's rows by unit (a root, or an
|
|
9
|
+
* instance of one root), the totals in the binary's own counting, the named
|
|
10
|
+
* destroys, replacements, refusals, imports and forgets, each group with the
|
|
11
|
+
* diff of its first unit, each unit's whole plan, the wave table and the
|
|
12
|
+
* waves marker, the policy overrides and warnings, the deferred units, the
|
|
13
|
+
* previewed waves and the units planned on another's planned outputs, the
|
|
14
|
+
* report links, and the lines and sections only the product knows about
|
|
15
|
+
* (its notices, a cost table, a blast radius). chant lays them out, links
|
|
16
|
+
* them into the report, and cuts the note to the forge's limit: whole plans
|
|
17
|
+
* go first, then group diffs shrink to attribute names, whichever saves the
|
|
18
|
+
* most first, then blocks drop from the end, and a Cut line names what went.
|
|
19
|
+
*
|
|
20
|
+
* The pr loop's bundle (pr-loop-bundle.test.ts) does not carry this module,
|
|
21
|
+
* so a product's sections do not grow it. {@link renderPrNote} here takes
|
|
22
|
+
* either report and renders a `PrReport` with the pr loop's own renderer,
|
|
23
|
+
* so a plywood or sql-yodeler note is byte for byte what it was.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { renderPrNote as renderPrLoopNote, type PrReport } from "./pr-loop";
|
|
27
|
+
import { GITHUB_COMMENT_LIMIT } from "./plan-summary";
|
|
28
|
+
import { activeProductWords, approveLine, overrideLine, type CiProductWords } from "./ci-product-words";
|
|
29
|
+
|
|
30
|
+
/** The first chant with the product plan note (#4810). */
|
|
31
|
+
export const PR_PLAN_NOTE_FLOOR = "0.124.78";
|
|
32
|
+
|
|
33
|
+
/** The read contract a {@link PrPlanNote} follows. */
|
|
34
|
+
export const PR_PLAN_NOTE_CONTRACT = 1;
|
|
35
|
+
|
|
36
|
+
/** One change line of a group, as chant's plan summary groups them. */
|
|
37
|
+
export interface PrPlanNoteChange {
|
|
38
|
+
line: string;
|
|
39
|
+
count: number;
|
|
40
|
+
differsFrom?: string;
|
|
41
|
+
differsIn?: string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A group of units with the same change. */
|
|
45
|
+
export interface PrPlanNoteGroup {
|
|
46
|
+
id: string;
|
|
47
|
+
units: string[];
|
|
48
|
+
/** The one resource an instance group is of. */
|
|
49
|
+
resource?: string;
|
|
50
|
+
outlier?: boolean;
|
|
51
|
+
noChanges?: boolean;
|
|
52
|
+
/** The group whose change this one adds to; `changes` are then what it adds. */
|
|
53
|
+
extends?: string;
|
|
54
|
+
/** Every change of the group is one on every run: the note shows its attribute names alone. */
|
|
55
|
+
recurring?: boolean;
|
|
56
|
+
/** The group's change lines (or what it adds to `extends`). */
|
|
57
|
+
changes: PrPlanNoteChange[];
|
|
58
|
+
/** The plan text of the group's first unit, as the binary printed it: the note shows it as a `diff` block. */
|
|
59
|
+
diff?: { unit: string; lines: string[] };
|
|
60
|
+
/** Where values differ between the group's units, as `address.path`. */
|
|
61
|
+
varies?: string[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** A destroy, replacement, refusal, import or forget, kept when the note is cut. */
|
|
65
|
+
export interface PrPlanNoteNamed {
|
|
66
|
+
/** The unit it is in (a root). */
|
|
67
|
+
member: string;
|
|
68
|
+
address?: string;
|
|
69
|
+
deposed?: string;
|
|
70
|
+
action: "delete" | "replace" | "refused" | "import" | "forget";
|
|
71
|
+
/** The word the note shows for the action. Default: destroy, replace, refused to plan, import, forget. */
|
|
72
|
+
word?: string;
|
|
73
|
+
/** The attribute paths that forced a replacement, each joined with `.`. */
|
|
74
|
+
forcedBy?: string[];
|
|
75
|
+
reason?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** A wave's row. A plan names each wave's review digest; an apply names its set digest and approval. */
|
|
79
|
+
export interface PrPlanNoteWave {
|
|
80
|
+
number: number;
|
|
81
|
+
/** How many units it holds. */
|
|
82
|
+
units: number;
|
|
83
|
+
composed?: boolean;
|
|
84
|
+
/** The environments its units are in. Set on every wave when the table shows the column. */
|
|
85
|
+
environments?: string[];
|
|
86
|
+
/** The digest an approval of the wave binds. Present (even null) on any wave puts the table in review form. */
|
|
87
|
+
digest?: string | null;
|
|
88
|
+
/** Whether the gate will hold it for an approval. */
|
|
89
|
+
waits?: boolean;
|
|
90
|
+
/** The waves it plans again after. */
|
|
91
|
+
replansAfter?: number[];
|
|
92
|
+
/** Units whose plan reads a value unknown at plan time, which holds it. */
|
|
93
|
+
unknownBy?: string[];
|
|
94
|
+
/** Units whose hook asks for an approval. */
|
|
95
|
+
heldByHooks?: string[];
|
|
96
|
+
/** What the policy said of the wave: held by its rules, or allowed unattended by them. */
|
|
97
|
+
policy?: { outcome: "held" | "unattended" | string; rules: string[] };
|
|
98
|
+
/** The approval rules at base, each with what it asks for in words. */
|
|
99
|
+
approvalRules?: { units: string[]; asks: string }[];
|
|
100
|
+
/** An apply's set digest and approval, in the other form of the table. */
|
|
101
|
+
setDigest?: string;
|
|
102
|
+
approval?: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** A denial a listed approver may override, or the override that stands. */
|
|
106
|
+
export interface PrPlanNoteOverride {
|
|
107
|
+
member: string;
|
|
108
|
+
/** The rules the override names, else those that denied. */
|
|
109
|
+
rules: string[];
|
|
110
|
+
override?: { by: string; at: string; sealed?: boolean; plan: string; reason: string };
|
|
111
|
+
/** Who may override it; an empty list names nobody. */
|
|
112
|
+
overriders: string[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** A line under the counts that may link into the report. */
|
|
116
|
+
export interface PrPlanNoteFact {
|
|
117
|
+
text: string;
|
|
118
|
+
/** Linked to the report's anchor when the note links report.html itself; else `plain`, or the text alone. */
|
|
119
|
+
link?: { text: string; anchor: string; plain?: string };
|
|
120
|
+
after?: string;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* What a product hands chant for its plan note: everything the note shows,
|
|
125
|
+
* built from the product's own plan run.
|
|
126
|
+
*/
|
|
127
|
+
export interface PrPlanNote {
|
|
128
|
+
kind: "plan-note";
|
|
129
|
+
contract: typeof PR_PLAN_NOTE_CONTRACT;
|
|
130
|
+
/** The stage as the heading names it, such as `tf-plan`. */
|
|
131
|
+
stage: string;
|
|
132
|
+
/** A plan of a pull request (not an apply or a drift check). */
|
|
133
|
+
planning?: boolean;
|
|
134
|
+
wave?: number;
|
|
135
|
+
/** The commit planned. */
|
|
136
|
+
head: string;
|
|
137
|
+
/** `instance`: the units are instances of one root. Default: the product's noun. */
|
|
138
|
+
unit?: "member" | "instance";
|
|
139
|
+
units: number;
|
|
140
|
+
/** The run's total in the binary's own counting: a replacement adds one and destroys one. */
|
|
141
|
+
totals?: { add: number; change: number; destroy: number; forget: number; members: number };
|
|
142
|
+
/** The change reaches no unit, so nothing was planned. */
|
|
143
|
+
nothing?: boolean;
|
|
144
|
+
/** Lines about the pipeline itself, such as overdue drift checks. */
|
|
145
|
+
notices?: string[];
|
|
146
|
+
/** The product's lines under them: tips, binaries, cost, the slowest resources. */
|
|
147
|
+
facts?: PrPlanNoteFact[];
|
|
148
|
+
named: PrPlanNoteNamed[];
|
|
149
|
+
overrides?: PrPlanNoteOverride[];
|
|
150
|
+
warnings?: { member: string; text: string }[];
|
|
151
|
+
deferred?: { unit: string; after: string[]; why: string; previewed?: boolean }[];
|
|
152
|
+
waves: PrPlanNoteWave[];
|
|
153
|
+
/** What the waves marker carries beside the waves. */
|
|
154
|
+
previews?: unknown[];
|
|
155
|
+
/** Waves planned at their gate against the preview a pull request showed. */
|
|
156
|
+
previewed?: { wave: number; pullRequest: number | string; units: number; moved: { unit: string; differences: string[] }[] }[];
|
|
157
|
+
/** Units planned on another unit's planned outputs. */
|
|
158
|
+
linked?: { member: string; upstream: string; composed?: boolean; unknown?: string[] }[];
|
|
159
|
+
/** The product's own blocks: `start` before the named changes, `groups` before the groups, `end` after them. Each text as it is shown. */
|
|
160
|
+
sections?: { at: "start" | "groups" | "end"; text: string }[];
|
|
161
|
+
groups: PrPlanNoteGroup[];
|
|
162
|
+
/** Each unit's whole plan, collapsed: its text, its totals line, and its plan file beside the report or at a link. */
|
|
163
|
+
plans?: { member: string; text: string; totals?: string; file?: string; url?: string }[];
|
|
164
|
+
/**
|
|
165
|
+
* Where the report is: `report`, report.html or the run's page when
|
|
166
|
+
* `artifacts`; `run`, the run's page when the run keeps no report;
|
|
167
|
+
* `expires`, when presigned links stop working.
|
|
168
|
+
*/
|
|
169
|
+
links?: { report?: string; artifacts?: boolean; run?: string; expires?: string };
|
|
170
|
+
/** A waiting wave's approve line and an override line ask for a signature. */
|
|
171
|
+
sealed?: boolean;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** The plan note's own words; every slot defaults to chant's. */
|
|
175
|
+
export interface PrPlanNoteWords {
|
|
176
|
+
/** The note's last line. */
|
|
177
|
+
footer?: string;
|
|
178
|
+
/** The report page's file name. */
|
|
179
|
+
page?: string;
|
|
180
|
+
/** The artifact the run keeps the report in. */
|
|
181
|
+
artifact?: string;
|
|
182
|
+
/** The line for a run that keeps no report, over `{run}`. */
|
|
183
|
+
noReport?: string;
|
|
184
|
+
/** The waves marker's name. Default `<product>:waves`. */
|
|
185
|
+
marker?: string;
|
|
186
|
+
/** The report's anchors for a unit and a group, over `{id}`. */
|
|
187
|
+
anchors?: { member?: string; group?: string };
|
|
188
|
+
/** The setting that names who may override a denial. */
|
|
189
|
+
overrideKey?: string;
|
|
190
|
+
/** The setting that holds the approval rules. */
|
|
191
|
+
approvalRulesKey?: string;
|
|
192
|
+
/** The stage that applies the plan. */
|
|
193
|
+
applyStage?: string;
|
|
194
|
+
/** The file each unit's plan is kept in. */
|
|
195
|
+
planFile?: string;
|
|
196
|
+
/** The op an override is recorded under. */
|
|
197
|
+
overrideOp?: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const NOTE_WORDS: Required<Omit<PrPlanNoteWords, "marker">> = {
|
|
201
|
+
footer: "",
|
|
202
|
+
page: "report.html",
|
|
203
|
+
artifact: "chant-pr",
|
|
204
|
+
noReport: "Planned in [this run]({run}), which keeps no report artifact.",
|
|
205
|
+
anchors: { member: "member-{id}", group: "group-{id}" },
|
|
206
|
+
overrideKey: "ci.policy",
|
|
207
|
+
approvalRulesKey: "approval rules",
|
|
208
|
+
applyStage: "apply",
|
|
209
|
+
planFile: "plan.txt",
|
|
210
|
+
overrideOp: "policy-override",
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
/** Options for {@link renderPlanNote}. */
|
|
214
|
+
export interface PlanNoteOptions {
|
|
215
|
+
/** The most characters the note may hold. Default GitHub's 65,536. */
|
|
216
|
+
limit?: number;
|
|
217
|
+
words?: CiProductWords;
|
|
218
|
+
note?: PrPlanNoteWords;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* The note for either report: a `PrReport` as the pr loop renders it, or a
|
|
223
|
+
* product's {@link PrPlanNote}.
|
|
224
|
+
*/
|
|
225
|
+
export function renderPrNote(report: PrReport | PrPlanNote, options: NonNullable<Parameters<typeof renderPrLoopNote>[1]> & { note?: PrPlanNoteWords } = {}): string {
|
|
226
|
+
return isPlanNote(report) ? renderPlanNote(report, options) : renderPrLoopNote(report, options);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** Whether `report` is a product's plan note. */
|
|
230
|
+
export function isPlanNote(report: unknown): report is PrPlanNote {
|
|
231
|
+
return typeof report === "object" && report !== null && (report as { kind?: unknown }).kind === "plan-note";
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const code = (s: string): string => "`" + s.replaceAll("`", "'") + "`";
|
|
235
|
+
const codePoints = (s: string): number => [...s].length;
|
|
236
|
+
const plural = (n: number, one: string, many = `${one}s`): string => `${n} ${n === 1 ? one : many}`;
|
|
237
|
+
const joinAnd = (xs: readonly string[]): string => (xs.length <= 1 ? (xs[0] ?? "") : `${xs.slice(0, -1).join(", ")} and ${xs[xs.length - 1]}`);
|
|
238
|
+
const esc = (s: string): string => s.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
239
|
+
const capital = (s: string): string => s.charAt(0).toUpperCase() + s.slice(1);
|
|
240
|
+
const oneLine = (s: string): string => s.split(/\s+/).join(" ");
|
|
241
|
+
/** A time as the note shows it: `2026-10-15 10:03 UTC`. */
|
|
242
|
+
const utc = (iso: string): string => iso.replace("T", " ").replace(/:\d{2}(\.\d+)?Z$/, " UTC");
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Lines as a `diff` block wants them, as Atlantis comments a plan: each
|
|
246
|
+
* line's change symbol (`+`, `-`, `~`, `-/+`, `+/-`) moves to the first
|
|
247
|
+
* column, so the forge colours additions and removals.
|
|
248
|
+
*/
|
|
249
|
+
export function diffLines(lines: readonly string[]): string[] {
|
|
250
|
+
return lines.map((l) => l.replace(/^(\s+)(-\/\+|\+\/-|[-+~])(?= )/, "$2$1"));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** A fenced `diff` block whose fence is longer than any run of backticks in the text. */
|
|
254
|
+
export function diffFence(lines: readonly string[]): string {
|
|
255
|
+
const body = lines.join("\n");
|
|
256
|
+
const longest = Math.max(0, ...[...body.matchAll(/`+/g)].map((m) => m[0].length));
|
|
257
|
+
const fence = "`".repeat(Math.max(3, longest + 1));
|
|
258
|
+
return `${fence}diff\n${body}\n${fence}\n`;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** The waves marker: an HTML comment with no `<` or `>` in its JSON, so nothing in it ends the comment. */
|
|
262
|
+
export function planNoteMarker(name: string, waves: { head: string; waves: { number: number; digest: string | null; waits: boolean }[]; previews?: unknown[] }): string {
|
|
263
|
+
return `<!-- ${name} ${JSON.stringify(waves).replace(/</g, "\\u003c").replace(/>/g, "\\u003e")} -->`;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
interface Block {
|
|
267
|
+
text: string;
|
|
268
|
+
kind: "line" | "group" | "plan";
|
|
269
|
+
units: number;
|
|
270
|
+
/** A group's text with its attribute names in place of its diff. */
|
|
271
|
+
short?: string;
|
|
272
|
+
member?: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
const ACTION_WORDS: Record<PrPlanNoteNamed["action"], string> = { delete: "destroy", replace: "replace", refused: "refused to plan", forget: "forget", import: "import" };
|
|
276
|
+
|
|
277
|
+
function changeText(l: PrPlanNoteChange): string {
|
|
278
|
+
let t = l.count > 1 ? `${l.line} (x${l.count})` : l.line;
|
|
279
|
+
if (l.differsFrom) t += l.differsIn?.length ? ` [differs from group ${l.differsFrom} in: ${l.differsIn.join(", ")}]` : ` [differs from group ${l.differsFrom}]`;
|
|
280
|
+
return t;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* A product's plan note. Each group links to its anchor in the report and
|
|
285
|
+
* each named change to its unit's. Destroys, replacements and refusals come
|
|
286
|
+
* first and are never dropped for space before a group is. Over the limit,
|
|
287
|
+
* the units' whole plans go and the groups' diffs shrink to their attribute
|
|
288
|
+
* names, whichever saves the most first; then blocks are dropped, whole,
|
|
289
|
+
* from the end. A Cut line names what went.
|
|
290
|
+
*/
|
|
291
|
+
export function renderPlanNote(report: PrPlanNote, options: PlanNoteOptions = {}): string {
|
|
292
|
+
const words = options.words ?? activeProductWords();
|
|
293
|
+
const w = { ...NOTE_WORDS, ...options.note, anchors: { ...NOTE_WORDS.anchors, ...options.note?.anchors } };
|
|
294
|
+
const markerName = options.note?.marker ?? `${words.product}:waves`;
|
|
295
|
+
const [one, many] = words.noun;
|
|
296
|
+
const links = report.links ?? {};
|
|
297
|
+
const url = links.report ?? (links.run ? undefined : w.page);
|
|
298
|
+
const artifacts = links.artifacts === true;
|
|
299
|
+
const linkable = url !== undefined && !artifacts;
|
|
300
|
+
const to = (text: string, anchor?: string): string => (url === undefined ? text : `[${text}](${url}${anchor && !artifacts ? `#${anchor}` : ""})`);
|
|
301
|
+
const memberLink = (m: string): string => to(code(m), w.anchors.member!.replace("{id}", m));
|
|
302
|
+
const until = links.expires ? ` The links to the bucket work until ${utc(links.expires)}.` : "";
|
|
303
|
+
const full = url === undefined
|
|
304
|
+
? w.noReport.replace("{run}", links.run ?? "")
|
|
305
|
+
: artifacts ? `The full report is \`${w.page}\` in the \`${w.artifact}\` artifact of [this run](${url}).` : `[Full report](${url})${until}`;
|
|
306
|
+
const fullReport = url === undefined ? "The full report" : artifacts ? `The full report, in the artifacts of [this run](${url}),` : `[The full report](${url})`;
|
|
307
|
+
const limit = options.limit ?? GITHUB_COMMENT_LIMIT;
|
|
308
|
+
const unitWord = report.unit === "instance" ? "instance" : one;
|
|
309
|
+
const unitWords = report.unit === "instance" ? "instances" : many;
|
|
310
|
+
const destroys = report.named.filter((n) => n.action === "delete" || n.action === "replace").length;
|
|
311
|
+
const refused = report.named.filter((n) => n.action === "refused").length;
|
|
312
|
+
const head: string[] = [`### ${words.product} ${report.stage}${report.wave !== undefined ? `, wave ${report.wave}` : ""}: ${code(report.head.slice(0, 12))}`, ""];
|
|
313
|
+
const parts = [plural(report.groups.length, "group"), plural(destroys, "destroy or replacement", "destroys or replacements")];
|
|
314
|
+
if (refused > 0) parts.push(`${refused} refused`);
|
|
315
|
+
head.push(`${plural(report.units, unitWord, unitWords)}: ${parts.join(", ")}. ${full}`, "");
|
|
316
|
+
const t0 = report.totals;
|
|
317
|
+
if (t0 && t0.members > 0) {
|
|
318
|
+
const counts = [`${t0.add} to add`, `${t0.change} to change`, `${t0.destroy} to destroy`];
|
|
319
|
+
if (t0.forget > 0) counts.push(`${t0.forget} to forget`);
|
|
320
|
+
head.push(`${counts.join(", ")} across ${plural(t0.members, one, many)}`, "");
|
|
321
|
+
}
|
|
322
|
+
if (report.nothing) head.push(`This change reaches no ${one}, so nothing was planned.`, "");
|
|
323
|
+
for (const n of report.notices ?? []) head.push(`> ${n}`, "");
|
|
324
|
+
for (const f of report.facts ?? []) {
|
|
325
|
+
const link = f.link ? (linkable ? `[${f.link.text}](${url}#${f.link.anchor})` : (f.link.plain ?? f.link.text)) : "";
|
|
326
|
+
head.push(`${f.text}${link}${f.after ?? ""}`, "");
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
const blocks: Block[] = [];
|
|
330
|
+
const line = (text: string): void => void blocks.push({ kind: "line", units: 0, text });
|
|
331
|
+
const sections = (at: "start" | "groups" | "end"): void => {
|
|
332
|
+
for (const s of report.sections ?? []) if (s.at === at) line(s.text);
|
|
333
|
+
};
|
|
334
|
+
sections("start");
|
|
335
|
+
if (report.named.length > 0) {
|
|
336
|
+
line(`**Destroys, replacements, refusals, imports and forgets (${report.named.length}):**\n\n`);
|
|
337
|
+
for (const n of report.named) {
|
|
338
|
+
const what = n.address ? `${n.member}: ${n.address}${n.deposed !== undefined ? ` (deposed ${n.deposed})` : ""}` : n.member;
|
|
339
|
+
const forced = n.forcedBy?.length ? `, forced by ${n.forcedBy.map(code).join(", ")}` : "";
|
|
340
|
+
const reason = n.reason ? `: ${oneLine(n.reason)}` : "";
|
|
341
|
+
line(`- ${to(code(what), w.anchors.member!.replace("{id}", n.member))} (${n.word ?? ACTION_WORDS[n.action]}${forced})${reason}\n`);
|
|
342
|
+
}
|
|
343
|
+
line("\n");
|
|
344
|
+
}
|
|
345
|
+
const overrides = report.overrides ?? [];
|
|
346
|
+
if (overrides.length > 0) {
|
|
347
|
+
let t = `**Policy overrides (${overrides.filter((r) => r.override).length} of ${overrides.length} denied):**\n\n`;
|
|
348
|
+
for (const r of overrides) {
|
|
349
|
+
const o = r.override;
|
|
350
|
+
const rules = r.rules.map(code).join(", ") || "its rules";
|
|
351
|
+
t += o
|
|
352
|
+
? `- ${memberLink(r.member)}: ${rules} overridden by ${o.by} at ${o.at}${o.sealed ? ", sealed" : ""}, for plan ${code(o.plan)}: ${oneLine(o.reason)}${report.planning ? `. ${w.applyStage} applies this plan; this run still fails it` : ""}\n`
|
|
353
|
+
: r.overriders.length === 0
|
|
354
|
+
? `- ${memberLink(r.member)}: denied by ${rules}. ${w.overrideKey} names nobody who may override it\n`
|
|
355
|
+
: `- ${memberLink(r.member)}: denied by ${rules}. ${r.overriders.join(", ")} may override it once a ${w.applyStage} wave records the denial: ${code(overrideLine(words, { op: w.overrideOp, target: r.member, rules: r.rules, sign: report.sealed === true }))}\n`;
|
|
356
|
+
}
|
|
357
|
+
line(t + "\n");
|
|
358
|
+
}
|
|
359
|
+
const warnings = report.warnings ?? [];
|
|
360
|
+
if (warnings.length > 0) {
|
|
361
|
+
let t = `**Policy warnings (${warnings.length}), which fail nothing:**\n\n`;
|
|
362
|
+
for (const x of warnings) t += `- ${memberLink(x.member)}: ${oneLine(x.text)}\n`;
|
|
363
|
+
line(t + "\n");
|
|
364
|
+
}
|
|
365
|
+
if (report.deferred?.length) {
|
|
366
|
+
let t = `**Planned once what they wait for applies (${report.deferred.length}):**\n\n`;
|
|
367
|
+
for (const d of report.deferred) t += `- ${code(d.unit)}${d.after.length ? ` after ${d.after.map(code).join(", ")}` : ""}: ${d.why}${d.previewed ? " (previewed)" : ""}\n`;
|
|
368
|
+
line(t + "\n");
|
|
369
|
+
}
|
|
370
|
+
const envs = report.waves.some((x) => x.environments !== undefined);
|
|
371
|
+
const envHead = envs ? " Environments |" : "";
|
|
372
|
+
const envRule = envs ? "---|" : "";
|
|
373
|
+
const envCell = (x: PrPlanNoteWave): string => (envs ? ` ${x.environments?.length ? x.environments.join(", ") : "none"} |` : "");
|
|
374
|
+
const Units = capital(many);
|
|
375
|
+
if (report.waves.some((x) => x.digest !== undefined)) {
|
|
376
|
+
let t = `| Wave | ${Units} |${envHead} Digest of its changes | When it applies |\n|---|---|${envRule}---|---|\n`;
|
|
377
|
+
for (const x of report.waves) {
|
|
378
|
+
const again = x.replansAfter?.length ? `plans again once wave ${x.replansAfter.join(", ")} applies, then ` : "";
|
|
379
|
+
const approve = (digest: string): string => approveLine(words, { op: words.op ?? "", gate: words.gateName.replace("{gate}", words.prGate).replace("{k}", String(x.number)), digest, sign: report.sealed === true });
|
|
380
|
+
const when = again
|
|
381
|
+
? `${again}${x.waits ? "waits for an approval of that plan" : "applies"}`
|
|
382
|
+
: x.waits && x.digest ? `waits for an approval: ${code(approve(x.digest))}` : x.waits ? "waits for an approval" : "applies";
|
|
383
|
+
const unknownBy = x.unknownBy ?? [];
|
|
384
|
+
const policyRules = (x.policy?.rules ?? []).map(code).join(", ");
|
|
385
|
+
const by = x.waits && unknownBy.length
|
|
386
|
+
? ` (since ${joinAnd(unknownBy.map(code))} ${unknownBy.length === 1 ? "reads" : "read"} a value unknown at plan time)`
|
|
387
|
+
: x.waits && x.heldByHooks?.length ? ` (a hook of ${x.heldByHooks.map(code).join(", ")} asks for one)`
|
|
388
|
+
: x.waits && x.policy?.outcome === "held" ? ` (held by ${policyRules})`
|
|
389
|
+
: x.policy?.outcome === "unattended" ? (x.waits ? ` (the policy allows it unattended, ${policyRules}, and something else holds it)` : ` without an approval: allowed unattended by ${policyRules}`) : "";
|
|
390
|
+
const rules = x.waits && x.approvalRules?.length ? `; ${w.approvalRulesKey}: ${x.approvalRules.map((r) => `${r.units.map(code).join(", ")} ${r.asks}`).join("; ")}` : "";
|
|
391
|
+
t += `| ${x.number} | ${x.units}${x.composed ? ", composed" : ""} |${envCell(x)} ${x.digest ? code(x.digest) : x.replansAfter?.length ? "after the re-plan" : "no change"} | ${when}${by}${rules} |\n`;
|
|
392
|
+
}
|
|
393
|
+
line(t + "\n");
|
|
394
|
+
const previews = report.previews ?? [];
|
|
395
|
+
head.push(planNoteMarker(markerName, { head: report.head, waves: report.waves.map((x) => ({ number: x.number, digest: x.digest ?? null, waits: x.waits === true })), ...(previews.length ? { previews } : {}) }), "");
|
|
396
|
+
} else if (report.waves.length > 0) {
|
|
397
|
+
let t = `| Wave | ${Units} |${envHead} Set digest | Approval |\n|---|---|${envRule}---|---|\n`;
|
|
398
|
+
for (const x of report.waves) t += `| ${x.number} | ${x.units}${x.composed ? ", composed" : ""} |${envCell(x)} ${x.replansAfter?.length ? `none yet: it plans again once wave ${x.replansAfter.join(", ")} applies` : x.setDigest ? code(x.setDigest.slice(0, 19)) : "none"} | ${x.approval ?? ""} |\n`;
|
|
399
|
+
line(t + "\n");
|
|
400
|
+
}
|
|
401
|
+
for (const p of report.previewed ?? []) {
|
|
402
|
+
const moved = p.moved.filter((u) => u.differences.length);
|
|
403
|
+
let t = moved.length
|
|
404
|
+
? `**Wave ${p.wave} plans differently from the preview in pull request ${p.pullRequest} (${moved.length} of ${p.units}):**\n\n`
|
|
405
|
+
: `**Wave ${p.wave} plans as pull request ${p.pullRequest} previewed it (${plural(p.units, unitWord, unitWords)}).**\n\n`;
|
|
406
|
+
for (const u of moved) for (const d of u.differences) t += `- ${memberLink(u.unit)}: ${d}\n`;
|
|
407
|
+
line(t + "\n");
|
|
408
|
+
}
|
|
409
|
+
const linked = report.linked ?? [];
|
|
410
|
+
if (linked.length > 0) {
|
|
411
|
+
let t = `**Planned on the planned outputs of another ${one} (${linked.length}):**\n\n`;
|
|
412
|
+
for (const x of linked) t += `- ${memberLink(x.member)} reads ${code(x.upstream)}${x.composed ? ", in the composed run" : ""}${x.unknown?.length ? `; ${x.unknown.map(code).join(", ")} known once it applies` : ""}\n`;
|
|
413
|
+
line(t + "\n");
|
|
414
|
+
}
|
|
415
|
+
sections("groups");
|
|
416
|
+
for (const g of report.groups) {
|
|
417
|
+
let title = `${to(`Group ${g.id}`, w.anchors.group!.replace("{id}", g.id))}: ${plural(g.units.length, unitWord, unitWords)}`;
|
|
418
|
+
if (g.resource) title += ` of ${code(g.resource)}`;
|
|
419
|
+
if (g.outlier) title += " (outlier)";
|
|
420
|
+
title += g.noChanges ? ", no changes" : g.extends ? `, group ${g.extends}'s change plus` : g.units.length > 1 ? ", identical change" : ", change";
|
|
421
|
+
if (g.recurring) title += ", on every run";
|
|
422
|
+
const heading = `#### ${title}\n\n`;
|
|
423
|
+
const names = g.changes.length > 0 ? "```\n" + g.changes.map(changeText).join("\n") + "\n```\n\n" : "";
|
|
424
|
+
const shown = g.units.slice(0, 20).map(code).join(", ");
|
|
425
|
+
const members = `${capital(unitWords)}: ${shown}${g.units.length > 20 ? `, and ${g.units.length - 20} more in the report` : ""}\n\n`;
|
|
426
|
+
const diff = g.noChanges || g.recurring ? undefined : g.diff;
|
|
427
|
+
if (!diff) {
|
|
428
|
+
blocks.push({ kind: "group", units: g.units.length, text: heading + names + members });
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
let t = heading;
|
|
432
|
+
if (g.units.length > 1) t += `As ${code(diff.unit)} plans it:\n\n`;
|
|
433
|
+
t += diffFence(diffLines(diff.lines)) + "\n";
|
|
434
|
+
const differs = g.changes.filter((l) => l.differsFrom);
|
|
435
|
+
for (const l of differs) t += `- ${code(l.line)} differs from group ${l.differsFrom}${l.differsIn?.length ? ` in ${l.differsIn.map(code).join(", ")}` : ""}.\n`;
|
|
436
|
+
const varies = g.varies ?? [];
|
|
437
|
+
if (varies.length > 0) t += `${differs.length > 0 ? "- " : ""}Values differ between its ${unitWords} in ${varies.map(code).join(", ")}.\n`;
|
|
438
|
+
if (differs.length > 0 || varies.length > 0) t += "\n";
|
|
439
|
+
blocks.push({ kind: "group", units: g.units.length, text: t + members, short: heading + names + members });
|
|
440
|
+
}
|
|
441
|
+
sections("end");
|
|
442
|
+
// A unit's plan file: the link given for it, else beside the report page when the note links the page itself.
|
|
443
|
+
const planLink = (member: string): string | undefined => {
|
|
444
|
+
const p = report.plans?.find((x) => x.member === member);
|
|
445
|
+
if (p?.url) return p.url;
|
|
446
|
+
if (!linkable || !p?.file) return undefined;
|
|
447
|
+
const bare = url.split("#")[0]!;
|
|
448
|
+
if (bare.includes("?") || !(bare === w.page || bare.endsWith(`/${w.page}`))) return undefined;
|
|
449
|
+
return bare.slice(0, bare.length - w.page.length) + p.file.split("/").map(encodeURIComponent).join("/");
|
|
450
|
+
};
|
|
451
|
+
let first = true;
|
|
452
|
+
for (const p of report.plans ?? []) {
|
|
453
|
+
const link = planLink(p.member);
|
|
454
|
+
let t = first ? `**Each ${one}'s plan:**\n\n` : "";
|
|
455
|
+
first = false;
|
|
456
|
+
t += `<details><summary><code>${esc(p.member)}</code>${p.totals ? `: ${esc(p.totals)}` : ""}</summary>\n\n`;
|
|
457
|
+
t += diffFence(diffLines(p.text.replace(/\r\n/g, "\n").replace(/^(\s*\n)+/, "").replace(/\s+$/, "").split("\n"))) + "\n";
|
|
458
|
+
if (link) t += `[${w.planFile}](${link})\n\n`;
|
|
459
|
+
t += "</details>\n\n";
|
|
460
|
+
blocks.push({ kind: "plan", units: 0, member: p.member, text: t });
|
|
461
|
+
}
|
|
462
|
+
const top = head.join("\n") + "\n";
|
|
463
|
+
const foot = w.footer ? `\n${w.footer}\n` : "";
|
|
464
|
+
const all = top + blocks.map((b) => b.text).join("") + foot;
|
|
465
|
+
if (codePoints(all) <= limit) return all;
|
|
466
|
+
|
|
467
|
+
const cut = { plans: [] as string[], diffs: 0, groups: 0, units: 0, lines: 0 };
|
|
468
|
+
const notice = (): string => {
|
|
469
|
+
const out: string[] = [];
|
|
470
|
+
if (cut.plans.length > 0) {
|
|
471
|
+
const named = cut.plans.slice(0, 20).map((m) => {
|
|
472
|
+
const link = planLink(m);
|
|
473
|
+
return link ? `[${code(m)}](${link})` : code(m);
|
|
474
|
+
});
|
|
475
|
+
const more = cut.plans.length - named.length;
|
|
476
|
+
out.push(`the whole plans of ${plural(cut.plans.length, one, many)} (${named.join(", ")}${more > 0 ? `, and ${more} more` : ""})`);
|
|
477
|
+
}
|
|
478
|
+
if (cut.groups > 0) out.push(`${plural(cut.groups, "group")} (${plural(cut.units, unitWord, unitWords)})`);
|
|
479
|
+
if (cut.lines > 0) out.push(plural(cut.lines, "line"));
|
|
480
|
+
const clauses: string[] = [];
|
|
481
|
+
if (out.length > 0) clauses.push(`leaves out ${joinAnd(out)}`);
|
|
482
|
+
if (cut.diffs > 0) clauses.push(`shows ${cut.diffs === 1 ? "one group" : `${cut.diffs} groups`} by attribute name, without the diff`);
|
|
483
|
+
return `**Cut:** this note ${clauses.join(" and ")}, to stay within ${limit} characters. ${fullReport} has all of it${report.plans !== undefined ? `, and each ${one}'s ${w.planFile} the whole plan` : ""}.\n`;
|
|
484
|
+
};
|
|
485
|
+
const size = (b: Block): number => codePoints(b.text);
|
|
486
|
+
let used = codePoints(all);
|
|
487
|
+
const over = (): boolean => used + codePoints(notice()) > limit;
|
|
488
|
+
// Whole plans and group diffs, whichever saves the most first: a whole plan before a diff that saves as much, the later of two alike first.
|
|
489
|
+
const candidates = blocks
|
|
490
|
+
.map((b, i) => ({ i, plan: b.kind === "plan", saves: b.kind === "plan" ? size(b) : b.short !== undefined ? size(b) - codePoints(b.short) : 0 }))
|
|
491
|
+
.filter((c) => c.saves > 0)
|
|
492
|
+
.sort((a, b) => b.saves - a.saves || Number(b.plan) - Number(a.plan) || b.i - a.i);
|
|
493
|
+
const gone = new Set<number>();
|
|
494
|
+
for (const c of candidates) {
|
|
495
|
+
if (!over()) break;
|
|
496
|
+
const b = blocks[c.i]!;
|
|
497
|
+
if (c.plan) {
|
|
498
|
+
used -= size(b);
|
|
499
|
+
gone.add(c.i);
|
|
500
|
+
} else {
|
|
501
|
+
used += codePoints(b.short!) - size(b);
|
|
502
|
+
b.text = b.short!;
|
|
503
|
+
b.short = undefined;
|
|
504
|
+
cut.diffs++;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
cut.plans.push(...blocks.filter((_, i) => gone.has(i)).map((b) => b.member!));
|
|
508
|
+
for (let i = blocks.length - 1; i >= 0; i--) if (gone.has(i)) blocks.splice(i, 1);
|
|
509
|
+
// Then whole blocks from the end: groups, and last the destroys.
|
|
510
|
+
while (blocks.length > 0 && over()) {
|
|
511
|
+
const b = blocks.pop()!;
|
|
512
|
+
used -= size(b);
|
|
513
|
+
if (b.kind === "group") {
|
|
514
|
+
cut.groups++;
|
|
515
|
+
cut.units += b.units;
|
|
516
|
+
} else if (b.kind === "plan") cut.plans.unshift(b.member!);
|
|
517
|
+
else cut.lines++;
|
|
518
|
+
}
|
|
519
|
+
return top + blocks.map((b) => b.text).join("") + notice() + foot;
|
|
520
|
+
}
|
package/src/release-floors.ts
CHANGED
|
@@ -19,4 +19,22 @@
|
|
|
19
19
|
* this constant to the next patch (#4501). The check fails while a floor
|
|
20
20
|
* still names this constant after its version shipped.
|
|
21
21
|
*/
|
|
22
|
-
export const NEXT_RELEASE = "0.124.
|
|
22
|
+
export const NEXT_RELEASE = "0.124.79";
|
|
23
|
+
|
|
24
|
+
/** The first chant whose change-set member can carry `outputs`, the outputs its plan changes, and counts a member with any as a change (#4849). */
|
|
25
|
+
export const CHANGE_SET_OUTPUTS_FLOOR = NEXT_RELEASE;
|
|
26
|
+
|
|
27
|
+
/** The first chant whose terraform lexicon's `terragruntApplyCapability` takes `resolveUnit` and plans a wave as one `run --all` per pair of pinned releases (#4849). */
|
|
28
|
+
export const TERRAGRUNT_UNIT_PINS_FLOOR = NEXT_RELEASE;
|
|
29
|
+
|
|
30
|
+
/** The first chant whose sql lexicon's `yodelCommitSpec("new", ...)` takes `envs`, so `--replace-own` reads those histories as the reader (#4815). */
|
|
31
|
+
export const YODEL_NEW_ENVS_FLOOR = "0.124.78";
|
|
32
|
+
|
|
33
|
+
/** The first chant whose sql lexicon's `yodelRefusalReply` reads yodel rebase's conflict refusal as yodel prints it, `<a> and the migrations after <p> up to <b>` or `<a> and the chain ending at <b>` (#4821). */
|
|
34
|
+
export const YODEL_CONFLICT_REPLY_FLOOR = "0.124.78";
|
|
35
|
+
|
|
36
|
+
/** The first chant whose `@intentius/chant/pr-forge-reads` exports the forge reads beside the clients (#4809). */
|
|
37
|
+
export const PR_FORGE_READS_FLOOR = "0.124.78";
|
|
38
|
+
|
|
39
|
+
/** The first chant whose GitLab `scheduledRuns` takes `schedule`, the selector of an Op's `gitlab.scheduleRule` (#4813). */
|
|
40
|
+
export const SCHEDULED_RUNS_SELECTOR_FLOOR = "0.124.78";
|
package/src/state-export.test.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { tmpdir } from "node:os";
|
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { describe, expect, test } from "vitest";
|
|
9
9
|
import { fakeLedger } from "./__fixtures__/gated-ledger";
|
|
10
|
-
import { NEXT_RELEASE } from "./release-floors";
|
|
11
10
|
import { exportStateVersion, exportRefusal, STATE_EXPORT_FLOOR, StateExportError, type StateVersionSource } from "./state-export";
|
|
12
11
|
|
|
13
12
|
const NO_CI = {};
|
|
@@ -120,6 +119,6 @@ describe("exportStateVersion", () => {
|
|
|
120
119
|
});
|
|
121
120
|
|
|
122
121
|
test("its floor is the next release", () => {
|
|
123
|
-
expect(STATE_EXPORT_FLOOR).toBe(
|
|
122
|
+
expect(STATE_EXPORT_FLOOR).toBe("0.124.77");
|
|
124
123
|
});
|
|
125
124
|
});
|
package/src/state-export.ts
CHANGED
|
@@ -36,10 +36,9 @@ import { basename, dirname, join, resolve } from "node:path";
|
|
|
36
36
|
import { CHANT_EXIT } from "./exit-codes";
|
|
37
37
|
import { gatedOp, type GatedRequestLedger } from "./lifecycle/gated-op";
|
|
38
38
|
import type { GatedRequestRules } from "./lifecycle/gated-request";
|
|
39
|
-
import { NEXT_RELEASE } from "./release-floors";
|
|
40
39
|
|
|
41
40
|
/** The first chant with the engine-neutral state export (#4762). */
|
|
42
|
-
export const STATE_EXPORT_FLOOR =
|
|
41
|
+
export const STATE_EXPORT_FLOOR = "0.124.77";
|
|
43
42
|
|
|
44
43
|
/** The version a store holds now. */
|
|
45
44
|
export interface StateVersion {
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { describe, expect, test } from "vitest";
|
|
6
6
|
import { fakeLedger } from "./__fixtures__/gated-ledger";
|
|
7
|
-
import { NEXT_RELEASE } from "./release-floors";
|
|
8
7
|
import { runStateMigration, STATE_MIGRATION_FLOOR, writeStateMigration, type MigrationRootPlan, type MigrationStateAt, type StateMigrationEngine } from "./state-migration";
|
|
9
8
|
|
|
10
9
|
const plan = (proof: string[] = []): MigrationRootPlan[] => [
|
|
@@ -129,6 +128,6 @@ describe("runStateMigration", () => {
|
|
|
129
128
|
});
|
|
130
129
|
|
|
131
130
|
test("its floor is the next release", () => {
|
|
132
|
-
expect(STATE_MIGRATION_FLOOR).toBe(
|
|
131
|
+
expect(STATE_MIGRATION_FLOOR).toBe("0.124.77");
|
|
133
132
|
});
|
|
134
133
|
});
|
package/src/state-migration.ts
CHANGED
|
@@ -32,10 +32,9 @@
|
|
|
32
32
|
import { CHANT_EXIT } from "./exit-codes";
|
|
33
33
|
import { gatedOp, type GatedRequestLedger } from "./lifecycle/gated-op";
|
|
34
34
|
import type { GatedRequestRules } from "./lifecycle/gated-request";
|
|
35
|
-
import { NEXT_RELEASE } from "./release-floors";
|
|
36
35
|
|
|
37
36
|
/** The first chant with the engine-neutral state migration (#4762). */
|
|
38
|
-
export const STATE_MIGRATION_FLOOR =
|
|
37
|
+
export const STATE_MIGRATION_FLOOR = "0.124.77";
|
|
39
38
|
|
|
40
39
|
/** A state as a migration binds it: its version id, when the store keeps versions, and its digest, null for no state. */
|
|
41
40
|
export interface MigrationStateAt {
|
package/src/state-unlock.test.ts
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { describe, expect, test } from "vitest";
|
|
7
7
|
import { fakeLedger } from "./__fixtures__/gated-ledger";
|
|
8
8
|
import type { ForgeFetch } from "./pr-forge";
|
|
9
|
-
import { NEXT_RELEASE } from "./release-floors";
|
|
10
9
|
import { CLOCK_SKEW_MS, forgeLiveRuns, parseLockInfo, possibleHolders, releaseStateLock, STATE_UNLOCK_FLOOR, StateUnlockError, type LiveRun, type LockInfo, type StateLockSource } from "./state-unlock";
|
|
11
10
|
|
|
12
11
|
const LOCK: LockInfo = { ID: "a1b2", Operation: "OperationTypeApply", Who: "runner@ci", Created: "2026-11-08T08:00:00Z" };
|
|
@@ -108,7 +107,7 @@ describe("releaseStateLock", () => {
|
|
|
108
107
|
});
|
|
109
108
|
|
|
110
109
|
test("its floor is the next release", () => {
|
|
111
|
-
expect(STATE_UNLOCK_FLOOR).toBe(
|
|
110
|
+
expect(STATE_UNLOCK_FLOOR).toBe("0.124.77");
|
|
112
111
|
});
|
|
113
112
|
});
|
|
114
113
|
|
package/src/state-unlock.ts
CHANGED
|
@@ -27,10 +27,9 @@ import { CHANT_EXIT } from "./exit-codes";
|
|
|
27
27
|
import { gatedOp, type GatedRequestLedger } from "./lifecycle/gated-op";
|
|
28
28
|
import type { GatedRequestRules } from "./lifecycle/gated-request";
|
|
29
29
|
import type { ForgeFetch, ForgeKind } from "./pr-forge";
|
|
30
|
-
import { NEXT_RELEASE } from "./release-floors";
|
|
31
30
|
|
|
32
31
|
/** The first chant with the engine-neutral lock release and {@link forgeLiveRuns} (#4762). */
|
|
33
|
-
export const STATE_UNLOCK_FLOOR =
|
|
32
|
+
export const STATE_UNLOCK_FLOOR = "0.124.77";
|
|
34
33
|
|
|
35
34
|
/** A run of the repository that has not finished, as {@link forgeLiveRuns} reads it. */
|
|
36
35
|
export interface LiveRun {
|
|
@@ -155,6 +155,13 @@
|
|
|
155
155
|
},
|
|
156
156
|
"description": "Added in contract 1 by #4463, written by chant 0.124.54 and newer. The inputs the member was previewed with stand-in values for (#4463), as var.<name>, sorted. Every attribute they drive is marked unknown in its entries, and its planDigest covers them."
|
|
157
157
|
},
|
|
158
|
+
"outputs": {
|
|
159
|
+
"type": "array",
|
|
160
|
+
"items": {
|
|
161
|
+
"type": "string"
|
|
162
|
+
},
|
|
163
|
+
"description": "Added in contract 1 by #4849, written by chant 0.124.79 and newer. The outputs the member's plan changes, by name, sorted. Absent when it changes none. A member with any is a change even when every entry is a no-op. Its planDigest covers them."
|
|
164
|
+
},
|
|
158
165
|
"holes": {
|
|
159
166
|
"type": "array",
|
|
160
167
|
"description": "What the planner could not read, so the plan says nothing about it.",
|