@revoengine/cli 1.0.26 → 1.0.27

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
@@ -648,3 +648,28 @@ Schedule and Event activation differences remain pending changes even if their c
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.
@@ -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";
@@ -405,6 +406,7 @@ async function handleMigrationRead(context, input, command) {
405
406
  const plan = await buildMigrationPlan({
406
407
  ...input,
407
408
  detailedDiff: true,
409
+ onProgress: readBoolFlag(context.args, ['json']) ? undefined : context.println,
408
410
  ...(command === 'diff' ? { allowDestructive: true } : {}),
409
411
  });
410
412
  if (command === 'diff') {
@@ -452,6 +454,19 @@ export async function handleDiffCommand(context) {
452
454
  await handleMigrationRead(context, await readWorkspaceDeploymentInput(context), 'diff');
453
455
  }
454
456
  export async function handlePlanCommand(context) {
457
+ if (context.args._[1] === 'update') {
458
+ if (Object.keys(context.args).some(key => !['_', 'json', 'project', 'update-notifier'].includes(key))) {
459
+ throw new Error('Offline plan update accepts --json and --project only; target/deployment flags require revo plan.');
460
+ }
461
+ const result = updateWorkspaceDigests(context.cwd);
462
+ if (readBoolFlag(context.args, ['json']))
463
+ context.print(result);
464
+ else
465
+ context.println(`Local digest index: ${result.resourcesIndexed} resources; ${result.changed ? 'updated' : 'unchanged'}. No remote reads or writes.`);
466
+ return;
467
+ }
468
+ if (context.args._[1])
469
+ throw new Error('Unknown plan command; use revo plan or revo plan update.');
455
470
  if (readBoolFlag(context.args, ['changed']) || readFlag(context.args, ['base'])) {
456
471
  throw new Error('Repository plan evaluates all tracked resources and dependencies; --changed and --base are supported only by component plan.');
457
472
  }
@@ -563,7 +578,8 @@ export async function handleDeployCommand(context) {
563
578
  if (readBoolFlag(context.args, ['changed']) || readFlag(context.args, ['base']) || readValues(context.args, ['resources', 'resource']).length > 0) {
564
579
  throw new Error('Repository deployment evaluates all tracked resources; select resources in .revoengine/revo.json.');
565
580
  }
566
- const input = { ...await readWorkspaceDeploymentInput(context), detailedDiff: true };
581
+ const input = { ...await readWorkspaceDeploymentInput(context), detailedDiff: true,
582
+ onProgress: readBoolFlag(context.args, ['json']) ? undefined : context.println };
567
583
  const preview = await buildMigrationPlan(input);
568
584
  const reviewedFile = readFlag(context.args, ['reviewed-plan']);
569
585
  if (reviewedFile) {
@@ -588,6 +604,7 @@ export async function handleDeployCommand(context) {
588
604
  if (!preview.readyToMigrate)
589
605
  throw new Error(`Deployment plan is blocked by ${preview.blockers.length} issue(s).`);
590
606
  await confirmDeploy(context);
607
+ updateWorkspaceDigests(context.cwd);
591
608
  const startedAt = Date.now();
592
609
  const result = await runMigration({ ...input, reviewedPrune: preview.prune, reviewedPlan: preview });
593
610
  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 {
@@ -1042,13 +1052,14 @@ function projectedDatabaseRecords(pull) {
1042
1052
  }));
1043
1053
  }
1044
1054
  async function planWorkspace(input) {
1055
+ const planStage = (stage, resource, environment, operation) => runMigrationStage(stage, resource, environment, operation, input.onProgress);
1045
1056
  const resources = selectedResources(input);
1046
1057
  const stableKeyName = readProjectStableKeyName(input.cwd);
1047
- const client = resolveTargetClient(input);
1058
+ const client = planningSnapshot(resolveTargetClient(input));
1048
1059
  const environmentKey = targetKey(input);
1049
1060
  const environmentLabel = targetLabel(input);
1050
1061
  const databaseSchemas = resources.includes('database-table')
1051
- ? await runMigrationStage('target plan', 'database-table', environmentLabel, () => buildDatabaseSchemasPlan({
1062
+ ? await planStage('target plan', 'database-table', environmentLabel, () => buildDatabaseSchemasPlan({
1052
1063
  client,
1053
1064
  cwd: input.cwd,
1054
1065
  envName: environmentKey,
@@ -1064,7 +1075,7 @@ async function planWorkspace(input) {
1064
1075
  && Boolean(input.pulls.databaseSchemas)
1065
1076
  && schemaPhase?.needsChanges === true;
1066
1077
  const databaseViews = resources.includes('database-view')
1067
- ? await runMigrationStage('target plan', 'database-view', environmentLabel, () => buildDatabaseViewsPlan({
1078
+ ? await planStage('target plan', 'database-view', environmentLabel, () => buildDatabaseViewsPlan({
1068
1079
  client,
1069
1080
  cwd: input.cwd,
1070
1081
  envName: environmentKey,
@@ -1076,30 +1087,30 @@ async function planWorkspace(input) {
1076
1087
  }))
1077
1088
  : undefined;
1078
1089
  const components = resources.includes('component')
1079
- ? await runMigrationStage('target plan', 'component', environmentLabel, () => buildComponentPlan(componentCommandContext({
1090
+ ? await planStage('target plan', 'component', environmentLabel, () => buildComponentPlan(componentCommandContext({
1080
1091
  cwd: input.cwd,
1081
1092
  envName: componentTargetEnvironment(input),
1082
1093
  client,
1083
1094
  operation: 'plan',
1084
1095
  }), undefined, input.detailedDiff === true))
1085
1096
  : undefined;
1086
- const identities = await planIdentityMigration({ client, cwd: input.cwd, stableKeyName, resources });
1097
+ const identities = await runMigrationStage('identity plan', 'group', environmentLabel, () => planIdentityMigration({ client, cwd: input.cwd, stableKeyName, resources }), input.onProgress);
1087
1098
  if (input.prune && input.sourceMode !== 'workspace')
1088
1099
  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;
1100
+ const prune = input.prune ? await runMigrationStage('prune plan', 'component', environmentLabel, () => buildWorkspacePrunePlan({ cwd: input.cwd, client, resources, captureTargets: true }), input.onProgress) : undefined;
1090
1101
  const serviceAccounts = resources.includes('service-account')
1091
- ? await runMigrationStage('target plan', 'service-account', environmentLabel, () => buildServiceAccountsPlan({ client, cwd: input.cwd, envName: environmentKey, stableKeyName,
1102
+ ? await planStage('target plan', 'service-account', environmentLabel, () => buildServiceAccountsPlan({ client, cwd: input.cwd, envName: environmentKey, stableKeyName,
1092
1103
  projectedIdentities: identities?.projection })) : undefined;
1093
1104
  if (serviceAccounts && identities) {
1094
1105
  serviceAccounts.blockers.push(...identities.blockers);
1095
1106
  }
1096
1107
  const projected = { component: input.projectDependencies && components ? components.items.filter(item => !item.blocked && ['create', 'update'].includes(componentItemAction(item))).flatMap(item => item.stableKey ? [item.stableKey] : []) : [],
1097
1108
  '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,
1109
+ 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;
1110
+ const agents = resources.includes('agent') ? await planStage('target plan', 'agent', environmentLabel, () => buildAgentsPlan({ client, cwd: input.cwd, envName: environmentKey, stableKeyName, family: 'agent', projected: { ...projected,
1100
1111
  'agent-plugin': agentPlugins?.items.filter(item => !item.blocked && item.desiredHash).flatMap(item => item.stableKey ? [item.stableKey] : []) || [] } })) : undefined;
1101
1112
  const jobTemplates = resources.includes('job-template')
1102
- ? await runMigrationStage('target plan', 'job-template', environmentLabel, () => buildJobTemplatesPlan({
1113
+ ? await planStage('target plan', 'job-template', environmentLabel, () => buildJobTemplatesPlan({
1103
1114
  client,
1104
1115
  cwd: input.cwd,
1105
1116
  envName: environmentKey,
@@ -1112,7 +1123,7 @@ async function planWorkspace(input) {
1112
1123
  }))
1113
1124
  : undefined;
1114
1125
  const endpoints = resources.includes('endpoint')
1115
- ? await runMigrationStage('target plan', 'endpoint', environmentLabel, () => buildEndpointsPlan({
1126
+ ? await planStage('target plan', 'endpoint', environmentLabel, () => buildEndpointsPlan({
1116
1127
  client,
1117
1128
  cwd: input.cwd,
1118
1129
  envName: environmentKey,
@@ -1125,7 +1136,7 @@ async function planWorkspace(input) {
1125
1136
  }))
1126
1137
  : undefined;
1127
1138
  const schedules = resources.includes('schedule')
1128
- ? await runMigrationStage('target plan', 'schedule', environmentLabel, () => buildSchedulesPlan({
1139
+ ? await planStage('target plan', 'schedule', environmentLabel, () => buildSchedulesPlan({
1129
1140
  client,
1130
1141
  cwd: input.cwd,
1131
1142
  envName: environmentKey,
@@ -1139,7 +1150,7 @@ async function planWorkspace(input) {
1139
1150
  }))
1140
1151
  : undefined;
1141
1152
  const events = resources.includes('event')
1142
- ? await runMigrationStage('target plan', 'event', environmentLabel, () => buildEventsPlan({
1153
+ ? await planStage('target plan', 'event', environmentLabel, () => buildEventsPlan({
1143
1154
  client,
1144
1155
  cwd: input.cwd,
1145
1156
  envName: environmentKey,
@@ -1150,7 +1161,7 @@ async function planWorkspace(input) {
1150
1161
  }))
1151
1162
  : undefined;
1152
1163
  const groups = resources.includes('group')
1153
- ? await runMigrationStage('target plan', 'group', environmentLabel, () => buildGroupsPlan({
1164
+ ? await planStage('target plan', 'group', environmentLabel, () => buildGroupsPlan({
1154
1165
  client,
1155
1166
  cwd: input.cwd,
1156
1167
  envName: environmentKey,
@@ -1162,7 +1173,7 @@ async function planWorkspace(input) {
1162
1173
  groups.blockers.push(...identities.blockers);
1163
1174
  }
1164
1175
  const roleGroups = resources.includes('role-group')
1165
- ? await runMigrationStage('target plan', 'role-group', environmentLabel, () => buildRoleGroupsPlan({
1176
+ ? await planStage('target plan', 'role-group', environmentLabel, () => buildRoleGroupsPlan({
1166
1177
  client,
1167
1178
  cwd: input.cwd,
1168
1179
  envName: environmentKey,
@@ -1297,6 +1308,7 @@ export async function runMigration(input) {
1297
1308
  return { ...base, verdict: 'blocked', results: [], phaseResults: {} };
1298
1309
  }
1299
1310
  const targetClient = resolveTargetClient(input);
1311
+ const deployStage = (resource, operation) => runMigrationStage('target deploy', resource, targetLabel(input), operation, input.onProgress);
1300
1312
  const environmentKey = targetKey(input);
1301
1313
  const phaseResults = {};
1302
1314
  const results = [];
@@ -1312,7 +1324,7 @@ export async function runMigration(input) {
1312
1324
  remainingPrune = { ...remainingPrune, items: remainingPrune.items.filter((item) => !item.beforeUpserts) };
1313
1325
  }
1314
1326
  if (resources.includes('database-table')) {
1315
- const pushed = await pushDatabaseSchemas({
1327
+ const pushed = await deployStage('database-table', () => pushDatabaseSchemas({
1316
1328
  client: targetClient,
1317
1329
  cwd: input.cwd,
1318
1330
  envName: environmentKey,
@@ -1321,17 +1333,17 @@ export async function runMigration(input) {
1321
1333
  prunePartitions: reviewedWorkspaceChanges && !input.prune,
1322
1334
  prunePartitionsConfirmed: reviewedWorkspaceChanges && !input.prune,
1323
1335
  migrationPolicy: migrationPolicy(input),
1324
- });
1336
+ }));
1325
1337
  phaseResults['database-table'] = pushed.results;
1326
1338
  results.push(...pushed.results);
1327
- const schemaVerification = await buildDatabaseSchemasPlan({
1339
+ const schemaVerification = await runMigrationStage('target plan', 'database-table', targetLabel(input), () => buildDatabaseSchemasPlan({
1328
1340
  client: targetClient,
1329
1341
  cwd: input.cwd,
1330
1342
  envName: environmentKey,
1331
1343
  stableKeyName,
1332
1344
  withStats: input.withStats,
1333
1345
  migrationPolicy: migrationPolicy(input),
1334
- });
1346
+ }), input.onProgress);
1335
1347
  const schemaPhase = applyWorkspaceDeploymentPolicy(input, summarizeSchemaPhase(schemaVerification), {
1336
1348
  databaseSchemas: schemaVerification,
1337
1349
  });
@@ -1355,13 +1367,13 @@ export async function runMigration(input) {
1355
1367
  }
1356
1368
  }
1357
1369
  if (resources.includes('database-view')) {
1358
- const liveViewPlan = await buildDatabaseViewsPlan({
1370
+ const liveViewPlan = await runMigrationStage('target plan', 'database-view', targetLabel(input), () => buildDatabaseViewsPlan({
1359
1371
  client: targetClient,
1360
1372
  cwd: input.cwd,
1361
1373
  envName: environmentKey,
1362
1374
  stableKeyName,
1363
1375
  migrationPolicy: viewMigrationPolicy(input),
1364
- });
1376
+ }), input.onProgress);
1365
1377
  const liveViewPhase = applyWorkspaceDeploymentPolicy(input, summarizeViewPhase(liveViewPlan), {
1366
1378
  databaseViews: liveViewPlan,
1367
1379
  });
@@ -1373,14 +1385,14 @@ export async function runMigration(input) {
1373
1385
  });
1374
1386
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1375
1387
  }
1376
- const pushed = await pushDatabaseViews({
1388
+ const pushed = await deployStage('database-view', () => pushDatabaseViews({
1377
1389
  client: targetClient,
1378
1390
  cwd: input.cwd,
1379
1391
  envName: environmentKey,
1380
1392
  stableKeyName,
1381
1393
  force: true,
1382
1394
  migrationPolicy: viewMigrationPolicy(input),
1383
- });
1395
+ }));
1384
1396
  phaseResults['database-view'] = pushed.results;
1385
1397
  results.push(...pushed.results);
1386
1398
  }
@@ -1400,13 +1412,13 @@ export async function runMigration(input) {
1400
1412
  });
1401
1413
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1402
1414
  }
1403
- const componentResults = await pushAllComponents(componentCommandContext({
1415
+ const componentResults = await deployStage('component', () => pushAllComponents(componentCommandContext({
1404
1416
  cwd: input.cwd,
1405
1417
  envName: componentTargetEnvironment(input),
1406
1418
  client: targetClient,
1407
1419
  operation: 'push',
1408
1420
  ...(input.reviewedPlan ? { reviewedComponents: initialPlan.components?.items } : {}),
1409
- }), { force: true, yes: true });
1421
+ }), { force: true, yes: true }));
1410
1422
  phaseResults.component = componentResults;
1411
1423
  results.push(...componentResults);
1412
1424
  if (!componentResultsAreComplete(componentResults)) {
@@ -1441,7 +1453,7 @@ export async function runMigration(input) {
1441
1453
  for (const node of identityRun.ordered) {
1442
1454
  const pushed = node.resource === 'service-account'
1443
1455
  ? 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] });
1456
+ : await deployStage('group', () => pushGroups({ client: targetClient, cwd: input.cwd, envName: environmentKey, stableKeyName, force: true, onlyStableKeys: [node.stableKey] }));
1445
1457
  const relevant = pushed.results.filter((item) => item.stableKey === node.stableKey);
1446
1458
  phaseResults[node.resource] = [...(phaseResults[node.resource] || []), ...relevant];
1447
1459
  results.push(...relevant);
@@ -1461,19 +1473,19 @@ export async function runMigration(input) {
1461
1473
  }
1462
1474
  for (const family of ['agent-plugin', 'agent'])
1463
1475
  if (resources.includes(family)) {
1464
- const pushed = await pushAgents({ client: targetClient, cwd: input.cwd, envName: environmentKey, stableKeyName, family, force: true });
1476
+ const pushed = await deployStage(family, () => pushAgents({ client: targetClient, cwd: input.cwd, envName: environmentKey, stableKeyName, family, force: true }));
1465
1477
  phaseResults[family] = pushed.results;
1466
1478
  results.push(...pushed.results);
1467
1479
  if (!resultsAreComplete(pushed.results))
1468
1480
  return { ...base, verdict: 'failed', results, phaseResults };
1469
1481
  }
1470
1482
  if (resources.includes('job-template')) {
1471
- const liveJobTemplatePlan = await buildJobTemplatesPlan({
1483
+ const liveJobTemplatePlan = await runMigrationStage('target plan', 'job-template', targetLabel(input), () => buildJobTemplatesPlan({
1472
1484
  client: targetClient,
1473
1485
  cwd: input.cwd,
1474
1486
  envName: environmentKey,
1475
1487
  stableKeyName,
1476
- });
1488
+ }), input.onProgress);
1477
1489
  const liveJobTemplatePhase = summarizeJobTemplatePhase(liveJobTemplatePlan);
1478
1490
  if (!liveJobTemplatePhase.readyToMigrate) {
1479
1491
  const verification = await planWorkspace({
@@ -1483,13 +1495,13 @@ export async function runMigration(input) {
1483
1495
  });
1484
1496
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1485
1497
  }
1486
- const pushed = await pushJobTemplates({
1498
+ const pushed = await deployStage('job-template', () => pushJobTemplates({
1487
1499
  client: targetClient,
1488
1500
  cwd: input.cwd,
1489
1501
  envName: environmentKey,
1490
1502
  stableKeyName,
1491
1503
  force: true,
1492
- });
1504
+ }));
1493
1505
  phaseResults['job-template'] = pushed.results;
1494
1506
  results.push(...pushed.results);
1495
1507
  if (!jobTemplateResultsAreComplete(pushed.results)) {
@@ -1502,13 +1514,13 @@ export async function runMigration(input) {
1502
1514
  }
1503
1515
  }
1504
1516
  if (resources.includes('endpoint')) {
1505
- const liveEndpointPlan = await buildEndpointsPlan({
1517
+ const liveEndpointPlan = await runMigrationStage('target plan', 'endpoint', targetLabel(input), () => buildEndpointsPlan({
1506
1518
  client: targetClient,
1507
1519
  cwd: input.cwd,
1508
1520
  envName: environmentKey,
1509
1521
  stableKeyName,
1510
1522
  includeDependencyBlockers: input.sourceMode === 'workspace',
1511
- });
1523
+ }), input.onProgress);
1512
1524
  const liveEndpointPhase = summarizeEndpointPhase(liveEndpointPlan);
1513
1525
  if (!liveEndpointPhase.readyToMigrate) {
1514
1526
  const verification = await planWorkspace({
@@ -1518,13 +1530,13 @@ export async function runMigration(input) {
1518
1530
  });
1519
1531
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1520
1532
  }
1521
- const pushed = await pushEndpoints({
1533
+ const pushed = await deployStage('endpoint', () => pushEndpoints({
1522
1534
  client: targetClient,
1523
1535
  cwd: input.cwd,
1524
1536
  envName: environmentKey,
1525
1537
  stableKeyName,
1526
1538
  force: true,
1527
- });
1539
+ }));
1528
1540
  phaseResults.endpoint = pushed.results;
1529
1541
  results.push(...pushed.results);
1530
1542
  if (!endpointResultsAreComplete(pushed.results)) {
@@ -1537,12 +1549,12 @@ export async function runMigration(input) {
1537
1549
  }
1538
1550
  }
1539
1551
  if (resources.includes('schedule')) {
1540
- const liveSchedulePlan = await buildSchedulesPlan({
1552
+ const liveSchedulePlan = await runMigrationStage('target plan', 'schedule', targetLabel(input), () => buildSchedulesPlan({
1541
1553
  client: targetClient,
1542
1554
  cwd: input.cwd,
1543
1555
  envName: environmentKey,
1544
1556
  stableKeyName,
1545
- });
1557
+ }), input.onProgress);
1546
1558
  const liveSchedulePhase = applyWorkspaceDeploymentPolicy(input, summarizeSchedulePhase(liveSchedulePlan), {
1547
1559
  schedules: liveSchedulePlan,
1548
1560
  });
@@ -1554,13 +1566,13 @@ export async function runMigration(input) {
1554
1566
  });
1555
1567
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1556
1568
  }
1557
- const pushed = await pushSchedules({
1569
+ const pushed = await deployStage('schedule', () => pushSchedules({
1558
1570
  client: targetClient,
1559
1571
  cwd: input.cwd,
1560
1572
  envName: environmentKey,
1561
1573
  stableKeyName,
1562
1574
  force: true,
1563
- });
1575
+ }));
1564
1576
  pendingSchedules.push(...pushed.verifiedActivationCandidates);
1565
1577
  phaseResults.schedule = pushed.results;
1566
1578
  results.push(...pushed.results);
@@ -1574,12 +1586,12 @@ export async function runMigration(input) {
1574
1586
  }
1575
1587
  }
1576
1588
  if (resources.includes('event')) {
1577
- const liveEventPlan = await buildEventsPlan({
1589
+ const liveEventPlan = await runMigrationStage('target plan', 'event', targetLabel(input), () => buildEventsPlan({
1578
1590
  client: targetClient,
1579
1591
  cwd: input.cwd,
1580
1592
  envName: environmentKey,
1581
1593
  stableKeyName,
1582
- });
1594
+ }), input.onProgress);
1583
1595
  const liveEventPhase = summarizeEventPhase(liveEventPlan);
1584
1596
  if (!liveEventPhase.readyToMigrate) {
1585
1597
  const verification = await planWorkspace({
@@ -1589,13 +1601,13 @@ export async function runMigration(input) {
1589
1601
  });
1590
1602
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1591
1603
  }
1592
- const pushed = await pushEvents({
1604
+ const pushed = await deployStage('event', () => pushEvents({
1593
1605
  client: targetClient,
1594
1606
  cwd: input.cwd,
1595
1607
  envName: environmentKey,
1596
1608
  stableKeyName,
1597
1609
  force: true,
1598
- });
1610
+ }));
1599
1611
  pendingEvents.push(...pushed.verifiedActivationCandidates);
1600
1612
  phaseResults.event = pushed.results;
1601
1613
  results.push(...pushed.results);
@@ -1609,12 +1621,12 @@ export async function runMigration(input) {
1609
1621
  }
1610
1622
  }
1611
1623
  if (resources.includes('group')) {
1612
- const liveGroupPlan = await buildGroupsPlan({
1624
+ const liveGroupPlan = await runMigrationStage('target plan', 'group', targetLabel(input), () => buildGroupsPlan({
1613
1625
  client: targetClient,
1614
1626
  cwd: input.cwd,
1615
1627
  envName: environmentKey,
1616
1628
  stableKeyName,
1617
- });
1629
+ }), input.onProgress);
1618
1630
  const liveGroupPhase = applyWorkspaceDeploymentPolicy(input, summarizeGroupPhase(liveGroupPlan), {
1619
1631
  groups: liveGroupPlan,
1620
1632
  });
@@ -1626,13 +1638,13 @@ export async function runMigration(input) {
1626
1638
  });
1627
1639
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1628
1640
  }
1629
- const pushed = await pushGroups({
1641
+ const pushed = await deployStage('group', () => pushGroups({
1630
1642
  client: targetClient,
1631
1643
  cwd: input.cwd,
1632
1644
  envName: environmentKey,
1633
1645
  stableKeyName,
1634
1646
  force: true,
1635
- });
1647
+ }));
1636
1648
  const groupRemaining = pushed.results.filter((item) => !(phaseResults.group || []).some((prior) => 'stableKey' in prior && prior.stableKey === item.stableKey));
1637
1649
  phaseResults.group = [...(phaseResults.group || []), ...groupRemaining];
1638
1650
  results.push(...groupRemaining);
@@ -1646,12 +1658,12 @@ export async function runMigration(input) {
1646
1658
  }
1647
1659
  }
1648
1660
  if (resources.includes('role-group')) {
1649
- const liveRoleGroupPlan = await buildRoleGroupsPlan({
1661
+ const liveRoleGroupPlan = await runMigrationStage('target plan', 'role-group', targetLabel(input), () => buildRoleGroupsPlan({
1650
1662
  client: targetClient,
1651
1663
  cwd: input.cwd,
1652
1664
  envName: environmentKey,
1653
1665
  stableKeyName,
1654
- });
1666
+ }), input.onProgress);
1655
1667
  const liveRoleGroupPhase = applyWorkspaceDeploymentPolicy(input, summarizeRoleGroupPhase(liveRoleGroupPlan), {
1656
1668
  roleGroups: liveRoleGroupPlan,
1657
1669
  });
@@ -1663,13 +1675,13 @@ export async function runMigration(input) {
1663
1675
  });
1664
1676
  return { ...base, verdict: 'failed', results, phaseResults, verification };
1665
1677
  }
1666
- const pushed = await pushRoleGroups({
1678
+ const pushed = await deployStage('role-group', () => pushRoleGroups({
1667
1679
  client: targetClient,
1668
1680
  cwd: input.cwd,
1669
1681
  envName: environmentKey,
1670
1682
  stableKeyName,
1671
1683
  force: true,
1672
- });
1684
+ }));
1673
1685
  phaseResults['role-group'] = pushed.results;
1674
1686
  results.push(...pushed.results);
1675
1687
  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
@@ -180,6 +180,7 @@ function renderCommandCatalog() {
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
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 plan update [--json]', 'Update the local Stable Key source digest index without contacting the target'),
183
184
  commandRow('revo deploy [--yes] [--activate] [--prune] [--reviewed-plan file] [--force] [--json]', 'Review, confirm, deploy and prune tracked resources in dependency order'),
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'),
@@ -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.27",
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",