@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.
- package/CHANGELOG.md +25 -0
- package/README.md +83 -6
- package/dist/src/argument-contract.d.ts +17 -0
- package/dist/src/argument-contract.js +359 -0
- package/dist/src/automation-contract.generated.d.ts +2 -2
- package/dist/src/automation-contract.generated.js +2 -2
- package/dist/src/cli.js +15 -13
- package/dist/src/client.d.ts +2 -0
- package/dist/src/client.js +22 -0
- package/dist/src/commands/agents.js +5 -1
- package/dist/src/commands/auth.js +2 -0
- package/dist/src/commands/component.js +34 -17
- package/dist/src/commands/database-tables.js +5 -1
- package/dist/src/commands/database-views.js +5 -1
- package/dist/src/commands/endpoints.js +5 -1
- package/dist/src/commands/env.js +5 -1
- package/dist/src/commands/events.js +5 -1
- package/dist/src/commands/groups.js +5 -1
- package/dist/src/commands/info.js +2 -0
- package/dist/src/commands/job-templates.js +5 -1
- package/dist/src/commands/metadata.js +2 -0
- package/dist/src/commands/migrate.d.ts +2 -2
- package/dist/src/commands/migrate.js +31 -7
- package/dist/src/commands/project.js +19 -14
- package/dist/src/commands/request.js +2 -0
- package/dist/src/commands/role-groups.js +5 -1
- package/dist/src/commands/schedules.js +5 -1
- package/dist/src/commands/search.js +2 -0
- package/dist/src/commands/service-accounts.js +5 -1
- package/dist/src/commands/studio.js +2 -0
- package/dist/src/commands/terminal-file-descriptor.d.ts +9 -0
- package/dist/src/commands/terminal-file-descriptor.js +39 -0
- package/dist/src/commands/terminal-file.js +41 -6
- package/dist/src/commands/terminal-image.js +3 -31
- package/dist/src/commands/terminal-process-group.d.ts +25 -0
- package/dist/src/commands/terminal-process-group.js +144 -0
- package/dist/src/commands/terminal.js +123 -40
- package/dist/src/commands/tests.js +2 -0
- package/dist/src/component-lock.d.ts +15 -1
- package/dist/src/component-lock.js +96 -10
- package/dist/src/env-sync.js +12 -6
- package/dist/src/migration.d.ts +7 -0
- package/dist/src/migration.js +39 -21
- package/dist/src/planning-snapshot.d.ts +3 -0
- package/dist/src/planning-snapshot.js +60 -2
- package/dist/src/project.d.ts +1 -0
- package/dist/src/project.js +7 -8
- package/dist/src/resource-syncs/agent-sync.js +76 -24
- package/dist/src/resource-syncs/database-table-sync.js +33 -22
- package/dist/src/resource-syncs/database-view-sync.js +41 -28
- package/dist/src/resource-syncs/endpoint-sync.js +90 -18
- package/dist/src/resource-syncs/event-sync.js +33 -14
- package/dist/src/resource-syncs/group-sync.js +21 -11
- package/dist/src/resource-syncs/job-template-sync.js +98 -37
- package/dist/src/resource-syncs/role-group-sync.js +22 -11
- package/dist/src/resource-syncs/schedule-sync.js +26 -11
- package/dist/src/resource-syncs/service-account-sync.js +22 -11
- package/dist/src/reviewed-plan.js +3 -0
- package/dist/src/runtime-view.js +2 -18
- package/dist/src/sync-omit-command.d.ts +6 -0
- package/dist/src/sync-omit-command.js +49 -0
- package/dist/src/sync-omit-write-fence.d.ts +10 -0
- package/dist/src/sync-omit-write-fence.js +134 -0
- package/dist/src/sync-omit.d.ts +59 -0
- package/dist/src/sync-omit.js +469 -0
- package/dist/src/ui.js +10 -5
- package/dist/src/update-notifier.d.ts +1 -1
- package/dist/src/update-notifier.js +2 -1
- package/dist/src/utils.js +46 -17
- package/dist/src/workspace-prune.js +11 -3
- package/dist/src/workspace-write-lock.d.ts +7 -0
- package/dist/src/workspace-write-lock.js +144 -0
- package/package.json +3 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertOmittedPropertiesPreserved, hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit, projectSyncDefinition, omitPaths } from "../sync-omit.js";
|
|
1
2
|
import { loadComponentSources } from "../component-manifests.js";
|
|
2
3
|
import { componentRevisionByDigest, isComponentDigest } from "../component-contract.js";
|
|
3
4
|
import path from 'node:path';
|
|
@@ -36,8 +37,9 @@ function canonicalJobTemplateOptions(value, inputs, normalizeDefaults = true) {
|
|
|
36
37
|
// definition: missing memory follows input overlays, then the isolate default.
|
|
37
38
|
const canonicalInputs = canonicalJobTemplateInputs(inputs);
|
|
38
39
|
const inputIsEmpty = isRecord(normalized.input) && Object.keys(normalized.input).length === 0;
|
|
40
|
+
const comparable = projectSyncDefinition('job-template', { options: normalized, inputs: canonicalInputs });
|
|
39
41
|
const inputDuplicatesLegacyInputs = inputs !== undefined
|
|
40
|
-
&& JSON.stringify(
|
|
42
|
+
&& JSON.stringify(comparable.options?.input) === JSON.stringify(comparable.inputs);
|
|
41
43
|
if ((inputIsEmpty && (canonicalInputs === undefined || (isRecord(canonicalInputs) && Object.keys(canonicalInputs).length === 0))) || inputDuplicatesLegacyInputs)
|
|
42
44
|
delete normalized.input;
|
|
43
45
|
return Object.keys(normalized).length === 0 ? undefined : normalized;
|
|
@@ -244,14 +246,53 @@ function buildUpdatePayload(manifest, componentId, version) {
|
|
|
244
246
|
version,
|
|
245
247
|
};
|
|
246
248
|
}
|
|
249
|
+
/** Predict the API's option materialization before a write can change an ignored legacy field. */
|
|
250
|
+
function assertJobTemplateOmitWriteSafe(target, desired, payload) {
|
|
251
|
+
if (!omitPaths('job-template').some(parts => ['options', 'inputs'].includes(parts[0])))
|
|
252
|
+
return;
|
|
253
|
+
if (!Object.hasOwn(payload, 'options') && !Object.hasOwn(payload, 'inputs'))
|
|
254
|
+
return;
|
|
255
|
+
const options = isRecord(payload.options) ? structuredClone(payload.options) : {};
|
|
256
|
+
if (options.input === null)
|
|
257
|
+
options.input = {};
|
|
258
|
+
if (!Object.hasOwn(options, 'input') && Object.hasOwn(payload, 'inputs'))
|
|
259
|
+
options.input = payload.inputs ?? {};
|
|
260
|
+
const concurrency = isRecord(options.concurrency) ? { ...options.concurrency } : {};
|
|
261
|
+
for (const field of ['key', 'limit', 'ttl'])
|
|
262
|
+
if (!concurrency[field])
|
|
263
|
+
concurrency[field] = null;
|
|
264
|
+
options.concurrency = concurrency;
|
|
265
|
+
const rawRetry = isRecord(options.retry) ? options.retry : {};
|
|
266
|
+
const retry = { ...requestContractDefaults.retry, ...rawRetry };
|
|
267
|
+
retry.enabled = retry.enabled === true;
|
|
268
|
+
retry.bypassConcurrencyOnRetry = retry.bypassConcurrencyOnRetry === true;
|
|
269
|
+
retry.maxAttempts = Object.hasOwn(rawRetry, 'maxAttempts') ? rawRetry.maxAttempts ?? (rawRetry.maxAttempts === null ? null : requestContractDefaults.retry.maxAttempts) : requestContractDefaults.retry.maxAttempts;
|
|
270
|
+
for (const field of ['minBackoffSeconds', 'maxBackoffSeconds', 'maxDoublings'])
|
|
271
|
+
retry[field] = Math.trunc(Number(retry[field]));
|
|
272
|
+
options.retry = retry;
|
|
273
|
+
const predicted = { ...desired, options, ...(Object.hasOwn(payload, 'inputs') ? { inputs: payload.inputs ?? {} } : {}) };
|
|
274
|
+
try {
|
|
275
|
+
assertOmittedPropertiesPreserved('job-template', target, predicted);
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
throw new Error('Job Template options cannot be updated without normalizing an omitted property; align target defaults or omit the complete options envelope.');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
247
281
|
export function hashPortableJobTemplate(manifest) {
|
|
248
282
|
return jobTemplateDefinitionHash(manifest, true);
|
|
249
283
|
}
|
|
250
284
|
function jobTemplateDefinitionHash(manifest, normalizeDefaults) {
|
|
285
|
+
const shape = jobTemplateDefinitionShape(manifest, normalizeDefaults);
|
|
286
|
+
const rawHash = omitPaths('job-template').length > 0
|
|
287
|
+
? withoutSyncOmit(() => hashStable(jobTemplateDefinitionShape(manifest, normalizeDefaults)))
|
|
288
|
+
: hashStable(shape);
|
|
289
|
+
return hashSyncDefinition('job-template', shape, rawHash);
|
|
290
|
+
}
|
|
291
|
+
function jobTemplateDefinitionShape(manifest, normalizeDefaults) {
|
|
251
292
|
const options = canonicalJobTemplateOptions(manifest.options, manifest.inputs, normalizeDefaults);
|
|
252
293
|
const rawInputs = canonicalJobTemplateInputs(manifest.inputs);
|
|
253
294
|
const inputs = normalizeDefaults && isRecord(rawInputs) && Object.keys(rawInputs).length === 0 ? undefined : rawInputs;
|
|
254
|
-
return
|
|
295
|
+
return {
|
|
255
296
|
kind: 'job-template',
|
|
256
297
|
stableKey: manifest.stableKey,
|
|
257
298
|
name: manifest.name,
|
|
@@ -265,9 +306,10 @@ function jobTemplateDefinitionHash(manifest, normalizeDefaults) {
|
|
|
265
306
|
: manifest.timeout === undefined ? {} : { timeout: manifest.timeout }),
|
|
266
307
|
...(options === undefined ? {} : { options }),
|
|
267
308
|
...(inputs === undefined ? {} : { inputs }),
|
|
268
|
-
}
|
|
309
|
+
};
|
|
269
310
|
}
|
|
270
311
|
function diffJobTemplates(desired, target) {
|
|
312
|
+
desired = preserveOmittedProperties('job-template', desired, target);
|
|
271
313
|
const fields = [
|
|
272
314
|
['name', desired.name, target.name],
|
|
273
315
|
['category', desired.category ?? null, target.category ?? null],
|
|
@@ -362,25 +404,6 @@ export async function buildJobTemplatesPlan(input) {
|
|
|
362
404
|
matches.push(record);
|
|
363
405
|
targetRecordsByName.set(record.name, matches);
|
|
364
406
|
}
|
|
365
|
-
const nameCollisionKeys = new Set();
|
|
366
|
-
const localNames = new Map();
|
|
367
|
-
for (const [stableKey, entries] of localByKey) {
|
|
368
|
-
const desired = entries[0].manifest;
|
|
369
|
-
const previous = localNames.get(desired.name);
|
|
370
|
-
if (previous && previous !== stableKey) {
|
|
371
|
-
blockers.push(`Duplicate local job-template name "${desired.name}" for "${previous}" and "${stableKey}".`);
|
|
372
|
-
nameCollisionKeys.add(previous);
|
|
373
|
-
nameCollisionKeys.add(stableKey);
|
|
374
|
-
}
|
|
375
|
-
localNames.set(desired.name, stableKey);
|
|
376
|
-
for (const record of targetRecordsByName.get(desired.name) || []) {
|
|
377
|
-
if (readConfiguredResourceMetadataStableKey(record, input.stableKeyName) === stableKey
|
|
378
|
-
|| input.pruneBeforeUpsertIds?.includes(jobTemplateIdOf(record)))
|
|
379
|
-
continue;
|
|
380
|
-
blockers.push(`Job-template name "${desired.name}" is already used by target "${jobTemplateIdOf(record)}" with a different or missing Stable Key; review its identity or an explicit workspace prune.`);
|
|
381
|
-
nameCollisionKeys.add(stableKey);
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
407
|
for (const record of targetRecords) {
|
|
385
408
|
const stableKey = readConfiguredResourceMetadataStableKey(record, input.stableKeyName);
|
|
386
409
|
if (!stableKey) {
|
|
@@ -431,6 +454,28 @@ export async function buildJobTemplatesPlan(input) {
|
|
|
431
454
|
pinned: (typeof record.componentVersion === 'number' && !record.componentDigest),
|
|
432
455
|
}]);
|
|
433
456
|
}
|
|
457
|
+
const nameCollisionKeys = new Set();
|
|
458
|
+
const localNames = new Map();
|
|
459
|
+
for (const [stableKey, entries] of localByKey) {
|
|
460
|
+
const matches = targetByKey.get(stableKey) || [];
|
|
461
|
+
const desired = matches.length === 1
|
|
462
|
+
? preserveOmittedProperties('job-template', entries[0].manifest, matches[0].manifest)
|
|
463
|
+
: entries[0].manifest;
|
|
464
|
+
const previous = localNames.get(desired.name);
|
|
465
|
+
if (previous && previous !== stableKey) {
|
|
466
|
+
blockers.push(`Duplicate local job-template name "${desired.name}" for "${previous}" and "${stableKey}".`);
|
|
467
|
+
nameCollisionKeys.add(previous);
|
|
468
|
+
nameCollisionKeys.add(stableKey);
|
|
469
|
+
}
|
|
470
|
+
localNames.set(desired.name, stableKey);
|
|
471
|
+
for (const record of targetRecordsByName.get(desired.name) || []) {
|
|
472
|
+
if (readConfiguredResourceMetadataStableKey(record, input.stableKeyName) === stableKey
|
|
473
|
+
|| input.pruneBeforeUpsertIds?.includes(jobTemplateIdOf(record)))
|
|
474
|
+
continue;
|
|
475
|
+
blockers.push(`Job-template name "${desired.name}" is already used by target "${jobTemplateIdOf(record)}" with a different or missing Stable Key; review its identity or an explicit workspace prune.`);
|
|
476
|
+
nameCollisionKeys.add(stableKey);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
434
479
|
const consumedTargetKeys = new Set();
|
|
435
480
|
for (const [stableKeyIdentity, entries] of localByKey) {
|
|
436
481
|
if (entries.length > 1) {
|
|
@@ -439,7 +484,10 @@ export async function buildJobTemplatesPlan(input) {
|
|
|
439
484
|
items.push({ status: 'collision', stableKey: desired.stableKey, name: desired.name, reason: 'duplicate desired stableKey' });
|
|
440
485
|
continue;
|
|
441
486
|
}
|
|
442
|
-
const
|
|
487
|
+
const targetMatches = targetByKey.get(stableKeyIdentity) || [];
|
|
488
|
+
const desired = targetMatches.length === 1
|
|
489
|
+
? preserveOmittedProperties('job-template', entries[0].manifest, targetMatches[0].manifest)
|
|
490
|
+
: entries[0].manifest;
|
|
443
491
|
if (nameCollisionKeys.has(stableKeyIdentity)) {
|
|
444
492
|
items.push({ status: 'collision', stableKey: desired.stableKey, name: desired.name, reason: 'job-template name is already in use' });
|
|
445
493
|
continue;
|
|
@@ -521,7 +569,7 @@ export async function buildJobTemplatesPlan(input) {
|
|
|
521
569
|
changedFields,
|
|
522
570
|
fieldChanges: describeJobTemplateChanges(desired, target.manifest, changedFields),
|
|
523
571
|
} : {};
|
|
524
|
-
const baseline = lockEntry?.environments[input.envName]
|
|
572
|
+
const baseline = syncBaselineHash('job-template', lockEntry?.environments[input.envName]);
|
|
525
573
|
if (!baseline) {
|
|
526
574
|
items.push({ status: 'missing-lock', stableKey: desired.stableKey, name: desired.name, desiredHash, currentHash: target.hash, reason: `missing ${input.envName} lock baseline`, ...dependencyDetails, ...changeDetails });
|
|
527
575
|
}
|
|
@@ -638,19 +686,21 @@ export async function pullJobTemplatesToWorkspace(input) {
|
|
|
638
686
|
const pathIdentity = portablePathIdentity(entry.manifestPath);
|
|
639
687
|
existingByPath.set(pathIdentity, [...(existingByPath.get(pathIdentity) || []), entry]);
|
|
640
688
|
}
|
|
641
|
-
const writes = manifests.map((
|
|
642
|
-
const hash = hashPortableJobTemplate(
|
|
643
|
-
const existing = existingByKey.get(
|
|
689
|
+
const writes = manifests.map((incoming) => {
|
|
690
|
+
const hash = hashPortableJobTemplate(incoming);
|
|
691
|
+
const existing = existingByKey.get(incoming.stableKey);
|
|
692
|
+
const manifest = existing ? preserveOmittedProperties('job-template', incoming, existing.manifest) : incoming;
|
|
693
|
+
const sourceHash = withoutSyncOmit(() => hashPortableJobTemplate(manifest));
|
|
644
694
|
if (existing && !input.force) {
|
|
645
695
|
const localHash = hashPortableJobTemplate(existing.manifest);
|
|
646
696
|
const baseline = lock.jobTemplates[manifest.stableKey];
|
|
647
|
-
if (localHash !== hash && (!baseline || localHash !== baseline
|
|
648
|
-
&& jobTemplateDefinitionHash(existing.manifest, false) !== baseline.sourceHash)) {
|
|
697
|
+
if (localHash !== hash && (!baseline || localHash !== syncSourceBaselineHash('job-template', baseline)
|
|
698
|
+
&& withoutSyncOmit(() => jobTemplateDefinitionHash(existing.manifest, false)) !== baseline.sourceHash)) {
|
|
649
699
|
throw new Error(`Cannot pull job-template "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
|
|
650
700
|
}
|
|
651
701
|
}
|
|
652
702
|
const filePath = jobTemplateManifestPath(workspaceRoot, manifest);
|
|
653
|
-
return { manifest, hash, filePath, previousPath: existing?.manifestPath };
|
|
703
|
+
return { manifest, hash, sourceHash, filePath, previousPath: existing?.manifestPath };
|
|
654
704
|
});
|
|
655
705
|
const sourceStableKeys = new Set(manifests.map((manifest) => manifest.stableKey));
|
|
656
706
|
const pruned = input.pruneOrphans === true
|
|
@@ -700,7 +750,7 @@ export async function pullJobTemplatesToWorkspace(input) {
|
|
|
700
750
|
const entry = {
|
|
701
751
|
stableKey: write.manifest.stableKey,
|
|
702
752
|
path: toPortableRelativePath(projectRoot, write.filePath),
|
|
703
|
-
sourceHash: write.
|
|
753
|
+
sourceHash: write.sourceHash,
|
|
704
754
|
...(write.manifest.migration
|
|
705
755
|
? { migration: write.manifest.migration }
|
|
706
756
|
: {}),
|
|
@@ -772,7 +822,7 @@ function updateJobTemplateEnvironmentBaseline(input) {
|
|
|
772
822
|
lock.jobTemplates[stableKey] = {
|
|
773
823
|
stableKey,
|
|
774
824
|
path: toPortableRelativePath(projectRoot, input.manifestPath),
|
|
775
|
-
sourceHash: hashPortableJobTemplate(input.manifest),
|
|
825
|
+
sourceHash: withoutSyncOmit(() => hashPortableJobTemplate(input.manifest)),
|
|
776
826
|
...(input.manifest.migration ? { migration: input.manifest.migration } : {}),
|
|
777
827
|
environments: {
|
|
778
828
|
...(existing?.environments || {}),
|
|
@@ -799,6 +849,7 @@ export async function pushJobTemplates(input) {
|
|
|
799
849
|
const stableKey = prepared.manifest.stableKey;
|
|
800
850
|
const targetPath = localTargetPath(input.cwd, prepared.manifestPath);
|
|
801
851
|
try {
|
|
852
|
+
const fullDesiredHash = withoutSyncOmit(() => hashPortableJobTemplate(prepared.manifest));
|
|
802
853
|
if (prepared.manifest.component.pinnedDigest)
|
|
803
854
|
await componentRevisionByDigest(input.client, prepared.componentId, prepared.manifest.component.pinnedDigest);
|
|
804
855
|
const created = unwrapData(await input.client.createJobTemplate({ ...buildCreatePayload(prepared.manifest, prepared.componentId), ...await targetPrincipalId(input.client, prepared.manifest, input.stableKeyName) }));
|
|
@@ -818,7 +869,7 @@ export async function pushJobTemplates(input) {
|
|
|
818
869
|
throw new Error(`created job template references a component without ${input.stableKeyName}`);
|
|
819
870
|
let verifiedManifest = await withRecordPrincipal(input.client, verified, manifestFromRecord(verified, verifiedStableKey, verifiedComponentKey, input.stableKeyName), input.stableKeyName, Boolean(prepared.manifest.executionPrincipal || prepared.manifest.executionPolicy), Boolean(prepared.manifest.executionPrincipal));
|
|
820
871
|
const desiredMemory = isRecord(prepared.manifest.options) ? prepared.manifest.options.memory : undefined;
|
|
821
|
-
if (hashPortableJobTemplate(verifiedManifest) !==
|
|
872
|
+
if (withoutSyncOmit(() => hashPortableJobTemplate(verifiedManifest)) !== fullDesiredHash
|
|
822
873
|
&& (desiredMemory === undefined || desiredMemory === null || desiredMemory === 0)) {
|
|
823
874
|
// Create coerces missing/null/0 memory to 256. The existing update API
|
|
824
875
|
// preserves it, so restore the complete desired options before accepting
|
|
@@ -829,10 +880,10 @@ export async function pushJobTemplates(input) {
|
|
|
829
880
|
if (!createdComponentKey)
|
|
830
881
|
throw new Error(`create response dependency is missing ${input.stableKeyName}`);
|
|
831
882
|
const createdManifest = await withRecordPrincipal(input.client, created, manifestFromRecord(created, stableKey, createdComponentKey, input.stableKeyName), input.stableKeyName, Boolean(prepared.manifest.executionPrincipal || prepared.manifest.executionPolicy), Boolean(prepared.manifest.executionPrincipal));
|
|
832
|
-
if (hashPortableJobTemplate(createdManifest) !== hashPortableJobTemplate(verifiedManifest))
|
|
883
|
+
if (withoutSyncOmit(() => hashPortableJobTemplate(createdManifest) !== hashPortableJobTemplate(verifiedManifest)))
|
|
833
884
|
throw new Error('created job template changed before restoring desired options');
|
|
834
885
|
const latestLocal = readWorkspaceJobTemplates(input.cwd).find(entry => entry.manifest.stableKey === stableKey);
|
|
835
|
-
if (!latestLocal || hashPortableJobTemplate(latestLocal.manifest) !==
|
|
886
|
+
if (!latestLocal || withoutSyncOmit(() => hashPortableJobTemplate(latestLocal.manifest)) !== fullDesiredHash)
|
|
836
887
|
throw new Error('desired manifest changed before restoring created job template options');
|
|
837
888
|
await input.client.updateJobTemplate(createdId, {
|
|
838
889
|
...buildUpdatePayload(prepared.manifest, prepared.componentId, created.version),
|
|
@@ -847,7 +898,7 @@ export async function pushJobTemplates(input) {
|
|
|
847
898
|
throw new Error(`restored target dependency is missing ${input.stableKeyName}`);
|
|
848
899
|
verifiedManifest = await withRecordPrincipal(input.client, verified, manifestFromRecord(verified, restoredStableKey, restoredComponentKey, input.stableKeyName), input.stableKeyName, Boolean(prepared.manifest.executionPrincipal || prepared.manifest.executionPolicy), Boolean(prepared.manifest.executionPrincipal));
|
|
849
900
|
}
|
|
850
|
-
if (hashPortableJobTemplate(verifiedManifest) !== prepared.desiredHash) {
|
|
901
|
+
if (hashPortableJobTemplate(verifiedManifest) !== prepared.desiredHash || withoutSyncOmit(() => hashPortableJobTemplate(verifiedManifest)) !== fullDesiredHash) {
|
|
851
902
|
throw new Error('created job template did not match desired portable hash');
|
|
852
903
|
}
|
|
853
904
|
updateJobTemplateEnvironmentBaseline({
|
|
@@ -916,6 +967,7 @@ export async function pushJobTemplates(input) {
|
|
|
916
967
|
if (!targetComponentKey)
|
|
917
968
|
throw new Error(`target dependency is missing ${input.stableKeyName}`);
|
|
918
969
|
const targetManifest = await withRecordPrincipal(input.client, target, manifestFromRecord(target, targetStableKey, targetComponentKey, input.stableKeyName), input.stableKeyName, Boolean(local.manifest.executionPrincipal || local.manifest.executionPolicy), Boolean(local.manifest.executionPrincipal));
|
|
970
|
+
const effectiveManifest = preserveOmittedProperties('job-template', local.manifest, targetManifest);
|
|
919
971
|
const targetHash = hashPortableJobTemplate(targetManifest);
|
|
920
972
|
if (targetHash !== item.currentHash)
|
|
921
973
|
throw new Error('target changed after planning');
|
|
@@ -947,7 +999,15 @@ export async function pushJobTemplates(input) {
|
|
|
947
999
|
throw new Error(`dependency "${local.manifest.component.stableKey}" has no target component id`);
|
|
948
1000
|
if (local.manifest.component.pinnedDigest)
|
|
949
1001
|
await componentRevisionByDigest(input.client, componentId, local.manifest.component.pinnedDigest);
|
|
950
|
-
|
|
1002
|
+
const payload = { ...buildUpdatePayload(effectiveManifest, componentId, target.version), ...await targetPrincipalId(input.client, effectiveManifest, input.stableKeyName, target) };
|
|
1003
|
+
const preservesRuntime = omitPaths('job-template').some(parts => ['options', 'inputs'].includes(parts[0]));
|
|
1004
|
+
const runtimeChanged = diffJobTemplates(effectiveManifest, targetManifest).some(field => ['options', 'inputs'].includes(field));
|
|
1005
|
+
if (preservesRuntime && !runtimeChanged) {
|
|
1006
|
+
delete payload.options;
|
|
1007
|
+
delete payload.inputs;
|
|
1008
|
+
}
|
|
1009
|
+
assertJobTemplateOmitWriteSafe(targetManifest, effectiveManifest, payload);
|
|
1010
|
+
await input.client.updateJobTemplate(targetId, payload);
|
|
951
1011
|
const verified = unwrapData(await input.client.getJobTemplate(targetId));
|
|
952
1012
|
const verifiedStableKey = readConfiguredResourceMetadataStableKey(verified, input.stableKeyName);
|
|
953
1013
|
if (verifiedStableKey !== stableKey)
|
|
@@ -959,6 +1019,7 @@ export async function pushJobTemplates(input) {
|
|
|
959
1019
|
if (hashPortableJobTemplate(verifiedManifest) !== desiredHash) {
|
|
960
1020
|
throw new Error('updated job template did not match desired portable hash');
|
|
961
1021
|
}
|
|
1022
|
+
assertOmittedPropertiesPreserved('job-template', targetManifest, verifiedManifest);
|
|
962
1023
|
updateJobTemplateEnvironmentBaseline({
|
|
963
1024
|
cwd: input.cwd,
|
|
964
1025
|
envName: input.envName,
|
|
@@ -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";
|
|
@@ -43,7 +44,7 @@ export function roleGroupManifestFromRecord(record, stableKeyName) {
|
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
export function hashPortableRoleGroup(manifest) {
|
|
46
|
-
return
|
|
47
|
+
return hashSyncDefinition('role-group', {
|
|
47
48
|
...manifest,
|
|
48
49
|
category: manifest.category ?? null,
|
|
49
50
|
description: manifest.description ?? '',
|
|
@@ -54,6 +55,7 @@ function roleGroupHint(value) {
|
|
|
54
55
|
return normalizeStableKeyValue(`${category}/${String(value.name || '')}`);
|
|
55
56
|
}
|
|
56
57
|
function diffRoleGroups(desired, target) {
|
|
58
|
+
desired = preserveOmittedProperties('role-group', desired, target);
|
|
57
59
|
const changedFields = ['name', 'category', 'description', 'metadata']
|
|
58
60
|
.filter((field) => {
|
|
59
61
|
const desiredValue = field === 'category' ? desired.category ?? null : field === 'description' ? desired.description ?? '' : desired[field];
|
|
@@ -213,9 +215,11 @@ export async function buildRoleGroupsPlan(input) {
|
|
|
213
215
|
items.push({ status: 'collision', stableKey, name: entries[0].manifest.name, reason: 'duplicate desired stableKey' });
|
|
214
216
|
continue;
|
|
215
217
|
}
|
|
216
|
-
const desired = entries[0].manifest;
|
|
217
|
-
const desiredHash = hashPortableRoleGroup(desired);
|
|
218
218
|
const matches = remoteByKey.get(normalized) || [];
|
|
219
|
+
const desired = matches.length === 1
|
|
220
|
+
? preserveOmittedProperties('role-group', entries[0].manifest, matches[0].manifest)
|
|
221
|
+
: entries[0].manifest;
|
|
222
|
+
const desiredHash = hashPortableRoleGroup(desired);
|
|
219
223
|
if (matches.length > 1) {
|
|
220
224
|
blockers.push(`Duplicate target role-group stableKey "${desired.stableKey}".`);
|
|
221
225
|
consumedRemoteKeys.add(normalized);
|
|
@@ -255,7 +259,7 @@ export async function buildRoleGroupsPlan(input) {
|
|
|
255
259
|
items.push({ status: 'clean', ...common });
|
|
256
260
|
continue;
|
|
257
261
|
}
|
|
258
|
-
const baselineHash = lockByNormalizedKey.get(normalized)?.environments[input.envName]
|
|
262
|
+
const baselineHash = syncBaselineHash('role-group', lockByNormalizedKey.get(normalized)?.environments[input.envName]);
|
|
259
263
|
if (!baselineHash) {
|
|
260
264
|
items.push({ status: 'missing-lock', ...common, reason: `missing ${input.envName} lock baseline` });
|
|
261
265
|
}
|
|
@@ -351,15 +355,17 @@ export async function pullRoleGroupsToWorkspace(input) {
|
|
|
351
355
|
}
|
|
352
356
|
const writes = [];
|
|
353
357
|
const outputPaths = new Set();
|
|
354
|
-
for (const
|
|
355
|
-
const hash = hashPortableRoleGroup(
|
|
356
|
-
const normalized = normalizeStableKeyValue(
|
|
358
|
+
for (const incoming of managed) {
|
|
359
|
+
const hash = hashPortableRoleGroup(incoming);
|
|
360
|
+
const normalized = normalizeStableKeyValue(incoming.stableKey);
|
|
357
361
|
const existing = existingByStableKey.get(normalized);
|
|
362
|
+
const manifest = existing ? preserveOmittedProperties('role-group', incoming, existing.manifest) : incoming;
|
|
363
|
+
const sourceHash = withoutSyncOmit(() => hashPortableRoleGroup(manifest));
|
|
358
364
|
if (existing && !input.force) {
|
|
359
365
|
const localHash = hashPortableRoleGroup(existing.manifest);
|
|
360
366
|
const lockEntry = Object.values(lock.roleGroups)
|
|
361
367
|
.find((entry) => normalizeStableKeyValue(entry.stableKey) === normalized);
|
|
362
|
-
if (localHash !== hash && (!lockEntry || localHash !== lockEntry
|
|
368
|
+
if (localHash !== hash && (!lockEntry || localHash !== syncSourceBaselineHash('role-group', lockEntry))) {
|
|
363
369
|
throw new Error(`Cannot pull role-group "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
|
|
364
370
|
}
|
|
365
371
|
}
|
|
@@ -379,6 +385,7 @@ export async function pullRoleGroupsToWorkspace(input) {
|
|
|
379
385
|
...(existing && existing.manifestPath !== filePath ? { previousPath: existing.manifestPath } : {}),
|
|
380
386
|
manifest,
|
|
381
387
|
hash,
|
|
388
|
+
sourceHash,
|
|
382
389
|
});
|
|
383
390
|
}
|
|
384
391
|
const sourceStableKeys = new Set(managed.map((manifest) => normalizeStableKeyValue(manifest.stableKey)));
|
|
@@ -415,7 +422,7 @@ export async function pullRoleGroupsToWorkspace(input) {
|
|
|
415
422
|
const entry = {
|
|
416
423
|
stableKey: write.manifest.stableKey,
|
|
417
424
|
path: toPortableRelativePath(projectRoot, write.filePath),
|
|
418
|
-
sourceHash: write.
|
|
425
|
+
sourceHash: write.sourceHash,
|
|
419
426
|
environments: {
|
|
420
427
|
...(previous?.environments || {}),
|
|
421
428
|
[input.envName]: previousBaseline?.remoteHash === write.hash
|
|
@@ -489,7 +496,7 @@ function updateEnvironmentBaseline(input) {
|
|
|
489
496
|
const nextEntry = {
|
|
490
497
|
stableKey: local.manifest.stableKey,
|
|
491
498
|
path: toPortableRelativePath(projectRoot, local.manifestPath),
|
|
492
|
-
sourceHash: hashPortableRoleGroup(local.manifest),
|
|
499
|
+
sourceHash: withoutSyncOmit(() => hashPortableRoleGroup(local.manifest)),
|
|
493
500
|
environments: {
|
|
494
501
|
...(entry?.environments || {}),
|
|
495
502
|
[input.envName]: existingBaseline?.remoteHash === input.remoteHash
|
|
@@ -586,6 +593,8 @@ export async function pushRoleGroups(input) {
|
|
|
586
593
|
if (!verifiedManifest || hashPortableRoleGroup(verifiedManifest) !== liveDesiredHash) {
|
|
587
594
|
throw new Error('created role-group did not match desired portable hash');
|
|
588
595
|
}
|
|
596
|
+
if (!withoutSyncOmit(() => hashPortableRoleGroup(verifiedManifest) === hashPortableRoleGroup(local.manifest)))
|
|
597
|
+
throw new Error('Created resource did not initialize the complete source definition.');
|
|
589
598
|
updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey, remoteHash: liveDesiredHash });
|
|
590
599
|
results.push({ stableKey, action: 'create', status: 'deployed', targetPath });
|
|
591
600
|
}
|
|
@@ -606,9 +615,10 @@ export async function pushRoleGroups(input) {
|
|
|
606
615
|
if (!targetManifest || hashPortableRoleGroup(targetManifest) !== item.currentHash) {
|
|
607
616
|
throw new Error('target changed after planning');
|
|
608
617
|
}
|
|
618
|
+
const preservedTargetManifest = structuredClone(targetManifest);
|
|
609
619
|
const diff = diffRoleGroups(local.manifest, targetManifest);
|
|
610
620
|
if (diff.changedFields.length > 0) {
|
|
611
|
-
await input.client.updateRoleGroup(targetId, buildBaseUpdatePayload(local.manifest, target));
|
|
621
|
+
await input.client.updateRoleGroup(targetId, buildBaseUpdatePayload(preserveOmittedProperties('role-group', local.manifest, targetManifest), target));
|
|
612
622
|
target = unwrapData(await input.client.getRoleGroup(targetId));
|
|
613
623
|
targetManifest = roleGroupManifestFromRecord(target, input.stableKeyName);
|
|
614
624
|
if (!targetManifest)
|
|
@@ -626,6 +636,7 @@ export async function pushRoleGroups(input) {
|
|
|
626
636
|
if (!verifiedManifest || hashPortableRoleGroup(verifiedManifest) !== liveDesiredHash) {
|
|
627
637
|
throw new Error('updated role-group did not match desired portable hash');
|
|
628
638
|
}
|
|
639
|
+
assertOmittedPropertiesPreserved('role-group', preservedTargetManifest, verifiedManifest);
|
|
629
640
|
updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey, remoteHash: liveDesiredHash });
|
|
630
641
|
results.push({ stableKey, action: 'update', status: 'deployed', targetPath });
|
|
631
642
|
}
|
|
@@ -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";
|
|
@@ -166,7 +167,7 @@ function manifestFromRecord(input) {
|
|
|
166
167
|
}
|
|
167
168
|
/** Desired target shape. Source-only configuration and activation are excluded. */
|
|
168
169
|
export function hashPortableSchedule(manifest) {
|
|
169
|
-
return
|
|
170
|
+
return hashSyncDefinition('schedule', {
|
|
170
171
|
kind: 'schedule',
|
|
171
172
|
stableKey: manifest.stableKey,
|
|
172
173
|
name: manifest.name,
|
|
@@ -181,7 +182,7 @@ export function hashPortableSchedule(manifest) {
|
|
|
181
182
|
}
|
|
182
183
|
/** Local baseline shape. It deliberately includes editable/source-only pull data. */
|
|
183
184
|
export function hashScheduleManifest(manifest) {
|
|
184
|
-
return
|
|
185
|
+
return hashSyncDefinition('schedule', canonicalValue(manifest));
|
|
185
186
|
}
|
|
186
187
|
function warningKey(record, stableKey) {
|
|
187
188
|
return stableKey || String(record.name || scheduleIdOf(record) || 'unknown schedule');
|
|
@@ -309,6 +310,7 @@ function scheduleHint(value) {
|
|
|
309
310
|
return normalizeStableKeyValue(`${category}/${String(value.name || '')}`);
|
|
310
311
|
}
|
|
311
312
|
function diffSchedules(desired, target) {
|
|
313
|
+
desired = preserveOmittedProperties('schedule', desired, target);
|
|
312
314
|
const desiredInput = readAutomationInput(desired);
|
|
313
315
|
const targetInput = readAutomationInput(target);
|
|
314
316
|
const fields = [
|
|
@@ -521,7 +523,10 @@ export async function buildSchedulesPlan(input) {
|
|
|
521
523
|
consumedTargetKeys.add(stableKey);
|
|
522
524
|
continue;
|
|
523
525
|
}
|
|
524
|
-
const
|
|
526
|
+
const matchingTargets = targetByKey.get(stableKey) || [];
|
|
527
|
+
const desired = matchingTargets.length === 1
|
|
528
|
+
? preserveOmittedProperties('schedule', entries[0].manifest, matchingTargets[0].manifest)
|
|
529
|
+
: entries[0].manifest;
|
|
525
530
|
const desiredHash = hashPortableSchedule(desired);
|
|
526
531
|
const excluded = excludedTargetByKey.get(stableKey) || [];
|
|
527
532
|
if (excluded.length > 0) {
|
|
@@ -740,7 +745,7 @@ export async function buildSchedulesPlan(input) {
|
|
|
740
745
|
...planTargetDetails(desired.target),
|
|
741
746
|
...(changedFields.length > 0 ? { changedFields, fieldChanges } : {}),
|
|
742
747
|
};
|
|
743
|
-
const baselineHash = lock.schedules[desired.stableKey]?.environments[input.envName]
|
|
748
|
+
const baselineHash = syncBaselineHash('schedule', lock.schedules[desired.stableKey]?.environments[input.envName]);
|
|
744
749
|
if (desiredHash === target.hash && activationDiffers) {
|
|
745
750
|
items.push({ status: 'activation-drift', ...common, reason: `desired active=${desiredActive}; target active=${currentActive}`, ...(baselineHash ? { baselineHash } : {}) });
|
|
746
751
|
}
|
|
@@ -914,14 +919,16 @@ export async function pullSchedulesToWorkspace(input) {
|
|
|
914
919
|
const pathIdentity = portablePathIdentity(entry.manifestPath);
|
|
915
920
|
existingByPath.set(pathIdentity, [...(existingByPath.get(pathIdentity) || []), entry]);
|
|
916
921
|
}
|
|
917
|
-
const writes = manifests.map((
|
|
918
|
-
const
|
|
919
|
-
const remoteHash = hashPortableSchedule(
|
|
920
|
-
const existing = existingByKey.get(
|
|
922
|
+
const writes = manifests.map((incoming) => {
|
|
923
|
+
const incomingHash = hashScheduleManifest(incoming);
|
|
924
|
+
const remoteHash = hashPortableSchedule(incoming);
|
|
925
|
+
const existing = existingByKey.get(incoming.stableKey);
|
|
926
|
+
const manifest = existing ? preserveOmittedProperties('schedule', incoming, existing.manifest) : incoming;
|
|
927
|
+
const sourceHash = withoutSyncOmit(() => hashScheduleManifest(manifest));
|
|
921
928
|
if (existing && !input.force) {
|
|
922
929
|
const localHash = hashScheduleManifest(existing.manifest);
|
|
923
930
|
const baseline = lock.schedules[manifest.stableKey];
|
|
924
|
-
if (localHash !==
|
|
931
|
+
if (localHash !== incomingHash && (!baseline || localHash !== syncSourceBaselineHash('schedule', baseline))) {
|
|
925
932
|
throw new Error(`Cannot pull Schedule "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
|
|
926
933
|
}
|
|
927
934
|
}
|
|
@@ -1067,7 +1074,7 @@ function updateScheduleEnvironmentBaseline(input) {
|
|
|
1067
1074
|
lock.schedules[stableKey] = {
|
|
1068
1075
|
stableKey,
|
|
1069
1076
|
path: toPortableRelativePath(projectRoot, input.manifestPath),
|
|
1070
|
-
sourceHash: hashScheduleManifest(input.manifest),
|
|
1077
|
+
sourceHash: withoutSyncOmit(() => hashScheduleManifest(input.manifest)),
|
|
1071
1078
|
environments: {
|
|
1072
1079
|
...(existing?.environments || {}),
|
|
1073
1080
|
[input.envName]: previousBaseline?.remoteHash === input.remoteHash
|
|
@@ -1156,6 +1163,7 @@ async function resolveLiveScheduleWriteTarget(input) {
|
|
|
1156
1163
|
schedule,
|
|
1157
1164
|
scheduleId,
|
|
1158
1165
|
currentHash: hashPortableSchedule(currentManifest),
|
|
1166
|
+
currentManifest,
|
|
1159
1167
|
};
|
|
1160
1168
|
}
|
|
1161
1169
|
async function verifyScheduleWrite(input) {
|
|
@@ -1189,6 +1197,10 @@ async function verifyScheduleWrite(input) {
|
|
|
1189
1197
|
if (hashPortableSchedule(verifiedManifest) !== input.desiredHash) {
|
|
1190
1198
|
throw new Error('written Schedule did not match desired portable hash');
|
|
1191
1199
|
}
|
|
1200
|
+
if (input.verifyFullSource && !withoutSyncOmit(() => hashPortableSchedule(verifiedManifest) === hashPortableSchedule(input.manifest)))
|
|
1201
|
+
throw new Error('Created Schedule did not initialize the complete source definition.');
|
|
1202
|
+
if (input.preservedTargetManifest)
|
|
1203
|
+
assertOmittedPropertiesPreserved('schedule', input.preservedTargetManifest, verifiedManifest);
|
|
1192
1204
|
return schedule;
|
|
1193
1205
|
}
|
|
1194
1206
|
export async function pushSchedules(input) {
|
|
@@ -1239,7 +1251,7 @@ export async function pushSchedules(input) {
|
|
|
1239
1251
|
if (live.currentHash !== item.currentHash) {
|
|
1240
1252
|
throw new Error('target Schedule changed after planning');
|
|
1241
1253
|
}
|
|
1242
|
-
await input.client.updateSchedule(live.scheduleId, buildScheduleUpdatePayload(local.manifest, live.targetId, live.schedule.version));
|
|
1254
|
+
await input.client.updateSchedule(live.scheduleId, buildScheduleUpdatePayload(preserveOmittedProperties('schedule', local.manifest, live.currentManifest), live.targetId, live.schedule.version));
|
|
1243
1255
|
scheduleId = live.scheduleId;
|
|
1244
1256
|
}
|
|
1245
1257
|
const verified = await verifyScheduleWrite({
|
|
@@ -1249,6 +1261,8 @@ export async function pushSchedules(input) {
|
|
|
1249
1261
|
scheduleId,
|
|
1250
1262
|
targetId: live.targetId,
|
|
1251
1263
|
desiredHash,
|
|
1264
|
+
preservedTargetManifest: action === 'update' ? live.currentManifest : undefined,
|
|
1265
|
+
verifyFullSource: action === 'create',
|
|
1252
1266
|
});
|
|
1253
1267
|
updateScheduleEnvironmentBaseline({
|
|
1254
1268
|
cwd: input.cwd,
|
|
@@ -1457,6 +1471,7 @@ export async function activateVerifiedSchedules(input) {
|
|
|
1457
1471
|
|| hashPortableSchedule(verifiedManifest) !== candidate.portableHash) {
|
|
1458
1472
|
throw new Error('activated Schedule definition does not match the verified candidate');
|
|
1459
1473
|
}
|
|
1474
|
+
assertOmittedPropertiesPreserved('schedule', currentManifest, verifiedManifest);
|
|
1460
1475
|
results.push({
|
|
1461
1476
|
stableKey: candidate.stableKey,
|
|
1462
1477
|
action,
|
|
@@ -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 { readPortableOwner, resolvePortableOwner, ownerIsAvailable } from "./account-principal.js";
|
|
3
4
|
import { isBuiltinSystemAccount } from "./account-principal.js";
|
|
@@ -45,13 +46,14 @@ async function readManagementPrincipal(client, record, stableKeyName) {
|
|
|
45
46
|
: { ownerType: 'USER', ownerId: managers[0].userId }, stableKeyName);
|
|
46
47
|
}
|
|
47
48
|
export function hashPortableServiceAccount(manifest) {
|
|
48
|
-
return
|
|
49
|
+
return hashSyncDefinition('service-account', { kind: manifest.kind, stableKey: manifest.stableKey, name: manifest.name, metadata: manifest.metadata,
|
|
49
50
|
...(['group', 'service-account', 'system'].includes(manifest.owner.type) ? { owner: manifest.owner } : {}) });
|
|
50
51
|
}
|
|
51
52
|
function serviceAccountHint(value) {
|
|
52
53
|
return String(value.name || '').trim().toLowerCase();
|
|
53
54
|
}
|
|
54
55
|
function diffServiceAccounts(desired, target) {
|
|
56
|
+
desired = preserveOmittedProperties('service-account', desired, target);
|
|
55
57
|
return { changedFields: ['name', 'metadata', 'owner'].filter((field) => {
|
|
56
58
|
if (field === 'owner' && !['group', 'service-account', 'system'].includes(desired.owner.type)) {
|
|
57
59
|
return false;
|
|
@@ -190,9 +192,11 @@ export async function buildServiceAccountsPlan(input) {
|
|
|
190
192
|
items.push({ status: 'collision', stableKey, name: entries[0].manifest.name, reason: 'duplicate desired stableKey' });
|
|
191
193
|
continue;
|
|
192
194
|
}
|
|
193
|
-
const desired = entries[0].manifest;
|
|
194
|
-
const desiredHash = hashPortableServiceAccount(desired);
|
|
195
195
|
const matches = remoteByKey.get(normalized) || [];
|
|
196
|
+
const desired = matches.length === 1
|
|
197
|
+
? preserveOmittedProperties('service-account', entries[0].manifest, matches[0].manifest)
|
|
198
|
+
: entries[0].manifest;
|
|
199
|
+
const desiredHash = hashPortableServiceAccount(desired);
|
|
196
200
|
if (matches.length > 1) {
|
|
197
201
|
blockers.push(`Duplicate target service-account stableKey "${desired.stableKey}".`);
|
|
198
202
|
consumedRemoteKeys.add(normalized);
|
|
@@ -247,7 +251,7 @@ export async function buildServiceAccountsPlan(input) {
|
|
|
247
251
|
items.push({ status: 'clean', ...common });
|
|
248
252
|
continue;
|
|
249
253
|
}
|
|
250
|
-
const baselineHash = lockByNormalizedKey.get(normalized)?.environments[input.envName]
|
|
254
|
+
const baselineHash = syncBaselineHash('service-account', lockByNormalizedKey.get(normalized)?.environments[input.envName]);
|
|
251
255
|
if (!baselineHash) {
|
|
252
256
|
items.push({ status: 'missing-lock', ...common, reason: `missing ${input.envName} lock baseline` });
|
|
253
257
|
}
|
|
@@ -350,15 +354,17 @@ export async function pullServiceAccountsToWorkspace(input) {
|
|
|
350
354
|
}
|
|
351
355
|
const writes = [];
|
|
352
356
|
const outputPaths = new Set();
|
|
353
|
-
for (const
|
|
354
|
-
const hash = hashPortableServiceAccount(
|
|
355
|
-
const normalized = exactKey(
|
|
357
|
+
for (const incoming of managed) {
|
|
358
|
+
const hash = hashPortableServiceAccount(incoming);
|
|
359
|
+
const normalized = exactKey(incoming.stableKey);
|
|
356
360
|
const existing = existingByStableKey.get(normalized);
|
|
361
|
+
const manifest = existing ? preserveOmittedProperties('service-account', incoming, existing.manifest) : incoming;
|
|
362
|
+
const sourceHash = withoutSyncOmit(() => hashPortableServiceAccount(manifest));
|
|
357
363
|
if (existing && !input.force) {
|
|
358
364
|
const localHash = hashPortableServiceAccount(existing.manifest);
|
|
359
365
|
const lockEntry = Object.values(lock.serviceAccounts)
|
|
360
366
|
.find((entry) => exactKey(entry.stableKey) === normalized);
|
|
361
|
-
if (localHash !== hash && (!lockEntry || localHash !== lockEntry
|
|
367
|
+
if (localHash !== hash && (!lockEntry || localHash !== syncSourceBaselineHash('service-account', lockEntry))) {
|
|
362
368
|
throw new Error(`Cannot pull service-account "${manifest.stableKey}": local manifest changed since the lock baseline. Re-run with --force.`);
|
|
363
369
|
}
|
|
364
370
|
}
|
|
@@ -378,6 +384,7 @@ export async function pullServiceAccountsToWorkspace(input) {
|
|
|
378
384
|
...(existing && existing.manifestPath !== filePath ? { previousPath: existing.manifestPath } : {}),
|
|
379
385
|
manifest,
|
|
380
386
|
hash,
|
|
387
|
+
sourceHash,
|
|
381
388
|
});
|
|
382
389
|
}
|
|
383
390
|
const sourceStableKeys = new Set(managed.map((manifest) => exactKey(manifest.stableKey)));
|
|
@@ -414,7 +421,7 @@ export async function pullServiceAccountsToWorkspace(input) {
|
|
|
414
421
|
const entry = {
|
|
415
422
|
stableKey: write.manifest.stableKey,
|
|
416
423
|
path: toPortableRelativePath(projectRoot, write.filePath),
|
|
417
|
-
sourceHash: write.
|
|
424
|
+
sourceHash: write.sourceHash,
|
|
418
425
|
environments: {
|
|
419
426
|
...(previous?.environments || {}),
|
|
420
427
|
[input.envName]: previousBaseline?.remoteHash === write.hash
|
|
@@ -498,7 +505,7 @@ function updateEnvironmentBaseline(input) {
|
|
|
498
505
|
const nextEntry = {
|
|
499
506
|
stableKey: local.manifest.stableKey,
|
|
500
507
|
path: toPortableRelativePath(projectRoot, local.manifestPath),
|
|
501
|
-
sourceHash: hashPortableServiceAccount(local.manifest),
|
|
508
|
+
sourceHash: withoutSyncOmit(() => hashPortableServiceAccount(local.manifest)),
|
|
502
509
|
environments: {
|
|
503
510
|
...(entry?.environments || {}),
|
|
504
511
|
[input.envName]: existingBaseline?.remoteHash === input.remoteHash
|
|
@@ -605,6 +612,8 @@ export async function pushServiceAccounts(input) {
|
|
|
605
612
|
if (!verifiedManifest || hashPortableServiceAccount(verifiedManifest) !== liveDesiredHash) {
|
|
606
613
|
throw new Error('created service-account did not match desired portable hash');
|
|
607
614
|
}
|
|
615
|
+
if (!withoutSyncOmit(() => hashPortableServiceAccount(verifiedManifest) === hashPortableServiceAccount(local.manifest)))
|
|
616
|
+
throw new Error('Created resource did not initialize the complete source definition.');
|
|
608
617
|
updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey, remoteHash: liveDesiredHash });
|
|
609
618
|
results.push({ stableKey, action: 'create', status: 'deployed', targetPath, reason: 'Created; secrets are target-local and require separate configuration', credentials: { stableKey, environment: input.envName, policy: 'target-local', status: 'configure-manually' } });
|
|
610
619
|
}
|
|
@@ -630,9 +639,10 @@ export async function pushServiceAccounts(input) {
|
|
|
630
639
|
if (!targetManifest || hashPortableServiceAccount(targetManifest) !== item.currentHash) {
|
|
631
640
|
throw new Error('target changed after planning');
|
|
632
641
|
}
|
|
642
|
+
const preservedTargetManifest = structuredClone(targetManifest);
|
|
633
643
|
const diff = diffServiceAccounts(local.manifest, targetManifest);
|
|
634
644
|
if (diff.changedFields.length > 0) {
|
|
635
|
-
await input.client.updateServiceAccount(targetId, await buildBaseUpdatePayload(input.client, local.manifest, target, input.stableKeyName));
|
|
645
|
+
await input.client.updateServiceAccount(targetId, await buildBaseUpdatePayload(input.client, preserveOmittedProperties('service-account', local.manifest, targetManifest), target, input.stableKeyName));
|
|
636
646
|
target = unwrapData(await input.client.getServiceAccount(targetId));
|
|
637
647
|
targetManifest = await serviceAccountManifestFromRecord(input.client, target, input.stableKeyName);
|
|
638
648
|
if (!targetManifest) {
|
|
@@ -645,6 +655,7 @@ export async function pushServiceAccounts(input) {
|
|
|
645
655
|
if (!verifiedManifest || hashPortableServiceAccount(verifiedManifest) !== liveDesiredHash) {
|
|
646
656
|
throw new Error('updated service-account did not match desired portable hash');
|
|
647
657
|
}
|
|
658
|
+
assertOmittedPropertiesPreserved('service-account', preservedTargetManifest, verifiedManifest);
|
|
648
659
|
updateEnvironmentBaseline({ cwd: input.cwd, envName: input.envName, stableKey, remoteHash: liveDesiredHash });
|
|
649
660
|
results.push({ stableKey, action: 'update', status: 'deployed', targetPath, reason: 'Target-local secrets preserved', credentials: { stableKey, environment: input.envName, policy: 'target-local', status: 'preserved-target-local' } });
|
|
650
661
|
}
|