@revoengine/cli 1.0.26 → 1.0.28

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/README.md CHANGED
@@ -444,7 +444,7 @@ revo schedules push --all --yes --force
444
444
 
445
445
  `--force` permits adopting a missing Schedule baseline or overwriting reviewed target drift. It also approves a reviewed transition between Job Template and Materialized View targets under one Schedule Stable Key. Materialized View refresh Schedules are included with the other Schedules and identify their Database View by Stable Key and refresh mode, never by a source UUID. User-managed `JOB_TEMPLATE` and `PLATFORM_OPERATION` schedules of kind `refresh_materialized_view` are supported. Other platform operations, `AGENT`, and system-managed Schedules are excluded; `--strict` treats exclusions as incomplete coverage.
446
446
 
447
- Pull initializes each Schedule's editable activation candidate from the source. A new target Schedule is created inactive, while a configuration update preserves its target activation state. `activationCandidate` records the desired active state. Plans report activation-only differences as `activation-drift`, including without a target lock baseline; repository plans mark them as pending changes, and strict plans or deployment verification do not report convergence until they are aligned. `schedules push --all --yes --activate` aligns verified new, updated and otherwise unchanged Schedules with manifest activation intent, including disabling them. Failed configuration preflight skips activation; changed definitions or dependencies block activation. Interactive activation asks for a second confirmation. Repository `deploy` and named `migrate` leave this activation step to the dedicated command.
447
+ Pull initializes each Schedule's editable activation candidate from the source. A new target Schedule is created inactive, while a configuration update preserves its target activation state. `activationCandidate` records the desired active state. Plans report activation-only differences as `activation-drift`, including without a target lock baseline. Repository `plan/deploy` without `--activate` verifies definition convergence and preserves target activation; activation-only drift remains informational and does not fail a strict plan or final verification. With `--activate`, activation differences require changes and are aligned only after verified writes and pruning. Plan and deploy must use the same activation policy. `schedules push --all --yes --activate` also aligns verified new, updated and otherwise unchanged Schedules, including disabling them. Failed configuration preflight skips activation; changed definitions or dependencies block activation. Interactive activation asks for a second confirmation. Named `migrate` retains its separate activation-convergence checks.
448
448
 
449
449
  Use `--project` to select a saved project explicitly (`--env` remains a compatible alias):
450
450
 
@@ -508,7 +508,7 @@ Resource plans support `--json` for automation and generally support `--strict`
508
508
  - `--force` approves only explicitly supported risky or drifted operations; it is not a universal bypass.
509
509
  - Writes resolve the target UUID and version immediately before mutation and verify the portable result afterward.
510
510
  - Stable Keys cross environments; source UUIDs, versions, members, users, ACLs, and other target-local identities do not.
511
- - New Schedules and Events are created inactive; ordinary updates preserve target activation. Dedicated `schedules push --all --yes --activate` aligns manifest activation intent for verified new, updated and otherwise unchanged Schedules, including disabling them. Activation drift is shown by plans and prevents repository strict-plan/deployment convergence until aligned. `events push --all --yes --activate` aligns verified Events with manifest activation intent, including disabling them; configuration failures skip Event activation. Interactive activation requires an additional confirmation. `deploy` and `migrate` do not run this activation phase.
511
+ - New Schedules and Events are created inactive; ordinary updates preserve target activation. Dedicated `schedules push --all --yes --activate` aligns manifest activation intent for verified new, updated and otherwise unchanged Schedules, including disabling them. Activation drift is shown by plans and affects repository convergence only with --activate. `events push --all --yes --activate` aligns verified Events with manifest activation intent, including disabling them; configuration failures skip Event activation. Interactive activation requires an additional confirmation. `deploy --activate` runs this phase after verified writes and pruning; named `migrate` leaves activation to dedicated commands.
512
512
  - Groups and Role Groups are intentionally late phases because they can affect ownership and access.
513
513
  - Lock data is stored in `.revoengine/revo.lock.json`; API tokens are never persisted in the project.
514
514
 
@@ -643,8 +643,33 @@ Portable comparison includes ordinary Component metadata and full structured Dat
643
643
 
644
644
  Endpoint and Job Template pins use the API content identity `v1:sha256:<64 lowercase hex characters>`, independently of the configuration hash. Latest bindings explicitly clear old digest pins. Endpoint `pinnedDigest` fingerprints from older CLI versions are upgraded in memory only when their exact local Component source proves the content identity; otherwise re-pull the source definition. Numeric-only Job Template pins remain explicitly unsupported; use a canonical digest pin instead.
645
645
 
646
- Schedule and Event activation differences remain pending changes even if their configuration matches. Ordinary deployment preserves activation; use the existing explicit `schedules push --all --yes --activate` or `events push --all --yes --activate` step to align it. Strict plans and final verification cannot report convergence until activation matches. Deprecated Schedule `targetVersion` is reported diagnostically; the backend does not use it to select a Job Template revision.
646
+ Repository `plan/deploy` without `--activate` preserves existing Event and Schedule activation and creates new definitions inactive. Differences from manifest activation remain visible as `activation-drift`, but do not prevent definition convergence. With `--activate`, strict plans and final verification require activation to match the manifest. Reviewed deployment still fences live target activation and rejects changes after planning, in either mode. Named migration and dedicated family plans retain their activation-convergence checks. Deprecated Schedule `targetVersion` is reported diagnostically; the backend does not use it to select a Job Template revision.
647
647
 
648
648
  `CUSTOM_NODEJS` deployment verifies runtime availability and the active desired revision after source readback. Automatic deployment waits up to two minutes for readiness; failed attempts, manual activation requirements and unavailable/pending revisions fail verification without adopting a deployment baseline. Re-run after the runtime is ready. Named `env diff/apply` also reports unavailable unchanged custom runtimes and returns an error on unverified writes. Definition synchronization does not invoke provider/plugin tests; component dependencies and their pinned revisions are checked with read-only API calls, including unchanged definitions.
649
649
 
650
650
  Execution options are compared without hiding runtime differences: missing Job Template memory means 256 MB; explicit 128 MB remains distinct. An empty `options.input` overrides legacy `inputs`. Endpoint `memory: null` remains distinct from 32 MB. If the backend substitutes a different value, readback verification fails rather than recording false convergence.
651
+
652
+ ## Deployment digests and local lock updates
653
+
654
+ `revo plan update [--json]` computes the tracked workspace's portable `sourceDigest`
655
+ index by Stable Key in `.revoengine/revo.lock.json` without authentication or remote
656
+ reads. Component entries also contain the canonical backend `contentDigest`.
657
+ Offline plan update and deployment refresh this index from actual source files;
658
+ the stored index is not trusted in place of recomputation. Existing target baselines
659
+ remain available for three-way diagnostics and ordinary resource push protection.
660
+ A repository `plan/deploy --prune` reconciles reviewed Git source with the current
661
+ target without requiring a pull merely to update historical versions or hashes.
662
+
663
+ The CLI uses `GET /api/v1/component/sync-manifests` where supported. A matching
664
+ aggregate digest alone is insufficient: it verifies every child digest before
665
+ reusing local code, and compares the live configuration and descriptions separately.
666
+ Changed, missing or invalid digests fall back to full source reads. Unsupported
667
+ older APIs (404/405 or the legacy component-ID route validation response) keep the existing inventory path; authentication, permission
668
+ and transport failures are never treated as compatibility fallback.
669
+
670
+ Within one planning pass, duplicate inventory/detail reads share an isolated
671
+ snapshot. A subsequent pass starts fresh; mutations and readback never use that
672
+ cache. Pruning still checks retained and out-of-scope consumers. Human output reports
673
+ phase start/end/duration and a heartbeat for slow phases; JSON output remains clean.
674
+ Stable Keys match identity across instances. Current versions and mutation-review
675
+ tokens remain necessary to reject changes made after plan approval.
package/dist/src/cli.js CHANGED
@@ -198,7 +198,7 @@ async function runMain(args, argv) {
198
198
  const command = args._[0];
199
199
  const noPositionals = args._.length === 0;
200
200
  if (command === 'version' || ((args.version !== undefined || args.V !== undefined) && noPositionals)) {
201
- print(args.json ? { version: packageVersion, capabilities: { workspacePrune: true, reviewedPrunePlan: true, reviewedDeploymentPlan: true, componentMutationReview: true, reviewedAutomationActivation: true } } : packageVersion);
201
+ print(args.json ? { version: packageVersion, capabilities: { workspacePrune: true, reviewedPrunePlan: true, reviewedDeploymentPlan: true, componentMutationReview: true, reviewedAutomationActivation: true, preservedAutomationActivation: true } } : packageVersion);
202
202
  return;
203
203
  }
204
204
  if (command === 'info' || ((args.i === true || args.info === true) && noPositionals)) {
@@ -368,6 +368,7 @@ export declare class RevoClient {
368
368
  private readonly maxRetries;
369
369
  private retryDelayMs;
370
370
  private requestQueue;
371
+ private componentSyncManifestsSupported?;
371
372
  constructor(options?: ClientOptions);
372
373
  get authHeader(): string;
373
374
  get authValidationKey(): string;
@@ -443,6 +444,10 @@ export declare class RevoClient {
443
444
  components: Record<string, unknown>[];
444
445
  discoveredTotal: number | null;
445
446
  }>;
447
+ listAllComponentSyncManifests(): Promise<{
448
+ components: Record<string, unknown>[];
449
+ discoveredTotal: number | null;
450
+ }>;
446
451
  getComponent(componentId: string, options?: Pick<RequestOptions, 'timeoutMs'>): Promise<unknown>;
447
452
  createComponent(body: unknown): Promise<unknown>;
448
453
  reviewComponent(componentId: string, body: unknown): Promise<unknown>;
@@ -411,6 +411,7 @@ export class RevoClient {
411
411
  maxRetries;
412
412
  retryDelayMs;
413
413
  requestQueue;
414
+ componentSyncManifestsSupported;
414
415
  constructor(options = {}) {
415
416
  const config = resolveRuntimeConfig(options);
416
417
  this.baseUrl = config.baseUrl;
@@ -1167,6 +1168,49 @@ export class RevoClient {
1167
1168
  }
1168
1169
  return { components, discoveredTotal };
1169
1170
  }
1171
+ async listAllComponentSyncManifests() {
1172
+ if (this.componentSyncManifestsSupported === false)
1173
+ return this.listAllComponents();
1174
+ const components = [];
1175
+ const seen = new Set();
1176
+ let afterComponentId = null;
1177
+ do {
1178
+ let page;
1179
+ try {
1180
+ page = await this.requestData('GET', '/api/v1/component/sync-manifests', {
1181
+ query: { take: 200, ...(afterComponentId ? { afterComponentId } : {}) },
1182
+ });
1183
+ }
1184
+ catch (error) {
1185
+ // Compatibility with already deployed APIs only. Permission/network errors
1186
+ // must not silently turn a failed read into a legacy inventory.
1187
+ const legacyIdRoute = error instanceof ApiError && error.status === 400
1188
+ && error.data !== null && typeof error.data === 'object' && 'message' in error.data
1189
+ && error.data.message === 'Provided "componentId" is not valid UUID.';
1190
+ if (components.length === 0 && error instanceof ApiError && ([404, 405].includes(error.status) || legacyIdRoute)) {
1191
+ this.componentSyncManifestsSupported = false;
1192
+ return this.listAllComponents();
1193
+ }
1194
+ throw error;
1195
+ }
1196
+ if (!Array.isArray(page?.data) || !(page.nextComponentId === null || typeof page.nextComponentId === 'string')) {
1197
+ throw new Error('Invalid component sync manifest page.');
1198
+ }
1199
+ for (const component of page.data) {
1200
+ const id = String(component.componentId || '');
1201
+ if (!id || seen.has(id))
1202
+ throw new Error('Repeated or missing component sync ID.');
1203
+ seen.add(id);
1204
+ components.push(component);
1205
+ }
1206
+ const next = page.nextComponentId;
1207
+ if (next !== null && (!page.data.length || next !== page.data.at(-1)?.componentId || next === afterComponentId)) {
1208
+ throw new Error('Invalid component sync pagination cursor.');
1209
+ }
1210
+ afterComponentId = next;
1211
+ } while (afterComponentId);
1212
+ return { components, discoveredTotal: components.length };
1213
+ }
1170
1214
  async getComponent(componentId, options = {}) {
1171
1215
  return this.requestData('GET', `/api/v1/component/${componentId}`, options);
1172
1216
  }
@@ -1,3 +1,4 @@
1
+ import { hydrateComponentManifest, listComponentManifests } from "../component-manifests.js";
1
2
  import { verifyComponentRuntime } from "../component-contract.js";
2
3
  import fs from 'node:fs';
3
4
  import path from 'node:path';
@@ -556,10 +557,13 @@ function componentPruneBlocker(localCatalog, remote) {
556
557
  async function buildRemoteComponentCatalog(context, identity, summaries) {
557
558
  const catalog = createComponentCatalog(identity);
558
559
  const source = summaries || (await fetchAllComponentSummaries(context)).components;
560
+ const local = buildLocalComponentCatalog(context.cwd, identity);
559
561
  const filtered = source.filter((summary) => Boolean(String(summary.componentId || summary.id || '')));
560
562
  const components = await mapWithConcurrency(filtered, async (summary) => {
561
563
  const componentId = String(summary.componentId || summary.id || '');
562
- return unwrapComponent(await context.client.getComponent(componentId));
564
+ const key = readComponentIdentityValue(summary, identity);
565
+ const hydrated = hydrateComponentManifest(summary, key ? local.byIdentity.get(key)?.component : undefined);
566
+ return hydrated || unwrapComponent(await context.client.getComponent(componentId, { timeoutMs: 30_000 }));
563
567
  });
564
568
  for (const component of components) {
565
569
  addCatalogEntry(catalog, {
@@ -1022,7 +1026,7 @@ async function pullSingleComponent(context, target, mode = { force: false, stale
1022
1026
  }
1023
1027
  async function fetchAllComponentSummaries(context) {
1024
1028
  try {
1025
- return await context.client.listAllComponents();
1029
+ return await listComponentManifests(context.client);
1026
1030
  }
1027
1031
  catch (error) {
1028
1032
  rethrowComponentAccessError(error, 'list');
@@ -1233,7 +1237,7 @@ async function pushSingleComponent(context, manifestPath, remoteCatalog) {
1233
1237
  if (typeTransitionBlocker) {
1234
1238
  throw new Error(`Cannot push ${targetPath}: ${typeTransitionBlocker}`);
1235
1239
  }
1236
- if (!readBoolFlag(context.args, ['force', 'f'])) {
1240
+ if (!context.componentReview && !readBoolFlag(context.args, ['force', 'f'])) {
1237
1241
  const lockEntry = getComponentLockEntry(readComponentLock(getProjectRoot(context.cwd)), identity, component, context.componentEnvironment);
1238
1242
  if (!lockEntry) {
1239
1243
  const remoteHash = componentSourceHash(remote, identity);
@@ -1,3 +1,4 @@
1
+ import { updateWorkspaceDigests } from "../workspace-digests.js";
1
2
  import fs from 'node:fs';
2
3
  import path from 'node:path';
3
4
  import { normalizeStableKeyValue } from "../resource-metadata.js";
@@ -127,6 +128,8 @@ function printMigrationPlan(context, plan) {
127
128
  context.println(`Diagnostics: ${plan.warnings.length} warning(s), ${plan.blockers.length} blocker(s).`);
128
129
  if (plan.policy.activateAutomations)
129
130
  context.println('Automation activation: align tracked Events and Schedules with repository active values after verified writes and pruning.');
131
+ else if (plan.from === 'workspace')
132
+ context.println('Automation activation: preserve target Event and Schedule active values; create new definitions inactive.');
130
133
  if (plan.sourcePull.mode === 'repository') {
131
134
  context.println('Source snapshot: repository workspace (no remote source pull).');
132
135
  }
@@ -405,6 +408,7 @@ async function handleMigrationRead(context, input, command) {
405
408
  const plan = await buildMigrationPlan({
406
409
  ...input,
407
410
  detailedDiff: true,
411
+ onProgress: readBoolFlag(context.args, ['json']) ? undefined : context.println,
408
412
  ...(command === 'diff' ? { allowDestructive: true } : {}),
409
413
  });
410
414
  if (command === 'diff') {
@@ -452,6 +456,19 @@ export async function handleDiffCommand(context) {
452
456
  await handleMigrationRead(context, await readWorkspaceDeploymentInput(context), 'diff');
453
457
  }
454
458
  export async function handlePlanCommand(context) {
459
+ if (context.args._[1] === 'update') {
460
+ if (Object.keys(context.args).some(key => !['_', 'json', 'project', 'update-notifier'].includes(key))) {
461
+ throw new Error('Offline plan update accepts --json and --project only; target/deployment flags require revo plan.');
462
+ }
463
+ const result = updateWorkspaceDigests(context.cwd);
464
+ if (readBoolFlag(context.args, ['json']))
465
+ context.print(result);
466
+ else
467
+ context.println(`Local digest index: ${result.resourcesIndexed} resources; ${result.changed ? 'updated' : 'unchanged'}. No remote reads or writes.`);
468
+ return;
469
+ }
470
+ if (context.args._[1])
471
+ throw new Error('Unknown plan command; use revo plan or revo plan update.');
455
472
  if (readBoolFlag(context.args, ['changed']) || readFlag(context.args, ['base'])) {
456
473
  throw new Error('Repository plan evaluates all tracked resources and dependencies; --changed and --base are supported only by component plan.');
457
474
  }
@@ -563,7 +580,8 @@ export async function handleDeployCommand(context) {
563
580
  if (readBoolFlag(context.args, ['changed']) || readFlag(context.args, ['base']) || readValues(context.args, ['resources', 'resource']).length > 0) {
564
581
  throw new Error('Repository deployment evaluates all tracked resources; select resources in .revoengine/revo.json.');
565
582
  }
566
- const input = { ...await readWorkspaceDeploymentInput(context), detailedDiff: true };
583
+ const input = { ...await readWorkspaceDeploymentInput(context), detailedDiff: true,
584
+ onProgress: readBoolFlag(context.args, ['json']) ? undefined : context.println };
567
585
  const preview = await buildMigrationPlan(input);
568
586
  const reviewedFile = readFlag(context.args, ['reviewed-plan']);
569
587
  if (reviewedFile) {
@@ -588,6 +606,7 @@ export async function handleDeployCommand(context) {
588
606
  if (!preview.readyToMigrate)
589
607
  throw new Error(`Deployment plan is blocked by ${preview.blockers.length} issue(s).`);
590
608
  await confirmDeploy(context);
609
+ updateWorkspaceDigests(context.cwd);
591
610
  const startedAt = Date.now();
592
611
  const result = await runMigration({ ...input, reviewedPrune: preview.prune, reviewedPlan: preview });
593
612
  if (readBoolFlag(context.args, ['json'])) {
@@ -111,7 +111,12 @@ export type RevoLockDiagnostics = {
111
111
  enabled: boolean;
112
112
  };
113
113
  };
114
+ export type WorkspaceDigest = {
115
+ sourceDigest: string;
116
+ contentDigest?: string;
117
+ };
114
118
  export type RevoLockFile = {
119
+ workspaceDigests?: Record<string, Record<string, WorkspaceDigest>>;
115
120
  schemaVersion: 2;
116
121
  diagnostics?: RevoLockDiagnostics;
117
122
  componentIdentity: ComponentIdentityConfig;
@@ -204,6 +204,7 @@ export function readComponentLock(projectRoot) {
204
204
  }));
205
205
  return {
206
206
  schemaVersion: 2,
207
+ ...(raw.workspaceDigests ? { workspaceDigests: raw.workspaceDigests } : {}),
207
208
  ...(diagnostics ? { diagnostics } : {}),
208
209
  componentIdentity,
209
210
  components,
@@ -432,6 +433,7 @@ export function writeComponentLock(projectRoot, lock) {
432
433
  const sortedDatabaseViews = Object.fromEntries(Object.entries(lock.databaseViews || {}).sort(([left], [right]) => left.localeCompare(right)));
433
434
  writeJsonFile(getLockPath(projectRoot), {
434
435
  schemaVersion: 2,
436
+ ...(lock.workspaceDigests ? { workspaceDigests: lock.workspaceDigests } : {}),
435
437
  ...(lock.diagnostics ? { diagnostics: normalizeDiagnostics(lock.diagnostics) } : {}),
436
438
  componentIdentity: normalizeComponentIdentityConfig(lock.componentIdentity),
437
439
  components: sortedComponents,
@@ -0,0 +1,14 @@
1
+ import type { RevoClient } from './client.ts';
2
+ import type { ComponentRecord } from './types.ts';
3
+ export declare function listComponentManifests(client: RevoClient): Promise<{
4
+ components: Record<string, unknown>[];
5
+ discoveredTotal: number | null;
6
+ }>;
7
+ /** Reuse local source only when each backend-stamped child digest proves equality.
8
+ * Descriptions, ids and properties always come from the live manifest.
9
+ */
10
+ export declare function hydrateComponentManifest(summary: ComponentRecord, local?: ComponentRecord): (ComponentRecord & {
11
+ elements: NonNullable<ComponentRecord['elements']>;
12
+ }) | null;
13
+ export declare function localComponentSources(cwd: string): Map<string, ComponentRecord>;
14
+ export declare function loadComponentSources(client: RevoClient, cwd: string): Promise<ComponentRecord[]>;
@@ -0,0 +1,73 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { findManifestFiles, requireProjectLayout, unwrapData } from "./resource-syncs/util.js";
4
+ import { readConfiguredResourceMetadataStableKey } from "./resource-metadata.js";
5
+ import { readProjectStableKeyName } from "./project.js";
6
+ import { hydrateWorkspaceComponentElementDetails } from "./workspace-component.js";
7
+ import { mapWithConcurrency } from "./utils.js";
8
+ import { withHttpTraceContext } from "./http-trace.js";
9
+ import { HTTP_REQUEST_CONCURRENCY } from "./request-queue.js";
10
+ import { componentContentDigest, isComponentDigest } from "./component-contract.js";
11
+ import { createHash } from 'node:crypto';
12
+ export async function listComponentManifests(client) {
13
+ return typeof client.listAllComponentSyncManifests === 'function'
14
+ ? client.listAllComponentSyncManifests() : client.listAllComponents();
15
+ }
16
+ /** Reuse local source only when each backend-stamped child digest proves equality.
17
+ * Descriptions, ids and properties always come from the live manifest.
18
+ */
19
+ export function hydrateComponentManifest(summary, local) {
20
+ if (!local || !Array.isArray(summary.elements) || !isComponentDigest(summary.metadata?.__digest))
21
+ return null;
22
+ if (summary.elements.length !== (local.elements || []).length)
23
+ return null;
24
+ const byKey = new Map((local.elements || []).map(element => [element.key, element]));
25
+ if (byKey.size !== (local.elements || []).length
26
+ || new Set(summary.elements.map(element => element.key)).size !== summary.elements.length)
27
+ return null;
28
+ const elements = summary.elements.map(element => {
29
+ const source = byKey.get(element.key);
30
+ const details = source?.details ?? '';
31
+ const digest = `v1:sha256:${createHash('sha256').update(details).digest('hex')}`;
32
+ if (!source || !isComponentDigest(element.metadata?.__digest)
33
+ || element.metadata.__digest !== digest)
34
+ return null;
35
+ return { ...element, details };
36
+ });
37
+ if (elements.some(element => element === null))
38
+ return null;
39
+ const hydrated = { ...summary, elements: elements };
40
+ return componentContentDigest(hydrated) === summary.metadata.__digest ? hydrated : null;
41
+ }
42
+ export function localComponentSources(cwd) {
43
+ const { workspaceRoot } = requireProjectLayout(cwd, 'Component manifests');
44
+ const property = readProjectStableKeyName(cwd);
45
+ const result = new Map();
46
+ for (const filename of findManifestFiles(path.join(workspaceRoot, 'Components'), 'component.json')) {
47
+ const manifest = JSON.parse(fs.readFileSync(filename, 'utf8'));
48
+ const type = String(manifest.type || '').toLowerCase();
49
+ const extension = type.includes('ts') || type === 'typescript' ? 'ts'
50
+ : type.includes('json') ? 'json' : type.includes('js') || type === 'javascript' ? 'js' : 'txt';
51
+ const component = hydrateWorkspaceComponentElementDetails(filename, manifest, extension);
52
+ const key = readConfiguredResourceMetadataStableKey(component, property);
53
+ if (!key)
54
+ continue;
55
+ if (result.has(key))
56
+ throw new Error(`Duplicate local Component Stable Key "${key}".`);
57
+ result.set(key, component);
58
+ }
59
+ return result;
60
+ }
61
+ export async function loadComponentSources(client, cwd) {
62
+ const local = localComponentSources(cwd);
63
+ const property = readProjectStableKeyName(cwd);
64
+ const { components } = await withHttpTraceContext({ dependency: 'component', operation: 'list' }, () => listComponentManifests(client));
65
+ return mapWithConcurrency(components, async (summary) => {
66
+ const key = readConfiguredResourceMetadataStableKey(summary, property);
67
+ const hydrated = hydrateComponentManifest(summary, key ? local.get(key) : undefined);
68
+ const id = String(summary.componentId || summary.id || '');
69
+ return hydrated || (id ? unwrapData(await withHttpTraceContext({
70
+ dependency: 'component', operation: 'get', entityId: id,
71
+ }, () => client.getComponent(id, { timeoutMs: 30_000 }))) : summary);
72
+ }, HTTP_REQUEST_CONCURRENCY);
73
+ }
@@ -6,8 +6,8 @@ import { writeJsonFile } from "./utils.js";
6
6
  const HTTP_TRACE_DIRECTORY = path.join(REVO_PROJECT_DIR, 'logs', 'http-trace');
7
7
  const SAFE_PATH_SEGMENTS = new Set([
8
8
  'api', 'v1', 'activity', 'automation', 'event', 'schedule', 'template',
9
- 'component', 'databases', 'stats', 'views', 'preview', 'endpoints',
10
- 'groups', 'me', 'role-groups', 'roles', 'search',
9
+ 'component', 'sync-manifests', 'databases', 'stats', 'views', 'preview', 'endpoints',
10
+ 'accounts', 'agents', 'registry', 'plugins', 'groups', 'me', 'role-groups', 'roles', 'search',
11
11
  ]);
12
12
  const SAFE_ERROR_NAMES = new Set(['Error', 'TypeError', 'SyntaxError', 'AbortError', 'TimeoutError']);
13
13
  const SAFE_HTTP_METHODS = new Set(['GET', 'HEAD', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']);
@@ -108,6 +108,7 @@ export type MigrationRun = {
108
108
  verification?: MigrationPlan;
109
109
  };
110
110
  type MigrationInputBase = {
111
+ onProgress?: (message: string) => void;
111
112
  cwd: string;
112
113
  from: string;
113
114
  to: string;
@@ -8,6 +8,7 @@ import { SERVICE_ACCOUNTS_DIRECTORY, buildServiceAccountsPlan, pullServiceAccoun
8
8
  import os from 'node:os';
9
9
  import path from 'node:path';
10
10
  import { RevoClient } from "./client.js";
11
+ import { planningSnapshot } from "./planning-snapshot.js";
11
12
  import { REVO_LOCK_FILE, readComponentLock } from "./component-lock.js";
12
13
  import { normalizeStableKeyValue } from "./resource-metadata.js";
13
14
  import { withHttpTraceContext } from "./http-trace.js";
@@ -61,7 +62,11 @@ function selectedResources(input) {
61
62
  const requested = new Set(input.resources?.length ? input.resources : RESOURCE_ORDER);
62
63
  return RESOURCE_ORDER.filter((resource) => requested.has(resource));
63
64
  }
64
- async function runMigrationStage(stage, resource, envName, operation) {
65
+ async function runMigrationStage(stage, resource, envName, operation, progress) {
66
+ const startedAt = Date.now();
67
+ const label = `${stage}: ${resource}`;
68
+ progress?.(`${label} started`);
69
+ const heartbeat = progress ? setInterval(() => progress(`${label} running (${Math.round((Date.now() - startedAt) / 1000)}s)`), 20000) : undefined;
65
70
  try {
66
71
  return await withHttpTraceContext({
67
72
  stage: stage.replace(' ', '-'),
@@ -73,6 +78,11 @@ async function runMigrationStage(stage, resource, envName, operation) {
73
78
  const message = error instanceof Error ? error.message : String(error);
74
79
  throw new Error(`Migration ${stage} failed for ${resource} in environment "${envName}": ${message}`, { cause: error });
75
80
  }
81
+ finally {
82
+ if (heartbeat)
83
+ clearInterval(heartbeat);
84
+ progress?.(`${label} finished (${((Date.now() - startedAt) / 1000).toFixed(1)}s)`);
85
+ }
76
86
  }
77
87
  function migrationPolicy(input) {
78
88
  return {
@@ -243,7 +253,7 @@ function summarizeEndpointPhase(plan) {
243
253
  blockers,
244
254
  };
245
255
  }
246
- function summarizeSchedulePhase(plan) {
256
+ function summarizeSchedulePhase(plan, alignActivation = true) {
247
257
  const operations = emptyOperations();
248
258
  for (const item of plan.items) {
249
259
  operations[migrationItemOperation(item, scheduleItemAction(item))] += 1;
@@ -262,7 +272,7 @@ function summarizeSchedulePhase(plan) {
262
272
  return {
263
273
  order: 6,
264
274
  resource: 'schedule',
265
- needsChanges: operations.create + operations.update > 0 || plan.items.some((item) => item.status === 'activation-drift'),
275
+ needsChanges: operations.create + operations.update > 0 || (alignActivation && plan.items.some((item) => item.status === 'activation-drift')),
266
276
  readyToMigrate: blockers.length === 0,
267
277
  verdict: phaseVerdict(blockers, warnings),
268
278
  operations,
@@ -270,7 +280,7 @@ function summarizeSchedulePhase(plan) {
270
280
  blockers,
271
281
  };
272
282
  }
273
- function summarizeEventPhase(plan) {
283
+ function summarizeEventPhase(plan, alignActivation = true) {
274
284
  const operations = emptyOperations();
275
285
  for (const item of plan.items) {
276
286
  operations[migrationItemOperation(item, eventItemAction(item))] += 1;
@@ -286,13 +296,15 @@ function summarizeEventPhase(plan) {
286
296
  .map((item) => `Event "${item.stableKey || item.name}" has no target lock baseline; source-wins migration will align or adopt it.`),
287
297
  ...plan.items
288
298
  .filter((item) => item.status === 'activation-drift')
289
- .map((item) => `Event "${item.stableKey || item.name}" has activation drift; activation requires repository plan/deploy --activate or the dedicated events push --activate step.`),
299
+ .map((item) => alignActivation
300
+ ? `Event "${item.stableKey || item.name}" has activation drift; activation requires repository plan/deploy --activate or the dedicated events push --activate step.`
301
+ : `Event "${item.stableKey || item.name}" has activation drift; repository deployment preserves target activation without --activate.`),
290
302
  ])];
291
303
  const blockers = [...new Set(plan.blockers)];
292
304
  return {
293
305
  order: 7,
294
306
  resource: 'event',
295
- needsChanges: operations.create + operations.update > 0 || plan.items.some(item => item.status === 'activation-drift'),
307
+ needsChanges: operations.create + operations.update > 0 || (alignActivation && plan.items.some(item => item.status === 'activation-drift')),
296
308
  readyToMigrate: blockers.length === 0,
297
309
  verdict: phaseVerdict(blockers, warnings),
298
310
  operations,
@@ -606,8 +618,8 @@ function combinePlan(input) {
606
618
  ...(input.agents ? [summarizeAgentPhase(input.agents)] : []),
607
619
  ...(input.jobTemplates ? [summarizeJobTemplatePhase(input.jobTemplates)] : []),
608
620
  ...(input.endpoints ? [summarizeEndpointPhase(input.endpoints)] : []),
609
- ...(input.schedules ? [summarizeSchedulePhase(input.schedules)] : []),
610
- ...(input.events ? [summarizeEventPhase(input.events)] : []),
621
+ ...(input.schedules ? [summarizeSchedulePhase(input.schedules, input.migrationInput.sourceMode !== 'workspace' || input.migrationInput.activateAutomations === true)] : []),
622
+ ...(input.events ? [summarizeEventPhase(input.events, input.migrationInput.sourceMode !== 'workspace' || input.migrationInput.activateAutomations === true)] : []),
611
623
  ...(input.groups ? [summarizeGroupPhase(input.groups)] : []),
612
624
  ...(input.roleGroups ? [summarizeRoleGroupPhase(input.roleGroups)] : []),
613
625
  ].map((phase) => ({ ...phase, order: RESOURCE_ORDER.indexOf(phase.resource) + 1 })).map((phase) => applyWorkspaceDeploymentPolicy(input.migrationInput, phase, input))
@@ -1042,13 +1054,14 @@ function projectedDatabaseRecords(pull) {
1042
1054
  }));
1043
1055
  }
1044
1056
  async function planWorkspace(input) {
1057
+ const planStage = (stage, resource, environment, operation) => runMigrationStage(stage, resource, environment, operation, input.onProgress);
1045
1058
  const resources = selectedResources(input);
1046
1059
  const stableKeyName = readProjectStableKeyName(input.cwd);
1047
- const client = resolveTargetClient(input);
1060
+ const client = planningSnapshot(resolveTargetClient(input));
1048
1061
  const environmentKey = targetKey(input);
1049
1062
  const environmentLabel = targetLabel(input);
1050
1063
  const databaseSchemas = resources.includes('database-table')
1051
- ? await runMigrationStage('target plan', 'database-table', environmentLabel, () => buildDatabaseSchemasPlan({
1064
+ ? await planStage('target plan', 'database-table', environmentLabel, () => buildDatabaseSchemasPlan({
1052
1065
  client,
1053
1066
  cwd: input.cwd,
1054
1067
  envName: environmentKey,
@@ -1064,7 +1077,7 @@ async function planWorkspace(input) {
1064
1077
  && Boolean(input.pulls.databaseSchemas)
1065
1078
  && schemaPhase?.needsChanges === true;
1066
1079
  const databaseViews = resources.includes('database-view')
1067
- ? await runMigrationStage('target plan', 'database-view', environmentLabel, () => buildDatabaseViewsPlan({
1080
+ ? await planStage('target plan', 'database-view', environmentLabel, () => buildDatabaseViewsPlan({
1068
1081
  client,
1069
1082
  cwd: input.cwd,
1070
1083
  envName: environmentKey,
@@ -1076,30 +1089,30 @@ async function planWorkspace(input) {
1076
1089
  }))
1077
1090
  : undefined;
1078
1091
  const components = resources.includes('component')
1079
- ? await runMigrationStage('target plan', 'component', environmentLabel, () => buildComponentPlan(componentCommandContext({
1092
+ ? await planStage('target plan', 'component', environmentLabel, () => buildComponentPlan(componentCommandContext({
1080
1093
  cwd: input.cwd,
1081
1094
  envName: componentTargetEnvironment(input),
1082
1095
  client,
1083
1096
  operation: 'plan',
1084
1097
  }), undefined, input.detailedDiff === true))
1085
1098
  : undefined;
1086
- const identities = await planIdentityMigration({ client, cwd: input.cwd, stableKeyName, resources });
1099
+ const identities = await runMigrationStage('identity plan', 'group', environmentLabel, () => planIdentityMigration({ client, cwd: input.cwd, stableKeyName, resources }), input.onProgress);
1087
1100
  if (input.prune && input.sourceMode !== 'workspace')
1088
1101
  throw new Error('Prune requires repository plan/deploy; named migration remains upsert-only.');
1089
- const prune = input.prune ? await buildWorkspacePrunePlan({ cwd: input.cwd, client, resources, captureTargets: true }) : undefined;
1102
+ const prune = input.prune ? await runMigrationStage('prune plan', 'component', environmentLabel, () => buildWorkspacePrunePlan({ cwd: input.cwd, client, resources, captureTargets: true }), input.onProgress) : undefined;
1090
1103
  const serviceAccounts = resources.includes('service-account')
1091
- ? await runMigrationStage('target plan', 'service-account', environmentLabel, () => buildServiceAccountsPlan({ client, cwd: input.cwd, envName: environmentKey, stableKeyName,
1104
+ ? await planStage('target plan', 'service-account', environmentLabel, () => buildServiceAccountsPlan({ client, cwd: input.cwd, envName: environmentKey, stableKeyName,
1092
1105
  projectedIdentities: identities?.projection })) : undefined;
1093
1106
  if (serviceAccounts && identities) {
1094
1107
  serviceAccounts.blockers.push(...identities.blockers);
1095
1108
  }
1096
1109
  const projected = { component: input.projectDependencies && components ? components.items.filter(item => !item.blocked && ['create', 'update'].includes(componentItemAction(item))).flatMap(item => item.stableKey ? [item.stableKey] : []) : [],
1097
1110
  'service-account': identities?.projection.serviceAccounts || [], group: identities?.projection.groups || [] };
1098
- const agentPlugins = resources.includes('agent-plugin') ? await runMigrationStage('target plan', 'agent-plugin', environmentLabel, () => buildAgentsPlan({ client, cwd: input.cwd, envName: environmentKey, stableKeyName, family: 'agent-plugin', projected })) : undefined;
1099
- const agents = resources.includes('agent') ? await runMigrationStage('target plan', 'agent', environmentLabel, () => buildAgentsPlan({ client, cwd: input.cwd, envName: environmentKey, stableKeyName, family: 'agent', projected: { ...projected,
1111
+ const agentPlugins = resources.includes('agent-plugin') ? await planStage('target plan', 'agent-plugin', environmentLabel, () => buildAgentsPlan({ client, cwd: input.cwd, envName: environmentKey, stableKeyName, family: 'agent-plugin', projected })) : undefined;
1112
+ const agents = resources.includes('agent') ? await planStage('target plan', 'agent', environmentLabel, () => buildAgentsPlan({ client, cwd: input.cwd, envName: environmentKey, stableKeyName, family: 'agent', projected: { ...projected,
1100
1113
  'agent-plugin': agentPlugins?.items.filter(item => !item.blocked && item.desiredHash).flatMap(item => item.stableKey ? [item.stableKey] : []) || [] } })) : undefined;
1101
1114
  const jobTemplates = resources.includes('job-template')
1102
- ? await runMigrationStage('target plan', 'job-template', environmentLabel, () => buildJobTemplatesPlan({
1115
+ ? await planStage('target plan', 'job-template', environmentLabel, () => buildJobTemplatesPlan({
1103
1116
  client,
1104
1117
  cwd: input.cwd,
1105
1118
  envName: environmentKey,
@@ -1112,7 +1125,7 @@ async function planWorkspace(input) {
1112
1125
  }))
1113
1126
  : undefined;
1114
1127
  const endpoints = resources.includes('endpoint')
1115
- ? await runMigrationStage('target plan', 'endpoint', environmentLabel, () => buildEndpointsPlan({
1128
+ ? await planStage('target plan', 'endpoint', environmentLabel, () => buildEndpointsPlan({
1116
1129
  client,
1117
1130
  cwd: input.cwd,
1118
1131
  envName: environmentKey,
@@ -1125,7 +1138,7 @@ async function planWorkspace(input) {
1125
1138
  }))
1126
1139
  : undefined;
1127
1140
  const schedules = resources.includes('schedule')
1128
- ? await runMigrationStage('target plan', 'schedule', environmentLabel, () => buildSchedulesPlan({
1141
+ ? await planStage('target plan', 'schedule', environmentLabel, () => buildSchedulesPlan({
1129
1142
  client,
1130
1143
  cwd: input.cwd,
1131
1144
  envName: environmentKey,
@@ -1139,7 +1152,7 @@ async function planWorkspace(input) {
1139
1152
  }))
1140
1153
  : undefined;
1141
1154
  const events = resources.includes('event')
1142
- ? await runMigrationStage('target plan', 'event', environmentLabel, () => buildEventsPlan({
1155
+ ? await planStage('target plan', 'event', environmentLabel, () => buildEventsPlan({
1143
1156
  client,
1144
1157
  cwd: input.cwd,
1145
1158
  envName: environmentKey,
@@ -1150,7 +1163,7 @@ async function planWorkspace(input) {
1150
1163
  }))
1151
1164
  : undefined;
1152
1165
  const groups = resources.includes('group')
1153
- ? await runMigrationStage('target plan', 'group', environmentLabel, () => buildGroupsPlan({
1166
+ ? await planStage('target plan', 'group', environmentLabel, () => buildGroupsPlan({
1154
1167
  client,
1155
1168
  cwd: input.cwd,
1156
1169
  envName: environmentKey,
@@ -1162,7 +1175,7 @@ async function planWorkspace(input) {
1162
1175
  groups.blockers.push(...identities.blockers);
1163
1176
  }
1164
1177
  const roleGroups = resources.includes('role-group')
1165
- ? await runMigrationStage('target plan', 'role-group', environmentLabel, () => buildRoleGroupsPlan({
1178
+ ? await planStage('target plan', 'role-group', environmentLabel, () => buildRoleGroupsPlan({
1166
1179
  client,
1167
1180
  cwd: input.cwd,
1168
1181
  envName: environmentKey,
@@ -1297,6 +1310,7 @@ export async function runMigration(input) {
1297
1310
  return { ...base, verdict: 'blocked', results: [], phaseResults: {} };
1298
1311
  }
1299
1312
  const targetClient = resolveTargetClient(input);
1313
+ const deployStage = (resource, operation) => runMigrationStage('target deploy', resource, targetLabel(input), operation, input.onProgress);
1300
1314
  const environmentKey = targetKey(input);
1301
1315
  const phaseResults = {};
1302
1316
  const results = [];
@@ -1312,7 +1326,7 @@ export async function runMigration(input) {
1312
1326
  remainingPrune = { ...remainingPrune, items: remainingPrune.items.filter((item) => !item.beforeUpserts) };
1313
1327
  }
1314
1328
  if (resources.includes('database-table')) {
1315
- const pushed = await pushDatabaseSchemas({
1329
+ const pushed = await deployStage('database-table', () => pushDatabaseSchemas({
1316
1330
  client: targetClient,
1317
1331
  cwd: input.cwd,
1318
1332
  envName: environmentKey,
@@ -1321,17 +1335,17 @@ export async function runMigration(input) {
1321
1335
  prunePartitions: reviewedWorkspaceChanges && !input.prune,
1322
1336
  prunePartitionsConfirmed: reviewedWorkspaceChanges && !input.prune,
1323
1337
  migrationPolicy: migrationPolicy(input),
1324
- });
1338
+ }));
1325
1339
  phaseResults['database-table'] = pushed.results;
1326
1340
  results.push(...pushed.results);
1327
- const schemaVerification = await buildDatabaseSchemasPlan({
1341
+ const schemaVerification = await runMigrationStage('target plan', 'database-table', targetLabel(input), () => buildDatabaseSchemasPlan({
1328
1342
  client: targetClient,
1329
1343
  cwd: input.cwd,
1330
1344
  envName: environmentKey,
1331
1345
  stableKeyName,
1332
1346
  withStats: input.withStats,
1333
1347
  migrationPolicy: migrationPolicy(input),
1334
- });
1348
+ }), input.onProgress);
1335
1349
  const schemaPhase = applyWorkspaceDeploymentPolicy(input, summarizeSchemaPhase(schemaVerification), {
1336
1350
  databaseSchemas: schemaVerification,
1337
1351
  });
@@ -1355,13 +1369,13 @@ export async function runMigration(input) {
1355
1369
  }
1356
1370
  }
1357
1371
  if (resources.includes('database-view')) {
1358
- const liveViewPlan = await buildDatabaseViewsPlan({
1372
+ const liveViewPlan = await runMigrationStage('target plan', 'database-view', targetLabel(input), () => buildDatabaseViewsPlan({
1359
1373
  client: targetClient,
1360
1374
  cwd: input.cwd,
1361
1375
  envName: environmentKey,
1362
1376
  stableKeyName,
1363
1377
  migrationPolicy: viewMigrationPolicy(input),
1364
- });
1378
+ }), input.onProgress);
1365
1379
  const liveViewPhase = applyWorkspaceDeploymentPolicy(input, summarizeViewPhase(liveViewPlan), {
1366
1380
  databaseViews: liveViewPlan,
1367
1381
  });
@@ -1373,14 +1387,14 @@ export async function runMigration(input) {
1373
1387
  });
1374
1388
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1375
1389
  }
1376
- const pushed = await pushDatabaseViews({
1390
+ const pushed = await deployStage('database-view', () => pushDatabaseViews({
1377
1391
  client: targetClient,
1378
1392
  cwd: input.cwd,
1379
1393
  envName: environmentKey,
1380
1394
  stableKeyName,
1381
1395
  force: true,
1382
1396
  migrationPolicy: viewMigrationPolicy(input),
1383
- });
1397
+ }));
1384
1398
  phaseResults['database-view'] = pushed.results;
1385
1399
  results.push(...pushed.results);
1386
1400
  }
@@ -1400,13 +1414,13 @@ export async function runMigration(input) {
1400
1414
  });
1401
1415
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1402
1416
  }
1403
- const componentResults = await pushAllComponents(componentCommandContext({
1417
+ const componentResults = await deployStage('component', () => pushAllComponents(componentCommandContext({
1404
1418
  cwd: input.cwd,
1405
1419
  envName: componentTargetEnvironment(input),
1406
1420
  client: targetClient,
1407
1421
  operation: 'push',
1408
1422
  ...(input.reviewedPlan ? { reviewedComponents: initialPlan.components?.items } : {}),
1409
- }), { force: true, yes: true });
1423
+ }), { force: true, yes: true }));
1410
1424
  phaseResults.component = componentResults;
1411
1425
  results.push(...componentResults);
1412
1426
  if (!componentResultsAreComplete(componentResults)) {
@@ -1441,7 +1455,7 @@ export async function runMigration(input) {
1441
1455
  for (const node of identityRun.ordered) {
1442
1456
  const pushed = node.resource === 'service-account'
1443
1457
  ? await pushServiceAccounts({ client: targetClient, cwd: input.cwd, envName: environmentKey, stableKeyName, force: true, onlyStableKeys: [node.stableKey] })
1444
- : await pushGroups({ client: targetClient, cwd: input.cwd, envName: environmentKey, stableKeyName, force: true, onlyStableKeys: [node.stableKey] });
1458
+ : await deployStage('group', () => pushGroups({ client: targetClient, cwd: input.cwd, envName: environmentKey, stableKeyName, force: true, onlyStableKeys: [node.stableKey] }));
1445
1459
  const relevant = pushed.results.filter((item) => item.stableKey === node.stableKey);
1446
1460
  phaseResults[node.resource] = [...(phaseResults[node.resource] || []), ...relevant];
1447
1461
  results.push(...relevant);
@@ -1461,19 +1475,19 @@ export async function runMigration(input) {
1461
1475
  }
1462
1476
  for (const family of ['agent-plugin', 'agent'])
1463
1477
  if (resources.includes(family)) {
1464
- const pushed = await pushAgents({ client: targetClient, cwd: input.cwd, envName: environmentKey, stableKeyName, family, force: true });
1478
+ const pushed = await deployStage(family, () => pushAgents({ client: targetClient, cwd: input.cwd, envName: environmentKey, stableKeyName, family, force: true }));
1465
1479
  phaseResults[family] = pushed.results;
1466
1480
  results.push(...pushed.results);
1467
1481
  if (!resultsAreComplete(pushed.results))
1468
1482
  return { ...base, verdict: 'failed', results, phaseResults };
1469
1483
  }
1470
1484
  if (resources.includes('job-template')) {
1471
- const liveJobTemplatePlan = await buildJobTemplatesPlan({
1485
+ const liveJobTemplatePlan = await runMigrationStage('target plan', 'job-template', targetLabel(input), () => buildJobTemplatesPlan({
1472
1486
  client: targetClient,
1473
1487
  cwd: input.cwd,
1474
1488
  envName: environmentKey,
1475
1489
  stableKeyName,
1476
- });
1490
+ }), input.onProgress);
1477
1491
  const liveJobTemplatePhase = summarizeJobTemplatePhase(liveJobTemplatePlan);
1478
1492
  if (!liveJobTemplatePhase.readyToMigrate) {
1479
1493
  const verification = await planWorkspace({
@@ -1483,13 +1497,13 @@ export async function runMigration(input) {
1483
1497
  });
1484
1498
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1485
1499
  }
1486
- const pushed = await pushJobTemplates({
1500
+ const pushed = await deployStage('job-template', () => pushJobTemplates({
1487
1501
  client: targetClient,
1488
1502
  cwd: input.cwd,
1489
1503
  envName: environmentKey,
1490
1504
  stableKeyName,
1491
1505
  force: true,
1492
- });
1506
+ }));
1493
1507
  phaseResults['job-template'] = pushed.results;
1494
1508
  results.push(...pushed.results);
1495
1509
  if (!jobTemplateResultsAreComplete(pushed.results)) {
@@ -1502,13 +1516,13 @@ export async function runMigration(input) {
1502
1516
  }
1503
1517
  }
1504
1518
  if (resources.includes('endpoint')) {
1505
- const liveEndpointPlan = await buildEndpointsPlan({
1519
+ const liveEndpointPlan = await runMigrationStage('target plan', 'endpoint', targetLabel(input), () => buildEndpointsPlan({
1506
1520
  client: targetClient,
1507
1521
  cwd: input.cwd,
1508
1522
  envName: environmentKey,
1509
1523
  stableKeyName,
1510
1524
  includeDependencyBlockers: input.sourceMode === 'workspace',
1511
- });
1525
+ }), input.onProgress);
1512
1526
  const liveEndpointPhase = summarizeEndpointPhase(liveEndpointPlan);
1513
1527
  if (!liveEndpointPhase.readyToMigrate) {
1514
1528
  const verification = await planWorkspace({
@@ -1518,13 +1532,13 @@ export async function runMigration(input) {
1518
1532
  });
1519
1533
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1520
1534
  }
1521
- const pushed = await pushEndpoints({
1535
+ const pushed = await deployStage('endpoint', () => pushEndpoints({
1522
1536
  client: targetClient,
1523
1537
  cwd: input.cwd,
1524
1538
  envName: environmentKey,
1525
1539
  stableKeyName,
1526
1540
  force: true,
1527
- });
1541
+ }));
1528
1542
  phaseResults.endpoint = pushed.results;
1529
1543
  results.push(...pushed.results);
1530
1544
  if (!endpointResultsAreComplete(pushed.results)) {
@@ -1537,13 +1551,13 @@ export async function runMigration(input) {
1537
1551
  }
1538
1552
  }
1539
1553
  if (resources.includes('schedule')) {
1540
- const liveSchedulePlan = await buildSchedulesPlan({
1554
+ const liveSchedulePlan = await runMigrationStage('target plan', 'schedule', targetLabel(input), () => buildSchedulesPlan({
1541
1555
  client: targetClient,
1542
1556
  cwd: input.cwd,
1543
1557
  envName: environmentKey,
1544
1558
  stableKeyName,
1545
- });
1546
- const liveSchedulePhase = applyWorkspaceDeploymentPolicy(input, summarizeSchedulePhase(liveSchedulePlan), {
1559
+ }), input.onProgress);
1560
+ const liveSchedulePhase = applyWorkspaceDeploymentPolicy(input, summarizeSchedulePhase(liveSchedulePlan, input.sourceMode !== 'workspace' || input.activateAutomations === true), {
1547
1561
  schedules: liveSchedulePlan,
1548
1562
  });
1549
1563
  if (!liveSchedulePhase.readyToMigrate) {
@@ -1554,13 +1568,13 @@ export async function runMigration(input) {
1554
1568
  });
1555
1569
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1556
1570
  }
1557
- const pushed = await pushSchedules({
1571
+ const pushed = await deployStage('schedule', () => pushSchedules({
1558
1572
  client: targetClient,
1559
1573
  cwd: input.cwd,
1560
1574
  envName: environmentKey,
1561
1575
  stableKeyName,
1562
1576
  force: true,
1563
- });
1577
+ }));
1564
1578
  pendingSchedules.push(...pushed.verifiedActivationCandidates);
1565
1579
  phaseResults.schedule = pushed.results;
1566
1580
  results.push(...pushed.results);
@@ -1574,13 +1588,13 @@ export async function runMigration(input) {
1574
1588
  }
1575
1589
  }
1576
1590
  if (resources.includes('event')) {
1577
- const liveEventPlan = await buildEventsPlan({
1591
+ const liveEventPlan = await runMigrationStage('target plan', 'event', targetLabel(input), () => buildEventsPlan({
1578
1592
  client: targetClient,
1579
1593
  cwd: input.cwd,
1580
1594
  envName: environmentKey,
1581
1595
  stableKeyName,
1582
- });
1583
- const liveEventPhase = summarizeEventPhase(liveEventPlan);
1596
+ }), input.onProgress);
1597
+ const liveEventPhase = summarizeEventPhase(liveEventPlan, input.sourceMode !== 'workspace' || input.activateAutomations === true);
1584
1598
  if (!liveEventPhase.readyToMigrate) {
1585
1599
  const verification = await planWorkspace({
1586
1600
  ...input,
@@ -1589,13 +1603,13 @@ export async function runMigration(input) {
1589
1603
  });
1590
1604
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1591
1605
  }
1592
- const pushed = await pushEvents({
1606
+ const pushed = await deployStage('event', () => pushEvents({
1593
1607
  client: targetClient,
1594
1608
  cwd: input.cwd,
1595
1609
  envName: environmentKey,
1596
1610
  stableKeyName,
1597
1611
  force: true,
1598
- });
1612
+ }));
1599
1613
  pendingEvents.push(...pushed.verifiedActivationCandidates);
1600
1614
  phaseResults.event = pushed.results;
1601
1615
  results.push(...pushed.results);
@@ -1609,12 +1623,12 @@ export async function runMigration(input) {
1609
1623
  }
1610
1624
  }
1611
1625
  if (resources.includes('group')) {
1612
- const liveGroupPlan = await buildGroupsPlan({
1626
+ const liveGroupPlan = await runMigrationStage('target plan', 'group', targetLabel(input), () => buildGroupsPlan({
1613
1627
  client: targetClient,
1614
1628
  cwd: input.cwd,
1615
1629
  envName: environmentKey,
1616
1630
  stableKeyName,
1617
- });
1631
+ }), input.onProgress);
1618
1632
  const liveGroupPhase = applyWorkspaceDeploymentPolicy(input, summarizeGroupPhase(liveGroupPlan), {
1619
1633
  groups: liveGroupPlan,
1620
1634
  });
@@ -1626,13 +1640,13 @@ export async function runMigration(input) {
1626
1640
  });
1627
1641
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1628
1642
  }
1629
- const pushed = await pushGroups({
1643
+ const pushed = await deployStage('group', () => pushGroups({
1630
1644
  client: targetClient,
1631
1645
  cwd: input.cwd,
1632
1646
  envName: environmentKey,
1633
1647
  stableKeyName,
1634
1648
  force: true,
1635
- });
1649
+ }));
1636
1650
  const groupRemaining = pushed.results.filter((item) => !(phaseResults.group || []).some((prior) => 'stableKey' in prior && prior.stableKey === item.stableKey));
1637
1651
  phaseResults.group = [...(phaseResults.group || []), ...groupRemaining];
1638
1652
  results.push(...groupRemaining);
@@ -1646,12 +1660,12 @@ export async function runMigration(input) {
1646
1660
  }
1647
1661
  }
1648
1662
  if (resources.includes('role-group')) {
1649
- const liveRoleGroupPlan = await buildRoleGroupsPlan({
1663
+ const liveRoleGroupPlan = await runMigrationStage('target plan', 'role-group', targetLabel(input), () => buildRoleGroupsPlan({
1650
1664
  client: targetClient,
1651
1665
  cwd: input.cwd,
1652
1666
  envName: environmentKey,
1653
1667
  stableKeyName,
1654
- });
1668
+ }), input.onProgress);
1655
1669
  const liveRoleGroupPhase = applyWorkspaceDeploymentPolicy(input, summarizeRoleGroupPhase(liveRoleGroupPlan), {
1656
1670
  roleGroups: liveRoleGroupPlan,
1657
1671
  });
@@ -1663,13 +1677,13 @@ export async function runMigration(input) {
1663
1677
  });
1664
1678
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1665
1679
  }
1666
- const pushed = await pushRoleGroups({
1680
+ const pushed = await deployStage('role-group', () => pushRoleGroups({
1667
1681
  client: targetClient,
1668
1682
  cwd: input.cwd,
1669
1683
  envName: environmentKey,
1670
1684
  stableKeyName,
1671
1685
  force: true,
1672
- });
1686
+ }));
1673
1687
  phaseResults['role-group'] = pushed.results;
1674
1688
  results.push(...pushed.results);
1675
1689
  if (!resultsAreComplete(pushed.results)) {
@@ -0,0 +1,2 @@
1
+ import type { RevoClient } from './client.ts';
2
+ export declare function planningSnapshot(client: RevoClient): RevoClient;
@@ -0,0 +1,29 @@
1
+ // Only one planning pass owns this cache. Mutation/readback uses the original
2
+ // client, and the next pass always starts empty. Never persist auth or row data.
3
+ export function planningSnapshot(client) {
4
+ const pending = new Map();
5
+ return new Proxy(client, {
6
+ get(target, property) {
7
+ const value = Reflect.get(target, property, target);
8
+ if (typeof value !== 'function')
9
+ return value;
10
+ if (typeof property !== 'string' || !/^(listAll|get)(Components?|ComponentSyncManifests|ComponentRuntime|ComponentSnapshotVersion|DatabaseSchemas?|DatabaseViews?ForSync|DatabaseView|Endpoints?|JobTemplates?|Schedules?|Events?|RoleGroups?|Groups?|ServiceAccounts?|Accounts?|Agents?|AgentPlugins?)$/.test(property)) {
11
+ return value.bind(target);
12
+ }
13
+ return async (...args) => {
14
+ // These detail methods accept transport timeout options only; they do not
15
+ // select different authoring state. Preserve semantic args for other methods.
16
+ const readArgs = ['getComponent', 'getEndpoint'].includes(property) ? args.slice(0, 1) : args;
17
+ const key = JSON.stringify([property, readArgs]);
18
+ let request = pending.get(key);
19
+ if (!request) {
20
+ request = Promise.resolve().then(() => value.apply(target, args));
21
+ pending.set(key, request);
22
+ request.catch(() => pending.delete(key));
23
+ }
24
+ // Planners annotate records. No consumer may mutate another's snapshot.
25
+ return structuredClone(await request);
26
+ };
27
+ },
28
+ });
29
+ }
@@ -1,3 +1,4 @@
1
+ import { loadComponentSources } from "../component-manifests.js";
1
2
  import { componentContentDigest, componentRevisionByDigest, isComponentDigest } from "../component-contract.js";
2
3
  import { executionPrincipalAvailable, portableExecutionPolicy, runtimeExecutionPolicyPayload, validPortableExecutionPolicy } from "./account-principal.js";
3
4
  import path from 'node:path';
@@ -245,20 +246,8 @@ async function loadRemoteEndpoints(client) {
245
246
  }, () => client.getEndpoint(endpointId, { timeoutMs: REMOTE_DETAIL_REQUEST_TIMEOUT_MS })));
246
247
  }, HTTP_REQUEST_CONCURRENCY);
247
248
  }
248
- async function loadRemoteComponents(client) {
249
- const { components } = await withHttpTraceContext({ dependency: 'component', operation: 'list' }, () => client.listAllComponents());
250
- return mapWithConcurrency(components, async (summary) => {
251
- const componentId = componentIdOf(summary);
252
- if (!componentId) {
253
- return summary;
254
- }
255
- return unwrapData(await withHttpTraceContext({
256
- dependency: 'component',
257
- operation: 'get',
258
- entityId: componentId,
259
- ...(typeof summary.name === 'string' ? { entityName: summary.name } : {}),
260
- }, () => client.getComponent(componentId, { timeoutMs: REMOTE_DETAIL_REQUEST_TIMEOUT_MS })));
261
- }, HTTP_REQUEST_CONCURRENCY);
249
+ async function loadRemoteComponents(client, cwd) {
250
+ return loadComponentSources(client, cwd);
262
251
  }
263
252
  async function componentBinding(input) {
264
253
  const component = input.componentsById.get(input.componentId);
@@ -358,7 +347,7 @@ export async function pullEndpointsToWorkspace(input) {
358
347
  const { projectRoot, workspaceRoot } = requireProjectLayout(input.cwd, 'Endpoint');
359
348
  const [records, components] = await Promise.all([
360
349
  loadRemoteEndpoints(input.client),
361
- loadRemoteComponents(input.client),
350
+ loadRemoteComponents(input.client, input.cwd),
362
351
  ]);
363
352
  const componentsById = new Map(components.map((component) => [componentIdOf(component), component]));
364
353
  const manifests = [];
@@ -761,7 +750,7 @@ export async function buildEndpointsPlan(input) {
761
750
  }
762
751
  const [targetEndpoints, targetComponents] = await Promise.all([
763
752
  loadRemoteEndpoints(input.client),
764
- loadRemoteComponents(input.client),
753
+ loadRemoteComponents(input.client, input.cwd),
765
754
  ]);
766
755
  const workspaceComponents = readWorkspaceComponents(input.cwd, input.stableKeyName);
767
756
  const targetComponentsByKey = targetComponentsByStableKey(targetComponents, input.stableKeyName);
@@ -1150,7 +1139,7 @@ function endpointWriteOptions(manifest, schemaComponent) {
1150
1139
  return Object.keys(options).length > 0 ? options : undefined;
1151
1140
  }
1152
1141
  async function resolveEndpointWritePayload(input) {
1153
- const targetComponents = await loadRemoteComponents(input.client);
1142
+ const targetComponents = await loadRemoteComponents(input.client, input.cwd);
1154
1143
  const targetByKey = targetComponentsByStableKey(targetComponents, input.stableKeyName);
1155
1144
  const workspaceComponents = input.workspaceComponents || readWorkspaceComponents(input.cwd, input.stableKeyName);
1156
1145
  const diagnostics = componentDependencyDiagnostics({
@@ -1239,7 +1228,7 @@ async function verifyEndpointWrite(input) {
1239
1228
  if (verifiedStableKey !== input.stableKey) {
1240
1229
  throw new Error(`written target is missing or changed ${input.stableKeyName}`);
1241
1230
  }
1242
- const targetComponents = await loadRemoteComponents(input.client);
1231
+ const targetComponents = await loadRemoteComponents(input.client, input.cwd);
1243
1232
  const componentsById = new Map(targetComponents.map((component) => [componentIdOf(component), component]));
1244
1233
  const verifiedManifest = await manifestFromRecord({
1245
1234
  includeExecutionPolicy: input.desiredManifest.executionPolicy !== undefined,
@@ -1297,6 +1286,7 @@ async function executeEndpointPushItem(input) {
1297
1286
  };
1298
1287
  const endpointId = await input.mutate(prepared);
1299
1288
  const remoteHash = await verifyEndpointWrite({
1289
+ cwd: input.cwd,
1300
1290
  client: input.client,
1301
1291
  endpointId,
1302
1292
  stableKey,
@@ -1372,7 +1362,7 @@ async function pushEndpointUpdate(input) {
1372
1362
  if (!targetId) {
1373
1363
  throw new Error('live target did not include endpointId');
1374
1364
  }
1375
- const targetComponents = await loadRemoteComponents(input.client);
1365
+ const targetComponents = await loadRemoteComponents(input.client, input.cwd);
1376
1366
  const targetManifest = await manifestFromRecord({
1377
1367
  includeExecutionPolicy: prepared.manifest.executionPolicy !== undefined,
1378
1368
  client: input.client,
@@ -1513,7 +1503,7 @@ export async function pushEndpoints(input) {
1513
1503
  if (endpointRevisionHash(target) !== item.targetRevisionHash) {
1514
1504
  throw new Error('deleted target changed after planning');
1515
1505
  }
1516
- const targetComponents = await loadRemoteComponents(input.client);
1506
+ const targetComponents = await loadRemoteComponents(input.client, input.cwd);
1517
1507
  const restoreBlockers = await activeDeletedEndpointRestoreBlockers({
1518
1508
  client: input.client,
1519
1509
  record: target,
@@ -1,3 +1,5 @@
1
+ import { mapWithConcurrency } from "../utils.js";
2
+ import { HTTP_REQUEST_CONCURRENCY } from "../request-queue.js";
1
3
  import { readComponentLock } from "../component-lock.js";
2
4
  import { readConfiguredResourceMetadataStableKey } from "../resource-metadata.js";
3
5
  import { readWorkspaceGroups } from "./group-sync.js";
@@ -19,8 +21,8 @@ export async function planIdentityMigration(input) {
19
21
  const id = (node) => `${node.resource}:${node.stableKey}`;
20
22
  const liveCounts = new Map();
21
23
  const { serviceAccounts } = await input.client.listAllServiceAccounts();
22
- for (const summary of serviceAccounts) {
23
- const record = await input.client.getServiceAccount(String(summary.userId || ''));
24
+ const accounts = await mapWithConcurrency(serviceAccounts, summary => input.client.getServiceAccount(String(summary.userId || '')), HTTP_REQUEST_CONCURRENCY);
25
+ for (const record of accounts) {
24
26
  if (isBuiltinSystemAccount(record))
25
27
  continue;
26
28
  const key = readConfiguredResourceMetadataStableKey(record, input.stableKeyName);
@@ -31,8 +33,8 @@ export async function planIdentityMigration(input) {
31
33
  }
32
34
  if (nodes.some((node) => node.resource === 'group' || node.owner?.type === 'group')) {
33
35
  const { groups } = await input.client.listAllGroups();
34
- for (const summary of groups) {
35
- const record = unwrapData(await input.client.getGroup(String(summary.groupId || summary.id || '')));
36
+ const details = await mapWithConcurrency(groups, async (summary) => unwrapData(await input.client.getGroup(String(summary.groupId || summary.id || ''))), HTTP_REQUEST_CONCURRENCY);
37
+ for (const record of details) {
36
38
  const key = readConfiguredResourceMetadataStableKey(record, input.stableKeyName);
37
39
  if (key && !record.deletedAt) {
38
40
  const k = id({
@@ -1,3 +1,4 @@
1
+ import { loadComponentSources } from "../component-manifests.js";
1
2
  import { componentRevisionByDigest, isComponentDigest } from "../component-contract.js";
2
3
  import path from 'node:path';
3
4
  import { accountPrincipal, resolveExecutionPrincipal, executionPrincipalAvailable, portableExecutionPolicy, runtimeExecutionPolicyPayload, validExecutionPrincipal, validPortableExecutionPolicy } from "./account-principal.js";
@@ -87,12 +88,8 @@ async function loadRemoteJobTemplates(client) {
87
88
  return id ? unwrapData(await client.getJobTemplate(id)) : summary;
88
89
  });
89
90
  }
90
- async function loadRemoteComponents(client) {
91
- const { components } = await client.listAllComponents();
92
- return mapWithConcurrency(components, async (summary) => {
93
- const id = componentIdOf(summary);
94
- return id ? unwrapData(await client.getComponent(id)) : summary;
95
- });
91
+ async function loadRemoteComponents(client, cwd) {
92
+ return loadComponentSources(client, cwd);
96
93
  }
97
94
  const JOB_TEMPLATE_MANIFEST_FIELDS = new Set([
98
95
  'executionPrincipal', 'executionPolicy',
@@ -307,7 +304,7 @@ export async function buildJobTemplatesPlan(input) {
307
304
  const lock = readComponentLock(projectRoot);
308
305
  const localEntries = readWorkspaceJobTemplates(input.cwd);
309
306
  const targetRecords = await loadRemoteJobTemplates(input.client);
310
- const targetComponents = await loadRemoteComponents(input.client);
307
+ const targetComponents = await loadRemoteComponents(input.client, input.cwd);
311
308
  const blockers = [];
312
309
  const warnings = [];
313
310
  const items = [];
@@ -723,7 +720,7 @@ async function prepareJobTemplateCreates(input) {
723
720
  .map((entry) => [entry.manifest.stableKey, entry]));
724
721
  const targetTemplates = await loadRemoteJobTemplates(input.client);
725
722
  const targetKeys = targetTemplates.map((record) => readConfiguredResourceMetadataStableKey(record, input.stableKeyName));
726
- const targetComponents = await loadRemoteComponents(input.client);
723
+ const targetComponents = await loadRemoteComponents(input.client, input.cwd);
727
724
  const prepared = [];
728
725
  for (const item of input.plan.items.filter((candidate) => candidate.status === 'create')) {
729
726
  const stableKey = item.stableKey || '';
@@ -847,7 +844,7 @@ export async function pushJobTemplates(input) {
847
844
  }
848
845
  const updateItems = plan.items.filter((candidate) => (['safe-update', 'remote-changed', 'conflict', 'missing-lock'].includes(candidate.status)));
849
846
  const liveTargetTemplates = updateItems.length > 0 ? await loadRemoteJobTemplates(input.client) : [];
850
- const liveTargetComponents = updateItems.length > 0 ? await loadRemoteComponents(input.client) : [];
847
+ const liveTargetComponents = updateItems.length > 0 ? await loadRemoteComponents(input.client, input.cwd) : [];
851
848
  for (const item of updateItems) {
852
849
  const stableKey = item.stableKey || '';
853
850
  const local = localByKey.get(stableKey);
package/dist/src/ui.js CHANGED
@@ -179,8 +179,9 @@ function renderCommandCatalog() {
179
179
  commandRow('revo metadata apply [--project <name>] --yes [--skip-partitions]', 'Populate missing stable-key metadata'),
180
180
  commandRow('revo pull --all|--resources <list> --yes [--skip-groups] [--force] [--json]', 'Build the repository workspace from the configured runtime source'),
181
181
  commandRow('revo diff [--json]', 'Show only workspace-to-target resource differences without writes'),
182
- commandRow('revo plan [--activate] [--prune] [--out file] [--force] [--strict] [--json] [--hints]', 'Plan tracked workspace upserts and optional Stable Key deletions without writes'),
183
- commandRow('revo deploy [--yes] [--activate] [--prune] [--reviewed-plan file] [--force] [--json]', 'Review, confirm, deploy and prune tracked resources in dependency order'),
182
+ commandRow('revo plan [--activate] [--prune] [--out file] [--force] [--strict] [--json] [--hints]', 'Plan tracked definitions; preserve automation activation unless --activate'),
183
+ commandRow('revo plan update [--json]', 'Update the local Stable Key source digest index without contacting the target'),
184
+ commandRow('revo deploy [--yes] [--activate] [--prune] [--reviewed-plan file] [--force] [--json]', 'Deploy tracked definitions; preserve automation activation unless --activate'),
184
185
  commandRow('revo migrate plan --from <env> --to <env> [--resources <list>] [--skip-groups] [--force] [--json] [--hints]', 'Preview twelve resource families and identity dependencies'),
185
186
  commandRow('revo migrate run --from <env> --to <env> [--resources <list>] [--skip-groups] --yes [--force] [--json]', 'Pull, plan, migrate, and verify resources in dependency order'),
186
187
  commandRow('revo migrate verify --from <env> --to <env> [--resources <list>] [--json]', 'Verify target resources against a fresh temporary source pull'),
@@ -0,0 +1,6 @@
1
+ /** Offline, deterministic authoring index. It never adopts or modifies a target baseline. */
2
+ export declare function updateWorkspaceDigests(cwd: string): {
3
+ changed: boolean;
4
+ resources: number;
5
+ resourcesIndexed: number;
6
+ };
@@ -0,0 +1,54 @@
1
+ import { hashPortableComponentSource, readComponentLock, writeComponentLock } from "./component-lock.js";
2
+ import { componentContentDigest } from "./component-contract.js";
3
+ import { localComponentSources } from "./component-manifests.js";
4
+ import { readPruneManifests } from "./workspace-prune.js";
5
+ import { requireProjectLayout } from "./resource-syncs/util.js";
6
+ import { TRACKABLE_RESOURCE_TYPES, shouldTrackResource } from "./tracked-resources.js";
7
+ import { readProjectTrackedResources, readProjectStableKeyName } from "./project.js";
8
+ import { hashPortableAgent } from "./resource-syncs/agent-sync.js";
9
+ import { hashPortableDatabaseSchema, readWorkspaceDatabaseSchemas } from "./resource-syncs/database-table-sync.js";
10
+ import { hashPortableDatabaseView } from "./resource-syncs/database-view-sync.js";
11
+ import { hashPortableEndpoint } from "./resource-syncs/endpoint-sync.js";
12
+ import { hashPortableEvent } from "./resource-syncs/event-sync.js";
13
+ import { hashPortableGroup } from "./resource-syncs/group-sync.js";
14
+ import { hashPortableJobTemplate } from "./resource-syncs/job-template-sync.js";
15
+ import { hashPortableRoleGroup } from "./resource-syncs/role-group-sync.js";
16
+ import { hashPortableSchedule } from "./resource-syncs/schedule-sync.js";
17
+ import { hashPortableServiceAccount } from "./resource-syncs/service-account-sync.js";
18
+ /** Offline, deterministic authoring index. It never adopts or modifies a target baseline. */
19
+ export function updateWorkspaceDigests(cwd) {
20
+ const { projectRoot } = requireProjectLayout(cwd, 'Plan update');
21
+ const resources = TRACKABLE_RESOURCE_TYPES.filter(resource => shouldTrackResource(readProjectTrackedResources(cwd), resource));
22
+ const local = readPruneManifests(cwd, resources);
23
+ const workspaceDigests = {};
24
+ const hashers = { agent: hashPortableAgent, 'agent-plugin': hashPortableAgent,
25
+ 'database-table': hashPortableDatabaseSchema, 'database-view': hashPortableDatabaseView,
26
+ endpoint: hashPortableEndpoint, event: hashPortableEvent, group: hashPortableGroup,
27
+ 'job-template': hashPortableJobTemplate, 'role-group': hashPortableRoleGroup,
28
+ schedule: hashPortableSchedule, 'service-account': hashPortableServiceAccount };
29
+ for (const resource of resources) {
30
+ const entries = {};
31
+ if (resource === 'component') {
32
+ for (const [key, component] of [...localComponentSources(cwd)].sort(([a], [b]) => a.localeCompare(b))) {
33
+ entries[key] = { sourceDigest: hashPortableComponentSource(component), contentDigest: componentContentDigest(component) };
34
+ }
35
+ }
36
+ else if (resource === 'database-table') {
37
+ for (const { manifest } of readWorkspaceDatabaseSchemas(cwd, readProjectStableKeyName(cwd))) {
38
+ entries[manifest.stableKey] = { sourceDigest: hashPortableDatabaseSchema(manifest) };
39
+ }
40
+ }
41
+ else {
42
+ for (const [key, manifest] of [...(local[resource] || [])].sort(([a], [b]) => a.localeCompare(b))) {
43
+ entries[key] = { sourceDigest: hashers[resource](manifest) };
44
+ }
45
+ }
46
+ workspaceDigests[resource] = entries;
47
+ }
48
+ const lock = readComponentLock(projectRoot);
49
+ const changed = JSON.stringify(lock.workspaceDigests) !== JSON.stringify(workspaceDigests);
50
+ if (changed)
51
+ writeComponentLock(projectRoot, { ...lock, workspaceDigests });
52
+ return { changed, resources: Object.keys(workspaceDigests).length,
53
+ resourcesIndexed: Object.values(workspaceDigests).reduce((sum, entries) => sum + Object.keys(entries).length, 0) };
54
+ }
@@ -1,6 +1,9 @@
1
+ import { loadComponentSources } from "./component-manifests.js";
1
2
  import { agentDependencies } from "./resource-syncs/agent-sync.js";
2
3
  import fs from 'node:fs';
3
4
  import path from 'node:path';
5
+ import { HTTP_REQUEST_CONCURRENCY } from "./request-queue.js";
6
+ import { mapWithConcurrency } from "./utils.js";
4
7
  import { hashStable, readComponentLock, removeComponentLockBaseline, writeComponentLock } from "./component-lock.js";
5
8
  import { readProjectStableKeyName } from "./project.js";
6
9
  import { readResourceInventory, resourceIdOf } from "./resource-inventory.js";
@@ -369,16 +372,26 @@ export async function buildWorkspacePrunePlan(input) {
369
372
  // Human owners also block Group/Account deletion. Keep the client sanitization
370
373
  // and sensitive-account trace redaction; never inventory credentials.
371
374
  const { serviceAccounts } = await input.client.listAllServiceAccounts({ includeHumans: true });
372
- for (const account of serviceAccounts) {
375
+ const accounts = await mapWithConcurrency(serviceAccounts, async (account) => {
373
376
  const id = resourceIdOf(account);
377
+ if (!id)
378
+ throw new Error('Incomplete account ownership inventory; prune blocked.');
374
379
  const detail = await input.client.getAccount(id);
375
- if (!id || resourceIdOf(detail) !== id)
380
+ if (resourceIdOf(detail) !== id)
376
381
  throw new Error('Incomplete account ownership inventory; prune blocked.');
377
- records.push(detail);
378
- }
382
+ return detail;
383
+ }, HTTP_REQUEST_CONCURRENCY);
384
+ records.push(...accounts);
379
385
  inventory[resource] = records;
380
386
  continue;
381
387
  }
388
+ if (resource === 'component') {
389
+ const components = await loadComponentSources(input.client, input.cwd);
390
+ if (components.some(component => !resourceIdOf(component)))
391
+ throw new Error('Incomplete component inventory; prune blocked.');
392
+ inventory[resource] = components;
393
+ continue;
394
+ }
382
395
  for await (const entry of readResourceInventory(input.client, resource)) {
383
396
  if (!entry.resource || resourceIdOf(entry.resource) !== entry.listedId)
384
397
  throw new Error(`Incomplete ${resource} inventory; prune blocked.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revoengine/cli",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "description": "CLI package for the RevoEngine Platform API",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -11,7 +11,7 @@
11
11
  "scripts": {
12
12
  "build": "npm run clean && tsc -p tsconfig.build.json",
13
13
  "clean": "node --input-type=module -e \"import fs from 'node:fs'; fs.rmSync('dist', { recursive: true, force: true });\"",
14
- "check": "node --input-type=module -e \"await import('./src/config.ts'); await import('./src/legacy.ts'); await import('./src/http-trace.ts'); await import('./src/request-queue.ts'); await import('./src/client.ts'); await import('./src/component-lock.ts'); await import('./src/component-contract.ts'); await import('./src/database-indexes.ts'); await import('./src/diff-details.ts'); await import('./src/resource-metadata.ts'); await import('./src/tracked-resources.ts'); await import('./src/resource-inventory.ts'); await import('./src/metadata-backfill.ts'); await import('./src/workspace-component.ts'); await import('./src/workspace-resource.ts'); await import('./src/database-table-artifacts.ts'); await import('./src/project.ts'); await import('./src/prompt.ts'); await import('./src/runtime-view.ts'); await import('./src/spinner.ts'); await import('./src/types.ts'); await import('./src/utils.ts'); await import('./src/resource-syncs/util.ts'); await import('./src/resource-syncs/agent-sync.ts'); await import('./src/resource-syncs/database-table-sync.ts'); await import('./src/resource-syncs/database-view-sync.ts'); await import('./src/resource-syncs/endpoint-sync.ts'); await import('./src/resource-syncs/group-sync.ts'); await import('./src/resource-syncs/role-group-sync.ts'); await import('./src/resource-syncs/job-template-sync.ts'); await import('./src/resource-syncs/schedule-sync.ts'); await import('./src/resource-syncs/event-sync.ts'); await import('./src/resource-syncs/account-principal.ts'); await import('./src/resource-syncs/identity-migration.ts'); await import('./src/resource-syncs/service-account-sync.ts'); await import('./src/commands/service-accounts.ts'); await import('./src/commands/agents.ts'); await import('./src/migration-actions.ts'); await import('./src/reviewed-plan.ts'); await import('./src/migration.ts'); await import('./src/workspace-diff.ts'); await import('./src/workspace-prune.ts'); await import('./src/sync-output.ts'); await import('./src/ui.ts'); await import('./src/update-notifier.ts'); await import('./src/env-sync.ts'); await import('./src/commands/auth.ts'); await import('./src/commands/component.ts'); await import('./src/commands/database-tables.ts'); await import('./src/commands/database-views.ts'); await import('./src/commands/endpoints.ts'); await import('./src/commands/env.ts'); await import('./src/commands/events.ts'); await import('./src/commands/groups.ts'); await import('./src/commands/info.ts'); await import('./src/commands/job-templates.ts'); await import('./src/commands/metadata.ts'); await import('./src/commands/migrate.ts'); await import('./src/commands/request.ts'); await import('./src/commands/role-groups.ts'); await import('./src/commands/search.ts'); await import('./src/commands/schedules.ts'); await import('./src/commands/terminal-service.ts'); await import('./src/commands/terminal-browser.ts'); await import('./src/commands/terminal-image.ts'); await import('./src/commands/terminal-sandbox.ts'); await import('./src/commands/terminal-patch.ts'); await import('./src/commands/terminal-patch-worker.ts'); await import('./src/commands/terminal.ts'); await import('./src/cli.ts'); await import('./src/index.ts'); await import('./bin/revo.ts'); await import('./scripts/dev.ts')\"",
14
+ "check": "node --input-type=module -e \"await import('./src/config.ts'); await import('./src/legacy.ts'); await import('./src/http-trace.ts'); await import('./src/request-queue.ts'); await import('./src/client.ts'); await import('./src/component-lock.ts'); await import('./src/component-contract.ts'); await import('./src/component-manifests.ts'); await import('./src/planning-snapshot.ts'); await import('./src/workspace-digests.ts'); await import('./src/database-indexes.ts'); await import('./src/diff-details.ts'); await import('./src/resource-metadata.ts'); await import('./src/tracked-resources.ts'); await import('./src/resource-inventory.ts'); await import('./src/metadata-backfill.ts'); await import('./src/workspace-component.ts'); await import('./src/workspace-resource.ts'); await import('./src/database-table-artifacts.ts'); await import('./src/project.ts'); await import('./src/prompt.ts'); await import('./src/runtime-view.ts'); await import('./src/spinner.ts'); await import('./src/types.ts'); await import('./src/utils.ts'); await import('./src/resource-syncs/util.ts'); await import('./src/resource-syncs/agent-sync.ts'); await import('./src/resource-syncs/database-table-sync.ts'); await import('./src/resource-syncs/database-view-sync.ts'); await import('./src/resource-syncs/endpoint-sync.ts'); await import('./src/resource-syncs/group-sync.ts'); await import('./src/resource-syncs/role-group-sync.ts'); await import('./src/resource-syncs/job-template-sync.ts'); await import('./src/resource-syncs/schedule-sync.ts'); await import('./src/resource-syncs/event-sync.ts'); await import('./src/resource-syncs/account-principal.ts'); await import('./src/resource-syncs/identity-migration.ts'); await import('./src/resource-syncs/service-account-sync.ts'); await import('./src/commands/service-accounts.ts'); await import('./src/commands/agents.ts'); await import('./src/migration-actions.ts'); await import('./src/reviewed-plan.ts'); await import('./src/migration.ts'); await import('./src/workspace-diff.ts'); await import('./src/workspace-prune.ts'); await import('./src/sync-output.ts'); await import('./src/ui.ts'); await import('./src/update-notifier.ts'); await import('./src/env-sync.ts'); await import('./src/commands/auth.ts'); await import('./src/commands/component.ts'); await import('./src/commands/database-tables.ts'); await import('./src/commands/database-views.ts'); await import('./src/commands/endpoints.ts'); await import('./src/commands/env.ts'); await import('./src/commands/events.ts'); await import('./src/commands/groups.ts'); await import('./src/commands/info.ts'); await import('./src/commands/job-templates.ts'); await import('./src/commands/metadata.ts'); await import('./src/commands/migrate.ts'); await import('./src/commands/request.ts'); await import('./src/commands/role-groups.ts'); await import('./src/commands/search.ts'); await import('./src/commands/schedules.ts'); await import('./src/commands/terminal-service.ts'); await import('./src/commands/terminal-browser.ts'); await import('./src/commands/terminal-image.ts'); await import('./src/commands/terminal-sandbox.ts'); await import('./src/commands/terminal-patch.ts'); await import('./src/commands/terminal-patch-worker.ts'); await import('./src/commands/terminal.ts'); await import('./src/cli.ts'); await import('./src/index.ts'); await import('./bin/revo.ts'); await import('./scripts/dev.ts')\"",
15
15
  "dev": "node ./scripts/dev.ts",
16
16
  "prepack": "npm run build",
17
17
  "test": "node --test ./test/*.test.ts",