@revoengine/cli 1.0.33 → 1.0.35

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 +34 -0
  2. package/README.md +89 -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 +38 -1
  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 +4 -2
@@ -1,8 +1,49 @@
1
+ import { hashStable } from "./component-lock.js";
2
+ import { syncTargetVersionRecords } from "./sync-omit-write-fence.js";
3
+ import { currentSyncOmitPolicy } from "./sync-omit.js";
4
+ const reviewVersions = new WeakMap();
5
+ export function planningSnapshotVersions(client) {
6
+ return { ...reviewVersions.get(client) };
7
+ }
8
+ function readFamily(method) {
9
+ if (/AgentPlugins?/.test(method))
10
+ return 'agent-plugin';
11
+ if (/Agents?/.test(method))
12
+ return 'agent';
13
+ if (/ServiceAccounts?|Accounts?/.test(method))
14
+ return 'service-account';
15
+ if (/RoleGroups?/.test(method))
16
+ return 'role-group';
17
+ if (/Groups?/.test(method))
18
+ return 'group';
19
+ if (/JobTemplates?/.test(method))
20
+ return 'job-template';
21
+ if (/Endpoints?/.test(method))
22
+ return 'endpoint';
23
+ if (/Schedules?/.test(method))
24
+ return 'schedule';
25
+ if (/Events?/.test(method))
26
+ return 'event';
27
+ if (/DatabaseViews?/.test(method))
28
+ return 'database-view';
29
+ if (/DatabaseSchemas?/.test(method))
30
+ return 'database-table';
31
+ // Historical/runtime component snapshots have their own revision namespace.
32
+ // Component writes retain the existing dedicated componentReview fence.
33
+ if (/^(getComponent|listAllComponents)$/.test(method))
34
+ return 'component';
35
+ return undefined;
36
+ }
37
+ export function planningSnapshotReviewHash(client) {
38
+ return hashStable(Object.entries(reviewVersions.get(client) || {}).sort(([left], [right]) => left.localeCompare(right)));
39
+ }
1
40
  // Only one planning pass owns this cache. Mutation/readback uses the original
2
41
  // client, and the next pass always starts empty. Never persist auth or row data.
3
42
  export function planningSnapshot(client) {
4
43
  const pending = new Map();
5
- return new Proxy(client, {
44
+ const versions = {};
45
+ const captureRevisions = currentSyncOmitPolicy().rules.length > 0;
46
+ const snapshot = new Proxy(client, {
6
47
  get(target, property) {
7
48
  const value = Reflect.get(target, property, target);
8
49
  if (typeof value !== 'function')
@@ -22,8 +63,25 @@ export function planningSnapshot(client) {
22
63
  request.catch(() => pending.delete(key));
23
64
  }
24
65
  // Planners annotate records. No consumer may mutate another's snapshot.
25
- return structuredClone(await request);
66
+ const result = await request;
67
+ const family = captureRevisions ? readFamily(property) : undefined;
68
+ if (family) {
69
+ const detailId = property.startsWith('get') && typeof args[0] === 'string' ? args[0] : undefined;
70
+ if (detailId && !Object.hasOwn(versions, `${family}:${detailId}`))
71
+ versions[`${family}:${detailId}`] = null;
72
+ for (const record of syncTargetVersionRecords(family, result, detailId)) {
73
+ const identity = `${family}:${record.id}`;
74
+ const previous = versions[identity];
75
+ if (previous != null && record.version != null && previous !== record.version)
76
+ throw new Error(`Target ${family} changed while planning; review a fresh deployment plan.`);
77
+ if (!Object.hasOwn(versions, identity) || record.version !== null)
78
+ versions[identity] = record.version;
79
+ }
80
+ }
81
+ return structuredClone(result);
26
82
  };
27
83
  },
28
84
  });
85
+ reviewVersions.set(snapshot, versions);
86
+ return snapshot;
29
87
  }
@@ -7,6 +7,7 @@ export declare const REVO_TYPES_FILE: string;
7
7
  export declare const REVO_TYPES_DEFINITIONS_FILE: string;
8
8
  export declare const REVO_METADATA_FILE: string;
9
9
  export declare const REVO_TYPES_GITIGNORE_ENTRY = ".revoengine/types/";
10
+ export declare const REVO_WORKSPACE_LOCK_GITIGNORE_ENTRY = ".revoengine/workspace-write.lock/";
10
11
  export declare const REVO_DEBUG_JS_FILE: string;
11
12
  export declare const REVO_DEBUG_TS_FILE: string;
12
13
  export declare const REVO_DEBUG_INPUT_FILE: string;
@@ -1,6 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { readJsonFile } from "./utils.js";
3
+ import { readJsonFile, writeJsonFile } from "./utils.js";
4
4
  import { COMPONENT_IDENTITY_BY_ID, DEFAULT_COMPONENT_IDENTITY, DEFAULT_STABLE_KEY_NAME, normalizeComponentIdentityConfig, normalizeComponentIdentityMode, normalizeStableKeyName, } from "./resource-metadata.js";
5
5
  import { TRACK_ALL_RESOURCES, normalizeTrackedResources, } from "./tracked-resources.js";
6
6
  export const REVO_PROJECT_DIR = '.revoengine';
@@ -9,6 +9,7 @@ export const REVO_TYPES_FILE = path.join(REVO_TYPES_DIR, 'revo.editor.d.ts');
9
9
  export const REVO_TYPES_DEFINITIONS_FILE = path.join(REVO_TYPES_DIR, 'revo.editor.definitions.json');
10
10
  export const REVO_METADATA_FILE = path.join(REVO_PROJECT_DIR, 'revo.json');
11
11
  export const REVO_TYPES_GITIGNORE_ENTRY = '.revoengine/types/';
12
+ export const REVO_WORKSPACE_LOCK_GITIGNORE_ENTRY = '.revoengine/workspace-write.lock/';
12
13
  export const REVO_DEBUG_JS_FILE = path.join(REVO_PROJECT_DIR, 'debug_code.js');
13
14
  export const REVO_DEBUG_TS_FILE = path.join(REVO_PROJECT_DIR, 'debug_code.ts');
14
15
  export const REVO_DEBUG_INPUT_FILE = path.join(REVO_PROJECT_DIR, 'debug_input.json');
@@ -198,10 +199,6 @@ function readResourceSelectionArgs(args) {
198
199
  }
199
200
  return values.length > 0 ? values : undefined;
200
201
  }
201
- function writeJsonFile(filePath, value) {
202
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
203
- fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`);
204
- }
205
202
  export function resolveProjectInvocation(args) {
206
203
  const projectArgs = args._.slice(1);
207
204
  const [first, second, ...rest] = projectArgs;
@@ -606,8 +603,9 @@ export function ensureProjectConfig(rootDir, typesInclude = REVO_TYPES_FILE) {
606
603
  }
607
604
  export function ensureProjectGitignore(rootDir) {
608
605
  const filePath = path.join(rootDir, '.gitignore');
606
+ const entries = [REVO_TYPES_GITIGNORE_ENTRY, REVO_WORKSPACE_LOCK_GITIGNORE_ENTRY];
609
607
  if (!fs.existsSync(filePath)) {
610
- fs.writeFileSync(filePath, `${REVO_TYPES_GITIGNORE_ENTRY}\n`);
608
+ fs.writeFileSync(filePath, `${entries.join('\n')}\n`);
611
609
  return {
612
610
  filePath,
613
611
  action: 'created',
@@ -615,14 +613,15 @@ export function ensureProjectGitignore(rootDir) {
615
613
  }
616
614
  const raw = fs.readFileSync(filePath, 'utf8');
617
615
  const lines = raw.split(/\r?\n/);
618
- if (lines.some((line) => line.trim() === REVO_TYPES_GITIGNORE_ENTRY)) {
616
+ const missing = entries.filter(entry => !lines.some(line => line.trim() === entry));
617
+ if (!missing.length) {
619
618
  return {
620
619
  filePath,
621
620
  action: 'unchanged',
622
621
  };
623
622
  }
624
623
  const trimmed = raw.replace(/\s*$/, '');
625
- const next = trimmed ? `${trimmed}\n${REVO_TYPES_GITIGNORE_ENTRY}\n` : `${REVO_TYPES_GITIGNORE_ENTRY}\n`;
624
+ const next = `${trimmed ? `${trimmed}\n` : ''}${missing.join('\n')}\n`;
626
625
  fs.writeFileSync(filePath, next);
627
626
  return {
628
627
  filePath,
@@ -1,3 +1,4 @@
1
+ import { assertOmittedPropertiesPreserved, hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit, omitPaths } from "../sync-omit.js";
1
2
  import { componentRevisionByDigest, verifyComponentRuntime } from "../component-contract.js";
2
3
  import fs from 'node:fs';
3
4
  import path from 'node:path';
@@ -149,7 +150,7 @@ function comparableAgent(desired, current) {
149
150
  }
150
151
  export function hashPortableAgent(manifest) {
151
152
  const { owner, ...rest } = manifest;
152
- return hashStable({ ...rest, ...((owner && ['group', 'service-account', 'system'].includes(owner.type)) ? { owner } : {}) });
153
+ return hashSyncDefinition(manifest.kind, { ...rest, ...((owner && ['group', 'service-account', 'system'].includes(owner.type)) ? { owner } : {}) });
153
154
  }
154
155
  export function readWorkspaceAgents(cwd, family) {
155
156
  const { workspaceRoot } = requireProjectLayout(cwd, family);
@@ -312,35 +313,39 @@ export async function pullAgentsToWorkspace(input) {
312
313
  unique(entries);
313
314
  const existing = readWorkspaceAgents(input.cwd, input.family);
314
315
  unique(existing);
316
+ const { projectRoot } = requireProjectLayout(input.cwd, input.family);
317
+ const lock = readComponentLock(projectRoot);
318
+ const field = AGENT_LAYOUT[input.family][2];
315
319
  const paths = new Set();
316
- for (const { manifest } of entries) {
320
+ const writes = entries.map(({ manifest: incoming }) => {
321
+ const remoteHash = hashPortableAgent(incoming);
322
+ const local = existing.find(value => value.manifest.stableKey === incoming.stableKey);
323
+ const manifest = local ? preserveOmittedProperties(input.family, incoming, local.manifest) : incoming;
324
+ const sourceHash = withoutSyncOmit(() => hashPortableAgent(manifest));
317
325
  const filename = manifestPath(input.cwd, manifest);
318
326
  const key = pathIdentity(filename);
319
327
  if (paths.has(key))
320
328
  throw new Error('Agent manifest filesystem path collision.');
321
329
  paths.add(key);
322
- const local = existing.find(v => v.manifest.stableKey === manifest.stableKey);
323
- if (local && hashPortableAgent(local.manifest) !== hashPortableAgent(manifest) && !input.force)
324
- throw new Error(`Local ${input.family} "${manifest.stableKey}" differs; use --force to replace.`);
330
+ if (local && !input.force) {
331
+ const localHash = hashPortableAgent(local.manifest);
332
+ if (localHash !== remoteHash && localHash !== syncSourceBaselineHash(input.family, lock[field][manifest.stableKey]))
333
+ throw new Error(`Local ${input.family} "${manifest.stableKey}" differs; use --force to replace.`);
334
+ }
325
335
  if (fs.existsSync(filename) && (!local || pathIdentity(local.manifestPath) !== key))
326
336
  throw new Error('Agent manifest path is occupied by another resource.');
327
- }
328
- const { projectRoot } = requireProjectLayout(input.cwd, input.family);
329
- const lock = readComponentLock(projectRoot);
330
- const field = AGENT_LAYOUT[input.family][2];
331
- if (input.pruneOrphans && skipped.length && existing.some(local => !entries.some(e => e.manifest.stableKey === local.manifest.stableKey)))
337
+ return { manifest, local, filename, remoteHash, sourceHash };
338
+ });
339
+ if (input.pruneOrphans && skipped.length && existing.some(local => !entries.some(entry => entry.manifest.stableKey === local.manifest.stableKey)))
332
340
  throw new Error('Cannot prune local Agent manifests while source inventory contains unmanaged resources.');
333
341
  const pulled = [];
334
342
  const pruned = [];
335
- for (const { manifest } of entries) {
336
- const filename = manifestPath(input.cwd, manifest);
343
+ for (const { manifest, local, filename, remoteHash, sourceHash } of writes) {
337
344
  writePulledManifest({ filePath: filename, manifest, root: path.dirname(filename) });
338
- const local = existing.find(v => v.manifest.stableKey === manifest.stableKey);
339
345
  if (local && local.manifestPath !== filename)
340
346
  fs.unlinkSync(local.manifestPath);
341
- const hash = hashPortableAgent(manifest);
342
347
  const prior = lock[field][manifest.stableKey];
343
- lock[field][manifest.stableKey] = { stableKey: manifest.stableKey, path: toPortableRelativePath(projectRoot, filename), sourceHash: hash, environments: { ...prior?.environments, [input.envName]: { remoteHash: hash, syncedAt: new Date().toISOString() } } };
348
+ lock[field][manifest.stableKey] = { stableKey: manifest.stableKey, path: toPortableRelativePath(projectRoot, filename), sourceHash, environments: { ...prior?.environments, [input.envName]: { remoteHash, syncedAt: new Date().toISOString() } } };
344
349
  pulled.push({ manifest, targetPath: path.relative(input.cwd, filename) });
345
350
  }
346
351
  if (input.pruneOrphans)
@@ -404,10 +409,46 @@ async function pluginPayload(input, definition, current, cache = new Map()) {
404
409
  }
405
410
  return result;
406
411
  }
412
+ function ownFields(value, fields) {
413
+ return Object.fromEntries(fields.filter(field => Object.hasOwn(value, field)).map(field => [field, value[field]]));
414
+ }
415
+ /** Raw shapes are used only in memory for ignored-path preservation, never exported or hashed as definitions. */
416
+ function rawAgentOmitShape(family, value) {
417
+ return {
418
+ ...ownFields(value, ['name', 'metadata']),
419
+ definition: family === 'agent-plugin'
420
+ ? { ...(isRecord(value.config) ? value.config : {}), ...ownFields(value, ['category', 'active']) }
421
+ : ownFields(value, ['desc', 'config', 'policy']),
422
+ };
423
+ }
424
+ function preserveRawAgentOmitPayload(input, payload, current) {
425
+ if (!current || omitPaths(input.family).length === 0)
426
+ return payload;
427
+ const shape = {
428
+ ...ownFields(payload, ['name', 'metadata']),
429
+ definition: input.family === 'agent-plugin'
430
+ ? Object.fromEntries(Object.entries(payload).filter(([field]) => field !== 'metadata'))
431
+ : ownFields(payload, ['desc', 'config', 'policy']),
432
+ };
433
+ const preserved = preserveOmittedProperties(input.family, shape, rawAgentOmitShape(input.family, current));
434
+ if (input.family === 'agent-plugin')
435
+ return { ...preserved.definition, ...ownFields(preserved, ['metadata']) };
436
+ const result = { ...payload };
437
+ const sections = [[preserved, ['name', 'metadata']], [preserved.definition, ['desc', 'config', 'policy']]];
438
+ for (const [source, fields] of sections) {
439
+ for (const field of fields) {
440
+ if (Object.hasOwn(source, field))
441
+ result[field] = source[field];
442
+ else
443
+ delete result[field];
444
+ }
445
+ }
446
+ return result;
447
+ }
407
448
  async function writePayload(input, manifest, current) {
408
449
  const cache = new Map();
409
450
  if (manifest.kind === 'agent-plugin')
410
- return { ...await pluginPayload(input, manifest.definition, isRecord(current?.config) ? current.config : undefined, cache), category: manifest.definition.category ?? null, metadata: manifest.metadata };
451
+ return preserveRawAgentOmitPayload(input, { ...await pluginPayload(input, manifest.definition, isRecord(current?.config) ? current.config : undefined, cache), category: manifest.definition.category ?? null, metadata: manifest.metadata }, current);
411
452
  if (manifest.executionPrincipal?.kind === 'service-account') {
412
453
  const id = await resolveKey(input, 'service-account', manifest.executionPrincipal.stableKey, cache);
413
454
  if ((await input.client.getServiceAccount(id)).platformAccess !== true)
@@ -435,7 +476,7 @@ async function writePayload(input, manifest, current) {
435
476
  replacement.plugins = [];
436
477
  result[field] = replacement;
437
478
  }
438
- return result;
479
+ return preserveRawAgentOmitPayload(input, result, current);
439
480
  }
440
481
  async function verifyPluginComponents(input, manifest, cache, projected) {
441
482
  const definitions = manifest.kind === 'agent-plugin' ? [manifest.definition]
@@ -511,10 +552,15 @@ export async function buildAgentsPlan(input) {
511
552
  }
512
553
  }
513
554
  const slugs = new Set();
514
- for (const { manifest } of locals) {
555
+ for (const local of locals) {
556
+ let manifest = local.manifest;
515
557
  const item = { name: manifest.name, stableKey: manifest.stableKey, status: 'collision' };
516
558
  plan.items.push(item);
517
559
  try {
560
+ const target = values.find(v => readConfiguredResourceMetadataStableKey(v, input.stableKeyName) === manifest.stableKey);
561
+ const current = target ? await agentManifestFromRecord(input, target) : null;
562
+ if (current)
563
+ manifest = preserveOmittedProperties(input.family, manifest, current);
518
564
  validate(manifest, input);
519
565
  if (input.family === 'agent-plugin') {
520
566
  const slug = String(manifest.definition.id);
@@ -522,7 +568,6 @@ export async function buildAgentsPlan(input) {
522
568
  throw new Error(`Duplicate local plugin slug "${slug}".`);
523
569
  slugs.add(slug);
524
570
  }
525
- const target = values.find(v => readConfiguredResourceMetadataStableKey(v, input.stableKeyName) === manifest.stableKey);
526
571
  if (target && input.family === 'agent-plugin' && target.pluginSlug !== manifest.definition.id)
527
572
  throw new Error('Plugin slug is immutable; target Stable Key belongs to a different slug.');
528
573
  const nameCollision = values.some(v => v !== target && (input.family === 'agent-plugin' ? v.pluginSlug === manifest.definition.id : String(v.name).trim().toLowerCase() === manifest.name.trim().toLowerCase()));
@@ -560,13 +605,12 @@ export async function buildAgentsPlan(input) {
560
605
  const mcp = manifest.definition.mcpServer;
561
606
  if (isRecord(mcp))
562
607
  requireMcpAuthentication(mcp, isRecord(target?.config) ? target.config.mcpServer : undefined);
563
- const current = target ? await agentManifestFromRecord(input, target) : null;
564
608
  // Human ownership stays local and cannot create drift.
565
609
  if (current && manifest.owner?.type === 'manual-user')
566
610
  current.owner = manifest.owner;
567
611
  item.desiredHash = hashPortableAgent(manifest);
568
612
  item.currentHash = current ? hashPortableAgent(current) : undefined;
569
- item.baselineHash = lock[manifest.stableKey]?.environments[input.envName]?.remoteHash;
613
+ item.baselineHash = syncBaselineHash(input.family, lock[manifest.stableKey]?.environments[input.envName]);
570
614
  item.status = !target ? 'create' : item.desiredHash === item.currentHash ? 'clean' : !item.baselineHash ? 'missing-lock' : item.currentHash === item.baselineHash ? 'safe-update' : item.desiredHash === item.baselineHash ? 'remote-changed' : 'conflict';
571
615
  if (current && item.desiredHash !== item.currentHash) {
572
616
  item.changedFields = Object.keys(manifest).filter(k => hashStable(manifest[k]) !== hashStable(current[k]));
@@ -614,10 +658,11 @@ export async function pushAgents(input) {
614
658
  const current = target ? await agentManifestFromRecord(input, target) : null;
615
659
  if ((current ? hashPortableAgent(comparableAgent(manifest, current)) : undefined) !== item.currentHash)
616
660
  throw new Error('Target definition changed after planning.');
617
- await verifyPluginComponents(input, manifest, new Map());
661
+ const effectiveManifest = current ? preserveOmittedProperties(input.family, manifest, current) : manifest;
662
+ await verifyPluginComponents(input, effectiveManifest, new Map());
618
663
  let written = target;
619
664
  if (item.desiredHash !== item.currentHash) {
620
- const payload = await writePayload(input, manifest, target);
665
+ const payload = await writePayload(input, effectiveManifest, target);
621
666
  if (target && !Number.isInteger(target.version))
622
667
  throw new Error('Target version is required.');
623
668
  if (target) {
@@ -633,11 +678,18 @@ export async function pushAgents(input) {
633
678
  const readback = await agentManifestFromRecord(input, verified);
634
679
  if (!readback || hashPortableAgent(comparableAgent(manifest, readback)) !== item.desiredHash)
635
680
  throw new Error('Portable readback differs; baseline not recorded.');
681
+ if (!target && !withoutSyncOmit(() => hashPortableAgent(comparableAgent(manifest, readback)) === hashPortableAgent(manifest)))
682
+ throw new Error('Created resource did not initialize the complete source definition.');
683
+ if (current)
684
+ assertOmittedPropertiesPreserved(input.family, current, readback);
685
+ if (target && omitPaths(input.family).length > 0) {
686
+ assertOmittedPropertiesPreserved(input.family, rawAgentOmitShape(input.family, target), rawAgentOmitShape(input.family, verified));
687
+ }
636
688
  const { projectRoot } = requireProjectLayout(input.cwd, input.family);
637
689
  const lock = readComponentLock(projectRoot);
638
690
  const field = AGENT_LAYOUT[input.family][2];
639
691
  const prior = lock[field][manifest.stableKey];
640
- lock[field][manifest.stableKey] = { stableKey: manifest.stableKey, path: toPortableRelativePath(projectRoot, filename), sourceHash: item.desiredHash, environments: { ...prior?.environments, [input.envName]: { remoteHash: item.desiredHash, syncedAt: new Date().toISOString() } } };
692
+ lock[field][manifest.stableKey] = { stableKey: manifest.stableKey, path: toPortableRelativePath(projectRoot, filename), sourceHash: withoutSyncOmit(() => hashPortableAgent(manifest)), environments: { ...prior?.environments, [input.envName]: { remoteHash: item.desiredHash, syncedAt: new Date().toISOString() } } };
641
693
  writeComponentLock(projectRoot, lock);
642
694
  output.status = 'deployed';
643
695
  }
@@ -1,3 +1,4 @@
1
+ import { hashSyncDefinition, preserveOmittedProperties, syncBaselineHash, syncSourceBaselineHash, withoutSyncOmit, assertOmittedPropertiesPreserved, omitPaths } from "../sync-omit.js";
1
2
  import { databaseIndexPayload } from "../database-indexes.js";
2
3
  import fs from 'node:fs';
3
4
  import path from 'node:path';
@@ -175,7 +176,7 @@ function portableDatabaseSchemaManifest(manifest) {
175
176
  };
176
177
  }
177
178
  export function hashPortableDatabaseSchema(manifest) {
178
- return hashStable(portableDatabaseSchemaManifest(manifest));
179
+ return hashSyncDefinition('database-table', portableDatabaseSchemaManifest(manifest));
179
180
  }
180
181
  function rootManifestPath(workspaceRoot, manifest) {
181
182
  const category = typeof manifest.category === 'string' && manifest.category.trim()
@@ -798,7 +799,7 @@ export async function buildDatabaseSchemasPlan(input) {
798
799
  if (entries.length !== 1) {
799
800
  continue;
800
801
  }
801
- const name = physicalNameHint(entries[0].manifest);
802
+ const name = physicalNameHint(preserveOmittedProperties('database-table', entries[0].manifest, targetByKey.get(stableKey)?.[0]?.manifest));
802
803
  localKeysByPhysicalName.set(name, [...(localKeysByPhysicalName.get(name) || []), stableKey]);
803
804
  }
804
805
  const duplicateLocalNames = new Set();
@@ -846,7 +847,7 @@ export async function buildDatabaseSchemasPlan(input) {
846
847
  visitParent(stableKey, []);
847
848
  }
848
849
  for (const [stableKey, entries] of localByKey) {
849
- const desired = portableDatabaseSchemaManifest(entries[0].manifest);
850
+ const desired = preserveOmittedProperties('database-table', portableDatabaseSchemaManifest(entries[0].manifest), targetByKey.get(stableKey)?.[0]?.manifest);
850
851
  if (entries.length > 1) {
851
852
  blockers.push(`Duplicate desired Database Table stableKey "${stableKey}".`);
852
853
  items.push({
@@ -1001,7 +1002,7 @@ export async function buildDatabaseSchemasPlan(input) {
1001
1002
  });
1002
1003
  }
1003
1004
  const changedFields = [...new Set(changes.map((change) => change.field))];
1004
- const baselineHash = lock.databaseSchemas[stableKey]?.environments[input.envName]?.remoteHash;
1005
+ const baselineHash = syncBaselineHash('database-table', lock.databaseSchemas[stableKey]?.environments[input.envName]);
1005
1006
  const currentStats = statsById.get(current.databaseId);
1006
1007
  const sizeHint = changes.length > 0 ? sizeRiskHint(currentStats) : undefined;
1007
1008
  const common = {
@@ -1355,7 +1356,8 @@ export async function pullDatabaseSchemasToWorkspace(input) {
1355
1356
  if (input.strict && catalog.skipped.length > 0) {
1356
1357
  throw new Error(`Database Table strict pull requires Stable Keys on all active resources; ${catalog.skipped.length} unmanaged resource(s) found.`);
1357
1358
  }
1358
- const manifestsById = new Map(catalog.entries.map((entry) => [entry.id, manifestFromEntry(entry, input.stableKeyName)]));
1359
+ const sourceManifestsById = new Map(catalog.entries.map((entry) => [entry.id, manifestFromEntry(entry, input.stableKeyName)]));
1360
+ const manifestsById = new Map(sourceManifestsById);
1359
1361
  const pathsById = new Map();
1360
1362
  const resolvePath = (entry) => {
1361
1363
  const existing = pathsById.get(entry.id);
@@ -1370,15 +1372,6 @@ export async function pullDatabaseSchemasToWorkspace(input) {
1370
1372
  return filePath;
1371
1373
  };
1372
1374
  const existingByKey = new Map();
1373
- const catalogPathOwners = new Map();
1374
- for (const entry of catalog.entries) {
1375
- const identity = pathIdentity(resolvePath(entry));
1376
- const owner = catalogPathOwners.get(identity);
1377
- if (owner && owner !== entry.stableKey) {
1378
- throw new Error(`Database Table workspace path collision for "${entry.stableKey}" and "${owner}"; no files were changed.`);
1379
- }
1380
- catalogPathOwners.set(identity, entry.stableKey);
1381
- }
1382
1375
  for (const local of loadWorkspaceManifests(workspaceRoot)) {
1383
1376
  if (!isRecord(local.manifest) || typeof local.manifest.stableKey !== 'string') {
1384
1377
  throw new Error(`Invalid database-table manifest ${path.relative(projectRoot, local.manifestPath)}; no files were changed.`);
@@ -1388,6 +1381,18 @@ export async function pullDatabaseSchemasToWorkspace(input) {
1388
1381
  }
1389
1382
  existingByKey.set(local.manifest.stableKey, local);
1390
1383
  }
1384
+ for (const entry of catalog.entries) {
1385
+ manifestsById.set(entry.id, preserveOmittedProperties('database-table', sourceManifestsById.get(entry.id), existingByKey.get(entry.stableKey)?.manifest));
1386
+ }
1387
+ const catalogPathOwners = new Map();
1388
+ for (const entry of catalog.entries) {
1389
+ const identity = pathIdentity(resolvePath(entry));
1390
+ const owner = catalogPathOwners.get(identity);
1391
+ if (owner && owner !== entry.stableKey) {
1392
+ throw new Error(`Database Table workspace path collision for "${entry.stableKey}" and "${owner}"; no files were changed.`);
1393
+ }
1394
+ catalogPathOwners.set(identity, entry.stableKey);
1395
+ }
1391
1396
  const lock = readComponentLock(projectRoot);
1392
1397
  const skipped = [...catalog.skipped];
1393
1398
  const writes = [];
@@ -1404,12 +1409,12 @@ export async function pullDatabaseSchemasToWorkspace(input) {
1404
1409
  : [];
1405
1410
  for (const entry of catalog.entries) {
1406
1411
  const manifest = manifestsById.get(entry.id);
1407
- const hash = hashPortableDatabaseSchema(manifest);
1412
+ const hash = hashPortableDatabaseSchema(sourceManifestsById.get(entry.id));
1408
1413
  const existing = existingByKey.get(entry.stableKey);
1409
1414
  if (existing && !input.force) {
1410
1415
  const localHash = hashPortableDatabaseSchema(existing.manifest);
1411
1416
  const baseline = lock.databaseSchemas[entry.stableKey];
1412
- if (localHash !== hash && (!baseline || localHash !== baseline.sourceHash)) {
1417
+ if (localHash !== hash && localHash !== syncSourceBaselineHash('database-table', baseline)) {
1413
1418
  skipped.push({
1414
1419
  targetPath: localTargetPath(input.cwd, existing.manifestPath),
1415
1420
  reason: 'local manifest changed since the lock baseline; use --force to overwrite',
@@ -1420,6 +1425,7 @@ export async function pullDatabaseSchemasToWorkspace(input) {
1420
1425
  writes.push({
1421
1426
  manifest,
1422
1427
  hash,
1428
+ sourceHash: withoutSyncOmit(() => hashPortableDatabaseSchema(manifest)),
1423
1429
  filePath: resolvePath(entry),
1424
1430
  ...(entry.parentId || typeof entry.record.restricted !== 'boolean'
1425
1431
  ? {}
@@ -1455,7 +1461,7 @@ export async function pullDatabaseSchemasToWorkspace(input) {
1455
1461
  const entry = {
1456
1462
  stableKey: write.manifest.stableKey,
1457
1463
  path: toPortableRelativePath(projectRoot, write.filePath),
1458
- sourceHash: write.hash,
1464
+ sourceHash: write.sourceHash,
1459
1465
  ...(typeof write.sourceRestricted === 'boolean' ? { sourceRestricted: write.sourceRestricted } : {}),
1460
1466
  ...(write.manifest.parentStableKey ? { parentStableKey: write.manifest.parentStableKey } : {}),
1461
1467
  environments: {
@@ -1635,12 +1641,12 @@ function verifyCreatedDatabaseSchema(input) {
1635
1641
  if (verified.length !== 1) {
1636
1642
  throw new Error('created target could not be resolved into the live partition graph');
1637
1643
  }
1638
- const remoteHash = verified[0].hash;
1639
- const desiredHash = hashPortableDatabaseSchema(input.desired);
1644
+ const remoteHash = withoutSyncOmit(() => hashPortableDatabaseSchema(verified[0].manifest));
1645
+ const desiredHash = withoutSyncOmit(() => hashPortableDatabaseSchema(input.desired));
1640
1646
  if (remoteHash !== desiredHash) {
1641
1647
  throw new Error(`created target did not match desired portable hash (desired: ${desiredHash}; actual: ${remoteHash})`);
1642
1648
  }
1643
- return remoteHash;
1649
+ return verified[0].hash;
1644
1650
  }
1645
1651
  function updateDatabaseSchemaEnvironmentBaseline(input) {
1646
1652
  const { projectRoot } = requireProjectLayout(input.cwd, 'Database Table');
@@ -1649,7 +1655,7 @@ function updateDatabaseSchemaEnvironmentBaseline(input) {
1649
1655
  const entry = {
1650
1656
  stableKey: input.manifest.stableKey,
1651
1657
  path: toPortableRelativePath(projectRoot, input.manifestPath),
1652
- sourceHash: hashPortableDatabaseSchema(input.manifest),
1658
+ sourceHash: withoutSyncOmit(() => hashPortableDatabaseSchema(input.manifest)),
1653
1659
  ...(input.manifest.kind === 'database-schema' && typeof existing?.sourceRestricted === 'boolean'
1654
1660
  ? { sourceRestricted: existing.sourceRestricted }
1655
1661
  : {}),
@@ -1798,6 +1804,10 @@ function verifyDatabaseSchemaWrite(input) {
1798
1804
  stableKey: input.desired.stableKey,
1799
1805
  stableKeyName: input.stableKeyName,
1800
1806
  });
1807
+ if (omitPaths('database-table').length) {
1808
+ const previous = resolveDatabaseSchemaManifestFromRecords({ records: input.recordsBeforeWrite, databaseId, stableKey: input.desired.stableKey, stableKeyName: input.stableKeyName });
1809
+ assertOmittedPropertiesPreserved('database-table', previous.manifest, verified.manifest);
1810
+ }
1801
1811
  const desiredHash = hashPortableDatabaseSchema(input.desired);
1802
1812
  if (verified.hash !== desiredHash) {
1803
1813
  throw new Error(`written target did not match desired portable hash (desired: ${desiredHash}; actual: ${verified.hash})`);
@@ -2132,7 +2142,8 @@ export async function pushDatabaseSchemas(input) {
2132
2142
  }
2133
2143
  await waitForDatabaseSchemaMutation(lastMutation.at);
2134
2144
  lastMutation.at = Date.now();
2135
- const payload = buildDatabaseSchemaUpdatePayload({ desired, target: live.record,
2145
+ const effectiveDesired = preserveOmittedProperties('database-table', desired, live.manifest);
2146
+ const payload = buildDatabaseSchemaUpdatePayload({ desired: effectiveDesired, target: live.record,
2136
2147
  stableKeyName: input.stableKeyName, sourceWins: input.migrationPolicy?.sourceWins });
2137
2148
  if (input.async) {
2138
2149
  const operation = await input.client.acceptDatabaseSchema(payload, live.databaseId, input.idempotencyKey);