@intentius/chant 0.124.85 → 0.124.86
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/bundle-check.d.ts +102 -0
- package/dist/bundle-check.d.ts.map +1 -0
- package/dist/bundle-check.js +310 -0
- package/dist/chant-install.d.ts +100 -0
- package/dist/chant-install.d.ts.map +1 -0
- package/dist/chant-install.js +158 -0
- package/dist/ci-commit.d.ts +19 -6
- package/dist/ci-commit.d.ts.map +1 -1
- package/dist/ci-commit.js +23 -4
- package/dist/ci-evidence-jobs.d.ts +54 -0
- package/dist/ci-evidence-jobs.d.ts.map +1 -0
- package/dist/ci-evidence-jobs.js +55 -0
- package/dist/ci-image.d.ts +274 -0
- package/dist/ci-image.d.ts.map +1 -0
- package/dist/ci-image.js +635 -0
- package/dist/ci-login.d.ts +150 -0
- package/dist/ci-login.d.ts.map +1 -0
- package/dist/ci-login.js +240 -0
- package/dist/ci-product.d.ts +16 -0
- package/dist/ci-product.d.ts.map +1 -1
- package/dist/ci-product.js +17 -0
- package/dist/cli/commands/import-index.js +2 -2
- package/dist/cli/handlers/build.d.ts +8 -0
- package/dist/cli/handlers/build.d.ts.map +1 -1
- package/dist/cli/handlers/build.js +22 -4
- package/dist/cli/handlers/ci-check.d.ts.map +1 -1
- package/dist/cli/handlers/ci-check.js +57 -2
- package/dist/cli/handlers/ci-evidence.d.ts +3 -0
- package/dist/cli/handlers/ci-evidence.d.ts.map +1 -0
- package/dist/cli/handlers/ci-evidence.js +171 -0
- package/dist/cli/handlers/components.js +3 -3
- package/dist/cli/handlers/dead-guards.d.ts +3 -0
- package/dist/cli/handlers/dead-guards.d.ts.map +1 -0
- package/dist/cli/handlers/dead-guards.js +35 -0
- package/dist/cli/handlers/graph.js +4 -4
- package/dist/cli/handlers/lifecycle.d.ts +2 -1
- package/dist/cli/handlers/lifecycle.d.ts.map +1 -1
- package/dist/cli/handlers/lifecycle.js +5 -4
- package/dist/cli/handlers/local-chant.d.ts +16 -0
- package/dist/cli/handlers/local-chant.d.ts.map +1 -0
- package/dist/cli/handlers/local-chant.js +109 -0
- package/dist/cli/handlers/operator.js +2 -2
- package/dist/cli/handlers/search.js +5 -5
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +38 -0
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +28 -0
- package/dist/cli/registry.d.ts +16 -0
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/components/check-hooks.d.ts +49 -0
- package/dist/components/check-hooks.d.ts.map +1 -1
- package/dist/components/check-hooks.js +64 -4
- package/dist/components/check-steps.d.ts +17 -0
- package/dist/components/check-steps.d.ts.map +1 -1
- package/dist/components/check-steps.js +37 -5
- package/dist/components/product-pipeline.d.ts +23 -0
- package/dist/components/product-pipeline.d.ts.map +1 -1
- package/dist/components/product-pipeline.js +6 -2
- package/dist/components/product-plan.d.ts +137 -0
- package/dist/components/product-plan.d.ts.map +1 -0
- package/dist/components/product-plan.js +143 -0
- package/dist/components/release-compile.d.ts.map +1 -1
- package/dist/components/release-compile.js +2 -2
- package/dist/config.d.ts +39 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +35 -3
- package/dist/dead-guards.d.ts +82 -0
- package/dist/dead-guards.d.ts.map +1 -0
- package/dist/dead-guards.js +436 -0
- package/dist/discovery/files.d.ts +3 -1
- package/dist/discovery/files.d.ts.map +1 -1
- package/dist/discovery/files.js +5 -3
- package/dist/drift-issue.d.ts +152 -0
- package/dist/drift-issue.d.ts.map +1 -0
- package/dist/drift-issue.js +167 -0
- package/dist/floor-table.d.ts +30 -0
- package/dist/floor-table.d.ts.map +1 -0
- package/dist/floor-table.data.d.ts +3 -0
- package/dist/floor-table.data.d.ts.map +1 -0
- package/dist/floor-table.data.js +178 -0
- package/dist/floor-table.js +56 -0
- package/dist/forge-flags.d.ts +90 -0
- package/dist/forge-flags.d.ts.map +1 -0
- package/dist/forge-flags.js +184 -0
- package/dist/lexicon.d.ts +69 -0
- package/dist/lexicon.d.ts.map +1 -1
- package/dist/lifecycle/gated-op.d.ts +7 -1
- package/dist/lifecycle/gated-op.d.ts.map +1 -1
- package/dist/lifecycle/gated-op.js +7 -4
- package/dist/local-chant.d.ts +98 -0
- package/dist/local-chant.d.ts.map +1 -0
- package/dist/local-chant.js +307 -0
- package/dist/op/activities/predict-behaviour.js +2 -2
- package/dist/op/op-waves-evidence-spec.d.ts +13 -0
- package/dist/op/op-waves-evidence-spec.d.ts.map +1 -0
- package/dist/op/op-waves-evidence-spec.js +21 -0
- package/dist/op/op-waves-evidence.d.ts +38 -0
- package/dist/op/op-waves-evidence.d.ts.map +1 -0
- package/dist/op/op-waves-evidence.js +57 -0
- package/dist/op/op-waves-run.d.ts +4 -0
- package/dist/op/op-waves-run.d.ts.map +1 -1
- package/dist/op/op-waves-run.js +24 -1
- package/dist/op/op-waves.d.ts +17 -1
- package/dist/op/op-waves.d.ts.map +1 -1
- package/dist/op/op-waves.js +23 -0
- package/dist/op/schedule-overdue.d.ts +41 -9
- package/dist/op/schedule-overdue.d.ts.map +1 -1
- package/dist/op/schedule-overdue.js +154 -25
- package/dist/plan-summary.d.ts +25 -0
- package/dist/plan-summary.d.ts.map +1 -1
- package/dist/plan-summary.js +31 -0
- package/dist/pr-plan-note.d.ts +35 -0
- package/dist/pr-plan-note.d.ts.map +1 -1
- package/dist/pr-plan-note.js +10 -0
- package/dist/pr-post.d.ts +23 -0
- package/dist/pr-post.d.ts.map +1 -1
- package/dist/pr-post.js +125 -3
- package/dist/release-floors.d.ts +31 -1
- package/dist/release-floors.d.ts.map +1 -1
- package/dist/release-floors.js +31 -1
- package/dist/state-migration.d.ts +24 -0
- package/dist/state-migration.d.ts.map +1 -1
- package/dist/state-migration.js +100 -5
- package/dist/wave-runtime.mjs +305 -298
- package/dist/workspace/lexicon-outputs.d.ts.map +1 -1
- package/dist/workspace/lexicon-outputs.js +21 -7
- package/dist/workspace/reason-codes.d.ts +3 -0
- package/dist/workspace/reason-codes.d.ts.map +1 -1
- package/dist/workspace/reason-codes.js +4 -0
- package/dist/workspace/ref-gate.schema.json +85 -0
- package/dist/workspace/search-contract.d.ts +1 -1
- package/dist/workspace/search-contract.d.ts.map +1 -1
- package/dist/workspace/trust/check-evidence-report.d.ts +51 -0
- package/dist/workspace/trust/check-evidence-report.d.ts.map +1 -0
- package/dist/workspace/trust/check-evidence-report.js +102 -0
- package/dist/workspace/trust/check-evidence.d.ts +126 -0
- package/dist/workspace/trust/check-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/check-evidence.js +237 -0
- package/dist/workspace/trust/local-evidence.d.ts +120 -0
- package/dist/workspace/trust/local-evidence.d.ts.map +1 -0
- package/dist/workspace/trust/local-evidence.js +259 -0
- package/dist/workspace/trust/policy.d.ts +84 -0
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +94 -1
- package/dist/workspace/trust/ref-gate-cli.d.ts +33 -0
- package/dist/workspace/trust/ref-gate-cli.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate-cli.js +234 -0
- package/dist/workspace/trust/ref-gate-fixture.d.ts +38 -0
- package/dist/workspace/trust/ref-gate-fixture.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate-fixture.js +97 -0
- package/dist/workspace/trust/ref-gate.d.ts +187 -0
- package/dist/workspace/trust/ref-gate.d.ts.map +1 -0
- package/dist/workspace/trust/ref-gate.js +430 -0
- package/dist/workspace/trust/trust-files.d.ts.map +1 -1
- package/dist/workspace/trust/trust-files.js +18 -1
- package/package.json +1 -1
- package/src/bundle-check.test.ts +140 -0
- package/src/bundle-check.ts +352 -0
- package/src/chant-install.test.ts +112 -0
- package/src/chant-install.ts +179 -0
- package/src/ci-commit.test.ts +45 -0
- package/src/ci-commit.ts +38 -4
- package/src/ci-evidence-jobs.ts +67 -0
- package/src/ci-image.test.ts +506 -0
- package/src/ci-image.ts +822 -0
- package/src/ci-login.test.ts +235 -0
- package/src/ci-login.ts +307 -0
- package/src/ci-product.ts +18 -0
- package/src/cli/commands/__fixtures__/source-dir-include/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-include/infra.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-include/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-root/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/infra.test.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/infra.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-root/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/app.ts +3 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/chant.config.json +1 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/infra/net.ts +1 -0
- package/src/cli/commands/__fixtures__/source-dir-scoped/scripts/run-on-load.ts +3 -0
- package/src/cli/commands/import-index.ts +2 -2
- package/src/cli/handlers/build-source-dir.test.ts +64 -0
- package/src/cli/handlers/build.ts +21 -4
- package/src/cli/handlers/ci-check.ts +56 -3
- package/src/cli/handlers/ci-evidence.ts +162 -0
- package/src/cli/handlers/components.ts +3 -3
- package/src/cli/handlers/dead-guards.ts +37 -0
- package/src/cli/handlers/graph.ts +4 -4
- package/src/cli/handlers/lifecycle.ts +5 -4
- package/src/cli/handlers/local-chant.ts +106 -0
- package/src/cli/handlers/operator.ts +2 -2
- package/src/cli/handlers/search.ts +5 -5
- package/src/cli/main.test.ts +7 -0
- package/src/cli/main.ts +38 -0
- package/src/cli/parse-args.ts +21 -0
- package/src/cli/registry.ts +16 -0
- package/src/components/check-evidence-stage.test.ts +80 -0
- package/src/components/check-hooks.ts +84 -4
- package/src/components/check-local-evidence-stage.test.ts +141 -0
- package/src/components/check-steps.ts +56 -6
- package/src/components/product-pipeline.ts +28 -3
- package/src/components/product-plan.test.ts +87 -0
- package/src/components/product-plan.ts +226 -0
- package/src/components/release-compile.ts +2 -2
- package/src/config.ts +44 -3
- package/src/dead-guards.test.ts +206 -0
- package/src/dead-guards.ts +446 -0
- package/src/discovery/files.ts +5 -3
- package/src/drift-issue-bundle.test.ts +31 -0
- package/src/drift-issue.test.ts +206 -0
- package/src/drift-issue.ts +274 -0
- package/src/fit-note.test.ts +44 -0
- package/src/floor-table.data.ts +180 -0
- package/src/floor-table.ts +77 -0
- package/src/forge-flags.test.ts +110 -0
- package/src/forge-flags.ts +208 -0
- package/src/gate-decision-bundle.test.ts +1 -0
- package/src/lexicon.ts +68 -0
- package/src/lifecycle/gated-op.ts +10 -5
- package/src/local-chant.e2e.test.ts +94 -0
- package/src/local-chant.test.ts +162 -0
- package/src/local-chant.ts +341 -0
- package/src/op/activities/predict-behaviour.ts +2 -2
- package/src/op/op-waves-evidence-spec.ts +24 -0
- package/src/op/op-waves-evidence.test.ts +130 -0
- package/src/op/op-waves-evidence.ts +57 -0
- package/src/op/op-waves-run.ts +25 -1
- package/src/op/op-waves.ts +31 -1
- package/src/op/schedule-overdue.test.ts +85 -0
- package/src/op/schedule-overdue.ts +162 -26
- package/src/plan-summary.ts +40 -0
- package/src/pr-plan-note.ts +34 -0
- package/src/pr-post-plan-note.test.ts +146 -0
- package/src/pr-post.ts +127 -3
- package/src/release-floors.ts +44 -1
- package/src/stage-hooks-bundle.test.ts +1 -0
- package/src/state-migration.test.ts +52 -1
- package/src/state-migration.ts +107 -5
- package/src/workspace/lexicon-outputs.ts +23 -6
- package/src/workspace/reason-codes.test.ts +3 -0
- package/src/workspace/reason-codes.ts +4 -0
- package/src/workspace/ref-gate.schema.json +85 -0
- package/src/workspace/trust/check-evidence-report.ts +106 -0
- package/src/workspace/trust/check-evidence.test.ts +133 -0
- package/src/workspace/trust/check-evidence.ts +257 -0
- package/src/workspace/trust/local-evidence.test.ts +127 -0
- package/src/workspace/trust/local-evidence.ts +266 -0
- package/src/workspace/trust/policy.ts +134 -1
- package/src/workspace/trust/ref-gate-cli.ts +244 -0
- package/src/workspace/trust/ref-gate-fixture.ts +125 -0
- package/src/workspace/trust/ref-gate.e2e.test.ts +76 -0
- package/src/workspace/trust/ref-gate.test.ts +247 -0
- package/src/workspace/trust/ref-gate.ts +538 -0
- package/src/workspace/trust/trust-files.test.ts +16 -0
- package/src/workspace/trust/trust-files.ts +41 -1
package/dist/state-migration.js
CHANGED
|
@@ -28,12 +28,33 @@
|
|
|
28
28
|
* released whatever happens. The finished line holds each root's
|
|
29
29
|
* location and its version and digest before and after, never a
|
|
30
30
|
* state's contents.
|
|
31
|
+
*
|
|
32
|
+
* A root whose new state is read from somewhere else (a backend move, #4806)
|
|
33
|
+
* names that place as its `source`: the request binds it, and under the
|
|
34
|
+
* locks the engine reads it again, so a source that moved refuses the write
|
|
35
|
+
* as a root's own state does. A request that waits while an approval of an
|
|
36
|
+
* earlier request of the same migration stands, made since that request was
|
|
37
|
+
* asked, answers `approval-moved` and names the roots whose state moved
|
|
38
|
+
* between the two (#4806).
|
|
31
39
|
*/
|
|
32
40
|
import { CHANT_EXIT } from "./exit-codes.js";
|
|
33
|
-
import { gatedOp } from "./lifecycle/gated-op.js";
|
|
41
|
+
import { chantGatedLedger, gatedOp } from "./lifecycle/gated-op.js";
|
|
42
|
+
import { gatedRequestAttachmentPath } from "./lifecycle/gated-request-digest.js";
|
|
43
|
+
import { samePlanDigest } from "./lifecycle/plan-digest.js";
|
|
44
|
+
import { NEXT_RELEASE } from "./release-floors.js";
|
|
34
45
|
/** The first chant with the engine-neutral state migration (#4762). */
|
|
35
46
|
export const STATE_MIGRATION_FLOOR = "0.124.77";
|
|
47
|
+
/** The first chant whose migration binds a root's `source` (an engine's `source` read under the locks) and answers `approval-moved`, and whose terraform lexicon plans backend moves (`planTerraformMigration`'s `backends`) and choudoufu estate migrations (`planEstateMigration`) onto it (#4806). */
|
|
48
|
+
export const STATE_MIGRATION_SOURCE_FLOOR = NEXT_RELEASE;
|
|
36
49
|
const same = (a, b) => (a.version_id ?? undefined) === (b.version_id ?? undefined) && a.digest === b.digest;
|
|
50
|
+
/** What a request's attachment binds of each root: its location and state before, its new state's digest, and its source when it has one. */
|
|
51
|
+
const boundRoot = (r) => ({
|
|
52
|
+
root: r.root,
|
|
53
|
+
location: r.location ?? null,
|
|
54
|
+
before: { version_id: r.before.version_id ?? null, digest: r.before.digest },
|
|
55
|
+
after: r.after.digest,
|
|
56
|
+
...(r.source ? { source: { location: r.source.location ?? null, version_id: r.source.version_id ?? null, digest: r.source.digest } } : {}),
|
|
57
|
+
});
|
|
37
58
|
/** The finished line's flat facts: how it ended, and each root's location, versions and digests. */
|
|
38
59
|
export function migrationFacts(result) {
|
|
39
60
|
const out = {
|
|
@@ -53,6 +74,10 @@ export function migrationFacts(result) {
|
|
|
53
74
|
out[`${r.root}.before_digest`] = r.before.digest;
|
|
54
75
|
if (r.after.digest)
|
|
55
76
|
out[`${r.root}.after_digest`] = r.after.digest;
|
|
77
|
+
if (r.source?.location)
|
|
78
|
+
out[`${r.root}.source`] = r.source.location;
|
|
79
|
+
if (r.source?.version_id)
|
|
80
|
+
out[`${r.root}.source_version`] = r.source.version_id;
|
|
56
81
|
}
|
|
57
82
|
return out;
|
|
58
83
|
}
|
|
@@ -66,9 +91,12 @@ export async function writeStateMigration(engine, roots) {
|
|
|
66
91
|
const release = await engine.lock();
|
|
67
92
|
try {
|
|
68
93
|
const moved = [];
|
|
69
|
-
for (const r of roots)
|
|
94
|
+
for (const r of roots) {
|
|
70
95
|
if (!same(await engine.current(r.root), r.before))
|
|
71
96
|
moved.push(r.root);
|
|
97
|
+
else if (r.source && engine.source && !same(await engine.source(r.root), r.source))
|
|
98
|
+
moved.push(r.root);
|
|
99
|
+
}
|
|
72
100
|
if (moved.length > 0)
|
|
73
101
|
return { status: "moved", roots, moved };
|
|
74
102
|
try {
|
|
@@ -104,7 +132,8 @@ export async function runStateMigration(input) {
|
|
|
104
132
|
return { status: "proof-failed", exit: CHANT_EXIT.failed, roots: input.roots, failing };
|
|
105
133
|
const roots = [...input.roots].sort((a, b) => (a.root < b.root ? -1 : a.root > b.root ? 1 : 0));
|
|
106
134
|
// The attachment binds each root's state before and after; the proof's wording is the engine's, not the migration.
|
|
107
|
-
const attachment = `${JSON.stringify({ name: input.name, roots: roots.map(
|
|
135
|
+
const attachment = `${JSON.stringify({ name: input.name, roots: roots.map(boundRoot) }, null, 2)}\n`;
|
|
136
|
+
const now = input.now ?? new Date().toISOString();
|
|
108
137
|
const result = await gatedOp({
|
|
109
138
|
op: input.words.op,
|
|
110
139
|
request: { kind: input.words.kind ?? "migrate", subject: input.name, by: input.by, fields: { ...(input.fields ?? {}), roots: roots.map((r) => r.root).join(",") } },
|
|
@@ -114,7 +143,7 @@ export async function runStateMigration(input) {
|
|
|
114
143
|
attachment,
|
|
115
144
|
...(input.base ? { base: input.base } : {}),
|
|
116
145
|
...(input.cwd ? { cwd: input.cwd } : {}),
|
|
117
|
-
|
|
146
|
+
now,
|
|
118
147
|
...(input.runId ? { runId: input.runId } : {}),
|
|
119
148
|
...(input.commit ? { commit: input.commit } : {}),
|
|
120
149
|
...(input.ledger ? { ledger: input.ledger } : {}),
|
|
@@ -124,8 +153,12 @@ export async function runStateMigration(input) {
|
|
|
124
153
|
});
|
|
125
154
|
const command = (fallback) => (input.words.approveCommand ? input.words.approveCommand(input.name, result.digest) : fallback);
|
|
126
155
|
switch (result.status) {
|
|
127
|
-
case "waiting":
|
|
156
|
+
case "waiting": {
|
|
157
|
+
const stood = await approvalMovedFrom(input, roots, result.digest, now);
|
|
158
|
+
if (stood)
|
|
159
|
+
return { status: "approval-moved", exit: CHANT_EXIT.moved, digest: result.digest, command: command(result.command), ...stood };
|
|
128
160
|
return { status: "waiting", exit: CHANT_EXIT.waiting, digest: result.digest, command: command(result.command) };
|
|
161
|
+
}
|
|
129
162
|
case "refused":
|
|
130
163
|
return { status: "refused", exit: CHANT_EXIT.waiting, digest: result.digest, command: command(result.command), by: result.by, reason: result.reason };
|
|
131
164
|
case "spent":
|
|
@@ -144,3 +177,65 @@ export async function runStateMigration(input) {
|
|
|
144
177
|
}
|
|
145
178
|
}
|
|
146
179
|
}
|
|
180
|
+
/** An earlier request's attachment on chant/lifecycle, by its digest. */
|
|
181
|
+
async function ledgerAttachment(op, digest, cwd) {
|
|
182
|
+
const { readBlobFromPath } = await import("./lifecycle/git.js");
|
|
183
|
+
const { dir, file } = gatedRequestAttachmentPath(op, digest);
|
|
184
|
+
return (await readBlobFromPath(dir, file, cwd ? { cwd } : undefined)) ?? undefined;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The approval a waiting request moved away from (#4806): a state written
|
|
188
|
+
* after an approval changes the request's digest, so the migration asks
|
|
189
|
+
* again. The approval that stands is the newest of another request of the
|
|
190
|
+
* migration, unspent, not its requester's own, and made since the newest
|
|
191
|
+
* pending fact before this run (`now` is this run's: a pending fact of that
|
|
192
|
+
* time is the one this run asked). The roots that moved are those whose
|
|
193
|
+
* bound state differs from that request's attachment, or every root when
|
|
194
|
+
* the attachment cannot be read. Undefined when no approval stands.
|
|
195
|
+
*
|
|
196
|
+
* Lifted from terragucci's `movedSinceChantApproval` and `beforeMembers`.
|
|
197
|
+
*/
|
|
198
|
+
async function approvalMovedFrom(input, roots, digest, now) {
|
|
199
|
+
const ledger = input.ledger ?? chantGatedLedger;
|
|
200
|
+
let requests;
|
|
201
|
+
try {
|
|
202
|
+
requests = await ledger.readGatedRequests(input.words.op, input.cwd ? { cwd: input.cwd } : undefined);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
const t = (s) => (s ? Date.parse(s) : 0);
|
|
208
|
+
const mine = requests.filter((r) => r.gate === input.name);
|
|
209
|
+
const asked = (r) => samePlanDigest(r.digest, digest) && t(r.pending.timestamp) === t(now);
|
|
210
|
+
const since = Math.max(0, ...mine.filter((r) => !asked(r)).map((r) => t(r.pending.timestamp)).filter((x) => !Number.isNaN(x)));
|
|
211
|
+
let prior;
|
|
212
|
+
let approval;
|
|
213
|
+
for (const r of mine) {
|
|
214
|
+
if (samePlanDigest(r.digest, digest) || r.applied)
|
|
215
|
+
continue;
|
|
216
|
+
const requester = r.request.by.toLowerCase();
|
|
217
|
+
for (const a of r.approvals) {
|
|
218
|
+
if (a.resolvedBy.toLowerCase() === requester || t(a.timestamp) < since)
|
|
219
|
+
continue;
|
|
220
|
+
if (!approval || t(a.timestamp) >= t(approval.timestamp))
|
|
221
|
+
[prior, approval] = [r, a];
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (!prior || !approval)
|
|
225
|
+
return undefined;
|
|
226
|
+
let stored;
|
|
227
|
+
try {
|
|
228
|
+
const text = input.readAttachment ? await input.readAttachment(input.words.op, prior.digest) : await ledgerAttachment(input.words.op, prior.digest, input.cwd);
|
|
229
|
+
stored = text ? JSON.parse(text) : undefined;
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
stored = undefined;
|
|
233
|
+
}
|
|
234
|
+
const was = new Map();
|
|
235
|
+
if (Array.isArray(stored?.roots))
|
|
236
|
+
for (const r of stored.roots)
|
|
237
|
+
if (typeof r.root === "string")
|
|
238
|
+
was.set(r.root, JSON.stringify({ ...r, after: null }));
|
|
239
|
+
const moved = Array.isArray(stored?.roots) ? roots.filter((r) => was.get(r.root) !== JSON.stringify({ ...boundRoot(r), after: null })).map((r) => r.root) : roots.map((r) => r.root);
|
|
240
|
+
return { approved: prior.digest, approvedBy: approval.resolvedBy, moved };
|
|
241
|
+
}
|