@neocompose/cli 0.89.11 → 0.89.13

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.
@@ -19377,7 +19377,7 @@ var init_registry = __esm({
19377
19377
  "../packages/manifest/schema-contract/registry.mjs"() {
19378
19378
  "use strict";
19379
19379
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
19380
- cliVersion: "0.89.11",
19380
+ cliVersion: "0.89.13",
19381
19381
  projectFileUploadBatchSize: 32,
19382
19382
  documentRecords: {
19383
19383
  member: {
@@ -25194,6 +25194,10 @@ function* staticMembersInitializedByName(analysis, syntax) {
25194
25194
  }
25195
25195
  }
25196
25196
  }
25197
+ function pendingLocalValueId(global) {
25198
+ const source = global.source;
25199
+ return `__pending__:value:${encodeURIComponent(source.uri)}:${source.range.start.line}:${source.range.start.character}:${encodeURIComponent(global.name)}`;
25200
+ }
25197
25201
  function typeText(type2) {
25198
25202
  return type2.name + (type2.arguments.length === 0 ? "" : `<${type2.arguments.map(typeText).join(", ")}>`) + (type2.nullable ? "?" : "");
25199
25203
  }
@@ -25243,6 +25247,7 @@ var init_local_values = __esm({
25243
25247
  resolve(expression, source, valueId) {
25244
25248
  if (expression.kind !== "ident") return { expression, source };
25245
25249
  let text;
25250
+ let pendingIdentity;
25246
25251
  for (const step of this.chain(expression.name)) {
25247
25252
  const global = step.global;
25248
25253
  if (valueId !== void 0) {
@@ -25264,8 +25269,9 @@ var init_local_values = __esm({
25264
25269
  source: global.source,
25265
25270
  label: global.name
25266
25271
  };
25272
+ pendingIdentity = this.scalarTypes.has(global.type.name) ? void 0 : pendingLocalValueId(global);
25267
25273
  }
25268
- return { expression, source, text };
25274
+ return { expression, source, text, pendingIdentity };
25269
25275
  }
25270
25276
  /**
25271
25277
  * The expression and text a bare local name stands for, through any alias
@@ -25303,7 +25309,7 @@ var init_local_values = __esm({
25303
25309
  * Compile authoring locals without introducing runtime globals. The splices
25304
25310
  * are the uses of `code` this replaced.
25305
25311
  */
25306
- executable(code, runtimeIdentifiers = /* @__PURE__ */ new Set(), materializationRoot, identity3, storedValueAtPath) {
25312
+ executable(code, runtimeIdentifiers = /* @__PURE__ */ new Set(), materializationRoot, identity3) {
25307
25313
  if (this.definitions.size === 0 || !mayUseLocalInitializer(code, this.definitions))
25308
25314
  return { code, splices: [] };
25309
25315
  const terminalName = (name) => {
@@ -25380,23 +25386,40 @@ var init_local_values = __esm({
25380
25386
  const annotation2 = terminal2.expression.kind === "annotated" ? terminal2.expression.annotations.find(
25381
25387
  (entry) => entry.name === "id"
25382
25388
  )?.args[0] : void 0;
25383
- const existingId = storedValueAtPath?.(
25384
- materializationRoot,
25385
- placementPath
25386
- );
25387
- if (annotation2?.kind === "litString" && existingId !== annotation2.value) {
25388
- throw new Error(
25389
- `Local initializer ${terminal2.global.name} has an @id that does not identify its existing row inside this constructor-backed owner. Remove that @id and let preparation assign the owning tree, or place the value directly in its own static member.`
25390
- );
25391
- }
25392
25389
  const source = terminal2.global.source;
25393
25390
  const suffix = this.scalarTypes.has(terminal2.global.type.name) ? `:${encodeURIComponent(JSON.stringify([materializationRoot, placementPath]))}` : "";
25394
- const id2 = annotation2?.kind === "litString" ? annotation2.value : `__pending__:value:${encodeURIComponent(source.uri)}:${source.range.start.line}:${source.range.start.character}:${encodeURIComponent(terminal2.global.name)}${suffix}`;
25391
+ const id2 = annotation2?.kind === "litString" ? annotation2.value : `${pendingLocalValueId(terminal2.global)}${suffix}`;
25392
+ if (annotation2?.kind === "litString")
25393
+ identity3?.validateAuthoredId?.(id2);
25395
25394
  for (const { global } of steps) {
25396
25395
  const owners = this.owners.get(global.name) ?? /* @__PURE__ */ new Map();
25397
- owners.set(existingId ?? id2, global.name);
25396
+ owners.set(id2, global.name);
25398
25397
  this.owners.set(global.name, owners);
25399
25398
  }
25399
+ const normalizeLocation = (rootId, path2) => {
25400
+ const seen = /* @__PURE__ */ new Set();
25401
+ let location4 = { rootId, path: path2 };
25402
+ while (!seen.has(location4.rootId)) {
25403
+ seen.add(location4.rootId);
25404
+ const parent = identity3?.sites.get(location4.rootId)?.materializedLocation ?? identity3?.storedParent?.(location4.rootId);
25405
+ if (parent === void 0) break;
25406
+ location4 = {
25407
+ rootId: parent.rootId,
25408
+ path: [...parent.path, ...location4.path]
25409
+ };
25410
+ }
25411
+ return location4;
25412
+ };
25413
+ const location3 = normalizeLocation(
25414
+ materializationRoot,
25415
+ placementPath
25416
+ );
25417
+ const prior = identity3?.sites.get(id2)?.materializedLocation;
25418
+ const priorLocation = prior === void 0 ? void 0 : normalizeLocation(prior.rootId, prior.path);
25419
+ if (priorLocation !== void 0 && (priorLocation.rootId !== location3.rootId || JSON.stringify(priorLocation.path) !== JSON.stringify(location3.path)))
25420
+ throw new Error(
25421
+ `Local value ${terminal2.global.name} has two owning assignments. Use Reference(${terminal2.global.name}) for a reference, or duplicate its initializer.`
25422
+ );
25400
25423
  identity3?.sites.set(id2, {
25401
25424
  id: id2,
25402
25425
  uri: source.uri,
@@ -25406,8 +25429,10 @@ var init_local_values = __esm({
25406
25429
  stampForm: 0 /* Prefix */,
25407
25430
  nestedListEntries: identity3.localListEntries(terminal2.global),
25408
25431
  materializedLocation: {
25409
- rootId: materializationRoot,
25410
- path: placementPath
25432
+ preserveIdentity: !this.scalarTypes.has(
25433
+ terminal2.global.type.name
25434
+ ),
25435
+ ...location3
25411
25436
  },
25412
25437
  stampIdentity: annotation2 === void 0 && !this.scalarTypes.has(terminal2.global.type.name)
25413
25438
  });
@@ -51098,6 +51123,13 @@ function applyConstructorFields(args) {
51098
51123
  let kept = 0;
51099
51124
  for (const row of createdValues) {
51100
51125
  if (row.id === keptId || row.containerId === keptId) {
51126
+ if (row.containerId === keptId) {
51127
+ if (ctx.__indexes !== void 0)
51128
+ unindexEvaluatorRow(ctx.__indexes, row);
51129
+ delete row.containerId;
51130
+ if (ctx.__indexes !== void 0)
51131
+ indexEvaluatorRow(ctx.__indexes, row);
51132
+ }
51101
51133
  createdById.delete(row.id);
51102
51134
  continue;
51103
51135
  }
@@ -54309,6 +54341,9 @@ function materializeConstructorArgumentValue(args) {
54309
54341
  for (const entry of rows) sourceEntries.push(entry.value);
54310
54342
  }
54311
54343
  const ids = [];
54344
+ const authoredEntries = args.ctx.__constructionEntryIds === void 0 ? void 0 : [];
54345
+ if (authoredEntries !== void 0)
54346
+ args.ctx.__constructionEntryIds?.set(row.id, authoredEntries);
54312
54347
  const references = recordedReferenceEntries(sourceEntries, args.ctx) ?? (args.collectionEntriesAreReferences === false ? 1 /* Values */ : collectionReferences(sourceEntries, args.ctx));
54313
54348
  for (const [index, rawEntry] of sourceEntries.entries()) {
54314
54349
  if (args.collectionOwnerId !== void 0 && args.collectionEntriesAreReferences !== false && isReferenceEntry(references, index) && typeof rawEntry === "string" && evalValueById(
@@ -54318,6 +54353,7 @@ function materializeConstructorArgumentValue(args) {
54318
54353
  args.ctx.__valueOverlay
54319
54354
  ) !== null) {
54320
54355
  ids.push(rawEntry);
54356
+ authoredEntries?.push(rawEntry);
54321
54357
  continue;
54322
54358
  }
54323
54359
  const entryValue = constructorCollectionEntryValue(
@@ -54339,6 +54375,7 @@ function materializeConstructorArgumentValue(args) {
54339
54375
  },
54340
54376
  destinationName: `${args.member.name}[${index}]`
54341
54377
  });
54378
+ authoredEntries?.push(child2.id);
54342
54379
  if (listKindOf(args.member) === 1 /* Unordered */) {
54343
54380
  child2.containerId = row.id;
54344
54381
  } else {
@@ -54884,11 +54921,13 @@ function cloneClassValueGraph(receiver, expected, ctx) {
54884
54921
  );
54885
54922
  clonedRecord[key] = clonedChild.id;
54886
54923
  }
54887
- } else if (Array.isArray(sourceRow.value) && (isMemberEntryCollectionBase(sourceMember) || sourceTypeInfo?.type === 6 /* List */ || sourceTypeInfo?.type === 28 /* Set */)) {
54924
+ } else if (Array.isArray(sourceRow.value) && (isMemberEntryCollectionBase(sourceMember) || isMemberTupleBase(sourceMember) || sourceTypeInfo?.type === 30 /* Tuple */ || sourceTypeInfo?.type === 6 /* List */ || sourceTypeInfo?.type === 28 /* Set */)) {
54888
54925
  const entryMember = isMemberEntryCollectionBase(sourceMember) ? evalMemberById(ctx.vm, sourceMember.entryMemberId) : null;
54889
54926
  const entryTypeInfo = sourceTypeInfo?.type === 6 /* List */ || sourceTypeInfo?.type === 28 /* Set */ ? sourceTypeInfo.entryTypeInfo : void 0;
54890
- if (entryMember !== null || entryTypeInfo !== void 0) {
54891
- clone.value = sourceRow.value.map((childId) => {
54927
+ const tuple = isMemberTupleBase(sourceMember) ? sourceMember : null;
54928
+ const tupleType = sourceTypeInfo?.type === 30 /* Tuple */ ? sourceTypeInfo : null;
54929
+ if (entryMember !== null || entryTypeInfo !== void 0 || tuple !== null || tupleType !== null) {
54930
+ clone.value = sourceRow.value.map((childId, index) => {
54892
54931
  if (typeof childId !== "string") return childId;
54893
54932
  const child2 = evalValueById(
54894
54933
  ctx,
@@ -54897,11 +54936,17 @@ function cloneClassValueGraph(receiver, expected, ctx) {
54897
54936
  ctx.__valueOverlay
54898
54937
  );
54899
54938
  if (child2 === null) return childId;
54939
+ const elementMember = tuple === null ? entryMember : evalMemberById(ctx.vm, tuple.elementMemberIds[index]);
54940
+ const elementType = tupleType === null ? entryTypeInfo : tupleType.elements[index]?.typeInfo;
54941
+ if (elementMember === null && elementType === void 0)
54942
+ throw new NSGetterRuntimeError(
54943
+ `Class.Clone tuple element ${index} has no type descriptor.`
54944
+ );
54900
54945
  return cloneRow2(
54901
54946
  child2,
54902
- entryMember,
54947
+ elementMember,
54903
54948
  child2.containerId === sourceRow.id ? id2 : void 0,
54904
- entryTypeInfo
54949
+ elementType
54905
54950
  ).id;
54906
54951
  });
54907
54952
  ctx.onUnattributableValueRead?.(containerEntriesRead(sourceRow.id));
@@ -57419,7 +57464,16 @@ var init_constructor_argument_ownership = __esm({
57419
57464
  ownershipFacts() {
57420
57465
  if (this.ownership !== void 0) return this.ownership;
57421
57466
  const targetValueIds = new Set(this.valuesById.keys());
57422
- const owners = resolveOwnerMembersForValues(this.document, targetValueIds);
57467
+ const owners = resolveOwnerMembersForValues(
57468
+ this.document,
57469
+ targetValueIds,
57470
+ [...this.contextualRootMembersByValueId ?? []].map(
57471
+ ([valueId, member]) => ({
57472
+ valueId,
57473
+ member: resolveMember(member, this.document.members)
57474
+ })
57475
+ )
57476
+ );
57423
57477
  this.ownership = {
57424
57478
  owners,
57425
57479
  independentlyOwnedValueIds: new Set(owners.keys())
@@ -57742,6 +57796,7 @@ function evaluateInitializerMaterialization(args) {
57742
57796
  const createdValues = [];
57743
57797
  const storageKeyDeclarations = /* @__PURE__ */ new Map();
57744
57798
  const evaluated = args.evaluateInitializer({
57799
+ constructionEntryIds: args.constructionEntryIds,
57745
57800
  randomSource: args.randomSource,
57746
57801
  genericEnv: args.genericEnv,
57747
57802
  init: args.init,
@@ -57821,7 +57876,9 @@ function finalizeMaterializedRoot(args) {
57821
57876
  });
57822
57877
  }
57823
57878
  function materializeInitializerValue(args) {
57879
+ const constructionEntryIds = args.captureConstructionEntries ? /* @__PURE__ */ new Map() : void 0;
57824
57880
  const { evaluated, createdValues, storageKeyDeclarations } = evaluateInitializerMaterialization({
57881
+ constructionEntryIds,
57825
57882
  randomSource: args.randomSource,
57826
57883
  evaluateInitializer: args.evaluateInitializer,
57827
57884
  init: args.row.init,
@@ -57873,6 +57930,7 @@ function materializeInitializerValue(args) {
57873
57930
  return {
57874
57931
  root,
57875
57932
  createdValues,
57933
+ constructionEntryIds,
57876
57934
  snapshot: evaluated.snapshot,
57877
57935
  pinnedRootSchemaKeys: evaluated.pinnedRootSchemaKeys ?? /* @__PURE__ */ new Set(),
57878
57936
  pinnedSchemaKeysByValueId: evaluated.pinnedSchemaKeysByValueId ?? /* @__PURE__ */ new Map()
@@ -58590,7 +58648,7 @@ function buildVirtualInstanceMaterializedIndex(args) {
58590
58648
  return {
58591
58649
  rows,
58592
58650
  rowsById,
58593
- graph: new MaterializedValueGraphContext(
58651
+ graph: args.materializedGraph ?? new MaterializedValueGraphContext(
58594
58652
  { ...args.document, values: rows },
58595
58653
  rowsById
58596
58654
  ),
@@ -59073,7 +59131,9 @@ function resolveVirtualInstanceGraph(args) {
59073
59131
  if (parent !== void 0 && isMemberEntryCollectionBase(parent.member) && listKindOf(parent.member) === 1 /* Unordered */)
59074
59132
  effective.containerId = parentId;
59075
59133
  }
59076
- if (isClassSlotMember(indexed.member) && effective.value !== null) {
59134
+ if (args.opaquePaths?.has(pathKey)) {
59135
+ effective.value = materialized?.value ?? indexed.expandedRow.value;
59136
+ } else if (isClassSlotMember(indexed.member) && effective.value !== null) {
59077
59137
  const storedRecord = stringRecord(materialized?.value);
59078
59138
  const classId = rowClassId(indexed.member, effective);
59079
59139
  const constructedChildren = materialized === null ? /* @__PURE__ */ new Map() : settledAggregateChildren(materialized, classId, pathKey);
@@ -60663,6 +60723,16 @@ function keptRowReason(facts) {
60663
60723
  if (!facts.defaultEqual) return "provenanceOnly";
60664
60724
  return "pinnedOrReference";
60665
60725
  }
60726
+ function indexAuthoredConstructionIdentities(locations) {
60727
+ const byRoot = /* @__PURE__ */ new Map();
60728
+ for (const [id2, location3] of locations) {
60729
+ if (!location3.preserveIdentity) continue;
60730
+ const entries = byRoot.get(location3.rootId) ?? [];
60731
+ entries.push({ id: id2, path: location3.path });
60732
+ byRoot.set(location3.rootId, entries);
60733
+ }
60734
+ return byRoot;
60735
+ }
60666
60736
  function sparsifyConstructedInstance(args) {
60667
60737
  const materializedRows = [
60668
60738
  args.constructed.root,
@@ -60677,18 +60747,107 @@ function sparsifyConstructedInstance(args) {
60677
60747
  new Map(materializedRows.map((row) => [row.id, row])),
60678
60748
  /* @__PURE__ */ new Map([[args.constructed.root.id, args.rootMember]])
60679
60749
  );
60750
+ const anchors = /* @__PURE__ */ new Map();
60751
+ const authoredIds = /* @__PURE__ */ new Set();
60752
+ for (const identity3 of args.authoredIdentities ?? []) {
60753
+ let row = args.constructed.root;
60754
+ for (const segment of identity3.path) {
60755
+ const payload = row.value;
60756
+ let childId;
60757
+ if (Array.isArray(payload) && typeof segment === "number")
60758
+ childId = args.constructionEntryIds?.get(row.id)?.[segment] ?? payload[segment];
60759
+ else if (isObjectRecord(payload)) childId = payload[String(segment)];
60760
+ if (typeof childId !== "string")
60761
+ throw new Error(
60762
+ `Named construction ${identity3.id} has no value at ${JSON.stringify(identity3.path)}.`
60763
+ );
60764
+ const child2 = materializedGraph.valuesById.get(childId);
60765
+ if (child2 === void 0)
60766
+ throw new Error(
60767
+ `Named construction ${identity3.id} points to missing child ${childId}.`
60768
+ );
60769
+ row = child2;
60770
+ }
60771
+ if (anchors.has(row.id))
60772
+ throw new Error(`Constructed row ${row.id} has multiple named owners.`);
60773
+ if (authoredIds.has(identity3.id))
60774
+ throw new Error(
60775
+ `Named construction identity ${identity3.id} has multiple owning placements.`
60776
+ );
60777
+ if (identity3.id !== row.id && materializedGraph.valuesById.has(identity3.id))
60778
+ throw new Error(
60779
+ `Named construction identity ${identity3.id} collides with another constructed row.`
60780
+ );
60781
+ anchors.set(row.id, identity3.id);
60782
+ authoredIds.add(identity3.id);
60783
+ }
60784
+ const rootId = args.constructed.root.id;
60785
+ const boundaries = /* @__PURE__ */ new Map();
60786
+ const namedPaths = namedConstructionPaths(
60787
+ materializedGraph,
60788
+ new Map([[rootId, rootId], ...anchors]),
60789
+ args.constructionEntryIds,
60790
+ boundaries
60791
+ );
60792
+ const materializedIndex = buildVirtualInstanceMaterializedIndex({
60793
+ document: args.document,
60794
+ materializedRows,
60795
+ materializedGraph
60796
+ });
60680
60797
  const graph = resolveVirtualInstanceGraph({
60681
60798
  document: args.document,
60682
60799
  instanceRoot: args.constructed.root,
60683
60800
  rootMember: args.rootMember,
60684
60801
  expandedRoot: args.baseline.root,
60685
60802
  expandedRows: [args.baseline.root, ...args.baseline.createdChildren],
60686
- materializedRows,
60687
- materializedGraph
60688
- });
60689
- const protectedValueIds = /* @__PURE__ */ new Set();
60803
+ materializedIndex,
60804
+ materializedGraph,
60805
+ opaquePaths: boundaries.get(rootId)
60806
+ });
60807
+ const namedClaims = /* @__PURE__ */ new Map();
60808
+ const namedIds2 = /* @__PURE__ */ new Map();
60809
+ const scopedId = (rowId) => {
60810
+ const anchor = anchors.get(rowId);
60811
+ if (anchor !== void 0) return anchor;
60812
+ const cached = namedIds2.get(rowId);
60813
+ if (cached !== void 0) return cached;
60814
+ const scope = namedPaths.get(rowId);
60815
+ if (scope === void 0 || scope.id === rootId) return void 0;
60816
+ const relativePath = scope.path;
60817
+ const claims = namedClaims.get(scope.id) ?? /* @__PURE__ */ new Map();
60818
+ namedClaims.set(scope.id, claims);
60819
+ const claimed = claimVirtualIdentity({
60820
+ claimedVirtualIds: claims,
60821
+ instanceRootId: scope.id,
60822
+ rawSourceIdentity: `materialized:${relativePath}`,
60823
+ pathKey: relativePath
60824
+ });
60825
+ const id2 = args.virtualValueIdForSource?.(scope.id, claimed.sourceIdentity) ?? claimed.virtualId;
60826
+ namedIds2.set(rowId, id2);
60827
+ return id2;
60828
+ };
60829
+ const namedRootIds = new Set(anchors.keys());
60830
+ const protectedValueIds = new Set(namedRootIds);
60690
60831
  if (args.snapshot)
60691
60832
  for (const row of materializedRows) protectedValueIds.add(row.id);
60833
+ const pinNamedTarget = (id2) => {
60834
+ const scope = namedPaths.get(id2);
60835
+ if (scope !== void 0 && scope.id !== rootId) protectedValueIds.add(id2);
60836
+ };
60837
+ if (anchors.size > 0) {
60838
+ for (const row of materializedRows) {
60839
+ const owner = materializedGraph.ownerForValue(row.id);
60840
+ if (owner?.kind === 9 /* Lookup */)
60841
+ for (const id2 of materializedGraph.referencedValueIds(row))
60842
+ pinNamedTarget(id2);
60843
+ if (owner?.kind === 25 /* NSDelegate */ && isMemberDelegateTarget(row.value)) {
60844
+ if (typeof row.value.valueId === "string")
60845
+ pinNamedTarget(row.value.valueId);
60846
+ }
60847
+ for (const id2 of materializedGraph.referenceArgumentIds(row))
60848
+ pinNamedTarget(id2);
60849
+ }
60850
+ }
60692
60851
  const localizedTextIds = args.localizedTextIds ?? new Set(args.document.localizedTexts?.map((text) => text.id));
60693
60852
  for (const location3 of graph.locationsByPath.values()) {
60694
60853
  const row = location3.materializedRow;
@@ -60730,11 +60889,13 @@ function sparsifyConstructedInstance(args) {
60730
60889
  for (const childId of materializedGraph.referencedValueIds(row))
60731
60890
  pinArgumentFields(childId);
60732
60891
  };
60733
- for (const edge of materializedGraph.constructorEdges(
60734
- args.constructed.root
60735
- )) {
60736
- protectArgument(edge.targetValueId, edge.typeInfo);
60737
- pinArgumentFields(edge.targetValueId);
60892
+ for (const id2 of [args.constructed.root.id, ...anchors.keys()]) {
60893
+ for (const edge of materializedGraph.constructorEdges(
60894
+ materializedGraph.valuesById.get(id2)
60895
+ )) {
60896
+ protectArgument(edge.targetValueId, edge.typeInfo);
60897
+ pinArgumentFields(edge.targetValueId);
60898
+ }
60738
60899
  }
60739
60900
  for (const schemaKey of args.pinnedRootSchemaKeys ?? []) {
60740
60901
  const location3 = graph.locationsByPath.get(
@@ -60744,8 +60905,30 @@ function sparsifyConstructedInstance(args) {
60744
60905
  protectedValueIds.add(location3.materializedRow.id);
60745
60906
  }
60746
60907
  }
60747
- const rootId = args.constructed.root.id;
60748
- const locationValueId = (location3) => args.virtualValueIdForSource?.(rootId, location3.sourceIdentity) ?? location3.virtualRow.id;
60908
+ const pinnedNamedCalls = /* @__PURE__ */ new Set();
60909
+ const pinNamedCallFields = (id2) => {
60910
+ if (pinnedNamedCalls.has(id2)) return;
60911
+ pinnedNamedCalls.add(id2);
60912
+ const row = materializedGraph.valuesById.get(id2);
60913
+ if (row === void 0) return;
60914
+ const member = materializedGraph.ownerForValue(id2);
60915
+ if (member !== void 0 && (isMemberEntryCollectionBase(member) || isMemberDictionaryBase(member) || isMemberTupleBase(member))) {
60916
+ for (const child2 of materializedGraph.referencedValueIds(row))
60917
+ pinNamedCallFields(child2);
60918
+ for (const child2 of materializedGraph.childrenByContainerId.get(id2) ?? [])
60919
+ pinNamedCallFields(child2.id);
60920
+ return;
60921
+ }
60922
+ if (!isObjectRecord(row.value)) return;
60923
+ for (const key of args.pinnedSchemaKeysByValueId?.get(id2) ?? []) {
60924
+ const child2 = row.value[key];
60925
+ if (typeof child2 !== "string") continue;
60926
+ protectedValueIds.add(child2);
60927
+ pinNamedCallFields(child2);
60928
+ }
60929
+ };
60930
+ for (const id2 of anchors.keys()) pinNamedCallFields(id2);
60931
+ const locationValueId = (location3) => (location3.materializedRow === null ? void 0 : scopedId(location3.materializedRow.id)) ?? args.virtualValueIdForSource?.(rootId, location3.sourceIdentity) ?? location3.virtualRow.id;
60749
60932
  if (args.bindingTargets !== void 0)
60750
60933
  pinReferencedSlots(
60751
60934
  graph,
@@ -60758,7 +60941,8 @@ function sparsifyConstructedInstance(args) {
60758
60941
  try {
60759
60942
  plan = planCollapseVirtualInstance({
60760
60943
  graph,
60761
- pinnedValueIds: protectedValueIds
60944
+ pinnedValueIds: protectedValueIds,
60945
+ nestedRootValueIds: namedRootIds
60762
60946
  });
60763
60947
  } catch (error) {
60764
60948
  if (!(error instanceof OpenGenericComparisonError)) throw error;
@@ -60768,6 +60952,59 @@ function sparsifyConstructedInstance(args) {
60768
60952
  const updatedValueById = new Map(
60769
60953
  plan.updates.map((update) => [update.valueId, update.value])
60770
60954
  );
60955
+ if (!args.snapshot) {
60956
+ for (const [rowId, authoredId] of anchors) {
60957
+ const root2 = materializedGraph.valuesById.get(rowId);
60958
+ const placement = materializedGraph.ownerForValue(rowId);
60959
+ if (placement === void 0)
60960
+ throw new Error(
60961
+ `Named construction ${authoredId} has no typed owning placement.`
60962
+ );
60963
+ const member = storedClassResolutionMember(
60964
+ placement,
60965
+ root2,
60966
+ args.document.members
60967
+ );
60968
+ if (member === null) continue;
60969
+ if (args.expandNamedRoot === void 0)
60970
+ throw new Error(
60971
+ "Named Class preparation requires its own construction expansion."
60972
+ );
60973
+ const baseline = args.expandNamedRoot(root2, member, materializedRows);
60974
+ const ownGraph = resolveVirtualInstanceGraph({
60975
+ document: args.document,
60976
+ instanceRoot: root2,
60977
+ rootMember: member,
60978
+ expandedRoot: baseline.root,
60979
+ expandedRows: baseline.rows,
60980
+ pinnedRootSchemaKeys: args.pinnedSchemaKeysByValueId?.get(rowId),
60981
+ materializedIndex,
60982
+ materializedGraph,
60983
+ opaquePaths: boundaries.get(authoredId)
60984
+ });
60985
+ for (const location3 of ownGraph.locationsByPath.values()) {
60986
+ const row = location3.materializedRow;
60987
+ if (row !== null && isMemberStringBase(location3.member) && isLocalizedStringMember(location3.member) && typeof row.value === "string" && row.value !== "" && !localizedTextIds.has(row.value))
60988
+ protectedValueIds.add(row.id);
60989
+ }
60990
+ if (args.bindingTargets !== void 0)
60991
+ pinReferencedSlots(
60992
+ ownGraph,
60993
+ authoredId,
60994
+ args.bindingTargets,
60995
+ locationValueId,
60996
+ protectedValueIds
60997
+ );
60998
+ const ownPlan = planCollapseVirtualInstance({
60999
+ graph: ownGraph,
61000
+ pinnedValueIds: protectedValueIds,
61001
+ nestedRootValueIds: namedRootIds
61002
+ });
61003
+ for (const id2 of ownPlan.deletes) deletedIds.add(id2);
61004
+ for (const update of ownPlan.updates)
61005
+ updatedValueById.set(update.valueId, update.value);
61006
+ }
61007
+ }
60771
61008
  restoreRowsRetainedRowsName(
60772
61009
  materializedGraph,
60773
61010
  materializedRows,
@@ -60789,6 +61026,10 @@ function sparsifyConstructedInstance(args) {
60789
61026
  );
60790
61027
  }
60791
61028
  nextIdById.set(args.constructed.root.id, args.constructed.root.id);
61029
+ for (const row of retainedRows) {
61030
+ const id2 = scopedId(row.id);
61031
+ if (id2 !== void 0) nextIdById.set(row.id, id2);
61032
+ }
60792
61033
  const unmappedRows = retainedRows.filter((row) => !nextIdById.has(row.id));
60793
61034
  const fallbackRows = (unmappedRows.length === 0 ? [] : (() => {
60794
61035
  const fallbackPaths = materializedFallbackPaths(
@@ -60804,6 +61045,11 @@ function sparsifyConstructedInstance(args) {
60804
61045
  (left, right) => left.path.localeCompare(right.path) || left.row.id.localeCompare(right.row.id)
60805
61046
  );
60806
61047
  for (const { row, path } of fallbackRows) {
61048
+ const namedId = scopedId(row.id);
61049
+ if (namedId !== void 0) {
61050
+ nextIdById.set(row.id, namedId);
61051
+ continue;
61052
+ }
60807
61053
  const rawSourceIdentity = typeof row.sourceValueId === "string" && row.sourceValueId.length > 0 ? row.sourceValueId : `materialized:${path}`;
60808
61054
  const { sourceIdentity: sourceIdentity3, virtualId } = claimVirtualIdentity({
60809
61055
  claimedVirtualIds,
@@ -60824,6 +61070,8 @@ function sparsifyConstructedInstance(args) {
60824
61070
  if (retainedId !== void 0) return retainedId;
60825
61071
  const receiver = graph.locationsById.get(id2);
60826
61072
  if (receiver === void 0) return id2;
61073
+ const named = scopedId(id2);
61074
+ if (named !== void 0) return named;
60827
61075
  return args.virtualValueIdForSource?.(
60828
61076
  args.constructed.root.id,
60829
61077
  receiver.sourceIdentity
@@ -60891,6 +61139,54 @@ function restoreRowsRetainedRowsName(materializedGraph, rows, updatedValueById,
60891
61139
  restore(valueId);
60892
61140
  }
60893
61141
  }
61142
+ function namedConstructionPaths(graph, anchors, entries, boundaries) {
61143
+ const paths = /* @__PURE__ */ new Map();
61144
+ const queue = [];
61145
+ for (const [rowId, id2] of anchors) {
61146
+ paths.set(rowId, { id: id2, path: ROOT_PATH });
61147
+ queue.push(rowId);
61148
+ }
61149
+ if (queue.length === 0) return paths;
61150
+ const add = (childId, scope, segment) => {
61151
+ if (typeof childId !== "string" || !graph.valuesById.has(childId)) return;
61152
+ const path = appendVirtualValuePath(scope.path, segment);
61153
+ if (anchors.has(childId)) {
61154
+ const paths2 = boundaries.get(scope.id) ?? /* @__PURE__ */ new Set();
61155
+ paths2.add(path);
61156
+ boundaries.set(scope.id, paths2);
61157
+ return;
61158
+ }
61159
+ if (paths.has(childId)) return;
61160
+ paths.set(childId, { id: scope.id, path });
61161
+ queue.push(childId);
61162
+ };
61163
+ for (let index = 0; index < queue.length; index++) {
61164
+ const rowId = queue[index];
61165
+ const row = graph.valuesById.get(rowId);
61166
+ const scope = paths.get(rowId);
61167
+ if (row === void 0) continue;
61168
+ const member = graph.ownerForValue(rowId);
61169
+ if (Array.isArray(row.value) && member !== void 0 && (isMemberEntryCollectionBase(member) || isMemberTupleBase(member))) {
61170
+ const children3 = entries?.get(rowId) ?? (row.value.length > 0 ? row.value : graph.childrenByContainerId.get(rowId)?.map((child2) => child2.id) ?? []);
61171
+ children3.forEach((id2, index2) => add(id2, scope, { kind: "list", index: index2 }));
61172
+ } else if (isObjectRecord(row.value) && (typeof row.classId === "string" || member !== void 0 && (isClassSlotMember(member) || isMemberDictionaryBase(member)))) {
61173
+ for (const [schemaKey, id2] of Object.entries(row.value))
61174
+ add(
61175
+ id2,
61176
+ scope,
61177
+ member !== void 0 && isMemberDictionaryBase(member) ? { kind: "dictionary", key: schemaKey } : { kind: "class", schemaKey }
61178
+ );
61179
+ }
61180
+ for (const edge of graph.edgesByOwnerValueId.get(rowId) ?? []) {
61181
+ if (graph.independentlyOwnedValueIds.has(edge.targetValueId)) continue;
61182
+ add(edge.targetValueId, scope, {
61183
+ kind: "class",
61184
+ schemaKey: `@constructor:${edge.parameterId}`
61185
+ });
61186
+ }
61187
+ }
61188
+ return paths;
61189
+ }
60894
61190
  function materializedFallbackPaths(rows, graph, materializedGraph) {
60895
61191
  const rowsById = new Map(rows.map((row) => [row.id, row]));
60896
61192
  const unorderedEntriesByContainerId = buildUnorderedListMembershipIndex(rows);
@@ -61074,6 +61370,7 @@ function indexExpansion(args) {
61074
61370
  discoveredNodes?.push(node);
61075
61371
  nodesByPath.set(pathKey, node);
61076
61372
  appendChildPath(parentPath, pathKey);
61373
+ if (args.opaquePaths?.has(pathKey)) return;
61077
61374
  if (isClassTypedMember(member)) {
61078
61375
  const record7 = stringRecord(row.value);
61079
61376
  const classId = row.classId ?? member.classId;
@@ -64036,6 +64333,7 @@ function evaluateMemberInitializer(args) {
64036
64333
  );
64037
64334
  const compiled = compileMemberInitializer(args, databaseVM);
64038
64335
  const ctx = {
64336
+ __constructionEntryIds: args.constructionEntryIds,
64039
64337
  randomSource: args.randomSource,
64040
64338
  randomIdentity,
64041
64339
  ...args.sessionValues === void 0 ? {} : { __runtimeSessionValues: args.sessionValues },
@@ -75264,9 +75562,10 @@ var init_strict_resolver = __esm({
75264
75562
  if (outerEntry === null) return null;
75265
75563
  const existing = context.byOuterEntry.get(outerEntry);
75266
75564
  if (existing !== void 0) return existing;
75565
+ const capturedType = context.outerScope.lookupNarrowedType(name, outerEntry) ?? outerEntry.type;
75267
75566
  const parameter4 = variable(
75268
75567
  `__capture_${context.serial}_${context.captures.length}__`,
75269
- outerEntry.type,
75568
+ capturedType,
75270
75569
  void 0,
75271
75570
  this.project
75272
75571
  );
@@ -75274,7 +75573,7 @@ var init_strict_resolver = __esm({
75274
75573
  ...scopeVariable(
75275
75574
  name,
75276
75575
  parameter4,
75277
- outerEntry.type,
75576
+ capturedType,
75278
75577
  "local" /* Local */,
75279
75578
  "local" /* Local */,
75280
75579
  outerEntry.writeRoot,
@@ -83014,7 +83313,9 @@ var init_strict_resolver = __esm({
83014
83313
  return literal(symbol.type, null);
83015
83314
  }
83016
83315
  hasValueReceiver(name, scope) {
83017
- return scope.lookup(name) !== null || this.implicitMember(name) !== null;
83316
+ return scope.lookup(name) !== null || this.delegateCaptureContexts.some(
83317
+ (context) => context.outerScope.lookup(name) !== null
83318
+ ) || this.implicitMember(name) !== null;
83018
83319
  }
83019
83320
  implicitMember(name) {
83020
83321
  if (this.context.implicitMemberAccess !== true) return null;
@@ -99500,7 +99801,8 @@ function validateExpression(expression, expected, scope, environment, uri, range
99500
99801
  const sourceOnly = expected !== void 0 && (isNeoVariantTypeName(expected.name) || expected.name === "NeoAction" || expected.name === "ImageRef");
99501
99802
  let receiver = expression;
99502
99803
  while (receiver.kind === "member") receiver = receiver.receiver;
99503
- const computed = (environment.checkComputedInitializers || expected?.name === "NeoDelegate") && !sourceOnly && (expression.kind === "member" && (receiver.kind !== "ident" || receiver.typeQualifier !== void 0) || [
99804
+ const executableMember = expression.kind === "member" && (receiver.kind !== "ident" || receiver.typeQualifier !== void 0);
99805
+ const computed = (environment.checkComputedInitializers || expected?.name === "NeoDelegate") && !sourceOnly && (executableMember || expression.kind === "member" && expected?.name !== "NeoDelegate" || [
99504
99806
  "binary",
99505
99807
  "unary",
99506
99808
  "force",
@@ -99549,14 +99851,13 @@ function validateExpression(expression, expected, scope, environment, uri, range
99549
99851
  void 0,
99550
99852
  { allowPendingRegistryEntries: true }
99551
99853
  );
99552
- scopedResolver.validateInitializerExpression(
99553
- expression,
99554
- expected === void 0 ? void 0 : resolveNeoScriptType(
99555
- semanticAst(expected, expression.pos),
99556
- context,
99557
- environment.projectIndex
99558
- )
99854
+ const storedMember = storedValue && expression.kind === "member" && !executableMember;
99855
+ const expectedType = expected === void 0 || storedMember ? void 0 : resolveNeoScriptType(
99856
+ semanticAst(expected, expression.pos),
99857
+ context,
99858
+ environment.projectIndex
99559
99859
  );
99860
+ scopedResolver.validateInitializerExpression(expression, expectedType);
99560
99861
  } catch (error) {
99561
99862
  if (!(error instanceof CompileError)) throw error;
99562
99863
  pushDiagnostic(
@@ -104061,6 +104362,7 @@ function validateProjectSourceTypes(documents) {
104061
104362
  validateSetSpelling(documents, environment.typeKinds, diagnostics);
104062
104363
  return {
104063
104364
  diagnostics,
104365
+ memberRelations: environment.memberRelations,
104064
104366
  overloadImplementations: overloadImplementations(environment)
104065
104367
  };
104066
104368
  }
@@ -104137,6 +104439,7 @@ function createEnvironment2(documents) {
104137
104439
  }
104138
104440
  return {
104139
104441
  declarations,
104442
+ memberRelations: [],
104140
104443
  classes,
104141
104444
  interfaces,
104142
104445
  memberOwners,
@@ -105317,11 +105620,12 @@ function validateMembers(environment, diagnostics) {
105317
105620
  }
105318
105621
  function validateInterfaceMemberConflicts(ref, environment, diagnostics) {
105319
105622
  const inherited = /* @__PURE__ */ new Map();
105623
+ const substitution = identitySubstitution(ref);
105320
105624
  for (const base of ref.declaration.baseTypes) {
105321
105625
  const target = environment.interfaces.get(base.name);
105322
105626
  if (!target) continue;
105323
105627
  for (const candidate of interfaceMembers(
105324
- { owner: target, substitution: /* @__PURE__ */ new Map() },
105628
+ interfaceView(base, target, substitution),
105325
105629
  environment
105326
105630
  )) {
105327
105631
  const key = candidate.member.name.toLowerCase();
@@ -105338,6 +105642,10 @@ function validateInterfaceMemberConflicts(ref, environment, diagnostics) {
105338
105642
  "interface-inherited",
105339
105643
  environment
105340
105644
  ) === null) {
105645
+ environment.memberRelations.push([
105646
+ interfaceMemberLocation(prior),
105647
+ interfaceMemberLocation(candidate)
105648
+ ]);
105341
105649
  continue;
105342
105650
  }
105343
105651
  diagnose(
@@ -105359,7 +105667,6 @@ function validateInterfaceMemberConflicts(ref, environment, diagnostics) {
105359
105667
  );
105360
105668
  }
105361
105669
  }
105362
- const substitution = identitySubstitution(ref);
105363
105670
  for (const member of ref.declaration.members) {
105364
105671
  const prior = inherited.get(member.name.toLowerCase());
105365
105672
  if (!prior) continue;
@@ -105368,12 +105675,18 @@ function validateInterfaceMemberConflicts(ref, environment, diagnostics) {
105368
105675
  }
105369
105676
  const mismatch = memberCompatibility(
105370
105677
  member,
105371
- /* @__PURE__ */ new Map(),
105678
+ substitution,
105372
105679
  prior,
105373
105680
  "interface-inherited",
105374
105681
  environment
105375
105682
  );
105376
- if (!mismatch) continue;
105683
+ if (!mismatch) {
105684
+ environment.memberRelations.push([
105685
+ interfaceMemberLocation(prior),
105686
+ { uri: ref.uri, range: member.nameRange }
105687
+ ]);
105688
+ continue;
105689
+ }
105377
105690
  diagnose(
105378
105691
  diagnostics,
105379
105692
  ref.uri,
@@ -105405,7 +105718,13 @@ function validateAbstractInterfaceMembers(ref, environment, diagnostics) {
105405
105718
  "interface-contract",
105406
105719
  environment
105407
105720
  );
105408
- if (!mismatch) continue;
105721
+ if (!mismatch) {
105722
+ environment.memberRelations.push([
105723
+ interfaceMemberLocation(contract),
105724
+ memberLocation(implementation)
105725
+ ]);
105726
+ continue;
105727
+ }
105409
105728
  diagnose(
105410
105729
  diagnostics,
105411
105730
  ref.uri,
@@ -106447,6 +106766,10 @@ function validateConcreteClass(ref, environment, diagnostics) {
106447
106766
  environment
106448
106767
  ) : null;
106449
106768
  if (implementation && !implementation.member.modifiers.includes("abstract") && !implementation.member.modifiers.includes("static") && mismatch === null) {
106769
+ environment.memberRelations.push([
106770
+ interfaceMemberLocation(required2),
106771
+ memberLocation(implementation)
106772
+ ]);
106450
106773
  continue;
106451
106774
  }
106452
106775
  diagnose(
@@ -107561,6 +107884,7 @@ function analyzeNeoProjectSources(inputs, parsedDocuments = /* @__PURE__ */ new
107561
107884
  compiledBodies: bodyCompilation.bodies,
107562
107885
  bodyContexts: bodyCompilation.contexts,
107563
107886
  overloadImplementations: typeValidation.overloadImplementations,
107887
+ memberRelations: typeValidation.memberRelations,
107564
107888
  diagnostics
107565
107889
  };
107566
107890
  }
@@ -118590,6 +118914,43 @@ function storedValueAtPathV4(rows, rootId, path) {
118590
118914
  }
118591
118915
  return id2;
118592
118916
  }
118917
+ function storedValueOwnsPathV4(records3, rows, ownerForValue) {
118918
+ const placements = buildStoredValuePlacementIndexV4(records3, rows);
118919
+ const parents = /* @__PURE__ */ new Map();
118920
+ for (const [id2, edge] of placements.placementByChildValueId)
118921
+ parents.set(id2, { id: edge.parentValueId, key: edge.schemaKey });
118922
+ for (const [id2, row] of rows) {
118923
+ if (typeof row.containerId === "string")
118924
+ parents.set(id2, { id: row.containerId, key: null });
118925
+ }
118926
+ for (const [id2, row] of rows) {
118927
+ if (!Array.isArray(row.value)) continue;
118928
+ const owner = ownerForValue(id2);
118929
+ if (owner === void 0) continue;
118930
+ if (!isMemberEntryCollectionBase(owner) && !isMemberTupleBase(owner))
118931
+ continue;
118932
+ row.value.forEach((child2, index) => {
118933
+ if (typeof child2 !== "string") return;
118934
+ const container = rows.get(child2)?.containerId;
118935
+ if (container !== void 0 && container !== id2) return;
118936
+ if (container === void 0 && parents.has(child2)) return;
118937
+ parents.set(child2, { id: id2, key: index });
118938
+ });
118939
+ }
118940
+ return (rootId, path, valueId) => {
118941
+ let id2 = valueId;
118942
+ for (let index = path.length - 1; index >= 0; index--) {
118943
+ const parent = parents.get(id2);
118944
+ if (parent === void 0) return false;
118945
+ const key = path[index];
118946
+ if (parent.key === null) {
118947
+ if (typeof key !== "number") return false;
118948
+ } else if (parent.key !== key) return false;
118949
+ id2 = parent.id;
118950
+ }
118951
+ return id2 === rootId;
118952
+ };
118953
+ }
118593
118954
  function buildStoredValuePlacementIndexV4(records3, logicalValues) {
118594
118955
  const live = [...records3].filter((record7) => record7.deleted !== true);
118595
118956
  const values = logicalValues ?? storedValueRowsByIdV4(live);
@@ -123532,6 +123893,14 @@ var init_project_migration_member_listeners = __esm({
123532
123893
  });
123533
123894
 
123534
123895
  // ../packages/neoscript-runtime/src/virtual-instance-values.ts
123896
+ function expandStoredClassValue2(args) {
123897
+ return expandStoredClassValue({
123898
+ ...args,
123899
+ evaluateInitializer: evaluateMemberInitializer,
123900
+ materializeInitializerValue,
123901
+ materializeMemberDefaultValue: materializeMemberDefaultValue2
123902
+ });
123903
+ }
123535
123904
  function expandStoredInstance2(args) {
123536
123905
  return expandStoredInstance({
123537
123906
  ...args,
@@ -123565,9 +123934,52 @@ function resolveStoredClassValue2(args) {
123565
123934
  materializeMemberDefaultValue: materializeMemberDefaultValue2
123566
123935
  });
123567
123936
  }
123937
+ function sparsifyConstructedInstance2(args) {
123938
+ let document;
123939
+ return sparsifyConstructedInstance({
123940
+ ...args,
123941
+ expandNamedRoot: (instanceRoot, rootMember, materializedRows) => {
123942
+ if (document === void 0) {
123943
+ if (!("project" in args.document))
123944
+ throw new Error(
123945
+ "Named Class preparation requires the project evaluation context."
123946
+ );
123947
+ const base = args.document;
123948
+ const baseRows = initializerEvaluatorLookups(base).evaluatorIndexes?.valueById ?? new Map(base.values.map((row) => [row.id, row]));
123949
+ const rows = new Map(materializedRows.map((row) => [row.id, row]));
123950
+ const valuesById = new OverlayReadonlyMap(baseRows, rows, /* @__PURE__ */ new Set());
123951
+ const values = lazyArray(() => valuesById.values());
123952
+ const changedContainerIds = new Set(rows.keys());
123953
+ for (const row of rows.values())
123954
+ if (row.containerId) changedContainerIds.add(row.containerId);
123955
+ document = {
123956
+ ...base,
123957
+ databaseVM: void 0,
123958
+ indexedView: void 0,
123959
+ evaluatorCache: void 0,
123960
+ worldQueryCache: void 0,
123961
+ values,
123962
+ valueById: (id2) => valuesById.get(id2) ?? null,
123963
+ evaluatorOverlay: {
123964
+ base,
123965
+ rows,
123966
+ hiddenIds: /* @__PURE__ */ new Set(),
123967
+ changedContainerIds,
123968
+ values,
123969
+ valuesById,
123970
+ containerMembership: "merge"
123971
+ }
123972
+ };
123973
+ }
123974
+ return expandStoredClassValue2({ document, instanceRoot, rootMember });
123975
+ }
123976
+ });
123977
+ }
123568
123978
  var init_virtual_instance_values = __esm({
123569
123979
  "../packages/neoscript-runtime/src/virtual-instance-values.ts"() {
123570
123980
  "use strict";
123981
+ init_overlay_readonly_map();
123982
+ init_lazy_array();
123571
123983
  init_initializer_materialization();
123572
123984
  init_evaluateInitializer();
123573
123985
  init_virtual_instance_graph();
@@ -148013,6 +148425,7 @@ function* prepareServerOwnedSchemaCommitPasses(args) {
148013
148425
  });
148014
148426
  materializePreparedInstanceInitializers({
148015
148427
  referenceOwners: args.initializerReferenceOwners,
148428
+ constructionIdentities: args.constructionIdentities,
148016
148429
  document: args.document,
148017
148430
  physicalValues: args.document.physicalValues,
148018
148431
  prepared,
@@ -148388,6 +148801,7 @@ function materializePreparedInstanceInitializers(args) {
148388
148801
  }
148389
148802
  const materialized = replay(
148390
148803
  (readTracking) => materializeInitializerValue2({
148804
+ captureConstructionEntries: args.constructionIdentities?.has(valueId),
148391
148805
  readTracking,
148392
148806
  // Every site that survives the declaration-default guard is source for
148393
148807
  // a persisted instance construction. The trusted replay mode both
@@ -148451,9 +148865,12 @@ function materializePreparedInstanceInitializers(args) {
148451
148865
  constructionBaselineReplay: true,
148452
148866
  storedConstructionReplay: true
148453
148867
  });
148454
- const sparse2 = sparsifyConstructedInstance({
148868
+ const authoredIdentities = args.constructionIdentities?.get(valueId);
148869
+ const sparse2 = sparsifyConstructedInstance2({
148870
+ authoredIdentities,
148871
+ constructionEntryIds: materialized.constructionEntryIds,
148455
148872
  localizedTextIds,
148456
- document: currentDocument,
148873
+ document: authoredIdentities?.length ? batch.comparisonDocument() : currentDocument,
148457
148874
  rootMember: member,
148458
148875
  constructed: {
148459
148876
  root: materialized.root,
@@ -149329,9 +149746,8 @@ function materializeVariantChildOverrideBindingMembers(args) {
149329
149746
  classId
149330
149747
  );
149331
149748
  args.serverMintedBindingMemberIds?.add(member.id);
149332
- if (isFrozenJsonData(args.document.members))
149333
- args.document.members = [...args.document.members, member];
149334
- else args.document.members.push(member);
149749
+ if (minted.size === 0) args.document.members = [...args.document.members];
149750
+ args.document.members.push(member);
149335
149751
  args.prepared.push({
149336
149752
  recordKind: "member",
149337
149753
  recordId: member.id,
@@ -149354,6 +149770,7 @@ function materializeStaticSeedBindingMembers(args) {
149354
149770
  if (ids.size !== bindings.length) {
149355
149771
  throw new Error("Schema commit contains duplicate generic binding seeds.");
149356
149772
  }
149773
+ if (bindings.length > 0) args.document.members = [...args.document.members];
149357
149774
  for (const binding of bindings) {
149358
149775
  const expectedBindingId = worldAnimationChildOverrideBindingMemberId(
149359
149776
  binding.classId
@@ -149378,9 +149795,7 @@ function materializeStaticSeedBindingMembers(args) {
149378
149795
  binding.classId
149379
149796
  );
149380
149797
  args.serverMintedBindingMemberIds?.add(member.id);
149381
- if (isFrozenJsonData(args.document.members))
149382
- args.document.members = [...args.document.members, member];
149383
- else args.document.members.push(member);
149798
+ args.document.members.push(member);
149384
149799
  args.prepared.push({
149385
149800
  recordKind: "member",
149386
149801
  recordId: member.id,
@@ -151663,7 +152078,6 @@ var init_project_version_schema_commit = __esm({
151663
152078
  "../src/database/project-version-schema-commit.ts"() {
151664
152079
  "use strict";
151665
152080
  init_members();
151666
- init_immutable_json2();
151667
152081
  init_commit_preparation_pass_cache();
151668
152082
  init_compiled_construction_types();
151669
152083
  init_member_kinds();
@@ -160209,6 +160623,7 @@ function preparationArgs(context) {
160209
160623
  return {
160210
160624
  document: context.document,
160211
160625
  initializerReferenceOwners: args.initializerReferenceOwners,
160626
+ constructionIdentities: args.constructionIdentities,
160212
160627
  contentHashHeads: context.contentHashHeads,
160213
160628
  changes: args.changes,
160214
160629
  authoredValueSeeds: args.authoredValueSeeds,
@@ -160783,8 +161198,14 @@ function verifyProjectSourceCommitAgainstStateV4(args) {
160783
161198
  ${blockingErrors.map((error) => error.message).join("\n")}` : `Trusted source lowering found conflict markers in ${status.conflictedFiles.join(", ")}.`
160784
161199
  );
160785
161200
  }
161201
+ const identitySeeds = new Map(status.authoredValueSeeds);
161202
+ identitySeeds.set("source-owned constructions", {
161203
+ values: [...status.pendingValueIdentitySites ?? []].flatMap(
161204
+ ([id2, site]) => site.materializedLocation?.preserveIdentity === true ? [{ id: id2, value: null }] : []
161205
+ )
161206
+ });
160786
161207
  auditAuthoredSeedRowIdentities(
160787
- status.authoredValueSeeds,
161208
+ identitySeeds,
160788
161209
  args.stateRecords,
160789
161210
  assignments,
160790
161211
  derivedSeedRowIds
@@ -160821,6 +161242,18 @@ ${blockingErrors.map((error) => error.message).join("\n")}` : `Trusted source lo
160821
161242
  ...rewrite(seed)
160822
161243
  })
160823
161244
  );
161245
+ const constructionIdentities = indexAuthoredConstructionIdentities(
161246
+ [...status.pendingValueIdentitySites ?? []].flatMap(([id2, site]) => {
161247
+ const location3 = site.materializedLocation;
161248
+ if (location3?.preserveIdentity !== true) return [];
161249
+ return [
161250
+ [
161251
+ rewrite(id2),
161252
+ { ...location3, rootId: rewrite(location3.rootId) }
161253
+ ]
161254
+ ];
161255
+ })
161256
+ );
160824
161257
  for (const pendingId2 of assignments.keys()) {
160825
161258
  if (!usedAssignments.has(pendingId2)) {
160826
161259
  const message = `Pending id assignment ${pendingId2} is not present in the verified source manifest.`;
@@ -160841,6 +161274,7 @@ ${blockingErrors.map((error) => error.message).join("\n")}` : `Trusted source lo
160841
161274
  });
160842
161275
  compareChanges(expectedChanges, verifiableChanges);
160843
161276
  compareSeeds(expectedSeeds, args.authoredValueSeeds);
161277
+ return constructionIdentities;
160844
161278
  }
160845
161279
  function isDerivedOnlyRefresh(change, stateRecords) {
160846
161280
  if (change.operation !== "update") return false;
@@ -161381,6 +161815,7 @@ var ProjectSourceCommitVerificationError, ABSENT_DIFFERENCE_VALUE;
161381
161815
  var init_trusted_commit_verification = __esm({
161382
161816
  "src/project-source/trusted-commit-verification.ts"() {
161383
161817
  "use strict";
161818
+ init_virtual_instance_values();
161384
161819
  init_animation_child_binding_id();
161385
161820
  init_world_system_classes();
161386
161821
  init_tuple_element_member_id();
@@ -161469,6 +161904,7 @@ function sourceCommitPreparation(args) {
161469
161904
  }),
161470
161905
  authoredValueSeeds: args.authoredValueSeeds,
161471
161906
  initializerReferenceOwners: args.initializerReferenceOwners,
161907
+ constructionIdentities: args.constructionIdentities,
161472
161908
  forceRecompile: args.forceRecompile,
161473
161909
  scriptSources: args.scriptSources,
161474
161910
  serverTimestamp: args.serverTimestamp
@@ -161752,6 +162188,7 @@ function replayStoredConstructionV4(args) {
161752
162188
  // explicit typed descriptor for evaluation that compiled the replay.
161753
162189
  member: compileMember,
161754
162190
  row: evaluationRow,
162191
+ captureConstructionEntries: args.captureConstructionEntries,
161755
162192
  storedConstructionReplay: true,
161756
162193
  ...args.omitConstructionFields === true ? { constructionBaselineReplay: true } : {},
161757
162194
  ...args.initializerArgumentValues === void 0 ? {} : { argumentValues: args.initializerArgumentValues }
@@ -166843,9 +167280,18 @@ function lowerSeedRow(context, member, sourceExpression, source, valueId, path,
166843
167280
  valueId,
166844
167281
  {
166845
167282
  sites: context.pendingValueIdentitySites,
167283
+ storedParent: (id2) => {
167284
+ const edge = context.readStoredValuePlacements().placementByChildValueId.get(id2);
167285
+ return edge === void 0 ? void 0 : { rootId: edge.parentValueId, path: [edge.schemaKey] };
167286
+ },
167287
+ validateAuthoredId: (id2) => {
167288
+ if (!isPendingId(id2) && context.state[`value:${id2}`] === void 0 && !isUuidV4Id(id2))
167289
+ throw new Error(
167290
+ `New local value @id(${JSON.stringify(id2)}) requires a UUID v4.`
167291
+ );
167292
+ },
166846
167293
  localListEntries: (local2) => localNestedListEntries(context, local2)
166847
- },
166848
- context.storedValueAtPath
167294
+ }
166849
167295
  );
166850
167296
  const settled = settleInitializerReferenceSpellings(
166851
167297
  executable.code,
@@ -167587,7 +168033,7 @@ function lowerSeedChild(context, member, expression, source, path, rows, localiz
167587
168033
  )
167588
168034
  });
167589
168035
  }
167590
- const valueId = annotatedId2 ?? context.structuralStoredIds.get(path) ?? pendingNestedValueId(source, path);
168036
+ const valueId = annotatedId2 ?? context.structuralStoredIds.get(path) ?? local.pendingIdentity ?? pendingNestedValueId(source, path);
167591
168037
  if (!context.structuralConstruction && annotatedId2 !== null && context.state[`value:${annotatedId2}`] !== void 0) {
167592
168038
  const failure = storedClassMoveFailure(
167593
168039
  context,
@@ -167637,7 +168083,7 @@ function lowerSeedChild(context, member, expression, source, path, rows, localiz
167637
168083
  expression,
167638
168084
  source,
167639
168085
  valueId,
167640
- unorderedRowSubtreePath(valueId, path, containerId),
168086
+ local.pendingIdentity === void 0 ? unorderedRowSubtreePath(valueId, path, containerId) : valueId,
167641
168087
  rows,
167642
168088
  localizedTexts,
167643
168089
  containerId,
@@ -167816,9 +168262,18 @@ function lowerAuthoredValueRow(context, member, sourceExpression, expectedValueI
167816
168262
  expectedValueId,
167817
168263
  {
167818
168264
  sites: context.pendingValueIdentitySites,
168265
+ storedParent: (id3) => {
168266
+ const edge = context.readStoredValuePlacements().placementByChildValueId.get(id3);
168267
+ return edge === void 0 ? void 0 : { rootId: edge.parentValueId, path: [edge.schemaKey] };
168268
+ },
168269
+ validateAuthoredId: (id3) => {
168270
+ if (!isPendingId(id3) && context.state[`value:${id3}`] === void 0 && !isUuidV4Id(id3))
168271
+ throw new Error(
168272
+ `New local value @id(${JSON.stringify(id3)}) requires a UUID v4.`
168273
+ );
168274
+ },
167819
168275
  localListEntries: (local2) => localNestedListEntries(context, local2)
167820
- },
167821
- context.storedValueAtPath
168276
+ }
167822
168277
  );
167823
168278
  const settled = settleInitializerReferenceSpellings(
167824
168279
  executable.code,
@@ -169410,9 +169865,10 @@ function recordRepeatedRow(context, rowId, collection, site, placedIds = context
169410
169865
  function lowerPendingListItem(context, member, expression, source, path, containerId, environment, authoredSlice) {
169411
169866
  const rows = /* @__PURE__ */ new Map();
169412
169867
  const localizedTexts = /* @__PURE__ */ new Map();
169413
- const annotatedId2 = authoredRowId(context, expression, source);
169414
- const valueId = annotatedId2 ?? pendingNestedValueId(source, path);
169415
- const stablePath = isPendingId(valueId) ? valueId : unorderedRowSubtreePath(valueId, path, containerId);
169868
+ const local = context.localValues.resolve(expression, source);
169869
+ const annotatedId2 = annotatedValue(local.expression).id;
169870
+ const valueId = annotatedId2 ?? local.pendingIdentity ?? pendingNestedValueId(source, path);
169871
+ const stablePath = isPendingId(valueId) || local.pendingIdentity !== void 0 ? valueId : unorderedRowSubtreePath(valueId, path, containerId);
169416
169872
  lowerSeedRow(
169417
169873
  context,
169418
169874
  member,
@@ -171395,6 +171851,14 @@ function emitValue(context, member, valueId, options) {
171395
171851
  context.localizedTextIds = /* @__PURE__ */ new Set();
171396
171852
  const expression2 = emitValue(context, member, valueId, {
171397
171853
  ...options,
171854
+ writeIdentity: options.writeIdentity || !context.symbolsByValueId.has(valueId) && member.valueId !== valueId && (typeof member.id !== "string" || memberValueId(member.id) !== valueId) && (!isObjectRecord(member.defaultValue) || member.defaultValue.id !== valueId) && [
171855
+ 7 /* Class */,
171856
+ 22 /* Interface */,
171857
+ 6 /* List */,
171858
+ 28 /* Set */,
171859
+ 5 /* Dictionary */,
171860
+ 30 /* Tuple */
171861
+ ].includes(numberField(member, "kind")),
171398
171862
  localDefinition: true,
171399
171863
  visited,
171400
171864
  decorateLocal: void 0
@@ -175732,6 +176196,9 @@ function reconciliationRecords(workspace, changes, seeds = /* @__PURE__ */ new M
175732
176196
  });
175733
176197
  }
175734
176198
  function materializeInitializersLocallyV4(args) {
176199
+ const constructionIdentities = indexAuthoredConstructionIdentities(
176200
+ args.localReferenceLocations ?? []
176201
+ );
175735
176202
  const records3 = prospectiveInitializerRecordsV4(args);
175736
176203
  const sourceRoots = initializerSourceRootIds(
175737
176204
  args.changes,
@@ -175964,7 +176431,7 @@ function materializeInitializersLocallyV4(args) {
175964
176431
  throw new PendingInitializerDependency(location3.rootId);
175965
176432
  if (pendingRoots.has(location3.rootId))
175966
176433
  throw new PendingInitializerDependency(location3.rootId);
175967
- const target = resolvedLocalIds.get(id2) ?? storedValueAtPathV4(
176434
+ const target = resolvedLocalIds.get(id2) ?? (location3.preserveIdentity && batch.valuesById.has(id2) ? id2 : null) ?? storedValueAtPathV4(
175968
176435
  batch.valuesById,
175969
176436
  location3.rootId,
175970
176437
  location3.path
@@ -176007,6 +176474,7 @@ function materializeInitializersLocallyV4(args) {
176007
176474
  pinnedSchemaKeysByValueId: /* @__PURE__ */ new Map()
176008
176475
  };
176009
176476
  const evaluated2 = replayStoredConstructionV4({
176477
+ captureConstructionEntries: constructionIdentities.has(sourceValueId),
176010
176478
  readTracking,
176011
176479
  records: records3,
176012
176480
  document,
@@ -176086,9 +176554,12 @@ function materializeInitializersLocallyV4(args) {
176086
176554
  }
176087
176555
  return [row];
176088
176556
  });
176089
- const sparse2 = sparsifyConstructedInstance({
176557
+ const authoredIdentities = constructionIdentities.get(sourceValueId);
176558
+ const sparse2 = sparsifyConstructedInstance2({
176559
+ authoredIdentities,
176560
+ constructionEntryIds: pinned.constructionEntryIds,
176090
176561
  localizedTextIds,
176091
- document,
176562
+ document: authoredIdentities?.length ? comparisonDocument() : document,
176092
176563
  rootMember: rootOwner,
176093
176564
  constructed: {
176094
176565
  root: evaluatedRoot,
@@ -176146,11 +176617,7 @@ function materializeInitializersLocallyV4(args) {
176146
176617
  for (const [id2, location3] of args.localReferenceLocations ?? []) {
176147
176618
  if (resolvedLocalIds.has(id2)) continue;
176148
176619
  if (unavailableRootIds.has(location3.rootId)) continue;
176149
- const target = storedValueAtPathV4(
176150
- batch.valuesById,
176151
- location3.rootId,
176152
- location3.path
176153
- );
176620
+ const target = location3.preserveIdentity && batch.valuesById.has(id2) ? id2 : storedValueAtPathV4(batch.valuesById, location3.rootId, location3.path);
176154
176621
  if (target !== null) resolvedLocalIds.set(id2, target);
176155
176622
  }
176156
176623
  return { roots, resolvedLocalIds, failures, unavailableRootIds };
@@ -188836,6 +189303,48 @@ function preserveProjectFileRegistrySource(existing, emitted, records3 = /* @__P
188836
189303
  if (registryOnly) emitted = existing;
188837
189304
  return applySourceEdits(emitted, replacements);
188838
189305
  }
189306
+ function augmentAuthoredProjectFileRegistries(existing, emitted) {
189307
+ const authored = parseNeoProjectSource(existing, "definition");
189308
+ const generated = parseNeoProjectSource(emitted, "definition");
189309
+ const declarations = new Map(
189310
+ authored.declarations.flatMap(
189311
+ (declaration) => declaration.kind === "global" ? [[declaration.name, declaration]] : []
189312
+ )
189313
+ );
189314
+ const edits = [];
189315
+ const additions = [];
189316
+ for (const declaration of generated.declarations) {
189317
+ if (declaration.kind !== "global") continue;
189318
+ if (!["ImageRegistry", "AudioClipRegistry"].includes(declaration.type.name))
189319
+ continue;
189320
+ const content = emitted.slice(
189321
+ generated.syntax.source.offsetAt(declaration.range.start),
189322
+ generated.syntax.source.offsetAt(declaration.range.end)
189323
+ );
189324
+ const prior = declarations.get(declaration.name);
189325
+ if (prior === void 0) {
189326
+ additions.push(content);
189327
+ continue;
189328
+ }
189329
+ const start = authored.syntax.source.offsetAt(prior.range.start);
189330
+ const end = authored.syntax.source.offsetAt(prior.range.end);
189331
+ edits.push({
189332
+ start,
189333
+ end,
189334
+ text: preserveProjectFileRegistrySource(
189335
+ existing.slice(start, end),
189336
+ content
189337
+ )
189338
+ });
189339
+ }
189340
+ if (additions.length > 0)
189341
+ edits.push({
189342
+ start: existing.length,
189343
+ end: existing.length,
189344
+ text: "\n" + additions.join("\n\n") + "\n"
189345
+ });
189346
+ return applySourceEdits(existing, edits);
189347
+ }
188839
189348
  function registries(document, source, templateIds) {
188840
189349
  if (document.diagnostics.some((diagnostic) => diagnostic.severity === "error"))
188841
189350
  return [];
@@ -189603,7 +190112,7 @@ function scriptFeatureIndex(snapshot) {
189603
190112
  typeAnnotations,
189604
190113
  tokens,
189605
190114
  tokenIndexes,
189606
- enclosingOpener: enclosingOpenerIndex(tokens),
190115
+ enclosingOpener: receiverEnclosingOpeners(tokens),
189607
190116
  objectInitializers
189608
190117
  };
189609
190118
  SCRIPT_FEATURE_INDEX.set(snapshot, index);
@@ -192574,7 +193083,7 @@ function flowProbe(snapshot) {
192574
193083
  const tokens = scriptFeatureIndex(snapshot).tokens;
192575
193084
  const overloaded = overloadedFunctionNames(snapshot.project);
192576
193085
  if (!tokens.some(
192577
- (token) => token.text === "is" || token.text === "switch" || overloaded.has(token.text)
193086
+ (token) => token.text === "is" || token.text === "=>" || token.text === "switch" || overloaded.has(token.text)
192578
193087
  ) && !hasGenericCall(snapshot))
192579
193088
  return result;
192580
193089
  const text = snapshot.source.text;
@@ -193921,6 +194430,8 @@ function expressionTokensBefore(tokens, endExclusive) {
193921
194430
  start = name;
193922
194431
  continue;
193923
194432
  }
194433
+ if (depth === 0 && token.text === "when" && start < endExclusive - 1 && ![".", "?.", "!", "[", "<"].includes(tokens[start + 1]?.text ?? "") && followsSwitchPattern(tokens, start))
194434
+ break;
193924
194435
  if (depth === 0 && (token.kind === "punctuation" && [";", "{", "}", ",", ":", "?"].includes(token.text) || // Only `?.` and `!` continue a receiver; every other operator
193925
194436
  // (`+=`, `==`, `<`, …) ends it.
193926
194437
  token.kind === "operator" && token.text !== "?." && token.text !== "!" || token.kind === "keyword" && ["return", "throw", "if", "else"].includes(token.text))) {
@@ -193929,6 +194440,24 @@ function expressionTokensBefore(tokens, endExclusive) {
193929
194440
  }
193930
194441
  return tokens.slice(start + 1, endExclusive);
193931
194442
  }
194443
+ function receiverEnclosingOpeners(tokens) {
194444
+ let index = RECEIVER_ENCLOSING_OPENERS.get(tokens);
194445
+ if (!index) {
194446
+ index = enclosingOpenerIndex(tokens);
194447
+ RECEIVER_ENCLOSING_OPENERS.set(tokens, index);
194448
+ }
194449
+ return index;
194450
+ }
194451
+ function followsSwitchPattern(tokens, index) {
194452
+ const opener = receiverEnclosingOpeners(tokens)[index] ?? -1;
194453
+ if (tokens[opener]?.text !== "{" || tokens[opener - 1]?.text !== "switch")
194454
+ return false;
194455
+ const previous = tokens[index - 1];
194456
+ if (!previous) return false;
194457
+ if (previous.text === "when")
194458
+ return ["{", ","].includes(tokens[index - 2]?.text ?? "");
194459
+ return previous.kind === "identifier" || previous.kind === "integer" || previous.kind === "float" || previous.kind === "type" || previous.kind === "string" || [")", "]", ">", "true", "false", "null"].includes(previous.text);
194460
+ }
193932
194461
  function genericCallNameIndex(tokens, close) {
193933
194462
  if (!["(", ".", "{"].includes(tokens[close + 1]?.text ?? "")) return -1;
193934
194463
  let depth = 0;
@@ -194082,7 +194611,7 @@ function isTypeAnnotationReference(snapshot, reference2) {
194082
194611
  function isConstructorTypeReference(snapshot, reference2) {
194083
194612
  return scriptFeatureIndex(snapshot).calls.get(reference2.start)?.kind === "constructor";
194084
194613
  }
194085
- var SCRIPT_FEATURE_INDEX, assumedLambdaInputs, LIST_OPENERS, LIST_CLOSERS, TUPLE_LABEL_DECLARATIONS, NAMED_ARGUMENT_LABELS, NO_EXPECTED_VALUE, CONSTRUCTIONS, ANNOTATION_TYPE_NAMES, FLOW_PROBES, PATTERN_DECLARATIONS, OVERLOADED_FUNCTION_NAMES, GENERIC_CALL_NAMES, LOCAL_SCOPE_INDEX, NAMED_ITEM_INDEX, COLLECTION_FUNCTION_DOCUMENTATION, LOCAL_SYMBOL_CACHE, CALL_COMMIT_CHARACTERS, GENERIC_CALL_COMMIT_CHARACTERS, SETTER_VALUE_ID_SUFFIX, LAMBDA_BODY_INDEX;
194614
+ var SCRIPT_FEATURE_INDEX, assumedLambdaInputs, LIST_OPENERS, LIST_CLOSERS, TUPLE_LABEL_DECLARATIONS, NAMED_ARGUMENT_LABELS, NO_EXPECTED_VALUE, CONSTRUCTIONS, ANNOTATION_TYPE_NAMES, FLOW_PROBES, PATTERN_DECLARATIONS, OVERLOADED_FUNCTION_NAMES, GENERIC_CALL_NAMES, LOCAL_SCOPE_INDEX, NAMED_ITEM_INDEX, COLLECTION_FUNCTION_DOCUMENTATION, LOCAL_SYMBOL_CACHE, CALL_COMMIT_CHARACTERS, GENERIC_CALL_COMMIT_CHARACTERS, SETTER_VALUE_ID_SUFFIX, RECEIVER_ENCLOSING_OPENERS, LAMBDA_BODY_INDEX;
194086
194615
  var init_analyzer = __esm({
194087
194616
  "../packages/neoscript-language/src/analyzer.ts"() {
194088
194617
  "use strict";
@@ -194162,6 +194691,7 @@ var init_analyzer = __esm({
194162
194691
  CALL_COMMIT_CHARACTERS = ["("];
194163
194692
  GENERIC_CALL_COMMIT_CHARACTERS = ["<", "("];
194164
194693
  SETTER_VALUE_ID_SUFFIX = ":setter-value";
194694
+ RECEIVER_ENCLOSING_OPENERS = /* @__PURE__ */ new WeakMap();
194165
194695
  LAMBDA_BODY_INDEX = /* @__PURE__ */ new WeakMap();
194166
194696
  }
194167
194697
  });
@@ -199770,19 +200300,22 @@ function projectReferenceFamily(analysis, target, index = buildProjectSymbolInde
199770
200300
  }
199771
200301
  if (target.kind !== "member" || !target.ownerName) return [target];
199772
200302
  const classes = /* @__PURE__ */ new Map();
199773
- for (const document of analysis.documents.values()) {
200303
+ const declarations = /* @__PURE__ */ new Map();
200304
+ for (const [uri, document] of analysis.documents) {
199774
200305
  for (const declaration of document.declarations) {
199775
- if (declaration.kind === "class")
199776
- classes.set(declaration.name, declaration);
200306
+ if (declaration.kind !== "class") continue;
200307
+ classes.set(declaration.name, declaration);
200308
+ for (const member of declaration.members)
200309
+ declarations.set(locationKey3({ uri, range: member.nameRange }), member);
199777
200310
  }
199778
200311
  }
199779
200312
  const joins = (member) => target.callable !== true || member?.kind === "function" && member.modifiers.some((modifier) => DISPATCH_MODIFIERS2.has(modifier));
199780
- const declared = (symbol) => classes.get(symbol.ownerName ?? "")?.members.find(
199781
- (member) => member.name === symbol.name && member.nameRange.start.line === symbol.location.range.start.line && member.nameRange.start.character === symbol.location.range.start.character
200313
+ const declared = (symbol) => declarations.get(locationKey3(symbol.location));
200314
+ const members2 = analysis.symbols.filter(
200315
+ (symbol) => symbol.kind === "member" && symbol.name.toLowerCase() === target.name.toLowerCase()
199782
200316
  );
199783
- if (!joins(declared(target))) return [target];
199784
200317
  const symbols = new Map(
199785
- named.filter((symbol) => symbol.kind === "member" && joins(declared(symbol))).map((symbol) => [symbol.ownerName, symbol])
200318
+ members2.filter((symbol) => symbol.kind === "member" && joins(declared(symbol))).map((symbol) => [symbol.ownerName, symbol])
199786
200319
  );
199787
200320
  const roots = /* @__PURE__ */ new Map();
199788
200321
  const root = (name) => {
@@ -199790,9 +200323,7 @@ function projectReferenceFamily(analysis, target, index = buildProjectSymbolInde
199790
200323
  roots.set(name, null);
199791
200324
  const declaration = classes.get(name);
199792
200325
  const own = symbols.get(name);
199793
- const member = declaration?.members.find(
199794
- (candidate) => candidate.name === target.name && joins(candidate)
199795
- );
200326
+ const member = own ? declared(own) : void 0;
199796
200327
  if (own && !member?.modifiers.includes("override")) {
199797
200328
  roots.set(name, own);
199798
200329
  return own;
@@ -199802,11 +200333,43 @@ function projectReferenceFamily(analysis, target, index = buildProjectSymbolInde
199802
200333
  roots.set(name, resolved);
199803
200334
  return resolved;
199804
200335
  };
199805
- const selected = root(target.ownerName);
199806
- if (!selected) return [target];
199807
- return [...symbols.values()].filter(
199808
- (symbol) => symbol.ownerName && root(symbol.ownerName) === selected
200336
+ const byLocation = new Map(
200337
+ members2.map((symbol) => [locationKey3(symbol.location), symbol])
199809
200338
  );
200339
+ const edges = /* @__PURE__ */ new Map();
200340
+ const connect = (a, b) => {
200341
+ const left = locationKey3(a);
200342
+ const right = locationKey3(b);
200343
+ if (!byLocation.has(left) || !byLocation.has(right)) return;
200344
+ const add = (from, to) => {
200345
+ let values = edges.get(from);
200346
+ if (!values) edges.set(from, values = /* @__PURE__ */ new Set());
200347
+ values.add(to);
200348
+ };
200349
+ add(left, right);
200350
+ add(right, left);
200351
+ };
200352
+ for (const symbol of symbols.values()) {
200353
+ const selected = symbol.ownerName ? root(symbol.ownerName) : null;
200354
+ if (selected) connect(symbol.location, selected.location);
200355
+ }
200356
+ for (const [contract, implementation] of analysis.memberRelations)
200357
+ connect(contract, implementation);
200358
+ const visited = /* @__PURE__ */ new Set();
200359
+ const pending = [locationKey3(target.location)];
200360
+ const family = [];
200361
+ while (pending.length > 0) {
200362
+ const key = pending.pop();
200363
+ if (visited.has(key)) continue;
200364
+ visited.add(key);
200365
+ const symbol = byLocation.get(key);
200366
+ if (symbol) family.push(symbol);
200367
+ for (const next of edges.get(key) ?? []) pending.push(next);
200368
+ }
200369
+ return family.length > 0 ? family : [target];
200370
+ }
200371
+ function locationKey3(location3) {
200372
+ return `${location3.uri}:${location3.range.start.line}:${location3.range.start.character}`;
199810
200373
  }
199811
200374
  var DISPATCH_MODIFIERS2;
199812
200375
  var init_project_source_reference_family = __esm({
@@ -200069,7 +200632,7 @@ function sameLocationInList(target, locations) {
200069
200632
  (location3) => location3.uri === target.uri && location3.range.start.line === target.range.start.line && location3.range.start.character === target.range.start.character
200070
200633
  );
200071
200634
  }
200072
- function locationKey3(location3) {
200635
+ function locationKey4(location3) {
200073
200636
  const { start, end } = location3.range;
200074
200637
  return JSON.stringify([
200075
200638
  location3.uri,
@@ -200636,8 +201199,9 @@ var init_service = __esm({
200636
201199
  if (!resolved) return [];
200637
201200
  const declaration = resolved.symbol;
200638
201201
  const family = projectReferenceFamily(analysis, declaration, index);
201202
+ const familyNames = new Set(family.map((member) => member.name));
200639
201203
  const familyLocations = new Set(
200640
- family.map((member) => locationKey3(member.location))
201204
+ family.map((member) => locationKey4(member.location))
200641
201205
  );
200642
201206
  const familyIds = new Set(
200643
201207
  family.flatMap((member) => member.id === null ? [] : [member.id])
@@ -200652,7 +201216,7 @@ var init_service = __esm({
200652
201216
  for (let tokenIndex = 0; tokenIndex < tokens.length; tokenIndex++) {
200653
201217
  const candidate = tokens[tokenIndex];
200654
201218
  if (!isProjectNameToken(candidate)) continue;
200655
- const matches = parameterName === null ? candidate.text === token.text : candidate.text === declaration.name || candidate.text.toLowerCase() === parameterName && isNamedArgumentLabel(tokens, tokenIndex);
201219
+ const matches = parameterName === null ? familyNames.has(candidate.text) : candidate.text === declaration.name || candidate.text.toLowerCase() === parameterName && isNamedArgumentLabel(tokens, tokenIndex);
200656
201220
  if (!matches) continue;
200657
201221
  const candidateSymbol = projectSymbolAt(
200658
201222
  analysis,
@@ -200660,11 +201224,11 @@ var init_service = __esm({
200660
201224
  candidate.range.start,
200661
201225
  index
200662
201226
  )?.symbol;
200663
- if (!candidateSymbol || !familyLocations.has(locationKey3(candidateSymbol.location))) {
201227
+ if (!candidateSymbol || !familyLocations.has(locationKey4(candidateSymbol.location))) {
200664
201228
  continue;
200665
201229
  }
200666
201230
  const location3 = { uri: state.document.uri, range: candidate.range };
200667
- if (!includeDeclaration && familyLocations.has(locationKey3(location3))) {
201231
+ if (!includeDeclaration && familyLocations.has(locationKey4(location3))) {
200668
201232
  continue;
200669
201233
  }
200670
201234
  locations.push(location3);
@@ -200675,11 +201239,11 @@ var init_service = __esm({
200675
201239
  if (isProjectDocument(state.document, state.context)) continue;
200676
201240
  const snapshot = this.scriptSnapshot(state);
200677
201241
  for (const candidate of snapshot.parsed.references) {
200678
- if (candidate.name !== declaration.name) continue;
201242
+ if (!familyNames.has(candidate.name)) continue;
200679
201243
  const symbolId = resolveReferenceSymbolId(snapshot, candidate);
200680
201244
  if (symbolId === null) continue;
200681
201245
  const matches = familyIds.has(symbolId) || definition(snapshot, candidate.range.start).some(
200682
- (location3) => familyLocations.has(locationKey3(location3))
201246
+ (location3) => familyLocations.has(locationKey4(location3))
200683
201247
  );
200684
201248
  if (!matches) continue;
200685
201249
  locations.push({ uri: state.document.uri, range: candidate.range });
@@ -200687,7 +201251,7 @@ var init_service = __esm({
200687
201251
  if (declaration.kind !== "parameter") continue;
200688
201252
  for (const label of namedArgumentLabels(snapshot)) {
200689
201253
  const parameter4 = label.parameter.selectionLocation;
200690
- if (parameter4 && familyLocations.has(locationKey3(parameter4)))
201254
+ if (parameter4 && familyLocations.has(locationKey4(parameter4)))
200691
201255
  locations.push({ uri: state.document.uri, range: label.range });
200692
201256
  }
200693
201257
  }
@@ -224312,7 +224876,7 @@ import {
224312
224876
  statSync as statSync7
224313
224877
  } from "node:fs";
224314
224878
  import { join as join22, relative as relative8, sep as sep9 } from "node:path";
224315
- function assignPendingIds(changes, authoredValueSeeds, reconstructed3, previousLedger = {}, codePendingIdCandidates = []) {
224879
+ function assignPendingIds(changes, authoredValueSeeds, reconstructed3, previousLedger = {}, codePendingIdCandidates = [], authoredPendingIds = []) {
224316
224880
  const assigned = /* @__PURE__ */ new Map();
224317
224881
  const minted = /* @__PURE__ */ new Map();
224318
224882
  let mint = (pendingId2) => {
@@ -224457,6 +225021,7 @@ function assignPendingIds(changes, authoredValueSeeds, reconstructed3, previousL
224457
225021
  for (const change of changes) collectCodeIds(change.nextData);
224458
225022
  for (const seed of authoredValueSeeds.values()) collectCodeIds(seed);
224459
225023
  }
225024
+ for (const id2 of authoredPendingIds) collect(id2);
224460
225025
  for (const root of roots) assign(root);
224461
225026
  const keys = identityLedgerKeys(minted.keys());
224462
225027
  const ledger = {};
@@ -225373,7 +225938,7 @@ async function prepareLocalPushArtifactsV4(workspace, status, onPhase = () => vo
225373
225938
  } : void 0;
225374
225939
  onPhase("Hashing project source\u2026");
225375
225940
  const source = projectSourceIdentityForStatus(status);
225376
- const verificationSource = options.fullValidation ? locatedPendingProjectSourceIdentity(workspace, status) : null;
225941
+ const verificationSource = options.fullValidation ? authoredVerificationSource(workspace, status, source) : null;
225377
225942
  onPhase("Assigning pending value identities\u2026");
225378
225943
  const release = options.purpose === "evaluation" /* Evaluation */ ? await acquireWorkspaceLock(
225379
225944
  workspace.root,
@@ -225389,6 +225954,9 @@ async function prepareLocalPushArtifactsV4(workspace, status, onPhase = () => vo
225389
225954
  { ...options.identityLedger, ...latestLedger },
225390
225955
  [...status.pendingValueIdentitySites ?? []].flatMap(
225391
225956
  ([id2, site]) => site.materializedLocation !== void 0 && pendingVirtualValueIdentity(id2) !== null ? [id2] : []
225957
+ ),
225958
+ [...status.pendingValueIdentitySites ?? []].flatMap(
225959
+ ([id2, site]) => site.materializedLocation?.preserveIdentity === true ? [id2] : []
225392
225960
  )
225393
225961
  );
225394
225962
  if (!mergeReservedIdentities(workspace.root, pendingAssignment.ledger)) {
@@ -225415,6 +225983,7 @@ async function prepareLocalPushArtifactsV4(workspace, status, onPhase = () => vo
225415
225983
  status.changes,
225416
225984
  localizedTextCreateEnvelopeConfig2(workspace, status.changes)
225417
225985
  );
225986
+ let verifiedConstructionIdentities;
225418
225987
  try {
225419
225988
  if (verificationSource !== null) {
225420
225989
  onPhase("Verifying the assigned value-id stamps\u2026");
@@ -225424,8 +225993,8 @@ async function prepareLocalPushArtifactsV4(workspace, status, onPhase = () => vo
225424
225993
  status.pendingValueIdentitySites,
225425
225994
  { sourceSnapshot: status.sourceSnapshot, validateResult: true }
225426
225995
  );
225427
- onPhase("Verifying the complete source round trip\u2026");
225428
- verifyProjectSourceCommitAgainstStateV4({
225996
+ onPhase("Verifying the authored source and ownership\u2026");
225997
+ verifiedConstructionIdentities = verifyProjectSourceCommitAgainstStateV4({
225429
225998
  projectId: workspace.config.projectId,
225430
225999
  versionId: workspace.config.versionId,
225431
226000
  stateRecords: workspace.state.records,
@@ -225447,6 +226016,23 @@ async function prepareLocalPushArtifactsV4(workspace, status, onPhase = () => vo
225447
226016
  let prepared;
225448
226017
  try {
225449
226018
  const preparationArgs2 = {
226019
+ constructionIdentities: verifiedConstructionIdentities ?? indexAuthoredConstructionIdentities(
226020
+ [...status.pendingValueIdentitySites ?? []].flatMap(
226021
+ ([id2, site]) => {
226022
+ const location3 = site.materializedLocation;
226023
+ if (location3 === void 0) return [];
226024
+ return [
226025
+ [
226026
+ pendingAssignment.assigned.get(id2) ?? id2,
226027
+ {
226028
+ ...location3,
226029
+ rootId: pendingAssignment.assigned.get(location3.rootId) ?? location3.rootId
226030
+ }
226031
+ ]
226032
+ ];
226033
+ }
226034
+ )
226035
+ ),
225450
226036
  initializerReferenceOwners: new Map(
225451
226037
  [...status.pendingValueIdentitySites ?? []].flatMap(
225452
226038
  ([id2, site]) => site.materializedLocation === void 0 ? [] : [
@@ -225535,17 +226121,6 @@ function locatePreparationError(error, status, assigned) {
225535
226121
  if (source === void 0) return error;
225536
226122
  return new Error(`${source.file}:${source.line} \u2014 ${error.message}`);
225537
226123
  }
225538
- function locatedPendingProjectSourceIdentity(workspace, status) {
225539
- try {
225540
- return createPendingProjectSourceIdentityV4(
225541
- workspace,
225542
- status,
225543
- status.authoredValueSeeds
225544
- );
225545
- } catch (error) {
225546
- throw locatePreparationError(error, status, /* @__PURE__ */ new Map());
225547
- }
225548
- }
225549
226124
  async function prepareLocalCandidateV4(workspace, options = {}) {
225550
226125
  const pushOptions = {
225551
226126
  dryRun: options.dryRun ?? true,
@@ -225783,6 +226358,30 @@ function reportDryRunFailure(error, json) {
225783
226358
  }
225784
226359
  console.error(`Dry run failed: ${message}`);
225785
226360
  }
226361
+ function authoredVerificationSource(workspace, status, source) {
226362
+ let canonical;
226363
+ try {
226364
+ canonical = createPendingProjectSourceIdentityV4(
226365
+ workspace,
226366
+ status,
226367
+ status.authoredValueSeeds
226368
+ );
226369
+ } catch (error) {
226370
+ throw locatePreparationError(error, status, /* @__PURE__ */ new Map());
226371
+ }
226372
+ const files = new Map(source.files.map((file) => [file.path, file]));
226373
+ for (const file of canonical.files) {
226374
+ const prior = files.get(file.path);
226375
+ const content = augmentAuthoredProjectFileRegistries(
226376
+ prior?.content ?? "",
226377
+ file.content
226378
+ );
226379
+ if (content === (prior?.content ?? "")) continue;
226380
+ files.set(file.path, { ...file, content });
226381
+ }
226382
+ const result = [...files.values()];
226383
+ return { files: result, sourceHash: hashProjectSourceFiles(result) };
226384
+ }
225786
226385
  function projectSourceIdentityForStatus(status) {
225787
226386
  if (status.sourceSnapshot === void 0) {
225788
226387
  throw new Error(
@@ -226133,11 +226732,46 @@ ${blockingErrors.map((error) => ` ${error.message}`).join("\n")}`
226133
226732
  replacements.exact
226134
226733
  );
226135
226734
  const ownedLocalReplacements = new Map(replacements.exact);
226735
+ let committedNamedRows;
226736
+ let ownsCommittedPath;
226136
226737
  for (const [locator, site] of localStatus.pendingValueIdentitySites ?? []) {
226137
226738
  const location3 = site.materializedLocation;
226138
226739
  if (location3 === void 0) continue;
226139
226740
  const rootId = rewritePlacementValueId(location3.rootId, replacements);
226140
- const id2 = committedValueAtPath(rootId, location3.path);
226741
+ const expectedId = rewritePlacementValueId(locator, replacements);
226742
+ let id2 = committedValueAtPath(rootId, location3.path);
226743
+ if (location3.preserveIdentity === true) {
226744
+ committedNamedRows ??= storedValueRowsByIdV4(Object.values(nextRecords));
226745
+ const row = committedNamedRows.get(expectedId);
226746
+ if (row === void 0)
226747
+ throw new Error(
226748
+ `Committed named value ${locator} is missing its assigned identity ${expectedId}.`
226749
+ );
226750
+ if (id2 !== expectedId) {
226751
+ if (ownsCommittedPath === void 0) {
226752
+ const document = readProjectDocument(
226753
+ pulledProjectDocumentRaw({
226754
+ ...workspace,
226755
+ state: { ...workspace.state, records: nextRecords }
226756
+ })
226757
+ );
226758
+ const graph = new MaterializedValueGraphContext(document);
226759
+ ownsCommittedPath = storedValueOwnsPathV4(
226760
+ Object.values(nextRecords),
226761
+ committedNamedRows,
226762
+ (id3) => graph.ownerForValue(id3)
226763
+ );
226764
+ }
226765
+ const path = location3.path.map(
226766
+ (key) => typeof key === "string" ? replacements.exact.get(key) ?? key : key
226767
+ );
226768
+ if (!ownsCommittedPath(rootId, path, expectedId))
226769
+ throw new Error(
226770
+ `Committed named value ${locator} is absent from its owning path.`
226771
+ );
226772
+ }
226773
+ id2 = expectedId;
226774
+ }
226141
226775
  if (id2 === null)
226142
226776
  throw new Error(
226143
226777
  `Committed local value ${locator} has no row at its owning path.`
@@ -226692,8 +227326,13 @@ function materializeAssignedValueIdsInAuthoredSource(workspace, replacements, pe
226692
227326
  assignedId,
226693
227327
  options.committedValueAtPath
226694
227328
  );
226695
- if (entryStamps === null) continue;
226696
- if (site.stampIdentity !== false) {
227329
+ if (entryStamps === null && !site.materializedLocation?.preserveIdentity)
227330
+ continue;
227331
+ if (site.stampIdentity !== false && site.materializedLocation?.preserveIdentity) {
227332
+ file.edits.push(
227333
+ idStamp(file, sourceOffset2(file, site.declarationStart), assignedId)
227334
+ );
227335
+ } else if (site.stampIdentity !== false) {
226697
227336
  const row = rowAt(file, expressionOffset);
226698
227337
  if (row === null) continue;
226699
227338
  if (row.slot === 0 /* Entry */) {
@@ -226707,7 +227346,7 @@ function materializeAssignedValueIdsInAuthoredSource(workspace, replacements, pe
226707
227346
  file.edits.push(...stamp);
226708
227347
  }
226709
227348
  }
226710
- file.edits.push(...entryStamps);
227349
+ file.edits.push(...entryStamps ?? []);
226711
227350
  }
226712
227351
  const preserved = /* @__PURE__ */ new Map();
226713
227352
  for (const [uri, file] of files)
@@ -227524,6 +228163,8 @@ var compileNSVoidBody2, compileNSFunction2, compileNSGetter2, compileNSSetter2,
227524
228163
  var init_push = __esm({
227525
228164
  "src/commands/push.ts"() {
227526
228165
  "use strict";
228166
+ init_constructor_argument_ownership();
228167
+ init_virtual_instance_values();
227527
228168
  init_animation_child_binding_id();
227528
228169
  init_world_system_classes();
227529
228170
  init_local_project_file_storage();
@@ -243072,7 +243713,7 @@ var releaseWorkspaceLock = () => void 0;
243072
243713
  async function main() {
243073
243714
  const args = parseArgs(process.argv.slice(2));
243074
243715
  if (args.command === "--version") {
243075
- console.log("0.89.11");
243716
+ console.log("0.89.13");
243076
243717
  return;
243077
243718
  }
243078
243719
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {