@revoengine/cli 1.0.33 → 1.0.34

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +83 -6
  3. package/dist/src/argument-contract.d.ts +17 -0
  4. package/dist/src/argument-contract.js +359 -0
  5. package/dist/src/automation-contract.generated.d.ts +2 -2
  6. package/dist/src/automation-contract.generated.js +2 -2
  7. package/dist/src/cli.js +15 -13
  8. package/dist/src/client.d.ts +2 -0
  9. package/dist/src/client.js +22 -0
  10. package/dist/src/commands/agents.js +5 -1
  11. package/dist/src/commands/auth.js +2 -0
  12. package/dist/src/commands/component.js +34 -17
  13. package/dist/src/commands/database-tables.js +5 -1
  14. package/dist/src/commands/database-views.js +5 -1
  15. package/dist/src/commands/endpoints.js +5 -1
  16. package/dist/src/commands/env.js +5 -1
  17. package/dist/src/commands/events.js +5 -1
  18. package/dist/src/commands/groups.js +5 -1
  19. package/dist/src/commands/info.js +2 -0
  20. package/dist/src/commands/job-templates.js +5 -1
  21. package/dist/src/commands/metadata.js +2 -0
  22. package/dist/src/commands/migrate.d.ts +2 -2
  23. package/dist/src/commands/migrate.js +31 -7
  24. package/dist/src/commands/project.js +19 -14
  25. package/dist/src/commands/request.js +2 -0
  26. package/dist/src/commands/role-groups.js +5 -1
  27. package/dist/src/commands/schedules.js +5 -1
  28. package/dist/src/commands/search.js +2 -0
  29. package/dist/src/commands/service-accounts.js +5 -1
  30. package/dist/src/commands/studio.js +2 -0
  31. package/dist/src/commands/terminal-file-descriptor.d.ts +9 -0
  32. package/dist/src/commands/terminal-file-descriptor.js +39 -0
  33. package/dist/src/commands/terminal-file.js +41 -6
  34. package/dist/src/commands/terminal-image.js +3 -31
  35. package/dist/src/commands/terminal-process-group.d.ts +25 -0
  36. package/dist/src/commands/terminal-process-group.js +144 -0
  37. package/dist/src/commands/terminal.js +123 -40
  38. package/dist/src/commands/tests.js +2 -0
  39. package/dist/src/component-lock.d.ts +15 -1
  40. package/dist/src/component-lock.js +96 -10
  41. package/dist/src/env-sync.js +12 -6
  42. package/dist/src/migration.d.ts +7 -0
  43. package/dist/src/migration.js +39 -21
  44. package/dist/src/planning-snapshot.d.ts +3 -0
  45. package/dist/src/planning-snapshot.js +60 -2
  46. package/dist/src/project.d.ts +1 -0
  47. package/dist/src/project.js +7 -8
  48. package/dist/src/resource-syncs/agent-sync.js +76 -24
  49. package/dist/src/resource-syncs/database-table-sync.js +33 -22
  50. package/dist/src/resource-syncs/database-view-sync.js +41 -28
  51. package/dist/src/resource-syncs/endpoint-sync.js +90 -18
  52. package/dist/src/resource-syncs/event-sync.js +33 -14
  53. package/dist/src/resource-syncs/group-sync.js +21 -11
  54. package/dist/src/resource-syncs/job-template-sync.js +98 -37
  55. package/dist/src/resource-syncs/role-group-sync.js +22 -11
  56. package/dist/src/resource-syncs/schedule-sync.js +26 -11
  57. package/dist/src/resource-syncs/service-account-sync.js +22 -11
  58. package/dist/src/reviewed-plan.js +3 -0
  59. package/dist/src/runtime-view.js +2 -18
  60. package/dist/src/sync-omit-command.d.ts +6 -0
  61. package/dist/src/sync-omit-command.js +49 -0
  62. package/dist/src/sync-omit-write-fence.d.ts +10 -0
  63. package/dist/src/sync-omit-write-fence.js +134 -0
  64. package/dist/src/sync-omit.d.ts +59 -0
  65. package/dist/src/sync-omit.js +469 -0
  66. package/dist/src/ui.js +10 -5
  67. package/dist/src/update-notifier.d.ts +1 -1
  68. package/dist/src/update-notifier.js +2 -1
  69. package/dist/src/utils.js +46 -17
  70. package/dist/src/workspace-prune.js +11 -3
  71. package/dist/src/workspace-write-lock.d.ts +7 -0
  72. package/dist/src/workspace-write-lock.js +144 -0
  73. package/package.json +3 -2
@@ -1,3 +1,4 @@
1
+ import { hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit, omitPaths, assertOmittedPropertiesPreserved } from "../sync-omit.js";
1
2
  import { normalizeDatabaseIndexes, databaseIndexPayload, databaseIndexReferences } from "../database-indexes.js";
2
3
  import path from 'node:path';
3
4
  import { describeFieldChanges, unifiedLineDiff } from "../diff-details.js";
@@ -130,7 +131,7 @@ function validManifest(value, stableKeyName) {
130
131
  return stableKeyOf(value, stableKeyName) === value.stableKey;
131
132
  }
132
133
  export function hashPortableDatabaseView(manifest) {
133
- return hashStable(canonicalValue({
134
+ return hashSyncDefinition('database-view', canonicalValue({
134
135
  ...manifest,
135
136
  ...(manifest.type === 'MATERIALIZED_VIEW' ? { indexes: normalizeDatabaseIndexes(manifest.indexes) } : {}),
136
137
  sources: [...manifest.sources].sort((left, right) => (left.databaseStableKey.localeCompare(right.databaseStableKey)
@@ -575,7 +576,7 @@ export async function buildDatabaseViewsPlan(input) {
575
576
  continue;
576
577
  }
577
578
  const entry = entries[0];
578
- const desired = entry.manifest;
579
+ let desired = entry.manifest;
579
580
  const desiredHash = hashPortableDatabaseView(desired);
580
581
  const comparableRecords = targetByKey.get(stableKey) || [];
581
582
  const comparableTarget = comparableRecords.length === 1
@@ -601,6 +602,8 @@ export async function buildDatabaseViewsPlan(input) {
601
602
  items.push({ status: 'conflict', stableKey, name: desired.name, reason: sourceReadiness, desiredHash, ...rawQueryDetail });
602
603
  continue;
603
604
  }
605
+ if (comparableTarget && typeof comparableTarget !== 'string')
606
+ desired = preserveOmittedProperties('database-view', desired, comparableTarget);
604
607
  const currentDetails = comparableTarget && typeof comparableTarget !== 'string'
605
608
  ? {
606
609
  currentHash: hashPortableDatabaseView(comparableTarget),
@@ -611,7 +614,7 @@ export async function buildDatabaseViewsPlan(input) {
611
614
  const baseline = lock.databaseViews[stableKey]?.environments[input.envName];
612
615
  const dependencyHash = databaseViewDependencyHash(desired, input.dependencyDatabases || targetDatabases, input.stableKeyName);
613
616
  const unchanged = currentDetails.currentHash === desiredHash
614
- && baseline?.remoteHash === desiredHash
617
+ && syncBaselineHash('database-view', baseline) === desiredHash
615
618
  && dependencyHash !== undefined && baseline.dependencyHash === dependencyHash;
616
619
  if (input.migrationPolicy?.deferPreview === true) {
617
620
  warnings.push(`Database View "${stableKey}" TARGET preview is deferred until Database Table migration completes.`);
@@ -683,7 +686,7 @@ export async function buildDatabaseViewsPlan(input) {
683
686
  }
684
687
  }
685
688
  const currentHash = hashPortableDatabaseView(current);
686
- const baselineHash = lock.databaseViews[stableKey]?.environments[input.envName]?.remoteHash;
689
+ const baselineHash = syncBaselineHash('database-view', lock.databaseViews[stableKey]?.environments[input.envName]);
687
690
  if (desiredHash === currentHash) {
688
691
  items.push({
689
692
  status: baselineHash ? 'clean' : 'missing-lock',
@@ -712,7 +715,7 @@ export async function buildDatabaseViewsPlan(input) {
712
715
  });
713
716
  continue;
714
717
  }
715
- const localChanged = hashDatabaseViewManifest(desired) !== lock.databaseViews[stableKey]?.sourceHash;
718
+ const localChanged = hashDatabaseViewManifest(desired) !== syncSourceBaselineHash('database-view', lock.databaseViews[stableKey]);
716
719
  const targetChanged = currentHash !== baselineHash;
717
720
  const status = localChanged && targetChanged ? 'conflict' : targetChanged ? 'remote-changed' : 'safe-update';
718
721
  items.push({
@@ -840,12 +843,12 @@ function verifyCreatedDatabaseView(input) {
840
843
  if (typeof actual === 'string') {
841
844
  throw new Error(actual);
842
845
  }
843
- const desiredHash = hashPortableDatabaseView(input.desired);
844
- const remoteHash = hashPortableDatabaseView(actual);
846
+ const desiredHash = withoutSyncOmit(() => hashPortableDatabaseView(input.desired));
847
+ const remoteHash = withoutSyncOmit(() => hashPortableDatabaseView(actual));
845
848
  if (remoteHash !== desiredHash) {
846
849
  throw new Error(`created target did not match desired portable hash (desired: ${desiredHash}; actual: ${remoteHash})`);
847
850
  }
848
- return remoteHash;
851
+ return hashPortableDatabaseView(actual);
849
852
  }
850
853
  function targetPrincipalIds(entries, property) {
851
854
  const ids = [];
@@ -870,31 +873,32 @@ function updateDatabaseViewPayload(input) {
870
873
  throw new Error('TARGET version is unavailable for optimistic update');
871
874
  }
872
875
  const version = input.target.version;
876
+ const manifest = preserveOmittedProperties('database-view', input.manifest, { ...input.manifest, name: input.target.name, category: input.target.category, description: input.target.desc, metadata: input.target.metadata });
873
877
  const base = {
874
- name: input.manifest.name,
875
- category: input.manifest.category ?? null,
876
- desc: input.manifest.description ?? null,
877
- metadata: sanitizeUserMetadata(input.manifest.metadata),
878
- type: input.manifest.type,
878
+ name: manifest.name,
879
+ category: manifest.category ?? null,
880
+ desc: manifest.description ?? null,
881
+ metadata: sanitizeUserMetadata(manifest.metadata),
882
+ type: manifest.type,
879
883
  restricted: input.target.restricted,
880
884
  users: targetPrincipalIds(input.target.users, 'userId'),
881
885
  groups: targetPrincipalIds(input.target.groups, 'groupId'),
882
886
  version,
883
- ...(input.manifest.type === 'MATERIALIZED_VIEW'
884
- ? { uniqueKey: input.manifest.uniqueKey, indexes: databaseViewWriteIndexes(input.manifest.indexes) }
887
+ ...(manifest.type === 'MATERIALIZED_VIEW'
888
+ ? { uniqueKey: manifest.uniqueKey, indexes: databaseViewWriteIndexes(manifest.indexes) }
885
889
  : {}),
886
890
  };
887
- if (input.manifest.definitionMode === 'RAW_SQL') {
891
+ if (manifest.definitionMode === 'RAW_SQL') {
888
892
  return {
889
893
  ...base,
890
894
  definitionMode: 'RAW_SQL',
891
- rawQuery: input.manifest.rawQuery,
895
+ rawQuery: manifest.rawQuery,
892
896
  };
893
897
  }
894
898
  return {
895
899
  ...base,
896
900
  definitionMode: 'STRUCTURED',
897
- request: canonicalValue(input.manifest.request),
901
+ request: canonicalValue(manifest.request),
898
902
  };
899
903
  }
900
904
  function verifyUpdatedDatabaseView(input) {
@@ -920,6 +924,12 @@ function verifyUpdatedDatabaseView(input) {
920
924
  if (typeof actual === 'string') {
921
925
  throw new Error(actual);
922
926
  }
927
+ if (input.previous && omitPaths('database-view').length) {
928
+ const previous = manifestFromRecord({ record: input.previous, stableKey: input.desired.stableKey, stableKeyName: input.stableKeyName, inventory: sourceInventory(input.databases, input.stableKeyName) });
929
+ if (typeof previous === 'string')
930
+ throw new Error(previous);
931
+ assertOmittedPropertiesPreserved('database-view', previous, actual);
932
+ }
923
933
  const remoteHash = hashPortableDatabaseView(actual);
924
934
  const desiredHash = hashPortableDatabaseView(input.desired);
925
935
  if (remoteHash !== desiredHash) {
@@ -948,7 +958,7 @@ async function recheckDatabaseViewUpdate(input) {
948
958
  && input.migrationPolicy?.allowDestructive !== true) {
949
959
  throw new Error('TARGET Database View changed type or definitionMode after planning');
950
960
  }
951
- if (target.name !== input.manifest.name && input.migrationPolicy?.sourceWins !== true) {
961
+ if (target.name !== input.manifest.name && !omitPaths('database-view').some(path => path.length === 1 && path[0] === 'name') && input.migrationPolicy?.sourceWins !== true) {
952
962
  throw new Error('TARGET name differs; renames require an explicit migration');
953
963
  }
954
964
  const sourceReadiness = validateTargetSources(input.manifest, databaseResult.databases, input.stableKeyName);
@@ -978,7 +988,7 @@ function updateDatabaseViewEnvironmentBaseline(input) {
978
988
  const entry = {
979
989
  stableKey: input.manifest.stableKey,
980
990
  path: toPortableRelativePath(projectRoot, input.manifestPath),
981
- sourceHash: hashDatabaseViewManifest(input.manifest),
991
+ sourceHash: withoutSyncOmit(() => hashDatabaseViewManifest(input.manifest)),
982
992
  environments: {
983
993
  ...(existing?.environments || {}),
984
994
  [input.envName]: {
@@ -1131,6 +1141,7 @@ export async function pushDatabaseViews(input) {
1131
1141
  databases: live.databases,
1132
1142
  desired,
1133
1143
  stableKeyName: input.stableKeyName,
1144
+ previous: live.target,
1134
1145
  expectedRestricted: payload.restricted,
1135
1146
  expectedUsers: payload.users,
1136
1147
  expectedGroups: payload.groups,
@@ -1190,6 +1201,7 @@ export async function pushDatabaseViews(input) {
1190
1201
  databases: live.databases,
1191
1202
  desired: local.manifest,
1192
1203
  stableKeyName: input.stableKeyName,
1204
+ previous: live.target,
1193
1205
  expectedRestricted: accessPolicy.restricted,
1194
1206
  expectedUsers: accessPolicy.users,
1195
1207
  expectedGroups: accessPolicy.groups,
@@ -1283,20 +1295,21 @@ export async function pullDatabaseViewsToWorkspace(input) {
1283
1295
  existingByKey.set(entry.manifest.stableKey, entry);
1284
1296
  existingByPath.set(path.resolve(entry.manifestPath), entry);
1285
1297
  }
1286
- const writes = manifests.map((manifest) => {
1287
- const existing = existingByKey.get(manifest.stableKey);
1288
- const sourceHash = hashDatabaseViewManifest(manifest);
1298
+ const writes = manifests.map((sourceManifest) => {
1299
+ const existing = existingByKey.get(sourceManifest.stableKey);
1300
+ const remoteHash = hashPortableDatabaseView(sourceManifest);
1289
1301
  if (existing && !input.force) {
1290
1302
  const localHash = hashDatabaseViewManifest(existing.manifest);
1291
- const baseline = lock.databaseViews[manifest.stableKey];
1292
- if (localHash !== sourceHash && (!baseline || localHash !== baseline.sourceHash)) {
1293
- throw new Error(`Cannot pull Database View "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
1303
+ const baseline = lock.databaseViews[sourceManifest.stableKey];
1304
+ if (localHash !== remoteHash && localHash !== syncSourceBaselineHash('database-view', baseline)) {
1305
+ throw new Error(`Cannot pull Database View "${sourceManifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
1294
1306
  }
1295
1307
  }
1308
+ const manifest = preserveOmittedProperties('database-view', sourceManifest, existing?.manifest);
1296
1309
  return {
1297
1310
  manifest,
1298
- sourceHash,
1299
- remoteHash: hashPortableDatabaseView(manifest),
1311
+ sourceHash: withoutSyncOmit(() => hashDatabaseViewManifest(manifest)),
1312
+ remoteHash,
1300
1313
  filePath: databaseViewManifestPath(workspaceRoot, manifest),
1301
1314
  previousPath: existing?.manifestPath,
1302
1315
  };
@@ -1,3 +1,5 @@
1
+ import { requestContractDefaults } from "../request-contract.js";
2
+ import { assertOmittedPropertiesPreserved, hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit, omitPaths } from "../sync-omit.js";
1
3
  import { loadComponentSources } from "../component-manifests.js";
2
4
  import { componentContentDigest, componentRevisionByDigest, isComponentDigest } from "../component-contract.js";
3
5
  import { executionPrincipalAvailable, portableExecutionPolicy, runtimeExecutionPolicyPayload, validPortableExecutionPolicy } from "./account-principal.js";
@@ -184,7 +186,7 @@ export function hashPortableEndpoint(manifest) {
184
186
  }
185
187
  function endpointDefinitionHash(manifest, normalizeDefaults) {
186
188
  const options = normalizeDefaults ? canonicalPortableOptions(manifest.options) : canonicalValue(manifest.options);
187
- return hashStable({
189
+ return hashSyncDefinition('endpoint', {
188
190
  kind: manifest.kind,
189
191
  stableKey: manifest.stableKey,
190
192
  name: manifest.name,
@@ -398,20 +400,23 @@ export async function pullEndpointsToWorkspace(input) {
398
400
  const identity = portablePathIdentity(entry.manifestPath);
399
401
  existingByPath.set(identity, [...(existingByPath.get(identity) || []), entry]);
400
402
  }
401
- const writes = manifests.map((manifest) => {
402
- const hash = hashPortableEndpoint(manifest);
403
- const existing = existingByKey.get(manifest.stableKey);
403
+ const writes = manifests.map((incoming) => {
404
+ const hash = hashPortableEndpoint(incoming);
405
+ const existing = existingByKey.get(incoming.stableKey);
406
+ const manifest = existing ? preserveOmittedProperties('endpoint', incoming, existing.manifest) : incoming;
407
+ const sourceHash = withoutSyncOmit(() => hashPortableEndpoint(manifest));
404
408
  if (existing && !input.force) {
405
409
  const localHash = hashPortableEndpoint(existing.manifest);
406
410
  const baseline = lock.endpoints[manifest.stableKey];
407
- if (localHash !== hash && (!baseline || localHash !== baseline.sourceHash
408
- && endpointDefinitionHash(existing.manifest, false) !== baseline.sourceHash)) {
411
+ if (localHash !== hash && (!baseline || localHash !== syncSourceBaselineHash('endpoint', baseline)
412
+ && withoutSyncOmit(() => endpointDefinitionHash(existing.manifest, false)) !== baseline.sourceHash)) {
409
413
  throw new Error(`Cannot pull endpoint "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
410
414
  }
411
415
  }
412
416
  return {
413
417
  manifest,
414
418
  hash,
419
+ sourceHash,
415
420
  filePath: endpointManifestPath(workspaceRoot, manifest),
416
421
  ...(existing ? { previousPath: existing.manifestPath } : {}),
417
422
  };
@@ -465,7 +470,7 @@ export async function pullEndpointsToWorkspace(input) {
465
470
  const entry = {
466
471
  stableKey: write.manifest.stableKey,
467
472
  path: toPortableRelativePath(projectRoot, write.filePath),
468
- sourceHash: write.hash,
473
+ sourceHash: write.sourceHash,
469
474
  environments: {
470
475
  ...(previous?.environments || {}),
471
476
  [input.envName]: previousBaseline?.remoteHash === write.hash
@@ -513,6 +518,7 @@ function endpointRecordRouteKey(record) {
513
518
  }
514
519
  }
515
520
  function diffEndpoints(desired, current) {
521
+ desired = preserveOmittedProperties('endpoint', desired, current);
516
522
  const fields = [
517
523
  ['name', desired.name, current.name],
518
524
  ['category', desired.category ?? null, current.category ?? null],
@@ -873,6 +879,12 @@ export async function buildEndpointsPlan(input) {
873
879
  });
874
880
  }
875
881
  }
882
+ for (const [stableKey, entries] of localByStableKey) {
883
+ const targets = liveTargetsByStableKey.get(stableKey) || [];
884
+ if (entries.length === 1 && targets.length === 1) {
885
+ entries[0] = { ...entries[0], manifest: preserveOmittedProperties('endpoint', entries[0].manifest, targets[0].manifest) };
886
+ }
887
+ }
876
888
  const desiredRouteOwners = new Map();
877
889
  const desiredRoutesByStableKey = new Map();
878
890
  for (const [stableKey, entries] of localByStableKey) {
@@ -1047,7 +1059,7 @@ export async function buildEndpointsPlan(input) {
1047
1059
  }
1048
1060
  consumedTargets.add(stableKey);
1049
1061
  const current = targets[0];
1050
- const baselineHash = lock.endpoints[stableKey]?.environments[input.envName]?.remoteHash;
1062
+ const baselineHash = syncBaselineHash('endpoint', lock.endpoints[stableKey]?.environments[input.envName]);
1051
1063
  const common = {
1052
1064
  ...dependencyBlockers,
1053
1065
  stableKey,
@@ -1200,6 +1212,24 @@ async function resolveEndpointWritePayload(input) {
1200
1212
  };
1201
1213
  return common;
1202
1214
  }
1215
+ function assertEndpointOmitWriteSafe(target, desired, options) {
1216
+ if (!omitPaths('endpoint').some(parts => parts[0] === 'options'))
1217
+ return;
1218
+ let normalized = options;
1219
+ if (options) {
1220
+ normalized = { ...requestContractDefaults.endpoint.optionDefaults, ...structuredClone(options), input: options.input ?? {} };
1221
+ if (!normalized.memory)
1222
+ normalized.memory = requestContractDefaults.endpoint.optionDefaults.memory;
1223
+ if (typeof normalized.popResult === 'string')
1224
+ normalized.popResult = `${normalized.popResult.charAt(0).toUpperCase()}${normalized.popResult.slice(1)}`;
1225
+ }
1226
+ try {
1227
+ assertOmittedPropertiesPreserved('endpoint', target, { ...desired, options: normalized });
1228
+ }
1229
+ catch {
1230
+ throw new Error('Endpoint options cannot be updated without normalizing an omitted property; align target defaults or omit the complete options envelope.');
1231
+ }
1232
+ }
1203
1233
  async function updateEndpointConfigurationAndActivation(input) {
1204
1234
  const latest = unwrapData(await input.client.getEndpoint(input.endpointId));
1205
1235
  const latestStableKey = readConfiguredResourceMetadataStableKey(latest, input.stableKeyName);
@@ -1212,20 +1242,51 @@ async function updateEndpointConfigurationAndActivation(input) {
1212
1242
  if (typeof latest.version !== 'number') {
1213
1243
  throw new Error(`${input.targetLabel} did not include a current version`);
1214
1244
  }
1215
- const payload = await resolveEndpointWritePayload(input);
1216
- await input.client.updateEndpoint(input.endpointId, {
1217
- ...payload,
1218
- options: payload.options ?? null,
1219
- version: latest.version,
1220
- });
1221
- const configured = unwrapData(await input.client.getEndpoint(input.endpointId));
1222
- if (Boolean(configured.active) !== input.manifest.active) {
1223
- if (input.manifest.active) {
1245
+ let effectiveManifest = input.manifest;
1246
+ let preservedTargetManifest;
1247
+ let preservationComponents;
1248
+ if (omitPaths('endpoint').length > 0) {
1249
+ const targetComponents = await loadRemoteComponents(input.client, input.cwd);
1250
+ preservationComponents = new Map(targetComponents.map(component => [componentIdOf(component), component]));
1251
+ const currentManifest = await manifestFromRecord({
1252
+ includeExecutionPolicy: input.manifest.executionPolicy !== undefined,
1253
+ client: input.client,
1254
+ record: latest,
1255
+ stableKey: input.stableKey,
1256
+ stableKeyName: input.stableKeyName,
1257
+ componentsById: preservationComponents,
1258
+ });
1259
+ preservedTargetManifest = currentManifest;
1260
+ effectiveManifest = preserveOmittedProperties('endpoint', input.manifest, currentManifest);
1261
+ }
1262
+ const payload = await resolveEndpointWritePayload({ ...input, manifest: effectiveManifest });
1263
+ const runtimePaths = omitPaths('endpoint').filter(parts => parts[0] === 'options');
1264
+ const wholeOptions = runtimePaths.some(parts => parts.length === 1);
1265
+ const schemaChanged = preservedTargetManifest && hashStable(effectiveManifest.schema ?? null) !== hashStable(preservedTargetManifest.schema ?? null);
1266
+ if (wholeOptions && schemaChanged)
1267
+ throw new Error('Endpoint schema binding cannot change while the complete options envelope is omitted; reconcile the binding or narrow --omit before deployment.');
1268
+ const runtimeChanged = !preservedTargetManifest || hashStable(canonicalPortableOptions(effectiveManifest.options)) !== hashStable(canonicalPortableOptions(preservedTargetManifest.options)) || schemaChanged;
1269
+ const { options, ...configuration } = payload;
1270
+ const writeOptions = runtimePaths.length > 0 && !runtimeChanged ? {} : { options: options ?? null };
1271
+ if (Object.hasOwn(writeOptions, 'options') && preservedTargetManifest)
1272
+ assertEndpointOmitWriteSafe(preservedTargetManifest, effectiveManifest, options ?? null);
1273
+ await input.client.updateEndpoint(input.endpointId, { ...configuration, ...writeOptions, version: latest.version });
1274
+ let configured = unwrapData(await input.client.getEndpoint(input.endpointId));
1275
+ if (Boolean(configured.active) !== effectiveManifest.active) {
1276
+ if (effectiveManifest.active) {
1224
1277
  await input.client.activateEndpoint(input.endpointId);
1225
1278
  }
1226
1279
  else {
1227
1280
  await input.client.disableEndpoint(input.endpointId);
1228
1281
  }
1282
+ if (preservedTargetManifest)
1283
+ configured = unwrapData(await input.client.getEndpoint(input.endpointId));
1284
+ }
1285
+ if (preservedTargetManifest) {
1286
+ const verifiedManifest = await manifestFromRecord({ client: input.client, record: configured,
1287
+ stableKey: input.stableKey, stableKeyName: input.stableKeyName,
1288
+ includeExecutionPolicy: input.manifest.executionPolicy !== undefined, componentsById: preservationComponents });
1289
+ assertOmittedPropertiesPreserved('endpoint', preservedTargetManifest, verifiedManifest);
1229
1290
  }
1230
1291
  }
1231
1292
  async function verifyEndpointWrite(input) {
@@ -1244,6 +1305,8 @@ async function verifyEndpointWrite(input) {
1244
1305
  stableKeyName: input.stableKeyName,
1245
1306
  componentsById,
1246
1307
  });
1308
+ if (input.verifyFullSource && !withoutSyncOmit(() => hashPortableEndpoint(verifiedManifest) === hashPortableEndpoint(input.desiredManifest)))
1309
+ throw new Error('Created Endpoint did not initialize the complete source definition.');
1247
1310
  const remoteHash = hashPortableEndpoint(verifiedManifest);
1248
1311
  if (remoteHash !== input.desiredHash) {
1249
1312
  const changedFields = diffEndpoints(input.desiredManifest, verifiedManifest);
@@ -1264,7 +1327,7 @@ function updateEndpointEnvironmentBaseline(input) {
1264
1327
  lock.endpoints[stableKey] = {
1265
1328
  stableKey,
1266
1329
  path: toPortableRelativePath(projectRoot, input.manifestPath),
1267
- sourceHash: hashPortableEndpoint(input.manifest),
1330
+ sourceHash: withoutSyncOmit(() => hashPortableEndpoint(input.manifest)),
1268
1331
  environments: {
1269
1332
  ...(existing?.environments || {}),
1270
1333
  [input.envName]: previousBaseline?.remoteHash === input.remoteHash
@@ -1297,6 +1360,7 @@ async function executeEndpointPushItem(input) {
1297
1360
  endpointId,
1298
1361
  stableKey,
1299
1362
  desiredManifest: local.manifest,
1363
+ verifyFullSource: input.action === 'create',
1300
1364
  desiredHash,
1301
1365
  stableKeyName: input.stableKeyName,
1302
1366
  });
@@ -1523,6 +1587,14 @@ export async function pushEndpoints(input) {
1523
1587
  && endpointRecordRouteKey(record) === oldRoute)) {
1524
1588
  throw new Error(`restore safety changed after planning: old route ${oldRoute} is now owned by a live endpoint`);
1525
1589
  }
1590
+ if (omitPaths('endpoint').some(parts => parts.length === 1 && parts[0] === 'options')) {
1591
+ const priorManifest = await manifestFromRecord({ client: input.client, record: target, stableKey: prepared.stableKey,
1592
+ stableKeyName: input.stableKeyName, includeExecutionPolicy: prepared.manifest.executionPolicy !== undefined,
1593
+ componentsById: new Map(targetComponents.map(component => [componentIdOf(component), component])) });
1594
+ if (hashStable(prepared.manifest.schema ?? null) !== hashStable(priorManifest.schema ?? null)) {
1595
+ throw new Error('Endpoint schema binding cannot change while the complete options envelope is omitted; reconcile the binding or narrow --omit before deployment.');
1596
+ }
1597
+ }
1526
1598
  await input.client.restoreEndpoint(targetId);
1527
1599
  const restored = unwrapData(await input.client.getEndpoint(targetId));
1528
1600
  const restoredStableKey = readConfiguredResourceMetadataStableKey(restored, input.stableKeyName);
@@ -1,3 +1,4 @@
1
+ import { assertOmittedPropertiesPreserved, hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit } from "../sync-omit.js";
1
2
  import path from 'node:path';
2
3
  import { describeFieldChanges } from "../diff-details.js";
3
4
  import { hashStable, readComponentLock, writeComponentLock } from "../component-lock.js";
@@ -143,11 +144,14 @@ function eventHashShape(manifest, extensions) {
143
144
  function unsupportedEventExtensions(manifest) {
144
145
  return Object.fromEntries(Object.entries(manifest.extensions || {}).filter(([field]) => !AUTOMATION_INPUT_FIELDS.has(field)));
145
146
  }
146
- export function hashEventContent(manifest) {
147
- return hashStable({
147
+ function eventContentShape(manifest) {
148
+ return {
148
149
  ...eventHashShape(manifest, unsupportedEventExtensions(manifest)),
149
150
  ...automationInputHashFields(manifest, true),
150
- });
151
+ };
152
+ }
153
+ export function hashEventContent(manifest) {
154
+ return hashSyncDefinition('event', eventContentShape(manifest));
151
155
  }
152
156
  /** Recognize an old lock representation without discarding any live non-default input. */
153
157
  function legacyEventBaselineHash(manifest, layout) {
@@ -164,10 +168,10 @@ function legacyEventBaselineHash(manifest, layout) {
164
168
  return hashStable({ content: hashStable(eventHashShape(manifest, extensions)), active: manifest.active });
165
169
  }
166
170
  export function hashPortableEvent(manifest) {
167
- return hashStable({ content: hashEventContent(manifest), active: manifest.active });
171
+ return hashSyncDefinition('event', { ...eventContentShape(manifest), active: manifest.active }, hashStable({ content: hashStable(eventContentShape(manifest)), active: manifest.active }));
168
172
  }
169
173
  export function hashEventManifest(manifest) {
170
- return hashStable(canonicalValue(manifest));
174
+ return hashSyncDefinition('event', canonicalValue(manifest));
171
175
  }
172
176
  async function hydrate(records, idOf, get) {
173
177
  return mapWithConcurrency(records, async (record) => {
@@ -219,6 +223,7 @@ function emptyPlanCounts() {
219
223
  };
220
224
  }
221
225
  function diffEvents(desired, current) {
226
+ desired = preserveOmittedProperties('event', desired, current);
222
227
  const desiredInput = readAutomationInput(desired, true);
223
228
  const currentInput = readAutomationInput(current, true);
224
229
  const fields = [
@@ -360,7 +365,10 @@ export async function buildEventsPlan(input) {
360
365
  if (localEvents.length !== 1) {
361
366
  continue;
362
367
  }
363
- const desired = localEvents[0].manifest;
368
+ const matchingTargets = targetsByStableKey.get(stableKey) || [];
369
+ const desired = matchingTargets.length === 1
370
+ ? preserveOmittedProperties('event', localEvents[0].manifest, matchingTargets[0].manifest)
371
+ : localEvents[0].manifest;
364
372
  const dependencyStableKey = desired.target.jobTemplateStableKey;
365
373
  const liveTemplates = templatesByStableKey.get(dependencyStableKey) || [];
366
374
  const usesProjection = projectedJobTemplatesByKey !== undefined;
@@ -443,7 +451,7 @@ export async function buildEventsPlan(input) {
443
451
  const current = targets[0];
444
452
  const fieldChanges = describeFieldChanges({ ...desired, ...readAutomationInput(desired, true) }, current.manifest, diffEvents(desired, current.manifest));
445
453
  const currentHash = current.hash;
446
- const baselineHash = lock.events[stableKey]?.environments[input.envName]?.remoteHash;
454
+ const baselineHash = syncBaselineHash('event', lock.events[stableKey]?.environments[input.envName]);
447
455
  const currentContentHash = current.contentHash;
448
456
  const desiredContentHash = hashEventContent(desired);
449
457
  if (desiredContentHash === currentContentHash && desired.active !== current.manifest.active) {
@@ -561,7 +569,7 @@ function updateEventEnvironmentBaseline(input) {
561
569
  lock.events[stableKey] = {
562
570
  stableKey,
563
571
  path: toPortableRelativePath(projectRoot, input.manifestPath),
564
- sourceHash: hashEventManifest(input.manifest),
572
+ sourceHash: withoutSyncOmit(() => hashEventManifest(input.manifest)),
565
573
  environments: {
566
574
  ...(existing?.environments || {}),
567
575
  [input.envName]: previousBaseline?.remoteHash === input.remoteHash
@@ -638,6 +646,7 @@ async function resolveLiveEventWriteTarget(input) {
638
646
  event,
639
647
  eventId,
640
648
  currentHash: hashPortableEvent(currentManifest),
649
+ currentManifest,
641
650
  active: currentManifest.active,
642
651
  };
643
652
  }
@@ -669,6 +678,10 @@ async function verifyEventWrite(input) {
669
678
  if (verifiedManifest.active !== input.expectedActive) {
670
679
  throw new Error('written Event did not preserve the expected target activation state');
671
680
  }
681
+ if (input.verifyFullSource && !withoutSyncOmit(() => hashEventContent(verifiedManifest) === hashEventContent(input.manifest)))
682
+ throw new Error('Created Event did not initialize the complete source definition.');
683
+ if (input.preservedTargetManifest)
684
+ assertOmittedPropertiesPreserved('event', input.preservedTargetManifest, verifiedManifest);
672
685
  return hashPortableEvent(verifiedManifest);
673
686
  }
674
687
  export async function pushEvents(input) {
@@ -734,7 +747,7 @@ export async function pushEvents(input) {
734
747
  if (live.currentHash !== item.currentHash) {
735
748
  throw new Error('target Event changed after planning');
736
749
  }
737
- await input.client.updateEvent(live.eventId, buildEventUpdatePayload(local.manifest, live.jobTemplateId, live.event.version));
750
+ await input.client.updateEvent(live.eventId, buildEventUpdatePayload(preserveOmittedProperties('event', local.manifest, live.currentManifest), live.jobTemplateId, live.event.version));
738
751
  eventId = live.eventId;
739
752
  expectedActive = live.active;
740
753
  }
@@ -746,6 +759,8 @@ export async function pushEvents(input) {
746
759
  jobTemplateId: live.jobTemplateId,
747
760
  expectedActive,
748
761
  jobTemplatesById: liveInventory?.jobTemplatesById,
762
+ preservedTargetManifest: action === 'update' ? live.currentManifest : undefined,
763
+ verifyFullSource: action === 'create',
749
764
  });
750
765
  updateEventEnvironmentBaseline({
751
766
  cwd: input.cwd,
@@ -894,6 +909,8 @@ export async function activateVerifiedEvents(input) {
894
909
  jobTemplateId: String(current.targetId || ''),
895
910
  expectedActive: candidate.manifest.active,
896
911
  jobTemplatesById: jobTemplatesCache,
912
+ preservedTargetManifest: manifestFromRecord({ record: current, stableKey: candidate.stableKey,
913
+ jobTemplateStableKey: candidate.manifest.target.jobTemplateStableKey, stableKeyName: candidate.stableKeyName }),
897
914
  });
898
915
  updateEventEnvironmentBaseline({
899
916
  cwd: candidate.cwd,
@@ -980,14 +997,16 @@ export async function pullEventsToWorkspace(input) {
980
997
  const pathIdentity = portablePathIdentity(entry.manifestPath);
981
998
  existingByPath.set(pathIdentity, [...(existingByPath.get(pathIdentity) || []), localEntry]);
982
999
  }
983
- const writes = manifests.map((manifest) => {
984
- const sourceHash = hashEventManifest(manifest);
985
- const remoteHash = hashPortableEvent(manifest);
986
- const existing = existingByKey.get(manifest.stableKey);
1000
+ const writes = manifests.map((incoming) => {
1001
+ const incomingHash = hashEventManifest(incoming);
1002
+ const remoteHash = hashPortableEvent(incoming);
1003
+ const existing = existingByKey.get(incoming.stableKey);
1004
+ const manifest = existing ? preserveOmittedProperties('event', incoming, existing.manifest) : incoming;
1005
+ const sourceHash = withoutSyncOmit(() => hashEventManifest(manifest));
987
1006
  if (existing && !input.force) {
988
1007
  const localHash = hashEventManifest(existing.manifest);
989
1008
  const baseline = lock.events[manifest.stableKey];
990
- if (localHash !== sourceHash && (!baseline || localHash !== baseline.sourceHash)) {
1009
+ if (localHash !== incomingHash && (!baseline || localHash !== syncSourceBaselineHash('event', baseline))) {
991
1010
  throw new Error(`Cannot pull Event "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force to overwrite.`);
992
1011
  }
993
1012
  }
@@ -1,3 +1,4 @@
1
+ import { assertOmittedPropertiesPreserved, hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit } from "../sync-omit.js";
1
2
  import path from 'node:path';
2
3
  import { accountPrincipal, serviceAccountMatches, ownerIsAvailable } from "./account-principal.js";
3
4
  import { ownerFromPrincipal, resolveSystemAccount } from "./account-principal.js";
@@ -65,13 +66,14 @@ export function groupManifestFromRecord(record, stableKeyName) {
65
66
  };
66
67
  }
67
68
  export function hashPortableGroup(manifest) {
68
- return hashStable({
69
+ return hashSyncDefinition('group', {
69
70
  ...manifest,
70
71
  category: manifest.category ?? null,
71
72
  description: manifest.description ?? '',
72
73
  });
73
74
  }
74
75
  function diffGroups(desired, target) {
76
+ desired = preserveOmittedProperties('group', desired, target);
75
77
  return ['name', 'category', 'description', 'metadata', 'owner']
76
78
  .filter((field) => {
77
79
  const desiredValue = field === 'category'
@@ -327,9 +329,11 @@ export async function buildGroupsPlan(input) {
327
329
  items.push({ status: 'collision', stableKey, name: desired.name, reason: 'duplicate desired stableKey' });
328
330
  continue;
329
331
  }
330
- const desired = entries[0].manifest;
332
+ const matches = remoteByKey.get(entries[0].manifest.stableKey) || [];
333
+ const desired = matches.length === 1
334
+ ? preserveOmittedProperties('group', entries[0].manifest, matches[0].manifest)
335
+ : entries[0].manifest;
331
336
  const desiredHash = hashPortableGroup(desired);
332
- const matches = remoteByKey.get(desired.stableKey) || [];
333
337
  if (matches.length > 1) {
334
338
  blockers.push(`Duplicate target Group stableKey "${desired.stableKey}".`);
335
339
  consumedRemoteKeys.add(desired.stableKey);
@@ -503,7 +507,7 @@ export async function buildGroupsPlan(input) {
503
507
  items.push({ status: 'safe-update', ...common, reason: 'target GROUP owner differs from source owner Stable Key' });
504
508
  continue;
505
509
  }
506
- const baselineHash = lockEntry?.environments[input.envName]?.remoteHash;
510
+ const baselineHash = syncBaselineHash('group', lockEntry?.environments[input.envName]);
507
511
  if (!baselineHash) {
508
512
  items.push({ status: 'missing-lock', ...common, reason: `missing ${input.envName} lock baseline` });
509
513
  }
@@ -647,13 +651,15 @@ export async function pullGroupsToWorkspace(input) {
647
651
  const writes = [];
648
652
  const outputPaths = new Set();
649
653
  for (const managedGroup of managed) {
650
- const { manifest, owner } = managedGroup;
651
- const hash = hashPortableGroup(manifest);
652
- const existing = existingByStableKey.get(manifest.stableKey);
654
+ const { manifest: incoming, owner } = managedGroup;
655
+ const hash = hashPortableGroup(incoming);
656
+ const existing = existingByStableKey.get(incoming.stableKey);
657
+ const manifest = existing ? preserveOmittedProperties('group', incoming, existing.manifest) : incoming;
658
+ const sourceHash = withoutSyncOmit(() => hashPortableGroup(manifest));
653
659
  if (existing && !input.force) {
654
660
  const localHash = hashPortableGroup(existing.manifest);
655
661
  const lockEntry = lock.groups[manifest.stableKey];
656
- if (localHash !== hash && (!lockEntry || localHash !== lockEntry.sourceHash)) {
662
+ if (localHash !== hash && (!lockEntry || localHash !== syncSourceBaselineHash('group', lockEntry))) {
657
663
  throw new Error(`Cannot pull Group "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
658
664
  }
659
665
  }
@@ -673,6 +679,7 @@ export async function pullGroupsToWorkspace(input) {
673
679
  ...(existing && existing.manifestPath !== filePath ? { previousPath: existing.manifestPath } : {}),
674
680
  manifest,
675
681
  hash,
682
+ sourceHash,
676
683
  owner,
677
684
  });
678
685
  }
@@ -703,7 +710,7 @@ export async function pullGroupsToWorkspace(input) {
703
710
  const entry = {
704
711
  stableKey: write.manifest.stableKey,
705
712
  path: toPortableRelativePath(projectRoot, write.filePath),
706
- sourceHash: write.hash,
713
+ sourceHash: write.sourceHash,
707
714
  owner: write.owner,
708
715
  environments: {
709
716
  ...(previous?.environments || {}),
@@ -777,7 +784,7 @@ function updateEnvironmentBaseline(input) {
777
784
  const nextEntry = {
778
785
  stableKey: local.manifest.stableKey,
779
786
  path: toPortableRelativePath(projectRoot, local.manifestPath),
780
- sourceHash: hashPortableGroup(local.manifest),
787
+ sourceHash: withoutSyncOmit(() => hashPortableGroup(local.manifest)),
781
788
  ...(entry?.owner ? { owner: entry.owner } : {}),
782
789
  environments: {
783
790
  ...(entry?.environments || {}),
@@ -909,6 +916,8 @@ export async function pushGroups(input) {
909
916
  if (!verifiedManifest || hashPortableGroup(verifiedManifest) !== liveDesiredHash) {
910
917
  throw new Error('created Group did not match desired portable hash');
911
918
  }
919
+ if (!withoutSyncOmit(() => hashPortableGroup(verifiedManifest) === hashPortableGroup(local.manifest)))
920
+ throw new Error('Created resource did not initialize the complete source definition.');
912
921
  if (String(verified.ownerType || '').toUpperCase() !== (item.ownerKind === 'service-account' || item.ownerKind === 'system' ? 'USER' : 'GROUP') || verified.ownerId !== ownerId) {
913
922
  throw new Error('created Group did not retain the resolved target owner');
914
923
  }
@@ -978,7 +987,7 @@ export async function pushGroups(input) {
978
987
  throw new Error('live target owner Group did not include groupId');
979
988
  }
980
989
  }
981
- await input.client.updateGroup(targetId, buildUpdatePayload(local.manifest, target, desiredOwnerId, item.ownerKind === 'service-account' || item.ownerKind === 'system' ? 'USER' : 'GROUP'));
990
+ await input.client.updateGroup(targetId, buildUpdatePayload(preserveOmittedProperties('group', local.manifest, targetManifest), target, desiredOwnerId, item.ownerKind === 'service-account' || item.ownerKind === 'system' ? 'USER' : 'GROUP'));
982
991
  const verified = unwrapData(await input.client.getGroup(targetId));
983
992
  const verifiedManifest = groupManifestFromRecord(verified, input.stableKeyName);
984
993
  if (verifiedManifest && local.manifest.owner && verified.ownerType === 'USER' && verified.ownerId) {
@@ -990,6 +999,7 @@ export async function pushGroups(input) {
990
999
  if (!verifiedManifest || hashPortableGroup(verifiedManifest) !== liveDesiredHash) {
991
1000
  throw new Error('updated Group did not match desired portable hash');
992
1001
  }
1002
+ assertOmittedPropertiesPreserved('group', targetManifest, verifiedManifest);
993
1003
  if (desiredOwnerId && (String(verified.ownerType || '').toUpperCase() !== (item.ownerKind === 'service-account' || item.ownerKind === 'system' ? 'USER' : 'GROUP')
994
1004
  || verified.ownerId !== desiredOwnerId)) {
995
1005
  throw new Error('updated Group did not retain the resolved target owner');