@neocompose/cli 0.36.10 → 0.36.12

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
@@ -572,6 +572,7 @@ var init_login = __esm({
572
572
  "project:version:create",
573
573
  "project:version:status:read",
574
574
  "project:version:changelog:read",
575
+ "project:version:changelog:write",
575
576
  "project:record:schema:read",
576
577
  "project:record:schema:write",
577
578
  "project:record:values:read",
@@ -32528,7 +32529,7 @@ function projectSchemaManifest(input, options = {}) {
32528
32529
  manifest.constructors ?? [],
32529
32530
  "ProjectSchemaManifest.constructors"
32530
32531
  );
32531
- const memberById = indexById(members, "ProjectSchemaManifest.members");
32532
+ const memberById2 = indexById(members, "ProjectSchemaManifest.members");
32532
32533
  const schemaClassById = indexById(classes, "ProjectSchemaManifest.classes");
32533
32534
  const interfaceById = indexById(
32534
32535
  interfaces,
@@ -32555,7 +32556,7 @@ function projectSchemaManifest(input, options = {}) {
32555
32556
  const rootMemberIds2 = options.rootMemberIds ?? inferRootMemberIds(members);
32556
32557
  const environment = {
32557
32558
  sourceUri: options.sourceUri ?? defaultSourceUri,
32558
- members: memberById,
32559
+ members: memberById2,
32559
32560
  classes: schemaClassById,
32560
32561
  interfaces: interfaceById,
32561
32562
  enums: indexById(enums, "ProjectSchemaManifest.enums"),
@@ -32765,10 +32766,10 @@ function inferRootMemberIds(members) {
32765
32766
  };
32766
32767
  }
32767
32768
  function effectiveMemberWritability(members, classes, roots) {
32768
- const memberById = /* @__PURE__ */ new Map();
32769
+ const memberById2 = /* @__PURE__ */ new Map();
32769
32770
  for (const member of members) {
32770
32771
  if (typeof member.id === "string") {
32771
- memberById.set(member.id, member);
32772
+ memberById2.set(member.id, member);
32772
32773
  }
32773
32774
  }
32774
32775
  const classById = /* @__PURE__ */ new Map();
@@ -32780,7 +32781,7 @@ function effectiveMemberWritability(members, classes, roots) {
32780
32781
  const declaredStorage = (memberId, seen = /* @__PURE__ */ new Set()) => {
32781
32782
  if (seen.has(memberId)) return null;
32782
32783
  seen.add(memberId);
32783
- const member = memberById.get(memberId);
32784
+ const member = memberById2.get(memberId);
32784
32785
  if (!member) return null;
32785
32786
  if (member.storage === "immutable" || member.storage === "save" || member.storage === "session") {
32786
32787
  return member.storage;
@@ -32849,7 +32850,7 @@ function effectiveMemberWritability(members, classes, roots) {
32849
32850
  if (typeof roots.session === "string") {
32850
32851
  rootStorage.set(roots.session, "session");
32851
32852
  }
32852
- for (const [memberId, member] of memberById) {
32853
+ for (const [memberId, member] of memberById2) {
32853
32854
  const root = rootStorage.get(memberId);
32854
32855
  const declared = declaredStorage(memberId);
32855
32856
  let storage = root ?? declared;
@@ -32866,7 +32867,7 @@ function effectiveMemberWritability(members, classes, roots) {
32866
32867
  let changed = true;
32867
32868
  while (changed) {
32868
32869
  changed = false;
32869
- for (const memberId of memberById.keys()) {
32870
+ for (const memberId of memberById2.keys()) {
32870
32871
  if (anchored.has(memberId)) continue;
32871
32872
  const next = new Set(effective.get(memberId) ?? []);
32872
32873
  for (const parentId of parents.get(memberId) ?? []) {
@@ -35199,6 +35200,19 @@ var init_names = __esm({
35199
35200
  function isObjectRecord2(value) {
35200
35201
  return typeof value === "object" && value !== null && !Array.isArray(value);
35201
35202
  }
35203
+ function effectiveRecordData(record3) {
35204
+ return record3.conflictServerHash !== void 0 && isObjectRecord2(record3.conflictServerData) ? record3.conflictServerData : record3.data;
35205
+ }
35206
+ function loweringBaseRecords(records2) {
35207
+ let normalized = null;
35208
+ for (const [key, record3] of Object.entries(records2)) {
35209
+ const effective = effectiveRecordData(record3);
35210
+ if (effective === record3.data) continue;
35211
+ if (normalized === null) normalized = { ...records2 };
35212
+ normalized[key] = { ...record3, data: effective };
35213
+ }
35214
+ return normalized ?? records2;
35215
+ }
35202
35216
  function splitRecordFields(data, serverOwnedFields) {
35203
35217
  const fileFields = {};
35204
35218
  const volatileValues = {};
@@ -54576,7 +54590,7 @@ function globalId(global, kind) {
54576
54590
  }
54577
54591
  function baseData(state, kind, id2) {
54578
54592
  const entry = state[`${kind}:${id2}`];
54579
- return entry?.conflictServerHash !== void 0 ? entry.conflictServerData : entry?.data;
54593
+ return entry === void 0 ? void 0 : effectiveRecordData(entry);
54580
54594
  }
54581
54595
  function optionalBase(value) {
54582
54596
  return isObjectRecord2(value) ? value : {};
@@ -64258,7 +64272,7 @@ function constructorActionParameterId(constructor2, index) {
64258
64272
  }
64259
64273
  return `__arg_${index}__`;
64260
64274
  }
64261
- function createTypedValueNormalizer(rows, document, childrenByContainerId, parameterTypesForRow, memberById, memberTypeInfo) {
64275
+ function createTypedValueNormalizer(rows, document, childrenByContainerId, parameterTypesForRow, memberById2, memberTypeInfo) {
64262
64276
  const visiting = /* @__PURE__ */ new Set();
64263
64277
  const normalizeLiteral = (value) => {
64264
64278
  if (Array.isArray(value)) return value.map(normalizeLiteral);
@@ -64341,7 +64355,7 @@ function createTypedValueNormalizer(rows, document, childrenByContainerId, param
64341
64355
  const childTypeBySchemaKey = /* @__PURE__ */ new Map();
64342
64356
  for (const entry of merged) {
64343
64357
  if (entry.memberId === null) continue;
64344
- const member = memberById(entry.memberId);
64358
+ const member = memberById2(entry.memberId);
64345
64359
  if (member === void 0) continue;
64346
64360
  const childType = memberTypeInfo(member, env);
64347
64361
  if (childType !== null) {
@@ -64534,6 +64548,11 @@ var init_constructor_argument_ownership = __esm({
64534
64548
  init_compile_ns_property();
64535
64549
  init_value_row_owner_members();
64536
64550
  MaterializedValueGraphContext = class {
64551
+ /**
64552
+ * P79 §7a. Generic in the caller's document view so a pass typed against a
64553
+ * narrowed view does not get the whole document handed back on the first
64554
+ * line it reads `graph.document`.
64555
+ */
64537
64556
  document;
64538
64557
  valuesById;
64539
64558
  childrenByContainerId;
@@ -72144,9 +72163,9 @@ function constructionInitEvaluator(ctx, createdValues, argumentScopes, construct
72144
72163
  let currentId = memberId;
72145
72164
  while (currentId !== void 0 && !visited.has(currentId)) {
72146
72165
  visited.add(currentId);
72147
- const declaringClassIds = indexes.declaringClassIdsByMemberId.get(currentId);
72166
+ const declaringClassIds2 = indexes.declaringClassIdsByMemberId.get(currentId);
72148
72167
  const owner = inheritanceChain.find(
72149
- (schemaClass2) => declaringClassIds?.has(schemaClass2.id)
72168
+ (schemaClass2) => declaringClassIds2?.has(schemaClass2.id)
72150
72169
  );
72151
72170
  if (owner !== void 0) return owner.id;
72152
72171
  currentId = indexes.containerMemberIdByEntryId.get(currentId) ?? indexes.memberById.get(currentId)?.extendsMemberId;
@@ -72261,7 +72280,7 @@ function buildConstructorInitializerIndexes(vm) {
72261
72280
  declaringClassIdsByMemberId.set(memberId, owners);
72262
72281
  }
72263
72282
  }
72264
- const memberById = new Map(vm.members.map((member) => [member.id, member]));
72283
+ const memberById2 = new Map(vm.members.map((member) => [member.id, member]));
72265
72284
  const containerMemberIdByEntryId = /* @__PURE__ */ new Map();
72266
72285
  for (const member of vm.members) {
72267
72286
  if (isMemberList(member) || isMemberDictionary(member)) {
@@ -72271,7 +72290,7 @@ function buildConstructorInitializerIndexes(vm) {
72271
72290
  return {
72272
72291
  initializerScopeMemberIds,
72273
72292
  declaringClassIdsByMemberId,
72274
- memberById,
72293
+ memberById: memberById2,
72275
72294
  containerMemberIdByEntryId
72276
72295
  };
72277
72296
  }
@@ -79912,7 +79931,7 @@ function baseData2(state, kind, id2) {
79912
79931
  return record3 ? effectiveData(record3) : {};
79913
79932
  }
79914
79933
  function effectiveData(record3) {
79915
- const data = record3.conflictServerHash !== void 0 ? record3.conflictServerData : record3.data;
79934
+ const data = effectiveRecordData(record3);
79916
79935
  return isObjectRecord2(data) ? data : {};
79917
79936
  }
79918
79937
  function requiredDestination(value, owner) {
@@ -81930,7 +81949,7 @@ function variantOwnershipRoots(args) {
81930
81949
  const folderById = new Map(
81931
81950
  (args.variantFolders ?? []).map((folder) => [folder.id, folder])
81932
81951
  );
81933
- const memberById = new Map(
81952
+ const memberById2 = new Map(
81934
81953
  (args.members ?? []).map((member) => [member.id, member])
81935
81954
  );
81936
81955
  const roots = [];
@@ -81971,7 +81990,7 @@ function variantOwnershipRoots(args) {
81971
81990
  })
81972
81991
  );
81973
81992
  const lookupParameterId = variantClass.genericParams?.[1]?.id;
81974
- const lookupCollection = lookupFolder?.binding == null ? void 0 : memberById.get(lookupFolder.binding.collectionMemberId);
81993
+ const lookupCollection = lookupFolder?.binding == null ? void 0 : memberById2.get(lookupFolder.binding.collectionMemberId);
81975
81994
  const lookupBinding = lookupParameterId !== void 0 && isMemberListBase(lookupCollection) ? {
81976
81995
  [lookupParameterId]: {
81977
81996
  kind: "member",
@@ -82126,8 +82145,17 @@ function transactionImpactsAnyOwnerMember(scope, impactedIds) {
82126
82145
  function collectNeoScriptRecompileTargets(args) {
82127
82146
  if (args.forceRecompile === true) return completeTargets(args.postDocument);
82128
82147
  const explicit = explicitTargetIds(args.changes);
82129
- const { impactedIds, impactedTypeNames, constructedClassIds } = collectChangedContractIds(args);
82148
+ const {
82149
+ impactedIds,
82150
+ changedValueIds,
82151
+ impactedTypeNames,
82152
+ constructedClassIds
82153
+ } = collectChangedContractIds(args);
82130
82154
  for (const id2 of args.additionalImpactedIds ?? []) impactedIds.add(id2);
82155
+ for (const id2 of args.additionalChangedValueIds ?? []) {
82156
+ changedValueIds.add(id2);
82157
+ explicit.valueIds.add(id2);
82158
+ }
82131
82159
  includeDerivedConstructionContracts(
82132
82160
  constructedClassIds,
82133
82161
  args.postDocument.classes
@@ -82144,7 +82172,7 @@ function collectNeoScriptRecompileTargets(args) {
82144
82172
  dependentsById.set(dependencyId, dependents);
82145
82173
  }
82146
82174
  }
82147
- const queue = [...impactedIds];
82175
+ const queue = [...impactedIds, ...changedValueIds];
82148
82176
  for (let index = 0; index < queue.length; index += 1) {
82149
82177
  const dependencyId = queue[index];
82150
82178
  if (dependencyId === void 0) continue;
@@ -82153,22 +82181,24 @@ function collectNeoScriptRecompileTargets(args) {
82153
82181
  }
82154
82182
  }
82155
82183
  const constructorOwnerById = constructorOwners(args.postDocument);
82156
- const impactedSourceNames = collectImpactedSourceNames({
82157
- currentDocument: args.currentDocument,
82158
- postDocument: args.postDocument,
82184
+ const gradesSourceOnlyBodies = impactedIds.size > 0 || impactedTypeNames.size > 0;
82185
+ const impactScope = {
82159
82186
  impactedIds,
82187
+ changedValueIds,
82160
82188
  impactedTypeNames,
82161
- constructedClassIds
82162
- });
82163
- const memberIds = new Set(explicit.memberIds);
82164
- for (const member of args.postDocument.members) {
82165
- if (recordDependsOnChangedContract(
82166
- member,
82189
+ constructedClassIds,
82190
+ impactedSourceNames: gradesSourceOnlyBodies ? collectImpactedSourceNames({
82191
+ currentDocument: args.currentDocument,
82192
+ postDocument: args.postDocument,
82167
82193
  impactedIds,
82194
+ changedValueIds,
82168
82195
  impactedTypeNames,
82169
- constructedClassIds,
82170
- impactedSourceNames
82171
- )) {
82196
+ constructedClassIds
82197
+ }) : /* @__PURE__ */ new Set()
82198
+ };
82199
+ const memberIds = new Set(explicit.memberIds);
82200
+ for (const member of args.postDocument.members) {
82201
+ if (recordDependsOnChangedContract(member, impactScope)) {
82172
82202
  memberIds.add(member.id);
82173
82203
  }
82174
82204
  }
@@ -82176,10 +82206,7 @@ function collectNeoScriptRecompileTargets(args) {
82176
82206
  const valueIds = selectedRecordIds(
82177
82207
  postValues,
82178
82208
  explicit.valueIds,
82179
- impactedIds,
82180
- impactedTypeNames,
82181
- constructedClassIds,
82182
- impactedSourceNames
82209
+ impactScope
82183
82210
  );
82184
82211
  if (impactedIds.size > 0 && postValues.length > 0) {
82185
82212
  const scope = withVariantOwnershipRoots(
@@ -82206,35 +82233,23 @@ function collectNeoScriptRecompileTargets(args) {
82206
82233
  constructorIds: selectedRecordIds(
82207
82234
  args.postDocument.constructors ?? [],
82208
82235
  explicit.constructorIds,
82209
- impactedIds,
82210
- impactedTypeNames,
82211
- constructedClassIds,
82212
- impactedSourceNames,
82236
+ impactScope,
82213
82237
  (record3) => constructorOwnerById.get(record3.id) ?? null
82214
82238
  ),
82215
82239
  migrationIds: selectedRecordIds(
82216
82240
  args.postDocument.migrations ?? [],
82217
82241
  explicit.migrationIds,
82218
- impactedIds,
82219
- impactedTypeNames,
82220
- constructedClassIds,
82221
- impactedSourceNames
82242
+ impactScope
82222
82243
  ),
82223
82244
  dialogueNodeIds: selectedRecordIds(
82224
82245
  args.postDocument.dialogueNodes ?? [],
82225
82246
  explicit.dialogueNodeIds,
82226
- impactedIds,
82227
- impactedTypeNames,
82228
- constructedClassIds,
82229
- impactedSourceNames
82247
+ impactScope
82230
82248
  ),
82231
82249
  dialogueGroupIds: selectedRecordIds(
82232
82250
  args.postDocument.dialogueGroups ?? [],
82233
82251
  explicit.dialogueGroupIds,
82234
- impactedIds,
82235
- impactedTypeNames,
82236
- constructedClassIds,
82237
- impactedSourceNames
82252
+ impactScope
82238
82253
  ),
82239
82254
  valueIds
82240
82255
  };
@@ -82310,6 +82325,7 @@ function isCompilerReferenceField(field) {
82310
82325
  }
82311
82326
  function collectChangedContractIds(args) {
82312
82327
  const impactedIds = /* @__PURE__ */ new Set();
82328
+ const changedValueIds = /* @__PURE__ */ new Set();
82313
82329
  const impactedTypeNames = /* @__PURE__ */ new Set();
82314
82330
  const constructedClassIds = /* @__PURE__ */ new Set();
82315
82331
  const currentMembers = new Map(
@@ -82370,7 +82386,7 @@ function collectChangedContractIds(args) {
82370
82386
  const current2 = currentValues.get(change.recordId);
82371
82387
  const next2 = postValues.get(change.recordId);
82372
82388
  if (current2 === void 0 || next2 === void 0 || Reflect.get(current2, "classId") !== Reflect.get(next2, "classId")) {
82373
- impactedIds.add(change.recordId);
82389
+ changedValueIds.add(change.recordId);
82374
82390
  }
82375
82391
  continue;
82376
82392
  }
@@ -82416,7 +82432,12 @@ function collectChangedContractIds(args) {
82416
82432
  }
82417
82433
  }
82418
82434
  }
82419
- return { impactedIds, impactedTypeNames, constructedClassIds };
82435
+ return {
82436
+ impactedIds,
82437
+ changedValueIds,
82438
+ impactedTypeNames,
82439
+ constructedClassIds
82440
+ };
82420
82441
  }
82421
82442
  function generatedConstructorMemberContractChanged(current, next) {
82422
82443
  if (current === void 0 || next === void 0) return true;
@@ -82603,50 +82624,51 @@ function explicitTargetIds(changes) {
82603
82624
  }
82604
82625
  return result;
82605
82626
  }
82606
- function selectedRecordIds(records2, explicitIds, impactedIds, impactedTypeNames, constructedClassIds, impactedSourceNames, ownerId = () => null) {
82627
+ function selectedRecordIds(records2, explicitIds, scope, ownerId = () => null) {
82607
82628
  const selected = new Set(explicitIds);
82608
82629
  for (const record3 of records2) {
82609
82630
  const owner = ownerId(record3);
82610
- if (owner !== null && impactedIds.has(owner) || recordDependsOnChangedContract(
82611
- record3,
82612
- impactedIds,
82613
- impactedTypeNames,
82614
- constructedClassIds,
82615
- impactedSourceNames
82616
- )) {
82631
+ if (owner !== null && scope.impactedIds.has(owner) || recordDependsOnChangedContract(record3, scope)) {
82617
82632
  selected.add(record3.id);
82618
82633
  }
82619
82634
  }
82620
82635
  return selected;
82621
82636
  }
82622
- function recordDependsOnChangedContract(record3, impactedIds, impactedTypeNames, constructedClassIds, impactedSourceNames) {
82637
+ function recordDependsOnChangedContract(record3, scope) {
82623
82638
  const recordId = isObjectRecord4(record3) ? record3.id : void 0;
82624
- if (typeof recordId === "string" && impactedIds.has(recordId)) return true;
82625
- if (intersects(collectCompilerReferenceIds(record3), impactedIds)) return true;
82626
- if (intersects(collectCompilerReferenceNames(record3), impactedTypeNames)) {
82639
+ if (typeof recordId === "string" && scope.impactedIds.has(recordId)) {
82627
82640
  return true;
82628
82641
  }
82629
- if (intersects(collectConstructedClassIds(record3), constructedClassIds)) {
82642
+ const referenceIds = collectCompilerReferenceIds(record3);
82643
+ if (intersects(referenceIds, scope.impactedIds)) return true;
82644
+ if (intersects(referenceIds, scope.changedValueIds)) return true;
82645
+ if (intersects(collectCompilerReferenceNames(record3), scope.impactedTypeNames)) {
82630
82646
  return true;
82631
82647
  }
82632
- if (impactedIds.size === 0 && impactedTypeNames.size === 0) return false;
82648
+ if (intersects(collectConstructedClassIds(record3), scope.constructedClassIds)) {
82649
+ return true;
82650
+ }
82651
+ if (scope.impactedIds.size === 0 && scope.impactedTypeNames.size === 0) {
82652
+ return false;
82653
+ }
82633
82654
  if (!containsAuthoredNeoScriptSource(record3)) return false;
82634
82655
  if (containsCompiledNeoScriptBody(record3)) return false;
82635
- if (impactedSourceNames === null) return true;
82656
+ if (scope.impactedSourceNames === null) return true;
82636
82657
  const sourceIdentifiers = collectAuthoredNeoScriptSourceIdentifiers(record3);
82637
82658
  if (sourceIdentifiers === null) return true;
82638
- return intersects(sourceIdentifiers, impactedSourceNames);
82659
+ return intersects(sourceIdentifiers, scope.impactedSourceNames);
82639
82660
  }
82640
82661
  function collectImpactedSourceNames(args) {
82641
82662
  const names = new Set(args.impactedTypeNames);
82642
82663
  let recoveredContract = args.impactedTypeNames.size > 0;
82664
+ const isImpactedRecordId = (id2) => args.impactedIds.has(id2) || args.changedValueIds.has(id2);
82643
82665
  const collectDocument = (document) => {
82644
82666
  const classById = new Map(
82645
82667
  document.classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
82646
82668
  );
82647
82669
  const ownerByConstructorId = constructorOwners(document);
82648
82670
  const impactedValueIds = new Set(
82649
- (document.values ?? []).filter((value) => args.impactedIds.has(value.id)).map((value) => value.id)
82671
+ (document.values ?? []).filter((value) => isImpactedRecordId(value.id)).map((value) => value.id)
82650
82672
  );
82651
82673
  const scope = withVariantOwnershipRoots(document, document.variants ?? []);
82652
82674
  const ownerByValueId = resolveOwnerMembersForValues(
@@ -82675,7 +82697,7 @@ function collectImpactedSourceNames(args) {
82675
82697
  ...document.values ?? []
82676
82698
  ];
82677
82699
  for (const record3 of records2) {
82678
- if (!args.impactedIds.has(record3.id)) continue;
82700
+ if (!isImpactedRecordId(record3.id)) continue;
82679
82701
  recoveredContract = true;
82680
82702
  collectDeclaredSourceNames(record3, names);
82681
82703
  const ownerClassId = ownerByConstructorId.get(record3.id);
@@ -87398,7 +87420,7 @@ function validateCreatedMigrationGraph(args) {
87398
87420
  }
87399
87421
  createdById.set(row.id, row);
87400
87422
  }
87401
- const memberById = new Map(args.members.map((member) => [member.id, member]));
87423
+ const memberById2 = new Map(args.members.map((member) => [member.id, member]));
87402
87424
  const classById = new Map(
87403
87425
  args.classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
87404
87426
  );
@@ -87497,7 +87519,7 @@ function validateCreatedMigrationGraph(args) {
87497
87519
  );
87498
87520
  }
87499
87521
  const childMemberId = schema.get(schemaKey);
87500
- const childMember = childMemberId === void 0 ? void 0 : memberById.get(childMemberId);
87522
+ const childMember = childMemberId === void 0 ? void 0 : memberById2.get(childMemberId);
87501
87523
  if (childMember === void 0) {
87502
87524
  throw graphError(
87503
87525
  args,
@@ -87513,7 +87535,7 @@ function validateCreatedMigrationGraph(args) {
87513
87535
  return;
87514
87536
  }
87515
87537
  if (member !== void 0 && isMemberListBase(member)) {
87516
- const entryMember = memberById.get(member.entryMemberId);
87538
+ const entryMember = memberById2.get(member.entryMemberId);
87517
87539
  if (entryMember === void 0) {
87518
87540
  throw graphError(
87519
87541
  args,
@@ -87541,7 +87563,7 @@ function validateCreatedMigrationGraph(args) {
87541
87563
  return;
87542
87564
  }
87543
87565
  if (member !== void 0 && isMemberDictionaryBase(member)) {
87544
- const entryMember = memberById.get(member.entryMemberId);
87566
+ const entryMember = memberById2.get(member.entryMemberId);
87545
87567
  if (entryMember === void 0) {
87546
87568
  throw graphError(
87547
87569
  args,
@@ -88765,13 +88787,13 @@ function lookupTargetClassContractViolation(args) {
88765
88787
  }
88766
88788
  return null;
88767
88789
  }
88768
- function lookupEntryClassId(member, memberById) {
88769
- const collection = memberById.get(member.collectionMemberId);
88790
+ function lookupEntryClassId(member, memberById2) {
88791
+ const collection = memberById2.get(member.collectionMemberId);
88770
88792
  if (collection === void 0) return null;
88771
88793
  if (!isMemberListBase(collection) && !isMemberDictionaryBase(collection)) {
88772
88794
  return null;
88773
88795
  }
88774
- const entry = memberById.get(collection.entryMemberId);
88796
+ const entry = memberById2.get(collection.entryMemberId);
88775
88797
  if (entry === void 0) return null;
88776
88798
  return isMemberClassBase(entry) ? entry.classId : null;
88777
88799
  }
@@ -88795,8 +88817,8 @@ function classAssignableToClass(actualClassId, expectedClassId, classById) {
88795
88817
  function classDisplayName(classId, classById) {
88796
88818
  return classById.get(classId)?.name ?? classId;
88797
88819
  }
88798
- function collectionMemberName(member, memberById, classes) {
88799
- const collection = memberById.get(member.collectionMemberId);
88820
+ function collectionMemberName(member, memberById2, classes) {
88821
+ const collection = memberById2.get(member.collectionMemberId);
88800
88822
  if (collection === void 0) return member.collectionMemberId;
88801
88823
  const owner = classes.find(
88802
88824
  (schemaClass2) => Object.values(schemaClass2.schema).includes(member.collectionMemberId)
@@ -89984,7 +90006,7 @@ function prepareServerOwnedSchemaCommit(args) {
89984
90006
  const hasValueChange = authoredChanges.some(
89985
90007
  (change) => change.recordKind === "value"
89986
90008
  );
89987
- const hasAdditionalContractImpact = (args.additionalImpactedIds?.size ?? 0) > 0;
90009
+ const hasAdditionalContractImpact = (args.additionalImpactedIds?.size ?? 0) > 0 || (args.additionalChangedValueIds?.size ?? 0) > 0;
89988
90010
  if (!hasSchemaChange && !hasMigrationChange && !hasDialogueSourceChange && !hasValueChange && !hasAdditionalContractImpact) {
89989
90011
  return authoredChanges;
89990
90012
  }
@@ -89997,6 +90019,7 @@ function prepareServerOwnedSchemaCommit(args) {
89997
90019
  postDocument: authoredPostDocument,
89998
90020
  changes: authoredChanges,
89999
90021
  additionalImpactedIds: args.additionalImpactedIds,
90022
+ additionalChangedValueIds: args.additionalChangedValueIds,
90000
90023
  forceRecompile: args.forceRecompile
90001
90024
  });
90002
90025
  const currentById = new Map(
@@ -90306,7 +90329,8 @@ function materializePreparedInstanceInitializers(args) {
90306
90329
  const existingValueById = new Map(
90307
90330
  args.document.values.map((value) => [value.id, value])
90308
90331
  );
90309
- const currentGraph = new MaterializedValueGraphContext(args.document);
90332
+ let currentGraph = null;
90333
+ const requireCurrentGraph = () => currentGraph ??= new MaterializedValueGraphContext(args.document);
90310
90334
  const rootKinds = /* @__PURE__ */ new Map();
90311
90335
  const materializationScope = withVariantOwnershipRoots(
90312
90336
  compiledDocument,
@@ -90346,7 +90370,7 @@ function materializePreparedInstanceInitializers(args) {
90346
90370
  if (existingConstructedRoot) {
90347
90371
  if (!isLiteralValueContent(materialized.root) || existingRoot.classId !== materialized.root.classId || !replayedCreationDataMatches({
90348
90372
  currentDocument: args.document,
90349
- currentGraph,
90373
+ currentGraph: requireCurrentGraph(),
90350
90374
  currentRoot: existingRoot,
90351
90375
  replayRoot: materialized.root,
90352
90376
  replayCreated: materialized.createdValues
@@ -91336,9 +91360,46 @@ function drainConstructedGraphValidations(args) {
91336
91360
  });
91337
91361
  }
91338
91362
  }
91363
+ function indexAuthoredSeedDocument(document) {
91364
+ const declaringClassIdsByMemberId = /* @__PURE__ */ new Map();
91365
+ for (const schemaClass2 of document.classes) {
91366
+ const declared = /* @__PURE__ */ new Set();
91367
+ for (const memberId of Object.values(schemaClass2.schema)) {
91368
+ if (typeof memberId !== "string") continue;
91369
+ if (declared.has(memberId)) continue;
91370
+ declared.add(memberId);
91371
+ const owners = declaringClassIdsByMemberId.get(memberId);
91372
+ if (owners === void 0) {
91373
+ declaringClassIdsByMemberId.set(memberId, [schemaClass2.id]);
91374
+ continue;
91375
+ }
91376
+ owners.push(schemaClass2.id);
91377
+ }
91378
+ }
91379
+ return {
91380
+ valuesById: indexRecordsById(document.values),
91381
+ membersById: indexRecordsById(document.members),
91382
+ localizedTextIds: new Set(
91383
+ (document.localizedTexts ?? []).map((text) => text.id)
91384
+ ),
91385
+ declaringClassIdsByMemberId
91386
+ };
91387
+ }
91388
+ function declaringClassIds(index, memberId) {
91389
+ return index.declaringClassIdsByMemberId.get(memberId) ?? [];
91390
+ }
91391
+ function hasLiveMemberChange(prepared) {
91392
+ return prepared.some(
91393
+ (change) => change.recordKind === "member" && change.operation !== "delete" && change.nextData !== void 0
91394
+ );
91395
+ }
91339
91396
  function materializeAuthoredValueSeeds(args) {
91397
+ if (args.authoredValueSeeds.length === 0 && !hasLiveMemberChange(args.prepared)) {
91398
+ return;
91399
+ }
91340
91400
  const pendingGraphValidations = [];
91341
91401
  materializeStaticSeedBindingMembers(args);
91402
+ const documentIndex = indexAuthoredSeedDocument(args.document);
91342
91403
  const seedByMemberId = new Map(
91343
91404
  args.authoredValueSeeds.map((seed) => [seed.memberId, seed])
91344
91405
  );
@@ -91358,6 +91419,7 @@ function materializeAuthoredValueSeeds(args) {
91358
91419
  consumedSeedMemberIds.add(member.id);
91359
91420
  materializeInstanceDefaultSeed({
91360
91421
  document: args.document,
91422
+ documentIndex,
91361
91423
  prepared: args.prepared,
91362
91424
  pendingGraphValidations,
91363
91425
  memberChange: { index, change },
@@ -91380,9 +91442,7 @@ function materializeAuthoredValueSeeds(args) {
91380
91442
  `Static Generic member "${member.name}" (${member.id}) cannot materialize a value.`
91381
91443
  );
91382
91444
  }
91383
- const owners = args.document.classes.filter(
91384
- (schemaClass2) => Object.values(schemaClass2.schema).includes(member.id)
91385
- );
91445
+ const owners = declaringClassIds(documentIndex, member.id);
91386
91446
  if (owners.length !== 1) {
91387
91447
  throw new Error(
91388
91448
  `Stored static member "${member.name}" (${member.id}) must have exactly one direct declaring class; found ${owners.length}.`
@@ -91390,7 +91450,7 @@ function materializeAuthoredValueSeeds(args) {
91390
91450
  }
91391
91451
  if (change.operation === "update" && seed === void 0) continue;
91392
91452
  if (change.operation === "create" && seed === void 0 && typeof member.valueId === "string") {
91393
- if (!args.document.values.some((value) => value.id === member.valueId)) {
91453
+ if (!documentIndex.valuesById.has(member.valueId)) {
91394
91454
  throw new Error(
91395
91455
  `Stored static member "${member.name}" (${member.id}) binds missing value "${member.valueId}".`
91396
91456
  );
@@ -91414,6 +91474,7 @@ function materializeAuthoredValueSeeds(args) {
91414
91474
  member: materializationMember
91415
91475
  }) : materializeAuthoredStaticSeed({
91416
91476
  document: args.document,
91477
+ documentIndex,
91417
91478
  member: materializationMember,
91418
91479
  // P61 must leave a computed static root as an init-backed prepared
91419
91480
  // row until `materializePreparedInstanceInitializers` runs. The
@@ -91423,7 +91484,7 @@ function materializeAuthoredValueSeeds(args) {
91423
91484
  seed: { ...seed, values: seed.values ?? [] }
91424
91485
  });
91425
91486
  const { createdValues, localizedTexts, storageKeyDeclarations, rootValue } = materialized;
91426
- const ownedValueId = args.document.members.find((candidate) => candidate.id === member.id)?.valueId ?? derivedMemberValueId(member.id);
91487
+ const ownedValueId = documentIndex.membersById.get(member.id)?.valueId ?? derivedMemberValueId(member.id);
91427
91488
  if (seed?.valueId !== void 0 && seed.valueId !== ownedValueId) {
91428
91489
  throw new Error(
91429
91490
  `Static value seed for member "${member.name}" (${member.id}) binds value "${seed.valueId}", but the member owns value "${ownedValueId}".`
@@ -91436,7 +91497,7 @@ function materializeAuthoredValueSeeds(args) {
91436
91497
  }
91437
91498
  if (seed?.values === void 0 && rootValue.id !== ownedValueId) {
91438
91499
  assertMintedRootValueIdIsFree({
91439
- document: args.document,
91500
+ documentIndex,
91440
91501
  prepared: args.prepared,
91441
91502
  member,
91442
91503
  valueId: ownedValueId
@@ -91458,7 +91519,7 @@ function materializeAuthoredValueSeeds(args) {
91458
91519
  rootValue.id,
91459
91520
  {
91460
91521
  mapKey: null,
91461
- classId: owners[0].id
91522
+ classId: owners[0]
91462
91523
  }
91463
91524
  ]
91464
91525
  ])
@@ -91506,12 +91567,11 @@ function materializeAuthoredValueSeeds(args) {
91506
91567
  }
91507
91568
  for (const seed of args.authoredValueSeeds) {
91508
91569
  if (consumedSeedMemberIds.has(seed.memberId)) continue;
91509
- const member = args.document.members.find(
91510
- (candidate) => candidate.id === seed.memberId
91511
- );
91570
+ const member = documentIndex.membersById.get(seed.memberId);
91512
91571
  if (member !== void 0 && member.isStatic !== true && !isProjectRootMember(args.document.project, member.id)) {
91513
91572
  materializeInstanceDefaultSeed({
91514
91573
  document: args.document,
91574
+ documentIndex,
91515
91575
  prepared: args.prepared,
91516
91576
  pendingGraphValidations,
91517
91577
  memberChange: null,
@@ -91523,6 +91583,7 @@ function materializeAuthoredValueSeeds(args) {
91523
91583
  }
91524
91584
  materializeExistingAuthoredValueSeed({
91525
91585
  document: args.document,
91586
+ documentIndex,
91526
91587
  prepared: args.prepared,
91527
91588
  pendingGraphValidations,
91528
91589
  seed,
@@ -91537,9 +91598,7 @@ function materializeAuthoredValueSeeds(args) {
91537
91598
  });
91538
91599
  }
91539
91600
  function materializeExistingAuthoredValueSeed(args) {
91540
- const member = args.document.members.find(
91541
- (candidate) => candidate.id === args.seed.memberId
91542
- );
91601
+ const member = args.documentIndex.membersById.get(args.seed.memberId);
91543
91602
  if (member === void 0) {
91544
91603
  throw new Error(
91545
91604
  `Member value seed "${args.seed.memberId}" does not target a stored member in this schema commit.`
@@ -91561,9 +91620,7 @@ function materializeExistingAuthoredValueSeed(args) {
91561
91620
  `Existing value graph seed for member "${member.name}" (${member.id}) targets value "${args.seed.valueId}", but the member binds "${String(member.valueId)}".`
91562
91621
  );
91563
91622
  }
91564
- const owners = args.document.classes.filter(
91565
- (schemaClass2) => Object.values(schemaClass2.schema).includes(member.id)
91566
- );
91623
+ const owners = declaringClassIds(args.documentIndex, member.id);
91567
91624
  if (!isRootMember && owners.length !== 1) {
91568
91625
  throw new Error(
91569
91626
  `Stored static member "${member.name}" (${member.id}) must have exactly one direct declaring class; found ${owners.length}.`
@@ -91571,6 +91628,7 @@ function materializeExistingAuthoredValueSeed(args) {
91571
91628
  }
91572
91629
  const materialized = materializeAuthoredStaticSeed({
91573
91630
  document: args.document,
91631
+ documentIndex: args.documentIndex,
91574
91632
  member,
91575
91633
  seed: { ...args.seed, values: args.seed.values },
91576
91634
  allowExistingRows: true
@@ -91591,7 +91649,7 @@ function materializeExistingAuthoredValueSeed(args) {
91591
91649
  mapKey: null,
91592
91650
  // A root member's row has no enclosing class, so declared storage
91593
91651
  // keys below it resolve against no parent class.
91594
- classId: owners[0]?.id
91652
+ classId: owners[0]
91595
91653
  }
91596
91654
  ]
91597
91655
  ])
@@ -91610,9 +91668,7 @@ function materializeExistingAuthoredValueSeed(args) {
91610
91668
  });
91611
91669
  for (const value of materialized.createdValues) {
91612
91670
  if (materialized.existingValueIds.has(value.id)) {
91613
- if (isInitValueContent(value) && !isInitValueContent(
91614
- args.document.values.find((candidate) => candidate.id === value.id)
91615
- )) {
91671
+ if (isInitValueContent(value) && !isInitValueContent(args.documentIndex.valuesById.get(value.id))) {
91616
91672
  args.prepared.push({
91617
91673
  recordKind: "value",
91618
91674
  recordId: value.id,
@@ -91816,9 +91872,7 @@ function materializeInstanceDefaultSeed(args) {
91816
91872
  `Constructed default seed for member "${args.member.name}" (${args.member.id}) requires a root value id and explicit value rows.`
91817
91873
  );
91818
91874
  }
91819
- const owners = args.document.classes.filter(
91820
- (schemaClass2) => Object.values(schemaClass2.schema).includes(args.member.id)
91821
- );
91875
+ const owners = declaringClassIds(args.documentIndex, args.member.id);
91822
91876
  if (owners.length !== 1) {
91823
91877
  throw new Error(
91824
91878
  `Constructed default member "${args.member.name}" (${args.member.id}) must have exactly one direct declaring class; found ${owners.length}.`
@@ -91836,6 +91890,7 @@ function materializeInstanceDefaultSeed(args) {
91836
91890
  existingValueIds
91837
91891
  } = materializeAuthoredStaticSeed({
91838
91892
  document: args.document,
91893
+ documentIndex: args.documentIndex,
91839
91894
  member: materializationMember,
91840
91895
  seed: { ...args.seed, values: args.seed.values },
91841
91896
  allowExistingRows: args.memberChange === null || args.memberChange.change.operation === "update"
@@ -91849,7 +91904,7 @@ function materializeInstanceDefaultSeed(args) {
91849
91904
  rootValue.id,
91850
91905
  {
91851
91906
  mapKey: null,
91852
- classId: owners[0].id
91907
+ classId: owners[0]
91853
91908
  }
91854
91909
  ]
91855
91910
  ])
@@ -91940,7 +91995,7 @@ function materializeDefaultStaticSeed(args) {
91940
91995
  };
91941
91996
  }
91942
91997
  function assertMintedRootValueIdIsFree(args) {
91943
- if (args.document.values.some((value) => value.id === args.valueId)) {
91998
+ if (args.documentIndex.valuesById.has(args.valueId)) {
91944
91999
  throw new Error(
91945
92000
  `Member "${args.member.name}" (${args.member.id}) owns value "${args.valueId}", which already exists in this version.`
91946
92001
  );
@@ -91977,7 +92032,7 @@ function materializeAuthoredStaticSeed(args) {
91977
92032
  const requestedIds = /* @__PURE__ */ new Set([requestedRootId, ...authoredRows.keys()]);
91978
92033
  const existingValueIds = /* @__PURE__ */ new Set();
91979
92034
  for (const id2 of requestedIds) {
91980
- const existing = args.document.values.find((value) => value.id === id2);
92035
+ const existing = args.documentIndex.valuesById.get(id2);
91981
92036
  if (existing === void 0) continue;
91982
92037
  if (args.allowExistingRows !== true) {
91983
92038
  throw new Error(`Value "${id2}" already exists.`);
@@ -91995,6 +92050,7 @@ function materializeAuthoredStaticSeed(args) {
91995
92050
  const usedRows = /* @__PURE__ */ new Set();
91996
92051
  const rootValue = materializeAuthoredSeedRow({
91997
92052
  document: args.document,
92053
+ documentIndex: args.documentIndex,
91998
92054
  member: args.member,
91999
92055
  row: seedRootRow(args.member, args.seed, requestedRootId),
92000
92056
  authoredRows,
@@ -92022,6 +92078,7 @@ function materializeAuthoredStaticSeed(args) {
92022
92078
  }
92023
92079
  const seededLocalizedTexts = materializeStaticLocalizedTexts({
92024
92080
  document: args.document,
92081
+ documentIndex: args.documentIndex,
92025
92082
  seeds: args.seed.localizedTexts ?? [],
92026
92083
  createdValues
92027
92084
  });
@@ -92157,9 +92214,7 @@ function materializeStaticLocalizedTexts(args) {
92157
92214
  throw new Error(`Localized text seed repeats id "${seed.id}".`);
92158
92215
  }
92159
92216
  seen.add(seed.id);
92160
- if ((args.document.localizedTexts ?? []).some(
92161
- (text) => text.id === seed.id
92162
- ) || args.document.values.some((value) => value.id === seed.id)) {
92217
+ if (args.documentIndex.localizedTextIds.has(seed.id) || args.documentIndex.valuesById.has(seed.id)) {
92163
92218
  throw new Error(`Localized text "${seed.id}" already exists.`);
92164
92219
  }
92165
92220
  const owner = args.createdValues.find((value) => value.id === seed.valueId);
@@ -92235,7 +92290,7 @@ function materializeAuthoredSeedRow(args) {
92235
92290
  ...isMemberClassBase(resolvedStoredMember) && args.row.classId !== null ? { topLevelClassId: args.row.classId } : {}
92236
92291
  });
92237
92292
  renameCreatedValueId({
92238
- document: args.document,
92293
+ documentIndex: args.documentIndex,
92239
92294
  createdValues: args.createdValues,
92240
92295
  storageKeyDeclarations: args.storageKeyDeclarations,
92241
92296
  generatedId: generatedRoot.id,
@@ -92323,7 +92378,7 @@ function materializeAuthoredClassFields(args) {
92323
92378
  `Class "${effectiveClassId}" has no stored member "${schemaKey}".`
92324
92379
  );
92325
92380
  }
92326
- const childMember = requireDocumentMember(args.document, childMemberId);
92381
+ const childMember = requireSeedMember(args.documentIndex, childMemberId);
92327
92382
  const currentBody = isStringValueRecord(args.rootValue.value) ? args.rootValue.value : {};
92328
92383
  const previousId = currentBody[schemaKey];
92329
92384
  if (previousId !== void 0 && previousId !== childId) {
@@ -92352,8 +92407,8 @@ function materializeAuthoredListItems(args) {
92352
92407
  if (!Array.isArray(args.row.value)) {
92353
92408
  throw new Error(`List value "${args.row.id}" requires an array body.`);
92354
92409
  }
92355
- const entryMember = requireDocumentMember(
92356
- args.document,
92410
+ const entryMember = requireSeedMember(
92411
+ args.documentIndex,
92357
92412
  args.member.entryMemberId
92358
92413
  );
92359
92414
  const unordered = listKindOf(args.member) === "unordered";
@@ -92384,8 +92439,8 @@ function materializeAuthoredDictionaryEntries(args) {
92384
92439
  `Dictionary value "${args.row.id}" requires an object body.`
92385
92440
  );
92386
92441
  }
92387
- const entryMember = requireDocumentMember(
92388
- args.document,
92442
+ const entryMember = requireSeedMember(
92443
+ args.documentIndex,
92389
92444
  args.member.entryMemberId
92390
92445
  );
92391
92446
  const body = {};
@@ -92403,9 +92458,7 @@ function materializeAuthoredChild(args) {
92403
92458
  if (authored !== void 0) {
92404
92459
  return materializeAuthoredSeedRow({ ...args, row: authored });
92405
92460
  }
92406
- const existing = args.document.values.find(
92407
- (value) => value.id === args.childId
92408
- );
92461
+ const existing = args.documentIndex.valuesById.get(args.childId);
92409
92462
  if (existing === void 0) {
92410
92463
  throw new Error(
92411
92464
  `Authored value graph references missing row "${args.childId}".`
@@ -92415,7 +92468,7 @@ function materializeAuthoredChild(args) {
92415
92468
  }
92416
92469
  function renameCreatedValueId(args) {
92417
92470
  if (args.generatedId === args.requestedId) return;
92418
- if (args.document.values.some((value2) => value2.id === args.requestedId) && !args.replaceExistingIds.has(args.requestedId) || args.createdValues.some(
92471
+ if (args.documentIndex.valuesById.has(args.requestedId) && !args.replaceExistingIds.has(args.requestedId) || args.createdValues.some(
92419
92472
  (value2) => value2.id === args.requestedId && value2.id !== args.generatedId
92420
92473
  )) {
92421
92474
  throw new Error(`Value "${args.requestedId}" already exists.`);
@@ -92487,10 +92540,8 @@ function collectStringReferences2(value, output) {
92487
92540
  collectStringReferences2(entry, output);
92488
92541
  }
92489
92542
  }
92490
- function requireDocumentMember(document, memberId) {
92491
- const member = document.members.find(
92492
- (candidate) => candidate.id === memberId
92493
- );
92543
+ function requireSeedMember(documentIndex, memberId) {
92544
+ const member = documentIndex.membersById.get(memberId);
92494
92545
  if (member === void 0) throw new Error(`Member "${memberId}" is missing.`);
92495
92546
  return member;
92496
92547
  }
@@ -92748,6 +92799,18 @@ function prepareServerOwnedValueInitializerBodies(args) {
92748
92799
  });
92749
92800
  }
92750
92801
  }
92802
+ function collectDelegateSweepRows(args) {
92803
+ if (args.targetIds.size === 0) return [];
92804
+ const preparedValueIds = indexChangesByRecordId(args.prepared, "value");
92805
+ const sweepRows = [];
92806
+ for (const value of args.postDocument.values) {
92807
+ if (!args.targetIds.has(value.id)) continue;
92808
+ if (preparedValueIds.has(value.id)) continue;
92809
+ const row = delegateValueRow(value);
92810
+ if (row !== null) sweepRows.push(row);
92811
+ }
92812
+ return sweepRows;
92813
+ }
92751
92814
  function delegateValueRow(value) {
92752
92815
  if (!isMemberValue(value) || !isLiteralValueContent(value)) return null;
92753
92816
  if (!isNSDelegateClosureValueDraft(value.value) && !isNSDelegateClosureValue(value.value)) {
@@ -92765,11 +92828,7 @@ function prepareServerOwnedDelegateValueBodies(args) {
92765
92828
  const row = delegateValueRow(change.nextData);
92766
92829
  if (row !== null) explicitRows.set(index, row);
92767
92830
  }
92768
- const sweepRows = args.postDocument.values.filter(
92769
- (value) => args.targetIds.has(value.id) && delegateValueRow(value) !== null && !args.prepared.some(
92770
- (change) => change.recordKind === "value" && change.recordId === value.id
92771
- )
92772
- );
92831
+ const sweepRows = collectDelegateSweepRows(args);
92773
92832
  if (explicitRows.size === 0 && sweepRows.length === 0) return;
92774
92833
  const committedDocument = applyProjectVersionWriteChanges(
92775
92834
  args.postDocument,
@@ -93292,8 +93351,7 @@ function applyProjectVersionWriteChanges(document, changes) {
93292
93351
  const hasGranularDialogueNodes = document.dialogueNodes !== void 0 || changes.some((change) => change.recordKind === "dialogue-node");
93293
93352
  const dialogueRecords = hasGranularDialogueRecords ? applyArrayChanges(document.dialogueRecords ?? [], changes, "dialogue") : void 0;
93294
93353
  const dialogueNodes = hasGranularDialogueNodes ? applyArrayChanges(document.dialogueNodes ?? [], changes, "dialogue-node") : void 0;
93295
- return {
93296
- ...document,
93354
+ const projected = {
93297
93355
  project: applySingletonChange(document.project, changes, "project"),
93298
93356
  members: applyArrayChanges(document.members, changes, "member"),
93299
93357
  classes: applyArrayChanges(document.classes, changes, "class"),
@@ -93347,8 +93405,6 @@ function applyProjectVersionWriteChanges(document, changes) {
93347
93405
  ),
93348
93406
  enums: applyArrayChanges(document.enums, changes, "enum"),
93349
93407
  interfaces: applyArrayChanges(document.interfaces, changes, "interface"),
93350
- ...dialogueRecords === void 0 ? {} : { dialogueRecords },
93351
- ...dialogueNodes === void 0 ? {} : { dialogueNodes },
93352
93408
  dialogues: dialogueRecords === void 0 || dialogueNodes === void 0 ? document.dialogues : materializeDialogues(
93353
93409
  dialogueRecords,
93354
93410
  dialogueNodes
@@ -93364,6 +93420,15 @@ function applyProjectVersionWriteChanges(document, changes) {
93364
93420
  "migration"
93365
93421
  )
93366
93422
  };
93423
+ return {
93424
+ ...document,
93425
+ ...projected,
93426
+ ...dialogueRecords === void 0 ? {} : { dialogueRecords },
93427
+ ...dialogueNodes === void 0 ? {} : { dialogueNodes }
93428
+ // The document spread above carries every bucket the caller's view declares
93429
+ // beyond the projected ones, so the result is the same view; TypeScript
93430
+ // cannot prove that of an object literal built over a type parameter.
93431
+ };
93367
93432
  }
93368
93433
  function applySingletonChange(current, changes, recordKind) {
93369
93434
  const change = changes.find(
@@ -93404,6 +93469,16 @@ function canonicallyEqual2(left, right) {
93404
93469
  return canonicalJsonStringify(left) === canonicalJsonStringify(right);
93405
93470
  }
93406
93471
  function reconcileVariantConstructorArgs(args) {
93472
+ const changeIndexByValueId = indexChangesByRecordId(args.prepared, "value");
93473
+ const commitTouchesProjectionSchema = variantConstructorArgsSchemaIsTouched(
93474
+ args.prepared
93475
+ );
93476
+ if (changeIndexByValueId.size === 0 && !commitTouchesProjectionSchema) {
93477
+ return;
93478
+ }
93479
+ if ((args.document.variants ?? []).length === 0 && !args.prepared.some((change) => change.recordKind === "variant")) {
93480
+ return;
93481
+ }
93407
93482
  const postDocument = applyProjectVersionWriteChanges(
93408
93483
  args.document,
93409
93484
  args.prepared
@@ -93412,9 +93487,8 @@ function reconcileVariantConstructorArgs(args) {
93412
93487
  if (variants.length === 0) return;
93413
93488
  const valueById = indexRecordsById(postDocument.values);
93414
93489
  const classById = indexRecordsById(postDocument.classes);
93415
- const memberById = indexRecordsById(postDocument.members);
93490
+ const memberById2 = indexRecordsById(postDocument.members);
93416
93491
  const constructorById = indexRecordsById(postDocument.constructors ?? []);
93417
- const changeIndexByValueId = indexChangesByRecordId(args.prepared, "value");
93418
93492
  let baseHashByValueId = null;
93419
93493
  for (const variant of variants) {
93420
93494
  const root = valueById.get(variant.valueId);
@@ -93431,6 +93505,9 @@ function reconcileVariantConstructorArgs(args) {
93431
93505
  if (constructorRecord === void 0) continue;
93432
93506
  if (typeof root.value !== "object" || root.value === null) continue;
93433
93507
  if (Array.isArray(root.value)) continue;
93508
+ if (!commitTouchesProjectionSchema && !variantConstructorArgsAreTouched(root, changeIndexByValueId)) {
93509
+ continue;
93510
+ }
93434
93511
  const nextArgs = {};
93435
93512
  for (let index = 0; index < constructorRecord.argumentTypes.length; index += 1) {
93436
93513
  const argument2 = constructorRecord.argumentTypes[index];
@@ -93444,7 +93521,7 @@ function reconcileVariantConstructorArgs(args) {
93444
93521
  );
93445
93522
  if (schemaKey === void 0) continue;
93446
93523
  const memberId = schemaClass2.schema[schemaKey];
93447
- const member = memberId === void 0 ? void 0 : memberById.get(memberId);
93524
+ const member = memberId === void 0 ? void 0 : memberById2.get(memberId);
93448
93525
  if (member === void 0) continue;
93449
93526
  const childId = root.value[schemaKey];
93450
93527
  if (typeof childId !== "string") continue;
@@ -93500,6 +93577,21 @@ function reconcileVariantConstructorArgs(args) {
93500
93577
  });
93501
93578
  }
93502
93579
  }
93580
+ function variantConstructorArgsSchemaIsTouched(prepared) {
93581
+ return prepared.some(
93582
+ (change) => VARIANT_CONSTRUCTOR_ARGS_SCHEMA_RECORD_KINDS.has(change.recordKind)
93583
+ );
93584
+ }
93585
+ function variantConstructorArgsAreTouched(root, changeIndexByValueId) {
93586
+ if (changeIndexByValueId.has(root.id)) return true;
93587
+ const body = root.value;
93588
+ for (const schemaKey of NEO_VARIANT_SCHEMA_KEY_BY_ARGUMENT_NAME.values()) {
93589
+ const childId = body[schemaKey];
93590
+ if (typeof childId !== "string") continue;
93591
+ if (changeIndexByValueId.has(childId)) return true;
93592
+ }
93593
+ return false;
93594
+ }
93503
93595
  function variantConstructorArgumentIsRestValue(schemaKey, value) {
93504
93596
  if (value === null) return true;
93505
93597
  if (schemaKey === NEO_VARIANT_OVERRIDES_SCHEMA_KEY) {
@@ -93548,7 +93640,7 @@ function appendVariantGraphCascadeDeletes(args) {
93548
93640
  });
93549
93641
  }
93550
93642
  }
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;
93643
+ 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, VARIANT_CONSTRUCTOR_ARGS_SCHEMA_RECORD_KINDS;
93552
93644
  var init_project_version_schema_commit = __esm({
93553
93645
  "../src/database/project-version-schema-commit.ts"() {
93554
93646
  "use strict";
@@ -93610,6 +93702,9 @@ var init_project_version_schema_commit = __esm({
93610
93702
  ["overrides", NEO_VARIANT_OVERRIDES_SCHEMA_KEY],
93611
93703
  ["childoverrides", NEO_VARIANT_CHILD_OVERRIDES_SCHEMA_KEY]
93612
93704
  ]);
93705
+ VARIANT_CONSTRUCTOR_ARGS_SCHEMA_RECORD_KINDS = /* @__PURE__ */ new Set(
93706
+ ["constructor", "class", "member", "variant"]
93707
+ );
93613
93708
  }
93614
93709
  });
93615
93710
 
@@ -95236,6 +95331,52 @@ var init_project_version_whole_graph_validation = __esm({
95236
95331
  }
95237
95332
  });
95238
95333
 
95334
+ // src/project-source/value-base-desync.ts
95335
+ function unanchoredValueDeleteIds(args) {
95336
+ const { records: records2, deletedValueIds } = args;
95337
+ if (deletedValueIds.size === 0) return [];
95338
+ const anchored = /* @__PURE__ */ new Set();
95339
+ for (const [key, record3] of Object.entries(records2)) {
95340
+ collectAnchoredMentions(record3.data, key, deletedValueIds, anchored);
95341
+ }
95342
+ const unanchored = [];
95343
+ for (const id2 of deletedValueIds) {
95344
+ if (anchored.has(id2)) continue;
95345
+ const data = records2[recordStateKey("value", id2)]?.data;
95346
+ const containerId = isObjectRecord2(data) ? data.containerId : void 0;
95347
+ if (typeof containerId === "string" && records2[recordStateKey("value", containerId)] !== void 0) {
95348
+ continue;
95349
+ }
95350
+ unanchored.push(id2);
95351
+ }
95352
+ return unanchored;
95353
+ }
95354
+ function collectAnchoredMentions(value, mentioningKey, candidates, anchored) {
95355
+ if (typeof value === "string") {
95356
+ if (!candidates.has(value)) return;
95357
+ if (recordStateKey("value", value) === mentioningKey) return;
95358
+ anchored.add(value);
95359
+ return;
95360
+ }
95361
+ if (Array.isArray(value)) {
95362
+ for (const element of value) {
95363
+ collectAnchoredMentions(element, mentioningKey, candidates, anchored);
95364
+ }
95365
+ return;
95366
+ }
95367
+ if (!isObjectRecord2(value)) return;
95368
+ for (const nested of Object.values(value)) {
95369
+ collectAnchoredMentions(nested, mentioningKey, candidates, anchored);
95370
+ }
95371
+ }
95372
+ var init_value_base_desync = __esm({
95373
+ "src/project-source/value-base-desync.ts"() {
95374
+ "use strict";
95375
+ init_projection();
95376
+ init_workspace();
95377
+ }
95378
+ });
95379
+
95239
95380
  // src/project-source/workspace-status-core.ts
95240
95381
  function listVirtualProjectSourceFilesV4(files) {
95241
95382
  const selected = files.filter((file) => {
@@ -95305,6 +95446,7 @@ function computeWorkspaceStatus(workspace, options) {
95305
95446
  binaryFiles: []
95306
95447
  };
95307
95448
  }
95449
+ const loweringRecords = loweringBaseRecords(workspace.state.records);
95308
95450
  const baseDocuments = schemaBaseDocuments(workspace);
95309
95451
  const staticMemberOwnershipRecoveries = [];
95310
95452
  const baseManifest = baseDocuments.length === 0 ? void 0 : documentsToProjectSchemaManifest(baseDocuments, {
@@ -95372,7 +95514,7 @@ function computeWorkspaceStatus(workspace, options) {
95372
95514
  };
95373
95515
  }
95374
95516
  try {
95375
- validateProjectRootEnvelopeV4(workspace.state.records, analysis);
95517
+ validateProjectRootEnvelopeV4(loweringRecords, analysis);
95376
95518
  } catch (error) {
95377
95519
  const root = analysis.configuration.globals.find(
95378
95520
  (global) => global.type.name === "Root"
@@ -95397,20 +95539,15 @@ function computeWorkspaceStatus(workspace, options) {
95397
95539
  };
95398
95540
  }
95399
95541
  manifest = lowerProjectSchemaV4(baseManifest, analysis, {
95400
- staticValueIdsBySymbol: staticValueIdsBySymbol(workspace.state.records),
95401
- projectFileIdsBySymbol: projectFileIdsBySymbol(
95402
- workspace.state.records,
95403
- analysis
95404
- ),
95405
- rowBackedDefaultMemberIds: rowBackedDefaultMemberIdsV4(
95406
- workspace.state.records
95407
- ),
95542
+ staticValueIdsBySymbol: staticValueIdsBySymbol(loweringRecords),
95543
+ projectFileIdsBySymbol: projectFileIdsBySymbol(loweringRecords, analysis),
95544
+ rowBackedDefaultMemberIds: rowBackedDefaultMemberIdsV4(loweringRecords),
95408
95545
  rootValueTargetsByPath: rootValueTargetsByPath(
95409
- Object.values(workspace.state.records)
95546
+ Object.values(loweringRecords)
95410
95547
  )
95411
95548
  });
95412
95549
  memberDefaults = lowerMemberDefaultSourcesV4(
95413
- workspace.state.records,
95550
+ loweringRecords,
95414
95551
  analysis,
95415
95552
  manifest,
95416
95553
  { registry: valueLowerRegistry }
@@ -95488,7 +95625,7 @@ function computeWorkspaceStatus(workspace, options) {
95488
95625
  );
95489
95626
  }
95490
95627
  const staticValues = lowerStaticValueSourcesV4(
95491
- workspace.state.records,
95628
+ loweringRecords,
95492
95629
  projectAnalysisV4,
95493
95630
  manifest,
95494
95631
  { registry: valueLowerRegistry }
@@ -95499,7 +95636,7 @@ function computeWorkspaceStatus(workspace, options) {
95499
95636
  ]);
95500
95637
  staticMemberValueIds = staticValues.memberValueIds;
95501
95638
  const rootValues = lowerProjectRootSourceV4(
95502
- workspace.state.records,
95639
+ loweringRecords,
95503
95640
  projectAnalysisV4,
95504
95641
  manifest,
95505
95642
  { registry: valueLowerRegistry }
@@ -95507,7 +95644,7 @@ function computeWorkspaceStatus(workspace, options) {
95507
95644
  reportPhase("documents-static-root");
95508
95645
  authoredValueSeeds = new Map([...authoredValueSeeds, ...rootValues.seeds]);
95509
95646
  const rootPathResolutionState = overlayProspectiveSourceRecords(
95510
- workspace.state.records,
95647
+ loweringRecords,
95511
95648
  documents,
95512
95649
  [...staticValues.records, ...memberDefaults.records, ...rootValues.records],
95513
95650
  staticMemberValueIds
@@ -95635,18 +95772,18 @@ function computeWorkspaceStatus(workspace, options) {
95635
95772
  }
95636
95773
  const rootRecords = rootValues.records;
95637
95774
  const variantValues = lowerVariantValueSourcesV4(
95638
- workspace.state.records,
95775
+ loweringRecords,
95639
95776
  manifest,
95640
95777
  variantValueBindingsV4(manifest, projectAnalysisV4),
95641
95778
  { analysis: projectAnalysisV4, registry: valueLowerRegistry }
95642
95779
  );
95643
95780
  const supplementalRecords = options.lowerSupplementalRecords(
95644
- workspace.state.records,
95781
+ loweringRecords,
95645
95782
  projectAnalysisV4,
95646
95783
  options.trustedPendingProjectFiles
95647
95784
  );
95648
95785
  const prospectiveState = overlayProspectiveSourceRecords(
95649
- workspace.state.records,
95786
+ loweringRecords,
95650
95787
  documents,
95651
95788
  [
95652
95789
  ...staticValues.records,
@@ -95795,6 +95932,50 @@ function computeWorkspaceStatus(workspace, options) {
95795
95932
  binaryFiles: []
95796
95933
  };
95797
95934
  }
95935
+ const unanchoredValueDeletes = unanchoredValueDeleteIds({
95936
+ records: workspace.state.records,
95937
+ deletedValueIds
95938
+ });
95939
+ if (unanchoredValueDeletes.length > 0) {
95940
+ const mintedRowCount = valueLowerRegistry.pendingValues.size + authoredValueSeeds.size;
95941
+ const named = unanchoredValueDeletes.slice(0, 3).join(", ");
95942
+ const remainder = Math.max(0, unanchoredValueDeletes.length - 3);
95943
+ const sample = remainder === 0 ? named : `${named}, +${remainder} more`;
95944
+ const deleteFile = changes.find(
95945
+ (change) => change.kind === "delete" && change.recordKind === "value" && change.recordId === unanchoredValueDeletes[0]
95946
+ )?.file;
95947
+ if (mintedRowCount > 0) {
95948
+ parseErrors.push(
95949
+ new SchemaSourceError(
95950
+ `This push would delete ${unanchoredValueDeletes.length} value row(s) no record in the workspace base holds (${sample}) while minting ${mintedRowCount} replacement row(s): the workspace base disagrees with its own file projection \u2014 run "neo pull" before pushing.`,
95951
+ deleteFile ?? "<project>",
95952
+ 1,
95953
+ 1,
95954
+ "value-base-desync"
95955
+ )
95956
+ );
95957
+ return {
95958
+ changes: [],
95959
+ conflictedFiles,
95960
+ parseErrors,
95961
+ parseWarnings,
95962
+ reconstructed: /* @__PURE__ */ new Map(),
95963
+ authoredValueSeeds: /* @__PURE__ */ new Map(),
95964
+ binaryChanges: [],
95965
+ binaryFiles: []
95966
+ };
95967
+ }
95968
+ parseWarnings.push(
95969
+ new SchemaSourceError(
95970
+ `This push deletes ${unanchoredValueDeletes.length} value row(s) no record in the workspace base holds (${sample}): the workspace base disagrees with its own file projection \u2014 run "neo pull" before pushing.`,
95971
+ deleteFile ?? "<project>",
95972
+ 1,
95973
+ 1,
95974
+ "value-base-desync",
95975
+ "warning"
95976
+ )
95977
+ );
95978
+ }
95798
95979
  for (let index = changes.length - 1; index >= 0; index -= 1) {
95799
95980
  const change = changes[index];
95800
95981
  if (change === void 0 || change.kind !== "update") continue;
@@ -96137,7 +96318,7 @@ function replayAnimationDeclarationInitializersV4(records2, document, fallbackDo
96137
96318
  }
96138
96319
  function animationRecordsFromState(records2) {
96139
96320
  return Object.values(records2).flatMap((record3) => {
96140
- const data = record3.conflictServerHash !== void 0 && isObjectRecord2(record3.conflictServerData) ? record3.conflictServerData : record3.data;
96321
+ const data = effectiveRecordData(record3);
96141
96322
  return isObjectRecord2(data) ? [{ recordKind: record3.recordKind, data }] : [];
96142
96323
  });
96143
96324
  }
@@ -96280,7 +96461,7 @@ function recordLabel(data) {
96280
96461
  function prospectiveAnimationRecords(base, reconstructed3, changes, seeds) {
96281
96462
  const prospective = /* @__PURE__ */ new Map();
96282
96463
  for (const [key, state] of Object.entries(base)) {
96283
- const data = state.conflictServerHash !== void 0 && isObjectRecord2(state.conflictServerData) ? state.conflictServerData : state.data;
96464
+ const data = effectiveRecordData(state);
96284
96465
  if (isObjectRecord2(data)) {
96285
96466
  prospective.set(key, { recordKind: state.recordKind, data });
96286
96467
  }
@@ -96412,7 +96593,8 @@ function overlayProspectiveSourceRecords(base, schemaDocuments, authored, static
96412
96593
  for (const record3 of authored) {
96413
96594
  const key = recordStateKey(record3.recordKind, record3.recordId);
96414
96595
  const previous = result[key];
96415
- const previousData = previous?.conflictServerHash !== void 0 && isObjectRecord2(previous.conflictServerData) ? previous.conflictServerData : isObjectRecord2(previous?.data) ? previous.data : {};
96596
+ const effectivePrevious = previous === void 0 ? void 0 : effectiveRecordData(previous);
96597
+ const previousData = isObjectRecord2(effectivePrevious) ? effectivePrevious : {};
96416
96598
  put(record3.recordKind, record3.recordId, {
96417
96599
  ...previousData,
96418
96600
  ...record3.fileFields
@@ -96424,7 +96606,7 @@ function schemaBaseDocuments(workspace) {
96424
96606
  const records2 = [];
96425
96607
  for (const state of Object.values(workspace.state.records)) {
96426
96608
  if (!isSchemaRecordKindV4(state.recordKind)) continue;
96427
- const effectiveBase = state.conflictServerHash !== void 0 && isObjectRecord2(state.conflictServerData) ? state.conflictServerData : state.data;
96609
+ const effectiveBase = effectiveRecordData(state);
96428
96610
  if (!isObjectRecord2(effectiveBase)) {
96429
96611
  throw new Error(
96430
96612
  `Schema base ${state.recordKind}:${state.recordId} must contain an object document. Run \`neo pull --reset\` to repair the workspace state.`
@@ -96565,6 +96747,7 @@ var init_workspace_status_core = __esm({
96565
96747
  init_compile_ns_property();
96566
96748
  init_materialized_construction_cache();
96567
96749
  init_project_version_whole_graph_validation();
96750
+ init_value_base_desync();
96568
96751
  }
96569
96752
  });
96570
96753
 
@@ -98378,6 +98561,7 @@ function buildValueLowerContext(state, manifest, options = {}) {
98378
98561
  parsedInitializers,
98379
98562
  declaredInitializers: indexDeclaredInitializers(options.analysis),
98380
98563
  reconstructed: /* @__PURE__ */ new Map(),
98564
+ retainedReconstructedKeys: /* @__PURE__ */ new Set(),
98381
98565
  pendingValues: registry.pendingValues,
98382
98566
  pendingLocalizedTexts: registry.pendingLocalizedTexts,
98383
98567
  loweredMemberIdByValueId: /* @__PURE__ */ new Map(),
@@ -100852,10 +101036,16 @@ function lowerClassValue(context, member, expression, base, source, outerEnviron
100852
101036
  );
100853
101037
  }
100854
101038
  if (materializedConstruction !== "lower") {
100855
- for (const childId of Object.values(baseBody)) {
100856
- if (typeof childId === "string") {
100857
- retainStoredValueSubgraph(context, childId, source.source, /* @__PURE__ */ new Set());
100858
- }
101039
+ const storedMemberIds = storedClassSchemaMemberIds(context, currentClassId);
101040
+ for (const [schemaKey, childId] of Object.entries(baseBody)) {
101041
+ if (typeof childId !== "string") continue;
101042
+ retainStoredValueSubgraph(
101043
+ context,
101044
+ childId,
101045
+ source.source,
101046
+ /* @__PURE__ */ new Set(),
101047
+ memberById(context, storedMemberIds.get(schemaKey))
101048
+ );
100859
101049
  }
100860
101050
  if (materializedConstruction === "preserve" && isObjectRecord2(base.constructorArgs)) {
100861
101051
  const constructor2 = storedValueConstructor(
@@ -100863,12 +101053,25 @@ function lowerClassValue(context, member, expression, base, source, outerEnviron
100863
101053
  schemaClass2,
100864
101054
  base.constructorArgs
100865
101055
  );
101056
+ const authoredArguments = constructorArgumentExpressions(expression);
100866
101057
  for (let index = 0; index < constructor2.arguments.length; index += 1) {
100867
101058
  const argument2 = constructor2.arguments[index];
101059
+ if (argument2 === void 0) continue;
100868
101060
  const valueId = base.constructorArgs[`__arg_${index}__`];
100869
- if (argument2 !== void 0 && typeof valueId === "string" && constructorArgumentOwnsRow(argument2.type)) {
100870
- retainStoredValueSubgraph(context, valueId, source.source, /* @__PURE__ */ new Set());
101061
+ if (typeof valueId !== "string") continue;
101062
+ if (!constructorArgumentOwnsRow(
101063
+ argument2.type,
101064
+ authoredArguments.get(argument2.name)
101065
+ )) {
101066
+ continue;
100871
101067
  }
101068
+ retainStoredValueSubgraph(
101069
+ context,
101070
+ valueId,
101071
+ source.source,
101072
+ /* @__PURE__ */ new Set(),
101073
+ null
101074
+ );
100872
101075
  }
100873
101076
  }
100874
101077
  }
@@ -100878,45 +101081,106 @@ function lowerClassValue(context, member, expression, base, source, outerEnviron
100878
101081
  ...classId === currentClassId ? {} : { classId }
100879
101082
  };
100880
101083
  }
100881
- function constructorArgumentOwnsRow(type) {
100882
- return type.kind === "class" || type.kind === "interface" || type.kind === "generic" || type.kind === "list" || type.kind === "dictionary";
101084
+ function constructorArgumentOwnsRow(type, authoredArgument) {
101085
+ if (type.kind !== "class" && type.kind !== "interface" && type.kind !== "generic" && type.kind !== "list" && type.kind !== "dictionary") {
101086
+ return false;
101087
+ }
101088
+ return !namesExistingRow(authoredArgument);
101089
+ }
101090
+ function constructorArgumentExpressions(expression) {
101091
+ const byName = /* @__PURE__ */ new Map();
101092
+ const names = expression.argumentNames ?? [];
101093
+ for (const [index, argument2] of expression.args.entries()) {
101094
+ const name = names[index];
101095
+ if (typeof name !== "string") continue;
101096
+ if (byName.has(name)) continue;
101097
+ byName.set(name, argument2);
101098
+ }
101099
+ return byName;
101100
+ }
101101
+ function namesExistingRow(expression) {
101102
+ if (expression === void 0) return false;
101103
+ const unwrapped = annotatedValue(expression).expression;
101104
+ if (unwrapped.kind !== "call") return false;
101105
+ if (unwrapped.callee.kind !== "ident") return false;
101106
+ return unwrapped.callee.name === "Reference";
101107
+ }
101108
+ function memberPointsAtForeignRows(member) {
101109
+ return member.kind === "lookup" || member.kind === "dialogueLookup";
101110
+ }
101111
+ function memberById(context, memberId) {
101112
+ if (memberId === void 0) return null;
101113
+ return context.members.get(memberId) ?? null;
101114
+ }
101115
+ function collectionEntryMember(context, member) {
101116
+ if (member === null) return null;
101117
+ if (member.kind !== "list" && member.kind !== "dictionary") return null;
101118
+ return memberById(context, member.entryMemberId);
101119
+ }
101120
+ function storedRowPlacementMember(context, valueId) {
101121
+ for (const placement of context.valuePlacements.placementsByValueId.get(
101122
+ valueId
101123
+ ) ?? []) {
101124
+ if (placement.containerClassId === null) continue;
101125
+ const memberId = storedClassSchemaMemberIds(
101126
+ context,
101127
+ placement.containerClassId
101128
+ ).get(placement.schemaKey);
101129
+ const member = memberById(context, memberId);
101130
+ if (member !== null) return member;
101131
+ }
101132
+ return null;
100883
101133
  }
100884
- function retainStoredValueSubgraph(context, valueId, source, visited) {
101134
+ function retainStoredValueSubgraph(context, valueId, source, visited, member) {
100885
101135
  if (visited.has(valueId)) return;
100886
101136
  visited.add(valueId);
100887
101137
  const state = context.state[`value:${valueId}`];
100888
101138
  if (state === void 0 || !isObjectRecord2(state.data)) return;
100889
- const key = `value:${valueId}`;
100890
- if (!context.reconstructed.has(key)) {
100891
- addReconstructed(
100892
- context,
100893
- "value",
100894
- valueId,
100895
- valueFileFields(state.data),
100896
- source
100897
- );
100898
- }
100899
- const referenced = /* @__PURE__ */ new Set();
100900
- const collect = (value) => {
101139
+ addReconstructed(
101140
+ context,
101141
+ "value",
101142
+ valueId,
101143
+ valueFileFields(state.data),
101144
+ source,
101145
+ { retained: true }
101146
+ );
101147
+ const owningMember = member ?? storedRowPlacementMember(context, valueId);
101148
+ if (owningMember !== null && memberPointsAtForeignRows(owningMember)) return;
101149
+ const referenced = /* @__PURE__ */ new Map();
101150
+ const add = (id2, childMember) => {
101151
+ if (context.state[`value:${id2}`] === void 0) return;
101152
+ if (referenced.has(id2)) return;
101153
+ referenced.set(id2, childMember);
101154
+ };
101155
+ const collect = (value, childMember) => {
100901
101156
  if (typeof value === "string") {
100902
- if (context.state[`value:${value}`] !== void 0) referenced.add(value);
101157
+ add(value, childMember);
100903
101158
  return;
100904
101159
  }
100905
101160
  if (Array.isArray(value)) {
100906
- for (const entry of value) collect(entry);
101161
+ for (const entry of value) collect(entry, childMember);
100907
101162
  return;
100908
101163
  }
100909
101164
  if (!isObjectRecord2(value)) return;
100910
- for (const entry of Object.values(value)) collect(entry);
101165
+ for (const entry of Object.values(value)) collect(entry, childMember);
100911
101166
  };
100912
- collect(state.data.value);
101167
+ const body = state.data.value;
101168
+ const storedClassId = stringOrNull(state.data.classId);
101169
+ if (isObjectRecord2(body) && storedClassId !== null) {
101170
+ const storedMemberIds = storedClassSchemaMemberIds(context, storedClassId);
101171
+ for (const [schemaKey, child] of Object.entries(body)) {
101172
+ collect(child, memberById(context, storedMemberIds.get(schemaKey)));
101173
+ }
101174
+ } else {
101175
+ collect(body, collectionEntryMember(context, owningMember));
101176
+ }
100913
101177
  for (const childId of context.valuePlacements.valueIdsByContainerId.get(
100914
101178
  valueId
100915
101179
  ) ?? []) {
100916
- referenced.add(childId);
101180
+ add(childId, collectionEntryMember(context, owningMember));
100917
101181
  }
100918
- for (const childId of referenced) {
100919
- retainStoredValueSubgraph(context, childId, source, visited);
101182
+ for (const [childId, childMember] of referenced) {
101183
+ retainStoredValueSubgraph(context, childId, source, visited, childMember);
100920
101184
  }
100921
101185
  }
100922
101186
  function lowerConstructorProjections(context, schemaClass2, expression, base, baseBody, body, source, environment, authoredSlice) {
@@ -102371,7 +102635,7 @@ function dialogueTargetsBySymbol(analysis) {
102371
102635
  }
102372
102636
  function indexSourceStaticTargets(targets, state, analysis, manifest, parsedInitializers) {
102373
102637
  if (!analysis) return;
102374
- const memberById = new Map(
102638
+ const memberById2 = new Map(
102375
102639
  manifest.members.map((member) => [member.id, member])
102376
102640
  );
102377
102641
  for (let pass = 0; pass < 2; pass += 1) {
@@ -102388,7 +102652,7 @@ function indexSourceStaticTargets(targets, state, analysis, manifest, parsedInit
102388
102652
  if (declaration.kind !== "field" || declaration.initializer === null)
102389
102653
  continue;
102390
102654
  const memberId = sourceIdentityId(declaration, "member", symbol);
102391
- if (!memberById.has(memberId)) continue;
102655
+ if (!memberById2.has(memberId)) continue;
102392
102656
  const expression = parseCachedInitializer(
102393
102657
  parsedInitializers,
102394
102658
  declaration.initializer
@@ -102651,21 +102915,30 @@ function annotationId2(annotations) {
102651
102915
  }
102652
102916
  return value.value;
102653
102917
  }
102654
- function addReconstructed(context, recordKind, recordId, fileFields, source) {
102918
+ function addReconstructed(context, recordKind, recordId, fileFields, source, options = {}) {
102655
102919
  const key = `${recordKind}:${recordId}`;
102656
102920
  const existing = context.reconstructed.get(key);
102921
+ const line = source.range.start.line + 1;
102657
102922
  if (existing !== void 0) {
102658
- if (!canonicallyEqual(existing.fileFields, fileFields)) {
102659
- throw new Error(`Source reconstructs ${key} with different content.`);
102923
+ if (options.retained === true) return;
102924
+ if (context.retainedReconstructedKeys.has(key)) {
102925
+ context.retainedReconstructedKeys.delete(key);
102926
+ } else {
102927
+ if (!canonicallyEqual(existing.fileFields, fileFields)) {
102928
+ throw new Error(
102929
+ `Source reconstructs ${key} with different content: ${existing.file}:${existing.line} and ${source.uri}:${line} each lower this record from a different body.`
102930
+ );
102931
+ }
102932
+ return;
102660
102933
  }
102661
- return;
102662
102934
  }
102935
+ if (options.retained === true) context.retainedReconstructedKeys.add(key);
102663
102936
  context.reconstructed.set(key, {
102664
102937
  recordKind,
102665
102938
  recordId,
102666
102939
  fileFields,
102667
102940
  file: source.uri,
102668
- line: source.range.start.line + 1,
102941
+ line,
102669
102942
  sourceSpan: {
102670
102943
  path: source.uri,
102671
102944
  start: source.range.start,
@@ -109650,14 +109923,14 @@ function resolveNSFunctionReceiverValue(thisRef, target, document) {
109650
109923
  }
109651
109924
  function buildRootValue(document) {
109652
109925
  const rootValue = {};
109653
- const memberById = new Map(
109926
+ const memberById2 = new Map(
109654
109927
  document.members.map((entry) => [entry.id, entry])
109655
109928
  );
109656
109929
  const valueById = new Map(document.values.map((entry) => [entry.id, entry]));
109657
109930
  for (const { root, memberId } of projectRootMembersInDisplayOrder(
109658
109931
  document.project
109659
109932
  )) {
109660
- const member = memberById.get(memberId);
109933
+ const member = memberById2.get(memberId);
109661
109934
  const valueId = member !== void 0 && typeof member.valueId === "string" ? member.valueId : null;
109662
109935
  rootValue[root.key] = valueId !== null ? valueById.get(valueId)?.value ?? null : null;
109663
109936
  }
@@ -110377,7 +110650,7 @@ function neoScriptCheckErrorMessage(error) {
110377
110650
  function resolveLocalScriptMember(manifest, memberRef) {
110378
110651
  if (memberRef === null) return null;
110379
110652
  const scripted = manifest.members.filter(isLocalScriptMember);
110380
- const memberById = new Map(scripted.map((member2) => [member2.id, member2]));
110653
+ const memberById2 = new Map(scripted.map((member2) => [member2.id, member2]));
110381
110654
  const separator = memberRef.lastIndexOf(".");
110382
110655
  if (separator > 0 && separator < memberRef.length - 1) {
110383
110656
  const classRef = memberRef.slice(0, separator);
@@ -110400,7 +110673,7 @@ function resolveLocalScriptMember(manifest, memberRef) {
110400
110673
  while (!visited.has(current.id)) {
110401
110674
  visited.add(current.id);
110402
110675
  for (const [schemaKey, memberId] of Object.entries(current.schema)) {
110403
- const member2 = memberById.get(memberId);
110676
+ const member2 = memberById2.get(memberId);
110404
110677
  if (member2 !== void 0 && (schemaKey === memberName || localMemberMatchesMember(member2, memberName))) {
110405
110678
  return { member: member2, receiverClassId: receiver.id };
110406
110679
  }
@@ -114395,7 +114668,7 @@ var init_registry2 = __esm({
114395
114668
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
114396
114669
  formatVersion: 3,
114397
114670
  contractVersion: "3.14",
114398
- cliVersion: "0.36.10",
114671
+ cliVersion: "0.36.12",
114399
114672
  projectFileUploadBatchSize: 32,
114400
114673
  documentRecords: {
114401
114674
  member: {
@@ -118222,7 +118495,7 @@ async function runPendingMigrations(workspace, client, raw, migrations, onlyRef,
118222
118495
  }
118223
118496
  }
118224
118497
  }
118225
- const memberById = new Map(
118498
+ const memberById2 = new Map(
118226
118499
  document.members.map((member) => [member.id, member])
118227
118500
  );
118228
118501
  const valueById = new Map(
@@ -118293,7 +118566,7 @@ async function runPendingMigrations(workspace, client, raw, migrations, onlyRef,
118293
118566
  },
118294
118567
  null
118295
118568
  );
118296
- const instances = targetClassId === null ? [null] : collectClassInstances(document, targetClassId, memberById, valueById);
118569
+ const instances = targetClassId === null ? [null] : collectClassInstances(document, targetClassId, memberById2, valueById);
118297
118570
  let instanceEditCount = 0;
118298
118571
  for (const instance of instances) {
118299
118572
  let result;
@@ -118499,7 +118772,7 @@ async function runPendingMigrations(workspace, client, raw, migrations, onlyRef,
118499
118772
  `Applied ${pending.length} migration(s). Run "neo pull" to refresh the working copy.`
118500
118773
  );
118501
118774
  }
118502
- function collectClassInstances(document, targetClassId, memberById, valueById) {
118775
+ function collectClassInstances(document, targetClassId, memberById2, valueById) {
118503
118776
  const classById = new Map(
118504
118777
  document.classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
118505
118778
  );
@@ -118508,7 +118781,7 @@ function collectClassInstances(document, targetClassId, memberById, valueById) {
118508
118781
  const walk = (memberId, valueId) => {
118509
118782
  if (typeof valueId !== "string" || seen.has(valueId)) return;
118510
118783
  seen.add(valueId);
118511
- const member = typeof memberId === "string" ? memberById.get(memberId) : void 0;
118784
+ const member = typeof memberId === "string" ? memberById2.get(memberId) : void 0;
118512
118785
  const valueRecord = valueById.get(valueId);
118513
118786
  if (member === void 0 || valueRecord === void 0) return;
118514
118787
  const memberKind = member.kind;
@@ -119732,7 +120005,7 @@ function buildWorld(document, raw) {
119732
120005
  const valueById = new Map(
119733
120006
  document.values.map((value) => [String(value.id), value])
119734
120007
  );
119735
- const memberById = new Map(
120008
+ const memberById2 = new Map(
119736
120009
  document.members.map((member) => [String(member.id), member])
119737
120010
  );
119738
120011
  const saveOwned = /* @__PURE__ */ new Set();
@@ -119750,7 +120023,7 @@ function buildWorld(document, raw) {
119750
120023
  if (visitedPlacements.has(visitKey)) return;
119751
120024
  visitedPlacements.add(visitKey);
119752
120025
  const value = valueById.get(valueId);
119753
- const member = memberById.get(memberId);
120026
+ const member = memberById2.get(memberId);
119754
120027
  if (value === void 0 || member === void 0) return;
119755
120028
  const storage = storageResolver.effectiveStorageForPath(memberPath2);
119756
120029
  if (storage === "save" /* Save */) saveOwned.add(valueId);
@@ -119783,7 +120056,7 @@ function buildWorld(document, raw) {
119783
120056
  for (const { memberId } of projectRootMembersInDisplayOrder(
119784
120057
  document.project
119785
120058
  )) {
119786
- const member = memberById.get(memberId);
120059
+ const member = memberById2.get(memberId);
119787
120060
  if (member !== void 0 && typeof member.valueId === "string") {
119788
120061
  walkOwnedGraph([memberId], member.valueId);
119789
120062
  }
@@ -121014,7 +121287,7 @@ There is no --keep-current: preserving current semantic state defines flatten.
121014
121287
  async function main() {
121015
121288
  const args = parseArgs(process.argv.slice(2));
121016
121289
  if (args.command === "--version") {
121017
- console.log("0.36.10");
121290
+ console.log("0.36.12");
121018
121291
  return;
121019
121292
  }
121020
121293
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {