@intentius/chant 0.124.59 → 0.124.60
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/components/capability.d.ts +11 -0
- package/dist/components/capability.d.ts.map +1 -1
- package/dist/lifecycle/wave-plans.d.ts +19 -0
- package/dist/lifecycle/wave-plans.d.ts.map +1 -1
- package/dist/lifecycle/wave-plans.js +25 -1
- package/dist/op/gate-review.d.ts +1 -1
- package/dist/op/gate-review.d.ts.map +1 -1
- package/dist/op/index.d.ts +1 -0
- package/dist/op/index.d.ts.map +1 -1
- package/dist/op/index.js +1 -0
- package/dist/op/op-waves-capability.d.ts +2 -0
- package/dist/op/op-waves-capability.d.ts.map +1 -1
- package/dist/op/op-waves-capability.js +1 -0
- package/dist/op/op-waves-preview.d.ts +45 -0
- package/dist/op/op-waves-preview.d.ts.map +1 -0
- package/dist/op/op-waves-preview.js +37 -0
- package/dist/op/op-waves-run.d.ts +18 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +40 -8
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +263 -263
- package/package.json +1 -1
- package/src/components/capability.ts +11 -0
- package/src/lifecycle/ledger-readers.test.ts +10 -0
- package/src/lifecycle/wave-plans.ts +41 -1
- package/src/op/gate-review.test.ts +1 -1
- package/src/op/gate-review.ts +1 -1
- package/src/op/index.ts +1 -0
- package/src/op/op-waves-capability.ts +3 -0
- package/src/op/op-waves-preview.test.ts +122 -5
- package/src/op/op-waves-preview.ts +70 -0
- package/src/op/op-waves-run.ts +58 -8
- package/src/op/op-waves.test.ts +11 -1
- package/src/release-floors.ts +1 -1
package/dist/op/op-waves-run.js
CHANGED
|
@@ -58,7 +58,7 @@ import { blockedMembers, blockedWords, earlierWaveOutcomes, passesThrough, readW
|
|
|
58
58
|
import { approveCommand, evaluateGate, gitGateLedgerPort } from "./gate.js";
|
|
59
59
|
import { isApprovalSpent } from "../lifecycle/gate-applied.js";
|
|
60
60
|
import { samePlanDigest } from "../lifecycle/plan-digest.js";
|
|
61
|
-
import {
|
|
61
|
+
import { movedSincePreview } from "./op-waves-preview.js";
|
|
62
62
|
import { isLifecycleLocalNote } from "../lifecycle/local-note.js";
|
|
63
63
|
import { ciRunIdFromEnv } from "./gate-run-locator.js";
|
|
64
64
|
import { appendRunRecord, DEFAULT_RUN_ENV } from "../lifecycle/run-ledger.js";
|
|
@@ -205,7 +205,7 @@ function pointAtBase(spec, name, where) {
|
|
|
205
205
|
return { point: opWavePointAt(spec, name) };
|
|
206
206
|
}
|
|
207
207
|
/** The first chant whose Op waves spec takes `approvals.preview`: a merged wave applies the plans its pull request previewed, or exits 4. */
|
|
208
|
-
export const OP_WAVES_PREVIEW_FLOOR =
|
|
208
|
+
export const OP_WAVES_PREVIEW_FLOOR = "0.124.59";
|
|
209
209
|
/** The first chant whose op entry exports {@link opWavePlanPath} (terragucci#1304). */
|
|
210
210
|
export const OP_WAVE_PLAN_PATH_FLOOR = "0.124.56";
|
|
211
211
|
/** Where a run's plan file goes: one target's plan, as opposed to {@link opWavePlansPath}, the wave's `plans.json`. */
|
|
@@ -250,6 +250,15 @@ function planRun(opts, waveName, run) {
|
|
|
250
250
|
}
|
|
251
251
|
return member(run.target, op, file);
|
|
252
252
|
}
|
|
253
|
+
/** A plan file's `resources`: a map of address to digest, or nothing. Anything else is a mistake the wave names. */
|
|
254
|
+
function resourcesOf(value, target) {
|
|
255
|
+
if (value === undefined)
|
|
256
|
+
return undefined;
|
|
257
|
+
if (value === null || typeof value !== "object" || Array.isArray(value) || !Object.values(value).every((d) => typeof d === "string" && d !== "")) {
|
|
258
|
+
throw new Error(`the plan of ${target} has resources ${JSON.stringify(value)}; it is a map of a resource's address to its digest`);
|
|
259
|
+
}
|
|
260
|
+
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
|
|
261
|
+
}
|
|
253
262
|
function member(target, op, file) {
|
|
254
263
|
for (const key of ["denied", "held"]) {
|
|
255
264
|
const value = file[key];
|
|
@@ -264,6 +273,7 @@ function member(target, op, file) {
|
|
|
264
273
|
member: target,
|
|
265
274
|
planDigest: file.planDigest,
|
|
266
275
|
op,
|
|
276
|
+
...(resourcesOf(file.resources, target) ? { resources: resourcesOf(file.resources, target) } : {}),
|
|
267
277
|
...(file.destructive === true ? { destructive: true } : {}),
|
|
268
278
|
...(file.empty === true ? { empty: true } : {}),
|
|
269
279
|
...(file.denied ? { denied: { rules: file.denied.rules, ...(file.denied.reason ? { reason: file.denied.reason } : {}) } } : {}),
|
|
@@ -410,6 +420,7 @@ async function planWaveRuns(at, runs, discover = false) {
|
|
|
410
420
|
const members = plans.map((p) => ({
|
|
411
421
|
member: p.target,
|
|
412
422
|
planDigest: p.planDigest,
|
|
423
|
+
...(p.resources ? { resources: p.resources } : {}),
|
|
413
424
|
op: runs.find((r) => r.target === p.target)?.op ?? spec.op,
|
|
414
425
|
...(p.destructive ? { destructive: true } : {}),
|
|
415
426
|
...(p.empty ? { empty: true } : {}),
|
|
@@ -1839,13 +1850,13 @@ async function decideOpWave(options, { prior }, planned, digest) {
|
|
|
1839
1850
|
// `approvals.preview` at base: the merged wave applies what the pull request previewed. Planned again to a digest this job already let through, it has been judged.
|
|
1840
1851
|
let unseen = false;
|
|
1841
1852
|
if (planned.rules.preview && !kept && decision.status !== "refused") {
|
|
1842
|
-
const seen = await previewOf(options, ctx, digest);
|
|
1853
|
+
const seen = await previewOf(options, ctx, digest, members);
|
|
1843
1854
|
if ("error" in seen)
|
|
1844
1855
|
return { end: failed(ctx, `wave ${k} (${wave.name}): ${seen.error}, so it cannot be compared with what the pull request previewed and nothing in it was applied`) };
|
|
1845
1856
|
decision.preview = seen.preview;
|
|
1846
1857
|
unseen = seen.preview.status !== "matched";
|
|
1847
1858
|
if (!unseen)
|
|
1848
|
-
log(`wave ${k} (${wave.name}): the plans are the ones pull request #${seen.preview.pr} previewed at ${seen.preview.head?.slice(0, 12)} (${digest})`);
|
|
1859
|
+
log(`wave ${k} (${wave.name}): the plans are the ones pull request #${seen.preview.pr} previewed at ${seen.preview.head?.slice(0, 12)} (${seen.preview.compared === "resources" ? `${seen.preview.recorded}, compared resource by resource; the wave now plans ${digest}` : digest})`);
|
|
1849
1860
|
else
|
|
1850
1861
|
log(`wave ${k} (${wave.name}): ${seen.preview.reason}`);
|
|
1851
1862
|
}
|
|
@@ -1887,7 +1898,7 @@ async function decideOpWave(options, { prior }, planned, digest) {
|
|
|
1887
1898
|
* `error` only when the forge or the ledger cannot be read, which fails the
|
|
1888
1899
|
* wave: a missing answer never stands in for a match.
|
|
1889
1900
|
*/
|
|
1890
|
-
async function previewOf(options, ctx, digest) {
|
|
1901
|
+
async function previewOf(options, ctx, digest, members) {
|
|
1891
1902
|
const { spec, k, cwd } = ctx;
|
|
1892
1903
|
const review = await import("./gate-review.js");
|
|
1893
1904
|
const head = options.head ?? execFileSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf-8" }).trim();
|
|
@@ -1908,21 +1919,40 @@ async function previewOf(options, ctx, digest) {
|
|
|
1908
1919
|
return { error: `the plans recorded for #${merged.pr} could not be read (${err instanceof Error ? err.message : String(err)})` };
|
|
1909
1920
|
}
|
|
1910
1921
|
const seen = { pr: merged.pr, head: merged.head };
|
|
1911
|
-
const
|
|
1922
|
+
const recordedWave = plans?.waves.find((w) => w.wave === k);
|
|
1923
|
+
const recorded = recordedWave?.digest;
|
|
1912
1924
|
if (recorded === undefined) {
|
|
1913
1925
|
return { preview: { status: "unrecorded", ...seen, reason: `no plans are recorded for wave ${k} at the head ${merged.head.slice(0, 12)} of #${merged.pr} (its pipeline runs \`chant run wave --record-plans\`), so nothing was previewed` } };
|
|
1914
1926
|
}
|
|
1927
|
+
// plywood#55: a record that holds each run's resources is compared resource by resource, over the ones the pull request's plan changed.
|
|
1928
|
+
if (recordedWave.members) {
|
|
1929
|
+
const moved = movedSincePreview(recordedWave.members, members);
|
|
1930
|
+
if (moved.length > 0) {
|
|
1931
|
+
return {
|
|
1932
|
+
preview: {
|
|
1933
|
+
status: "moved",
|
|
1934
|
+
...seen,
|
|
1935
|
+
recorded,
|
|
1936
|
+
compared: "resources",
|
|
1937
|
+
moved,
|
|
1938
|
+
reason: `the plans moved since #${merged.pr} previewed them: ${moved.join("; ")} (the head ${merged.head.slice(0, 12)} planned ${recorded}, and the merge plans ${digest})`,
|
|
1939
|
+
},
|
|
1940
|
+
};
|
|
1941
|
+
}
|
|
1942
|
+
return { preview: { status: "matched", ...seen, recorded, compared: "resources" } };
|
|
1943
|
+
}
|
|
1915
1944
|
if (!samePlanDigest(recorded, digest)) {
|
|
1916
1945
|
return {
|
|
1917
1946
|
preview: {
|
|
1918
1947
|
status: "moved",
|
|
1919
1948
|
...seen,
|
|
1920
1949
|
recorded,
|
|
1921
|
-
|
|
1950
|
+
compared: "wave",
|
|
1951
|
+
reason: `the plans moved since #${merged.pr} previewed them: the head ${merged.head.slice(0, 12)} planned ${recorded}, and the merge plans ${digest}. The record was written by chant 0.124.59, which keeps the wave's digest only, so the whole wave was compared; a later chant records each resource and compares those`,
|
|
1922
1952
|
},
|
|
1923
1953
|
};
|
|
1924
1954
|
}
|
|
1925
|
-
return { preview: { status: "matched", ...seen, recorded } };
|
|
1955
|
+
return { preview: { status: "matched", ...seen, recorded, compared: "wave" } };
|
|
1926
1956
|
}
|
|
1927
1957
|
/**
|
|
1928
1958
|
* The gate was asked about plans the pull request did not preview. An
|
|
@@ -3211,6 +3241,8 @@ export async function recordOpWaveHeadPlans(options) {
|
|
|
3211
3241
|
digest: opWaveSetDigest(spec, members, extras),
|
|
3212
3242
|
changes: !members.every((m) => m.empty === true),
|
|
3213
3243
|
destructive: members.some((m) => m.destructive === true),
|
|
3244
|
+
// plywood#55: each run's resources, which a merged wave under `approvals.preview` compares with its own.
|
|
3245
|
+
members: members.map((m) => ({ member: m.member, planDigest: m.planDigest, ...(m.resources ? { resources: m.resources } : {}), ...(m.empty ? { empty: true } : {}) })),
|
|
3214
3246
|
// #4630: a pull-request wave's change set, which the pull request's own approval must cover.
|
|
3215
3247
|
...(changeSet ? { changeSet: changeSet.digest } : {}),
|
|
3216
3248
|
});
|
package/dist/release-floors.d.ts
CHANGED
|
@@ -19,5 +19,5 @@
|
|
|
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 declare const NEXT_RELEASE = "0.124.
|
|
22
|
+
export declare const NEXT_RELEASE = "0.124.60";
|
|
23
23
|
//# sourceMappingURL=release-floors.d.ts.map
|
package/dist/release-floors.js
CHANGED