nx 24.0.0-beta.2 → 24.0.0-beta.3
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/bin/post-install.js +5 -3
- package/dist/src/adapter/ngcli-adapter.js +1 -2
- package/dist/src/command-line/add/add.d.ts +2 -0
- package/dist/src/command-line/add/add.js +23 -5
- package/dist/src/command-line/affected/affected.js +2 -2
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +21 -62
- package/dist/src/command-line/migrate/agentic/definitions.d.ts +1 -3
- package/dist/src/command-line/migrate/agentic/definitions.js +5 -97
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +7 -41
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +9 -48
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +1 -43
- package/dist/src/command-line/migrate/agentic/handoff.js +3 -119
- package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +0 -21
- package/dist/src/command-line/migrate/agentic/instruction-files.js +6 -27
- package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +19 -1
- package/dist/src/command-line/migrate/agentic/master/run-master-session.js +63 -36
- package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +1 -0
- package/dist/src/command-line/migrate/agentic/master/spawn-master.js +7 -5
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +2 -2
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +2 -2
- package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +1 -12
- package/dist/src/command-line/migrate/agentic/prompts/fragments.js +8 -17
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +0 -15
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +3 -100
- package/dist/src/command-line/migrate/agentic/select.d.ts +12 -6
- package/dist/src/command-line/migrate/agentic/select.js +35 -5
- package/dist/src/command-line/migrate/agentic/types.d.ts +9 -68
- package/dist/src/command-line/migrate/agentic/types.js +5 -5
- package/dist/src/command-line/migrate/command-object.js +3 -3
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +12 -1
- package/dist/src/command-line/migrate/migrate-analytics.js +26 -0
- package/dist/src/command-line/migrate/migrate-commits.d.ts +9 -10
- package/dist/src/command-line/migrate/migrate-commits.js +25 -18
- package/dist/src/command-line/migrate/migrate-output.d.ts +1 -6
- package/dist/src/command-line/migrate/migrate-output.js +1 -10
- package/dist/src/command-line/migrate/migrate.js +16 -27
- package/dist/src/command-line/migrate/run/agent-output.d.ts +1 -0
- package/dist/src/command-line/migrate/run/agent-output.js +4 -0
- package/dist/src/command-line/migrate/run/broker.js +1 -1
- package/dist/src/command-line/migrate/run/give-up.d.ts +4 -3
- package/dist/src/command-line/migrate/run/give-up.js +8 -5
- package/dist/src/command-line/migrate/run/index.d.ts +2 -1
- package/dist/src/command-line/migrate/run/index.js +5 -1
- package/dist/src/command-line/migrate/run/issues.js +7 -2
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +40 -4
- package/dist/src/command-line/migrate/run/orchestrator.js +233 -92
- package/dist/src/command-line/migrate/run/run-state.d.ts +4 -1
- package/dist/src/command-line/migrate/run/run-state.js +20 -2
- package/dist/src/command-line/migrate/run/runbook.d.ts +1 -0
- package/dist/src/command-line/migrate/run/runbook.js +99 -21
- package/dist/src/command-line/migrate/run/state-lock.d.ts +29 -4
- package/dist/src/command-line/migrate/run/state-lock.js +102 -10
- package/dist/src/command-line/migrate/run/util.d.ts +4 -2
- package/dist/src/command-line/migrate/run/util.js +23 -2
- package/dist/src/command-line/migrate/run/worker.d.ts +1 -1
- package/dist/src/command-line/migrate/run/worker.js +252 -250
- package/dist/src/command-line/release/changelog.js +9 -6
- package/dist/src/command-line/release/config/config.d.ts +1 -0
- package/dist/src/command-line/release/config/config.js +48 -9
- package/dist/src/command-line/release/release.js +2 -2
- package/dist/src/command-line/release/utils/git.js +8 -7
- package/dist/src/command-line/release/utils/interpolate-release-config.d.ts +6 -0
- package/dist/src/command-line/release/utils/interpolate-release-config.js +39 -0
- package/dist/src/command-line/release/utils/release-graph.d.ts +5 -0
- package/dist/src/command-line/release/utils/release-graph.js +1 -0
- package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +2 -2
- package/dist/src/command-line/release/utils/shared.js +10 -10
- package/dist/src/command-line/release/utils/version-plan-utils.d.ts +3 -12
- package/dist/src/command-line/release/utils/version-plan-utils.js +33 -55
- package/dist/src/command-line/release/version/version-actions.js +2 -1
- package/dist/src/command-line/release/version.js +5 -2
- package/dist/src/command-line/show/projects.js +5 -3
- package/dist/src/command-line/yargs-utils/shared-options.js +1 -1
- package/dist/src/config/nx-json.d.ts +8 -5
- package/dist/src/config/workspace-json-project-json.d.ts +12 -9
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/devkit-exports.d.ts +4 -0
- package/dist/src/devkit-exports.js +6 -1
- package/dist/src/devkit-internals.d.ts +1 -1
- package/dist/src/devkit-internals.js +4 -3
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +2 -2
- package/dist/src/executors/run-commands/run-commands.impl.js +20 -10
- package/dist/src/executors/run-commands/running-tasks.d.ts +12 -3
- package/dist/src/executors/run-commands/running-tasks.js +22 -18
- package/dist/src/hasher/check-task-files.js +1 -4
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +1 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +6 -11
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +2 -2
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.d.ts +4 -0
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.js +15 -0
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.md +30 -0
- package/dist/src/migrations/update-24-0-0/move-custom-hashers-to-inputs.md +7 -6
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.d.ts +3 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.js +130 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.md +62 -0
- package/dist/src/native/index.d.ts +3 -3
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +1 -3
- package/dist/src/plugins/js/lock-file/pruned-output.d.ts +2 -2
- package/dist/src/plugins/js/lock-file/pruned-output.js +4 -4
- package/dist/src/project-graph/affected/affected-tasks.d.ts +6 -5
- package/dist/src/project-graph/affected/affected-tasks.js +16 -6
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +1 -1
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +7 -133
- package/dist/src/project-graph/utils/project-configuration-utils.js +2 -2
- package/dist/src/tasks-runner/readiness/probes.js +30 -1
- package/dist/src/tasks-runner/readiness/ready-when.d.ts +31 -10
- package/dist/src/tasks-runner/readiness/ready-when.js +178 -41
- package/dist/src/tasks-runner/task-orchestrator.d.ts +4 -0
- package/dist/src/tasks-runner/task-orchestrator.js +113 -38
- package/dist/src/tasks-runner/tokens.d.ts +54 -0
- package/dist/src/tasks-runner/tokens.js +161 -0
- package/dist/src/tasks-runner/utils.d.ts +15 -1
- package/dist/src/tasks-runner/utils.js +79 -33
- package/dist/src/utils/acknowledge-build-scripts.d.ts +34 -1
- package/dist/src/utils/acknowledge-build-scripts.js +171 -32
- package/dist/src/utils/long-running-target.d.ts +1 -3
- package/dist/src/utils/long-running-target.js +1 -3
- package/migrations.json +13 -6
- package/package.json +11 -11
- package/schemas/nx-schema.json +17 -11
- package/schemas/project-schema.json +8 -7
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +0 -56
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +0 -67
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +0 -49
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +0 -53
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +0 -26
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +0 -27
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +0 -70
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +0 -113
- package/dist/src/command-line/migrate/agentic/run-step.d.ts +0 -68
- package/dist/src/command-line/migrate/agentic/run-step.js +0 -148
- package/dist/src/command-line/migrate/agentic/runner.d.ts +0 -21
- package/dist/src/command-line/migrate/agentic/runner.js +0 -262
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +0 -9
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +0 -18
|
@@ -8,7 +8,13 @@ exports.releaseRunToHandOff = releaseRunToHandOff;
|
|
|
8
8
|
exports.activeRunForClassic = activeRunForClassic;
|
|
9
9
|
exports.checkRunForStartFresh = checkRunForStartFresh;
|
|
10
10
|
exports.deleteRunForStartFresh = deleteRunForStartFresh;
|
|
11
|
+
exports.refuseNewRunAlongsideLiveRun = refuseNewRunAlongsideLiveRun;
|
|
12
|
+
exports.checkRunsForSingleMigration = checkRunsForSingleMigration;
|
|
13
|
+
exports.prepareSingleMigrationRun = prepareSingleMigrationRun;
|
|
14
|
+
exports.removeSingleMigrationRun = removeSingleMigrationRun;
|
|
11
15
|
exports.runOrchestratorReconcile = runOrchestratorReconcile;
|
|
16
|
+
exports.dispenseSingleMigrationStep = dispenseSingleMigrationStep;
|
|
17
|
+
exports.lastCoveringLandedEntry = lastCoveringLandedEntry;
|
|
12
18
|
exports.completionWarnings = completionWarnings;
|
|
13
19
|
const child_process_1 = require("child_process");
|
|
14
20
|
const crypto_1 = require("crypto");
|
|
@@ -97,7 +103,7 @@ function refuseUnsafeScratchExposure(exposure, thenWhat) {
|
|
|
97
103
|
}
|
|
98
104
|
}
|
|
99
105
|
async function runOrchestratorInit(input) {
|
|
100
|
-
const { root, migrationsJson, migrationsPath, createCommits, commitPrefix, skipInstall, installedNxVersion, validate, finalValidation, emitAgentInstructions = true, onExistingRun = 'report', replaceRunId, confirmStart, } = input;
|
|
106
|
+
const { root, migrationsJson, migrationsPath, createCommits, commitPrefix, skipInstall, installedNxVersion, validate, finalValidation, emitAgentInstructions = true, onExistingRun = 'report', replaceRunId, confirmStart, singleMigration = false, } = input;
|
|
101
107
|
const migrations = (migrationsJson.migrations ?? []);
|
|
102
108
|
const sorted = (0, sort_migrations_1.sortMigrations)(migrations.slice());
|
|
103
109
|
const plannedIds = sorted.map((m) => `${m.package}:${m.name}`);
|
|
@@ -106,9 +112,11 @@ async function runOrchestratorInit(input) {
|
|
|
106
112
|
// and whether to continue it or replace it is the user's call, not a guess
|
|
107
113
|
// from the plans. Reported before the migration id check below: this plan
|
|
108
114
|
// is not being started. NewerRunStateFormatError propagates.
|
|
109
|
-
const active =
|
|
110
|
-
?
|
|
111
|
-
:
|
|
115
|
+
const active = singleMigration
|
|
116
|
+
? null
|
|
117
|
+
: onExistingRun === 'start-fresh'
|
|
118
|
+
? activeRunToReplace(root, replaceRunId)
|
|
119
|
+
: findActiveRunForInit(root);
|
|
112
120
|
if (active &&
|
|
113
121
|
(onExistingRun === 'report' ||
|
|
114
122
|
(replaceRunId !== undefined && active.runId !== replaceRunId))) {
|
|
@@ -123,7 +131,7 @@ async function runOrchestratorInit(input) {
|
|
|
123
131
|
}
|
|
124
132
|
if ((0, fs_1.existsSync)((0, run_state_1.migrateRunsDir)(root))) {
|
|
125
133
|
(0, state_lock_1.withRunCreationLock)(root, () => {
|
|
126
|
-
|
|
134
|
+
refuseNewRunAlongsideLiveRun(root, singleMigration);
|
|
127
135
|
if (active) {
|
|
128
136
|
refuseUndeletableRun(root, active.runId, active.state);
|
|
129
137
|
}
|
|
@@ -155,18 +163,11 @@ async function runOrchestratorInit(input) {
|
|
|
155
163
|
refuseUnsafeScratchExposure(scratchExposure, INIT_CONTINUE_HINT);
|
|
156
164
|
}
|
|
157
165
|
// Applied before the checkpoint so the entry (when it can be added) already
|
|
158
|
-
// covers older scratch by the time the checkpoint's `git add -A` runs
|
|
159
|
-
// fallback's standalone commit is suppressed because that checkpoint
|
|
160
|
-
// carries the edit. A planned ignore migration can't be deferred to: the
|
|
161
|
-
// run dir is created below, before that migration runs.
|
|
166
|
+
// covers older scratch by the time the checkpoint's `git add -A` runs.
|
|
162
167
|
await (0, handoff_gitignore_1.applyAgenticHandoffGitignoreFallback)({
|
|
163
168
|
migrations: sorted,
|
|
164
169
|
installedNxVersion,
|
|
165
|
-
effectiveCreateCommits: createCommits,
|
|
166
|
-
commitPrefix,
|
|
167
170
|
root,
|
|
168
|
-
applyWhenPlanned: true,
|
|
169
|
-
commitStandalone: false,
|
|
170
171
|
});
|
|
171
172
|
if (scratchExposure === 'unignored') {
|
|
172
173
|
// The fallback was the workspace's last chance at ignore coverage;
|
|
@@ -180,17 +181,21 @@ async function runOrchestratorInit(input) {
|
|
|
180
181
|
// migrate would wait on this process. The .gitignore fallback is idempotent.
|
|
181
182
|
let deleted = false;
|
|
182
183
|
const reserved = (0, state_lock_1.withRunCreationLock)(root, () => {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (nowActive && nowActive.runId !== active?.runId) {
|
|
186
|
-
return nowActive;
|
|
184
|
+
if (singleMigration) {
|
|
185
|
+
refuseNewRunAlongsideLiveRun(root, true);
|
|
187
186
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (
|
|
191
|
-
|
|
187
|
+
else {
|
|
188
|
+
const nowActive = findActiveRunForInit(root, active !== null);
|
|
189
|
+
if (nowActive && nowActive.runId !== active?.runId) {
|
|
190
|
+
return nowActive;
|
|
191
|
+
}
|
|
192
|
+
if (active) {
|
|
193
|
+
// Completed meanwhile (a reconcile finished it): nothing to replace.
|
|
194
|
+
if (!nowActive) {
|
|
195
|
+
throw new Error(noActiveRunToReplace(active.runId));
|
|
196
|
+
}
|
|
197
|
+
deleted = deleteRunRecord(root, active.runId);
|
|
192
198
|
}
|
|
193
|
-
deleted = deleteRunRecord(root, active.runId);
|
|
194
199
|
}
|
|
195
200
|
// The snapshot must exist before run.json makes the run discoverable: a
|
|
196
201
|
// crash in between must not leave an active run without its plan.
|
|
@@ -252,6 +257,7 @@ async function runOrchestratorInit(input) {
|
|
|
252
257
|
steps: buildSteps(sorted, finalValidation !== false),
|
|
253
258
|
commits: checkpoint ? [checkpoint] : [],
|
|
254
259
|
...(checkpointFailed ? { checkpointFailed: true } : {}),
|
|
260
|
+
...(singleMigration ? { singleMigration: true } : {}),
|
|
255
261
|
analytics: { startEmitted: false, completeEmitted: false },
|
|
256
262
|
};
|
|
257
263
|
(0, state_lock_1.withRunCreationLock)(root, () => {
|
|
@@ -277,9 +283,9 @@ function runOrchestratorResume(input) {
|
|
|
277
283
|
* Holds the active run `runId` names and returns its state. A continue calls
|
|
278
284
|
* this before the install and the agent selection: a concurrent start-fresh
|
|
279
285
|
* must not delete the run meanwhile. Throws when the id names no run or a
|
|
280
|
-
* finished one, and while another process holds the run
|
|
281
|
-
* open a second session over a live one.
|
|
282
|
-
* holder refuses.
|
|
286
|
+
* finished one, and while another process holds the run or works on a
|
|
287
|
+
* different run: continuing would open a second session over a live one.
|
|
288
|
+
* Under WASM nothing is held and no holder refuses.
|
|
283
289
|
*/
|
|
284
290
|
function holdRunToContinue(root, runId) {
|
|
285
291
|
if (!run_id_1.RUN_ID_SAFE.test(runId)) {
|
|
@@ -362,7 +368,6 @@ function deleteRunForStartFresh(root, runId) {
|
|
|
362
368
|
// Call under the creation lock. A run that became active since the user chose
|
|
363
369
|
// is refused, never deleted in place of the one they saw.
|
|
364
370
|
function activeRunToDelete(root, runId) {
|
|
365
|
-
refuseLiveReservation(root);
|
|
366
371
|
const active = findActiveRunForInit(root, true);
|
|
367
372
|
if (!active) {
|
|
368
373
|
throw new Error(noActiveRunToReplace(runId));
|
|
@@ -377,47 +382,136 @@ function activeRunToDelete(root, runId) {
|
|
|
377
382
|
// invocation would compete with) but only warn when a healthy active run is
|
|
378
383
|
// found, unless `refuseUninterpretable`: a start-fresh would delete that run
|
|
379
384
|
// and then find only the unreadable ones. NewerRunStateFormatError propagates
|
|
380
|
-
// from the read.
|
|
385
|
+
// from the read. Refuses while another process works on a run it wouldn't
|
|
386
|
+
// report.
|
|
381
387
|
function findActiveRunForInit(root, refuseUninterpretable = false) {
|
|
388
|
+
refuseNewRunAlongsideLiveRun(root);
|
|
382
389
|
const { active, uninterpretable } = (0, run_state_1.findActiveRun)(root);
|
|
383
390
|
if (uninterpretable.length > 0) {
|
|
384
|
-
const noun = uninterpretable.length === 1 ? 'directory' : 'directories';
|
|
385
|
-
// A directory name is whatever is on disk and a reason quotes what it
|
|
386
|
-
// found, so neither can be trusted to stay on the line it is put on.
|
|
387
|
-
// Sanitized here rather than left to the gateway: these same lines are
|
|
388
|
-
// joined into the throw below, which leaves through handleErrors.
|
|
389
|
-
const details = uninterpretable.map((u) => `${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${(0, text_1.singleLine)(u.dirName)}: ${(0, text_1.singleLine)(u.reason)}`);
|
|
390
391
|
if (!active || refuseUninterpretable) {
|
|
392
|
+
const noun = uninterpretable.length === 1 ? 'directory' : 'directories';
|
|
391
393
|
throw new Error([
|
|
392
394
|
`Whether a migrate run is still active could not be determined; running the plan could re-apply migrations an unfinished run already applied.`,
|
|
393
|
-
...
|
|
395
|
+
...uninterpretableDetails(uninterpretable),
|
|
394
396
|
`Fix or remove the listed ${noun}, then re-run the command.`,
|
|
395
397
|
].join('\n'));
|
|
396
398
|
}
|
|
399
|
+
warnIgnoredRunDirs(uninterpretable);
|
|
400
|
+
}
|
|
401
|
+
return active;
|
|
402
|
+
}
|
|
403
|
+
// A directory name is whatever is on disk and a reason quotes what it found,
|
|
404
|
+
// so neither can be trusted to stay on the line it is put on. Sanitized here
|
|
405
|
+
// rather than left to the gateway: these lines are also joined into a throw,
|
|
406
|
+
// which leaves through handleErrors.
|
|
407
|
+
function uninterpretableDetails(uninterpretable) {
|
|
408
|
+
return uninterpretable.map((u) => `${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${(0, text_1.singleLine)(u.dirName)}: ${(0, text_1.singleLine)(u.reason)}`);
|
|
409
|
+
}
|
|
410
|
+
function warnIgnoredRunDirs(uninterpretable) {
|
|
411
|
+
const noun = uninterpretable.length === 1 ? 'directory' : 'directories';
|
|
412
|
+
(0, agent_output_1.warnToAgent)({
|
|
413
|
+
title: `Ignoring ${uninterpretable.length} migrate run ${noun} that could not be read.`,
|
|
414
|
+
bodyLines: uninterpretableDetails(uninterpretable),
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Throws while another process works on a run that init wouldn't report: a
|
|
419
|
+
* `--run-migration` run, a run being started, or a run nx can't read. A new
|
|
420
|
+
* run would install and commit over its in-progress edits. An active
|
|
421
|
+
* `--run-migrations` run is reported instead, except to a `--run-migration`
|
|
422
|
+
* run, and records no process holds block nothing.
|
|
423
|
+
*/
|
|
424
|
+
function refuseNewRunAlongsideLiveRun(root, singleMigration = false) {
|
|
425
|
+
const live = (0, state_lock_1.findOtherLiveRuns)(root).find((run) => singleMigration || !run.state || (0, run_state_1.runKind)(run.state) !== 'active');
|
|
426
|
+
if (live) {
|
|
427
|
+
throw (0, state_lock_1.liveRunRefusal)(singleMigration
|
|
428
|
+
? 'Not running the migration'
|
|
429
|
+
: 'Not running the migrations', live);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* The refusals of prepareSingleMigrationRun alone, for the CLI to make before
|
|
434
|
+
* its install. Removes and warns about nothing.
|
|
435
|
+
*/
|
|
436
|
+
function checkRunsForSingleMigration(root) {
|
|
437
|
+
if (!(0, fs_1.existsSync)((0, run_state_1.migrateRunsDir)(root)))
|
|
438
|
+
return;
|
|
439
|
+
(0, state_lock_1.withRunCreationLock)(root, () => refuseNewRunAlongsideLiveRun(root, true));
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* The check every `--run-migration` run without a run id makes before it runs
|
|
443
|
+
* anything. Throws while another nx migrate process works on a run, removes
|
|
444
|
+
* `--run-migration` records no process holds, and warns about idle active
|
|
445
|
+
* runs, which do not record this migration.
|
|
446
|
+
*/
|
|
447
|
+
function prepareSingleMigrationRun(root) {
|
|
448
|
+
if (!(0, fs_1.existsSync)((0, run_state_1.migrateRunsDir)(root)))
|
|
449
|
+
return;
|
|
450
|
+
const idleRunIds = [];
|
|
451
|
+
const uninterpretable = [];
|
|
452
|
+
(0, state_lock_1.withRunCreationLock)(root, () => {
|
|
453
|
+
refuseNewRunAlongsideLiveRun(root, true);
|
|
454
|
+
// No other process holds what is left.
|
|
455
|
+
for (const run of (0, state_lock_1.listOtherRuns)(root)) {
|
|
456
|
+
if (run.starting)
|
|
457
|
+
continue;
|
|
458
|
+
if (run.state?.singleMigration === true) {
|
|
459
|
+
removeSingleMigrationRun(root, run.dirName);
|
|
460
|
+
}
|
|
461
|
+
else if (run.state) {
|
|
462
|
+
idleRunIds.push(run.dirName);
|
|
463
|
+
}
|
|
464
|
+
else if (!(run.readError instanceof run_state_1.NewerRunStateFormatError)) {
|
|
465
|
+
// A newer nx's run is that nx's to report.
|
|
466
|
+
uninterpretable.push({
|
|
467
|
+
dirName: run.dirName,
|
|
468
|
+
reason: (0, util_1.summarizeError)(run.readError),
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
if (uninterpretable.length > 0) {
|
|
474
|
+
warnIgnoredRunDirs(uninterpretable);
|
|
475
|
+
}
|
|
476
|
+
if (idleRunIds.length > 0) {
|
|
477
|
+
const runs = idleRunIds.map((id) => `'${(0, text_1.singleLine)(id)}'`).join(', ');
|
|
397
478
|
(0, agent_output_1.warnToAgent)({
|
|
398
|
-
title: `
|
|
399
|
-
bodyLines:
|
|
479
|
+
title: `This migration won't be recorded into the active migrate ${idleRunIds.length === 1 ? 'run' : 'runs'} ${runs}.`,
|
|
480
|
+
bodyLines: [
|
|
481
|
+
idleRunIds.length === 1
|
|
482
|
+
? 'Continuing that run may apply the migration again.'
|
|
483
|
+
: 'Continuing one of those runs may apply the migration again.',
|
|
484
|
+
],
|
|
400
485
|
});
|
|
401
486
|
}
|
|
402
|
-
return active;
|
|
403
487
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
function
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
488
|
+
/**
|
|
489
|
+
* Removes a `--run-migration` run's record. Call under the creation lock. Kept
|
|
490
|
+
* while another process still works on the run, such as a worker the agent
|
|
491
|
+
* left running: other runs refuse alongside it, and the next
|
|
492
|
+
* `--run-migration` removes it once none does. Otherwise best effort: what is
|
|
493
|
+
* left blocks nothing.
|
|
494
|
+
*/
|
|
495
|
+
function removeSingleMigrationRun(root, runId) {
|
|
496
|
+
const dir = (0, run_state_1.runDir)(root, runId);
|
|
497
|
+
const path = `${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runId}`;
|
|
498
|
+
try {
|
|
499
|
+
const deletion = deleteUnheldRunRecord(root, runId);
|
|
500
|
+
if (typeof deletion === 'object') {
|
|
501
|
+
(0, state_lock_1.releaseRunActivity)(dir);
|
|
502
|
+
(0, agent_output_1.warnToAgent)({
|
|
503
|
+
title: deletion.holders === 'unknown'
|
|
504
|
+
? `Kept ${path}: nx cannot tell whether another nx migrate process is still working on it. Make sure none is, then remove it.`
|
|
505
|
+
: `Kept ${path}: ${(0, state_lock_1.describeHolders)(deletion.holders)}. Other nx migrate runs refuse until it ends, and the next --run-migration removes it.`,
|
|
506
|
+
});
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
(0, fs_1.rmSync)(dir, { recursive: true, force: true });
|
|
510
|
+
}
|
|
511
|
+
catch (e) {
|
|
512
|
+
(0, agent_output_1.warnToAgent)({
|
|
513
|
+
title: `Could not remove ${path}: ${(0, util_1.summarizeError)(e)}. It blocks nothing; remove it when convenient.`,
|
|
514
|
+
});
|
|
421
515
|
}
|
|
422
516
|
}
|
|
423
517
|
// The report for an init that found a run already active. On the agent path
|
|
@@ -463,7 +557,7 @@ function refuseUndeletableRun(root, runId, state) {
|
|
|
463
557
|
throw new Error(`Not deleting migrate run '${runId}': without a native file lock nx cannot tell whether another nx migrate process is acting on it. Make sure none is, remove ${types_1.MIGRATE_RUNS_RELATIVE_DIR}/${runId}, then re-run the command.`);
|
|
464
558
|
}
|
|
465
559
|
const holders = (0, state_lock_1.liveRunActivityPids)((0, run_state_1.runDir)(root, runId));
|
|
466
|
-
if (
|
|
560
|
+
if ((0, state_lock_1.isHeld)(holders)) {
|
|
467
561
|
throw (0, state_lock_1.heldRunError)('deleting', runId, holders);
|
|
468
562
|
}
|
|
469
563
|
const workers = (0, existing_run_report_1.liveWorkers)(state);
|
|
@@ -479,19 +573,36 @@ function refuseUndeletableRun(root, runId, state) {
|
|
|
479
573
|
function noActiveRunToReplace(runId) {
|
|
480
574
|
return `Not starting fresh: ${runId === undefined ? 'no migrate run' : `no migrate run '${runId}'`} is active, so there is nothing to replace. To start a run, re-run the command without --start-fresh and --run-id.`;
|
|
481
575
|
}
|
|
482
|
-
//
|
|
483
|
-
//
|
|
484
|
-
// state: the early pass predates the prompt. False when already gone.
|
|
576
|
+
// The refusals run again on fresh state: the early pass predates the prompt.
|
|
577
|
+
// False when already gone.
|
|
485
578
|
function deleteRunRecord(root, runId) {
|
|
579
|
+
const deletion = deleteUnheldRunRecord(root, runId, (state) => refuseUndeletableRun(root, runId, state));
|
|
580
|
+
if (deletion === 'deleted')
|
|
581
|
+
return true;
|
|
582
|
+
if (deletion === 'gone')
|
|
583
|
+
return false;
|
|
584
|
+
throw (0, state_lock_1.heldRunError)('deleting', runId, deletion.holders);
|
|
585
|
+
}
|
|
586
|
+
/**
|
|
587
|
+
* Removes run.json unless another process holds the run, and returns its
|
|
588
|
+
* holders instead. Call under the creation lock, which every claim takes, so
|
|
589
|
+
* no process starts holding the run between the check and the removal. The
|
|
590
|
+
* state lock keeps a reconcile or worker from starting against a directory
|
|
591
|
+
* about to disappear. `refuse` sees the state read under it.
|
|
592
|
+
*/
|
|
593
|
+
function deleteUnheldRunRecord(root, runId, refuse) {
|
|
486
594
|
const dir = (0, run_state_1.runDir)(root, runId);
|
|
487
595
|
return (0, state_lock_1.withRunStateLock)(dir, () => {
|
|
488
596
|
if (!(0, run_state_1.hasRunState)(dir))
|
|
489
|
-
return
|
|
490
|
-
|
|
491
|
-
|
|
597
|
+
return 'gone';
|
|
598
|
+
refuse?.((0, run_state_1.readRunState)(dir));
|
|
599
|
+
const holders = (0, state_lock_1.liveRunActivityPids)(dir);
|
|
600
|
+
if ((0, state_lock_1.isHeld)(holders))
|
|
601
|
+
return { holders };
|
|
602
|
+
// The hold's lock file is inside the directory removed afterwards.
|
|
492
603
|
(0, state_lock_1.releaseRunActivity)(dir);
|
|
493
604
|
(0, fs_1.rmSync)((0, path_1.join)(dir, run_state_1.RUN_STATE_FILE_NAME), { force: true });
|
|
494
|
-
return
|
|
605
|
+
return 'deleted';
|
|
495
606
|
});
|
|
496
607
|
}
|
|
497
608
|
// The rest of a deleted run's directory, removed outside the locks and best
|
|
@@ -624,7 +735,8 @@ function finishInit(root, dir, runId, state, origin, emitAgentInstructions,
|
|
|
624
735
|
// which must fail before its git and state side effects).
|
|
625
736
|
runbook) {
|
|
626
737
|
let current = state;
|
|
627
|
-
if (
|
|
738
|
+
if (reportsOrchestratorAnalytics(current) &&
|
|
739
|
+
!current.analytics.startEmitted) {
|
|
628
740
|
// Claim the watermark on the fresh state first: of two concurrent inits
|
|
629
741
|
// exactly one flips it, and only that one reports.
|
|
630
742
|
let claimed = false;
|
|
@@ -646,7 +758,7 @@ runbook) {
|
|
|
646
758
|
});
|
|
647
759
|
}
|
|
648
760
|
}
|
|
649
|
-
if (origin === 'resumed') {
|
|
761
|
+
if (origin === 'resumed' && reportsOrchestratorAnalytics(current)) {
|
|
650
762
|
(0, migrate_analytics_1.reportMigrateOrchestratorResume)((0, state_machine_1.runTallies)(current));
|
|
651
763
|
}
|
|
652
764
|
const content = runbook ?? ensureRunbook(root, dir, runId, current);
|
|
@@ -752,6 +864,7 @@ function runbookContext(root, runId, state) {
|
|
|
752
864
|
// The pass guidance follows the plan: an opted-out run, or one recorded
|
|
753
865
|
// before the pass existed, has no pass step to dispense.
|
|
754
866
|
finalValidation: state.steps.some((s) => s.kind === 'final-validation'),
|
|
867
|
+
singleMigration: state.singleMigration === true,
|
|
755
868
|
};
|
|
756
869
|
}
|
|
757
870
|
// Only the newest recorded commit is checked, so the warning stops on its own
|
|
@@ -818,7 +931,7 @@ async function runOrchestratorReconcile(input) {
|
|
|
818
931
|
try {
|
|
819
932
|
const result = await applyReconcileStepAction(root, dir, state, stepAction, scope);
|
|
820
933
|
if (result.kind === 'error') {
|
|
821
|
-
emitError(root, runId, result.reason);
|
|
934
|
+
emitError(root, runId, state, result.reason);
|
|
822
935
|
return; // no transition was written
|
|
823
936
|
}
|
|
824
937
|
const target = result.targetStep;
|
|
@@ -830,10 +943,10 @@ async function runOrchestratorReconcile(input) {
|
|
|
830
943
|
!result.resetTree) {
|
|
831
944
|
const outcome = await (0, broker_1.giveUpStepTree)(root, dir, target, state.skipInstall === true, reconcileCommand(root, runId), scope);
|
|
832
945
|
if (outcome.kind === 'refused') {
|
|
833
|
-
emitError(root, runId, outcome.reason);
|
|
946
|
+
emitError(root, runId, state, outcome.reason);
|
|
834
947
|
return;
|
|
835
948
|
}
|
|
836
|
-
(0, give_up_1.warnAboutGiveUp)(target, outcome);
|
|
949
|
+
(0, give_up_1.warnAboutGiveUp)(target, outcome, (0, util_1.commitFailureRecovery)(state));
|
|
837
950
|
if (target.installFailed === true)
|
|
838
951
|
warnInstallLeftToUser(root, target);
|
|
839
952
|
// Settled already; the dispense refuses a tree still held.
|
|
@@ -916,7 +1029,7 @@ async function runOrchestratorReconcile(input) {
|
|
|
916
1029
|
: next;
|
|
917
1030
|
});
|
|
918
1031
|
if (freshRejection) {
|
|
919
|
-
emitError(root, runId, entry?.kind === 'landed' && entry.sha
|
|
1032
|
+
emitError(root, runId, state, entry?.kind === 'landed' && entry.sha
|
|
920
1033
|
? `${freshRejection} Note: this action's commit ${entry.sha} had already landed and stays in history; resolve the step against the tree as it stands now.`
|
|
921
1034
|
: freshRejection);
|
|
922
1035
|
return;
|
|
@@ -1432,9 +1545,10 @@ async function commitForStep(root, dir, state, step, scope, commitAs) {
|
|
|
1432
1545
|
const name = (0, state_machine_1.commitNameForStep)(step);
|
|
1433
1546
|
const absorbedStepIds = (0, state_machine_1.uncoveredFailedStepIds)(state).filter((id) => id !== step.id);
|
|
1434
1547
|
const skipInstall = state.skipInstall === true;
|
|
1548
|
+
const recovery = (0, util_1.commitFailureRecovery)(state);
|
|
1435
1549
|
let commit;
|
|
1436
1550
|
try {
|
|
1437
|
-
commit = await (0, broker_1.commitStepTree)(dir, step, absorbedStepIds, () => (0, migrate_commits_1.commitMigrationIfRequested)(root, { name }, true, state.commitPrefix, () => (0, util_1.installDepsChangedSinceDispense)(root, dir, step, skipInstall, reconcileCommand(root, state.runId)), (0, state_machine_1.stepsToPendingMigrations)(state, absorbedStepIds)), scope, commitAs);
|
|
1551
|
+
commit = await (0, broker_1.commitStepTree)(dir, step, absorbedStepIds, () => (0, migrate_commits_1.commitMigrationIfRequested)(root, { name }, true, state.commitPrefix, () => (0, util_1.installDepsChangedSinceDispense)(root, dir, step, skipInstall, reconcileCommand(root, state.runId)), (0, state_machine_1.stepsToPendingMigrations)(state, absorbedStepIds), recovery), scope, commitAs);
|
|
1438
1552
|
}
|
|
1439
1553
|
catch (e) {
|
|
1440
1554
|
// Nothing to record: the step moved on, another process holds the tree, or
|
|
@@ -1448,14 +1562,14 @@ async function commitForStep(root, dir, state, step, scope, commitAs) {
|
|
|
1448
1562
|
// reports through result.status. The debt cannot stand in for the install
|
|
1449
1563
|
// failure, since a later commit absorbing this diff clears the debt while
|
|
1450
1564
|
// the dependencies are still missing.
|
|
1451
|
-
(0, util_1.warnCommitFailed)(name, e);
|
|
1565
|
+
(0, util_1.warnCommitFailed)(name, recovery, e);
|
|
1452
1566
|
return {
|
|
1453
1567
|
entry: { kind: 'failed', stepIds: [step.id] },
|
|
1454
1568
|
installFailed: true,
|
|
1455
1569
|
};
|
|
1456
1570
|
}
|
|
1457
1571
|
if (commit.result.status === 'failed') {
|
|
1458
|
-
(0, util_1.warnCommitFailed)(name);
|
|
1572
|
+
(0, util_1.warnCommitFailed)(name, recovery);
|
|
1459
1573
|
}
|
|
1460
1574
|
return {
|
|
1461
1575
|
entry: (0, state_machine_1.commitResultToLedgerEntry)(commit.result, step.id, commit.absorbedStepIds),
|
|
@@ -1577,11 +1691,7 @@ function dispenseNextStep(root, dir, runId, state, step, noProgress) {
|
|
|
1577
1691
|
// Read the pre-step baselines (git and package.json reads) before the
|
|
1578
1692
|
// lock; the dispense transition and the baselines then apply to the fresh
|
|
1579
1693
|
// state in one write.
|
|
1580
|
-
const baselines =
|
|
1581
|
-
gitRefBefore: (0, git_utils_1.getLatestCommitSha)(root) ?? undefined,
|
|
1582
|
-
treeCleanAtDispense: (0, git_utils_1.getWorkingTreeStatus)(root) === 'clean',
|
|
1583
|
-
depsHashAtDispense: (0, util_1.depsHash)(root),
|
|
1584
|
-
};
|
|
1694
|
+
const baselines = readDispenseBaselines(root);
|
|
1585
1695
|
let advancedElsewhere = false;
|
|
1586
1696
|
let held;
|
|
1587
1697
|
const current = (0, state_lock_1.updateRunState)(dir, (fresh) => {
|
|
@@ -1612,10 +1722,12 @@ function dispenseNextStep(root, dir, runId, state, step, noProgress) {
|
|
|
1612
1722
|
return;
|
|
1613
1723
|
}
|
|
1614
1724
|
const dispensed = current.steps.find((s) => s.id === step.id);
|
|
1615
|
-
(
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1725
|
+
if (reportsOrchestratorAnalytics(current)) {
|
|
1726
|
+
(0, migrate_analytics_1.reportMigrateOrchestratorStepDispensed)({
|
|
1727
|
+
attempt: dispensed.attempt,
|
|
1728
|
+
ordinal: (0, state_machine_1.runTallies)(current).dispenseCount,
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1619
1731
|
switch (dispensed.kind) {
|
|
1620
1732
|
case 'migration':
|
|
1621
1733
|
emitNextStep(root, runId, current, dispensed, noProgress);
|
|
@@ -1629,6 +1741,25 @@ function dispenseNextStep(root, dir, runId, state, step, noProgress) {
|
|
|
1629
1741
|
}
|
|
1630
1742
|
}
|
|
1631
1743
|
}
|
|
1744
|
+
function readDispenseBaselines(root) {
|
|
1745
|
+
return {
|
|
1746
|
+
gitRefBefore: (0, git_utils_1.getLatestCommitSha)(root) ?? undefined,
|
|
1747
|
+
treeCleanAtDispense: (0, git_utils_1.getWorkingTreeStatus)(root) === 'clean',
|
|
1748
|
+
depsHashAtDispense: (0, util_1.depsHash)(root),
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
/**
|
|
1752
|
+
* Dispenses a `--run-migration` run's step without a response: the parent
|
|
1753
|
+
* runs the step's first attempt itself, and an agent it starts afterwards
|
|
1754
|
+
* gets the step from the "next" command.
|
|
1755
|
+
*/
|
|
1756
|
+
function dispenseSingleMigrationStep(root, runId) {
|
|
1757
|
+
const baselines = readDispenseBaselines(root);
|
|
1758
|
+
(0, state_lock_1.updateRunState)((0, run_state_1.runDir)(root, runId), (fresh) => {
|
|
1759
|
+
const [step] = fresh.steps;
|
|
1760
|
+
return setDispenseBaselines(applyEventOrThrow(fresh, dispenseEvent(step)), step.id, baselines);
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1632
1763
|
function dispenseEvent(step) {
|
|
1633
1764
|
switch (step.kind) {
|
|
1634
1765
|
case 'migration':
|
|
@@ -1852,7 +1983,9 @@ function lastCoveringLandedEntry(state, step) {
|
|
|
1852
1983
|
// reset, a partial commit, or the tree left as it stands.
|
|
1853
1984
|
function unresolvedOptionLine(root, runId, state, step, resetTree) {
|
|
1854
1985
|
const command = reconcileCommand(root, runId, 'unresolved');
|
|
1855
|
-
const recorded =
|
|
1986
|
+
const recorded = state.singleMigration === true
|
|
1987
|
+
? `The failure is listed in the completion report.`
|
|
1988
|
+
: `The failure is recorded as a run issue and listed in the completion report.`;
|
|
1856
1989
|
const noun = (0, state_machine_1.stepNoun)(step);
|
|
1857
1990
|
if (resetTree) {
|
|
1858
1991
|
return ` unresolved: give up on this ${noun}, resetting the tree to ${step.gitRefBefore ?? 'the pre-migration ref'} (discarding what the failed attempt left, ${types_1.MIGRATE_RUNS_RELATIVE_DIR} kept), then run: ${command}. ${recorded}`;
|
|
@@ -2116,9 +2249,8 @@ function planPromptPath(dir, state, migrationId) {
|
|
|
2116
2249
|
}
|
|
2117
2250
|
return null;
|
|
2118
2251
|
}
|
|
2119
|
-
//
|
|
2120
|
-
//
|
|
2121
|
-
// refused to consume it, and only this response can tell the agent why.
|
|
2252
|
+
// A readable handoff whose issue report is invalid is a rejection too: the
|
|
2253
|
+
// fold refused to consume it, and only this response can tell the agent why.
|
|
2122
2254
|
function describeRejectedHandoff(dir, state, step) {
|
|
2123
2255
|
const result = readStepHandoff(dir, step.id);
|
|
2124
2256
|
const followUp = 'Rewrite the handoff file, then run the "next" command.';
|
|
@@ -2161,7 +2293,7 @@ function describeRejectedHandoff(dir, state, step) {
|
|
|
2161
2293
|
// to the request, and it carries the reconcile command to run next. A non-zero
|
|
2162
2294
|
// exit would tell the driving agent that reconcile itself crashed, and it
|
|
2163
2295
|
// would stop reading for the correction it is being handed.
|
|
2164
|
-
function emitError(root, runId, reason) {
|
|
2296
|
+
function emitError(root, runId, state, reason) {
|
|
2165
2297
|
// A rejected action is an active response like any dispense, so it carries
|
|
2166
2298
|
// the runbook footer: the master receiving it may have just lost its
|
|
2167
2299
|
// context. One sanitized array feeds both outputs, as in emit().
|
|
@@ -2174,7 +2306,9 @@ function emitError(root, runId, reason) {
|
|
|
2174
2306
|
next: reconcileCommand(root, runId),
|
|
2175
2307
|
instructions: lines.join('\n'),
|
|
2176
2308
|
});
|
|
2177
|
-
(
|
|
2309
|
+
if (reportsOrchestratorAnalytics(state)) {
|
|
2310
|
+
(0, migrate_analytics_1.reportMigrateOrchestratorDispense)({ action: 'error', attempt: 0 });
|
|
2311
|
+
}
|
|
2178
2312
|
}
|
|
2179
2313
|
/**
|
|
2180
2314
|
* What a completed run leaves behind for whoever reads its summary, one line
|
|
@@ -2234,7 +2368,7 @@ function completeRun(root, dir, runId, state) {
|
|
|
2234
2368
|
};
|
|
2235
2369
|
});
|
|
2236
2370
|
}
|
|
2237
|
-
if (shouldEmit) {
|
|
2371
|
+
if (shouldEmit && reportsOrchestratorAnalytics(current)) {
|
|
2238
2372
|
(0, migrate_analytics_1.reportMigrateOrchestratorComplete)((0, state_machine_1.runTallies)(current));
|
|
2239
2373
|
}
|
|
2240
2374
|
const warnings = completionWarnings(root, runId, current);
|
|
@@ -2273,11 +2407,18 @@ function emit(root, runId, state, step, action, payload, noProgress) {
|
|
|
2273
2407
|
...rest,
|
|
2274
2408
|
...(lines ? { instructions: lines.join('\n') } : {}),
|
|
2275
2409
|
});
|
|
2276
|
-
(
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2410
|
+
if (reportsOrchestratorAnalytics(state)) {
|
|
2411
|
+
(0, migrate_analytics_1.reportMigrateOrchestratorDispense)({
|
|
2412
|
+
action: effectiveAction,
|
|
2413
|
+
attempt: step.attempt,
|
|
2414
|
+
ordinal: (0, state_machine_1.runTallies)(state).dispenseCount,
|
|
2415
|
+
});
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
// A `--run-migration` run reports its own events, so only `--run-migrations`
|
|
2419
|
+
// runs report orchestrator events.
|
|
2420
|
+
function reportsOrchestratorAnalytics(state) {
|
|
2421
|
+
return state.singleMigration !== true;
|
|
2281
2422
|
}
|
|
2282
2423
|
function noProgressLines(step, streak) {
|
|
2283
2424
|
let subject;
|
|
@@ -141,8 +141,10 @@ export interface MigrateRunState {
|
|
|
141
141
|
noProgress?: MigrateRunNoProgress;
|
|
142
142
|
checkpointFailed?: boolean;
|
|
143
143
|
treeOperation?: MigrateTreeOperation;
|
|
144
|
+
singleMigration?: boolean;
|
|
144
145
|
analytics: MigrateRunAnalytics;
|
|
145
146
|
}
|
|
147
|
+
export declare function runKind(state: MigrateRunState): 'single' | 'active' | 'finished';
|
|
146
148
|
export declare const TREE_OPERATION_KINDS: readonly ['commit', 'install', 'fold-install', 'action-install', 'reset', 'give-up', 'checkpoint'];
|
|
147
149
|
export type MigrateTreeOperationKind = (typeof TREE_OPERATION_KINDS)[number];
|
|
148
150
|
export interface MigrateTreeOperation {
|
|
@@ -200,7 +202,8 @@ export interface UninterpretableRunDir {
|
|
|
200
202
|
*
|
|
201
203
|
* A dir that reads cleanly as a finished run is skipped whatever its name is:
|
|
202
204
|
* it competes with nothing, and reporting it would block every future run
|
|
203
|
-
* with no way for retention to ever clear it.
|
|
205
|
+
* with no way for retention to ever clear it. A `--run-migration` run's record
|
|
206
|
+
* is skipped too: nothing continues it, and a leftover must not block a run.
|
|
204
207
|
*
|
|
205
208
|
* Throws {@link NewerRunStateFormatError} when any run dir holds a
|
|
206
209
|
* newer-format run.json: whether that run is active can't be determined
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NewerRunStateFormatError = exports.TREE_OPERATION_KINDS = exports.MIGRATE_ISSUE_DISPOSITIONS = exports.TERMINAL_STEP_STATUSES = exports.ISSUE_ID = exports.SHELL_SAFE_VALUE = exports.RUN_STATE_FILE_NAME = exports.CURRENT_RUN_STATE_FORMAT_VERSION = void 0;
|
|
4
4
|
exports.migrationIdProblems = migrationIdProblems;
|
|
5
5
|
exports.issueFingerprint = issueFingerprint;
|
|
6
|
+
exports.runKind = runKind;
|
|
6
7
|
exports.migrateRunsDir = migrateRunsDir;
|
|
7
8
|
exports.runDir = runDir;
|
|
8
9
|
exports.runHandoffsDir = runHandoffsDir;
|
|
@@ -138,6 +139,21 @@ exports.MIGRATE_ISSUE_DISPOSITIONS = [
|
|
|
138
139
|
'resolved',
|
|
139
140
|
'deferred-final',
|
|
140
141
|
];
|
|
142
|
+
// A `--run-migration` record is 'single' whatever its status.
|
|
143
|
+
function runKind(state) {
|
|
144
|
+
if (state.singleMigration === true)
|
|
145
|
+
return 'single';
|
|
146
|
+
switch (state.status) {
|
|
147
|
+
case 'active':
|
|
148
|
+
return 'active';
|
|
149
|
+
case 'completed':
|
|
150
|
+
return 'finished';
|
|
151
|
+
default: {
|
|
152
|
+
const unhandled = state.status;
|
|
153
|
+
throw new Error(`Unhandled migrate run status: ${unhandled}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
141
157
|
exports.TREE_OPERATION_KINDS = [
|
|
142
158
|
'commit',
|
|
143
159
|
'install',
|
|
@@ -430,6 +446,7 @@ function hasValidRunStateShape(parsed) {
|
|
|
430
446
|
isOptionalBoolean(parsed.checkpointFailed) &&
|
|
431
447
|
isOptionalBoolean(parsed.skipInstall) &&
|
|
432
448
|
isOptionalBoolean(parsed.validate) &&
|
|
449
|
+
isOptionalBoolean(parsed.singleMigration) &&
|
|
433
450
|
isOptionalSha(parsed.gitRefAtInit) &&
|
|
434
451
|
isOptionalMatching(RUNBOOK_NAME, parsed.runbookPath) &&
|
|
435
452
|
isOptionalString(parsed.branch) &&
|
|
@@ -587,7 +604,8 @@ function readRunDirState(candidateDir) {
|
|
|
587
604
|
*
|
|
588
605
|
* A dir that reads cleanly as a finished run is skipped whatever its name is:
|
|
589
606
|
* it competes with nothing, and reporting it would block every future run
|
|
590
|
-
* with no way for retention to ever clear it.
|
|
607
|
+
* with no way for retention to ever clear it. A `--run-migration` run's record
|
|
608
|
+
* is skipped too: nothing continues it, and a leftover must not block a run.
|
|
591
609
|
*
|
|
592
610
|
* Throws {@link NewerRunStateFormatError} when any run dir holds a
|
|
593
611
|
* newer-format run.json: whether that run is active can't be determined
|
|
@@ -619,7 +637,7 @@ function findActiveRun(root) {
|
|
|
619
637
|
});
|
|
620
638
|
continue;
|
|
621
639
|
}
|
|
622
|
-
if (state
|
|
640
|
+
if (runKind(state) !== 'active')
|
|
623
641
|
continue;
|
|
624
642
|
// Run ids are joined into paths and interpolated into dispensed commands,
|
|
625
643
|
// so a dir whose name fails the gate is never trusted as a resumable run.
|