@neocompose/cli 0.36.8 → 0.36.10

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/dist/neo.mjs CHANGED
@@ -45228,6 +45228,21 @@ function findSchemaPlacement(memberId, classes) {
45228
45228
  }
45229
45229
  return null;
45230
45230
  }
45231
+ function findNearestAncestorSchemaPlacement(ownerClass, schemaKey, classesById) {
45232
+ const visited = /* @__PURE__ */ new Set([ownerClass.id]);
45233
+ let ancestorId = ownerClass.extendsClassId;
45234
+ while (typeof ancestorId === "string") {
45235
+ if (visited.has(ancestorId)) return null;
45236
+ visited.add(ancestorId);
45237
+ const ancestor = classesById.get(ancestorId);
45238
+ if (ancestor === void 0) return null;
45239
+ if (typeof ancestor.schema[schemaKey] === "string") {
45240
+ return { ownerClass: ancestor, schemaKey };
45241
+ }
45242
+ ancestorId = ancestor.extendsClassId;
45243
+ }
45244
+ return null;
45245
+ }
45231
45246
  function walkExtendsMemberChain(startId, members, pick, options) {
45232
45247
  const requireKind = options?.requireKind;
45233
45248
  const maxHops = options?.maxHops ?? 16;
@@ -57224,6 +57239,104 @@ var init_dialogue_sources = __esm({
57224
57239
  }
57225
57240
  });
57226
57241
 
57242
+ // ../src/models/variants/variants.ts
57243
+ function isNonEmptyString2(value) {
57244
+ if (typeof value !== "string") return false;
57245
+ return value.length > 0;
57246
+ }
57247
+ function isNeoClassVariant(value) {
57248
+ if (typeof value !== "object" || value === null) return false;
57249
+ if (Array.isArray(value)) return false;
57250
+ const v = value;
57251
+ if (!isNonEmptyString2(v.id)) return false;
57252
+ if (!isNonEmptyString2(v.classId)) return false;
57253
+ if (!isNonEmptyString2(v.name)) return false;
57254
+ if (!isNonEmptyString2(v.valueId)) return false;
57255
+ if (v.folderId !== null && !isNonEmptyString2(v.folderId)) return false;
57256
+ return true;
57257
+ }
57258
+ function isNeoClassVariantFolder(value) {
57259
+ if (typeof value !== "object" || value === null) return false;
57260
+ if (Array.isArray(value)) return false;
57261
+ const v = value;
57262
+ if (!isNonEmptyString2(v.id)) return false;
57263
+ if (!isNonEmptyString2(v.classId)) return false;
57264
+ if (typeof v.path !== "string") return false;
57265
+ if (v.binding === void 0 || v.binding === null) return v.path.length > 0;
57266
+ if (typeof v.binding !== "object" || Array.isArray(v.binding)) return false;
57267
+ const binding = v.binding;
57268
+ if (!isNonEmptyString2(binding.collectionMemberId)) return false;
57269
+ if (!isNonEmptyString2(binding.collectionValueId)) return false;
57270
+ return true;
57271
+ }
57272
+ var NEO_VARIANT_INITIALIZE_SCHEMA_KEY, NEO_VARIANT_APPLY_SCHEMA_KEY, NEO_VARIANT_OVERRIDES_SCHEMA_KEY, NEO_VARIANT_CHILD_OVERRIDES_SCHEMA_KEY;
57273
+ var init_variants = __esm({
57274
+ "../src/models/variants/variants.ts"() {
57275
+ "use strict";
57276
+ NEO_VARIANT_INITIALIZE_SCHEMA_KEY = "Initialize";
57277
+ NEO_VARIANT_APPLY_SCHEMA_KEY = "Apply";
57278
+ NEO_VARIANT_OVERRIDES_SCHEMA_KEY = "Overrides";
57279
+ NEO_VARIANT_CHILD_OVERRIDES_SCHEMA_KEY = "ChildOverrides";
57280
+ }
57281
+ });
57282
+
57283
+ // ../src/models/variants/variant-member.ts
57284
+ function neoVariantSystemClass(classes, lookup = false) {
57285
+ const declared = classes.find(
57286
+ (item) => item.system?.worldKind === (lookup ? NeoWorldSystemClassKind.LookupVariant : NeoWorldSystemClassKind.Variant)
57287
+ );
57288
+ if (declared === void 0) return null;
57289
+ const targetParamId = declared.genericParams?.[0]?.id;
57290
+ if (targetParamId === void 0) return null;
57291
+ const valueParamId = declared.genericParams?.[1]?.id;
57292
+ return {
57293
+ classId: declared.id,
57294
+ targetParamId,
57295
+ ...valueParamId === void 0 ? {} : { valueParamId }
57296
+ };
57297
+ }
57298
+ var init_variant_member = __esm({
57299
+ "../src/models/variants/variant-member.ts"() {
57300
+ "use strict";
57301
+ init_core();
57302
+ init_member_kind_enum();
57303
+ }
57304
+ });
57305
+
57306
+ // ../src/models/variants/variant-naming.ts
57307
+ var init_variant_naming = __esm({
57308
+ "../src/models/variants/variant-naming.ts"() {
57309
+ "use strict";
57310
+ }
57311
+ });
57312
+
57313
+ // ../src/models/variants/variant-write.ts
57314
+ var init_variant_write = __esm({
57315
+ "../src/models/variants/variant-write.ts"() {
57316
+ "use strict";
57317
+ }
57318
+ });
57319
+
57320
+ // ../src/models/variants/variant-initialize-source.ts
57321
+ var init_variant_initialize_source = __esm({
57322
+ "../src/models/variants/variant-initialize-source.ts"() {
57323
+ "use strict";
57324
+ init_member_kind_enum();
57325
+ }
57326
+ });
57327
+
57328
+ // ../src/models/variants/index.ts
57329
+ var init_variants2 = __esm({
57330
+ "../src/models/variants/index.ts"() {
57331
+ "use strict";
57332
+ init_variants();
57333
+ init_variant_member();
57334
+ init_variant_naming();
57335
+ init_variant_write();
57336
+ init_variant_initialize_source();
57337
+ }
57338
+ });
57339
+
57227
57340
  // src/project-source/lower-support.ts
57228
57341
  function identityMap(declarations, kind) {
57229
57342
  return new Map(
@@ -61184,99 +61297,6 @@ var init_member_value_id = __esm({
61184
61297
  }
61185
61298
  });
61186
61299
 
61187
- // ../src/models/variants/variants.ts
61188
- function isNonEmptyString2(value) {
61189
- if (typeof value !== "string") return false;
61190
- return value.length > 0;
61191
- }
61192
- function isNeoClassVariant(value) {
61193
- if (typeof value !== "object" || value === null) return false;
61194
- if (Array.isArray(value)) return false;
61195
- const v = value;
61196
- if (!isNonEmptyString2(v.id)) return false;
61197
- if (!isNonEmptyString2(v.classId)) return false;
61198
- if (!isNonEmptyString2(v.name)) return false;
61199
- if (!isNonEmptyString2(v.valueId)) return false;
61200
- if (v.folderId !== null && !isNonEmptyString2(v.folderId)) return false;
61201
- return true;
61202
- }
61203
- function isNeoClassVariantFolder(value) {
61204
- if (typeof value !== "object" || value === null) return false;
61205
- if (Array.isArray(value)) return false;
61206
- const v = value;
61207
- if (!isNonEmptyString2(v.id)) return false;
61208
- if (!isNonEmptyString2(v.classId)) return false;
61209
- if (typeof v.path !== "string") return false;
61210
- if (v.binding === void 0 || v.binding === null) return v.path.length > 0;
61211
- if (typeof v.binding !== "object" || Array.isArray(v.binding)) return false;
61212
- const binding = v.binding;
61213
- if (!isNonEmptyString2(binding.collectionMemberId)) return false;
61214
- if (!isNonEmptyString2(binding.collectionValueId)) return false;
61215
- return true;
61216
- }
61217
- var init_variants = __esm({
61218
- "../src/models/variants/variants.ts"() {
61219
- "use strict";
61220
- }
61221
- });
61222
-
61223
- // ../src/models/variants/variant-member.ts
61224
- function neoVariantSystemClass(classes, lookup = false) {
61225
- const declared = classes.find(
61226
- (item) => item.system?.worldKind === (lookup ? NeoWorldSystemClassKind.LookupVariant : NeoWorldSystemClassKind.Variant)
61227
- );
61228
- if (declared === void 0) return null;
61229
- const targetParamId = declared.genericParams?.[0]?.id;
61230
- if (targetParamId === void 0) return null;
61231
- const valueParamId = declared.genericParams?.[1]?.id;
61232
- return {
61233
- classId: declared.id,
61234
- targetParamId,
61235
- ...valueParamId === void 0 ? {} : { valueParamId }
61236
- };
61237
- }
61238
- var init_variant_member = __esm({
61239
- "../src/models/variants/variant-member.ts"() {
61240
- "use strict";
61241
- init_core();
61242
- init_member_kind_enum();
61243
- }
61244
- });
61245
-
61246
- // ../src/models/variants/variant-naming.ts
61247
- var init_variant_naming = __esm({
61248
- "../src/models/variants/variant-naming.ts"() {
61249
- "use strict";
61250
- }
61251
- });
61252
-
61253
- // ../src/models/variants/variant-write.ts
61254
- var init_variant_write = __esm({
61255
- "../src/models/variants/variant-write.ts"() {
61256
- "use strict";
61257
- }
61258
- });
61259
-
61260
- // ../src/models/variants/variant-initialize-source.ts
61261
- var init_variant_initialize_source = __esm({
61262
- "../src/models/variants/variant-initialize-source.ts"() {
61263
- "use strict";
61264
- init_member_kind_enum();
61265
- }
61266
- });
61267
-
61268
- // ../src/models/variants/index.ts
61269
- var init_variants2 = __esm({
61270
- "../src/models/variants/index.ts"() {
61271
- "use strict";
61272
- init_variants();
61273
- init_variant_member();
61274
- init_variant_naming();
61275
- init_variant_write();
61276
- init_variant_initialize_source();
61277
- }
61278
- });
61279
-
61280
61300
  // ../src/models/project/project-root-members.ts
61281
61301
  function buildRootStorageMap(project) {
61282
61302
  const map = /* @__PURE__ */ new Map();
@@ -82093,6 +82113,16 @@ function neoScriptMemberContractProjection(value) {
82093
82113
  defaultPresent: value.defaultValue != null
82094
82114
  };
82095
82115
  }
82116
+ function transactionImpactsAnyOwnerMember(scope, impactedIds) {
82117
+ for (const member of scope.document.members) {
82118
+ if (impactedIds.has(member.id)) return true;
82119
+ }
82120
+ for (const root of scope.roots) {
82121
+ const ownerId = Reflect.get(root.member, "id");
82122
+ if (typeof ownerId === "string" && impactedIds.has(ownerId)) return true;
82123
+ }
82124
+ return false;
82125
+ }
82096
82126
  function collectNeoScriptRecompileTargets(args) {
82097
82127
  if (args.forceRecompile === true) return completeTargets(args.postDocument);
82098
82128
  const explicit = explicitTargetIds(args.changes);
@@ -82156,15 +82186,17 @@ function collectNeoScriptRecompileTargets(args) {
82156
82186
  args.postDocument,
82157
82187
  args.postDocument.variants ?? []
82158
82188
  );
82159
- const ownerByValueId = resolveOwnerMembersForValues(
82160
- scope.document,
82161
- new Set(postValues.map((record3) => record3.id)),
82162
- scope.roots
82163
- );
82164
- for (const [valueId, owner] of ownerByValueId) {
82165
- const ownerId = Reflect.get(owner, "id");
82166
- if (typeof ownerId === "string" && impactedIds.has(ownerId)) {
82167
- valueIds.add(valueId);
82189
+ if (transactionImpactsAnyOwnerMember(scope, impactedIds)) {
82190
+ const ownerByValueId = resolveOwnerMembersForValues(
82191
+ scope.document,
82192
+ new Set(postValues.map((record3) => record3.id)),
82193
+ scope.roots
82194
+ );
82195
+ for (const [valueId, owner] of ownerByValueId) {
82196
+ const ownerId = Reflect.get(owner, "id");
82197
+ if (typeof ownerId === "string" && impactedIds.has(ownerId)) {
82198
+ valueIds.add(valueId);
82199
+ }
82168
82200
  }
82169
82201
  }
82170
82202
  }
@@ -88544,6 +88576,56 @@ var init_project_version_transaction_types = __esm({
88544
88576
  }
88545
88577
  });
88546
88578
 
88579
+ // ../src/database/project-version-relation-sweep-trigger.ts
88580
+ function stagedChangesAffectClassRelations(current, changes) {
88581
+ const classesById = new Map(
88582
+ (current.classes ?? []).map((schemaClass2) => [schemaClass2.id, schemaClass2])
88583
+ );
88584
+ const valuesById = new Map(
88585
+ (current.values ?? []).map((value) => [value.id, value])
88586
+ );
88587
+ for (const change of changes) {
88588
+ if (change.recordKind === "internal-record-relation") return true;
88589
+ if (change.recordKind === "class") {
88590
+ if (change.operation !== "update") return true;
88591
+ if (change.deleted === true) return true;
88592
+ const before2 = classesById.get(change.recordId);
88593
+ if (before2 === void 0) return true;
88594
+ const after = change.nextData;
88595
+ if (!isPlainRecord(after)) return true;
88596
+ if (before2.extendsClassId !== after.extendsClassId) return true;
88597
+ continue;
88598
+ }
88599
+ if (change.recordKind !== "value") continue;
88600
+ const before = valuesById.get(change.recordId);
88601
+ if (valueCreateCannotAffectClassRelations(change, before)) continue;
88602
+ if (relationEndpointClassId(before) !== relationEndpointClassId(change.nextData)) {
88603
+ return true;
88604
+ }
88605
+ }
88606
+ return false;
88607
+ }
88608
+ function valueCreateCannotAffectClassRelations(change, before) {
88609
+ if (change.operation !== "create") return false;
88610
+ if (change.deleted === true) return false;
88611
+ return before === void 0;
88612
+ }
88613
+ function relationEndpointClassId(record3) {
88614
+ if (!isPlainRecord(record3)) return void 0;
88615
+ if (typeof record3.classId === "string") return record3.classId;
88616
+ if (typeof record3.typeId === "string") return record3.typeId;
88617
+ return void 0;
88618
+ }
88619
+ function isPlainRecord(value) {
88620
+ if (value === null || typeof value !== "object") return false;
88621
+ return !Array.isArray(value);
88622
+ }
88623
+ var init_project_version_relation_sweep_trigger = __esm({
88624
+ "../src/database/project-version-relation-sweep-trigger.ts"() {
88625
+ "use strict";
88626
+ }
88627
+ });
88628
+
88547
88629
  // ../src/database/project-version-transaction-planning.ts
88548
88630
  function variantRootValueId2(data) {
88549
88631
  if (typeof data !== "object" || data === null) return null;
@@ -88565,7 +88647,7 @@ function addProjectVersionTransactionBudgets(left, right) {
88565
88647
  returnBytes: left.returnBytes + right.returnBytes
88566
88648
  };
88567
88649
  }
88568
- var KIB, MIB, PROJECT_TRANSACTION_CHUNK_PAYLOAD_TARGET_BYTES, PROJECT_TRANSACTION_IMMEDIATE_BUDGET, PROJECT_TRANSACTION_WORKER_BUDGET, PROJECT_TRANSACTION_SINGLE_CHANGE_NATIVE_BUDGET, EMPTY_BUDGET, CHUNK_GRAPH_VALIDATION_RESERVE, CHUNK_FIXED_COST, IMMEDIATE_FIXED_COST, WHOLE_GRAPH_VALIDATION_SURCHARGE;
88650
+ var KIB, MIB, PROJECT_TRANSACTION_CHUNK_PAYLOAD_TARGET_BYTES, PROJECT_TRANSACTION_IMMEDIATE_BUDGET, PROJECT_TRANSACTION_WORKER_BUDGET, PROJECT_TRANSACTION_SINGLE_CHANGE_NATIVE_BUDGET, EMPTY_BUDGET, CHUNK_GRAPH_VALIDATION_RESERVE, CHUNK_FIXED_COST, IMMEDIATE_FIXED_COST, WHOLE_GRAPH_VALIDATION_SURCHARGE, CHANGE_BYTES_READ_OVERHEAD, CHANGE_BYTES_WRITTEN_OVERHEAD;
88569
88651
  var init_project_version_transaction_planning = __esm({
88570
88652
  "../src/database/project-version-transaction-planning.ts"() {
88571
88653
  "use strict";
@@ -88579,8 +88661,8 @@ var init_project_version_transaction_planning = __esm({
88579
88661
  bytesWritten: 4 * MIB,
88580
88662
  documentsRead: 4e3,
88581
88663
  documentsWritten: 1400,
88582
- databaseQueries: 420,
88583
- indexRanges: 320,
88664
+ databaseQueries: 800,
88665
+ indexRanges: 800,
88584
88666
  functionsScheduled: 24,
88585
88667
  scheduledFunctionArgsBytes: 64 * KIB,
88586
88668
  returnBytes: 4 * MIB
@@ -88591,8 +88673,8 @@ var init_project_version_transaction_planning = __esm({
88591
88673
  bytesWritten: 4 * MIB,
88592
88674
  documentsRead: 4e3,
88593
88675
  documentsWritten: 900,
88594
- databaseQueries: 420,
88595
- indexRanges: 320,
88676
+ databaseQueries: 700,
88677
+ indexRanges: 700,
88596
88678
  functionsScheduled: 8,
88597
88679
  scheduledFunctionArgsBytes: 32 * KIB,
88598
88680
  returnBytes: 128 * KIB
@@ -88628,9 +88710,9 @@ var init_project_version_transaction_planning = __esm({
88628
88710
  bytesRead: 32 * KIB,
88629
88711
  bytesWritten: 48 * KIB,
88630
88712
  documentsRead: 4,
88631
- documentsWritten: 4,
88632
- databaseQueries: 10,
88633
- indexRanges: 8,
88713
+ documentsWritten: 5,
88714
+ databaseQueries: 97,
88715
+ indexRanges: 105,
88634
88716
  functionsScheduled: 2,
88635
88717
  scheduledFunctionArgsBytes: 2 * KIB,
88636
88718
  returnBytes: 2 * KIB
@@ -88639,21 +88721,23 @@ var init_project_version_transaction_planning = __esm({
88639
88721
  argumentBytes: 2 * KIB,
88640
88722
  bytesRead: 96 * KIB,
88641
88723
  bytesWritten: 64 * KIB,
88642
- documentsRead: 12,
88643
- documentsWritten: 4,
88724
+ documentsRead: 18,
88725
+ documentsWritten: 8,
88644
88726
  databaseQueries: 34,
88645
- indexRanges: 24,
88727
+ indexRanges: 34,
88646
88728
  functionsScheduled: 4,
88647
88729
  scheduledFunctionArgsBytes: 8 * KIB,
88648
88730
  returnBytes: 8 * KIB
88649
88731
  };
88650
88732
  WHOLE_GRAPH_VALIDATION_SURCHARGE = {
88651
88733
  ...EMPTY_BUDGET,
88652
- bytesRead: 512 * KIB,
88653
- documentsRead: 400,
88654
- databaseQueries: 300,
88655
- indexRanges: 200
88734
+ bytesRead: 336 * KIB,
88735
+ documentsRead: 782,
88736
+ databaseQueries: 410,
88737
+ indexRanges: 410
88656
88738
  };
88739
+ CHANGE_BYTES_READ_OVERHEAD = 4 * KIB;
88740
+ CHANGE_BYTES_WRITTEN_OVERHEAD = 4 * KIB;
88657
88741
  }
88658
88742
  });
88659
88743
 
@@ -89764,6 +89848,97 @@ var init_localizable_member_value_writes = __esm({
89764
89848
  });
89765
89849
 
89766
89850
  // ../src/database/project-version-schema-commit.ts
89851
+ function indexRecordsById(records2) {
89852
+ const recordsById2 = /* @__PURE__ */ new Map();
89853
+ for (const record3 of records2) recordsById2.set(record3.id, record3);
89854
+ return recordsById2;
89855
+ }
89856
+ function indexLiveContentHashesByRecordId(heads, recordKind) {
89857
+ const hashes = /* @__PURE__ */ new Map();
89858
+ for (const head of heads) {
89859
+ if (head.recordKind !== recordKind || head.deleted) continue;
89860
+ hashes.set(head.recordId, head.contentHash);
89861
+ }
89862
+ return hashes;
89863
+ }
89864
+ function indexLiveContentHashesByRecordKey(heads) {
89865
+ const hashes = /* @__PURE__ */ new Map();
89866
+ for (const head of heads) {
89867
+ if (head.deleted) continue;
89868
+ hashes.set(`${head.recordKind}:${head.recordId}`, head.contentHash);
89869
+ }
89870
+ return hashes;
89871
+ }
89872
+ function indexChangesByRecordId(changes, recordKind) {
89873
+ const indexes = /* @__PURE__ */ new Map();
89874
+ for (let index = 0; index < changes.length; index += 1) {
89875
+ const change = changes[index];
89876
+ if (change?.recordKind === recordKind) indexes.set(change.recordId, index);
89877
+ }
89878
+ return indexes;
89879
+ }
89880
+ function reconcileDirectOverrideChains(args) {
89881
+ if (!args.changes.some(
89882
+ (change) => change.recordKind === "class" || change.recordKind === "member"
89883
+ )) {
89884
+ return;
89885
+ }
89886
+ const postDocument = applyProjectVersionWriteChanges(
89887
+ args.document,
89888
+ args.changes
89889
+ );
89890
+ const postClassesById = indexRecordsById(postDocument.classes);
89891
+ const postMembersById = indexRecordsById(postDocument.members);
89892
+ const changeIndexByMemberId = indexChangesByRecordId(args.changes, "member");
89893
+ let baseHashByMemberId = null;
89894
+ for (const schemaClass2 of postDocument.classes) {
89895
+ for (const [schemaKey, memberId] of Object.entries(schemaClass2.schema)) {
89896
+ const member = postMembersById.get(memberId);
89897
+ if (member === void 0 || typeof member.extendsMemberId !== "string") {
89898
+ continue;
89899
+ }
89900
+ const expectedPlacement = findNearestAncestorSchemaPlacement(
89901
+ schemaClass2,
89902
+ schemaKey,
89903
+ postClassesById
89904
+ );
89905
+ const expected = expectedPlacement?.ownerClass.schema[expectedPlacement.schemaKey];
89906
+ if (expected === member.extendsMemberId) continue;
89907
+ if (typeof expected !== "string") continue;
89908
+ const nextMember = { ...member, extendsMemberId: expected };
89909
+ postMembersById.set(member.id, nextMember);
89910
+ const existingIndex = changeIndexByMemberId.get(member.id);
89911
+ if (existingIndex !== void 0) {
89912
+ const existing = args.changes[existingIndex];
89913
+ if (existing !== void 0) {
89914
+ args.changes[existingIndex] = { ...existing, nextData: nextMember };
89915
+ }
89916
+ continue;
89917
+ }
89918
+ baseHashByMemberId ??= indexLiveContentHashesByRecordId(
89919
+ args.contentHashHeads,
89920
+ "member"
89921
+ );
89922
+ const expectedBaseContentHash = baseHashByMemberId.get(member.id);
89923
+ if (expectedBaseContentHash === void 0) {
89924
+ throw new Error(
89925
+ `Cannot safely repair override chain for member "${member.name}" (${member.id}): its current content hash is unavailable.`
89926
+ );
89927
+ }
89928
+ changeIndexByMemberId.set(member.id, args.changes.length);
89929
+ args.changes.push({
89930
+ recordKind: "member",
89931
+ recordId: member.id,
89932
+ operation: "update",
89933
+ nextData: nextMember,
89934
+ expectedBaseContentHash,
89935
+ intent: createProjectVersionIntent("member.update", {
89936
+ source: "server-direct-override-chain-reconcile"
89937
+ })
89938
+ });
89939
+ }
89940
+ }
89941
+ }
89767
89942
  function prepareServerOwnedSchemaCommit(args) {
89768
89943
  if (args.forceRecompile === true) clearNeoScriptBodyCompileCache();
89769
89944
  assertUniqueChanges(args.changes);
@@ -89784,6 +89959,18 @@ function prepareServerOwnedSchemaCommit(args) {
89784
89959
  ),
89785
89960
  changes: authoredChanges
89786
89961
  });
89962
+ const explicitlyChangedMemberIds = /* @__PURE__ */ new Set();
89963
+ for (const change of authoredChanges) {
89964
+ if (change.recordKind !== "member" || change.operation === "delete") {
89965
+ continue;
89966
+ }
89967
+ explicitlyChangedMemberIds.add(change.recordId);
89968
+ }
89969
+ reconcileDirectOverrideChains({
89970
+ document: args.document,
89971
+ changes: authoredChanges,
89972
+ contentHashHeads: args.contentHashHeads
89973
+ });
89787
89974
  assertNoLegacyWorldLayerBindingFields(authoredChanges);
89788
89975
  const hasSchemaChange = authoredChanges.some(
89789
89976
  (change) => SCHEMA_RECORD_KINDS.has(change.recordKind)
@@ -89812,11 +89999,6 @@ function prepareServerOwnedSchemaCommit(args) {
89812
89999
  additionalImpactedIds: args.additionalImpactedIds,
89813
90000
  forceRecompile: args.forceRecompile
89814
90001
  });
89815
- const explicitlyChangedMemberIds = new Set(
89816
- authoredChanges.filter(
89817
- (change) => change.recordKind === "member" && change.operation !== "delete"
89818
- ).map((change) => change.recordId)
89819
- );
89820
90002
  const currentById = new Map(
89821
90003
  args.document.members.map((member) => [member.id, member])
89822
90004
  );
@@ -89875,9 +90057,12 @@ function prepareServerOwnedSchemaCommit(args) {
89875
90057
  const compiledById = new Map(
89876
90058
  sourceMembers.map((member) => [member.id, member])
89877
90059
  );
89878
- const explicitMemberIds = new Set(
89879
- authoredChanges.filter((change) => change.recordKind === "member").map((change) => change.recordId)
89880
- );
90060
+ const explicitMemberIds = /* @__PURE__ */ new Set();
90061
+ for (const change of authoredChanges) {
90062
+ if (change.recordKind === "member") {
90063
+ explicitMemberIds.add(change.recordId);
90064
+ }
90065
+ }
89881
90066
  const prepared = authoredChanges.map((change) => {
89882
90067
  if (change.recordKind !== "member" || change.operation === "delete") {
89883
90068
  return change;
@@ -89890,9 +90075,7 @@ function prepareServerOwnedSchemaCommit(args) {
89890
90075
  }
89891
90076
  return { ...change, nextData: compiled };
89892
90077
  });
89893
- const hashByKey = new Map(
89894
- args.contentHashHeads.filter((head) => !head.deleted).map((head) => [`${head.recordKind}:${head.recordId}`, head.contentHash])
89895
- );
90078
+ const hashByKey = indexLiveContentHashesByRecordKey(args.contentHashHeads);
89896
90079
  for (const compiled of sourceMembers) {
89897
90080
  if (!recompileTargets.memberIds.has(compiled.id)) continue;
89898
90081
  if (explicitMemberIds.has(compiled.id)) continue;
@@ -89946,11 +90129,16 @@ function prepareServerOwnedSchemaCommit(args) {
89946
90129
  if (listIndexErrors.length > 0) {
89947
90130
  throw new Error(listIndexErrors[0].message);
89948
90131
  }
89949
- validateInternalRecordRelations({
89950
- relations: postDocument.internalRecordRelations ?? [],
89951
- endpoints: collectProjectDocumentRelationEndpoints(postDocument),
89952
- classes: postDocument.classes
89953
- });
90132
+ if (stagedChangesAffectClassRelations(args.document, [
90133
+ ...prepared,
90134
+ ...readOnlyConversionChanges
90135
+ ])) {
90136
+ validateInternalRecordRelations({
90137
+ relations: postDocument.internalRecordRelations ?? [],
90138
+ endpoints: collectProjectDocumentRelationEndpoints(postDocument),
90139
+ classes: postDocument.classes
90140
+ });
90141
+ }
89954
90142
  const accessModifierErrors = validateDocumentAccessModifiers({
89955
90143
  members: postDocument.members,
89956
90144
  classes: postDocument.classes,
@@ -90097,10 +90285,6 @@ function orderVariantRootValuesWithVariants(prepared) {
90097
90285
  return ordered;
90098
90286
  }
90099
90287
  function materializePreparedInstanceInitializers(args) {
90100
- const compiledDocument = applyProjectVersionWriteChanges(
90101
- args.document,
90102
- args.prepared
90103
- );
90104
90288
  const sites = /* @__PURE__ */ new Map();
90105
90289
  for (let index = 0; index < args.prepared.length; index += 1) {
90106
90290
  const change = args.prepared[index];
@@ -90115,6 +90299,10 @@ function materializePreparedInstanceInitializers(args) {
90115
90299
  });
90116
90300
  }
90117
90301
  if (sites.size === 0) return;
90302
+ const compiledDocument = applyProjectVersionWriteChanges(
90303
+ args.document,
90304
+ args.prepared
90305
+ );
90118
90306
  const existingValueById = new Map(
90119
90307
  args.document.values.map((value) => [value.id, value])
90120
90308
  );
@@ -91496,6 +91684,15 @@ function normalizeClientBindingMemberCreates(args) {
91496
91684
  };
91497
91685
  }
91498
91686
  }
91687
+ function stampsAbsentBindingMember(value, existingMemberIds) {
91688
+ const stamp = value.genericBindings;
91689
+ if (stamp === void 0 || stamp === null) return false;
91690
+ for (const bindingMemberId of Object.values(stamp)) {
91691
+ if (typeof bindingMemberId !== "string") continue;
91692
+ if (!existingMemberIds.has(bindingMemberId)) return true;
91693
+ }
91694
+ return false;
91695
+ }
91499
91696
  function materializeVariantChildOverrideBindingMembers(args) {
91500
91697
  normalizeClientBindingMemberCreates(args);
91501
91698
  const postDocument = applyProjectVersionWriteChanges(
@@ -91504,6 +91701,13 @@ function materializeVariantChildOverrideBindingMembers(args) {
91504
91701
  );
91505
91702
  const variants = postDocument.variants ?? [];
91506
91703
  if (variants.length === 0) return;
91704
+ const existingMemberIds = new Set(
91705
+ postDocument.members.map((member) => member.id)
91706
+ );
91707
+ const candidates = postDocument.values.filter(
91708
+ (value) => stampsAbsentBindingMember(value, existingMemberIds)
91709
+ );
91710
+ if (candidates.length === 0) return;
91507
91711
  const graphValueIds = collectVariantGraphValueIds({
91508
91712
  document: postDocument,
91509
91713
  variants,
@@ -91516,11 +91720,8 @@ function materializeVariantChildOverrideBindingMembers(args) {
91516
91720
  schemaClass2.id
91517
91721
  ])
91518
91722
  );
91519
- const existingMemberIds = new Set(
91520
- postDocument.members.map((member) => member.id)
91521
- );
91522
91723
  const minted = /* @__PURE__ */ new Set();
91523
- for (const value of postDocument.values) {
91724
+ for (const value of candidates) {
91524
91725
  if (!graphValueIds.has(value.id)) continue;
91525
91726
  const stamp = value.genericBindings;
91526
91727
  if (stamp === void 0 || stamp === null) continue;
@@ -93209,32 +93410,17 @@ function reconcileVariantConstructorArgs(args) {
93209
93410
  );
93210
93411
  const variants = postDocument.variants ?? [];
93211
93412
  if (variants.length === 0) return;
93212
- const valueById = new Map(
93213
- postDocument.values.map((value) => [value.id, value])
93214
- );
93215
- const classById = new Map(
93216
- postDocument.classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
93217
- );
93218
- const memberById = new Map(
93219
- postDocument.members.map((member) => [member.id, member])
93220
- );
93221
- const constructorById = new Map(
93222
- (postDocument.constructors ?? []).map((record3) => [record3.id, record3])
93223
- );
93224
- const changeIndexByValueId = /* @__PURE__ */ new Map();
93225
- args.prepared.forEach((change, index) => {
93226
- if (change.recordKind !== "value") return;
93227
- changeIndexByValueId.set(change.recordId, index);
93228
- });
93229
- const baseHashByValueId = new Map(
93230
- args.contentHashHeads.filter((head) => head.recordKind === "value" && !head.deleted).map((head) => [head.recordId, head.contentHash])
93231
- );
93413
+ const valueById = indexRecordsById(postDocument.values);
93414
+ const classById = indexRecordsById(postDocument.classes);
93415
+ const memberById = indexRecordsById(postDocument.members);
93416
+ const constructorById = indexRecordsById(postDocument.constructors ?? []);
93417
+ const changeIndexByValueId = indexChangesByRecordId(args.prepared, "value");
93418
+ let baseHashByValueId = null;
93232
93419
  for (const variant of variants) {
93233
93420
  const root = valueById.get(variant.valueId);
93234
93421
  if (root === void 0) continue;
93235
93422
  if (!isLiteralValueContent(root)) continue;
93236
- const existingArgs = root.constructorArgs;
93237
- if (existingArgs === void 0 || existingArgs === null) continue;
93423
+ const existingArgs = root.constructorArgs ?? {};
93238
93424
  const rootClassId = root.classId;
93239
93425
  if (typeof rootClassId !== "string") continue;
93240
93426
  const schemaClass2 = classById.get(rootClassId);
@@ -93245,37 +93431,46 @@ function reconcileVariantConstructorArgs(args) {
93245
93431
  if (constructorRecord === void 0) continue;
93246
93432
  if (typeof root.value !== "object" || root.value === null) continue;
93247
93433
  if (Array.isArray(root.value)) continue;
93248
- const nextArgs = { ...existingArgs };
93249
- let changed = false;
93250
- constructorRecord.argumentTypes.forEach((argument2, index) => {
93434
+ const nextArgs = {};
93435
+ for (let index = 0; index < constructorRecord.argumentTypes.length; index += 1) {
93436
+ const argument2 = constructorRecord.argumentTypes[index];
93437
+ if (argument2 === void 0) continue;
93251
93438
  const parameterId = constructorActionParameterId(
93252
93439
  constructorRecord,
93253
93440
  index
93254
93441
  );
93255
- if (!(parameterId in nextArgs)) return;
93256
- const schemaKey = Object.keys(schemaClass2.schema).find(
93257
- (key) => key.toLowerCase() === argument2.name.toLowerCase()
93442
+ const schemaKey = NEO_VARIANT_SCHEMA_KEY_BY_ARGUMENT_NAME.get(
93443
+ argument2.name.toLowerCase()
93258
93444
  );
93259
- if (schemaKey === void 0) return;
93445
+ if (schemaKey === void 0) continue;
93260
93446
  const memberId = schemaClass2.schema[schemaKey];
93261
93447
  const member = memberId === void 0 ? void 0 : memberById.get(memberId);
93262
- if (member?.kind !== 25 /* NSDelegate */) return;
93448
+ if (member === void 0) continue;
93263
93449
  const childId = root.value[schemaKey];
93264
- if (typeof childId !== "string") return;
93450
+ if (typeof childId !== "string") continue;
93265
93451
  const childRow = valueById.get(childId);
93266
- if (childRow === void 0 || !isLiteralValueContent(childRow)) return;
93452
+ if (childRow === void 0 || !isLiteralValueContent(childRow)) continue;
93267
93453
  const rowValue = childRow.value;
93268
- if (typeof rowValue !== "object" || rowValue === null) return;
93269
- if (Array.isArray(rowValue)) return;
93270
- const rowCode = rowValue.code;
93271
- if (typeof rowCode !== "string") return;
93272
- const derived = { code: rowCode };
93273
- if (canonicalJsonStringify(nextArgs[parameterId]) === canonicalJsonStringify(derived)) {
93274
- return;
93454
+ if (variantConstructorArgumentIsRestValue(schemaKey, rowValue)) {
93455
+ continue;
93275
93456
  }
93276
- nextArgs[parameterId] = derived;
93277
- changed = true;
93278
- });
93457
+ if (member.kind === 25 /* NSDelegate */) {
93458
+ if (typeof rowValue !== "object" || rowValue === null) continue;
93459
+ if (Array.isArray(rowValue)) continue;
93460
+ const rowCode = rowValue.code;
93461
+ if (typeof rowCode !== "string") continue;
93462
+ nextArgs[parameterId] = { code: rowCode };
93463
+ continue;
93464
+ }
93465
+ if (member.kind === 7 /* Class */ || member.kind === 22 /* Interface */ || member.kind === 21 /* Generic */ || member.kind === 6 /* List */ || member.kind === 5 /* Dictionary */) {
93466
+ nextArgs[parameterId] = childId;
93467
+ continue;
93468
+ }
93469
+ const defaultValue = argument2.defaultValue?.value;
93470
+ if (canonicallyEqual2(rowValue, defaultValue)) continue;
93471
+ nextArgs[parameterId] = rowValue;
93472
+ }
93473
+ const changed = !canonicallyEqual2(existingArgs, nextArgs);
93279
93474
  if (!changed) continue;
93280
93475
  const nextRoot = { ...root, constructorArgs: nextArgs };
93281
93476
  const existingIndex = changeIndexByValueId.get(root.id);
@@ -93286,8 +93481,13 @@ function reconcileVariantConstructorArgs(args) {
93286
93481
  }
93287
93482
  continue;
93288
93483
  }
93484
+ baseHashByValueId ??= indexLiveContentHashesByRecordId(
93485
+ args.contentHashHeads,
93486
+ "value"
93487
+ );
93289
93488
  const baseContentHash = baseHashByValueId.get(root.id);
93290
93489
  if (baseContentHash === void 0) continue;
93490
+ changeIndexByValueId.set(root.id, args.prepared.length);
93291
93491
  args.prepared.push({
93292
93492
  recordKind: "value",
93293
93493
  recordId: root.id,
@@ -93300,6 +93500,13 @@ function reconcileVariantConstructorArgs(args) {
93300
93500
  });
93301
93501
  }
93302
93502
  }
93503
+ function variantConstructorArgumentIsRestValue(schemaKey, value) {
93504
+ if (value === null) return true;
93505
+ if (schemaKey === NEO_VARIANT_OVERRIDES_SCHEMA_KEY) {
93506
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0;
93507
+ }
93508
+ return schemaKey === NEO_VARIANT_CHILD_OVERRIDES_SCHEMA_KEY && Array.isArray(value) && value.length === 0;
93509
+ }
93303
93510
  function appendVariantGraphCascadeDeletes(args) {
93304
93511
  const deletedVariantIds = /* @__PURE__ */ new Set();
93305
93512
  for (const change of args.prepared) {
@@ -93313,11 +93520,13 @@ function appendVariantGraphCascadeDeletes(args) {
93313
93520
  variants: args.document.variants ?? [],
93314
93521
  variantIds: deletedVariantIds
93315
93522
  });
93316
- const alreadyChanged = new Set(
93317
- args.prepared.filter((change) => change.recordKind === "value").map((change) => change.recordId)
93318
- );
93319
- const baseHashByValueId = new Map(
93320
- args.contentHashHeads.filter((head) => head.recordKind === "value").map((head) => [head.recordId, head.contentHash])
93523
+ const alreadyChanged = /* @__PURE__ */ new Set();
93524
+ for (const change of args.prepared) {
93525
+ if (change.recordKind === "value") alreadyChanged.add(change.recordId);
93526
+ }
93527
+ const baseHashByValueId = indexLiveContentHashesByRecordId(
93528
+ args.contentHashHeads,
93529
+ "value"
93321
93530
  );
93322
93531
  for (const valueId of valueIds) {
93323
93532
  if (alreadyChanged.has(valueId)) continue;
@@ -93339,7 +93548,7 @@ function appendVariantGraphCascadeDeletes(args) {
93339
93548
  });
93340
93549
  }
93341
93550
  }
93342
- var SERVER_COMPILATION_PROJECT_CACHE_LIMIT, serverCompilationProjectCache, READ_ONLY_SOURCE_CONVERSION_INTENT_SOURCE, SCHEMA_RECORD_KINDS, DIALOGUE_SOURCE_RECORD_KINDS;
93551
+ var SERVER_COMPILATION_PROJECT_CACHE_LIMIT, serverCompilationProjectCache, READ_ONLY_SOURCE_CONVERSION_INTENT_SOURCE, SCHEMA_RECORD_KINDS, DIALOGUE_SOURCE_RECORD_KINDS, NEO_VARIANT_SCHEMA_KEY_BY_ARGUMENT_NAME;
93343
93552
  var init_project_version_schema_commit = __esm({
93344
93553
  "../src/database/project-version-schema-commit.ts"() {
93345
93554
  "use strict";
@@ -93352,6 +93561,7 @@ var init_project_version_schema_commit = __esm({
93352
93561
  init_project2();
93353
93562
  init_member_access_modifier_validation();
93354
93563
  init_variant_value_graph();
93564
+ init_variants2();
93355
93565
  init_localization2();
93356
93566
  init_internal_record_relations();
93357
93567
  init_project_content_hash();
@@ -93364,6 +93574,7 @@ var init_project_version_schema_commit = __esm({
93364
93574
  init_general_function_call_ir_source_recompile();
93365
93575
  init_projectDocumentDialogueMaterialization();
93366
93576
  init_project_version_transaction_types();
93577
+ init_project_version_relation_sweep_trigger();
93367
93578
  init_project_version_transaction_planning();
93368
93579
  init_project_version_static_value_writes();
93369
93580
  init_localizable_member_value_writes();
@@ -93393,12 +93604,18 @@ var init_project_version_schema_commit = __esm({
93393
93604
  "dialogue-node",
93394
93605
  "dialogue-group"
93395
93606
  ]);
93607
+ NEO_VARIANT_SCHEMA_KEY_BY_ARGUMENT_NAME = /* @__PURE__ */ new Map([
93608
+ ["initialize", NEO_VARIANT_INITIALIZE_SCHEMA_KEY],
93609
+ ["apply", NEO_VARIANT_APPLY_SCHEMA_KEY],
93610
+ ["overrides", NEO_VARIANT_OVERRIDES_SCHEMA_KEY],
93611
+ ["childoverrides", NEO_VARIANT_CHILD_OVERRIDES_SCHEMA_KEY]
93612
+ ]);
93396
93613
  }
93397
93614
  });
93398
93615
 
93399
93616
  // ../src/database/project-record-semantics.ts
93400
93617
  function projectRecordSemanticData(value) {
93401
- if (!isPlainRecord(value)) return value;
93618
+ if (!isPlainRecord2(value)) return value;
93402
93619
  const semantic = {};
93403
93620
  for (const [key, child] of Object.entries(value)) {
93404
93621
  if (SERVER_MANAGED_PROJECT_RECORD_FIELDS.has(key)) continue;
@@ -93435,7 +93652,7 @@ function toCanonicalJsonValue2(value) {
93435
93652
  if (Array.isArray(value)) {
93436
93653
  return value.map((item) => toCanonicalJsonValue2(item) ?? null);
93437
93654
  }
93438
- if (!isPlainRecord(value)) {
93655
+ if (!isPlainRecord2(value)) {
93439
93656
  throw new Error("Cannot canonicalize a non-plain object.");
93440
93657
  }
93441
93658
  const canonical = {};
@@ -93449,7 +93666,7 @@ function toCanonicalJsonValue2(value) {
93449
93666
  }
93450
93667
  return canonical;
93451
93668
  }
93452
- function isPlainRecord(value) {
93669
+ function isPlainRecord2(value) {
93453
93670
  if (value === null || typeof value !== "object") return false;
93454
93671
  const prototype = Object.getPrototypeOf(value);
93455
93672
  return prototype === Object.prototype || prototype === null;
@@ -93558,7 +93775,7 @@ function systemProtectedWriteInheritedRecordId(write) {
93558
93775
  if (write.baseData !== void 0) return null;
93559
93776
  if (write.deleted) return null;
93560
93777
  if (!isSystemBearingRecordKind(write.recordKind)) return null;
93561
- if (!isPlainRecord2(write.nextData)) return null;
93778
+ if (!isPlainRecord3(write.nextData)) return null;
93562
93779
  if (readSystemMetadata(write.nextData) === null) return null;
93563
93780
  const extendsMemberId = write.nextData.extendsMemberId;
93564
93781
  if (typeof extendsMemberId !== "string") return null;
@@ -93578,7 +93795,7 @@ function assertSystemProtectedRecordWriteValid(write) {
93578
93795
  assertSystemMetadataUnchanged(write, base);
93579
93796
  }
93580
93797
  function readBaseRecord(write) {
93581
- if (!isPlainRecord2(write.baseData)) return null;
93798
+ if (!isPlainRecord3(write.baseData)) return null;
93582
93799
  return {
93583
93800
  recordKind: write.recordKind,
93584
93801
  data: write.baseData,
@@ -93591,7 +93808,7 @@ function collectSystemBearingBaseRecords(document) {
93591
93808
  const stored = document[collection];
93592
93809
  if (!Array.isArray(stored)) continue;
93593
93810
  for (const record3 of stored) {
93594
- if (!isPlainRecord2(record3)) continue;
93811
+ if (!isPlainRecord3(record3)) continue;
93595
93812
  const id2 = record3.id;
93596
93813
  if (typeof id2 !== "string") continue;
93597
93814
  records2.set(baseKey(recordKind, id2), {
@@ -93605,7 +93822,7 @@ function collectSystemBearingBaseRecords(document) {
93605
93822
  }
93606
93823
  function assertCreateDeclaresNoSystemMetadata(write) {
93607
93824
  if (!isSystemBearingRecordKind(write.recordKind)) return;
93608
- if (!isPlainRecord2(write.nextData)) return;
93825
+ if (!isPlainRecord3(write.nextData)) return;
93609
93826
  const system = readSystemMetadata(write.nextData);
93610
93827
  if (system === null) return;
93611
93828
  if (inheritsLegacyEmittedSystemMetadata(write, system)) return;
@@ -93631,7 +93848,7 @@ function assertProtectedRecordNotEdited(change, base) {
93631
93848
  )) {
93632
93849
  return;
93633
93850
  }
93634
- if (!isPlainRecord2(change.nextData)) return;
93851
+ if (!isPlainRecord3(change.nextData)) return;
93635
93852
  if (authoredFieldsEqual(change.recordKind, base.data, change.nextData)) {
93636
93853
  return;
93637
93854
  }
@@ -93640,7 +93857,7 @@ function assertProtectedRecordNotEdited(change, base) {
93640
93857
  );
93641
93858
  }
93642
93859
  function assertSystemMetadataUnchanged(change, base) {
93643
- if (!isPlainRecord2(change.nextData)) return;
93860
+ if (!isPlainRecord3(change.nextData)) return;
93644
93861
  const next = readSystemMetadata(change.nextData);
93645
93862
  if (systemMetadataEqual(base.system, next)) return;
93646
93863
  throw new Error(
@@ -93688,10 +93905,10 @@ function repointedChildValueIds(document, change) {
93688
93905
  );
93689
93906
  if (baseValue === void 0) return [];
93690
93907
  const before = baseValue.value;
93691
- if (!isPlainRecord2(before)) return [];
93692
- if (!isPlainRecord2(change.nextData)) return [];
93908
+ if (!isPlainRecord3(before)) return [];
93909
+ if (!isPlainRecord3(change.nextData)) return [];
93693
93910
  const after = change.nextData.value;
93694
- if (!isPlainRecord2(after)) return [];
93911
+ if (!isPlainRecord3(after)) return [];
93695
93912
  return Object.entries(before).flatMap(([schemaKey, childValueId]) => {
93696
93913
  if (typeof childValueId !== "string") return [];
93697
93914
  if (after[schemaKey] === childValueId) return [];
@@ -93726,7 +93943,7 @@ function isSystemBearingRecordKind(recordKind) {
93726
93943
  );
93727
93944
  }
93728
93945
  function readSystemMetadata(record3) {
93729
- if (!isPlainRecord2(record3)) return null;
93946
+ if (!isPlainRecord3(record3)) return null;
93730
93947
  const system = record3.system;
93731
93948
  if (!isSystemMetadata(system)) return null;
93732
93949
  return system;
@@ -93745,11 +93962,11 @@ function systemReason(system) {
93745
93962
  return SYSTEM_PROTECTION_RULES[system.kind].serverReason;
93746
93963
  }
93747
93964
  function describeChangedRecord(recordKind, recordId, record3) {
93748
- const name = isPlainRecord2(record3) ? record3.name : void 0;
93965
+ const name = isPlainRecord3(record3) ? record3.name : void 0;
93749
93966
  if (typeof name !== "string") return `Record ${recordKind} "${recordId}"`;
93750
93967
  return `Record ${recordKind} "${name}" (${recordId})`;
93751
93968
  }
93752
- function isPlainRecord2(value) {
93969
+ function isPlainRecord3(value) {
93753
93970
  return typeof value === "object" && value !== null && !Array.isArray(value);
93754
93971
  }
93755
93972
  function baseKey(recordKind, recordId) {
@@ -93863,7 +94080,7 @@ function readWorldReferenceList(args) {
93863
94080
  args.keyCandidates
93864
94081
  );
93865
94082
  if (schemaKey === null) return [];
93866
- if (!isPlainRecord3(args.ownerValue.value)) return [];
94083
+ if (!isPlainRecord4(args.ownerValue.value)) return [];
93867
94084
  const listValueId = args.ownerValue.value[schemaKey];
93868
94085
  if (typeof listValueId !== "string") return [];
93869
94086
  const listValue2 = args.graph.valuesById.get(listValueId);
@@ -93929,18 +94146,18 @@ function worldReferenceClassInherits(graph, classId, ancestorClassId) {
93929
94146
  return false;
93930
94147
  }
93931
94148
  function toWorldReferenceClassRecord(value) {
93932
- if (!isPlainRecord3(value)) return null;
94149
+ if (!isPlainRecord4(value)) return null;
93933
94150
  const id2 = stringField2(value, "id");
93934
94151
  if (id2 === null) return null;
93935
94152
  return {
93936
94153
  id: id2,
93937
94154
  extendsClassId: nullableStringField(value, "extendsClassId"),
93938
94155
  schema: isStringRecord5(value.schema) ? value.schema : void 0,
93939
- system: isPlainRecord3(value.system) ? value.system : null
94156
+ system: isPlainRecord4(value.system) ? value.system : null
93940
94157
  };
93941
94158
  }
93942
94159
  function toWorldReferenceValueRecord(value) {
93943
- if (!isPlainRecord3(value)) return null;
94160
+ if (!isPlainRecord4(value)) return null;
93944
94161
  const id2 = stringField2(value, "id");
93945
94162
  if (id2 === null) return null;
93946
94163
  return {
@@ -93954,10 +94171,10 @@ function worldReferenceValueClassId(value) {
93954
94171
  return typeof value.classId === "string" && value.classId.length > 0 ? value.classId : null;
93955
94172
  }
93956
94173
  function isStringRecord5(value) {
93957
- if (!isPlainRecord3(value)) return false;
94174
+ if (!isPlainRecord4(value)) return false;
93958
94175
  return Object.values(value).every((entry) => typeof entry === "string");
93959
94176
  }
93960
- function isPlainRecord3(value) {
94177
+ function isPlainRecord4(value) {
93961
94178
  return typeof value === "object" && value !== null && !Array.isArray(value);
93962
94179
  }
93963
94180
  function stringField2(value, key) {
@@ -94256,31 +94473,6 @@ function assertStagedInternalRecordRelationsValid(current, projected, changes) {
94256
94473
  classes: projected.classes
94257
94474
  });
94258
94475
  }
94259
- function stagedChangesAffectClassRelations(current, changes) {
94260
- const classesById = new Map(
94261
- current.classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
94262
- );
94263
- const valuesById = new Map(current.values.map((value) => [value.id, value]));
94264
- for (const change of changes) {
94265
- if (change.recordKind === "internal-record-relation") return true;
94266
- if (change.recordKind === "class") {
94267
- if (change.operation !== "update") return true;
94268
- if (change.deleted === true) return true;
94269
- const before2 = classesById.get(change.recordId);
94270
- if (before2 === void 0) return true;
94271
- const after = change.nextData;
94272
- if (!isPlainRecord4(after)) return true;
94273
- if (before2.extendsClassId !== after.extendsClassId) return true;
94274
- continue;
94275
- }
94276
- if (change.recordKind !== "value") continue;
94277
- const before = valuesById.get(change.recordId);
94278
- if (relationEndpointClassId(before) !== relationEndpointClassId(change.nextData)) {
94279
- return true;
94280
- }
94281
- }
94282
- return false;
94283
- }
94284
94476
  function assertStagedWorldContentLayerBindingsValid(current, projected, changes) {
94285
94477
  if (!stagedChangesRequireWorldLayerBindingValidation(current, changes)) {
94286
94478
  return;
@@ -94327,7 +94519,7 @@ function stagedChangesRequireWorldLayerBindingValidation(current, changes) {
94327
94519
  const before = classesById.get(change.recordId);
94328
94520
  if (before === void 0) return true;
94329
94521
  const after = change.nextData;
94330
- if (!isPlainRecord4(after)) return true;
94522
+ if (!isPlainRecord(after)) return true;
94331
94523
  if (before.extendsClassId !== after.extendsClassId) return true;
94332
94524
  if (before.isAbstract !== after.isAbstract) return true;
94333
94525
  if (!worldClassSystemBlockIsEqual(before.system, after.system)) return true;
@@ -94378,7 +94570,7 @@ function stagedAffectedWorldLayerLinkClassIds(args) {
94378
94570
  change.nextData
94379
94571
  ];
94380
94572
  for (const candidate of candidates) {
94381
- if (!isPlainRecord4(candidate)) continue;
94573
+ if (!isPlainRecord(candidate)) continue;
94382
94574
  const relationKind = candidate.relationKind;
94383
94575
  if (typeof relationKind !== "string") continue;
94384
94576
  if (!isStagedWorldLayerLinkTargetRelationKind(relationKind)) continue;
@@ -94421,21 +94613,11 @@ function worldClassSystemBlockIsEqual(before, after) {
94421
94613
  );
94422
94614
  }
94423
94615
  function hasWorldLayerOverrideMetadata(record3) {
94424
- if (!isPlainRecord4(record3)) return false;
94616
+ if (!isPlainRecord(record3)) return false;
94425
94617
  const value = record3.value;
94426
- if (!isPlainRecord4(value)) return false;
94618
+ if (!isPlainRecord(value)) return false;
94427
94619
  return typeof value.layerOverrideValueId === "string";
94428
94620
  }
94429
- function relationEndpointClassId(record3) {
94430
- if (!isPlainRecord4(record3)) return void 0;
94431
- if (typeof record3.classId === "string") return record3.classId;
94432
- if (typeof record3.typeId === "string") return record3.typeId;
94433
- return void 0;
94434
- }
94435
- function isPlainRecord4(value) {
94436
- if (value === null || typeof value !== "object") return false;
94437
- return !Array.isArray(value);
94438
- }
94439
94621
  function assertStagedProjectInterfaceValid(projected, changes) {
94440
94622
  const relevant = changes.filter(
94441
94623
  (change) => INTERFACE_VALIDATED_RECORD_KINDS.has(change.recordKind)
@@ -94569,7 +94751,7 @@ function candidateActionListenerRowIds(projected, actions) {
94569
94751
  }
94570
94752
  if (actionSchemaKeys.size === 0) return candidates;
94571
94753
  for (const row of projected.values) {
94572
- if (!isPlainRecord4(row.value)) continue;
94754
+ if (!isPlainRecord(row.value)) continue;
94573
94755
  for (const schemaKey of actionSchemaKeys) {
94574
94756
  const childId = row.value[schemaKey];
94575
94757
  if (typeof childId === "string") candidates.add(childId);
@@ -94579,7 +94761,7 @@ function candidateActionListenerRowIds(projected, actions) {
94579
94761
  }
94580
94762
  function storedRowActionListeners(row) {
94581
94763
  const body = row.value;
94582
- if (!isPlainRecord4(body)) return [];
94764
+ if (!isPlainRecord(body)) return [];
94583
94765
  const listeners = body.listeners;
94584
94766
  return Array.isArray(listeners) ? listeners : [];
94585
94767
  }
@@ -94657,7 +94839,7 @@ function authoredActionListeners(action) {
94657
94839
  if (defaultValue === void 0 || defaultValue === null) return [];
94658
94840
  if (!isLiteralValueContent(defaultValue)) return [];
94659
94841
  const body = defaultValue.value;
94660
- if (!isPlainRecord4(body)) return [];
94842
+ if (!isPlainRecord(body)) return [];
94661
94843
  const listeners = body.listeners;
94662
94844
  return Array.isArray(listeners) ? listeners : [];
94663
94845
  }
@@ -94997,7 +95179,7 @@ function candidateVariantRowIds(projected, variantMembers) {
94997
95179
  }
94998
95180
  if (schemaKeys.size === 0) return candidates;
94999
95181
  for (const row of projected.values) {
95000
- if (!isPlainRecord4(row.value)) continue;
95182
+ if (!isPlainRecord(row.value)) continue;
95001
95183
  for (const schemaKey of schemaKeys) {
95002
95184
  const childId = row.value[schemaKey];
95003
95185
  if (typeof childId === "string") candidates.add(childId);
@@ -95034,6 +95216,7 @@ var init_project_version_whole_graph_validation = __esm({
95034
95216
  init_world_system_classes();
95035
95217
  init_project_world_reference_graph();
95036
95218
  init_project_record_semantics();
95219
+ init_project_version_relation_sweep_trigger();
95037
95220
  INTERFACE_VALIDATED_RECORD_KINDS = /* @__PURE__ */ new Set([
95038
95221
  "member",
95039
95222
  "class",
@@ -97826,15 +98009,15 @@ function emitVariantValueSourcesV4(records2, manifest) {
97826
98009
  visited
97827
98010
  });
97828
98011
  };
97829
- const initialize = argument2("Initialize");
98012
+ const initialize = argument2(NEO_VARIANT_INITIALIZE_SCHEMA_KEY);
97830
98013
  if (initialize === null) {
97831
98014
  throw new Error(
97832
98015
  `Variant "${variant.id}" has no Initialize row; every variant constructs a fresh instance.`
97833
98016
  );
97834
98017
  }
97835
- const apply = argument2("Apply");
97836
- const overrides = argument2("Overrides");
97837
- const childOverrides = argument2("ChildOverrides");
98018
+ const apply = argument2(NEO_VARIANT_APPLY_SCHEMA_KEY);
98019
+ const overrides = argument2(NEO_VARIANT_OVERRIDES_SCHEMA_KEY);
98020
+ const childOverrides = argument2(NEO_VARIANT_CHILD_OVERRIDES_SCHEMA_KEY);
97838
98021
  const authored = [["initialize", initialize]];
97839
98022
  if (apply !== null && apply !== "null") authored.push(["apply", apply]);
97840
98023
  if (overrides !== null && overrides !== "new {}") {
@@ -102887,6 +103070,12 @@ function storedConstructorCallSource(context, schemaClass2, value, className, en
102887
103070
  `Stored construction for ${className} is missing evaluated argument ${key}.`
102888
103071
  );
102889
103072
  }
103073
+ const settledMember = settledMemberForConstructorArgument(
103074
+ context,
103075
+ schemaClass2,
103076
+ value,
103077
+ constructorArgs[key]
103078
+ );
102890
103079
  return `${argument2.name}: ${storedConstructorArgumentSource(
102891
103080
  context,
102892
103081
  argument2.type,
@@ -102894,24 +103083,23 @@ function storedConstructorCallSource(context, schemaClass2, value, className, en
102894
103083
  environment,
102895
103084
  visited,
102896
103085
  cloneAggregateArguments,
102897
- settledMemberIsPartial(context, schemaClass2, value, constructorArgs[key])
103086
+ settledMember?.partial === true,
103087
+ settledMember !== void 0
102898
103088
  )}`;
102899
103089
  });
102900
103090
  return argumentsValue.length === 0 && targetTyped ? "new()" : constructorCallSource(`new ${className}`, argumentsValue);
102901
103091
  }
102902
- function settledMemberIsPartial(context, schemaClass2, value, argument2) {
102903
- if (typeof argument2 !== "string") return false;
103092
+ function settledMemberForConstructorArgument(context, schemaClass2, value, argument2) {
103093
+ if (typeof argument2 !== "string") return void 0;
102904
103094
  const body = value.value;
102905
- if (!isObjectRecord2(body)) return false;
103095
+ if (!isObjectRecord2(body)) return void 0;
102906
103096
  const schemaKey = Object.entries(body).find(
102907
103097
  ([, rowId]) => rowId === argument2
102908
103098
  )?.[0];
102909
- if (schemaKey === void 0) return false;
103099
+ if (schemaKey === void 0) return void 0;
102910
103100
  const schema = isObjectRecord2(schemaClass2.schema) ? schemaClass2.schema : {};
102911
103101
  const memberId = schema[schemaKey];
102912
- if (typeof memberId !== "string") return false;
102913
- const member = context.members.get(memberId);
102914
- return member?.partial === true;
103102
+ return typeof memberId === "string" ? context.members.get(memberId) : void 0;
102915
103103
  }
102916
103104
  function constructorCallSource(callee, argumentsValue) {
102917
103105
  const inline = `${callee}(${argumentsValue.join(", ")})`;
@@ -102950,7 +103138,7 @@ function storedValueConstructor(context, schemaClass2, constructorArgs) {
102950
103138
  }
102951
103139
  return selected;
102952
103140
  }
102953
- function storedConstructorArgumentSource(context, type, value, environment, visited, cloneAggregateArguments = false, partial = false) {
103141
+ function storedConstructorArgumentSource(context, type, value, environment, visited, cloneAggregateArguments = false, partial = false, constructorOwnsGraph = false) {
102954
103142
  if (value === null) {
102955
103143
  if (!type.nullable) {
102956
103144
  throw new Error("Required constructor argument stores null.");
@@ -103033,7 +103221,8 @@ function storedConstructorArgumentSource(context, type, value, environment, visi
103033
103221
  environment,
103034
103222
  visited,
103035
103223
  false,
103036
- partial
103224
+ partial,
103225
+ constructorOwnsGraph
103037
103226
  );
103038
103227
  }
103039
103228
  case "generic": {
@@ -103057,7 +103246,8 @@ function storedConstructorArgumentSource(context, type, value, environment, visi
103057
103246
  environment,
103058
103247
  visited,
103059
103248
  cloneAggregateArguments,
103060
- partial
103249
+ partial,
103250
+ constructorOwnsGraph
103061
103251
  );
103062
103252
  }
103063
103253
  case "interface":
@@ -103077,7 +103267,9 @@ function storedConstructorArgumentSource(context, type, value, environment, visi
103077
103267
  value,
103078
103268
  environment,
103079
103269
  visited,
103080
- false
103270
+ false,
103271
+ false,
103272
+ constructorOwnsGraph
103081
103273
  );
103082
103274
  case "lookup":
103083
103275
  return referenceValue(
@@ -103351,7 +103543,7 @@ function storedSchemaTypeName(context, type, environment, valueId) {
103351
103543
  return "null";
103352
103544
  }
103353
103545
  }
103354
- function storedTypedRowSource(context, type, valueId, environment, visited, writeIdentity, partial = false) {
103546
+ function storedTypedRowSource(context, type, valueId, environment, visited, writeIdentity, partial = false, constructorOwnsGraph = false) {
103355
103547
  const symbol = context.symbolsByValueId.get(valueId);
103356
103548
  if (symbol !== void 0) return symbol;
103357
103549
  const row = context.values.get(valueId);
@@ -103360,6 +103552,9 @@ function storedTypedRowSource(context, type, valueId, environment, visited, writ
103360
103552
  `Stored ${type.kind} constructor argument references missing value row ${valueId}.`
103361
103553
  );
103362
103554
  }
103555
+ if (!constructorOwnsGraph && context.readMaterializedGraph().independentlyOwnedValueIds.has(valueId)) {
103556
+ return `Reference<${storedSchemaTypeName(context, type, environment, valueId)}>(id: ${quote5(valueId)})`;
103557
+ }
103363
103558
  if (visited.has(valueId)) {
103364
103559
  throw new Error(
103365
103560
  `Stored constructor argument containment cycle reaches ${valueId}.`
@@ -103410,7 +103605,9 @@ ${ids.map(
103410
103605
  id2,
103411
103606
  environment,
103412
103607
  visited,
103413
- true
103608
+ true,
103609
+ false,
103610
+ constructorOwnsGraph
103414
103611
  ),
103415
103612
  2
103416
103613
  )
@@ -103438,7 +103635,9 @@ ${entries.flatMap(
103438
103635
  id2,
103439
103636
  environment,
103440
103637
  visited,
103441
- false
103638
+ false,
103639
+ false,
103640
+ constructorOwnsGraph
103442
103641
  )}`,
103443
103642
  2
103444
103643
  )
@@ -104201,6 +104400,7 @@ var init_value_sources = __esm({
104201
104400
  "use strict";
104202
104401
  init_src();
104203
104402
  init_projection();
104403
+ init_variants2();
104204
104404
  init_project_file_source();
104205
104405
  init_lower_members();
104206
104406
  init_lower_variants();
@@ -111889,10 +112089,20 @@ async function downloadProjectVersionTransactionResult(args) {
111889
112089
  }
111890
112090
  changedRecords.push(...page.changedRecords);
111891
112091
  if (page.isDone) {
112092
+ if (args.status.totalChangeCount === null) {
112093
+ throw new Error(
112094
+ `Project transaction "${args.transactionId}" reported no total change count after committing; its result download cannot be checked for completeness.`
112095
+ );
112096
+ }
112097
+ if (changedRecords.length !== args.status.totalChangeCount) {
112098
+ throw new Error(
112099
+ `Project transaction "${args.transactionId}" committed ${args.status.totalChangeCount} changes but its result download returned ${changedRecords.length}.`
112100
+ );
112101
+ }
111892
112102
  return {
111893
112103
  kind: "committed",
111894
112104
  transactionId: args.transactionId,
111895
- totalChangeCount: args.status.totalChangeCount ?? changedRecords.length,
112105
+ totalChangeCount: args.status.totalChangeCount,
111896
112106
  totalChunkCount: args.status.totalChunkCount ?? 0,
111897
112107
  assignments,
111898
112108
  changedRecords
@@ -114185,7 +114395,7 @@ var init_registry2 = __esm({
114185
114395
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
114186
114396
  formatVersion: 3,
114187
114397
  contractVersion: "3.14",
114188
- cliVersion: "0.36.8",
114398
+ cliVersion: "0.36.10",
114189
114399
  projectFileUploadBatchSize: 32,
114190
114400
  documentRecords: {
114191
114401
  member: {
@@ -120501,7 +120711,7 @@ __export(resolve_exports, {
120501
120711
  import { readFileSync as readFileSync19, rmSync as rmSync8, writeFileSync as writeFileSync14 } from "node:fs";
120502
120712
  import { join as join21 } from "node:path";
120503
120713
  function runResolve(workspace, side) {
120504
- const resolvedRecords = acceptSourceEquivalentConflictBases(workspace);
120714
+ const resolvedRecords = adoptServerConflictBases(workspace);
120505
120715
  let resolvedFiles = 0;
120506
120716
  for (const filePath of listProjectSourceFilesV4(workspace.root)) {
120507
120717
  const source = readFileSync19(filePath, "utf8");
@@ -120546,6 +120756,22 @@ function runResolve(workspace, side) {
120546
120756
  `Resolved ${resolvedFiles} source file(s), ${resolvedRecords} record conflict(s), and ${resolvedBinaries} binary file(s) keeping the "${side}" side. Review with "neo diff", then "neo push".`
120547
120757
  );
120548
120758
  }
120759
+ function adoptServerConflictBases(workspace) {
120760
+ let adopted = 0;
120761
+ for (const [key, record3] of Object.entries(workspace.state.records)) {
120762
+ if (typeof record3.conflictServerHash !== "string") continue;
120763
+ const next = {
120764
+ ...record3,
120765
+ contentHash: record3.conflictServerHash,
120766
+ data: record3.conflictServerData
120767
+ };
120768
+ delete next.conflictServerHash;
120769
+ delete next.conflictServerData;
120770
+ workspace.state.records[key] = next;
120771
+ adopted += 1;
120772
+ }
120773
+ return adopted;
120774
+ }
120549
120775
  function resolveMarkers(source, side) {
120550
120776
  const lines = source.split("\n");
120551
120777
  const output = [];
@@ -120592,7 +120818,6 @@ var init_resolve = __esm({
120592
120818
  init_workspace_status();
120593
120819
  init_source_diagnostics();
120594
120820
  init_project_files();
120595
- init_source_record_comparison();
120596
120821
  }
120597
120822
  });
120598
120823
 
@@ -120789,7 +121014,7 @@ There is no --keep-current: preserving current semantic state defines flatten.
120789
121014
  async function main() {
120790
121015
  const args = parseArgs(process.argv.slice(2));
120791
121016
  if (args.command === "--version") {
120792
- console.log("0.36.8");
121017
+ console.log("0.36.10");
120793
121018
  return;
120794
121019
  }
120795
121020
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {