@neocompose/cli 0.38.1 → 0.38.2

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
@@ -11838,7 +11838,7 @@ var init_strict_resolver = __esm({
11838
11838
  expression.pos
11839
11839
  );
11840
11840
  }
11841
- if (expression.initializer && expression.initializer.length > 0 && !projectionCall) {
11841
+ if (expression.initializer && expression.initializer.length > 0 && !projectionCall && this.context.storedConstructionReplay !== true) {
11842
11842
  throw new CompileError(
11843
11843
  "Object initializers are available to project source construction and are not executable NeoScript constructors.",
11844
11844
  expression.pos
@@ -61807,9 +61807,504 @@ var init_lower_variants = __esm({
61807
61807
  }
61808
61808
  });
61809
61809
 
61810
+ // ../src/models/constructors/constructors.ts
61811
+ function hasRejectedConstructorKey(value) {
61812
+ return REJECTED_CONSTRUCTOR_KEYS.some((key) => value[key] !== void 0);
61813
+ }
61814
+ function isNamedBaseClauseEntry(value, nameIsValid) {
61815
+ if (typeof value !== "object" || value === null) return false;
61816
+ if (Array.isArray(value)) return false;
61817
+ const candidate = value;
61818
+ if (!Object.keys(candidate).every((key) => key === "name" || key === "code")) {
61819
+ return false;
61820
+ }
61821
+ if (!nameIsValid(candidate.name)) return false;
61822
+ if (typeof candidate.code !== "string") return false;
61823
+ return candidate.code.length > 0;
61824
+ }
61825
+ function isNeoConstructorBaseArgument(value) {
61826
+ return isNamedBaseClauseEntry(value, isValidCallableArgumentIdentifier);
61827
+ }
61828
+ function isNeoConstructorBaseInitializerField(value) {
61829
+ return isNamedBaseClauseEntry(value, isValidSchemaMemberIdentifier);
61830
+ }
61831
+ function isNeoClassConstructorBase(value) {
61832
+ if (typeof value !== "object" || value === null) return false;
61833
+ if (Array.isArray(value)) return false;
61834
+ const v = value;
61835
+ if (hasRejectedConstructorKey(v)) return false;
61836
+ if (!isValidDocsText(v.docsText)) return false;
61837
+ if (typeof v.classId !== "string") return false;
61838
+ if (v.classId.length === 0) return false;
61839
+ if (typeof v.code !== "string" && v.code !== null) return false;
61840
+ if (!Array.isArray(v.argumentTypes)) return false;
61841
+ const parameterNames = /* @__PURE__ */ new Set();
61842
+ const argumentTypes = [];
61843
+ for (const argument2 of v.argumentTypes) {
61844
+ if (!isNSFunctionArgumentTypeInfo(argument2)) return false;
61845
+ if (!isValidCallableArgumentIdentifier(argument2.name)) return false;
61846
+ if (parameterNames.has(argument2.name)) return false;
61847
+ parameterNames.add(argument2.name);
61848
+ argumentTypes.push(argument2);
61849
+ }
61850
+ if (validateParameterDefaults(argumentTypes).length > 0) return false;
61851
+ if (v.baseArguments !== void 0 && v.baseArguments !== null) {
61852
+ if (!Array.isArray(v.baseArguments)) return false;
61853
+ const baseNames = /* @__PURE__ */ new Set();
61854
+ for (const baseArgument of v.baseArguments) {
61855
+ if (!isNeoConstructorBaseArgument(baseArgument)) return false;
61856
+ if (baseNames.has(baseArgument.name)) return false;
61857
+ baseNames.add(baseArgument.name);
61858
+ }
61859
+ }
61860
+ if (v.baseInitializerFields !== void 0 && v.baseInitializerFields !== null) {
61861
+ if (!Array.isArray(v.baseInitializerFields)) return false;
61862
+ const fieldNames = /* @__PURE__ */ new Set();
61863
+ for (const field of v.baseInitializerFields) {
61864
+ if (!isNeoConstructorBaseInitializerField(field)) return false;
61865
+ if (fieldNames.has(field.name)) return false;
61866
+ fieldNames.add(field.name);
61867
+ }
61868
+ }
61869
+ if (v.action !== void 0 && v.action !== null) return false;
61870
+ if (v.compiledBaseArguments !== void 0 && v.compiledBaseArguments !== null) {
61871
+ return false;
61872
+ }
61873
+ return v.compiledBaseInitializerFields === void 0 || v.compiledBaseInitializerFields === null;
61874
+ }
61875
+ function isUncompiledNeoClassConstructor(value) {
61876
+ if (!isNeoClassConstructorBase(value)) return false;
61877
+ const v = value;
61878
+ if (typeof v.id !== "string" || v.id.length === 0) return false;
61879
+ if (typeof v.projectId !== "string" || v.projectId.length === 0) return false;
61880
+ if (!isEpochMillis(v.createdAt)) return false;
61881
+ return isEpochMillis(v.updatedAt);
61882
+ }
61883
+ function hasValidConstructorAction(action, argumentTypes) {
61884
+ if (!isNSFunctionWithReturnType(action)) return false;
61885
+ if (action.typeInfo.type !== 0 /* Null */) return false;
61886
+ if (action.typeInfo.required !== true) return false;
61887
+ if (action.parameters.length !== argumentTypes.length + 2) return false;
61888
+ if (action.parameters[0]?.id !== "__this__") return false;
61889
+ if (action.parameters[1]?.id !== "__root__") return false;
61890
+ for (let index = 0; index < argumentTypes.length; index += 1) {
61891
+ const parameter4 = action.parameters[index + 2];
61892
+ if (parameter4?.id !== `__arg_${index}__`) return false;
61893
+ const declared = argumentTypes[index];
61894
+ if (declared === void 0) return false;
61895
+ if (!typeInfosInvariantlyEqual(parameter4.typeInfo, declared)) return false;
61896
+ }
61897
+ return true;
61898
+ }
61899
+ function compiledBaseClauseGettersAlign(compiled, authored) {
61900
+ const authoredCount = Array.isArray(authored) ? authored.length : 0;
61901
+ if (compiled === void 0 || compiled === null) return authoredCount === 0;
61902
+ if (!Array.isArray(compiled)) return false;
61903
+ if (!compiled.every(isNSGetter)) return false;
61904
+ return compiled.length === authoredCount;
61905
+ }
61906
+ function isNeoClassConstructorProps(value) {
61907
+ if (typeof value !== "object" || value === null) return false;
61908
+ const v = value;
61909
+ const {
61910
+ action: _action,
61911
+ compiledBaseArguments: _compiledBaseArguments,
61912
+ compiledBaseInitializerFields: _compiledBaseInitializerFields,
61913
+ ...authored
61914
+ } = v;
61915
+ void _action;
61916
+ void _compiledBaseArguments;
61917
+ void _compiledBaseInitializerFields;
61918
+ if (!isNeoClassConstructorBase(authored)) return false;
61919
+ if (typeof v.id !== "string") return false;
61920
+ if (v.id.length === 0) return false;
61921
+ if (typeof v.projectId !== "string") return false;
61922
+ if (!isEpochMillis(v.createdAt)) return false;
61923
+ if (!isEpochMillis(v.updatedAt)) return false;
61924
+ const argumentTypes = v.argumentTypes;
61925
+ if (!hasValidConstructorAction(v.action, argumentTypes)) return false;
61926
+ if (!compiledBaseClauseGettersAlign(v.compiledBaseArguments, v.baseArguments)) {
61927
+ return false;
61928
+ }
61929
+ return compiledBaseClauseGettersAlign(
61930
+ v.compiledBaseInitializerFields,
61931
+ v.baseInitializerFields
61932
+ );
61933
+ }
61934
+ function isNeoClassConstructor(value) {
61935
+ return isNeoClassConstructorProps(value);
61936
+ }
61937
+ function constructorActionParameterId(constructor2, index) {
61938
+ const action = "action" in constructor2 ? constructor2.action : void 0;
61939
+ if (action !== null && typeof action === "object") {
61940
+ const parameters = action.parameters;
61941
+ if (Array.isArray(parameters)) {
61942
+ const parameter4 = parameters[index + 2];
61943
+ if (parameter4 !== null && typeof parameter4 === "object" && typeof parameter4.id === "string") {
61944
+ return parameter4.id;
61945
+ }
61946
+ }
61947
+ }
61948
+ return `__arg_${index}__`;
61949
+ }
61950
+ var REJECTED_CONSTRUCTOR_KEYS;
61951
+ var init_constructors = __esm({
61952
+ "../src/models/constructors/constructors.ts"() {
61953
+ "use strict";
61954
+ init_core();
61955
+ init_docs_text2();
61956
+ init_member_kinds();
61957
+ init_schema_identifiers();
61958
+ init_neoscript();
61959
+ REJECTED_CONSTRUCTOR_KEYS = [
61960
+ "bodyMode",
61961
+ "uiAction",
61962
+ "returnTypeInfo",
61963
+ "deferred"
61964
+ ];
61965
+ }
61966
+ });
61967
+
61968
+ // ../src/models/constructors/index.ts
61969
+ var init_constructors2 = __esm({
61970
+ "../src/models/constructors/index.ts"() {
61971
+ "use strict";
61972
+ init_constructors();
61973
+ }
61974
+ });
61975
+
61976
+ // ../src/models/classes/constructor-parameter-settlement.ts
61977
+ function createConstructorSettlementResolver(view) {
61978
+ const classesById2 = new Map(
61979
+ view.classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
61980
+ );
61981
+ const membersById2 = new Map(
61982
+ view.members.map((member) => [member.id, member])
61983
+ );
61984
+ const constructorsById = new Map(
61985
+ (view.constructors ?? []).map((constructor2) => [
61986
+ constructor2.id,
61987
+ constructor2
61988
+ ])
61989
+ );
61990
+ const directResultByClassAndParameter = /* @__PURE__ */ new Map();
61991
+ const recordedResultByConstructorAndParameter = /* @__PURE__ */ new Map();
61992
+ const directSettlement = (classId, parameterName) => {
61993
+ const cacheKey = `${classId}\0${parameterName}`;
61994
+ if (directResultByClassAndParameter.has(cacheKey)) {
61995
+ return directResultByClassAndParameter.get(cacheKey) ?? null;
61996
+ }
61997
+ const visited = /* @__PURE__ */ new Set();
61998
+ let currentId = classId;
61999
+ while (currentId !== null && !visited.has(currentId)) {
62000
+ visited.add(currentId);
62001
+ const schemaClass2 = classesById2.get(currentId);
62002
+ if (schemaClass2 === void 0) break;
62003
+ for (const [schemaKey, memberId] of Object.entries(
62004
+ schemaClass2.schema ?? {}
62005
+ )) {
62006
+ if (typeof memberId !== "string") continue;
62007
+ const member = membersById2.get(memberId);
62008
+ const defaultRecord = asRecord(member?.defaultValue);
62009
+ const initRecord = asRecord(defaultRecord?.init);
62010
+ if (initRecord !== null && typeof initRecord.code === "string" && initRecord.code.trim() === parameterName) {
62011
+ const result = { schemaKey, memberId };
62012
+ directResultByClassAndParameter.set(cacheKey, result);
62013
+ return result;
62014
+ }
62015
+ }
62016
+ currentId = schemaClass2.extendsClassId ?? null;
62017
+ }
62018
+ directResultByClassAndParameter.set(cacheKey, null);
62019
+ return null;
62020
+ };
62021
+ const memberIdForSchemaKey = (classId, schemaKey) => {
62022
+ const visited = /* @__PURE__ */ new Set();
62023
+ let currentId = classId;
62024
+ while (currentId !== null && !visited.has(currentId)) {
62025
+ visited.add(currentId);
62026
+ const schemaClass2 = classesById2.get(currentId);
62027
+ if (schemaClass2 === void 0) return null;
62028
+ const memberId = schemaClass2.schema?.[schemaKey];
62029
+ if (typeof memberId === "string") return memberId;
62030
+ currentId = schemaClass2.extendsClassId ?? null;
62031
+ }
62032
+ return null;
62033
+ };
62034
+ const recordedSettlement = (classId, parameterName, constructorId, resolving) => {
62035
+ const cacheKey = `${classId}\0${constructorId}\0${parameterName}`;
62036
+ if (recordedResultByConstructorAndParameter.has(cacheKey)) {
62037
+ return recordedResultByConstructorAndParameter.get(cacheKey) ?? null;
62038
+ }
62039
+ if (resolving.has(cacheKey)) return null;
62040
+ const constructor2 = constructorsById.get(constructorId);
62041
+ if (constructor2?.classId !== classId) {
62042
+ recordedResultByConstructorAndParameter.set(cacheKey, null);
62043
+ return null;
62044
+ }
62045
+ const direct = directSettlement(classId, parameterName);
62046
+ if (direct !== null) {
62047
+ recordedResultByConstructorAndParameter.set(cacheKey, direct);
62048
+ return direct;
62049
+ }
62050
+ const schemaClass2 = classesById2.get(classId);
62051
+ const baseClassId = schemaClass2?.extendsClassId;
62052
+ if (typeof baseClassId !== "string") {
62053
+ recordedResultByConstructorAndParameter.set(cacheKey, null);
62054
+ return null;
62055
+ }
62056
+ for (const field of constructor2.baseInitializerFields ?? []) {
62057
+ const record3 = asRecord(field);
62058
+ if (typeof record3?.name !== "string" || typeof record3.code !== "string" || record3.code.trim() !== parameterName) {
62059
+ continue;
62060
+ }
62061
+ const memberId = memberIdForSchemaKey(baseClassId, record3.name);
62062
+ if (memberId !== null) {
62063
+ const result = { schemaKey: record3.name, memberId };
62064
+ recordedResultByConstructorAndParameter.set(cacheKey, result);
62065
+ return result;
62066
+ }
62067
+ }
62068
+ const baseConstructorId = classesById2.get(baseClassId)?.requiredConstructorId;
62069
+ if (typeof baseConstructorId !== "string") {
62070
+ recordedResultByConstructorAndParameter.set(cacheKey, null);
62071
+ return null;
62072
+ }
62073
+ resolving.add(cacheKey);
62074
+ for (const argument2 of constructor2.baseArguments ?? []) {
62075
+ const record3 = asRecord(argument2);
62076
+ if (typeof record3?.name !== "string" || typeof record3.code !== "string" || record3.code.trim() !== parameterName) {
62077
+ continue;
62078
+ }
62079
+ const result = recordedSettlement(
62080
+ baseClassId,
62081
+ record3.name,
62082
+ baseConstructorId,
62083
+ resolving
62084
+ );
62085
+ resolving.delete(cacheKey);
62086
+ recordedResultByConstructorAndParameter.set(cacheKey, result);
62087
+ return result;
62088
+ }
62089
+ resolving.delete(cacheKey);
62090
+ recordedResultByConstructorAndParameter.set(cacheKey, null);
62091
+ return null;
62092
+ };
62093
+ return (classId, parameterName, constructorId) => constructorId === void 0 ? directSettlement(classId, parameterName) : recordedSettlement(classId, parameterName, constructorId, /* @__PURE__ */ new Set());
62094
+ }
62095
+ function constructorSettledSchemaEntry(view, classId, parameterName, constructorId) {
62096
+ return createConstructorSettlementResolver(view)(
62097
+ classId,
62098
+ parameterName,
62099
+ constructorId
62100
+ );
62101
+ }
62102
+ function asRecord(value) {
62103
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
62104
+ return null;
62105
+ }
62106
+ return value;
62107
+ }
62108
+ var init_constructor_parameter_settlement = __esm({
62109
+ "../src/models/classes/constructor-parameter-settlement.ts"() {
62110
+ "use strict";
62111
+ }
62112
+ });
62113
+
62114
+ // src/project-source/stored-value-placements.ts
62115
+ function buildStoredValuePlacementIndexV4(records2) {
62116
+ const live = [...records2].filter((record3) => record3.deleted !== true);
62117
+ const values = /* @__PURE__ */ new Map();
62118
+ const classes = [];
62119
+ const members = [];
62120
+ const memberDataById = /* @__PURE__ */ new Map();
62121
+ const constructors = /* @__PURE__ */ new Map();
62122
+ const variantTargetClassByRootValueId = /* @__PURE__ */ new Map();
62123
+ for (const record3 of live) {
62124
+ if (!isObjectRecord2(record3.data)) continue;
62125
+ if (record3.recordKind === "value") {
62126
+ values.set(record3.recordId, record3.data);
62127
+ } else if (record3.recordKind === "class") {
62128
+ classes.push({
62129
+ id: record3.recordId,
62130
+ ...isStringRecord2(record3.data.schema) ? { schema: record3.data.schema } : {},
62131
+ ...typeof record3.data.extendsClassId === "string" || record3.data.extendsClassId === null ? { extendsClassId: record3.data.extendsClassId } : {},
62132
+ ...typeof record3.data.requiredConstructorId === "string" ? { requiredConstructorId: record3.data.requiredConstructorId } : {},
62133
+ ...Array.isArray(record3.data.genericParams) ? {
62134
+ genericParamIds: record3.data.genericParams.flatMap(
62135
+ (entry) => isObjectRecord2(entry) && typeof entry.id === "string" ? [entry.id] : []
62136
+ )
62137
+ } : {}
62138
+ });
62139
+ } else if (record3.recordKind === "member") {
62140
+ memberDataById.set(record3.recordId, record3.data);
62141
+ members.push({
62142
+ id: record3.recordId,
62143
+ ...record3.data.defaultValue === void 0 ? {} : { defaultValue: record3.data.defaultValue }
62144
+ });
62145
+ } else if (record3.recordKind === "constructor") {
62146
+ constructors.set(record3.recordId, record3.data);
62147
+ } else if (record3.recordKind === "variant" && typeof record3.data.valueId === "string" && typeof record3.data.classId === "string") {
62148
+ variantTargetClassByRootValueId.set(
62149
+ record3.data.valueId,
62150
+ record3.data.classId
62151
+ );
62152
+ }
62153
+ }
62154
+ const classesById2 = new Map(
62155
+ classes.map((schemaClass2) => [schemaClass2.id, schemaClass2])
62156
+ );
62157
+ const resolveSettlement = createConstructorSettlementResolver({
62158
+ classes,
62159
+ constructors: [...constructors].flatMap(
62160
+ ([id2, constructor2]) => typeof constructor2.classId === "string" ? [
62161
+ {
62162
+ id: id2,
62163
+ classId: constructor2.classId,
62164
+ ...Array.isArray(constructor2.baseArguments) ? { baseArguments: constructor2.baseArguments } : {},
62165
+ ...Array.isArray(constructor2.baseInitializerFields) ? {
62166
+ baseInitializerFields: constructor2.baseInitializerFields
62167
+ } : {}
62168
+ }
62169
+ ] : []
62170
+ ),
62171
+ members
62172
+ });
62173
+ const memberIdForSchemaKey = (classId, schemaKey) => {
62174
+ const visited = /* @__PURE__ */ new Set();
62175
+ let cursor = classId;
62176
+ while (cursor !== null && !visited.has(cursor)) {
62177
+ visited.add(cursor);
62178
+ const schemaClass2 = classesById2.get(cursor);
62179
+ if (schemaClass2 === void 0) return null;
62180
+ const memberId = schemaClass2.schema?.[schemaKey];
62181
+ if (typeof memberId === "string") return memberId;
62182
+ cursor = schemaClass2.extendsClassId ?? null;
62183
+ }
62184
+ return null;
62185
+ };
62186
+ const childrenByParentValueId = /* @__PURE__ */ new Map();
62187
+ const placementByChildValueId = /* @__PURE__ */ new Map();
62188
+ const add = (edge) => {
62189
+ const children = childrenByParentValueId.get(edge.parentValueId) ?? /* @__PURE__ */ new Map();
62190
+ if (children.has(edge.schemaKey)) return;
62191
+ children.set(edge.schemaKey, edge);
62192
+ childrenByParentValueId.set(edge.parentValueId, children);
62193
+ if (!placementByChildValueId.has(edge.childValueId)) {
62194
+ placementByChildValueId.set(edge.childValueId, edge);
62195
+ }
62196
+ };
62197
+ for (const [parentValueId, value] of values) {
62198
+ const classId = typeof value.classId === "string" ? value.classId : null;
62199
+ const body = value.value;
62200
+ if (isObjectRecord2(body)) {
62201
+ for (const [schemaKey, childValueId] of Object.entries(body)) {
62202
+ if (typeof childValueId !== "string" || !values.has(childValueId)) {
62203
+ continue;
62204
+ }
62205
+ add({
62206
+ childValueId,
62207
+ memberId: classId === null ? null : memberIdForSchemaKey(classId, schemaKey),
62208
+ parentValueId,
62209
+ schemaKey,
62210
+ source: "body"
62211
+ });
62212
+ }
62213
+ }
62214
+ const constructorId = value.instanceConstructorId;
62215
+ const constructorArgs = value.constructorArgs;
62216
+ if (classId === null || typeof constructorId !== "string" || !isObjectRecord2(constructorArgs)) {
62217
+ continue;
62218
+ }
62219
+ const constructor2 = constructors.get(constructorId);
62220
+ const parameters = constructor2?.argumentTypes;
62221
+ if (constructor2 === void 0 || constructor2.classId !== classId || !Array.isArray(parameters)) {
62222
+ continue;
62223
+ }
62224
+ for (const [index, parameter4] of parameters.entries()) {
62225
+ if (!isObjectRecord2(parameter4) || typeof parameter4.name !== "string") {
62226
+ continue;
62227
+ }
62228
+ const settled = resolveSettlement(classId, parameter4.name, constructorId);
62229
+ if (settled === null) continue;
62230
+ if (isObjectRecord2(body) && Object.hasOwn(body, settled.schemaKey)) {
62231
+ continue;
62232
+ }
62233
+ const parameterId = constructorActionParameterId(constructor2, index);
62234
+ const childValueId = constructorArgs[parameterId];
62235
+ if (typeof childValueId !== "string" || !values.has(childValueId) || !memberStoresAggregate(
62236
+ memberDataById.get(settled.memberId),
62237
+ value,
62238
+ memberDataById,
62239
+ parentValueId,
62240
+ classesById2,
62241
+ variantTargetClassByRootValueId
62242
+ )) {
62243
+ continue;
62244
+ }
62245
+ add({
62246
+ childValueId,
62247
+ memberId: settled.memberId,
62248
+ parentValueId,
62249
+ schemaKey: settled.schemaKey,
62250
+ source: "constructor"
62251
+ });
62252
+ }
62253
+ }
62254
+ return { childrenByParentValueId, placementByChildValueId };
62255
+ }
62256
+ function memberStoresAggregate(member, parent, membersById2, parentValueId, classesById2, variantTargetClassByRootValueId, visitedMemberIds = /* @__PURE__ */ new Set()) {
62257
+ const kind = member?.kind;
62258
+ if (kind === 5 /* Dictionary */ || kind === 6 /* List */ || kind === 7 /* Class */ || kind === "dictionary" || kind === "list" || kind === "class") {
62259
+ return true;
62260
+ }
62261
+ if (kind !== 21 /* Generic */ && kind !== "generic") return false;
62262
+ const memberId = typeof member?.id === "string" ? member.id : null;
62263
+ if (memberId !== null && visitedMemberIds.has(memberId)) return false;
62264
+ const genericParamId = member?.genericParamId;
62265
+ const bindings = parent.genericBindings;
62266
+ if (typeof genericParamId === "string" && isObjectRecord2(bindings)) {
62267
+ const bindingMemberId = bindings[genericParamId];
62268
+ if (typeof bindingMemberId === "string") {
62269
+ return memberStoresAggregate(
62270
+ membersById2.get(bindingMemberId),
62271
+ parent,
62272
+ membersById2,
62273
+ parentValueId,
62274
+ classesById2,
62275
+ variantTargetClassByRootValueId,
62276
+ /* @__PURE__ */ new Set([
62277
+ ...visitedMemberIds,
62278
+ ...memberId === null ? [] : [memberId]
62279
+ ])
62280
+ );
62281
+ }
62282
+ }
62283
+ const parentClassId = parent.classId;
62284
+ const variantTargetClassId = variantTargetClassByRootValueId.get(parentValueId);
62285
+ if (typeof parentClassId === "string" && typeof variantTargetClassId === "string" && classesById2.get(parentClassId)?.genericParamIds?.[0] === genericParamId && classesById2.has(variantTargetClassId)) {
62286
+ return true;
62287
+ }
62288
+ return false;
62289
+ }
62290
+ function isStringRecord2(value) {
62291
+ return isObjectRecord2(value) && Object.values(value).every((entry) => typeof entry === "string");
62292
+ }
62293
+ var init_stored_value_placements = __esm({
62294
+ "src/project-source/stored-value-placements.ts"() {
62295
+ "use strict";
62296
+ init_constructors2();
62297
+ init_constructor_parameter_settlement();
62298
+ init_members();
62299
+ init_projection();
62300
+ }
62301
+ });
62302
+
61810
62303
  // src/project-source/root-value-paths.ts
61811
- function rootValuePathsByValueId(records2) {
61812
- const indexed = indexRecords(records2);
62304
+ function rootValuePathsByValueId(records2, storedPlacements) {
62305
+ const allRecords = [...records2];
62306
+ const indexed = indexRecords(allRecords);
62307
+ const placements = storedPlacements ?? buildStoredValuePlacementIndexV4(allRecords);
61813
62308
  const paths = /* @__PURE__ */ new Map();
61814
62309
  const queue = [];
61815
62310
  for (const [field, slot] of ROOT_PROJECT_FIELDS) {
@@ -61825,19 +62320,18 @@ function rootValuePathsByValueId(records2) {
61825
62320
  if (next === void 0) break;
61826
62321
  if (paths.has(next.id)) continue;
61827
62322
  paths.set(next.id, next.path);
61828
- const body = indexed.values.get(next.id)?.value;
61829
- if (!isObjectRecord3(body)) continue;
61830
- for (const [schemaKey, child] of Object.entries(body)) {
61831
- if (typeof child !== "string") continue;
61832
- if (!indexed.values.has(child)) continue;
61833
- queue.push({ id: child, path: `${next.path}.${schemaKey}` });
62323
+ for (const edge of placements.childrenByParentValueId.get(next.id)?.values() ?? []) {
62324
+ queue.push({
62325
+ id: edge.childValueId,
62326
+ path: `${next.path}.${edge.schemaKey}`
62327
+ });
61834
62328
  }
61835
62329
  }
61836
62330
  return paths;
61837
62331
  }
61838
- function rootValueTargetsByPath(records2) {
62332
+ function rootValueTargetsByPath(records2, storedPlacements) {
61839
62333
  const allRecords = [...records2];
61840
- const paths = rootValuePathsByValueId(allRecords);
62334
+ const paths = rootValuePathsByValueId(allRecords, storedPlacements);
61841
62335
  const values = new Map(
61842
62336
  allRecords.flatMap(
61843
62337
  (record3) => !record3.deleted && record3.recordKind === "value" && isObjectRecord3(record3.data) ? [[record3.recordId, record3.data]] : []
@@ -61855,17 +62349,14 @@ function rootValueTargetsByPath(records2) {
61855
62349
  function indexRecords(records2) {
61856
62350
  let project;
61857
62351
  const members = /* @__PURE__ */ new Map();
61858
- const values = /* @__PURE__ */ new Map();
61859
62352
  for (const record3 of records2) {
61860
62353
  if (record3.deleted || !isObjectRecord3(record3.data)) continue;
61861
62354
  if (record3.recordKind === "project") project ??= record3.data;
61862
62355
  else if (record3.recordKind === "member") {
61863
62356
  members.set(record3.recordId, record3.data);
61864
- } else if (record3.recordKind === "value") {
61865
- values.set(record3.recordId, record3.data);
61866
62357
  }
61867
62358
  }
61868
- return { project, members, values };
62359
+ return { project, members };
61869
62360
  }
61870
62361
  function isObjectRecord3(value) {
61871
62362
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -61874,6 +62365,7 @@ var ROOT_PROJECT_FIELDS;
61874
62365
  var init_root_value_paths = __esm({
61875
62366
  "src/project-source/root-value-paths.ts"() {
61876
62367
  "use strict";
62368
+ init_stored_value_placements();
61877
62369
  ROOT_PROJECT_FIELDS = [
61878
62370
  ["rootAssetsMemberId", "Assets"],
61879
62371
  ["rootSaveFileMemberId", "Save"],
@@ -63504,7 +63996,12 @@ function compileNSInitializer(code, ctx) {
63504
63996
  `return
63505
63997
  ${code};`,
63506
63998
  createContext(
63507
- { ...compilerContext, thisClass: lexicalThisClass ?? null },
63999
+ {
64000
+ ...compilerContext,
64001
+ thisClass: lexicalThisClass ?? null,
64002
+ implicitMemberAccess: lexicalThisClass !== null,
64003
+ staticMember: false
64004
+ },
63508
64005
  {
63509
64006
  scriptKind: "initializer",
63510
64007
  returnTypeInfo: ctx.returnTypeInfo,
@@ -63760,9 +64257,6 @@ function initializerReferencedIdentifiers(source) {
63760
64257
  }
63761
64258
  return identifiers;
63762
64259
  }
63763
- function initializerReferencesLexicalThis(source) {
63764
- return initializerReferencedIdentifiers(source).has("this");
63765
- }
63766
64260
  function initializerReferencesAnyIdentifier(source, names) {
63767
64261
  const identifiers = initializerReferencedIdentifiers(source);
63768
64262
  for (const name of names) {
@@ -64636,7 +65130,7 @@ function isRecordValue(value) {
64636
65130
  if (Array.isArray(value)) return false;
64637
65131
  return Object.values(value).every((entry) => typeof entry === "string");
64638
65132
  }
64639
- function resolveOwnerMembersForValues(document, targetValueIds, additionalRoots, rootOwners, rootKinds) {
65133
+ function resolveOwnerMembersForValues(document, targetValueIds, additionalRoots, rootOwners, rootKinds, traversalExtension) {
64640
65134
  const resolved = /* @__PURE__ */ new Map();
64641
65135
  if (targetValueIds.size === 0) return resolved;
64642
65136
  const valuesById = new Map(document.values.map((value) => [value.id, value]));
@@ -64659,6 +65153,7 @@ function resolveOwnerMembersForValues(document, targetValueIds, additionalRoots,
64659
65153
  }
64660
65154
  }
64661
65155
  const visited = /* @__PURE__ */ new Set();
65156
+ const discoveredRoots = [];
64662
65157
  const declaringClassIdByMemberId = /* @__PURE__ */ new Map();
64663
65158
  for (const schemaClass2 of document.classes) {
64664
65159
  for (const memberId of Object.values(schemaClass2.schema)) {
@@ -64701,6 +65196,14 @@ function resolveOwnerMembersForValues(document, targetValueIds, additionalRoots,
64701
65196
  visited.add(valueId);
64702
65197
  const value = valuesById.get(valueId);
64703
65198
  if (value === void 0) return;
65199
+ discoveredRoots.push(
65200
+ ...traversalExtension?.({
65201
+ member,
65202
+ valueId,
65203
+ rootOwner,
65204
+ rootKind
65205
+ }) ?? []
65206
+ );
64704
65207
  searchChildren(
64705
65208
  member,
64706
65209
  rootOwner,
@@ -64781,18 +65284,23 @@ function resolveOwnerMembersForValues(document, targetValueIds, additionalRoots,
64781
65284
  return;
64782
65285
  }
64783
65286
  }
64784
- function searchRootMember(member, valueId, rootKind) {
65287
+ function searchRootMember(member, valueId, rootKind, rootOwner = member) {
64785
65288
  const env = declaringClassEnv(member);
64786
65289
  searchRow(
64787
65290
  trySubstituteMember(member, env) ?? member,
64788
65291
  valueId,
64789
- member,
65292
+ rootOwner,
64790
65293
  env,
64791
65294
  rootKind
64792
65295
  );
64793
65296
  }
64794
65297
  for (const root of additionalRoots ?? []) {
64795
- searchRootMember(root.member, root.valueId, "instance");
65298
+ searchRootMember(
65299
+ root.member,
65300
+ root.valueId,
65301
+ root.rootKind ?? "instance",
65302
+ root.rootOwner
65303
+ );
64796
65304
  }
64797
65305
  for (const member of document.members) {
64798
65306
  if (typeof member.valueId !== "string") continue;
@@ -64817,6 +65325,16 @@ function resolveOwnerMembersForValues(document, targetValueIds, additionalRoots,
64817
65325
  "declaration"
64818
65326
  );
64819
65327
  }
65328
+ for (let cursor = 0; cursor < discoveredRoots.length; cursor += 1) {
65329
+ const root = discoveredRoots[cursor];
65330
+ if (root === void 0) continue;
65331
+ searchRootMember(
65332
+ root.member,
65333
+ root.valueId,
65334
+ root.rootKind ?? "instance",
65335
+ root.rootOwner
65336
+ );
65337
+ }
64820
65338
  return resolved;
64821
65339
  }
64822
65340
  var init_value_row_owner_members = __esm({
@@ -64830,21 +65348,91 @@ var init_value_row_owner_members = __esm({
64830
65348
  });
64831
65349
 
64832
65350
  // ../src/database/constructor-argument-ownership.ts
64833
- function constructorActionParameterId(constructor2, index) {
64834
- const action = constructor2.action;
64835
- if (action !== null && typeof action === "object") {
64836
- const parameters = action.parameters;
64837
- if (Array.isArray(parameters)) {
64838
- const parameter4 = parameters[index + 2];
64839
- if (parameter4 !== null && typeof parameter4 === "object" && typeof parameter4.id === "string") {
64840
- return parameter4.id;
65351
+ function resolveSemanticOwnerMembersForValues(document, targetValueIds, additionalRoots, rootOwners, rootKinds) {
65352
+ const result = /* @__PURE__ */ new Map();
65353
+ if (targetValueIds.size === 0) return result;
65354
+ const directRootOwners = /* @__PURE__ */ new Map();
65355
+ const directRootKinds = /* @__PURE__ */ new Map();
65356
+ const directOwners = resolveOwnerMembersForValues(
65357
+ document,
65358
+ targetValueIds,
65359
+ additionalRoots,
65360
+ directRootOwners,
65361
+ directRootKinds
65362
+ );
65363
+ if (targetValueIds.size === directOwners.size) {
65364
+ for (const valueId of targetValueIds) {
65365
+ const owner = directOwners.get(valueId);
65366
+ if (owner === void 0) continue;
65367
+ result.set(valueId, owner);
65368
+ const rootOwner = directRootOwners.get(valueId);
65369
+ if (rootOwner !== void 0) rootOwners?.set(valueId, rootOwner);
65370
+ const rootKind = directRootKinds.get(valueId);
65371
+ if (rootKind !== void 0) rootKinds?.set(valueId, rootKind);
65372
+ }
65373
+ return result;
65374
+ }
65375
+ const graph = new MaterializedValueGraphContext(document);
65376
+ const allValueIds = new Set(graph.valuesById.keys());
65377
+ const semanticRoots = [
65378
+ ...additionalRoots ?? []
65379
+ ];
65380
+ const semanticRootIds = new Set(semanticRoots.map((root) => root.valueId));
65381
+ const bodyRootOwners = /* @__PURE__ */ new Map();
65382
+ const bodyRootKinds = /* @__PURE__ */ new Map();
65383
+ const bodyOwners = resolveOwnerMembersForValues(
65384
+ document,
65385
+ allValueIds,
65386
+ additionalRoots,
65387
+ bodyRootOwners,
65388
+ bodyRootKinds
65389
+ );
65390
+ const allRootOwners = new Map(bodyRootOwners);
65391
+ const allRootKinds = new Map(bodyRootKinds);
65392
+ const owners = resolveOwnerMembersForValues(
65393
+ document,
65394
+ allValueIds,
65395
+ semanticRoots,
65396
+ allRootOwners,
65397
+ allRootKinds,
65398
+ ({ valueId: ownerValueId, rootOwner, rootKind }) => {
65399
+ const roots = [];
65400
+ for (const edge of graph.edgesByOwnerValueId.get(ownerValueId) ?? []) {
65401
+ if (graph.referenceCountByTargetValueId.get(edge.targetValueId) !== 1) {
65402
+ continue;
65403
+ }
65404
+ if (bodyOwners.has(edge.targetValueId)) continue;
65405
+ if (semanticRootIds.has(edge.targetValueId)) continue;
65406
+ const member = graph.constructorArgumentOwnerMember(edge);
65407
+ if (member === void 0) continue;
65408
+ semanticRootIds.add(edge.targetValueId);
65409
+ roots.push({
65410
+ member,
65411
+ valueId: edge.targetValueId,
65412
+ rootOwner,
65413
+ rootKind
65414
+ });
64841
65415
  }
65416
+ return roots;
64842
65417
  }
65418
+ );
65419
+ for (const [valueId, owner] of bodyOwners) owners.set(valueId, owner);
65420
+ for (const [valueId, owner] of bodyRootOwners) {
65421
+ allRootOwners.set(valueId, owner);
64843
65422
  }
64844
- return `__arg_${index}__`;
64845
- }
64846
- function constructorArgumentAggregateEdgesForValue(document, row) {
64847
- return [...new MaterializedValueGraphContext(document).constructorEdges(row)];
65423
+ for (const [valueId, kind] of bodyRootKinds) {
65424
+ allRootKinds.set(valueId, kind);
65425
+ }
65426
+ for (const valueId of targetValueIds) {
65427
+ const owner = owners.get(valueId);
65428
+ if (owner === void 0) continue;
65429
+ result.set(valueId, owner);
65430
+ const rootOwner = allRootOwners.get(valueId);
65431
+ if (rootOwner !== void 0) rootOwners?.set(valueId, rootOwner);
65432
+ const rootKind = allRootKinds.get(valueId);
65433
+ if (rootKind !== void 0) rootKinds?.set(valueId, rootKind);
65434
+ }
65435
+ return result;
64848
65436
  }
64849
65437
  function createTypedValueNormalizer(rows, document, childrenByContainerId, parameterTypesForRow, memberById2, memberTypeInfo) {
64850
65438
  const visiting = /* @__PURE__ */ new Set();
@@ -64858,6 +65446,16 @@ function createTypedValueNormalizer(rows, document, childrenByContainerId, param
64858
65446
  ])
64859
65447
  );
64860
65448
  };
65449
+ const normalizeTypedLiteral = (value, typeInfo) => {
65450
+ if (typeInfo.type === 25 /* NSDelegate */ && value !== null && typeof value === "object" && !Array.isArray(value) && typeof Reflect.get(value, "code") === "string") {
65451
+ const captures = Reflect.get(value, "captures");
65452
+ return {
65453
+ code: Reflect.get(value, "code"),
65454
+ ...captures === void 0 ? {} : { captures: normalizeLiteral(captures) }
65455
+ };
65456
+ }
65457
+ return normalizeLiteral(value);
65458
+ };
64861
65459
  const normalizeTypedRow = (valueId, typeInfo) => {
64862
65460
  const row = rows.get(valueId);
64863
65461
  if (row === void 0) return valueId;
@@ -64875,7 +65473,7 @@ function createTypedValueNormalizer(rows, document, childrenByContainerId, param
64875
65473
  ) : Array.isArray(row.value) ? row.value.map(
64876
65474
  (childId) => typeof childId === "string" ? normalizeTypedRow(childId, typeInfo.entryTypeInfo) : normalizeLiteral(childId)
64877
65475
  ) : normalizeLiteral(row.value);
64878
- } else if (typeInfo.type === 5 /* Dictionary */ && isStringRecord2(row.value)) {
65476
+ } else if (typeInfo.type === 5 /* Dictionary */ && isStringRecord3(row.value)) {
64879
65477
  value = Object.fromEntries(
64880
65478
  Object.entries(row.value).map(([key, childId]) => [
64881
65479
  key,
@@ -64883,7 +65481,7 @@ function createTypedValueNormalizer(rows, document, childrenByContainerId, param
64883
65481
  ])
64884
65482
  );
64885
65483
  } else {
64886
- value = normalizeLiteral(row.value);
65484
+ value = normalizeTypedLiteral(row.value, typeInfo);
64887
65485
  }
64888
65486
  const normalized = {
64889
65487
  ...typeof row.classId === "string" ? { classId: row.classId } : {},
@@ -64917,7 +65515,7 @@ function createTypedValueNormalizer(rows, document, childrenByContainerId, param
64917
65515
  return normalized;
64918
65516
  };
64919
65517
  const normalizeClassValue = (row, typeInfo) => {
64920
- if (!isStringRecord2(row.value)) return normalizeLiteral(row.value);
65518
+ if (!isStringRecord3(row.value)) return normalizeLiteral(row.value);
64921
65519
  const effectiveClassId = row.classId ?? (typeInfo.type === 7 /* Class */ ? typeInfo.classId : void 0);
64922
65520
  if (effectiveClassId === void 0) return normalizeLiteral(row.value);
64923
65521
  const env = rowGenericEnvironment(document, row);
@@ -64952,7 +65550,10 @@ function createTypedValueNormalizer(rows, document, childrenByContainerId, param
64952
65550
  Object.entries(constructorArgs).map(([parameterId, value]) => {
64953
65551
  const typeInfo = parameterTypes.get(parameterId);
64954
65552
  if (typeInfo === void 0 || !isAggregateTypeInfo(typeInfo) || typeof value !== "string") {
64955
- return [parameterId, normalizeLiteral(value)];
65553
+ return [
65554
+ parameterId,
65555
+ typeInfo === void 0 ? normalizeLiteral(value) : normalizeTypedLiteral(value, typeInfo)
65556
+ ];
64956
65557
  }
64957
65558
  return [parameterId, normalizeTypedRow(value, typeInfo)];
64958
65559
  })
@@ -65002,7 +65603,7 @@ function collectSoftOwnedConstructorArgumentValueIds(index, ownerValueId, preser
65002
65603
  collectTypedRow(childId, typeInfo.entryTypeInfo);
65003
65604
  }
65004
65605
  }
65005
- } else if (typeInfo.type === 5 /* Dictionary */ && isStringRecord2(row.value)) {
65606
+ } else if (typeInfo.type === 5 /* Dictionary */ && isStringRecord3(row.value)) {
65006
65607
  for (const childId of Object.values(row.value)) {
65007
65608
  collectTypedRow(childId, typeInfo.entryTypeInfo);
65008
65609
  }
@@ -65024,7 +65625,7 @@ function collectSoftOwnedConstructorArgumentValueIds(index, ownerValueId, preser
65024
65625
  collectNestedConstructorArguments(valueId);
65025
65626
  };
65026
65627
  const collectClassChildren = (row, typeInfo) => {
65027
- if (!isStringRecord2(row.value)) return;
65628
+ if (!isStringRecord3(row.value)) return;
65028
65629
  const effectiveClassId = row.classId ?? (typeInfo.type === 7 /* Class */ ? typeInfo.classId : void 0);
65029
65630
  if (effectiveClassId === void 0) return;
65030
65631
  const env = rowGenericEnvironment(index.document, row);
@@ -65093,7 +65694,7 @@ function tryMemberTypeInfo(document, rawMember, env) {
65093
65694
  function isAggregateTypeInfo(typeInfo) {
65094
65695
  return typeInfo.type === 7 /* Class */ || typeInfo.type === 22 /* Interface */ || typeInfo.type === 6 /* List */ || typeInfo.type === 5 /* Dictionary */;
65095
65696
  }
65096
- function isStringRecord2(value) {
65697
+ function isStringRecord3(value) {
65097
65698
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
65098
65699
  return false;
65099
65700
  }
@@ -65118,7 +65719,10 @@ var init_constructor_argument_ownership = __esm({
65118
65719
  "use strict";
65119
65720
  init_members();
65120
65721
  init_inheritance();
65722
+ init_constructor_parameter_settlement();
65723
+ init_constructors2();
65121
65724
  init_generics();
65725
+ init_core();
65122
65726
  init_compile_ns_property();
65123
65727
  init_value_row_owner_members();
65124
65728
  MaterializedValueGraphContext = class {
@@ -65136,6 +65740,7 @@ var init_constructor_argument_ownership = __esm({
65136
65740
  membersById;
65137
65741
  constructorsById;
65138
65742
  parameterTypesByValueId = /* @__PURE__ */ new Map();
65743
+ settleConstructorParameter;
65139
65744
  aggregateTypeByTargetValueId = /* @__PURE__ */ new Map();
65140
65745
  typedNormalizer;
65141
65746
  ownership;
@@ -65194,9 +65799,8 @@ var init_constructor_argument_ownership = __esm({
65194
65799
  if (typeof root.classId !== "string") {
65195
65800
  return result;
65196
65801
  }
65197
- const schemaClass2 = this.classesById.get(root.classId);
65198
- const constructorId = root.instanceConstructorId !== void 0 ? root.instanceConstructorId : schemaClass2?.requiredConstructorId;
65199
- if (constructorId === void 0 || constructorId === null) {
65802
+ const constructorId = root.instanceConstructorId;
65803
+ if (typeof constructorId !== "string") {
65200
65804
  return result;
65201
65805
  }
65202
65806
  const constructor2 = this.constructorsById.get(constructorId);
@@ -65232,6 +65836,49 @@ var init_constructor_argument_ownership = __esm({
65232
65836
  }
65233
65837
  return edges;
65234
65838
  }
65839
+ /** Schema field whose declared initializer one aggregate constructor argument settles. */
65840
+ constructorArgumentOwnerPlacement(edge) {
65841
+ const owner = this.valuesById.get(edge.ownerValueId);
65842
+ if (owner === void 0) return void 0;
65843
+ if (typeof owner.classId !== "string") return void 0;
65844
+ if (typeof owner.instanceConstructorId !== "string") return void 0;
65845
+ const constructor2 = this.constructorsById.get(owner.instanceConstructorId);
65846
+ if (constructor2 === void 0) return void 0;
65847
+ if (constructor2.classId !== owner.classId) return void 0;
65848
+ const parameterIndex = constructor2.argumentTypes.findIndex(
65849
+ (_, index) => constructorActionParameterId(constructor2, index) === edge.parameterId
65850
+ );
65851
+ if (parameterIndex === -1) return void 0;
65852
+ const parameter4 = constructor2.argumentTypes[parameterIndex];
65853
+ if (parameter4 === void 0) return void 0;
65854
+ this.settleConstructorParameter ??= createConstructorSettlementResolver(
65855
+ this.document
65856
+ );
65857
+ const settled = this.settleConstructorParameter(
65858
+ owner.classId,
65859
+ parameter4.name,
65860
+ owner.instanceConstructorId
65861
+ );
65862
+ if (settled === null) return void 0;
65863
+ const member = this.membersById.get(settled.memberId);
65864
+ if (member === void 0) return void 0;
65865
+ try {
65866
+ return {
65867
+ ...settled,
65868
+ member: substituteMember(
65869
+ member,
65870
+ rowGenericEnvironment(this.document, owner),
65871
+ this.document.members
65872
+ )
65873
+ };
65874
+ } catch {
65875
+ return void 0;
65876
+ }
65877
+ }
65878
+ /** Member whose declared initializer one aggregate constructor argument settles. */
65879
+ constructorArgumentOwnerMember(edge) {
65880
+ return this.constructorArgumentOwnerPlacement(edge)?.member;
65881
+ }
65235
65882
  normalizeConstructorArguments(constructorArgs, root) {
65236
65883
  return this.normalizer().normalizeConstructorArgs(constructorArgs, root);
65237
65884
  }
@@ -67939,6 +68586,10 @@ function parameterDefaultRuntimeValue(parameter4, subject) {
67939
68586
  if (parameter4.type === 8 /* Enum */) return [defaultValue.value];
67940
68587
  return defaultValue.value;
67941
68588
  }
68589
+ function parameterDefaultsAsFullArguments(argumentTypes, subject) {
68590
+ if (!argumentTypes.every(parameterHasDefault)) return null;
68591
+ return fillTrailingParameterDefaults([], argumentTypes, subject);
68592
+ }
67942
68593
  function fillCallableCallSiteArguments(args, member, ctx) {
67943
68594
  if (member === null) return args;
67944
68595
  if (member.kind !== 13 /* Function */ && member.kind !== 23 /* NSFunction */) {
@@ -73115,15 +73766,21 @@ function evaluateInitializerInContext(init, member, ctx, createdValues, argument
73115
73766
  deleteRuntimeSessionValue(ctx, rootRow.id);
73116
73767
  ctx.__executionState?.constructorGroups.delete(rootRow.id);
73117
73768
  const constructorArgs = typeof result.value === "object" && result.value !== null ? ctx.__constructedArgumentsByValue.get(result.value) : void 0;
73769
+ const provenance = pickInstanceProvenance({
73770
+ constructorArgs,
73771
+ instanceConstructorId: rootRow.instanceConstructorId,
73772
+ instanceVariantId: rootRow.instanceVariantId,
73773
+ instanceVariantRowValueId: rootRow.instanceVariantRowValueId
73774
+ });
73118
73775
  return {
73119
73776
  value: result.value,
73120
73777
  classId: rootRow.classId ?? null,
73121
73778
  ...rootRow.genericBindings === void 0 ? {} : { genericBindings: { ...rootRow.genericBindings } },
73122
73779
  provisionalRootId: rootRow.id,
73123
- ...constructorArgs === void 0 ? {} : { constructorArgs: deepClonePlainData(constructorArgs) },
73124
- ...rootRow.instanceConstructorId === void 0 ? {} : { instanceConstructorId: rootRow.instanceConstructorId },
73125
- ...rootRow.instanceVariantId === void 0 ? {} : { instanceVariantId: rootRow.instanceVariantId },
73126
- ...rootRow.instanceVariantRowValueId === void 0 ? {} : { instanceVariantRowValueId: rootRow.instanceVariantRowValueId }
73780
+ ...provenance,
73781
+ ...provenance.constructorArgs === void 0 ? {} : {
73782
+ constructorArgs: deepClonePlainData(provenance.constructorArgs)
73783
+ }
73127
73784
  };
73128
73785
  }
73129
73786
  function encodeLookupInitializerResult(member, value, created, ctx) {
@@ -75304,6 +75961,14 @@ function buildStoredValuePlacementIndex(args) {
75304
75961
  for (const entries of unorderedEntriesByContainerId.values()) {
75305
75962
  entries.sort((left, right) => left.id.localeCompare(right.id));
75306
75963
  }
75964
+ const constructorsById = new Map(
75965
+ args.constructors.map((constructor2) => [constructor2.id, constructor2])
75966
+ );
75967
+ const resolveConstructorSettlement = createConstructorSettlementResolver({
75968
+ classes: args.classes,
75969
+ constructors: args.constructors,
75970
+ members: args.members
75971
+ });
75307
75972
  const resolvedMemberById = /* @__PURE__ */ new Map();
75308
75973
  const resolvedMember = (member) => {
75309
75974
  const cached = resolvedMemberById.get(member.id);
@@ -75377,10 +76042,30 @@ function buildStoredValuePlacementIndex(args) {
75377
76042
  if (isMemberClassBase(member)) {
75378
76043
  const classId = value.classId ?? member.classId;
75379
76044
  appendPlacement(mutablePlacementsByClassId, classId, placement);
75380
- if (!isStringRecord3(value.value)) continue;
76045
+ if (!isLiteralValueContent(value) || !isStringRecord4(value.value)) {
76046
+ continue;
76047
+ }
76048
+ const settledChildrenBySchemaKey = /* @__PURE__ */ new Map();
76049
+ const constructor2 = typeof value.instanceConstructorId === "string" ? constructorsById.get(value.instanceConstructorId) : void 0;
76050
+ if (constructor2 !== void 0 && constructor2.classId === classId && value.constructorArgs != null) {
76051
+ for (const [index, parameter4] of constructor2.argumentTypes.entries()) {
76052
+ const settled = resolveConstructorSettlement(
76053
+ classId,
76054
+ parameter4.name,
76055
+ constructor2.id
76056
+ );
76057
+ if (settled === null || Object.hasOwn(value.value, settled.schemaKey)) {
76058
+ continue;
76059
+ }
76060
+ const childValueId = value.constructorArgs[constructorActionParameterId(constructor2, index)];
76061
+ if (typeof childValueId === "string" && valuesById.has(childValueId)) {
76062
+ settledChildrenBySchemaKey.set(settled.schemaKey, childValueId);
76063
+ }
76064
+ }
76065
+ }
75381
76066
  for (const entry of storedSchema(classId)) {
75382
76067
  const childMember = membersById2.get(entry.memberId);
75383
- const childValueId = value.value[entry.schemaKey];
76068
+ const childValueId = value.value[entry.schemaKey] ?? settledChildrenBySchemaKey.get(entry.schemaKey);
75384
76069
  if (childMember === void 0 || typeof childValueId !== "string") {
75385
76070
  continue;
75386
76071
  }
@@ -75400,7 +76085,7 @@ function buildStoredValuePlacementIndex(args) {
75400
76085
  const entryMember = membersById2.get(member.entryMemberId);
75401
76086
  if (entryMember === void 0) continue;
75402
76087
  if (isMemberDictionaryBase(member)) {
75403
- if (!isStringRecord3(value.value)) continue;
76088
+ if (!isStringRecord4(value.value)) continue;
75404
76089
  for (const [key, childValueId] of Object.entries(value.value)) {
75405
76090
  queue.push({
75406
76091
  memberId: entryMember.id,
@@ -75448,7 +76133,7 @@ function appendPlacement(index, key, placement) {
75448
76133
  placements.push(placement);
75449
76134
  }
75450
76135
  }
75451
- function isStringRecord3(value) {
76136
+ function isStringRecord4(value) {
75452
76137
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
75453
76138
  return false;
75454
76139
  }
@@ -75458,6 +76143,8 @@ var init_stored_value_placement_index = __esm({
75458
76143
  "../src/models/members/stored-value-placement-index.ts"() {
75459
76144
  "use strict";
75460
76145
  init_inheritance();
76146
+ init_constructor_parameter_settlement();
76147
+ init_constructors2();
75461
76148
  init_project2();
75462
76149
  init_member_kinds();
75463
76150
  }
@@ -75747,6 +76434,46 @@ function resolveVirtualInstanceGraph(args) {
75747
76434
  (args.materializedRows ?? args.document.values).map((row) => [row.id, row])
75748
76435
  );
75749
76436
  const materializedRows = [...materializedById.values()];
76437
+ const materializedGraph = args.materializedGraph ?? new MaterializedValueGraphContext(
76438
+ { ...args.document, values: materializedRows },
76439
+ materializedById
76440
+ );
76441
+ const constructorsById = new Map(
76442
+ (args.document.constructors ?? []).map((constructor2) => [
76443
+ constructor2.id,
76444
+ constructor2
76445
+ ])
76446
+ );
76447
+ const resolveConstructorSettlement = createConstructorSettlementResolver({
76448
+ classes: args.document.classes,
76449
+ constructors: args.document.constructors ?? [],
76450
+ members: args.document.members
76451
+ });
76452
+ const settledAggregateChildren = (row, classId) => {
76453
+ if (!isLiteralValueContent(row)) return /* @__PURE__ */ new Map();
76454
+ if (typeof row.instanceConstructorId !== "string") return /* @__PURE__ */ new Map();
76455
+ const constructor2 = constructorsById.get(row.instanceConstructorId);
76456
+ if (constructor2 === void 0) return /* @__PURE__ */ new Map();
76457
+ const edgeByParameterId = new Map(
76458
+ materializedGraph.constructorEdges(row).map((edge) => [edge.parameterId, edge])
76459
+ );
76460
+ const result = /* @__PURE__ */ new Map();
76461
+ for (const [index, parameter4] of constructor2.argumentTypes.entries()) {
76462
+ const edge = edgeByParameterId.get(
76463
+ constructorActionParameterId(constructor2, index)
76464
+ );
76465
+ if (edge === void 0) continue;
76466
+ const settled = resolveConstructorSettlement(
76467
+ classId,
76468
+ parameter4.name,
76469
+ row.instanceConstructorId
76470
+ );
76471
+ if (settled !== null) {
76472
+ result.set(settled.schemaKey, edge.targetValueId);
76473
+ }
76474
+ }
76475
+ return result;
76476
+ };
75750
76477
  const materializedUnorderedEntryIdsByContainerId = buildUnorderedListMembershipIndex(materializedRows);
75751
76478
  const readMaterializedRow = (valueId) => {
75752
76479
  recorder?.recordValueRead(valueId);
@@ -75791,8 +76518,9 @@ function resolveVirtualInstanceGraph(args) {
75791
76518
  };
75792
76519
  if (isMemberClassBase(indexed.member) && effective.value !== null) {
75793
76520
  const storedRecord = stringRecord2(materialized?.value);
75794
- const effectiveRecord = {};
75795
76521
  const classId = effective.classId ?? indexed.member.classId;
76522
+ const constructedChildren = materialized === null ? /* @__PURE__ */ new Map() : settledAggregateChildren(materialized, classId);
76523
+ const effectiveRecord = {};
75796
76524
  const schema = mergeStoredInstanceSchema(
75797
76525
  classId,
75798
76526
  args.document.classes,
@@ -75804,7 +76532,7 @@ function resolveVirtualInstanceGraph(args) {
75804
76532
  schemaKey: entry.schemaKey
75805
76533
  });
75806
76534
  if (!expansion.nodesByPath.has(childPath)) continue;
75807
- const storedChildId = storedRecord[entry.schemaKey] ?? null;
76535
+ const storedChildId = storedRecord[entry.schemaKey] ?? constructedChildren.get(entry.schemaKey) ?? null;
75808
76536
  const child = resolvePath(childPath, storedChildId, effectiveId);
75809
76537
  effectiveRecord[entry.schemaKey] = child.id;
75810
76538
  }
@@ -76619,21 +77347,24 @@ function sparsifyConstructedInstance(args) {
76619
77347
  args.constructed.root,
76620
77348
  ...args.constructed.createdChildren
76621
77349
  ];
77350
+ const constructionDocument = {
77351
+ ...args.document,
77352
+ values: materializedRows
77353
+ };
77354
+ const materializedGraph = new MaterializedValueGraphContext(
77355
+ constructionDocument
77356
+ );
76622
77357
  const graph = resolveVirtualInstanceGraph({
76623
77358
  document: args.document,
76624
77359
  instanceRoot: args.constructed.root,
76625
77360
  rootMember: args.rootMember,
76626
77361
  expandedRoot: args.baseline.root,
76627
77362
  expandedRows: [args.baseline.root, ...args.baseline.createdChildren],
76628
- materializedRows
77363
+ materializedRows,
77364
+ materializedGraph
76629
77365
  });
76630
77366
  const protectedValueIds = /* @__PURE__ */ new Set();
76631
- const constructionDocument = {
76632
- ...args.document,
76633
- values: materializedRows
76634
- };
76635
- for (const edge of constructorArgumentAggregateEdgesForValue(
76636
- constructionDocument,
77367
+ for (const edge of materializedGraph.constructorEdges(
76637
77368
  args.constructed.root
76638
77369
  )) {
76639
77370
  protectedValueIds.add(edge.targetValueId);
@@ -76658,7 +77389,9 @@ function sparsifyConstructedInstance(args) {
76658
77389
  (row) => !deletedIds.has(row.id)
76659
77390
  );
76660
77391
  const nextIdById = /* @__PURE__ */ new Map();
77392
+ const claimedVirtualIds = /* @__PURE__ */ new Map();
76661
77393
  for (const location3 of graph.locationsByPath.values()) {
77394
+ claimedVirtualIds.set(location3.virtualRow.id, location3.pathKey);
76662
77395
  const real = location3.materializedRow;
76663
77396
  if (real === null || deletedIds.has(real.id)) continue;
76664
77397
  nextIdById.set(
@@ -76670,6 +77403,36 @@ function sparsifyConstructedInstance(args) {
76670
77403
  );
76671
77404
  }
76672
77405
  nextIdById.set(args.constructed.root.id, args.constructed.root.id);
77406
+ const unmappedRows = retainedRows.filter((row) => !nextIdById.has(row.id));
77407
+ const fallbackRows = (unmappedRows.length === 0 ? [] : (() => {
77408
+ const fallbackPaths = materializedFallbackPaths(
77409
+ materializedRows,
77410
+ graph,
77411
+ materializedGraph
77412
+ );
77413
+ return unmappedRows.flatMap((row) => {
77414
+ const path = fallbackPaths.get(row.id);
77415
+ return path === void 0 ? [] : [{ row, path }];
77416
+ });
77417
+ })()).sort(
77418
+ (left, right) => left.path.localeCompare(right.path) || left.row.id.localeCompare(right.row.id)
77419
+ );
77420
+ for (const { row, path } of fallbackRows) {
77421
+ const rawSourceIdentity = typeof row.sourceValueId === "string" && row.sourceValueId.length > 0 ? row.sourceValueId : `materialized:${path}`;
77422
+ const { sourceIdentity: sourceIdentity3, virtualId } = claimVirtualIdentity({
77423
+ claimedVirtualIds,
77424
+ instanceRootId: args.constructed.root.id,
77425
+ rawSourceIdentity,
77426
+ pathKey: path
77427
+ });
77428
+ nextIdById.set(
77429
+ row.id,
77430
+ args.virtualValueIdForSource?.(
77431
+ args.constructed.root.id,
77432
+ sourceIdentity3
77433
+ ) ?? virtualId
77434
+ );
77435
+ }
76673
77436
  const remap = (value) => {
76674
77437
  if (typeof value === "string") return nextIdById.get(value) ?? value;
76675
77438
  if (Array.isArray(value)) return value.map(remap);
@@ -76696,6 +77459,70 @@ function sparsifyConstructedInstance(args) {
76696
77459
  }
76697
77460
  return { root, createdChildren };
76698
77461
  }
77462
+ function materializedFallbackPaths(rows, graph, materializedGraph) {
77463
+ const rowsById = new Map(rows.map((row) => [row.id, row]));
77464
+ const unorderedEntriesByContainerId = buildUnorderedListMembershipIndex(rows);
77465
+ const paths = /* @__PURE__ */ new Map();
77466
+ for (const location3 of graph.locationsByPath.values()) {
77467
+ if (location3.materializedRow !== null) {
77468
+ paths.set(location3.materializedRow.id, location3.pathKey);
77469
+ }
77470
+ }
77471
+ paths.set(graph.instanceRootId, ROOT_PATH);
77472
+ let frontier = [...paths.keys()];
77473
+ while (frontier.length > 0) {
77474
+ const candidates = [];
77475
+ for (const parentId of frontier) {
77476
+ const row = rowsById.get(parentId);
77477
+ const parentPath = paths.get(parentId);
77478
+ if (row === void 0 || parentPath === void 0) continue;
77479
+ if (Array.isArray(row.value)) {
77480
+ row.value.forEach((childId, index) => {
77481
+ if (typeof childId !== "string" || !rowsById.has(childId)) return;
77482
+ candidates.push([
77483
+ childId,
77484
+ appendPath(parentPath, { kind: "list", index })
77485
+ ]);
77486
+ });
77487
+ } else if (row.value !== null && typeof row.value === "object") {
77488
+ for (const [schemaKey, childId] of Object.entries(row.value)) {
77489
+ if (typeof childId !== "string" || !rowsById.has(childId)) continue;
77490
+ candidates.push([
77491
+ childId,
77492
+ appendPath(parentPath, { kind: "class", schemaKey })
77493
+ ]);
77494
+ }
77495
+ }
77496
+ for (const [index, childId] of (unorderedEntriesByContainerId.get(row.id) ?? []).filter((childId2) => rowsById.has(childId2)).sort((left, right) => left.localeCompare(right)).entries()) {
77497
+ candidates.push([
77498
+ childId,
77499
+ appendPath(parentPath, { kind: "list", index })
77500
+ ]);
77501
+ }
77502
+ for (const edge of materializedGraph.edgesByOwnerValueId.get(row.id) ?? []) {
77503
+ if (!rowsById.has(edge.targetValueId)) continue;
77504
+ candidates.push([
77505
+ edge.targetValueId,
77506
+ appendPath(parentPath, {
77507
+ kind: "class",
77508
+ schemaKey: `@constructor:${edge.parameterId}`
77509
+ })
77510
+ ]);
77511
+ }
77512
+ }
77513
+ candidates.sort(
77514
+ (left, right) => left[1].localeCompare(right[1]) || left[0].localeCompare(right[0])
77515
+ );
77516
+ const nextFrontier = [];
77517
+ for (const [childId, path] of candidates) {
77518
+ if (paths.has(childId)) continue;
77519
+ paths.set(childId, path);
77520
+ nextFrontier.push(childId);
77521
+ }
77522
+ frontier = nextFrontier;
77523
+ }
77524
+ return paths;
77525
+ }
76699
77526
  function closeClassArgumentsFromRowStamp(member, row) {
76700
77527
  if (!isMemberClassBase(member)) return member;
76701
77528
  const stamp = row.genericBindings;
@@ -77359,6 +78186,7 @@ function resolveVariantInstanceGraphForDocument(args) {
77359
78186
  function variantSwapDeclaredMember(document, rootValueId) {
77360
78187
  const placement = buildStoredValuePlacementIndex({
77361
78188
  classes: document.classes,
78189
+ constructors: document.constructors ?? [],
77362
78190
  members: document.members,
77363
78191
  project: document.project,
77364
78192
  resolveStaticValueId: (memberId) => document.members.find((member) => member.id === memberId)?.valueId ?? null,
@@ -77372,6 +78200,7 @@ function createHeadlessVirtualInstanceResolver(args) {
77372
78200
  let placementByValueId = null;
77373
78201
  const placements = () => placementByValueId ??= buildStoredValuePlacementIndex({
77374
78202
  classes: document.classes,
78203
+ constructors: document.constructors ?? [],
77375
78204
  members: document.members,
77376
78205
  project: document.project,
77377
78206
  resolveStaticValueId: (memberId) => document.members.find((member) => member.id === memberId)?.valueId ?? null,
@@ -77463,6 +78292,7 @@ var init_virtual_instance_values = __esm({
77463
78292
  "use strict";
77464
78293
  init_deep_clone_plain_data();
77465
78294
  init_inheritance();
78295
+ init_constructor_parameter_settlement();
77466
78296
  init_generics();
77467
78297
  init_members();
77468
78298
  init_member_value_id();
@@ -77472,6 +78302,7 @@ var init_virtual_instance_values = __esm({
77472
78302
  init_neoscript();
77473
78303
  init_init_backed_value_materialization();
77474
78304
  init_constructor_argument_ownership();
78305
+ init_constructors2();
77475
78306
  init_src();
77476
78307
  KEPT_ROW_SAMPLE_LIMIT = 12;
77477
78308
  CORPUS_SCANNING_MEMBER_KINDS = /* @__PURE__ */ new Set([
@@ -77671,16 +78502,22 @@ function evaluateMemberInitializer(args) {
77671
78502
  // origin or the recipe reads as a historical unrecorded overload.
77672
78503
  rootRow.constructorArgs ?? void 0;
77673
78504
  const pinnedRootSchemaKeys = typeof result.value === "object" && result.value !== null ? ctx.__constructedFieldSchemaKeysByValue?.get(result.value) : void 0;
78505
+ const provenance = pickInstanceProvenance({
78506
+ constructorArgs,
78507
+ instanceConstructorId: rootRow.instanceConstructorId,
78508
+ instanceVariantId: rootRow.instanceVariantId,
78509
+ instanceVariantRowValueId: rootRow.instanceVariantRowValueId
78510
+ });
77674
78511
  return {
77675
78512
  value: result.value,
77676
78513
  classId: rootRow.classId ?? null,
77677
78514
  ...rootRow.genericBindings === void 0 ? {} : { genericBindings: { ...rootRow.genericBindings } },
77678
78515
  ...pinnedRootSchemaKeys === void 0 ? {} : { pinnedRootSchemaKeys },
77679
78516
  provisionalRootId: rootRow.id,
77680
- ...constructorArgs === void 0 ? {} : { constructorArgs: deepClonePlainData(constructorArgs) },
77681
- ...rootRow.instanceConstructorId === void 0 ? {} : { instanceConstructorId: rootRow.instanceConstructorId },
77682
- ...rootRow.instanceVariantId === void 0 ? {} : { instanceVariantId: rootRow.instanceVariantId },
77683
- ...rootRow.instanceVariantRowValueId === void 0 ? {} : { instanceVariantRowValueId: rootRow.instanceVariantRowValueId }
78517
+ ...provenance,
78518
+ ...provenance.constructorArgs === void 0 ? {} : {
78519
+ constructorArgs: deepClonePlainData(provenance.constructorArgs)
78520
+ }
77684
78521
  };
77685
78522
  }
77686
78523
  var evaluatorLookupsByDocument;
@@ -77688,6 +78525,7 @@ var init_evaluateInitializer = __esm({
77688
78525
  "../src/view-models/neoscript-evaluator/evaluateInitializer.ts"() {
77689
78526
  "use strict";
77690
78527
  init_deep_clone_plain_data();
78528
+ init_instance_provenance();
77691
78529
  init_members();
77692
78530
  init_project2();
77693
78531
  init_NSGetterRuntimeError();
@@ -77708,6 +78546,26 @@ var init_neoscript_evaluator = __esm({
77708
78546
  });
77709
78547
 
77710
78548
  // ../src/database/init-backed-value-materialization.ts
78549
+ function declarationInitializerContext(document) {
78550
+ const cached = declarationInitializerContextByDocument.get(document);
78551
+ if (cached !== void 0) return cached;
78552
+ const initializerValueIds = new Set(
78553
+ document.values.filter(isInitValueContent).map((value) => value.id)
78554
+ );
78555
+ const valuesById = new Map(
78556
+ document.values.map((value) => [value.id, value])
78557
+ );
78558
+ const rootOwners = /* @__PURE__ */ new Map();
78559
+ resolveOwnerMembersForValues(
78560
+ document,
78561
+ initializerValueIds,
78562
+ void 0,
78563
+ rootOwners
78564
+ );
78565
+ const created = { valuesById, rootOwners };
78566
+ declarationInitializerContextByDocument.set(document, created);
78567
+ return created;
78568
+ }
77711
78569
  function evaluateInitializerMaterialization(args) {
77712
78570
  const createdValues = [];
77713
78571
  const storageKeyDeclarations = /* @__PURE__ */ new Map();
@@ -77797,6 +78655,36 @@ function materializeInitializerValue(args) {
77797
78655
  function materializeMemberDefaultValue(args) {
77798
78656
  const createdValues = [];
77799
78657
  const storageKeyDeclarations = /* @__PURE__ */ new Map();
78658
+ const { valuesById, rootOwners } = declarationInitializerContext(
78659
+ args.document
78660
+ );
78661
+ const declarationArguments = (member, init, sourceValueId) => {
78662
+ const ownerClass = typeof sourceValueId === "string" ? initializerOwnerContext(
78663
+ args.document,
78664
+ sourceValueId,
78665
+ rootOwners,
78666
+ valuesById
78667
+ ).ownerClass : typeof Reflect.get(member, "id") === "string" ? findSchemaPlacement(
78668
+ String(Reflect.get(member, "id")),
78669
+ args.document.classes
78670
+ )?.ownerClass ?? null : null;
78671
+ if (ownerClass === null) return [];
78672
+ const constructorId = ownerClass.requiredConstructorId;
78673
+ if (typeof constructorId !== "string") return [];
78674
+ const constructor2 = args.document.constructors?.find(
78675
+ (candidate) => candidate.id === constructorId
78676
+ );
78677
+ if (constructor2 === void 0) return [];
78678
+ const defaults = parameterDefaultsAsFullArguments(
78679
+ constructor2.argumentTypes,
78680
+ `Declaration template on '${ownerClass.name}'`
78681
+ );
78682
+ if (defaults !== null) return defaults;
78683
+ const parameterNames = new Set(
78684
+ constructor2.argumentTypes.map((argument2) => argument2.name)
78685
+ );
78686
+ return initializerReferencesAnyIdentifier(init.code, parameterNames) ? [] : constructor2.argumentTypes.map(() => null);
78687
+ };
77800
78688
  const built = buildDefaultMemberValue({
77801
78689
  document: args.document,
77802
78690
  projectId: args.envelope.projectId,
@@ -77806,11 +78694,17 @@ function materializeMemberDefaultValue(args) {
77806
78694
  ...args.genericEnv === void 0 ? {} : { genericEnv: args.genericEnv },
77807
78695
  // A declaration default may itself be init-backed one level down (P43 §2),
77808
78696
  // and those nested initializers must evaluate against the same document.
77809
- initEvaluator: (member, init) => evaluateMemberInitializer({
78697
+ initEvaluator: (member, init, sourceValueId) => evaluateMemberInitializer({
77810
78698
  init,
77811
78699
  member,
77812
78700
  document: args.document,
77813
- createdValues
78701
+ createdValues,
78702
+ storedConstructionReplay: true,
78703
+ argumentValues: declarationArguments(
78704
+ member,
78705
+ init,
78706
+ sourceValueId ?? null
78707
+ )
77814
78708
  })
77815
78709
  });
77816
78710
  const interior = createdValues.filter((created) => created.id !== built.id);
@@ -77831,165 +78725,18 @@ function materializeMemberDefaultValue(args) {
77831
78725
  });
77832
78726
  return { root, createdValues: interior, pinnedRootSchemaKeys: /* @__PURE__ */ new Set() };
77833
78727
  }
78728
+ var declarationInitializerContextByDocument;
77834
78729
  var init_init_backed_value_materialization = __esm({
77835
78730
  "../src/database/init-backed-value-materialization.ts"() {
77836
78731
  "use strict";
77837
78732
  init_deep_clone_plain_data();
77838
78733
  init_members();
78734
+ init_inheritance();
77839
78735
  init_neoscript_evaluator();
77840
- }
77841
- });
77842
-
77843
- // ../src/models/constructors/constructors.ts
77844
- function hasRejectedConstructorKey(value) {
77845
- return REJECTED_CONSTRUCTOR_KEYS.some((key) => value[key] !== void 0);
77846
- }
77847
- function isNamedBaseClauseEntry(value, nameIsValid) {
77848
- if (typeof value !== "object" || value === null) return false;
77849
- if (Array.isArray(value)) return false;
77850
- const candidate = value;
77851
- if (!Object.keys(candidate).every((key) => key === "name" || key === "code")) {
77852
- return false;
77853
- }
77854
- if (!nameIsValid(candidate.name)) return false;
77855
- if (typeof candidate.code !== "string") return false;
77856
- return candidate.code.length > 0;
77857
- }
77858
- function isNeoConstructorBaseArgument(value) {
77859
- return isNamedBaseClauseEntry(value, isValidCallableArgumentIdentifier);
77860
- }
77861
- function isNeoConstructorBaseInitializerField(value) {
77862
- return isNamedBaseClauseEntry(value, isValidSchemaMemberIdentifier);
77863
- }
77864
- function isNeoClassConstructorBase(value) {
77865
- if (typeof value !== "object" || value === null) return false;
77866
- if (Array.isArray(value)) return false;
77867
- const v = value;
77868
- if (hasRejectedConstructorKey(v)) return false;
77869
- if (!isValidDocsText(v.docsText)) return false;
77870
- if (typeof v.classId !== "string") return false;
77871
- if (v.classId.length === 0) return false;
77872
- if (typeof v.code !== "string" && v.code !== null) return false;
77873
- if (!Array.isArray(v.argumentTypes)) return false;
77874
- const parameterNames = /* @__PURE__ */ new Set();
77875
- const argumentTypes = [];
77876
- for (const argument2 of v.argumentTypes) {
77877
- if (!isNSFunctionArgumentTypeInfo(argument2)) return false;
77878
- if (!isValidCallableArgumentIdentifier(argument2.name)) return false;
77879
- if (parameterNames.has(argument2.name)) return false;
77880
- parameterNames.add(argument2.name);
77881
- argumentTypes.push(argument2);
77882
- }
77883
- if (validateParameterDefaults(argumentTypes).length > 0) return false;
77884
- if (v.baseArguments !== void 0 && v.baseArguments !== null) {
77885
- if (!Array.isArray(v.baseArguments)) return false;
77886
- const baseNames = /* @__PURE__ */ new Set();
77887
- for (const baseArgument of v.baseArguments) {
77888
- if (!isNeoConstructorBaseArgument(baseArgument)) return false;
77889
- if (baseNames.has(baseArgument.name)) return false;
77890
- baseNames.add(baseArgument.name);
77891
- }
77892
- }
77893
- if (v.baseInitializerFields !== void 0 && v.baseInitializerFields !== null) {
77894
- if (!Array.isArray(v.baseInitializerFields)) return false;
77895
- const fieldNames = /* @__PURE__ */ new Set();
77896
- for (const field of v.baseInitializerFields) {
77897
- if (!isNeoConstructorBaseInitializerField(field)) return false;
77898
- if (fieldNames.has(field.name)) return false;
77899
- fieldNames.add(field.name);
77900
- }
77901
- }
77902
- if (v.action !== void 0 && v.action !== null) return false;
77903
- if (v.compiledBaseArguments !== void 0 && v.compiledBaseArguments !== null) {
77904
- return false;
77905
- }
77906
- return v.compiledBaseInitializerFields === void 0 || v.compiledBaseInitializerFields === null;
77907
- }
77908
- function isUncompiledNeoClassConstructor(value) {
77909
- if (!isNeoClassConstructorBase(value)) return false;
77910
- const v = value;
77911
- if (typeof v.id !== "string" || v.id.length === 0) return false;
77912
- if (typeof v.projectId !== "string" || v.projectId.length === 0) return false;
77913
- if (!isEpochMillis(v.createdAt)) return false;
77914
- return isEpochMillis(v.updatedAt);
77915
- }
77916
- function hasValidConstructorAction(action, argumentTypes) {
77917
- if (!isNSFunctionWithReturnType(action)) return false;
77918
- if (action.typeInfo.type !== 0 /* Null */) return false;
77919
- if (action.typeInfo.required !== true) return false;
77920
- if (action.parameters.length !== argumentTypes.length + 2) return false;
77921
- if (action.parameters[0]?.id !== "__this__") return false;
77922
- if (action.parameters[1]?.id !== "__root__") return false;
77923
- for (let index = 0; index < argumentTypes.length; index += 1) {
77924
- const parameter4 = action.parameters[index + 2];
77925
- if (parameter4?.id !== `__arg_${index}__`) return false;
77926
- const declared = argumentTypes[index];
77927
- if (declared === void 0) return false;
77928
- if (!typeInfosInvariantlyEqual(parameter4.typeInfo, declared)) return false;
77929
- }
77930
- return true;
77931
- }
77932
- function compiledBaseClauseGettersAlign(compiled, authored) {
77933
- const authoredCount = Array.isArray(authored) ? authored.length : 0;
77934
- if (compiled === void 0 || compiled === null) return authoredCount === 0;
77935
- if (!Array.isArray(compiled)) return false;
77936
- if (!compiled.every(isNSGetter)) return false;
77937
- return compiled.length === authoredCount;
77938
- }
77939
- function isNeoClassConstructorProps(value) {
77940
- if (typeof value !== "object" || value === null) return false;
77941
- const v = value;
77942
- const {
77943
- action: _action,
77944
- compiledBaseArguments: _compiledBaseArguments,
77945
- compiledBaseInitializerFields: _compiledBaseInitializerFields,
77946
- ...authored
77947
- } = v;
77948
- void _action;
77949
- void _compiledBaseArguments;
77950
- void _compiledBaseInitializerFields;
77951
- if (!isNeoClassConstructorBase(authored)) return false;
77952
- if (typeof v.id !== "string") return false;
77953
- if (v.id.length === 0) return false;
77954
- if (typeof v.projectId !== "string") return false;
77955
- if (!isEpochMillis(v.createdAt)) return false;
77956
- if (!isEpochMillis(v.updatedAt)) return false;
77957
- const argumentTypes = v.argumentTypes;
77958
- if (!hasValidConstructorAction(v.action, argumentTypes)) return false;
77959
- if (!compiledBaseClauseGettersAlign(v.compiledBaseArguments, v.baseArguments)) {
77960
- return false;
77961
- }
77962
- return compiledBaseClauseGettersAlign(
77963
- v.compiledBaseInitializerFields,
77964
- v.baseInitializerFields
77965
- );
77966
- }
77967
- function isNeoClassConstructor(value) {
77968
- return isNeoClassConstructorProps(value);
77969
- }
77970
- var REJECTED_CONSTRUCTOR_KEYS;
77971
- var init_constructors = __esm({
77972
- "../src/models/constructors/constructors.ts"() {
77973
- "use strict";
77974
- init_core();
77975
- init_docs_text2();
77976
- init_member_kinds();
77977
- init_schema_identifiers();
77978
- init_neoscript();
77979
- REJECTED_CONSTRUCTOR_KEYS = [
77980
- "bodyMode",
77981
- "uiAction",
77982
- "returnTypeInfo",
77983
- "deferred"
77984
- ];
77985
- }
77986
- });
77987
-
77988
- // ../src/models/constructors/index.ts
77989
- var init_constructors2 = __esm({
77990
- "../src/models/constructors/index.ts"() {
77991
- "use strict";
77992
- init_constructors();
78736
+ init_evaluateNSGetter();
78737
+ init_value_row_owner_members();
78738
+ init_compile_ns_property();
78739
+ declarationInitializerContextByDocument = /* @__PURE__ */ new WeakMap();
77993
78740
  }
77994
78741
  });
77995
78742
 
@@ -83099,6 +83846,11 @@ function quote4(value) {
83099
83846
  }
83100
83847
  function resolveRootPathCollectionValuesV4(args) {
83101
83848
  const resolved = /* @__PURE__ */ new Map();
83849
+ const placements = prospectiveStoredValuePlacements(
83850
+ args.state,
83851
+ args.registry,
83852
+ args.manifest
83853
+ );
83102
83854
  for (const member of args.manifest.members) {
83103
83855
  if (member.kind !== "lookup") continue;
83104
83856
  const spelled = member.collectionValueId;
@@ -83117,13 +83869,24 @@ function resolveRootPathCollectionValuesV4(args) {
83117
83869
  }
83118
83870
  });
83119
83871
  };
83120
- const target = walkRootValuePath(path, args.state, args.registry, fail);
83872
+ const target = walkRootValuePath(
83873
+ path,
83874
+ args.state,
83875
+ args.registry,
83876
+ placements,
83877
+ fail
83878
+ );
83121
83879
  if (target !== null) resolved.set(member.id, target);
83122
83880
  }
83123
83881
  return resolved;
83124
83882
  }
83125
83883
  function resolveRootPathVariantFolderCollectionValuesV4(args) {
83126
83884
  const resolved = /* @__PURE__ */ new Map();
83885
+ const placements = prospectiveStoredValuePlacements(
83886
+ args.state,
83887
+ args.registry,
83888
+ args.manifest
83889
+ );
83127
83890
  for (const folder of args.manifest.variantFolders) {
83128
83891
  const spelled = folder.binding?.collectionValueId;
83129
83892
  if (typeof spelled !== "string") continue;
@@ -83141,12 +83904,18 @@ function resolveRootPathVariantFolderCollectionValuesV4(args) {
83141
83904
  }
83142
83905
  });
83143
83906
  };
83144
- const target = walkRootValuePath(path, args.state, args.registry, fail);
83907
+ const target = walkRootValuePath(
83908
+ path,
83909
+ args.state,
83910
+ args.registry,
83911
+ placements,
83912
+ fail
83913
+ );
83145
83914
  if (target !== null) resolved.set(folder.id, target);
83146
83915
  }
83147
83916
  return resolved;
83148
83917
  }
83149
- function walkRootValuePath(path, state, registry, fail) {
83918
+ function walkRootValuePath(path, state, registry, placements, fail) {
83150
83919
  const segments = path.split(".");
83151
83920
  const slotName = segments[1];
83152
83921
  if (segments[0] !== "root" || slotName === void 0) {
@@ -83191,7 +83960,7 @@ function walkRootValuePath(path, state, registry, fail) {
83191
83960
  );
83192
83961
  return null;
83193
83962
  }
83194
- const next = body[segment];
83963
+ const next = placements.childrenByParentValueId.get(cursor)?.get(segment)?.childValueId;
83195
83964
  if (typeof next !== "string") {
83196
83965
  const cursorData = state[`value:${cursor}`]?.data;
83197
83966
  const collapsed = isObjectRecord2(cursorData) && isVirtualInstanceRootShape(cursorData);
@@ -83204,6 +83973,62 @@ function walkRootValuePath(path, state, registry, fail) {
83204
83973
  }
83205
83974
  return cursor;
83206
83975
  }
83976
+ function prospectiveStoredValuePlacements(state, registry, manifest) {
83977
+ const records2 = new Map(
83978
+ Object.values(state).map((record3) => [
83979
+ `${record3.recordKind}:${record3.recordId}`,
83980
+ record3
83981
+ ])
83982
+ );
83983
+ for (const row of registry.pendingValues.values()) {
83984
+ records2.set(`value:${row.id}`, {
83985
+ recordKind: "value",
83986
+ recordId: row.id,
83987
+ contentHash: "pending",
83988
+ data: row
83989
+ });
83990
+ }
83991
+ for (const schemaClass2 of manifest.classes) {
83992
+ const key = `class:${schemaClass2.id}`;
83993
+ records2.set(key, {
83994
+ recordKind: "class",
83995
+ recordId: schemaClass2.id,
83996
+ contentHash: "pending",
83997
+ data: schemaClass2
83998
+ });
83999
+ }
84000
+ for (const member of manifest.members) {
84001
+ const key = `member:${member.id}`;
84002
+ records2.set(key, {
84003
+ recordKind: "member",
84004
+ recordId: member.id,
84005
+ contentHash: "pending",
84006
+ data: member
84007
+ });
84008
+ }
84009
+ for (const constructor2 of manifest.constructors) {
84010
+ const key = `constructor:${constructor2.id}`;
84011
+ const current = records2.get(key)?.data;
84012
+ records2.set(key, {
84013
+ recordKind: "constructor",
84014
+ recordId: constructor2.id,
84015
+ contentHash: "pending",
84016
+ data: isObjectRecord2(current) && current.action !== void 0 ? current : {
84017
+ ...constructor2,
84018
+ argumentTypes: constructor2.arguments
84019
+ }
84020
+ });
84021
+ }
84022
+ for (const variant of manifest.variants ?? []) {
84023
+ records2.set(`variant:${variant.id}`, {
84024
+ recordKind: "variant",
84025
+ recordId: variant.id,
84026
+ contentHash: "pending",
84027
+ data: variant
84028
+ });
84029
+ }
84030
+ return buildStoredValuePlacementIndexV4(records2.values());
84031
+ }
83207
84032
  var ROOT_PROJECT_FIELDS2, ROOT_PATH_PENDING_PREFIX;
83208
84033
  var init_root_source = __esm({
83209
84034
  "src/project-source/root-source.ts"() {
@@ -83214,6 +84039,7 @@ var init_root_source = __esm({
83214
84039
  init_value_sources();
83215
84040
  init_root_value_paths();
83216
84041
  init_source_format();
84042
+ init_stored_value_placements();
83217
84043
  ROOT_PROJECT_FIELDS2 = [
83218
84044
  "rootAssetsMemberId",
83219
84045
  "rootSaveFileMemberId",
@@ -84620,13 +85446,21 @@ function storedConstructionEmitters(state, manifest) {
84620
85446
  }
84621
85447
  candidateRoots.add(record3.recordId);
84622
85448
  }
84623
- const owners = resolveOwnerMembersForValues(
84624
- readPulledProjectDocumentV4(records2),
84625
- candidateRoots
85449
+ const document = readPulledProjectDocumentV4(records2);
85450
+ const owners = resolveOwnerMembersForValues(document, candidateRoots);
85451
+ const storedPlacements = buildStoredValuePlacementIndexV4(records2.values());
85452
+ const membersById2 = new Map(
85453
+ document.members.map((member) => [member.id, member])
84626
85454
  );
85455
+ for (const valueId of candidateRoots) {
85456
+ if (owners.has(valueId)) continue;
85457
+ const memberId = storedPlacements.placementByChildValueId.get(valueId)?.memberId;
85458
+ const member = memberId === null || memberId === void 0 ? void 0 : membersById2.get(memberId);
85459
+ if (member !== void 0) owners.set(valueId, member);
85460
+ }
84627
85461
  const probe = createStoredConstructionProbeV4(records2, manifest);
84628
85462
  let parents;
84629
- const parentByChildId = () => parents ??= storedValueParentIndex(records2);
85463
+ const parentByChildId = () => parents ??= storedValueParentIndex(records2, storedPlacements);
84630
85464
  const root = (valueId) => {
84631
85465
  const member = owners.get(valueId);
84632
85466
  return member === void 0 ? void 0 : {
@@ -84663,7 +85497,7 @@ function storedConstructionEmitters(state, manifest) {
84663
85497
  }
84664
85498
  };
84665
85499
  }
84666
- function storedValueParentIndex(records2) {
85500
+ function storedValueParentIndex(records2, placements) {
84667
85501
  const parents = /* @__PURE__ */ new Map();
84668
85502
  const valueIds = /* @__PURE__ */ new Set();
84669
85503
  for (const record3 of records2.values()) {
@@ -84692,6 +85526,12 @@ function storedValueParentIndex(records2) {
84692
85526
  }
84693
85527
  }
84694
85528
  }
85529
+ for (const edge of placements.placementByChildValueId.values()) {
85530
+ if (edge.source !== "constructor") continue;
85531
+ if (!parents.has(edge.childValueId)) {
85532
+ parents.set(edge.childValueId, edge.parentValueId);
85533
+ }
85534
+ }
84695
85535
  return parents;
84696
85536
  }
84697
85537
  function nearestOwnedAncestor(valueId, parents, owners) {
@@ -84787,6 +85627,7 @@ var init_materialized_construction_cache = __esm({
84787
85627
  init_value_row_owner_members();
84788
85628
  init_instance_provenance();
84789
85629
  init_value_sources();
85630
+ init_stored_value_placements();
84790
85631
  MATERIALIZED_CONSTRUCTION_BUILD_CACHE_PATH = ".neo/build/materialized-constructions-v1.json";
84791
85632
  MATERIALIZED_CONSTRUCTION_BUILD_CACHE_REVISION = 2;
84792
85633
  }
@@ -84922,7 +85763,7 @@ function collectVariantGraphValueIds(args) {
84922
85763
  if (roots.length === 0) return collected;
84923
85764
  const rootMemberIds2 = new Set(roots.map((root) => root.member.id));
84924
85765
  const rootOwners = /* @__PURE__ */ new Map();
84925
- resolveOwnerMembersForValues(
85766
+ resolveSemanticOwnerMembersForValues(
84926
85767
  document,
84927
85768
  new Set(document.values.map((value) => value.id)),
84928
85769
  roots,
@@ -84939,7 +85780,7 @@ var init_variant_value_graph = __esm({
84939
85780
  "use strict";
84940
85781
  init_members();
84941
85782
  init_core();
84942
- init_value_row_owner_members();
85783
+ init_constructor_argument_ownership();
84943
85784
  }
84944
85785
  });
84945
85786
 
@@ -85092,7 +85933,7 @@ function collectNeoScriptRecompileTargets(args) {
85092
85933
  args.postDocument.variants ?? []
85093
85934
  );
85094
85935
  if (transactionImpactsAnyOwnerMember(scope, impactedIds)) {
85095
- const ownerByValueId = resolveOwnerMembersForValues(
85936
+ const ownerByValueId = resolveSemanticOwnerMembersForValues(
85096
85937
  scope.document,
85097
85938
  new Set(postValues.map((record3) => record3.id)),
85098
85939
  scope.roots
@@ -85549,7 +86390,7 @@ function collectImpactedSourceNames(args) {
85549
86390
  (document.values ?? []).filter((value) => isImpactedRecordId(value.id)).map((value) => value.id)
85550
86391
  );
85551
86392
  const scope = withVariantOwnershipRoots(document, document.variants ?? []);
85552
- const ownerByValueId = resolveOwnerMembersForValues(
86393
+ const ownerByValueId = resolveSemanticOwnerMembersForValues(
85553
86394
  scope.document,
85554
86395
  impactedValueIds,
85555
86396
  scope.roots
@@ -85738,7 +86579,7 @@ var init_neo_script_recompile_scope = __esm({
85738
86579
  init_inheritance();
85739
86580
  init_effective_storage();
85740
86581
  init_project_root_members();
85741
- init_value_row_owner_members();
86582
+ init_constructor_argument_ownership();
85742
86583
  NON_CONTRACT_MEMBER_FIELDS = /* @__PURE__ */ new Set([
85743
86584
  "createdAt",
85744
86585
  "updatedAt",
@@ -86074,12 +86915,10 @@ function materializedInitializerReconciliationFailuresV4(args) {
86074
86915
  rootMember: owner
86075
86916
  });
86076
86917
  } catch (error) {
86077
- if (!(error instanceof VirtualExpansionUnsupportedError)) {
86078
- throw new Error(
86079
- `Resolving the stored instance graph of value "${reconciliation.valueId}" failed: ${error instanceof Error ? error.message : String(error)}`,
86080
- { cause: error }
86081
- );
86082
- }
86918
+ throw new Error(
86919
+ `Resolving the canonical stored instance graph of value "${reconciliation.valueId}" failed: ${error instanceof Error ? error.message : String(error)}`,
86920
+ { cause: error }
86921
+ );
86083
86922
  }
86084
86923
  }
86085
86924
  const currentNormalized = currentRoot === void 0 ? void 0 : new MaterializedValueGraphContext(
@@ -86173,7 +87012,7 @@ function materializeInitializersLocallyV4(args) {
86173
87012
  );
86174
87013
  let document = variantScope.document;
86175
87014
  const rootKinds = /* @__PURE__ */ new Map();
86176
- const rootOwners = resolveOwnerMembersForValues(
87015
+ const rootOwners = resolveSemanticOwnerMembersForValues(
86177
87016
  document,
86178
87017
  sourceRoots,
86179
87018
  variantScope.roots,
@@ -86181,7 +87020,7 @@ function materializeInitializersLocallyV4(args) {
86181
87020
  rootKinds
86182
87021
  );
86183
87022
  const roots = [];
86184
- for (const sourceValueId of sourceRoots) {
87023
+ for (const sourceValueId of [...sourceRoots].sort()) {
86185
87024
  if (rootKinds.get(sourceValueId) === "declaration") continue;
86186
87025
  const rootOwner = rootOwners.get(sourceValueId);
86187
87026
  if (rootOwner === void 0) {
@@ -86464,6 +87303,7 @@ var init_local_initializer_materialization = __esm({
86464
87303
  init_initializer_replay();
86465
87304
  init_members();
86466
87305
  init_constructor_argument_ownership();
87306
+ init_constructor_argument_ownership();
86467
87307
  init_value_row_owner_members();
86468
87308
  init_variant_value_graph();
86469
87309
  init_neo_script_recompile_scope();
@@ -88449,7 +89289,7 @@ function assertProjectInterfaceDocumentValid(view, options = {}) {
88449
89289
  );
88450
89290
  }
88451
89291
  }
88452
- const resolveMember3 = (member) => {
89292
+ const resolveMember4 = (member) => {
88453
89293
  const chain = [];
88454
89294
  const seen = /* @__PURE__ */ new Set();
88455
89295
  let current = member;
@@ -88506,7 +89346,7 @@ function assertProjectInterfaceDocumentValid(view, options = {}) {
88506
89346
  }
88507
89347
  if (member.isReadOnly !== true) continue;
88508
89348
  const placements = placementsByMemberId.get(member.id) ?? [];
88509
- const resolved = resolveMember3(member);
89349
+ const resolved = resolveMember4(member);
88510
89350
  if (placements.length === 0) {
88511
89351
  throw new Error(
88512
89352
  `Read-only member "${member.name}" (${member.id}) has no owning class and must have at least one direct class-schema owner.`
@@ -88562,7 +89402,7 @@ function assertProjectInterfaceDocumentValid(view, options = {}) {
88562
89402
  const visitKey = `${rawOwned.id}\0${environmentKey}`;
88563
89403
  if (visited.has(visitKey)) return;
88564
89404
  visited.add(visitKey);
88565
- const inherited = resolveMember3(rawOwned);
89405
+ const inherited = resolveMember4(rawOwned);
88566
89406
  let owned = inherited;
88567
89407
  if (inherited.kind === 21) {
88568
89408
  const visitedParams = /* @__PURE__ */ new Set();
@@ -88590,7 +89430,7 @@ function assertProjectInterfaceDocumentValid(view, options = {}) {
88590
89430
  `Read-only member "${member.name}" has an owned Generic member "${inherited.name}" bound to missing member "${bindingId}"; ${ownerLabel}.`
88591
89431
  );
88592
89432
  }
88593
- owned = resolveMember3(binding);
89433
+ owned = resolveMember4(binding);
88594
89434
  }
88595
89435
  owned = { ...owned, id: rawOwned.id, name: inherited.name };
88596
89436
  if (inherited.storage === void 0) delete owned.storage;
@@ -88737,7 +89577,7 @@ function assertProjectInterfaceDocumentValid(view, options = {}) {
88737
89577
  );
88738
89578
  const visitedValueIds = /* @__PURE__ */ new Set();
88739
89579
  const inspectValueBody = (rawMember, body, classId, ownerValueId) => {
88740
- const inspectedMember = resolveMember3(rawMember);
89580
+ const inspectedMember = resolveMember4(rawMember);
88741
89581
  if (inspectedMember.kind === 9) {
88742
89582
  assertNoPersistedReadOnlySyntheticLookupId2(
88743
89583
  body,
@@ -88873,14 +89713,14 @@ function assertProjectInterfaceDocumentValid(view, options = {}) {
88873
89713
  return env;
88874
89714
  }
88875
89715
  function substituteMemberForClass(member, schemaClass2) {
88876
- const resolved = resolveMember3(member);
89716
+ const resolved = resolveMember4(member);
88877
89717
  const env = genericEnvForClass(schemaClass2);
88878
89718
  if (resolved.kind === 21 && typeof resolved.genericParamId === "string") {
88879
89719
  const bindingId = env.get(resolved.genericParamId);
88880
89720
  const binding = bindingId ? membersById2.get(bindingId) : void 0;
88881
89721
  if (!binding) return resolved;
88882
89722
  const substituted = {
88883
- ...resolveMember3(binding),
89723
+ ...resolveMember4(binding),
88884
89724
  id: member.id,
88885
89725
  name: resolved.name
88886
89726
  };
@@ -90061,46 +90901,6 @@ var init_project_schema_identifier_validation = __esm({
90061
90901
  }
90062
90902
  });
90063
90903
 
90064
- // ../src/database/constructor-parameter-settlement.ts
90065
- function constructorSettledSchemaEntry(view, classId, parameterName) {
90066
- const membersById2 = new Map(
90067
- view.members.map((member) => [member.id, member])
90068
- );
90069
- const visited = /* @__PURE__ */ new Set();
90070
- let currentId = classId;
90071
- while (currentId !== null && !visited.has(currentId)) {
90072
- visited.add(currentId);
90073
- const schemaClass2 = view.classes.find(
90074
- (candidate) => candidate.id === currentId
90075
- );
90076
- if (schemaClass2 === void 0) return null;
90077
- for (const [schemaKey, memberId] of Object.entries(
90078
- schemaClass2.schema ?? {}
90079
- )) {
90080
- if (typeof memberId !== "string") continue;
90081
- const member = membersById2.get(memberId);
90082
- const defaultRecord = asRecord(member?.defaultValue);
90083
- const initRecord = asRecord(defaultRecord?.init);
90084
- if (initRecord !== null && typeof initRecord.code === "string" && initRecord.code.trim() === parameterName) {
90085
- return { schemaKey, memberId };
90086
- }
90087
- }
90088
- currentId = schemaClass2.extendsClassId ?? null;
90089
- }
90090
- return null;
90091
- }
90092
- function asRecord(value) {
90093
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
90094
- return null;
90095
- }
90096
- return value;
90097
- }
90098
- var init_constructor_parameter_settlement = __esm({
90099
- "../src/database/constructor-parameter-settlement.ts"() {
90100
- "use strict";
90101
- }
90102
- });
90103
-
90104
90904
  // ../src/database/project-document-value-overlay.ts
90105
90905
  function overlayCreatedValues(documentValues, createdValues) {
90106
90906
  if (createdValues.length === 0) return [...documentValues];
@@ -90431,6 +91231,363 @@ var init_member_access_modifier_validation = __esm({
90431
91231
  }
90432
91232
  });
90433
91233
 
91234
+ // ../src/models/search/universal-search-projection.ts
91235
+ function truncateUtf8(value, maxBytes) {
91236
+ if (value === void 0) return "";
91237
+ if (!Number.isInteger(maxBytes) || maxBytes < 0) {
91238
+ throw new Error(
91239
+ "UTF-8 truncation maxBytes must be a non-negative integer."
91240
+ );
91241
+ }
91242
+ if (value.length <= maxBytes && isAscii(value)) return value;
91243
+ if (utf8Encoder.encode(value).byteLength <= maxBytes) return value;
91244
+ let result = "";
91245
+ let bytes = 0;
91246
+ for (const character of value) {
91247
+ const characterBytes = utf8Encoder.encode(character).byteLength;
91248
+ if (bytes + characterBytes > maxBytes) break;
91249
+ result += character;
91250
+ bytes += characterBytes;
91251
+ }
91252
+ return result.trimEnd();
91253
+ }
91254
+ function isAscii(value) {
91255
+ for (let index = 0; index < value.length; index += 1) {
91256
+ if (value.charCodeAt(index) > 127) return false;
91257
+ }
91258
+ return true;
91259
+ }
91260
+ var utf8Encoder;
91261
+ var init_universal_search_projection = __esm({
91262
+ "../src/models/search/universal-search-projection.ts"() {
91263
+ "use strict";
91264
+ utf8Encoder = new TextEncoder();
91265
+ }
91266
+ });
91267
+
91268
+ // ../convex/valueHeadPlacementGraph.ts
91269
+ function projectValueHeadPlacementGraph(args) {
91270
+ const members = recordMap(args.members);
91271
+ const classes = recordMap(args.classes);
91272
+ const values = recordMap(args.values);
91273
+ const resolvedMembers = /* @__PURE__ */ new Map();
91274
+ const effectiveSchemas = /* @__PURE__ */ new Map();
91275
+ const resolvedMember = (member) => {
91276
+ const id2 = requireId(member, "member");
91277
+ const cached = resolvedMembers.get(id2);
91278
+ if (cached !== void 0) return cached;
91279
+ const resolved = resolveMember3(member, members);
91280
+ resolvedMembers.set(id2, resolved);
91281
+ return resolved;
91282
+ };
91283
+ const effectiveSchema = (classId) => {
91284
+ const cached = effectiveSchemas.get(classId);
91285
+ if (cached !== void 0) return cached;
91286
+ const schema = resolveClassSchema(classId, classes);
91287
+ effectiveSchemas.set(classId, schema);
91288
+ return schema;
91289
+ };
91290
+ const unorderedByContainer = /* @__PURE__ */ new Map();
91291
+ for (const value of values.values()) {
91292
+ if (typeof value.containerId !== "string") continue;
91293
+ const members2 = unorderedByContainer.get(value.containerId) ?? [];
91294
+ members2.push(requireId(value, "value"));
91295
+ unorderedByContainer.set(value.containerId, members2);
91296
+ }
91297
+ const constructorEdgesByOwner = /* @__PURE__ */ new Map();
91298
+ for (const edge of args.constructorEdges ?? []) {
91299
+ const edges = constructorEdgesByOwner.get(edge.ownerValueId) ?? [];
91300
+ edges.push(edge);
91301
+ constructorEdgesByOwner.set(edge.ownerValueId, edges);
91302
+ }
91303
+ const result = /* @__PURE__ */ new Map();
91304
+ const constructorOriginByValueId = /* @__PURE__ */ new Map();
91305
+ const queue = [];
91306
+ for (const root of args.rootMembers) {
91307
+ const member = members.get(root.id);
91308
+ if (member === void 0 || typeof member.valueId !== "string") continue;
91309
+ queue.push({
91310
+ valueId: member.valueId,
91311
+ memberId: root.id,
91312
+ parentRecordKind: "member",
91313
+ parentRecordId: root.id,
91314
+ relation: "memberValue",
91315
+ scope: "authored",
91316
+ ownerId: null,
91317
+ rootMemberId: root.id,
91318
+ path: root.label
91319
+ });
91320
+ }
91321
+ for (const root of args.variantRoots ?? []) {
91322
+ queue.push({
91323
+ valueId: root.valueId,
91324
+ memberId: null,
91325
+ parentRecordKind: "variant",
91326
+ parentRecordId: root.variantId,
91327
+ relation: "variantValue",
91328
+ scope: "variant",
91329
+ ownerId: null,
91330
+ rootMemberId: null,
91331
+ path: null
91332
+ });
91333
+ }
91334
+ for (const member of members.values()) {
91335
+ if (!isRecord8(member.defaultValue)) continue;
91336
+ for (const child of directChildEdges({
91337
+ member: resolvedMember(member),
91338
+ body: member.defaultValue.value,
91339
+ unorderedByContainer,
91340
+ parentValueId: null,
91341
+ effectiveSchema
91342
+ })) {
91343
+ queue.push({
91344
+ valueId: child.valueId,
91345
+ memberId: child.memberId,
91346
+ parentRecordKind: "member",
91347
+ parentRecordId: requireId(member, "member"),
91348
+ relation: "memberDefault",
91349
+ scope: "memberDefault",
91350
+ ownerId: null,
91351
+ rootMemberId: null,
91352
+ path: null
91353
+ });
91354
+ }
91355
+ }
91356
+ for (let cursor = 0; cursor < queue.length; cursor += 1) {
91357
+ const item = queue[cursor];
91358
+ if (item === void 0) continue;
91359
+ const value = values.get(item.valueId);
91360
+ if (value === void 0) continue;
91361
+ const explicitClassId = stringOrNull(value.classId);
91362
+ const rootlessMember = item.memberId === null && explicitClassId !== null ? {
91363
+ id: `variant-root:${item.valueId}`,
91364
+ kind: 7,
91365
+ classId: explicitClassId
91366
+ } : null;
91367
+ const storedMember = item.memberId === null ? void 0 : members.get(item.memberId);
91368
+ if (rootlessMember === null && storedMember === void 0) continue;
91369
+ const member = rootlessMember ?? resolvedMember(storedMember);
91370
+ const classId = explicitClassId ?? (member.kind === 7 ? stringOrNull(member.classId) : null);
91371
+ const ownerId = classId === null ? item.ownerId : item.valueId;
91372
+ const schemaClass2 = classId === null ? void 0 : classes.get(classId);
91373
+ const projection = {
91374
+ valueMemberId: item.memberId,
91375
+ parentRecordKind: item.parentRecordKind,
91376
+ parentRecordId: item.parentRecordId,
91377
+ parentRelation: item.relation,
91378
+ valuePlacementScope: item.scope,
91379
+ valueOwnerId: ownerId,
91380
+ valueRootMemberId: item.rootMemberId,
91381
+ valueClassId: classId,
91382
+ valueSearchClassName: schemaClass2 !== void 0 && typeof schemaClass2.name === "string" ? truncateUtf8(schemaClass2.name, 512) : null,
91383
+ valueSearchPlacementPath: item.path,
91384
+ ...item.constructorParameterId === void 0 ? {} : { constructorParameterId: item.constructorParameterId },
91385
+ ...item.constructorSchemaKey === void 0 ? {} : { constructorSchemaKey: item.constructorSchemaKey }
91386
+ };
91387
+ const existing = result.get(item.valueId);
91388
+ if (existing !== void 0) {
91389
+ const existingConstructorOrigin = constructorOriginByValueId.get(item.valueId) === true;
91390
+ const projectionConstructorOrigin = item.constructorOrigin === true;
91391
+ if (!placementsEqual(existing, projection) || existingConstructorOrigin !== projectionConstructorOrigin) {
91392
+ if (existing.valuePlacementScope === "memberDefault" && projection.valuePlacementScope === "authored") {
91393
+ } else if (existing.valuePlacementScope === "authored" && projection.valuePlacementScope === "memberDefault") {
91394
+ continue;
91395
+ } else if (existing.valuePlacementScope !== "standalone" && projection.valuePlacementScope === "standalone") {
91396
+ continue;
91397
+ } else if (existing.valuePlacementScope === "standalone" && projection.valuePlacementScope !== "standalone") {
91398
+ } else if (existingConstructorOrigin !== projectionConstructorOrigin) {
91399
+ if (!existingConstructorOrigin) continue;
91400
+ } else if (existing.parentRelation !== "unorderedCollectionEntry" && projection.parentRelation === "unorderedCollectionEntry") {
91401
+ continue;
91402
+ } else if (existing.parentRelation === "unorderedCollectionEntry" && projection.parentRelation !== "unorderedCollectionEntry") {
91403
+ } else if (existing.parentRecordKind === "member" && existing.parentRelation === "memberValue" && existing.valuePlacementScope === "authored") {
91404
+ continue;
91405
+ } else {
91406
+ throw new Error(
91407
+ `Value "${item.valueId}" has ambiguous containment parents "${existing.parentRecordId ?? "none"}" and "${item.parentRecordId}".`
91408
+ );
91409
+ }
91410
+ } else {
91411
+ continue;
91412
+ }
91413
+ }
91414
+ result.set(item.valueId, projection);
91415
+ constructorOriginByValueId.set(
91416
+ item.valueId,
91417
+ item.constructorOrigin === true
91418
+ );
91419
+ for (const child of directChildEdges({
91420
+ member,
91421
+ body: value.value,
91422
+ unorderedByContainer,
91423
+ parentValueId: item.valueId,
91424
+ classId,
91425
+ effectiveSchema
91426
+ })) {
91427
+ const childMember = members.get(child.memberId);
91428
+ const childName = childMember === void 0 ? null : stringOrNull(resolvedMember(childMember).name);
91429
+ queue.push({
91430
+ valueId: child.valueId,
91431
+ memberId: child.memberId,
91432
+ parentRecordKind: "value",
91433
+ parentRecordId: item.valueId,
91434
+ relation: child.relation,
91435
+ scope: item.scope,
91436
+ ownerId,
91437
+ rootMemberId: item.rootMemberId,
91438
+ path: child.relation === "classField" && childName !== null ? joinPath(item.path, childName) : item.path,
91439
+ constructorOrigin: item.constructorOrigin
91440
+ });
91441
+ }
91442
+ for (const edge of constructorEdgesByOwner.get(item.valueId) ?? []) {
91443
+ const childMember = members.get(edge.memberId);
91444
+ const childName = childMember === void 0 ? null : stringOrNull(resolvedMember(childMember).name);
91445
+ queue.push({
91446
+ valueId: edge.targetValueId,
91447
+ memberId: edge.memberId,
91448
+ parentRecordKind: "value",
91449
+ parentRecordId: item.valueId,
91450
+ relation: "classField",
91451
+ scope: item.scope,
91452
+ ownerId,
91453
+ rootMemberId: item.rootMemberId,
91454
+ path: childName === null ? item.path : joinPath(item.path, childName),
91455
+ constructorOrigin: true,
91456
+ constructorParameterId: edge.parameterId,
91457
+ constructorSchemaKey: edge.schemaKey
91458
+ });
91459
+ }
91460
+ }
91461
+ for (const [valueId, value] of values) {
91462
+ if (result.has(valueId)) continue;
91463
+ const classId = stringOrNull(value.classId);
91464
+ const schemaClass2 = classId === null ? void 0 : classes.get(classId);
91465
+ result.set(valueId, {
91466
+ valueMemberId: null,
91467
+ parentRecordKind: null,
91468
+ parentRecordId: null,
91469
+ parentRelation: null,
91470
+ valuePlacementScope: "standalone",
91471
+ valueOwnerId: classId === null ? null : valueId,
91472
+ valueRootMemberId: null,
91473
+ valueClassId: classId,
91474
+ valueSearchClassName: schemaClass2 !== void 0 && typeof schemaClass2.name === "string" ? truncateUtf8(schemaClass2.name, 512) : null,
91475
+ valueSearchPlacementPath: null
91476
+ });
91477
+ }
91478
+ return result;
91479
+ }
91480
+ function directChildEdges(args) {
91481
+ const result = [];
91482
+ if (args.member.kind === 9) return result;
91483
+ if (args.member.kind === 7) {
91484
+ if (!isRecord8(args.body)) return result;
91485
+ const classId = args.classId ?? stringOrNull(args.member.classId);
91486
+ if (classId === null) return result;
91487
+ const schema = args.effectiveSchema(classId);
91488
+ for (const [schemaKey, valueId] of Object.entries(args.body)) {
91489
+ const memberId = schema.get(schemaKey);
91490
+ if (memberId === void 0 || typeof valueId !== "string") continue;
91491
+ result.push({ valueId, memberId, relation: "classField" });
91492
+ }
91493
+ return result;
91494
+ }
91495
+ const entryMemberId = stringOrNull(args.member.entryMemberId);
91496
+ if (entryMemberId === null) return result;
91497
+ if (args.parentValueId !== null) {
91498
+ for (const valueId of args.unorderedByContainer.get(args.parentValueId) ?? []) {
91499
+ result.push({
91500
+ valueId,
91501
+ memberId: entryMemberId,
91502
+ relation: "unorderedCollectionEntry"
91503
+ });
91504
+ }
91505
+ if (args.member.listKind === "unordered") return result;
91506
+ }
91507
+ const ids = Array.isArray(args.body) ? args.body : isRecord8(args.body) ? Object.values(args.body) : [];
91508
+ for (const valueId of ids) {
91509
+ if (typeof valueId !== "string") continue;
91510
+ result.push({
91511
+ valueId,
91512
+ memberId: entryMemberId,
91513
+ relation: "collectionEntry"
91514
+ });
91515
+ }
91516
+ return result;
91517
+ }
91518
+ function resolveMember3(source, members) {
91519
+ const chain = [];
91520
+ const visited = /* @__PURE__ */ new Set();
91521
+ let current = source;
91522
+ while (current !== void 0) {
91523
+ const id2 = requireId(current, "member");
91524
+ if (visited.has(id2))
91525
+ throw new Error(`Member inheritance cycle at "${id2}".`);
91526
+ visited.add(id2);
91527
+ chain.unshift(current);
91528
+ const baseId = stringOrNull(current.extendsMemberId);
91529
+ current = baseId === null ? void 0 : members.get(baseId);
91530
+ }
91531
+ const result = {};
91532
+ for (const layer of chain) {
91533
+ for (const [key, value] of Object.entries(layer)) {
91534
+ if (value !== void 0) result[key] = value;
91535
+ }
91536
+ }
91537
+ return result;
91538
+ }
91539
+ function resolveClassSchema(classId, classes) {
91540
+ const chain = [];
91541
+ const visited = /* @__PURE__ */ new Set();
91542
+ let current = classes.get(classId);
91543
+ while (current !== void 0) {
91544
+ const id2 = requireId(current, "class");
91545
+ if (visited.has(id2)) throw new Error(`Class inheritance cycle at "${id2}".`);
91546
+ visited.add(id2);
91547
+ chain.unshift(current);
91548
+ const baseId = stringOrNull(current.extendsClassId);
91549
+ current = baseId === null ? void 0 : classes.get(baseId);
91550
+ }
91551
+ const schema = /* @__PURE__ */ new Map();
91552
+ for (const schemaClass2 of chain) {
91553
+ if (!isRecord8(schemaClass2.schema)) continue;
91554
+ for (const [key, memberId] of Object.entries(schemaClass2.schema)) {
91555
+ if (typeof memberId === "string") schema.set(key, memberId);
91556
+ }
91557
+ }
91558
+ return schema;
91559
+ }
91560
+ function recordMap(values) {
91561
+ const result = /* @__PURE__ */ new Map();
91562
+ for (const value of values) {
91563
+ if (!isRecord8(value)) continue;
91564
+ result.set(requireId(value, "record"), value);
91565
+ }
91566
+ return result;
91567
+ }
91568
+ function requireId(value, kind) {
91569
+ if (typeof value.id === "string" && value.id.length > 0) return value.id;
91570
+ throw new Error(`Placement ${kind} record is missing a stable id.`);
91571
+ }
91572
+ function stringOrNull(value) {
91573
+ return typeof value === "string" && value.length > 0 ? value : null;
91574
+ }
91575
+ function joinPath(parent, child) {
91576
+ return truncateUtf8(parent === null ? child : `${parent} > ${child}`, 512);
91577
+ }
91578
+ function placementsEqual(left, right) {
91579
+ return JSON.stringify(left) === JSON.stringify(right);
91580
+ }
91581
+ function isRecord8(value) {
91582
+ return typeof value === "object" && value !== null && !Array.isArray(value);
91583
+ }
91584
+ var init_valueHeadPlacementGraph = __esm({
91585
+ "../convex/valueHeadPlacementGraph.ts"() {
91586
+ "use strict";
91587
+ init_universal_search_projection();
91588
+ }
91589
+ });
91590
+
90434
91591
  // ../src/database/project-migration-created-values.ts
90435
91592
  function validateCreatedMigrationGraph(args) {
90436
91593
  if (args.createdSessionValues.length === 0) return [];
@@ -90546,7 +91703,7 @@ function validateCreatedMigrationGraph(args) {
90546
91703
  if (row.value === null && member !== void 0 && isMemberClassBase(member) && !member.required) {
90547
91704
  return;
90548
91705
  }
90549
- if (!isRecord8(row.value)) {
91706
+ if (!isRecord9(row.value)) {
90550
91707
  throw graphError(
90551
91708
  args,
90552
91709
  `Class value "${valueId}" does not contain a record`
@@ -90612,7 +91769,7 @@ function validateCreatedMigrationGraph(args) {
90612
91769
  `Dictionary value "${valueId}" references missing entry member "${member.entryMemberId}"`
90613
91770
  );
90614
91771
  }
90615
- if (!isRecord8(row.value)) {
91772
+ if (!isRecord9(row.value)) {
90616
91773
  throw graphError(args, `Dictionary value "${valueId}" is not a record`);
90617
91774
  }
90618
91775
  for (const [key, childId] of Object.entries(row.value)) {
@@ -90656,7 +91813,7 @@ function validateCreatedMigrationGraph(args) {
90656
91813
  }
90657
91814
  return [...createdById.values()];
90658
91815
  }
90659
- function isRecord8(value) {
91816
+ function isRecord9(value) {
90660
91817
  return typeof value === "object" && value !== null && !Array.isArray(value);
90661
91818
  }
90662
91819
  function graphError(args, detail) {
@@ -90931,14 +92088,14 @@ function findParentValues(valueId, values) {
90931
92088
  }
90932
92089
  continue;
90933
92090
  }
90934
- if (!isStringRecord4(value.value)) continue;
92091
+ if (!isStringRecord5(value.value)) continue;
90935
92092
  for (const [key, childValueId] of Object.entries(value.value)) {
90936
92093
  if (childValueId === valueId) parents.push({ value, key });
90937
92094
  }
90938
92095
  }
90939
92096
  return parents;
90940
92097
  }
90941
- function isStringRecord4(value) {
92098
+ function isStringRecord5(value) {
90942
92099
  if (typeof value !== "object") return false;
90943
92100
  if (value === null) return false;
90944
92101
  if (Array.isArray(value)) return false;
@@ -91956,7 +93113,7 @@ function assertNumberRange(member, value, path) {
91956
93113
  throw new Error(`${path} must be at most ${max}.`);
91957
93114
  }
91958
93115
  }
91959
- function isStringRecord5(value) {
93116
+ function isStringRecord6(value) {
91960
93117
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
91961
93118
  return false;
91962
93119
  }
@@ -92351,7 +93508,7 @@ var init_project_version_static_value_writes = __esm({
92351
93508
  if (!isLiteralValueContent(args.value)) {
92352
93509
  throw new Error(`${args.path} must store a literal Class value.`);
92353
93510
  }
92354
- if (!isStringRecord5(args.value.value)) {
93511
+ if (!isStringRecord6(args.value.value)) {
92355
93512
  throw new Error(`${args.path} must store a Class schema-key map.`);
92356
93513
  }
92357
93514
  const effectiveClassId = args.value.classId ?? args.member.classId;
@@ -92508,7 +93665,7 @@ var init_project_version_static_value_writes = __esm({
92508
93665
  }
92509
93666
  }
92510
93667
  validateDictionary(args) {
92511
- if (!isStringRecord5(args.value.value)) {
93668
+ if (!isStringRecord6(args.value.value)) {
92512
93669
  throw new Error(`${args.path} must store a Dictionary key/value-id map.`);
92513
93670
  }
92514
93671
  const entryRecord = this.memberById.get(args.member.entryMemberId);
@@ -92610,7 +93767,7 @@ var init_project_version_static_value_writes = __esm({
92610
93767
  }
92611
93768
  collectOwnedBody(args) {
92612
93769
  const member = resolveMember2(args.member, this.document.members);
92613
- if (isMemberClassBase(member) && isStringRecord5(args.body)) {
93770
+ if (isMemberClassBase(member) && isStringRecord6(args.body)) {
92614
93771
  const effectiveClassId = args.classId ?? member.classId;
92615
93772
  const env = resolveInstanceEnv(
92616
93773
  effectiveClassId,
@@ -92657,7 +93814,7 @@ var init_project_version_static_value_writes = __esm({
92657
93814
  }
92658
93815
  return;
92659
93816
  }
92660
- if (isMemberDictionaryBase(member) && isStringRecord5(args.body)) {
93817
+ if (isMemberDictionaryBase(member) && isStringRecord6(args.body)) {
92661
93818
  const entryRecord = this.memberById.get(member.entryMemberId);
92662
93819
  if (entryRecord === void 0) return;
92663
93820
  const entryMember = substituteMember(
@@ -92823,7 +93980,7 @@ function materializeLocalizableStringWriteChanges(args) {
92823
93980
  )
92824
93981
  );
92825
93982
  if (valueChangeIds.size === 0) return changes;
92826
- const owners = resolveOwnerMembersForValues(
93983
+ const owners = resolveSemanticOwnerMembersForValues(
92827
93984
  args.postDocument,
92828
93985
  valueChangeIds
92829
93986
  );
@@ -92847,7 +94004,7 @@ function materializeLocalizableStringWriteChanges(args) {
92847
94004
  if (member === void 0) continue;
92848
94005
  additionalRoots.push({ member, valueId: rootId });
92849
94006
  }
92850
- const additionalOwners = resolveOwnerMembersForValues(
94007
+ const additionalOwners = resolveSemanticOwnerMembersForValues(
92851
94008
  args.postDocument,
92852
94009
  valueChangeIds,
92853
94010
  additionalRoots
@@ -92998,7 +94155,7 @@ var init_localizable_member_value_writes = __esm({
92998
94155
  init_localization2();
92999
94156
  init_members();
93000
94157
  init_project_version_intents();
93001
- init_value_row_owner_members();
94158
+ init_constructor_argument_ownership();
93002
94159
  }
93003
94160
  });
93004
94161
 
@@ -93352,7 +94509,7 @@ function prepareServerOwnedSchemaCommit(args) {
93352
94509
  contentHashHeads: args.contentHashHeads
93353
94510
  });
93354
94511
  const serverMintedBindingMemberIds = /* @__PURE__ */ new Set();
93355
- materializeAuthoredValueSeeds({
94512
+ const pendingConstructedGraphValidations = materializeAuthoredValueSeeds({
93356
94513
  document: applyProjectVersionWriteChanges(postDocument, prepared),
93357
94514
  prepared,
93358
94515
  authoredValueSeeds: args.authoredValueSeeds ?? [],
@@ -93383,6 +94540,11 @@ function prepareServerOwnedSchemaCommit(args) {
93383
94540
  document: applyProjectVersionWriteChanges(args.document, prepared)
93384
94541
  });
93385
94542
  }
94543
+ drainConstructedGraphValidations({
94544
+ document: args.document,
94545
+ prepared,
94546
+ pending: pendingConstructedGraphValidations
94547
+ });
93386
94548
  prepareServerOwnedDelegateValueBodies({
93387
94549
  document: args.document,
93388
94550
  postDocument,
@@ -93409,11 +94571,69 @@ function prepareServerOwnedSchemaCommit(args) {
93409
94571
  document: committedDocument,
93410
94572
  prepared
93411
94573
  });
94574
+ attachPreparedValuePlacements(prepared, committedDocument);
93412
94575
  attachPreparedConstructorAggregateEdges(prepared, committedDocument);
93413
94576
  return orderVariantRootValuesWithVariants(
93414
94577
  orderDeclaredMemberCreatesFirst(prepared, postDocument)
93415
94578
  );
93416
94579
  }
94580
+ function attachPreparedValuePlacements(prepared, document) {
94581
+ const creates = prepared.filter(
94582
+ (change) => change.recordKind === "value" && change.operation === "create"
94583
+ );
94584
+ if (creates.length === 0) return;
94585
+ const materializedGraph = new MaterializedValueGraphContext(document);
94586
+ const constructorEdges = [];
94587
+ for (const edges of materializedGraph.edgesByOwnerValueId.values()) {
94588
+ for (const edge of edges) {
94589
+ if (materializedGraph.referenceCountByTargetValueId.get(
94590
+ edge.targetValueId
94591
+ ) !== 1 || materializedGraph.independentlyOwnedValueIds.has(edge.targetValueId)) {
94592
+ continue;
94593
+ }
94594
+ const owner = materializedGraph.constructorArgumentOwnerPlacement(edge);
94595
+ if (owner === void 0) continue;
94596
+ constructorEdges.push({
94597
+ ownerValueId: edge.ownerValueId,
94598
+ targetValueId: edge.targetValueId,
94599
+ memberId: owner.memberId,
94600
+ parameterId: edge.parameterId,
94601
+ schemaKey: owner.schemaKey
94602
+ });
94603
+ }
94604
+ }
94605
+ const placements = projectValueHeadPlacementGraph({
94606
+ rootMembers: [
94607
+ { id: document.project.rootAssetsMemberId, label: "Assets" },
94608
+ { id: document.project.rootSaveFileMemberId, label: "Save" },
94609
+ { id: document.project.rootSessionMemberId, label: "Session" }
94610
+ ],
94611
+ variantRoots: (document.variants ?? []).map((variant) => ({
94612
+ variantId: variant.id,
94613
+ valueId: variant.valueId
94614
+ })),
94615
+ members: document.members,
94616
+ classes: document.classes,
94617
+ values: document.values,
94618
+ constructorEdges
94619
+ });
94620
+ for (const change of creates) {
94621
+ const placement = placements.get(change.recordId);
94622
+ if (placement === void 0) continue;
94623
+ change.serverValuePlacement = {
94624
+ valueMemberId: placement.valueMemberId,
94625
+ parentRecordKind: placement.parentRecordKind,
94626
+ parentRecordId: placement.parentRecordId,
94627
+ parentRelation: placement.parentRelation,
94628
+ valuePlacementScope: placement.valuePlacementScope,
94629
+ valueOwnerId: placement.valueOwnerId,
94630
+ valueRootMemberId: placement.valueRootMemberId,
94631
+ valueClassId: placement.valueClassId,
94632
+ valueSearchClassName: placement.valueSearchClassName,
94633
+ valueSearchPlacementPath: placement.valueSearchPlacementPath
94634
+ };
94635
+ }
94636
+ }
93417
94637
  function attachPreparedConstructorAggregateEdges(prepared, document) {
93418
94638
  const valueChanges = prepared.filter(
93419
94639
  (change) => change.recordKind === "value" && change.operation !== "delete"
@@ -93496,16 +94716,13 @@ function materializePreparedInstanceInitializers(args) {
93496
94716
  compiledDocument,
93497
94717
  compiledDocument.variants ?? []
93498
94718
  );
93499
- const owners = resolveOwnerMembersForValues(
94719
+ const owners = resolveSemanticOwnerMembersForValues(
93500
94720
  materializationScope.document,
93501
94721
  new Set(sites.keys()),
93502
94722
  materializationScope.roots,
93503
94723
  void 0,
93504
94724
  rootKinds
93505
94725
  );
93506
- const variantRootValueIds = new Set(
93507
- materializationScope.roots.map((root) => root.valueId)
93508
- );
93509
94726
  const replayOnlyIndexes = [];
93510
94727
  for (const [valueId, site] of sites) {
93511
94728
  const existingRoot = existingValueById.get(valueId);
@@ -93520,12 +94737,15 @@ function materializePreparedInstanceInitializers(args) {
93520
94737
  );
93521
94738
  }
93522
94739
  const materialized = materializeInitializerValue({
93523
- // The scope document, so the evaluator can close `NeoVariant<TObject>`
93524
- // through the same synthetic binding member the ownership walk used.
94740
+ // Every site that survives the declaration-default guard is source for
94741
+ // a persisted instance construction. The trusted replay mode both
94742
+ // admits Immutable storage and installs the concrete generic slot; the
94743
+ // CLI uses the same mode on the first push, so it cannot be conditional
94744
+ // on a literal row already existing.
93525
94745
  document: materializationScope.document,
93526
94746
  member,
93527
94747
  row: site.row,
93528
- ...existingConstructedRoot || variantRootValueIds.has(valueId) ? { storedConstructionReplay: true } : {}
94748
+ storedConstructionReplay: true
93529
94749
  });
93530
94750
  if (existingConstructedRoot) {
93531
94751
  if (!isLiteralValueContent(materialized.root) || existingRoot.classId !== materialized.root.classId || !replayedCreationDataMatches({
@@ -93551,7 +94771,7 @@ function materializePreparedInstanceInitializers(args) {
93551
94771
  init: withoutInitializerConstructionFields(site.row.init)
93552
94772
  },
93553
94773
  constructionBaselineReplay: true,
93554
- ...variantRootValueIds.has(valueId) ? { storedConstructionReplay: true } : {}
94774
+ storedConstructionReplay: true
93555
94775
  });
93556
94776
  const sparse = sparsifyConstructedInstance({
93557
94777
  document: materializationScope.document,
@@ -94532,8 +95752,12 @@ function appendDerivedDialogueChanges(args) {
94532
95752
  }
94533
95753
  function drainConstructedGraphValidations(args) {
94534
95754
  if (args.pending.length === 0) return;
95755
+ const postDocument = applyProjectVersionWriteChanges(
95756
+ args.document,
95757
+ args.prepared
95758
+ );
94535
95759
  const sameTransactionValues = new Map(
94536
- args.document.values.map((value) => [value.id, value])
95760
+ postDocument.values.map((value) => [value.id, value])
94537
95761
  );
94538
95762
  for (const change of args.prepared) {
94539
95763
  if (change.recordKind !== "value") continue;
@@ -94548,8 +95772,17 @@ function drainConstructedGraphValidations(args) {
94548
95772
  );
94549
95773
  }
94550
95774
  for (const validation of args.pending) {
95775
+ const validationDocument = {
95776
+ ...postDocument,
95777
+ localizedTexts: validation.document.localizedTexts
95778
+ };
95779
+ const member = validationDocument.members.find(
95780
+ (candidate) => candidate.id === validation.member.id
95781
+ ) ?? validation.member;
94551
95782
  validateConstructedStaticValueGraph({
94552
95783
  ...validation,
95784
+ document: validationDocument,
95785
+ member,
94553
95786
  sameTransactionValues
94554
95787
  });
94555
95788
  }
@@ -94587,9 +95820,57 @@ function hasLiveMemberChange(prepared) {
94587
95820
  (change) => change.recordKind === "member" && change.operation !== "delete" && change.nextData !== void 0
94588
95821
  );
94589
95822
  }
95823
+ function withProspectiveAuthoredSeedValues(document, seeds) {
95824
+ const prospective = [];
95825
+ const envelope = {
95826
+ projectId: document.project.id,
95827
+ createdAt: 0,
95828
+ updatedAt: 0
95829
+ };
95830
+ for (const seed of seeds) {
95831
+ if (seed.valueId !== void 0 && !isAuthoredValueSeedInitContent(seed)) {
95832
+ prospective.push({
95833
+ ...envelope,
95834
+ id: seed.valueId,
95835
+ value: structuredClone(seed.value),
95836
+ ...typeof seed.classId === "string" ? { classId: seed.classId } : {},
95837
+ ...pickInstanceProvenance(seed)
95838
+ });
95839
+ }
95840
+ for (const row of seed.values ?? []) {
95841
+ if (isAuthoredValueSeedInitContent(row)) continue;
95842
+ prospective.push({
95843
+ ...envelope,
95844
+ id: row.id,
95845
+ value: structuredClone(row.value),
95846
+ ...typeof row.classId === "string" ? { classId: row.classId } : {},
95847
+ ...row.containerId === void 0 ? {} : { containerId: row.containerId },
95848
+ ...row.genericBindings === void 0 ? {} : { genericBindings: { ...row.genericBindings } },
95849
+ ...row.sourceValueId === void 0 ? {} : { sourceValueId: row.sourceValueId },
95850
+ ...pickInstanceProvenance(row)
95851
+ });
95852
+ }
95853
+ }
95854
+ if (prospective.length === 0) return document;
95855
+ const seedByMemberId = new Map(
95856
+ seeds.filter((seed) => typeof seed.valueId === "string").map((seed) => [seed.memberId, seed])
95857
+ );
95858
+ return {
95859
+ ...document,
95860
+ members: document.members.map((member) => {
95861
+ const seed = seedByMemberId.get(member.id);
95862
+ if (seed?.valueId === void 0) return member;
95863
+ if (member.isStatic !== true && !isProjectRootMember(document.project, member.id)) {
95864
+ return member;
95865
+ }
95866
+ return { ...member, valueId: seed.valueId };
95867
+ }),
95868
+ values: overlayCreatedValues(document.values, prospective)
95869
+ };
95870
+ }
94590
95871
  function materializeAuthoredValueSeeds(args) {
94591
95872
  if (args.authoredValueSeeds.length === 0 && !hasLiveMemberChange(args.prepared)) {
94592
- return;
95873
+ return [];
94593
95874
  }
94594
95875
  const pendingGraphValidations = [];
94595
95876
  materializeStaticSeedBindingMembers(args);
@@ -94600,6 +95881,10 @@ function materializeAuthoredValueSeeds(args) {
94600
95881
  if (seedByMemberId.size !== args.authoredValueSeeds.length) {
94601
95882
  throw new Error("Schema commit contains duplicate member value seeds.");
94602
95883
  }
95884
+ const evaluationDocument = withProspectiveAuthoredSeedValues(
95885
+ args.document,
95886
+ args.authoredValueSeeds
95887
+ );
94603
95888
  const consumedSeedMemberIds = /* @__PURE__ */ new Set();
94604
95889
  for (let index = 0; index < args.prepared.length; index += 1) {
94605
95890
  const change = args.prepared[index];
@@ -94612,7 +95897,7 @@ function materializeAuthoredValueSeeds(args) {
94612
95897
  if (seed === void 0) continue;
94613
95898
  consumedSeedMemberIds.add(member.id);
94614
95899
  materializeInstanceDefaultSeed({
94615
- document: args.document,
95900
+ document: evaluationDocument,
94616
95901
  documentIndex,
94617
95902
  prepared: args.prepared,
94618
95903
  pendingGraphValidations,
@@ -94668,10 +95953,10 @@ function materializeAuthoredValueSeeds(args) {
94668
95953
  ...seed === void 0 ? {} : { defaultValue: seedValueContent(seed) }
94669
95954
  };
94670
95955
  const materialized = seed?.values === void 0 && (seed === void 0 || !isAuthoredValueSeedInitContent(seed)) ? materializeDefaultStaticSeed({
94671
- document: args.document,
95956
+ document: evaluationDocument,
94672
95957
  member: materializationMember
94673
95958
  }) : materializeAuthoredStaticSeed({
94674
- document: args.document,
95959
+ document: evaluationDocument,
94675
95960
  documentIndex,
94676
95961
  member: materializationMember,
94677
95962
  // P61 must leave a computed static root as an init-backed prepared
@@ -94770,7 +96055,7 @@ function materializeAuthoredValueSeeds(args) {
94770
96055
  const member = documentIndex.membersById.get(seed.memberId);
94771
96056
  if (member !== void 0 && member.isStatic !== true && !isProjectRootMember(args.document.project, member.id)) {
94772
96057
  materializeInstanceDefaultSeed({
94773
- document: args.document,
96058
+ document: evaluationDocument,
94774
96059
  documentIndex,
94775
96060
  prepared: args.prepared,
94776
96061
  pendingGraphValidations,
@@ -94782,7 +96067,7 @@ function materializeAuthoredValueSeeds(args) {
94782
96067
  continue;
94783
96068
  }
94784
96069
  materializeExistingAuthoredValueSeed({
94785
- document: args.document,
96070
+ document: evaluationDocument,
94786
96071
  documentIndex,
94787
96072
  prepared: args.prepared,
94788
96073
  pendingGraphValidations,
@@ -94791,11 +96076,7 @@ function materializeAuthoredValueSeeds(args) {
94791
96076
  });
94792
96077
  consumedSeedMemberIds.add(seed.memberId);
94793
96078
  }
94794
- drainConstructedGraphValidations({
94795
- document: args.document,
94796
- prepared: args.prepared,
94797
- pending: pendingGraphValidations
94798
- });
96079
+ return pendingGraphValidations;
94799
96080
  }
94800
96081
  function materializeExistingAuthoredValueSeed(args) {
94801
96082
  const member = args.documentIndex.membersById.get(args.seed.memberId);
@@ -95873,7 +97154,7 @@ function collectTouchedInitializerSites(args) {
95873
97154
  args.document,
95874
97155
  args.document.variants ?? []
95875
97156
  );
95876
- const ownerByValueId = resolveOwnerMembersForValues(
97157
+ const ownerByValueId = resolveSemanticOwnerMembersForValues(
95877
97158
  initScope.document,
95878
97159
  new Set(initRows.map((row) => row.id)),
95879
97160
  initScope.roots
@@ -95897,19 +97178,18 @@ function collectTouchedInitializerSites(args) {
95897
97178
  function assertProducedGraphLookupsResolve(args) {
95898
97179
  if (args.createdValues.length === 0) return;
95899
97180
  const rootMember = args.produced.classId === null ? args.site.member : { ...args.site.member, classId: args.produced.classId };
95900
- const graphValues = overlayCreatedValues(
95901
- args.document.values,
95902
- args.createdValues
95903
- );
97181
+ const graphValues = args.createdValues;
95904
97182
  const rootRow = {
95905
97183
  id: `${args.site.label}:root`,
95906
97184
  projectId: args.document.project.id,
95907
97185
  value: args.produced.value,
95908
97186
  classId: args.produced.classId,
97187
+ ...args.produced.constructorArgs === void 0 ? {} : { constructorArgs: args.produced.constructorArgs },
97188
+ ...args.produced.instanceConstructorId === void 0 ? {} : { instanceConstructorId: args.produced.instanceConstructorId },
95909
97189
  createdAt: 0,
95910
97190
  updatedAt: 0
95911
97191
  };
95912
- const ownerByValueId = resolveOwnerMembersForValues(
97192
+ const ownerByValueId = resolveSemanticOwnerMembersForValues(
95913
97193
  { ...args.document, values: [...graphValues, rootRow] },
95914
97194
  new Set(args.createdValues.map((value) => value.id)),
95915
97195
  [{ member: rootMember, valueId: rootRow.id }]
@@ -95972,7 +97252,7 @@ function prepareServerOwnedValueInitializerBodies(args) {
95972
97252
  committedDocument,
95973
97253
  committedDocument.variants ?? []
95974
97254
  );
95975
- const ownerByValueId = resolveOwnerMembersForValues(
97255
+ const ownerByValueId = resolveSemanticOwnerMembersForValues(
95976
97256
  initScope.document,
95977
97257
  ownershipTargetIds,
95978
97258
  initScope.roots,
@@ -95988,8 +97268,6 @@ function prepareServerOwnedValueInitializerBodies(args) {
95988
97268
  `Value "${row.id}" carries an initializer but no member in this project version stores it, so its declared type is unknown.`
95989
97269
  );
95990
97270
  }
95991
- const currentValue = currentValueById.get(row.id);
95992
- const replaysStoredConstruction = isLiteralValueContent(currentValue) && (typeof currentValue.classId === "string" || currentValue.constructorArgs !== void 0);
95993
97271
  const ownerContext = initializerOwnerContext(
95994
97272
  document,
95995
97273
  row.id,
@@ -96008,8 +97286,12 @@ function prepareServerOwnedValueInitializerBodies(args) {
96008
97286
  valueRow: row,
96009
97287
  valueId: row.id,
96010
97288
  initializerOwnerClass: ownerContext.ownerClass,
96011
- lexicalThisClass: initializerReferencesLexicalThis(row.init.code) ? ownerContext.lexicalThisClass : null,
96012
- ...replaysStoredConstruction ? { storedConstructionReplay: true } : {}
97289
+ lexicalThisClass: ownerContext.lexicalThisClass,
97290
+ // A value-row initializer is source for a persisted construction, never
97291
+ // an ad-hoc runtime `new`. The CLI replay compiler uses this same mode;
97292
+ // applying it only after a literal row already existed made the first
97293
+ // push of an Immutable declaration fail while its second push passed.
97294
+ storedConstructionReplay: true
96013
97295
  });
96014
97296
  };
96015
97297
  for (const [index, row] of explicitRows) {
@@ -96123,7 +97405,12 @@ function compileInlineDelegateConstructorArguments(args) {
96123
97405
  );
96124
97406
  }
96125
97407
  const rowConstructorId = row.instanceConstructorId;
96126
- const constructorId = typeof rowConstructorId === "string" ? rowConstructorId : schemaClass2.requiredConstructorId ?? null;
97408
+ if (typeof rowConstructorId !== "string") {
97409
+ throw new Error(
97410
+ `Value "${row.id}" carries inline delegate constructor arguments without a recorded constructor id.`
97411
+ );
97412
+ }
97413
+ const constructorId = rowConstructorId;
96127
97414
  const constructorRecord = (document.constructors ?? []).find(
96128
97415
  (candidate) => candidate.id === constructorId
96129
97416
  );
@@ -96159,7 +97446,8 @@ function compileInlineDelegateConstructorArguments(args) {
96159
97446
  const settled = constructorSettledSchemaEntry(
96160
97447
  document,
96161
97448
  classId,
96162
- parameter4.name
97449
+ parameter4.name,
97450
+ constructorRecord.id
96163
97451
  );
96164
97452
  const settledMember = document.members.find(
96165
97453
  (candidate) => candidate.id === settled?.memberId
@@ -96222,7 +97510,7 @@ function prepareServerOwnedDelegateValueBodies(args) {
96222
97510
  committedDocument,
96223
97511
  committedDocument.variants ?? []
96224
97512
  );
96225
- const ownerByValueId = resolveOwnerMembersForValues(
97513
+ const ownerByValueId = resolveSemanticOwnerMembersForValues(
96226
97514
  delegateScope.document,
96227
97515
  targetIds,
96228
97516
  delegateScope.roots,
@@ -96980,13 +98268,16 @@ function reconcileVariantConstructorArgs(args) {
96980
98268
  if (canonicallyEqual2(rowValue, defaultValue)) continue;
96981
98269
  nextArgs[parameterId] = rowValue;
96982
98270
  }
96983
- const stampIsMissing = root.instanceConstructorId === void 0;
96984
- const changed = stampIsMissing || !canonicallyEqual2(existingArgs, nextArgs);
98271
+ if (root.instanceConstructorId !== constructorId) {
98272
+ throw new Error(
98273
+ `Variant root "${root.id}" must record constructor "${constructorId}" before its arguments can be reconciled.`
98274
+ );
98275
+ }
98276
+ const changed = !canonicallyEqual2(existingArgs, nextArgs);
96985
98277
  if (!changed) continue;
96986
98278
  const nextRoot = {
96987
98279
  ...root,
96988
- constructorArgs: nextArgs,
96989
- ...stampIsMissing ? { instanceConstructorId: constructorId } : {}
98280
+ constructorArgs: nextArgs
96990
98281
  };
96991
98282
  const existingIndex = changeIndexByValueId.get(root.id);
96992
98283
  if (existingIndex !== void 0) {
@@ -97093,6 +98384,7 @@ var init_project_version_schema_commit = __esm({
97093
98384
  init_project_document_value_overlay();
97094
98385
  init_project2();
97095
98386
  init_member_access_modifier_validation();
98387
+ init_valueHeadPlacementGraph();
97096
98388
  init_variant_value_graph();
97097
98389
  init_variants2();
97098
98390
  init_localization2();
@@ -97115,6 +98407,7 @@ var init_project_version_schema_commit = __esm({
97115
98407
  init_value_row_owner_members();
97116
98408
  init_init_backed_value_materialization();
97117
98409
  init_constructor_argument_ownership();
98410
+ init_constructors2();
97118
98411
  init_dialogue_node_index();
97119
98412
  init_dist_node();
97120
98413
  init_member_value_id();
@@ -97421,7 +98714,10 @@ function assertProtectedValuesNotReplaced(document, changes) {
97421
98714
  candidateValueIds.add(childId);
97422
98715
  }
97423
98716
  }
97424
- const owners = resolveOwnerMembersForValues(document, candidateValueIds);
98717
+ const owners = resolveSemanticOwnerMembersForValues(
98718
+ document,
98719
+ candidateValueIds
98720
+ );
97425
98721
  for (const valueId of candidateValueIds) {
97426
98722
  const owner = owners.get(valueId);
97427
98723
  if (owner === void 0) continue;
@@ -97520,7 +98816,7 @@ var init_project_version_system_protection_writes = __esm({
97520
98816
  init_project_record_semantics();
97521
98817
  init_system_protection();
97522
98818
  init_system_protection();
97523
- init_value_row_owner_members();
98819
+ init_constructor_argument_ownership();
97524
98820
  SYSTEM_BEARING_RECORD_KINDS = [
97525
98821
  { recordKind: "member", collection: "members" },
97526
98822
  { recordKind: "class", collection: "classes" },
@@ -97707,7 +99003,7 @@ function toWorldReferenceClassRecord(value) {
97707
99003
  return {
97708
99004
  id: id2,
97709
99005
  extendsClassId: nullableStringField(value, "extendsClassId"),
97710
- schema: isStringRecord6(value.schema) ? value.schema : void 0,
99006
+ schema: isStringRecord7(value.schema) ? value.schema : void 0,
97711
99007
  system: isPlainRecord4(value.system) ? value.system : null
97712
99008
  };
97713
99009
  }
@@ -97725,7 +99021,7 @@ function worldReferenceValueClassId(value) {
97725
99021
  if (value === void 0) return null;
97726
99022
  return typeof value.classId === "string" && value.classId.length > 0 ? value.classId : null;
97727
99023
  }
97728
- function isStringRecord6(value) {
99024
+ function isStringRecord7(value) {
97729
99025
  if (!isPlainRecord4(value)) return false;
97730
99026
  return Object.values(value).every((entry) => typeof entry === "string");
97731
99027
  }
@@ -97785,6 +99081,7 @@ function assertProjectVersionWholeGraphWritesValid(args) {
97785
99081
  document: args.document,
97786
99082
  changes: args.changes
97787
99083
  });
99084
+ assertStagedUnorderedContainmentValid(args.document, projected, args.changes);
97788
99085
  assertStagedSchemaIdentifiersValid(projected, args.changes);
97789
99086
  assertStagedActionListenersValid(projected, args.changes);
97790
99087
  assertStagedVariantMemberValuesValid(projected, args.changes);
@@ -97811,6 +99108,65 @@ function assertProjectVersionWholeGraphWritesValid(args) {
97811
99108
  });
97812
99109
  }
97813
99110
  }
99111
+ function assertStagedUnorderedContainmentValid(current, projected, changes) {
99112
+ const currentValues = new Map(
99113
+ current.values.map((value) => [value.id, value])
99114
+ );
99115
+ const projectedValues = new Map(
99116
+ projected.values.map((value) => [value.id, value])
99117
+ );
99118
+ const projectedMemberByContainerId = /* @__PURE__ */ new Map();
99119
+ for (const value of projected.values) {
99120
+ if (typeof value.containerId !== "string") continue;
99121
+ if (!projectedMemberByContainerId.has(value.containerId)) {
99122
+ projectedMemberByContainerId.set(value.containerId, value);
99123
+ }
99124
+ }
99125
+ for (const change of changes) {
99126
+ if (change.recordKind !== "value") continue;
99127
+ const before = currentValues.get(change.recordId);
99128
+ const after = projectedValues.get(change.recordId);
99129
+ const beforeContainerId = typeof before?.containerId === "string" ? before.containerId : null;
99130
+ const afterContainerId = typeof after?.containerId === "string" ? after.containerId : null;
99131
+ if (before !== void 0 && after !== void 0 && beforeContainerId !== afterContainerId) {
99132
+ throw new Error(
99133
+ `Value "${change.recordId}" cannot change containerId from ${beforeContainerId === null ? "unset" : `"${beforeContainerId}"`} to ${afterContainerId === null ? "unset" : `"${afterContainerId}"`}: unordered-list membership is stamped at creation and immutable (move = delete + recreate).`
99134
+ );
99135
+ }
99136
+ if (before === void 0 && afterContainerId !== null) {
99137
+ if (afterContainerId === change.recordId) {
99138
+ throw new Error(
99139
+ `Value "${change.recordId}" cannot declare itself as its own containerId.`
99140
+ );
99141
+ }
99142
+ const container = projectedValues.get(afterContainerId);
99143
+ if (container === void 0) {
99144
+ throw new Error(
99145
+ `Value "${change.recordId}" joins container "${afterContainerId}", but no live value with that id exists in the projected transaction.`
99146
+ );
99147
+ }
99148
+ if (container.value === null) {
99149
+ throw new Error(
99150
+ `Value "${change.recordId}" joins container "${afterContainerId}", but that list is null \u2014 set the list to [] (a fresh instance) before adding entries.`
99151
+ );
99152
+ }
99153
+ if (!Array.isArray(container.value) || container.value.length > 0) {
99154
+ throw new Error(
99155
+ `Value "${change.recordId}" joins container "${afterContainerId}", but that value does not look like an unordered list container (expected value [] \u2014 got ${Array.isArray(container.value) ? "a non-empty array (ordered list)" : typeof container.value}).`
99156
+ );
99157
+ }
99158
+ }
99159
+ const becameNull = before !== void 0 && after !== void 0 && Array.isArray(before.value) && before.value.length === 0 && after.value === null;
99160
+ if (after === void 0 || becameNull) {
99161
+ const stranded = projectedMemberByContainerId.get(change.recordId);
99162
+ if (stranded !== void 0) {
99163
+ throw new Error(
99164
+ `Value "${change.recordId}" cannot be ${after === void 0 ? "deleted" : "set to null"} while member "${stranded.id}" is still live: cascade-delete the unordered list's members first.`
99165
+ );
99166
+ }
99167
+ }
99168
+ }
99169
+ }
97814
99170
  function assertNoValueDematerialization(args) {
97815
99171
  const updates = args.changes.filter(
97816
99172
  (change) => change.recordKind === "value" && change.operation === "update" && change.deleted !== true
@@ -97861,7 +99217,7 @@ function materializeDeclarationInitializersForAnimationValidation(document) {
97861
99217
  return document;
97862
99218
  }
97863
99219
  const rootKinds = /* @__PURE__ */ new Map();
97864
- const owners = resolveOwnerMembersForValues(
99220
+ const owners = resolveSemanticOwnerMembersForValues(
97865
99221
  document,
97866
99222
  new Set(initializers.map((value) => value.id)),
97867
99223
  void 0,
@@ -97960,16 +99316,45 @@ function materializeDeclarationInitializersForAnimationValidation(document) {
97960
99316
  }
97961
99317
  return member;
97962
99318
  });
99319
+ const constructorGraph = new MaterializedValueGraphContext(document);
99320
+ const deferredParametersByParentId = /* @__PURE__ */ new Map();
99321
+ for (const [parentId, edges] of constructorGraph.edgesByOwnerValueId) {
99322
+ for (const edge of edges) {
99323
+ if (!deferred.has(edge.targetValueId)) continue;
99324
+ const parameterIds = deferredParametersByParentId.get(parentId) ?? /* @__PURE__ */ new Set();
99325
+ parameterIds.add(edge.parameterId);
99326
+ deferredParametersByParentId.set(parentId, parameterIds);
99327
+ }
99328
+ }
97963
99329
  const parentIds = new Set(
97964
- [...valuesById.values()].flatMap(
97965
- (row) => containsDirectValueId(row.value, deferred) ? [row.id] : []
97966
- )
99330
+ [
99331
+ [...valuesById.values()].flatMap(
99332
+ (row) => containsDirectValueId(row.value, deferred) ? [row.id] : []
99333
+ ),
99334
+ ...deferredParametersByParentId.keys()
99335
+ ].flat()
99336
+ );
99337
+ const parentOwners = resolveSemanticOwnerMembersForValues(
99338
+ document,
99339
+ parentIds
97967
99340
  );
97968
- const parentOwners = resolveOwnerMembersForValues(document, parentIds);
97969
99341
  for (const id2 of parentIds) {
97970
- const row = valuesById.get(id2);
99342
+ let row = valuesById.get(id2);
99343
+ if (row === void 0) continue;
97971
99344
  const owner = parentOwners.get(id2);
97972
- if (row === void 0 || owner === void 0) continue;
99345
+ const deferredParameters = deferredParametersByParentId.get(id2);
99346
+ if (deferredParameters !== void 0 && isLiteralValueContent(row) && row.constructorArgs !== void 0 && row.constructorArgs !== null) {
99347
+ row = {
99348
+ ...row,
99349
+ constructorArgs: Object.fromEntries(
99350
+ Object.entries(row.constructorArgs).filter(
99351
+ ([parameterId]) => !deferredParameters.has(parameterId)
99352
+ )
99353
+ )
99354
+ };
99355
+ valuesById.set(id2, row);
99356
+ }
99357
+ if (owner === void 0) continue;
97973
99358
  if (isMemberListBase(owner) && Array.isArray(row.value)) {
97974
99359
  valuesById.set(id2, {
97975
99360
  ...row,
@@ -98273,7 +99658,10 @@ function assertStagedActionListenersValid(projected, changes) {
98273
99658
  const rowsById = new Map(
98274
99659
  projected.values.map((value) => [value.id, value])
98275
99660
  );
98276
- const owners = resolveOwnerMembersForValues(projected, candidateRowIds);
99661
+ const owners = resolveSemanticOwnerMembersForValues(
99662
+ projected,
99663
+ candidateRowIds
99664
+ );
98277
99665
  for (const [rowId, owner] of owners) {
98278
99666
  if (owner.kind !== 26 /* NSAction */) continue;
98279
99667
  const row = rowsById.get(rowId);
@@ -98316,8 +99704,9 @@ function candidateActionListenerRowIds(projected, actions) {
98316
99704
  for (const action of actions) {
98317
99705
  if (typeof action.valueId === "string") candidates.add(action.valueId);
98318
99706
  }
98319
- if (actionSchemaKeys.size === 0) return candidates;
98320
99707
  for (const row of projected.values) {
99708
+ if (storedRowActionListeners(row).length > 0) candidates.add(row.id);
99709
+ if (actionSchemaKeys.size === 0) continue;
98321
99710
  if (!isPlainRecord(row.value)) continue;
98322
99711
  for (const schemaKey of actionSchemaKeys) {
98323
99712
  const childId = row.value[schemaKey];
@@ -98542,7 +99931,10 @@ function assertStagedVariantMemberValuesValid(projected, changes) {
98542
99931
  const rowsById = new Map(
98543
99932
  projected.values.map((value) => [value.id, value])
98544
99933
  );
98545
- const owners = resolveOwnerMembersForValues(projected, candidateRowIds);
99934
+ const owners = resolveSemanticOwnerMembersForValues(
99935
+ projected,
99936
+ candidateRowIds
99937
+ );
98546
99938
  for (const [rowId, owner] of owners) {
98547
99939
  if (owner.kind !== 27 /* Variant */) continue;
98548
99940
  const row = rowsById.get(rowId);
@@ -98744,8 +100136,11 @@ function candidateVariantRowIds(projected, variantMembers) {
98744
100136
  for (const member of variantMembers) {
98745
100137
  if (typeof member.valueId === "string") candidates.add(member.valueId);
98746
100138
  }
98747
- if (schemaKeys.size === 0) return candidates;
98748
100139
  for (const row of projected.values) {
100140
+ if (row.value === null || isVariantRefValue(row.value)) {
100141
+ candidates.add(row.id);
100142
+ }
100143
+ if (schemaKeys.size === 0) continue;
98749
100144
  if (!isPlainRecord(row.value)) continue;
98750
100145
  for (const schemaKey of schemaKeys) {
98751
100146
  const childId = row.value[schemaKey];
@@ -98780,7 +100175,7 @@ var init_project_version_whole_graph_validation = __esm({
98780
100175
  init_generics();
98781
100176
  init_inheritance();
98782
100177
  init_neoscript();
98783
- init_value_row_owner_members();
100178
+ init_constructor_argument_ownership();
98784
100179
  init_init_backed_value_materialization();
98785
100180
  init_world_system_classes();
98786
100181
  init_project_world_reference_graph();
@@ -100827,8 +102222,10 @@ function compareInitializerMaterialization(expected, received) {
100827
102222
  const normalizedReceived = normalize(received);
100828
102223
  if (canonicalStringify(normalizedExpected) !== canonicalStringify(normalizedReceived)) {
100829
102224
  const difference = firstDifference(normalizedExpected, normalizedReceived);
102225
+ const rootIndex = difference === null ? null : /^\$\.roots\[(\d+)\]/u.exec(difference.path)?.[1];
102226
+ const sourceValueId = rootIndex === null || rootIndex === void 0 ? void 0 : normalizedExpected.roots[Number(rootIndex)]?.sourceValueId;
100830
102227
  throw new ProjectSourceCommitVerificationError(
100831
- `Source commit initializer materialization does not match trusted evaluation${difference === null ? "." : ` at ${difference.path}: trusted ${formatDifferenceValue(difference.trusted)}, submitted ${formatDifferenceValue(difference.submitted)}.`}`
102228
+ `Source commit initializer materialization does not match trusted evaluation${difference === null ? "." : `${sourceValueId === void 0 ? "" : ` for root ${JSON.stringify(sourceValueId)}`} at ${difference.path}: trusted ${formatDifferenceValue(difference.trusted)}, submitted ${formatDifferenceValue(difference.submitted)}.`}`
100832
102229
  );
100833
102230
  }
100834
102231
  }
@@ -101242,7 +102639,7 @@ function replayStoredConstructionV4(args) {
101242
102639
  // Instance calls are self-contained. Declaration calls inherit the class
101243
102640
  // header parameters that are in lexical scope at their source site.
101244
102641
  initializerOwnerClass: args.initializerOwnerClass ?? null,
101245
- lexicalThisClass: initializerReferencesLexicalThis(args.code) ? args.lexicalThisClass ?? null : null,
102642
+ lexicalThisClass: args.lexicalThisClass ?? null,
101246
102643
  storedConstructionReplay: true,
101247
102644
  ...compilationProject === void 0 ? {} : { compilationProject }
101248
102645
  });
@@ -101441,20 +102838,6 @@ function compilePulledProjectDocumentForEvaluationV4(document, compilationProjec
101441
102838
  throw error;
101442
102839
  }
101443
102840
  }
101444
- for (const site of valueInitializerCompilationSites(document).values()) {
101445
- if (isInitValueContent(site.row) && site.row.init.compiled !== void 0) {
101446
- continue;
101447
- }
101448
- compileValueRowInitializerBody({
101449
- ...compileArgs,
101450
- member: site.member,
101451
- valueRow: site.row,
101452
- valueId: String(Reflect.get(site.row, "id")),
101453
- initializerOwnerClass: site.ownerClass,
101454
- lexicalThisClass: site.lexicalThisClass,
101455
- storedConstructionReplay: true
101456
- });
101457
- }
101458
102841
  }
101459
102842
  function assertPulledConstructorsCompiled(document) {
101460
102843
  const uncompiled = (document.constructors ?? []).find(
@@ -101682,6 +103065,14 @@ function buildValueEmitContext(records2, manifest) {
101682
103065
  mainLocale: projectMainLocale(records2),
101683
103066
  symbolsByValueId,
101684
103067
  rootPathsByValueId: rootValuePathsByValueId(records2.values()),
103068
+ collectionBindingValueIds: /* @__PURE__ */ new Set([
103069
+ ...manifest.members.flatMap(
103070
+ (member) => member.kind === "lookup" && typeof member.collectionValueId === "string" ? [member.collectionValueId] : []
103071
+ ),
103072
+ ...(manifest.variantFolders ?? []).flatMap(
103073
+ (folder) => folder.binding === null ? [] : [folder.binding.collectionValueId]
103074
+ )
103075
+ ]),
101685
103076
  variantPathsById: buildVariantPathsByIdV4(manifest),
101686
103077
  symbolsByDialogueId: new Map(
101687
103078
  [...dialogues].flatMap(
@@ -101923,7 +103314,7 @@ function emitStoredConstructorExpression(context, member, valueId, visited = /*
101923
103314
  `Stored construction ${valueId} belongs to a non-Class member.`
101924
103315
  );
101925
103316
  }
101926
- const classId = stringOrNull(value.classId) ?? stringField3(resolvedMember, "classId");
103317
+ const classId = stringOrNull2(value.classId) ?? stringField3(resolvedMember, "classId");
101927
103318
  const schemaClass2 = context.classes.get(classId);
101928
103319
  if (schemaClass2 === void 0) {
101929
103320
  throw new Error(`Unknown value class ${classId}.`);
@@ -102133,6 +103524,7 @@ function createValueLowerRegistryV4(options = {}) {
102133
103524
  return {
102134
103525
  materializedConstructorExpressions: options.materializedConstructorExpressions ?? /* @__PURE__ */ new Map(),
102135
103526
  pendingValues: /* @__PURE__ */ new Map(),
103527
+ pendingContainerChildCounts: /* @__PURE__ */ new Map(),
102136
103528
  pendingLocalizedTexts: /* @__PURE__ */ new Map(),
102137
103529
  pendingBindingMembersByClassId: /* @__PURE__ */ new Map(),
102138
103530
  referenceObligations: [],
@@ -102199,6 +103591,10 @@ function buildValueLowerContext(state, manifest, options = {}) {
102199
103591
  manifest.classes,
102200
103592
  manifest.constructors
102201
103593
  );
103594
+ const stateRecords = Object.values(state);
103595
+ let storedValuePlacements;
103596
+ const readStoredValuePlacements = () => storedValuePlacements ??= buildStoredValuePlacementIndexV4(stateRecords);
103597
+ let rootValueTargets;
102202
103598
  return {
102203
103599
  state,
102204
103600
  members,
@@ -102218,7 +103614,21 @@ function buildValueLowerContext(state, manifest, options = {}) {
102218
103614
  ])
102219
103615
  ),
102220
103616
  staticValueIdsBySymbol: staticTargets,
102221
- rootValueTargetsByPath: rootValueTargetsByPath(Object.values(state)),
103617
+ get rootValueTargetsByPath() {
103618
+ return rootValueTargets ??= rootValueTargetsByPath(
103619
+ stateRecords,
103620
+ readStoredValuePlacements()
103621
+ );
103622
+ },
103623
+ readStoredValuePlacements,
103624
+ collectionBindingMemberIds: /* @__PURE__ */ new Set([
103625
+ ...manifest.members.flatMap(
103626
+ (member) => member.kind === "lookup" ? [member.collectionMemberId] : []
103627
+ ),
103628
+ ...(manifest.variantFolders ?? []).flatMap(
103629
+ (folder) => folder.binding === null ? [] : [folder.binding.collectionMemberId]
103630
+ )
103631
+ ]),
102222
103632
  variantPathTargets,
102223
103633
  dialogueTargetsBySymbol: dialogueTargetsBySymbol(options.analysis),
102224
103634
  projectFileIdsBySymbol: projectFileIdsBySymbol(state, options.analysis),
@@ -102229,6 +103639,7 @@ function buildValueLowerContext(state, manifest, options = {}) {
102229
103639
  reconstructed: /* @__PURE__ */ new Map(),
102230
103640
  retainedReconstructedKeys: /* @__PURE__ */ new Set(),
102231
103641
  pendingValues: registry.pendingValues,
103642
+ pendingContainerChildCounts: registry.pendingContainerChildCounts,
102232
103643
  pendingLocalizedTexts: registry.pendingLocalizedTexts,
102233
103644
  loweredMemberIdByValueId: /* @__PURE__ */ new Map(),
102234
103645
  storedClassSchemaMemberIds: /* @__PURE__ */ new Map(),
@@ -102507,6 +103918,7 @@ function variantConstructionExpression(binding) {
102507
103918
  return expression;
102508
103919
  }
102509
103920
  function indexStructuralStoredIds(context, rootValueId, rootPath) {
103921
+ const placements = context.readStoredValuePlacements();
102510
103922
  const visit = (valueId, path, depth) => {
102511
103923
  if (depth > 64) return;
102512
103924
  const data = context.state[`value:${valueId}`]?.data;
@@ -102532,26 +103944,12 @@ function indexStructuralStoredIds(context, rootValueId, rootPath) {
102532
103944
  visit(child, childPath, depth + 1);
102533
103945
  }
102534
103946
  }
102535
- const constructorArgs = data.constructorArgs;
102536
- const classId = data.classId;
102537
- const instanceConstructorId = data.instanceConstructorId;
102538
- if (isObjectRecord2(constructorArgs) && typeof classId === "string" && typeof instanceConstructorId === "string") {
102539
- const schemaClass2 = context.classes.get(classId);
102540
- const requiredId = schemaClass2?.requiredConstructorId;
102541
- const constructor2 = requiredId === void 0 ? void 0 : context.manifestConstructors.get(requiredId);
102542
- if (schemaClass2 !== void 0 && constructor2 !== void 0) {
102543
- const settledBy = structuralMemberByParameterName(context, schemaClass2);
102544
- constructor2.arguments.forEach((parameter4, index) => {
102545
- const schemaKey = settledBy.get(parameter4.name) ?? settledParameterSchemaKey(context, classId, parameter4.name);
102546
- const child = constructorArgs[`__arg_${index}__`];
102547
- if (schemaKey === void 0 || indexedSchemaKeys.has(schemaKey) || typeof child !== "string" || context.state[`value:${child}`] === void 0) {
102548
- return;
102549
- }
102550
- const childPath = `${path}.${schemaKey}`;
102551
- context.structuralStoredIds.set(childPath, child);
102552
- visit(child, childPath, depth + 1);
102553
- });
102554
- }
103947
+ for (const edge of placements.childrenByParentValueId.get(valueId)?.values() ?? []) {
103948
+ if (edge.source !== "constructor") continue;
103949
+ if (indexedSchemaKeys.has(edge.schemaKey)) continue;
103950
+ const childPath = `${path}.${edge.schemaKey}`;
103951
+ context.structuralStoredIds.set(childPath, edge.childValueId);
103952
+ visit(edge.childValueId, childPath, depth + 1);
102555
103953
  }
102556
103954
  };
102557
103955
  visit(rootValueId, rootPath, 0);
@@ -102856,7 +104254,7 @@ function lowerMemberDefaultSourcesV4(state, analysis, manifest, options = {}) {
102856
104254
  if (storedDefault !== null && canonicallyEqual(seed.value, storedDefault.value) && (seed.classId ?? null) === (typeof storedDefaultClassId === "string" ? storedDefaultClassId : null) && (seed.values === void 0 || seed.values.length === 0) && (seed.bindingMembers === void 0 || seed.bindingMembers.length === 0) && (seed.localizedTexts === void 0 || seed.localizedTexts.length === 0)) {
102857
104255
  for (const id2 of context.pendingValues.keys()) {
102858
104256
  if (!pendingValueIdsBeforeSeed.has(id2)) {
102859
- context.pendingValues.delete(id2);
104257
+ deletePendingValue(context, id2);
102860
104258
  }
102861
104259
  }
102862
104260
  memberDefaultValues.set(memberId, {
@@ -103356,7 +104754,7 @@ function classGenericEnvironment(context, classId) {
103356
104754
  }
103357
104755
  function lowerRowBackedDefault(context, member, backed, baseData3, binding) {
103358
104756
  const baseDefault = isObjectRecord2(baseData3.defaultValue) ? baseData3.defaultValue : {};
103359
- const storedClassId = stringOrNull(baseDefault.classId);
104757
+ const storedClassId = stringOrNull2(baseDefault.classId);
103360
104758
  const expression = annotatedValue(
103361
104759
  parseCachedInitializer(context.parsedInitializers, binding.initializer)
103362
104760
  ).expression;
@@ -103614,7 +105012,7 @@ function lowerStoredBinding(context, binding, memberValueIds, seeds) {
103614
105012
  );
103615
105013
  seeds.set(binding.memberId, {
103616
105014
  value: root.value,
103617
- classId: stringOrNull(root.classId),
105015
+ classId: stringOrNull2(root.classId),
103618
105016
  valueId,
103619
105017
  values: [...existingRows, ...pendingRows],
103620
105018
  ...bindingMembers.length === 0 ? {} : { bindingMembers },
@@ -103734,13 +105132,13 @@ function storedClassSchemaMemberIds(context, classId) {
103734
105132
  }
103735
105133
  }
103736
105134
  }
103737
- current = stringOrNull(data.extendsClassId);
105135
+ current = stringOrNull2(data.extendsClassId);
103738
105136
  }
103739
105137
  context.storedClassSchemaMemberIds.set(classId, memberIds);
103740
105138
  return memberIds;
103741
105139
  }
103742
105140
  function staticValueSeedRow(value, loweredMemberId) {
103743
- const id2 = stringOrNull(value.id);
105141
+ const id2 = stringOrNull2(value.id);
103744
105142
  if (id2 === null) throw new Error("Authored value row is missing id.");
103745
105143
  if (loweredMemberId === void 0) {
103746
105144
  throw new Error(`Authored value row ${id2} is missing memberId.`);
@@ -103765,7 +105163,7 @@ function staticValueSeedRow(value, loweredMemberId) {
103765
105163
  return {
103766
105164
  ...fields,
103767
105165
  value: value.value,
103768
- classId: stringOrNull(value.classId),
105166
+ classId: stringOrNull2(value.classId),
103769
105167
  // A seed row IS the row the push will materialize, and its consumer
103770
105168
  // (`staticValueSeedEmitRecords`) projects provenance straight back out
103771
105169
  // with `pickInstanceProvenance`. Dropping it here left a constructed row
@@ -104047,8 +105445,7 @@ function lowerSeedRow(context, member, sourceExpression, source, valueId, path,
104047
105445
  leaf,
104048
105446
  localizedTexts
104049
105447
  });
104050
- rows.delete(childId);
104051
- context.pendingValues.delete(childId);
105448
+ deleteSeedRow(context, rows, childId);
104052
105449
  }
104053
105450
  }
104054
105451
  for (const assignment of expression.initializer ?? []) {
@@ -104086,8 +105483,7 @@ function lowerSeedRow(context, member, sourceExpression, source, valueId, path,
104086
105483
  localizedTexts,
104087
105484
  environment
104088
105485
  })) {
104089
- rows.delete(childId);
104090
- context.pendingValues.delete(childId);
105486
+ deleteSeedRow(context, rows, childId);
104091
105487
  continue;
104092
105488
  }
104093
105489
  body[assignment.name] = childId;
@@ -104206,6 +105602,27 @@ function registerSeedRow(context, rows, row, source, expression) {
104206
105602
  }
104207
105603
  rows.set(row.id, row);
104208
105604
  context.pendingValues.set(row.id, row);
105605
+ if (row.containerId !== void 0) {
105606
+ context.pendingContainerChildCounts.set(
105607
+ row.containerId,
105608
+ (context.pendingContainerChildCounts.get(row.containerId) ?? 0) + 1
105609
+ );
105610
+ }
105611
+ }
105612
+ function deleteSeedRow(context, rows, valueId) {
105613
+ rows.delete(valueId);
105614
+ deletePendingValue(context, valueId);
105615
+ }
105616
+ function deletePendingValue(context, valueId) {
105617
+ const row = context.pendingValues.get(valueId);
105618
+ context.pendingValues.delete(valueId);
105619
+ if (row?.containerId === void 0) return;
105620
+ const remaining = (context.pendingContainerChildCounts.get(row.containerId) ?? 1) - 1;
105621
+ if (remaining === 0) {
105622
+ context.pendingContainerChildCounts.delete(row.containerId);
105623
+ } else {
105624
+ context.pendingContainerChildCounts.set(row.containerId, remaining);
105625
+ }
104209
105626
  }
104210
105627
  function storedSchemaEntries(context, schemaClass2) {
104211
105628
  const entries = /* @__PURE__ */ new Map();
@@ -104332,8 +105749,7 @@ function lowerStructuralConstructionRow(context, member, expression, source, val
104332
105749
  localizedTexts
104333
105750
  });
104334
105751
  constructorArgs[`__arg_${parameterIndex}__`] = inline;
104335
- rows.delete(childId);
104336
- context.pendingValues.delete(childId);
105752
+ deleteSeedRow(context, rows, childId);
104337
105753
  }
104338
105754
  });
104339
105755
  for (const assignment of expression.initializer ?? []) {
@@ -104362,8 +105778,7 @@ function lowerStructuralConstructionRow(context, member, expression, source, val
104362
105778
  localizedTexts,
104363
105779
  environment
104364
105780
  })) {
104365
- rows.delete(childId);
104366
- context.pendingValues.delete(childId);
105781
+ deleteSeedRow(context, rows, childId);
104367
105782
  continue;
104368
105783
  }
104369
105784
  value[assignment.name] = childId;
@@ -104519,7 +105934,7 @@ function lowerValueRow(context, member, sourceExpression, expectedValueId, sourc
104519
105934
  return expectedValueId;
104520
105935
  }
104521
105936
  const materializedClass = resolvedMember.kind === "class" && isObjectRecord2(base.value);
104522
- const effectiveClassId = resolvedMember.kind === "class" ? stringOrNull(base.classId) ?? resolvedMember.classId : null;
105937
+ const effectiveClassId = resolvedMember.kind === "class" ? stringOrNull2(base.classId) ?? resolvedMember.classId : null;
104523
105938
  const materializedPlainClass = materializedClass && effectiveClassId !== null && context.classes.get(effectiveClassId)?.requiredConstructorId === void 0;
104524
105939
  const requiresCanonicalConstruction = storedConstructorArgs === null && materializedClass && !materializedPlainClass;
104525
105940
  const canonicalConstruction = requiresCanonicalConstruction ? context.materializedConstructorExpressions.get(expectedValueId) : void 0;
@@ -104731,7 +106146,7 @@ function authoredResetSchemaKeys(context, base, expression, partial) {
104731
106146
  function lowerClassValue(context, member, expression, base, source, outerEnvironment, authoredSlice, materializedConstruction = "lower") {
104732
106147
  if (expression.kind !== "new")
104733
106148
  throw new Error("Class values require new(...).");
104734
- const currentClassId = stringOrNull(base.classId) ?? member.classId;
106149
+ const currentClassId = stringOrNull2(base.classId) ?? member.classId;
104735
106150
  const classId = constructedClass(
104736
106151
  context,
104737
106152
  member,
@@ -104875,8 +106290,7 @@ function lowerClassValue(context, member, expression, base, source, outerEnviron
104875
106290
  const constructor2 = storedValueConstructor(
104876
106291
  context,
104877
106292
  schemaClass2,
104878
- base.constructorArgs,
104879
- typeof base.instanceConstructorId === "string" ? base.instanceConstructorId : void 0
106293
+ recordedStoredConstructorId(base, schemaClass2)
104880
106294
  );
104881
106295
  const authoredArguments = constructorArgumentExpressions(expression);
104882
106296
  for (let index = 0; index < constructor2.arguments.length; index += 1) {
@@ -104990,7 +106404,7 @@ function retainStoredValueSubgraph(context, valueId, source, visited, member) {
104990
106404
  for (const entry of Object.values(value)) collect(entry, childMember);
104991
106405
  };
104992
106406
  const body = state.data.value;
104993
- const storedClassId = stringOrNull(state.data.classId);
106407
+ const storedClassId = stringOrNull2(state.data.classId);
104994
106408
  if (isObjectRecord2(body) && storedClassId !== null) {
104995
106409
  const storedMemberIds = storedClassSchemaMemberIds(context, storedClassId);
104996
106410
  for (const [schemaKey, child] of Object.entries(body)) {
@@ -105544,7 +106958,7 @@ function lowerListValue(context, member, expression, base, source, inheritedEnvi
105544
106958
  element,
105545
106959
  source,
105546
106960
  `${String(base.id)}[${index}]`,
105547
- member.listKind === "unordered" ? stringOrNull(base.id) : void 0,
106961
+ member.listKind === "unordered" ? stringOrNull2(base.id) : void 0,
105548
106962
  environment,
105549
106963
  entrySlices[index]
105550
106964
  )
@@ -105566,7 +106980,7 @@ function lowerListValue(context, member, expression, base, source, inheritedEnvi
105566
106980
  element,
105567
106981
  source,
105568
106982
  `${String(base.id)}[${index}]`,
105569
- member.listKind === "unordered" ? stringOrNull(base.id) : void 0,
106983
+ member.listKind === "unordered" ? stringOrNull2(base.id) : void 0,
105570
106984
  environment,
105571
106985
  entrySlices[index]
105572
106986
  )
@@ -105622,7 +107036,7 @@ function lowerPendingListItem(context, member, expression, source, path, contain
105622
107036
  }
105623
107037
  function existingListItemIds(context, member, base) {
105624
107038
  if (member.listKind === "unordered") {
105625
- const containerId = stringOrNull(base.id);
107039
+ const containerId = stringOrNull2(base.id);
105626
107040
  if (containerId === null) return /* @__PURE__ */ new Set();
105627
107041
  return context.valuePlacements.valueIdsByContainerId.get(containerId) ?? /* @__PURE__ */ new Set();
105628
107042
  }
@@ -106574,6 +107988,7 @@ function freshChildReplaysDeclaredDefault(args) {
106574
107988
  if (child.genericBindings !== void 0) return false;
106575
107989
  if (child.instanceVariantId != null) return false;
106576
107990
  if (child.instanceVariantRowValueId != null) return false;
107991
+ if (context.collectionBindingMemberIds.has(childMember.id)) return false;
106577
107992
  const defaultValue = childMember.defaultValue;
106578
107993
  if (defaultValue === null || defaultValue === void 0) return false;
106579
107994
  if (!("value" in defaultValue)) return false;
@@ -106592,7 +108007,12 @@ function freshChildReplaysDeclaredDefault(args) {
106592
108007
  defaultValue
106593
108008
  );
106594
108009
  }
106595
- if (resolved.kind === "list" || resolved.kind === "dictionary") return false;
108010
+ if (resolved.kind === "list") {
108011
+ return Array.isArray(child.value) && child.value.length === 0 && !context.pendingContainerChildCounts.has(childId) && Array.isArray(defaultValue.value) && defaultValue.value.length === 0 && child.classId == null && child.constructorArgs === void 0 && child.instanceConstructorId == null;
108012
+ }
108013
+ if (resolved.kind === "dictionary") {
108014
+ return isObjectRecord2(child.value) && Object.keys(child.value).length === 0 && isObjectRecord2(defaultValue.value) && Object.keys(defaultValue.value).length === 0 && child.classId == null && child.constructorArgs === void 0 && child.instanceConstructorId == null;
108015
+ }
106596
108016
  if (resolved.kind === "string" && resolved.localizable === true) return false;
106597
108017
  if (child.classId !== null && child.classId !== void 0) return false;
106598
108018
  if (isObjectRecord2(child.constructorArgs)) return false;
@@ -106987,7 +108407,7 @@ function emitValueBody(context, member, value, visited, targetTyped, environment
106987
108407
  function classValue(context, member, value, visited, targetTyped, outerEnvironment) {
106988
108408
  if (value.value === null) return "null";
106989
108409
  const partial = member.partial === true;
106990
- const classId = stringOrNull(value.classId) ?? stringField3(member, "classId");
108410
+ const classId = stringOrNull2(value.classId) ?? stringField3(member, "classId");
106991
108411
  const schemaClass2 = context.classes.get(classId);
106992
108412
  if (schemaClass2 === void 0)
106993
108413
  throw new Error(`Unknown value class ${classId}.`);
@@ -107100,11 +108520,12 @@ function classValue(context, member, value, visited, targetTyped, outerEnvironme
107100
108520
  const childMember = context.members.get(childMemberId);
107101
108521
  if (childMember === void 0)
107102
108522
  throw new Error(`Class ${name}.${key} has no member record.`);
107103
- if (emitsAsMemberDefaultDerivedAbsence(context, childMember, childId)) {
108523
+ const preservesExternalBinding = context.collectionBindingValueIds.has(childId);
108524
+ if (!preservesExternalBinding && emitsAsMemberDefaultDerivedAbsence(context, childMember, childId)) {
107104
108525
  continue;
107105
108526
  }
107106
108527
  const replayChildId = replayBody[key];
107107
- if (replayGraph !== null && typeof replayChildId === "string" && materializedValueSubgraphsEqual(
108528
+ if (!preservesExternalBinding && replayGraph !== null && typeof replayChildId === "string" && materializedValueSubgraphsEqual(
107108
108529
  context,
107109
108530
  context.readMaterializedGraph(),
107110
108531
  replayGraph,
@@ -107151,7 +108572,7 @@ function emitsAsMemberDefaultDerivedAbsence(context, member, valueId) {
107151
108572
  const body = value.value;
107152
108573
  if (!isObjectRecord2(body)) return false;
107153
108574
  if (Object.keys(body).length > 0) return false;
107154
- const effectiveClassId = stringOrNull(value.classId) ?? stringOrNull(member.classId);
108575
+ const effectiveClassId = stringOrNull2(value.classId) ?? stringOrNull2(member.classId);
107155
108576
  if (effectiveClassId === null) return false;
107156
108577
  return derivesContentFromMemberDefault({
107157
108578
  member,
@@ -107275,18 +108696,21 @@ function storedConstructorCallSource(context, schemaClass2, value, className, en
107275
108696
  }
107276
108697
  return targetTyped ? "new()" : `new ${className}()`;
107277
108698
  }
108699
+ const recordedConstructorId = recordedStoredConstructorId(
108700
+ value,
108701
+ manifestClass
108702
+ );
107278
108703
  const constructor2 = storedValueConstructor(
107279
108704
  context,
107280
108705
  manifestClass,
107281
- constructorArgs,
107282
- typeof value.instanceConstructorId === "string" ? value.instanceConstructorId : void 0
108706
+ recordedConstructorId
107283
108707
  );
107284
108708
  const argumentsValue = constructor2.arguments.flatMap((argument2, index) => {
107285
108709
  const key = `__arg_${index}__`;
107286
108710
  if (!(key in constructorArgs)) {
107287
108711
  if (argument2.default !== null || argument2.type.nullable) return [];
107288
108712
  throw new Error(
107289
- `Stored construction on value row "${stringOrNull(value.id) ?? "<unknown>"}" of class "${stringOrNull(schemaClass2.name) ?? "<unnamed>"}" (${stringOrNull(schemaClass2.id) ?? "<no id>"}) is missing evaluated argument ${key} for required parameter "${argument2.name}".`
108713
+ `Stored construction on value row "${stringOrNull2(value.id) ?? "<unknown>"}" of class "${stringOrNull2(schemaClass2.name) ?? "<unnamed>"}" (${stringOrNull2(schemaClass2.id) ?? "<no id>"}) is missing evaluated argument ${key} for required parameter "${argument2.name}".`
107290
108714
  );
107291
108715
  }
107292
108716
  const settledMember = settledMemberForConstructorArgument(
@@ -107373,47 +108797,27 @@ function constructorCallSource(callee, argumentsValue) {
107373
108797
  ${argumentsValue.map((argument2) => `${indentNeoSourceNonEmptyLines(argument2, 2)},`).join("\n")}
107374
108798
  )`;
107375
108799
  }
107376
- function storedValueConstructor(context, schemaClass2, constructorArgs, recordedConstructorId) {
107377
- if (recordedConstructorId !== void 0) {
107378
- const recorded = context.manifestConstructors.get(recordedConstructorId);
107379
- if (recorded === void 0) {
107380
- throw new Error(
107381
- `Stored construction for ${schemaClass2.name} names missing constructor ${recordedConstructorId}.`
107382
- );
107383
- }
107384
- if (schemaClass2.requiredConstructorId !== recordedConstructorId && !(schemaClass2.constructorIds ?? []).includes(recordedConstructorId)) {
107385
- throw new Error(
107386
- `Stored construction for ${schemaClass2.name} names constructor ${recordedConstructorId}, which the class does not declare.`
107387
- );
107388
- }
107389
- return recorded;
107390
- }
107391
- const requiredId = schemaClass2.requiredConstructorId;
107392
- if (requiredId !== void 0) {
107393
- const required2 = context.manifestConstructors.get(requiredId);
107394
- if (required2 === void 0) {
107395
- throw new Error(
107396
- `Stored construction for ${schemaClass2.name} names missing required constructor ${requiredId}.`
107397
- );
107398
- }
107399
- return required2;
108800
+ function storedValueConstructor(context, schemaClass2, recordedConstructorId) {
108801
+ const recorded = context.manifestConstructors.get(recordedConstructorId);
108802
+ if (recorded === void 0) {
108803
+ throw new Error(
108804
+ `Stored construction for ${schemaClass2.name} names missing constructor ${recordedConstructorId}.`
108805
+ );
107400
108806
  }
107401
- const count = Object.keys(constructorArgs).length;
107402
- const candidates = (schemaClass2.constructorIds ?? []).map((id2) => context.manifestConstructors.get(id2)).filter(
107403
- (candidate) => candidate !== void 0 && candidate.arguments.length === count
107404
- );
107405
- if (candidates.length !== 1) {
108807
+ if (schemaClass2.requiredConstructorId !== recordedConstructorId && !(schemaClass2.constructorIds ?? []).includes(recordedConstructorId)) {
107406
108808
  throw new Error(
107407
- `Stored construction for ${schemaClass2.name} cannot select one constructor from ${candidates.length} ${count}-argument candidates.`
108809
+ `Stored construction for ${schemaClass2.name} names constructor ${recordedConstructorId}, which the class does not declare.`
107408
108810
  );
107409
108811
  }
107410
- const selected = candidates[0];
107411
- if (selected === void 0) {
108812
+ return recorded;
108813
+ }
108814
+ function recordedStoredConstructorId(value, schemaClass2) {
108815
+ if (typeof value.instanceConstructorId !== "string") {
107412
108816
  throw new Error(
107413
- `Stored construction for ${schemaClass2.name} resolved no constructor.`
108817
+ `Stored construction on value row "${stringOrNull2(value.id) ?? "<unknown>"}" of class "${schemaClass2.name}" (${schemaClass2.id}) is not canonical: constructorArgs requires a recorded instanceConstructorId.`
107414
108818
  );
107415
108819
  }
107416
- return selected;
108820
+ return value.instanceConstructorId;
107417
108821
  }
107418
108822
  function storedConstructorArgumentSource(context, type, value, environment, visited, cloneAggregateArguments = false, partial = false, constructorOwnsGraph = false) {
107419
108823
  if (value === null) {
@@ -108656,7 +110060,7 @@ function stringField3(value, key) {
108656
110060
  if (typeof result !== "string") throw new Error(`Expected string ${key}.`);
108657
110061
  return result;
108658
110062
  }
108659
- function stringOrNull(value) {
110063
+ function stringOrNull2(value) {
108660
110064
  return typeof value === "string" ? value : null;
108661
110065
  }
108662
110066
  function numberOr2(value, fallback) {
@@ -108688,6 +110092,7 @@ var init_value_sources = __esm({
108688
110092
  init_init_source();
108689
110093
  init_source_format();
108690
110094
  init_root_value_paths();
110095
+ init_stored_value_placements();
108691
110096
  init_world_system_classes();
108692
110097
  init_member_value_id();
108693
110098
  init_instance_provenance();
@@ -112647,7 +114052,10 @@ var init_history = __esm({
112647
114052
  function auditProjectIntegrity(workspace) {
112648
114053
  const records2 = workspace.state.records;
112649
114054
  const values = collectValueRows(records2);
112650
- const placements = collectPlacements(values);
114055
+ const storedPlacements = buildStoredValuePlacementIndexV4(
114056
+ Object.values(records2)
114057
+ );
114058
+ const placements = collectPlacements(values, storedPlacements);
112651
114059
  const memberIdBySchemaKey = collectClassSchemas(records2);
112652
114060
  const storageKeyByMemberId = collectMemberStorageKeys(records2);
112653
114061
  const findings = [];
@@ -112871,7 +114279,7 @@ function collectValueRows(records2) {
112871
114279
  }
112872
114280
  return values;
112873
114281
  }
112874
- function collectPlacements(values) {
114282
+ function collectPlacements(values, storedPlacements) {
112875
114283
  const placements = /* @__PURE__ */ new Map();
112876
114284
  const claim = (childId, placement) => {
112877
114285
  if (values.has(childId) && !placements.has(childId)) {
@@ -112899,6 +114307,12 @@ function collectPlacements(values) {
112899
114307
  if (container === void 0) continue;
112900
114308
  claim(value.id, { parent: container, schemaKey: UNORDERED_MEMBERSHIP_KEY });
112901
114309
  }
114310
+ for (const edge of storedPlacements.placementByChildValueId.values()) {
114311
+ if (edge.source !== "constructor") continue;
114312
+ const parent = values.get(edge.parentValueId);
114313
+ if (parent === void 0) continue;
114314
+ claim(edge.childValueId, { parent, schemaKey: edge.schemaKey });
114315
+ }
112902
114316
  return placements;
112903
114317
  }
112904
114318
  function collectClassSchemas(records2) {
@@ -112971,6 +114385,7 @@ var init_project_integrity = __esm({
112971
114385
  init_member_storage_key();
112972
114386
  init_system_record_id();
112973
114387
  init_projection();
114388
+ init_stored_value_placements();
112974
114389
  UNORDERED_MEMBERSHIP_KEY = "(container)";
112975
114390
  MEMBER_KIND_STRING = 3;
112976
114391
  RECORD_ID_PATTERN2 = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
@@ -118971,7 +120386,7 @@ var init_registry2 = __esm({
118971
120386
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
118972
120387
  formatVersion: 3,
118973
120388
  contractVersion: "3.14",
118974
- cliVersion: "0.38.1",
120389
+ cliVersion: "0.38.2",
118975
120390
  projectFileUploadBatchSize: 32,
118976
120391
  documentRecords: {
118977
120392
  member: {
@@ -120316,7 +121731,7 @@ import {
120316
121731
  sep as sep5
120317
121732
  } from "node:path";
120318
121733
  import { isDeepStrictEqual } from "node:util";
120319
- function isRecord9(value) {
121734
+ function isRecord10(value) {
120320
121735
  return typeof value === "object" && value !== null && !Array.isArray(value);
120321
121736
  }
120322
121737
  function expectation(actual, negated = false) {
@@ -120327,13 +121742,13 @@ function expectation(actual, negated = false) {
120327
121742
  return value;
120328
121743
  }
120329
121744
  function readExpectation(value) {
120330
- if (!isRecord9(value) || value.__neoExpectation !== true) {
121745
+ if (!isRecord10(value) || value.__neoExpectation !== true) {
120331
121746
  throw new NeoTestAssertionError("Matcher receiver is not an expectation.");
120332
121747
  }
120333
121748
  return value;
120334
121749
  }
120335
121750
  function readMockHandle(value) {
120336
- if (!isRecord9(value) || value.__neoMockHandle !== true || typeof value.mockId !== "number") {
121751
+ if (!isRecord10(value) || value.__neoMockHandle !== true || typeof value.mockId !== "number") {
120337
121752
  throw new NeoTestAssertionError(
120338
121753
  "Mock configuration receiver is not a mock handle."
120339
121754
  );
@@ -120444,13 +121859,13 @@ function errorMessage2(error) {
120444
121859
  return error instanceof Error ? error.message : String(error);
120445
121860
  }
120446
121861
  function findDelegateTargetMemberId(value) {
120447
- return isRecord9(value) && typeof value.memberId === "string" ? value.memberId : null;
121862
+ return isRecord10(value) && typeof value.memberId === "string" ? value.memberId : null;
120448
121863
  }
120449
121864
  function sharedEvaluatorBase(rawDocument) {
120450
121865
  const cached = SHARED_EVALUATOR_BASES.get(rawDocument);
120451
121866
  if (cached !== void 0) return cached;
120452
121867
  const document = readDocumentArrays(rawDocument);
120453
- const constructors = Array.isArray(rawDocument.constructors) ? rawDocument.constructors.filter(isRecord9) : [];
121868
+ const constructors = Array.isArray(rawDocument.constructors) ? rawDocument.constructors.filter(isRecord10) : [];
120454
121869
  const lookups = cliEvaluatorLookups(
120455
121870
  { ...document, constructors },
120456
121871
  { includeValueGraphIndexes: true }
@@ -120518,7 +121933,7 @@ function preparedHookCandidate(workspace) {
120518
121933
  const parsed = JSON.parse(
120519
121934
  readFileSync16(join16(directory, "candidate.json"), "utf8")
120520
121935
  );
120521
- if (!isRecord9(parsed)) {
121936
+ if (!isRecord10(parsed)) {
120522
121937
  throw new NeoTestPreparedCandidateError(
120523
121938
  "Configured push hook candidate manifest must be a JSON object."
120524
121939
  );
@@ -120538,7 +121953,7 @@ function preparedHookCandidate(workspace) {
120538
121953
  "Configured push hook candidate inputs no longer match the workspace."
120539
121954
  );
120540
121955
  }
120541
- if (!isRecord9(parsed.document)) {
121956
+ if (!isRecord10(parsed.document)) {
120542
121957
  throw new NeoTestPreparedCandidateError(
120543
121958
  "Configured push hook candidate is missing its project document."
120544
121959
  );
@@ -120587,7 +122002,7 @@ function cachedTestCandidate(workspace, inputFingerprint) {
120587
122002
  try {
120588
122003
  const candidatePath = testCandidateCachePath(workspace, inputFingerprint);
120589
122004
  const parsed = JSON.parse(readFileSync16(candidatePath, "utf8"));
120590
- if (!isRecord9(parsed)) return null;
122005
+ if (!isRecord10(parsed)) return null;
120591
122006
  if (parsed.version !== 1) return null;
120592
122007
  if (parsed.candidateRevision !== TEST_CANDIDATE_CACHE_REVISION) return null;
120593
122008
  if (parsed.cliVersion !== PROJECT_SCHEMA_CONTRACT.cliVersion) return null;
@@ -120605,7 +122020,7 @@ function cachedTestCandidate(workspace, inputFingerprint) {
120605
122020
  return null;
120606
122021
  }
120607
122022
  const document = JSON.parse(documentJson);
120608
- if (!isRecord9(document)) return null;
122023
+ if (!isRecord10(document)) return null;
120609
122024
  return {
120610
122025
  document,
120611
122026
  sourceHash: parsed.sourceHash,
@@ -120649,7 +122064,7 @@ function compileSpec(workspace, document, absolutePath, projectCompilationHash2)
120649
122064
  );
120650
122065
  try {
120651
122066
  const cached = JSON.parse(readFileSync16(artifactPath, "utf8"));
120652
- if (isRecord9(cached) && cached.version === 1 && cached.compilerRevision === NEOSCRIPT_COMPILER_REVISION && cached.projectCompilationHash === projectCompilationHash2 && cached.sourceHash === sourceHash && isRecord9(cached.action) && typeof cached.artifactSha256 === "string" && createHash11("sha256").update(JSON.stringify(cached.action)).digest("hex") === cached.artifactSha256 && cached.action.compilerRevision === NEOSCRIPT_COMPILER_REVISION && Array.isArray(cached.action.parameters) && Array.isArray(cached.action.instructions) && isRecord9(cached.action.typeInfo)) {
122067
+ if (isRecord10(cached) && cached.version === 1 && cached.compilerRevision === NEOSCRIPT_COMPILER_REVISION && cached.projectCompilationHash === projectCompilationHash2 && cached.sourceHash === sourceHash && isRecord10(cached.action) && typeof cached.artifactSha256 === "string" && createHash11("sha256").update(JSON.stringify(cached.action)).digest("hex") === cached.artifactSha256 && cached.action.compilerRevision === NEOSCRIPT_COMPILER_REVISION && Array.isArray(cached.action.parameters) && Array.isArray(cached.action.instructions) && isRecord10(cached.action.typeInfo)) {
120653
122068
  return {
120654
122069
  path,
120655
122070
  source,
@@ -120813,7 +122228,7 @@ function portableDelegate(value) {
120813
122228
  }
120814
122229
  }
120815
122230
  function callMemberId(value) {
120816
- if (!isRecord9(value) || value.type !== "callFunction") return null;
122231
+ if (!isRecord10(value) || value.type !== "callFunction") return null;
120817
122232
  return typeof value.memberId === "string" ? value.memberId : null;
120818
122233
  }
120819
122234
  function assertNoNestedRegistration(value) {
@@ -120821,7 +122236,7 @@ function assertNoNestedRegistration(value) {
120821
122236
  for (const entry of value) assertNoNestedRegistration(entry);
120822
122237
  return;
120823
122238
  }
120824
- if (!isRecord9(value)) return;
122239
+ if (!isRecord10(value)) return;
120825
122240
  const memberId = callMemberId(value);
120826
122241
  if (memberId !== null && REGISTRATION_IDS.has(memberId)) {
120827
122242
  throw new NeoTestRegistrationError(
@@ -120837,8 +122252,8 @@ function compiledDelegateActions(value) {
120837
122252
  for (const child of entry) visit(child);
120838
122253
  return;
120839
122254
  }
120840
- if (!isRecord9(entry)) return;
120841
- if (isRecord9(entry.action) && Array.isArray(entry.action.instructions) && Array.isArray(entry.action.parameters) && isRecord9(entry.action.typeInfo)) {
122255
+ if (!isRecord10(entry)) return;
122256
+ if (isRecord10(entry.action) && Array.isArray(entry.action.instructions) && Array.isArray(entry.action.parameters) && isRecord10(entry.action.typeInfo)) {
120842
122257
  actions.push(entry.action);
120843
122258
  return;
120844
122259
  }
@@ -120849,7 +122264,7 @@ function compiledDelegateActions(value) {
120849
122264
  }
120850
122265
  function validateRegistrationAction(action, allowRegistration) {
120851
122266
  for (const instruction of action.instructions) {
120852
- const record3 = isRecord9(instruction) ? instruction : null;
122267
+ const record3 = isRecord10(instruction) ? instruction : null;
120853
122268
  const call = record3?.type === "functionCall" ? record3.call : null;
120854
122269
  const memberId = callMemberId(call);
120855
122270
  if (memberId !== null && REGISTRATION_IDS.has(memberId)) {
@@ -120982,8 +122397,8 @@ function mockResponse(environment, mock, selected, call) {
120982
122397
  };
120983
122398
  }
120984
122399
  function partialObjectMatch(actual, expected) {
120985
- if (!isRecord9(expected)) return isDeepStrictEqual(actual, expected);
120986
- if (!isRecord9(actual)) return false;
122400
+ if (!isRecord10(expected)) return isDeepStrictEqual(actual, expected);
122401
+ if (!isRecord10(actual)) return false;
120987
122402
  return Object.entries(expected).every(
120988
122403
  ([key, value]) => partialObjectMatch(actual[key], value)
120989
122404
  );
@@ -121175,7 +122590,7 @@ function interceptTestCallCore(environment, call) {
121175
122590
  const contains2 = typeof actual === "string" ? actual.includes(String(call.args[0])) : Array.isArray(actual) && actual.some((entry) => isDeepStrictEqual(entry, call.args[0]));
121176
122591
  assertMatcher(contains2, expectationValue, "toContain", call.args[0]);
121177
122592
  } else if (call.memberId === NEO_TEST_IDS.toHaveLength) {
121178
- const length = typeof actual === "string" || Array.isArray(actual) ? actual.length : isRecord9(actual) ? Object.keys(actual).length : -1;
122593
+ const length = typeof actual === "string" || Array.isArray(actual) ? actual.length : isRecord10(actual) ? Object.keys(actual).length : -1;
121179
122594
  assertMatcher(
121180
122595
  length === call.args[0],
121181
122596
  expectationValue,
@@ -121266,11 +122681,11 @@ function snapshotEnvironmentDocument(environment) {
121266
122681
  const values = [...baseValues];
121267
122682
  const byId = /* @__PURE__ */ new Map();
121268
122683
  values.forEach((value, index) => {
121269
- if (isRecord9(value) && typeof value.id === "string")
122684
+ if (isRecord10(value) && typeof value.id === "string")
121270
122685
  byId.set(value.id, index);
121271
122686
  });
121272
122687
  const mergeRow = (row) => {
121273
- if (!isRecord9(row) || typeof row.id !== "string") return;
122688
+ if (!isRecord10(row) || typeof row.id !== "string") return;
121274
122689
  const cloned = structuredClone(row);
121275
122690
  const index = byId.get(row.id);
121276
122691
  if (index === void 0) {
@@ -121286,7 +122701,7 @@ function snapshotEnvironmentDocument(environment) {
121286
122701
  if (bindings.size > 0) {
121287
122702
  const baseMembers = Array.isArray(snapshot.members) ? snapshot.members : [];
121288
122703
  snapshot.members = baseMembers.map((member) => {
121289
- if (!isRecord9(member) || typeof member.id !== "string" || !bindings.has(member.id)) {
122704
+ if (!isRecord10(member) || typeof member.id !== "string" || !bindings.has(member.id)) {
121290
122705
  return member;
121291
122706
  }
121292
122707
  return { ...member, valueId: bindings.get(member.id) ?? null };
@@ -125694,7 +127109,7 @@ There is no --keep-current: preserving current semantic state defines flatten.
125694
127109
  async function main() {
125695
127110
  const args = parseArgs(process.argv.slice(2));
125696
127111
  if (args.command === "--version") {
125697
- console.log("0.38.1");
127112
+ console.log("0.38.2");
125698
127113
  return;
125699
127114
  }
125700
127115
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {