@neocompose/cli 0.53.1 → 0.53.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
@@ -31783,9 +31783,9 @@ function assertDialogue(value, path) {
31783
31783
  (entry, index) => assertMember(entry, `${path}.functions[${index}]`)
31784
31784
  );
31785
31785
  array(dialogue.members, `${path}.members`).forEach((entry, index) => {
31786
- const memberPath2 = `${path}.members[${index}]`;
31787
- const member = record(entry, memberPath2);
31788
- exactKeys(member, memberPath2, [
31786
+ const memberPath3 = `${path}.members[${index}]`;
31787
+ const member = record(entry, memberPath3);
31788
+ exactKeys(member, memberPath3, [
31789
31789
  "id",
31790
31790
  "state",
31791
31791
  "source",
@@ -31796,16 +31796,16 @@ function assertDialogue(value, path) {
31796
31796
  "arguments",
31797
31797
  "content"
31798
31798
  ]);
31799
- assertIdentity(member, memberPath2);
31800
- string(member.name, `${memberPath2}.name`);
31801
- string(member.graphType, `${memberPath2}.graphType`);
31799
+ assertIdentity(member, memberPath3);
31800
+ string(member.name, `${memberPath3}.name`);
31801
+ string(member.graphType, `${memberPath3}.graphType`);
31802
31802
  if (member.destination !== null) {
31803
- string(member.destination, `${memberPath2}.destination`);
31803
+ string(member.destination, `${memberPath3}.destination`);
31804
31804
  }
31805
- string(member.initializer, `${memberPath2}.initializer`);
31806
- assertFlowArguments(member.arguments, `${memberPath2}.arguments`);
31805
+ string(member.initializer, `${memberPath3}.initializer`);
31806
+ assertFlowArguments(member.arguments, `${memberPath3}.arguments`);
31807
31807
  if (member.content !== null) {
31808
- assertDialogueContent(member.content, `${memberPath2}.content`);
31808
+ assertDialogueContent(member.content, `${memberPath3}.content`);
31809
31809
  }
31810
31810
  });
31811
31811
  }
@@ -34796,6 +34796,111 @@ var init_src = __esm({
34796
34796
  }
34797
34797
  });
34798
34798
 
34799
+ // src/project-source/lower-support.ts
34800
+ function identityMap(declarations, kind) {
34801
+ return new Map(
34802
+ declarations.map((declaration) => [
34803
+ declaration.name,
34804
+ materializedId(declaration, kind, declaration.name)
34805
+ ])
34806
+ );
34807
+ }
34808
+ function sourceIdentity2(identity2, kind, name) {
34809
+ const sourceSpan = span(identity2);
34810
+ return {
34811
+ symbolId: `${kind}:${materializedIdentityId(identity2, kind, name)}`,
34812
+ kind,
34813
+ span: sourceSpan,
34814
+ selectionSpan: sourceSpan
34815
+ };
34816
+ }
34817
+ function span(identity2) {
34818
+ return {
34819
+ path: identity2.source.uri,
34820
+ start: { ...identity2.source.range.start },
34821
+ end: { ...identity2.source.range.end }
34822
+ };
34823
+ }
34824
+ function materializedId(identity2, kind, name) {
34825
+ return materializedIdentityId(identity2, kind, name);
34826
+ }
34827
+ function materializedIdentityId(identity2, kind, name) {
34828
+ return identity2.id ?? `__pending__:${kind}:${encodeURIComponent(identity2.source.uri)}:${identity2.source.range.start.line}:${identity2.source.range.start.character}:${encodeURIComponent(name)}`;
34829
+ }
34830
+ function expressionArguments(expression) {
34831
+ const result = /* @__PURE__ */ new Map();
34832
+ expression.args.forEach((entry, index) => {
34833
+ const name = expression.argumentNames?.[index] ?? null;
34834
+ if (name === null) {
34835
+ throw new Error(
34836
+ "Project configuration constructors require named arguments."
34837
+ );
34838
+ }
34839
+ if (result.has(name)) {
34840
+ throw new Error(
34841
+ `Constructor argument ${JSON.stringify(name)} is duplicated.`
34842
+ );
34843
+ }
34844
+ result.set(name, entry);
34845
+ });
34846
+ return result;
34847
+ }
34848
+ function annotation(annotations, name) {
34849
+ return annotations.find((entry) => entry.name === name);
34850
+ }
34851
+ function argument(value, name) {
34852
+ return value?.arguments.find((entry) => entry.name === name)?.expression ?? null;
34853
+ }
34854
+ function parseAnnotationExpression(value) {
34855
+ return parseExpression(value);
34856
+ }
34857
+ function stringArgument(value, name) {
34858
+ const raw = argument(value, name);
34859
+ if (raw === null) return null;
34860
+ const expression = parseAnnotationExpression(raw);
34861
+ return expression.kind === "litString" ? expression.value : null;
34862
+ }
34863
+ function contextualEnumArgument(value, name) {
34864
+ const raw = argument(value, name);
34865
+ if (raw === null) return null;
34866
+ const expression = parseAnnotationExpression(raw);
34867
+ return expression.kind === "contextualEnum" ? expression.name : null;
34868
+ }
34869
+ function systemMetadata(annotations) {
34870
+ const system = annotation(annotations, "system");
34871
+ if (!system) return null;
34872
+ const kind = contextualEnumArgument(system, "kind");
34873
+ if (kind === null) {
34874
+ throw new Error("@system requires a kind inferred enum argument.");
34875
+ }
34876
+ const worldKind = contextualEnumArgument(system, "worldKind");
34877
+ return {
34878
+ kind: lowerFirst2(kind),
34879
+ worldKind: worldKind ? lowerFirst2(worldKind) : null
34880
+ };
34881
+ }
34882
+ function requiredName(values, name, kind) {
34883
+ const value = values.get(name);
34884
+ if (!value) throw new Error(`Unknown ${kind} ${JSON.stringify(name)}.`);
34885
+ return value;
34886
+ }
34887
+ function lowerFirst2(value) {
34888
+ return value.length ? `${value[0].toLowerCase()}${value.slice(1)}` : value;
34889
+ }
34890
+ function indexFirstById(values) {
34891
+ const result = /* @__PURE__ */ new Map();
34892
+ for (const value of values) {
34893
+ if (!result.has(value.id)) result.set(value.id, value);
34894
+ }
34895
+ return result;
34896
+ }
34897
+ var init_lower_support = __esm({
34898
+ "src/project-source/lower-support.ts"() {
34899
+ "use strict";
34900
+ init_src();
34901
+ }
34902
+ });
34903
+
34799
34904
  // src/project-source/local-values.ts
34800
34905
  function validateLocalValuePlacementsV4(value) {
34801
34906
  if (!Array.isArray(value))
@@ -34870,6 +34975,23 @@ function validateLocalValuePlacementsV4(value) {
34870
34975
  for (const entry of active) visited.add(entry);
34871
34976
  }
34872
34977
  }
34978
+ function* staticMembersInitializedByName(analysis) {
34979
+ for (const sourceClass of analysis.schema.classes) {
34980
+ for (const declaration of sourceClass.members) {
34981
+ if (!declaration.modifiers.includes("static")) continue;
34982
+ if (declaration.kind !== "field" || declaration.initializer === null)
34983
+ continue;
34984
+ const name = declaration.initializer.trim();
34985
+ if (!/^[A-Za-z_]\w*$/u.test(name)) continue;
34986
+ const path = `${sourceClass.name}.${declaration.name}`;
34987
+ yield {
34988
+ name,
34989
+ memberId: materializedId(declaration, "member", path),
34990
+ path
34991
+ };
34992
+ }
34993
+ }
34994
+ }
34873
34995
  function typeText2(type) {
34874
34996
  return type.name + (type.arguments.length === 0 ? "" : `<${type.arguments.map(typeText2).join(", ")}>`) + (type.nullable ? "?" : "");
34875
34997
  }
@@ -34879,12 +35001,15 @@ var init_local_values = __esm({
34879
35001
  "use strict";
34880
35002
  init_workspace_source_path();
34881
35003
  init_src();
35004
+ init_lower_support();
34882
35005
  LocalValueBindingsV4 = class {
34883
35006
  definitions = /* @__PURE__ */ new Map();
34884
35007
  expressions = /* @__PURE__ */ new Map();
34885
35008
  owners = /* @__PURE__ */ new Map();
35009
+ /** Static members whose initializer is a bare local name, by that name. */
35010
+ ownerMembers = /* @__PURE__ */ new Map();
34886
35011
  scalarTypes;
34887
- constructor(globals, enumNames = []) {
35012
+ constructor(globals, enumNames = [], ownerMembers = []) {
34888
35013
  const scalarTypes = /* @__PURE__ */ new Set(["string", "int", "float", "decimal", "bool"]);
34889
35014
  for (const name of enumNames) scalarTypes.add(name);
34890
35015
  this.scalarTypes = scalarTypes;
@@ -34893,6 +35018,12 @@ var init_local_values = __esm({
34893
35018
  throw new Error(`Duplicate local value ${global.name}.`);
34894
35019
  this.definitions.set(global.name, global);
34895
35020
  }
35021
+ for (const owner of ownerMembers) {
35022
+ if (!this.definitions.has(owner.name)) continue;
35023
+ const members = this.ownerMembers.get(owner.name) ?? [];
35024
+ members.push({ memberId: owner.memberId, path: owner.path });
35025
+ this.ownerMembers.set(owner.name, members);
35026
+ }
34896
35027
  }
34897
35028
  resolve(expression, source, valueId) {
34898
35029
  if (expression.kind !== "ident") return { expression, source };
@@ -34931,6 +35062,44 @@ var init_local_values = __esm({
34931
35062
  has(name) {
34932
35063
  return this.definitions.has(name);
34933
35064
  }
35065
+ /**
35066
+ * The row a local names, answered without its owning assignment having
35067
+ * lowered, so the answer does not depend on which file lowered first: the
35068
+ * `@id` its declaration carries (through any alias chain), else the static
35069
+ * member whose initializer is the local, whose row derives from the member.
35070
+ * `null` for a local no push has identified yet.
35071
+ */
35072
+ declaredTarget(name) {
35073
+ const definition2 = this.definitions.get(name);
35074
+ if (definition2 === void 0) return null;
35075
+ const chain = /* @__PURE__ */ new Set();
35076
+ let global = definition2;
35077
+ let expression;
35078
+ for (; ; ) {
35079
+ if (chain.has(global.name))
35080
+ throw new Error(`Local initializer cycle reaches ${global.name}.`);
35081
+ chain.add(global.name);
35082
+ expression = this.expressions.get(global.name) ?? parseExpression(global.initializer);
35083
+ this.expressions.set(global.name, expression);
35084
+ const alias = expression.kind === "ident" ? this.definitions.get(expression.name) : void 0;
35085
+ if (alias === void 0) break;
35086
+ global = alias;
35087
+ }
35088
+ const typeName = definition2.type.name;
35089
+ const id2 = expression.kind === "annotated" ? expression.annotations.find((entry) => entry.name === "id")?.args[0] : void 0;
35090
+ if (id2 !== void 0 && id2.kind === "litString" && id2.value.length > 0) {
35091
+ return { id: id2.value, typeName };
35092
+ }
35093
+ const owners = this.ownerMembers.get(name);
35094
+ if (owners === void 0) return null;
35095
+ if (owners.length !== 1) {
35096
+ throw new Error(
35097
+ `Reference(${name}) requires exactly one owning assignment.`
35098
+ );
35099
+ }
35100
+ const owner = owners[0];
35101
+ return { ownerMemberId: owner.memberId, ownerPath: owner.path, typeName };
35102
+ }
34934
35103
  target(name) {
34935
35104
  const owners = this.owners.get(name);
34936
35105
  if (owners?.size !== 1)
@@ -59609,7 +59778,7 @@ function emitSupplementalProjectSourcesV4(records2, binaryPaths) {
59609
59778
  (candidate) => candidate.recordKind === "priority-group"
59610
59779
  )) {
59611
59780
  const data = recordData(record6);
59612
- const name = requiredName(data, record6);
59781
+ const name = requiredName2(data, record6);
59613
59782
  files.push({
59614
59783
  path: defaultDeclarationPathV4("PriorityGroups", name, record6.recordId),
59615
59784
  content: emitPriorityGroup(data, record6.recordId, name),
@@ -59620,7 +59789,7 @@ function emitSupplementalProjectSourcesV4(records2, binaryPaths) {
59620
59789
  (candidate) => candidate.recordKind === "dialogue-group"
59621
59790
  )) {
59622
59791
  const data = recordData(record6);
59623
- const name = requiredName(data, record6);
59792
+ const name = requiredName2(data, record6);
59624
59793
  files.push({
59625
59794
  path: defaultDeclarationPathV4("DialogueGroups", name, record6.recordId),
59626
59795
  content: emitDialogueGroup(
@@ -60380,7 +60549,7 @@ function recordData(record6) {
60380
60549
  }
60381
60550
  return record6.data;
60382
60551
  }
60383
- function requiredName(data, record6) {
60552
+ function requiredName2(data, record6) {
60384
60553
  if (typeof data.name !== "string") {
60385
60554
  throw new Error(`${record6.recordKind}:${record6.recordId} has no name.`);
60386
60555
  }
@@ -60391,7 +60560,7 @@ function namesById(records2, kind) {
60391
60560
  return new Map(
60392
60561
  records2.filter((record6) => record6.recordKind === kind).map((record6) => [
60393
60562
  record6.recordId,
60394
- requiredName(recordData(record6), record6)
60563
+ requiredName2(recordData(record6), record6)
60395
60564
  ])
60396
60565
  );
60397
60566
  }
@@ -60512,9 +60681,9 @@ function lowerSystemMetadata(annotations) {
60512
60681
  throw new Error("@system worldKind must be an inferred enum or null.");
60513
60682
  }
60514
60683
  return {
60515
- kind: lowerFirst2(kindExpression.name),
60684
+ kind: lowerFirst3(kindExpression.name),
60516
60685
  ...worldKindExpression === void 0 ? {} : {
60517
- worldKind: worldKindExpression.kind === "contextualEnum" ? lowerFirst2(worldKindExpression.name) : null
60686
+ worldKind: worldKindExpression.kind === "contextualEnum" ? lowerFirst3(worldKindExpression.name) : null
60518
60687
  }
60519
60688
  };
60520
60689
  }
@@ -60524,7 +60693,7 @@ function hasAnnotation(annotations, name) {
60524
60693
  function enumCase2(value) {
60525
60694
  return value.split(/[-_\s]+/).filter(Boolean).map((part) => `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join("");
60526
60695
  }
60527
- function lowerFirst2(value) {
60696
+ function lowerFirst3(value) {
60528
60697
  return `${value[0]?.toLowerCase() ?? ""}${value.slice(1)}`;
60529
60698
  }
60530
60699
  function assertProjectIdentifier2(value, kind) {
@@ -96056,176 +96225,6 @@ function orderLocalizedTextWritesBesideLinks(prepared) {
96056
96225
  });
96057
96226
  return ordered;
96058
96227
  }
96059
- function planProjectVersionTransaction(changes, atomicGroups, options = {}) {
96060
- if (changes.length === 0) {
96061
- throw new Error("A project-version transaction plan requires changes.");
96062
- }
96063
- if (options.basePayloadBytes !== void 0 && options.basePayloadBytes.length !== changes.length)
96064
- throw new Error("Transaction base payload sizes must cover every change.");
96065
- const changeCosts = changes.map(
96066
- (change, index) => estimateProjectVersionChangeCost(change, options.basePayloadBytes?.[index])
96067
- );
96068
- const groups = normalizeAtomicGroups(changes.length, atomicGroups);
96069
- let totalEstimatedCost = changeCosts.reduce(
96070
- addProjectVersionTransactionBudgets,
96071
- IMMEDIATE_FIXED_COST
96072
- );
96073
- if (changes.some(projectVersionChangeCanTriggerWholeGraphValidation)) {
96074
- totalEstimatedCost = addProjectVersionTransactionBudgets(
96075
- totalEstimatedCost,
96076
- WHOLE_GRAPH_VALIDATION_SURCHARGE
96077
- );
96078
- }
96079
- const limitingResource = firstExceededResource(
96080
- totalEstimatedCost,
96081
- PROJECT_TRANSACTION_IMMEDIATE_BUDGET
96082
- );
96083
- if (limitingResource === null && options.forceAsync !== true) {
96084
- return {
96085
- path: "immediate",
96086
- limitingResource: null,
96087
- totalEstimatedCost,
96088
- chunks: [
96089
- {
96090
- firstChangeIndex: 0,
96091
- changeCount: changes.length,
96092
- estimatedCost: totalEstimatedCost
96093
- }
96094
- ]
96095
- };
96096
- }
96097
- const stagedChangeCosts = changes.map((change, index) => {
96098
- const cost = changeCosts[index];
96099
- const receiptBytes = 2 * KIB + new TextEncoder().encode(change.recordId).byteLength;
96100
- return addProjectVersionTransactionBudgets(cost, {
96101
- ...EMPTY_BUDGET,
96102
- bytesRead: receiptBytes,
96103
- bytesWritten: receiptBytes,
96104
- documentsRead: 1,
96105
- documentsWritten: 1,
96106
- databaseQueries: 1,
96107
- indexRanges: 1
96108
- });
96109
- });
96110
- const chunks = [];
96111
- let firstChangeIndex = 0;
96112
- let chunkCost = CHUNK_FIXED_COST;
96113
- let changeCount = 0;
96114
- for (const group of groups) {
96115
- const groupCost = stagedChangeCosts.slice(group.firstChangeIndex, group.firstChangeIndex + group.changeCount).reduce(addProjectVersionTransactionBudgets, EMPTY_BUDGET);
96116
- const nativeExceeded = firstExceededResource(
96117
- addProjectVersionTransactionBudgets(CHUNK_FIXED_COST, groupCost),
96118
- PROJECT_TRANSACTION_SINGLE_CHANGE_NATIVE_BUDGET
96119
- );
96120
- if (nativeExceeded !== null) {
96121
- throw new Error(
96122
- `Project-version atomic group starting at change ${group.firstChangeIndex} (${group.changeCount} changes) exceeds the native worker budget for ${nativeExceeded}.`
96123
- );
96124
- }
96125
- const nextCost = addProjectVersionTransactionBudgets(chunkCost, groupCost);
96126
- const exceeded = firstExceededResource(
96127
- nextCost,
96128
- PROJECT_TRANSACTION_WORKER_BUDGET
96129
- );
96130
- if (exceeded !== null && changeCount > 0) {
96131
- chunks.push({ firstChangeIndex, changeCount, estimatedCost: chunkCost });
96132
- firstChangeIndex = group.firstChangeIndex;
96133
- changeCount = 0;
96134
- chunkCost = CHUNK_FIXED_COST;
96135
- }
96136
- chunkCost = addProjectVersionTransactionBudgets(chunkCost, groupCost);
96137
- changeCount += group.changeCount;
96138
- }
96139
- if (changeCount > 0) {
96140
- chunks.push({ firstChangeIndex, changeCount, estimatedCost: chunkCost });
96141
- }
96142
- return {
96143
- path: "asynchronous",
96144
- limitingResource,
96145
- totalEstimatedCost,
96146
- chunks
96147
- };
96148
- }
96149
- function projectVersionChangeCanTriggerWholeGraphValidation(change) {
96150
- if (change.recordKind === "enum" || change.recordKind === "member" || change.recordKind === "project" || change.recordKind === "internal-record-relation") {
96151
- return true;
96152
- }
96153
- if (change.recordKind === "class") return change.operation !== "create";
96154
- if (change.recordKind !== "value") return false;
96155
- if (change.operation === "delete") return true;
96156
- return valueChangeCarriesWorldLayerOverride(change);
96157
- }
96158
- function valueChangeCarriesWorldLayerOverride(change) {
96159
- const nextData = change.nextData;
96160
- if (nextData === null || typeof nextData !== "object") return false;
96161
- if (Array.isArray(nextData)) return false;
96162
- const value = nextData.value;
96163
- if (value === null || typeof value !== "object") return false;
96164
- if (Array.isArray(value)) return false;
96165
- return typeof value.layerOverrideValueId === "string";
96166
- }
96167
- function normalizeAtomicGroups(changeCount, groups) {
96168
- if (groups === void 0) {
96169
- return Array.from({ length: changeCount }, (_, firstChangeIndex) => ({
96170
- firstChangeIndex,
96171
- changeCount: 1
96172
- }));
96173
- }
96174
- let nextChangeIndex = 0;
96175
- for (const group of groups) {
96176
- if (!Number.isSafeInteger(group.firstChangeIndex) || !Number.isSafeInteger(group.changeCount) || group.firstChangeIndex !== nextChangeIndex || group.changeCount < 1) {
96177
- throw new Error(
96178
- "Project-version atomic groups must be positive, ordered, and contiguous."
96179
- );
96180
- }
96181
- nextChangeIndex += group.changeCount;
96182
- }
96183
- if (nextChangeIndex !== changeCount) {
96184
- throw new Error(
96185
- `Project-version atomic groups cover ${nextChangeIndex}/${changeCount} changes.`
96186
- );
96187
- }
96188
- return [...groups];
96189
- }
96190
- function estimateProjectVersionChangeCost(change, basePayloadBytes) {
96191
- const encoded = canonicalJsonStringify(change);
96192
- const payloadBytes = new TextEncoder().encode(encoded).byteLength;
96193
- const hasBase = change.operation !== "create";
96194
- if (basePayloadBytes !== void 0 && (!Number.isSafeInteger(basePayloadBytes) || basePayloadBytes < 0))
96195
- throw new Error(
96196
- "Transaction base payload size must be a nonnegative byte count."
96197
- );
96198
- const baseBytes = hasBase ? basePayloadBytes ?? payloadBytes : 0;
96199
- const nextStoredBytes = change.operation === "delete" ? baseBytes : payloadBytes;
96200
- const counts = changeCountCost(change);
96201
- return {
96202
- argumentBytes: payloadBytes + 128,
96203
- bytesRead: payloadBytes + 2 * baseBytes + CHANGE_BYTES_READ_OVERHEAD,
96204
- // Live records appear in the snapshot, result data, result snapshot and diff.
96205
- bytesWritten: (change.operation === "delete" ? 2 * baseBytes + payloadBytes : 4 * nextStoredBytes) + CHANGE_BYTES_WRITTEN_OVERHEAD,
96206
- documentsRead: counts.documentsRead,
96207
- documentsWritten: counts.documentsWritten,
96208
- databaseQueries: counts.databaseQueries,
96209
- // Not metered by Convex: `TransactionMetrics` reports seven dimensions and
96210
- // this is not one of them, so it cannot be measured the way the others
96211
- // were. Every index range a change opens is also a database query, so the
96212
- // measured query count is a strict upper bound on it. Charging exactly
96213
- // that keeps the dimension a true bound instead of an invented number,
96214
- // and keeps it dominated by `databaseQueries` rather than silently
96215
- // becoming the binding constraint on a well-measured plan.
96216
- indexRanges: counts.databaseQueries,
96217
- functionsScheduled: 0,
96218
- scheduledFunctionArgsBytes: 0,
96219
- // Deleted result rows still carry the complete tombstone snapshot.
96220
- returnBytes: (change.operation === "delete" ? baseBytes : 2 * nextStoredBytes) + 512
96221
- };
96222
- }
96223
- function changeCountCost(change) {
96224
- if (change.recordKind === "value") {
96225
- return VALUE_CHANGE_COUNT_COSTS[change.operation];
96226
- }
96227
- return SCHEMA_CHANGE_COUNT_COSTS[change.operation];
96228
- }
96229
96228
  function addProjectVersionTransactionBudgets(left, right) {
96230
96229
  return {
96231
96230
  argumentBytes: left.argumentBytes + right.argumentBytes,
@@ -96240,15 +96239,7 @@ function addProjectVersionTransactionBudgets(left, right) {
96240
96239
  returnBytes: left.returnBytes + right.returnBytes
96241
96240
  };
96242
96241
  }
96243
- function firstExceededResource(cost, target) {
96244
- for (const resource of Object.keys(
96245
- EMPTY_BUDGET
96246
- )) {
96247
- if (cost[resource] > target[resource]) return resource;
96248
- }
96249
- return null;
96250
- }
96251
- var KIB, MIB, PROJECT_TRANSACTION_CHUNK_PAYLOAD_TARGET_BYTES, PROJECT_TRANSACTION_IMMEDIATE_BUDGET, PROJECT_TRANSACTION_WORKER_BUDGET, PROJECT_TRANSACTION_SINGLE_CHANGE_NATIVE_BUDGET, EMPTY_BUDGET, CHUNK_GRAPH_VALIDATION_RESERVE, CHUNK_FIXED_COST, IMMEDIATE_FIXED_COST, WHOLE_GRAPH_VALIDATION_SURCHARGE, VALUE_CHANGE_COUNT_COSTS, SCHEMA_CHANGE_COUNT_COSTS, CHANGE_BYTES_READ_OVERHEAD, CHANGE_BYTES_WRITTEN_OVERHEAD;
96242
+ var KIB, MIB, PROJECT_TRANSACTION_CHUNK_PAYLOAD_TARGET_BYTES, PROJECT_TRANSACTION_IMMEDIATE_BUDGET, PROJECT_TRANSACTION_WORKER_BUDGET, PROJECT_TRANSACTION_SINGLE_CHANGE_NATIVE_BUDGET, EMPTY_BUDGET, CHUNK_GRAPH_VALIDATION_RESERVE, CHUNK_FIXED_COST, IMMEDIATE_FIXED_COST, WHOLE_GRAPH_VALIDATION_SURCHARGE, CHANGE_BYTES_READ_OVERHEAD, CHANGE_BYTES_WRITTEN_OVERHEAD;
96252
96243
  var init_project_version_transaction_planning = __esm({
96253
96244
  "../src/database/project-version-transaction-planning.ts"() {
96254
96245
  "use strict";
@@ -96340,16 +96331,6 @@ var init_project_version_transaction_planning = __esm({
96340
96331
  databaseQueries: 410,
96341
96332
  indexRanges: 410
96342
96333
  };
96343
- VALUE_CHANGE_COUNT_COSTS = {
96344
- create: { documentsRead: 3, documentsWritten: 3, databaseQueries: 8 },
96345
- update: { documentsRead: 6, documentsWritten: 3, databaseQueries: 9 },
96346
- delete: { documentsRead: 6, documentsWritten: 3, databaseQueries: 14 }
96347
- };
96348
- SCHEMA_CHANGE_COUNT_COSTS = {
96349
- create: { documentsRead: 9, documentsWritten: 7, databaseQueries: 9 },
96350
- update: { documentsRead: 6, documentsWritten: 5, databaseQueries: 22 },
96351
- delete: { documentsRead: 6, documentsWritten: 5, databaseQueries: 22 }
96352
- };
96353
96334
  CHANGE_BYTES_READ_OVERHEAD = 4 * KIB;
96354
96335
  CHANGE_BYTES_WRITTEN_OVERHEAD = 4 * KIB;
96355
96336
  }
@@ -101603,12 +101584,12 @@ var init_animation_clips = __esm({
101603
101584
  * fix.
101604
101585
  */
101605
101586
  validateStructuredLeafPartial(args) {
101606
- const memberPath2 = args.path.join(".");
101587
+ const memberPath3 = args.path.join(".");
101607
101588
  const prefix = `Animation clip "${args.clipName}" frame ${args.frameIndex}`;
101608
101589
  const kind = args.member.kind;
101609
101590
  if (!isStructuredLeafKind(kind)) {
101610
101591
  throw new Error(
101611
- `${prefix} member "${memberPath2}" is of kind ${MemberKind[kind]}, which has no addressable fields, so it cannot take a "${STRUCTURED_LEAF_PARTIAL_KEY}" field override.`
101592
+ `${prefix} member "${memberPath3}" is of kind ${MemberKind[kind]}, which has no addressable fields, so it cannot take a "${STRUCTURED_LEAF_PARTIAL_KEY}" field override.`
101612
101593
  );
101613
101594
  }
101614
101595
  const kindLabel = MemberKind[kind];
@@ -101617,7 +101598,7 @@ var init_animation_clips = __esm({
101617
101598
  args.member.id
101618
101599
  ])) {
101619
101600
  throw new Error(
101620
- `${prefix} ${kindLabel} member "${memberPath2}" cannot take a "${STRUCTURED_LEAF_PARTIAL_KEY}" field override; member "${args.member.name}" is not a writable Save/Session override leaf.`
101601
+ `${prefix} ${kindLabel} member "${memberPath3}" cannot take a "${STRUCTURED_LEAF_PARTIAL_KEY}" field override; member "${args.member.name}" is not a writable Save/Session override leaf.`
101621
101602
  );
101622
101603
  }
101623
101604
  const violation = structuredLeafPartialViolation(
@@ -101626,14 +101607,14 @@ var init_animation_clips = __esm({
101626
101607
  kindLabel
101627
101608
  );
101628
101609
  if (violation !== null) {
101629
- throw new Error(`${prefix} member "${memberPath2}" ${violation}.`);
101610
+ throw new Error(`${prefix} member "${memberPath3}" ${violation}.`);
101630
101611
  }
101631
101612
  const resolution = this.resolveDefinitionChildResolution(
101632
101613
  args.definitionNode,
101633
101614
  args.schemaKey,
101634
101615
  args.member
101635
101616
  );
101636
- const descent = `${prefix} cannot descend into ${kindLabel} member "${memberPath2}"`;
101617
+ const descent = `${prefix} cannot descend into ${kindLabel} member "${memberPath3}"`;
101637
101618
  if (resolution.node === null) {
101638
101619
  if (resolution.absence.reason === "nullDefault") {
101639
101620
  throw new Error(
@@ -106922,111 +106903,6 @@ var init_value_record_comparison = __esm({
106922
106903
  }
106923
106904
  });
106924
106905
 
106925
- // src/project-source/lower-support.ts
106926
- function identityMap(declarations, kind) {
106927
- return new Map(
106928
- declarations.map((declaration) => [
106929
- declaration.name,
106930
- materializedId(declaration, kind, declaration.name)
106931
- ])
106932
- );
106933
- }
106934
- function sourceIdentity2(identity2, kind, name) {
106935
- const sourceSpan = span(identity2);
106936
- return {
106937
- symbolId: `${kind}:${materializedIdentityId(identity2, kind, name)}`,
106938
- kind,
106939
- span: sourceSpan,
106940
- selectionSpan: sourceSpan
106941
- };
106942
- }
106943
- function span(identity2) {
106944
- return {
106945
- path: identity2.source.uri,
106946
- start: { ...identity2.source.range.start },
106947
- end: { ...identity2.source.range.end }
106948
- };
106949
- }
106950
- function materializedId(identity2, kind, name) {
106951
- return materializedIdentityId(identity2, kind, name);
106952
- }
106953
- function materializedIdentityId(identity2, kind, name) {
106954
- return identity2.id ?? `__pending__:${kind}:${encodeURIComponent(identity2.source.uri)}:${identity2.source.range.start.line}:${identity2.source.range.start.character}:${encodeURIComponent(name)}`;
106955
- }
106956
- function expressionArguments(expression) {
106957
- const result = /* @__PURE__ */ new Map();
106958
- expression.args.forEach((entry, index) => {
106959
- const name = expression.argumentNames?.[index] ?? null;
106960
- if (name === null) {
106961
- throw new Error(
106962
- "Project configuration constructors require named arguments."
106963
- );
106964
- }
106965
- if (result.has(name)) {
106966
- throw new Error(
106967
- `Constructor argument ${JSON.stringify(name)} is duplicated.`
106968
- );
106969
- }
106970
- result.set(name, entry);
106971
- });
106972
- return result;
106973
- }
106974
- function annotation(annotations, name) {
106975
- return annotations.find((entry) => entry.name === name);
106976
- }
106977
- function argument(value, name) {
106978
- return value?.arguments.find((entry) => entry.name === name)?.expression ?? null;
106979
- }
106980
- function parseAnnotationExpression(value) {
106981
- return parseExpression(value);
106982
- }
106983
- function stringArgument(value, name) {
106984
- const raw = argument(value, name);
106985
- if (raw === null) return null;
106986
- const expression = parseAnnotationExpression(raw);
106987
- return expression.kind === "litString" ? expression.value : null;
106988
- }
106989
- function contextualEnumArgument(value, name) {
106990
- const raw = argument(value, name);
106991
- if (raw === null) return null;
106992
- const expression = parseAnnotationExpression(raw);
106993
- return expression.kind === "contextualEnum" ? expression.name : null;
106994
- }
106995
- function systemMetadata(annotations) {
106996
- const system = annotation(annotations, "system");
106997
- if (!system) return null;
106998
- const kind = contextualEnumArgument(system, "kind");
106999
- if (kind === null) {
107000
- throw new Error("@system requires a kind inferred enum argument.");
107001
- }
107002
- const worldKind = contextualEnumArgument(system, "worldKind");
107003
- return {
107004
- kind: lowerFirst3(kind),
107005
- worldKind: worldKind ? lowerFirst3(worldKind) : null
107006
- };
107007
- }
107008
- function requiredName2(values, name, kind) {
107009
- const value = values.get(name);
107010
- if (!value) throw new Error(`Unknown ${kind} ${JSON.stringify(name)}.`);
107011
- return value;
107012
- }
107013
- function lowerFirst3(value) {
107014
- return value.length ? `${value[0].toLowerCase()}${value.slice(1)}` : value;
107015
- }
107016
- function indexFirstById(values) {
107017
- const result = /* @__PURE__ */ new Map();
107018
- for (const value of values) {
107019
- if (!result.has(value.id)) result.set(value.id, value);
107020
- }
107021
- return result;
107022
- }
107023
- var init_lower_support = __esm({
107024
- "src/project-source/lower-support.ts"() {
107025
- "use strict";
107026
- init_src();
107027
- }
107028
- });
107029
-
107030
106906
  // src/project-source/lower-configuration.ts
107031
106907
  function lowerConfiguration(base, analysis) {
107032
106908
  const globals = analysis.configuration.globals;
@@ -107978,7 +107854,7 @@ function nullableStatusConstructorArgument(argumentsValue, name, fallback, statu
107978
107854
  }
107979
107855
  function resolveStatusExpression(expression, statusIdsByName) {
107980
107856
  if (expression.kind === "ident") {
107981
- return requiredName2(
107857
+ return requiredName(
107982
107858
  statusIdsByName,
107983
107859
  expression.name,
107984
107860
  "localization status"
@@ -108054,6 +107930,200 @@ var init_lower_configuration = __esm({
108054
107930
  }
108055
107931
  });
108056
107932
 
107933
+ // src/project-source/initializer-reference-spellings.ts
107934
+ function sourceOffsetAt(source, pos) {
107935
+ let offset = 0;
107936
+ for (let line = 1; line < pos.line; line += 1) {
107937
+ const next = source.indexOf("\n", offset);
107938
+ if (next < 0) return null;
107939
+ offset = next + 1;
107940
+ }
107941
+ return Math.min(offset + pos.column - 1, source.length);
107942
+ }
107943
+ function settleInitializerReferenceSpellings(code, settle) {
107944
+ const splices = [];
107945
+ const pending = [parseExpression(code)];
107946
+ while (pending.length > 0) {
107947
+ const node = pending.pop();
107948
+ switch (node.kind) {
107949
+ case "call": {
107950
+ const target = settle(node);
107951
+ if (target === null) {
107952
+ pending.push(node.callee, ...node.args);
107953
+ break;
107954
+ }
107955
+ const start = sourceOffsetAt(code, node.callee.pos);
107956
+ const end = start === null ? null : referenceCallEnd(code, start);
107957
+ if (start === null || end === null) break;
107958
+ splices.push({
107959
+ start,
107960
+ end,
107961
+ text: `Reference<${target.typeName}>(id: ${JSON.stringify(target.id)})`
107962
+ });
107963
+ break;
107964
+ }
107965
+ case "annotated":
107966
+ pending.push(node.expression);
107967
+ break;
107968
+ case "new":
107969
+ pending.push(...node.args);
107970
+ for (const entry of node.initializer ?? []) pending.push(entry.value);
107971
+ break;
107972
+ case "litList":
107973
+ pending.push(...node.elements);
107974
+ break;
107975
+ case "litDict":
107976
+ for (const entry of node.entries) pending.push(entry.value);
107977
+ break;
107978
+ case "member":
107979
+ pending.push(node.receiver);
107980
+ break;
107981
+ case "index":
107982
+ pending.push(node.receiver, node.index);
107983
+ break;
107984
+ case "binary":
107985
+ case "coalesce":
107986
+ pending.push(node.left, node.right);
107987
+ break;
107988
+ case "conditional":
107989
+ pending.push(node.condition, node.whenTrue, node.whenFalse);
107990
+ break;
107991
+ case "unary":
107992
+ case "force":
107993
+ case "is":
107994
+ pending.push(node.operand);
107995
+ break;
107996
+ }
107997
+ }
107998
+ if (splices.length === 0) return code;
107999
+ splices.sort((left, right) => right.start - left.start);
108000
+ let settled = code;
108001
+ for (const splice of splices) {
108002
+ settled = settled.slice(0, splice.start) + splice.text + settled.slice(splice.end);
108003
+ }
108004
+ return settled;
108005
+ }
108006
+ function referenceCallEnd(code, start) {
108007
+ const open = code.indexOf("(", start);
108008
+ if (open < 0) return null;
108009
+ let depth = 0;
108010
+ let quoted = null;
108011
+ for (let index = open; index < code.length; index += 1) {
108012
+ const character = code[index];
108013
+ if (quoted !== null) {
108014
+ if (character === "\\") index += 1;
108015
+ else if (character === quoted) quoted = null;
108016
+ continue;
108017
+ }
108018
+ if (character === '"' || character === "'") quoted = character;
108019
+ else if (character === "(") depth += 1;
108020
+ else if (character === ")") {
108021
+ depth -= 1;
108022
+ if (depth === 0) return index + 1;
108023
+ }
108024
+ }
108025
+ return null;
108026
+ }
108027
+ function memberValueIdV4(memberId) {
108028
+ return isPendingId(memberId) ? pendingMemberValueId(memberId) : derivedMemberValueId(memberId);
108029
+ }
108030
+ function referencedSymbolPath(call) {
108031
+ if (call.callee.kind !== "ident" || call.callee.name !== "Reference") {
108032
+ return null;
108033
+ }
108034
+ if ((call.typeArguments?.length ?? 0) > 1) return null;
108035
+ if (call.args.length !== 1) return null;
108036
+ if (typeof call.argumentNames?.[0] === "string") return null;
108037
+ const path = memberPath(call.args[0]);
108038
+ if (path === null) return null;
108039
+ const typeArgument = call.typeArguments?.[0];
108040
+ return {
108041
+ path,
108042
+ genericTypeName: typeArgument === void 0 ? null : astTypeNameV4(typeArgument)
108043
+ };
108044
+ }
108045
+ function memberPath(expression) {
108046
+ if (expression.kind === "ident") return expression.name;
108047
+ if (expression.kind !== "member") return null;
108048
+ const receiver = memberPath(expression.receiver);
108049
+ return receiver === null ? null : `${receiver}.${expression.name}`;
108050
+ }
108051
+ function unidentifiedLocalReferenceError(name) {
108052
+ return new Error(
108053
+ `Reference(${name}) inside a constructed initializer needs ${name} to carry an @id. Push the declaration of ${name} first, then reference it.`
108054
+ );
108055
+ }
108056
+ function createSchemaInitializerReferenceSettlerV4(args) {
108057
+ let sourceStatics = null;
108058
+ const readSourceStatics = () => {
108059
+ if (sourceStatics !== null) return sourceStatics;
108060
+ const statics = /* @__PURE__ */ new Map();
108061
+ for (const sourceClass of args.analysis.schema.classes) {
108062
+ for (const declaration of sourceClass.members) {
108063
+ if (!declaration.modifiers.includes("static")) continue;
108064
+ if (declaration.kind !== "field") continue;
108065
+ const path = `${sourceClass.name}.${declaration.name}`;
108066
+ statics.set(path, {
108067
+ memberId: materializedId(declaration, "member", path),
108068
+ typeName: declaration.type.name
108069
+ });
108070
+ }
108071
+ }
108072
+ sourceStatics = statics;
108073
+ return statics;
108074
+ };
108075
+ const staticValueId = (path, memberId) => args.staticValueIdsBySymbol.get(path) ?? memberValueIdV4(memberId);
108076
+ const settle = (call) => {
108077
+ const spelled = referencedSymbolPath(call);
108078
+ if (spelled === null) return null;
108079
+ if (args.localValues.has(spelled.path)) {
108080
+ const declared = args.localValues.declaredTarget(spelled.path);
108081
+ if (declared === null)
108082
+ throw unidentifiedLocalReferenceError(spelled.path);
108083
+ const typeName2 = spelled.genericTypeName ?? declared.typeName;
108084
+ if ("id" in declared) return { id: declared.id, typeName: typeName2 };
108085
+ return {
108086
+ id: staticValueId(declared.ownerPath, declared.ownerMemberId),
108087
+ typeName: typeName2
108088
+ };
108089
+ }
108090
+ const source = readSourceStatics().get(spelled.path);
108091
+ if (source !== void 0) {
108092
+ return {
108093
+ id: staticValueId(spelled.path, source.memberId),
108094
+ typeName: spelled.genericTypeName ?? source.typeName
108095
+ };
108096
+ }
108097
+ const stored = args.staticValueIdsBySymbol.get(spelled.path);
108098
+ if (stored === void 0) return null;
108099
+ const typeName = spelled.genericTypeName ?? storedStaticTypeName(args.manifest, spelled.path);
108100
+ return typeName === null ? null : { id: stored, typeName };
108101
+ };
108102
+ return (code) => settleInitializerReferenceSpellings(code, settle);
108103
+ }
108104
+ function storedStaticTypeName(manifest, path) {
108105
+ const separator = path.lastIndexOf(".");
108106
+ if (separator < 0) return null;
108107
+ const className = path.slice(0, separator);
108108
+ const memberName = path.slice(separator + 1);
108109
+ const schemaClass2 = manifest.classes.find(
108110
+ (entry) => entry.name === className
108111
+ );
108112
+ const memberId = schemaClass2?.schema[memberName];
108113
+ const member = manifest.members.find((entry) => entry.id === memberId);
108114
+ if (member?.kind !== "class") return null;
108115
+ return manifest.classes.find((entry) => entry.id === member.classId)?.name ?? null;
108116
+ }
108117
+ var init_initializer_reference_spellings = __esm({
108118
+ "src/project-source/initializer-reference-spellings.ts"() {
108119
+ "use strict";
108120
+ init_member_value_id();
108121
+ init_src();
108122
+ init_key_reference_spelling();
108123
+ init_lower_support();
108124
+ }
108125
+ });
108126
+
108057
108127
  // ../src/models/members/required-constructor-id.ts
108058
108128
  function derivedRequiredConstructorId(classId) {
108059
108129
  return inSystemRecordNamespaceOf(
@@ -108506,9 +108576,9 @@ function lowerClass(context, declaration) {
108506
108576
  if (classBases.length > 1) {
108507
108577
  throw new Error(`Class ${declaration.name} has more than one Class base.`);
108508
108578
  }
108509
- const extendsClassId = classBases[0] ? requiredName2(context.classIdsByName, classBases[0].name, "class") : null;
108579
+ const extendsClassId = classBases[0] ? requiredName(context.classIdsByName, classBases[0].name, "class") : null;
108510
108580
  const implementsInterfaceIds = declaration.baseTypes.filter((type) => context.interfaceIdsByName.has(type.name)).map(
108511
- (type) => requiredName2(context.interfaceIdsByName, type.name, "interface")
108581
+ (type) => requiredName(context.interfaceIdsByName, type.name, "interface")
108512
108582
  );
108513
108583
  const schema = {};
108514
108584
  const schemaKeyOrder = [];
@@ -109141,7 +109211,7 @@ function lowerFieldMember(context, ownerClass, declaration, id2, commonInput, ba
109141
109211
  entryMemberId: entryId,
109142
109212
  key: keyType.name === "string" ? { kind: "string" } : {
109143
109213
  kind: "enum",
109144
- enumId: requiredName2(context.enumIdsByName, keyType.name, "enum")
109214
+ enumId: requiredName(context.enumIdsByName, keyType.name, "enum")
109145
109215
  }
109146
109216
  };
109147
109217
  }
@@ -109498,7 +109568,7 @@ function lowerInterface(context, declaration) {
109498
109568
  ...declaration.docsText === void 0 ? {} : { docsText: declaration.docsText },
109499
109569
  members,
109500
109570
  extendsInterfaceIds: declaration.baseTypes.map(
109501
- (type) => requiredName2(context.interfaceIdsByName, type.name, "interface")
109571
+ (type) => requiredName(context.interfaceIdsByName, type.name, "interface")
109502
109572
  ),
109503
109573
  system: systemMetadata(declaration.annotations) ?? base?.system ?? null
109504
109574
  };
@@ -109595,7 +109665,7 @@ function lowerType(context, type, ownerClass) {
109595
109665
  kind: "dictionary",
109596
109666
  nullable: nullable2,
109597
109667
  entryType: lowerType(context, requiredTypeArgument(type, 1), ownerClass),
109598
- keyEnumId: key.name === "string" ? null : requiredName2(context.enumIdsByName, key.name, "enum"),
109668
+ keyEnumId: key.name === "string" ? null : requiredName(context.enumIdsByName, key.name, "enum"),
109599
109669
  readOnly: false
109600
109670
  };
109601
109671
  }
@@ -109675,7 +109745,13 @@ function lowerDefault(context, initializer, type, ownerClass, base, memberId, st
109675
109745
  }
109676
109746
  const expression = parseExpression(initializer);
109677
109747
  if (positionRequiresEvaluation(context, expression, type, ownerClass)) {
109678
- return { init: { code: normalizeInitializerSource(initializer) } };
109748
+ return {
109749
+ init: {
109750
+ code: context.settleInitializerReferences(
109751
+ normalizeInitializerSource(initializer)
109752
+ )
109753
+ }
109754
+ };
109679
109755
  }
109680
109756
  if (context.rowBackedDefaultMemberIds.has(memberId) && base?.defaultValue && !("serverValueId" in base.defaultValue)) {
109681
109757
  return base.defaultValue;
@@ -110000,7 +110076,7 @@ function lowerExpressionValue(context, expression, declaredExpected, ownerClass,
110000
110076
  );
110001
110077
  }
110002
110078
  const className = explicitPartial ? expectedType.name : expression.className ?? expectedType.name;
110003
- const classId = requiredName2(context.classIdsByName, className, "class");
110079
+ const classId = requiredName(context.classIdsByName, className, "class");
110004
110080
  const innerEnvironment = constructedGenericEnvironment(
110005
110081
  context,
110006
110082
  classId,
@@ -110180,15 +110256,6 @@ function isStoredActionLiteral(type, expression) {
110180
110256
  while (current.kind === "annotated") current = current.expression;
110181
110257
  return current.kind === "litList";
110182
110258
  }
110183
- function sourceOffsetAt(source, pos) {
110184
- let offset = 0;
110185
- for (let line = 1; line < pos.line; line += 1) {
110186
- const next = source.indexOf("\n", offset);
110187
- if (next < 0) return null;
110188
- offset = next + 1;
110189
- }
110190
- return Math.min(offset + pos.column - 1, source.length);
110191
- }
110192
110259
  function lambdaExpressionSource(source, lambda) {
110193
110260
  const start = sourceOffsetAt(source, lambda.pos);
110194
110261
  if (start === null) return null;
@@ -110668,14 +110735,14 @@ function genericConstraint(context, ownerClass, parameterId, type, baseConstrain
110668
110735
  }
110669
110736
  return {
110670
110737
  kind: "enum",
110671
- enumId: requiredName2(context.enumIdsByName, type.name, "enum")
110738
+ enumId: requiredName(context.enumIdsByName, type.name, "enum")
110672
110739
  };
110673
110740
  }
110674
110741
  function inheritedMemberId(context, ownerClass, name) {
110675
110742
  const directBase = ownerClass.baseTypes.find(
110676
110743
  (entry) => context.classIdsByName.has(entry.name)
110677
110744
  );
110678
- const classId = directBase ? requiredName2(context.classIdsByName, directBase.name, "class") : null;
110745
+ const classId = directBase ? requiredName(context.classIdsByName, directBase.name, "class") : null;
110679
110746
  return effectiveMemberIdByName(context, classId, name);
110680
110747
  }
110681
110748
  function effectiveMemberIdByName(context, startClassId, name) {
@@ -110698,7 +110765,7 @@ function effectiveMemberIdByName(context, startClassId, name) {
110698
110765
  const sourceBase = sourceClass.baseTypes.find(
110699
110766
  (entry) => context.classIdsByName.has(entry.name)
110700
110767
  );
110701
- classId = sourceBase ? requiredName2(context.classIdsByName, sourceBase.name, "class") : null;
110768
+ classId = sourceBase ? requiredName(context.classIdsByName, sourceBase.name, "class") : null;
110702
110769
  continue;
110703
110770
  }
110704
110771
  const pulledClass = context.baseClasses.get(classId);
@@ -111014,6 +111081,7 @@ var UNSET_LIST_COLUMN_WIDTH, EMPTY_GENERIC_TYPE_ENVIRONMENT, DICTIONARY_KEY_TYPE
111014
111081
  var init_lower_members = __esm({
111015
111082
  "src/project-source/lower-members.ts"() {
111016
111083
  "use strict";
111084
+ init_initializer_reference_spellings();
111017
111085
  init_src();
111018
111086
  init_src2();
111019
111087
  init_lower_support();
@@ -111218,7 +111286,7 @@ function genericRelationEndpoint(context, expression, relationKind, side, prior)
111218
111286
  }
111219
111287
  return {
111220
111288
  recordKind: "class",
111221
- recordId: requiredName2(context.classIdsByName, expression.name, "class")
111289
+ recordId: requiredName(context.classIdsByName, expression.name, "class")
111222
111290
  };
111223
111291
  }
111224
111292
  if (expression.kind === "member" && expression.receiver.kind === "ident" && expected === "value") {
@@ -111326,7 +111394,7 @@ function relationExpressionIdentity(expression) {
111326
111394
  }
111327
111395
  function relationTargetClassId(context, expression) {
111328
111396
  if (expression.kind === "ident") {
111329
- return requiredName2(context.classIdsByName, expression.name, "class");
111397
+ return requiredName(context.classIdsByName, expression.name, "class");
111330
111398
  }
111331
111399
  if (expression.kind === "call" && expression.callee.kind === "ident" && expression.callee.name === "Reference") {
111332
111400
  const index = expression.argumentNames?.findIndex((name) => name === "id") ?? -1;
@@ -111374,7 +111442,7 @@ function lowerVariants(context, analysis) {
111374
111442
  );
111375
111443
  const variants = variantGlobals(analysis).map((global) => {
111376
111444
  const className = owningClassName(global);
111377
- const classId = requiredName2(context.classIdsByName, className, "class");
111445
+ const classId = requiredName(context.classIdsByName, className, "class");
111378
111446
  const variantId = variantRecordId(global, global.type.name);
111379
111447
  return {
111380
111448
  id: variantId,
@@ -111406,7 +111474,7 @@ function variantValueBindingsV4(manifest, analysis) {
111406
111474
  targetClassId: variant2.classId,
111407
111475
  targetClassName: requiredClassName2(classNames, variant2.classId),
111408
111476
  variantTypeName: global.type.name,
111409
- valueClassId: global.type.name === NEO_LOOKUP_VARIANT_TYPE_NAME ? requiredName2(
111477
+ valueClassId: global.type.name === NEO_LOOKUP_VARIANT_TYPE_NAME ? requiredName(
111410
111478
  new Map(
111411
111479
  manifest.classes.map((entry) => [entry.name, entry.id])
111412
111480
  ),
@@ -111441,7 +111509,7 @@ function lowerVariantFolders(context, analysis) {
111441
111509
  return {
111442
111510
  id: variantRecordId(global, NEO_VARIANT_FOLDER_TYPE_NAME),
111443
111511
  source: sourceIdentity2(global, "variantFolder", global.name),
111444
- classId: requiredName2(context.classIdsByName, className, "class"),
111512
+ classId: requiredName(context.classIdsByName, className, "class"),
111445
111513
  path: folderPath2(global),
111446
111514
  binding: folderBinding(context, global)
111447
111515
  };
@@ -111641,6 +111709,7 @@ var init_lower_variants = __esm({
111641
111709
  // src/project-source/lower-schema.ts
111642
111710
  function lowerProjectSchemaV4(base, analysis, options = {}) {
111643
111711
  const classIdsByName = identityMap(analysis.schema.classes, "class");
111712
+ const staticValueIdsBySymbol3 = options.staticValueIdsBySymbol ?? /* @__PURE__ */ new Map();
111644
111713
  const interfaceIdsByName = identityMap(
111645
111714
  analysis.schema.interfaces,
111646
111715
  "interface"
@@ -111716,7 +111785,17 @@ function lowerProjectSchemaV4(base, analysis, options = {}) {
111716
111785
  loweredMembers: /* @__PURE__ */ new Map(),
111717
111786
  entryTypesByEntryId: /* @__PURE__ */ new Map(),
111718
111787
  placements: /* @__PURE__ */ new Map(),
111719
- staticValueIdsBySymbol: options.staticValueIdsBySymbol ?? /* @__PURE__ */ new Map(),
111788
+ staticValueIdsBySymbol: staticValueIdsBySymbol3,
111789
+ settleInitializerReferences: createSchemaInitializerReferenceSettlerV4({
111790
+ analysis,
111791
+ manifest: base,
111792
+ staticValueIdsBySymbol: staticValueIdsBySymbol3,
111793
+ localValues: new LocalValueBindingsV4(
111794
+ analysis.values.globals,
111795
+ analysis.schema.enums.map((declaration) => declaration.name),
111796
+ staticMembersInitializedByName(analysis)
111797
+ )
111798
+ }),
111720
111799
  templateIdsByName: new Map(
111721
111800
  analysis.configuration.globals.flatMap(
111722
111801
  (global) => global.type.name === "TextureTemplate" ? [
@@ -111849,6 +111928,8 @@ var init_lower_schema = __esm({
111849
111928
  init_lower_relations();
111850
111929
  init_lower_variants();
111851
111930
  init_lower_support();
111931
+ init_initializer_reference_spellings();
111932
+ init_local_values();
111852
111933
  }
111853
111934
  });
111854
111935
 
@@ -115321,7 +115402,7 @@ function materializedInitializerReconciliationFailuresV4(args) {
115321
115402
  `Cannot reconcile stored construction for value "${valueId}": its canonical pulled constructor expression is unavailable.`
115322
115403
  );
115323
115404
  }
115324
- const authoredConstructionChanged = args.manifest !== void 0 && canonicalExpression !== constructorExpressionSlice(reconciliation.code);
115405
+ const authoredConstructionChanged = args.manifest !== void 0 && canonicalExpression !== reconciliation.construction;
115325
115406
  authoredConstructionChangedByValueId.set(
115326
115407
  valueId,
115327
115408
  authoredConstructionChanged
@@ -115710,7 +115791,6 @@ var init_local_initializer_materialization = __esm({
115710
115791
  init_src();
115711
115792
  init_projection();
115712
115793
  init_source_diagnostics();
115713
- init_init_source();
115714
115794
  init_initializer_replay();
115715
115795
  init_materialized_construction_cache();
115716
115796
  init_neoscript_build_cache();
@@ -119959,7 +120039,8 @@ function buildValueLowerContext(state, manifest, options = {}) {
119959
120039
  return {
119960
120040
  localValues: registry.localValues ??= new LocalValueBindingsV4(
119961
120041
  options.analysis?.values.globals ?? [],
119962
- manifest.enums.values().map((entry) => entry.name)
120042
+ manifest.enums.values().map((entry) => entry.name),
120043
+ options.analysis === void 0 ? [] : staticMembersInitializedByName(options.analysis)
119963
120044
  ),
119964
120045
  state,
119965
120046
  members,
@@ -121061,7 +121142,7 @@ function memberInitializerRequiresEvaluation(context, member, expression, source
121061
121142
  return requiresEvaluation;
121062
121143
  }
121063
121144
  function isSchemaMemberValueRead(context, expression, source) {
121064
- const path = memberPath(annotatedValue(expression).expression);
121145
+ const path = memberPath2(annotatedValue(expression).expression);
121065
121146
  if (path === null) return false;
121066
121147
  const parts = path.split(".");
121067
121148
  const name = parts.at(-1);
@@ -121724,7 +121805,10 @@ function lowerSeedRow(context, member, sourceExpression, source, valueId, path,
121724
121805
  nodeType: "initializer",
121725
121806
  id: valueId,
121726
121807
  memberId: member.id,
121727
- code,
121808
+ code: settleInitializerReferenceSpellings(
121809
+ code,
121810
+ (call) => settledReferenceTarget(context, call)
121811
+ ),
121728
121812
  ...containerId === void 0 ? {} : { containerId }
121729
121813
  };
121730
121814
  registerSeedRow(context, rows, initRow, source, sourceExpression);
@@ -122369,6 +122453,10 @@ function lowerValueRow(context, member, sourceExpression, expectedValueId, sourc
122369
122453
  );
122370
122454
  }
122371
122455
  indexInitAuthoredRowIds(context, code, source.label);
122456
+ const compiledCode = settleInitializerReferenceSpellings(
122457
+ code,
122458
+ (call) => settledReferenceTarget(context, call)
122459
+ );
122372
122460
  const storedConstructorArgs = isObjectRecord2(base.constructorArgs) ? base.constructorArgs : null;
122373
122461
  if (resolvedMember.kind !== "class" && isLiteralValueContent(base)) {
122374
122462
  addReconstructed(
@@ -122403,7 +122491,8 @@ function lowerValueRow(context, member, sourceExpression, expectedValueId, sourc
122403
122491
  if (source.purpose === "stored" || requiresCanonicalConstruction) {
122404
122492
  context.initializerReconciliations.set(expectedValueId, {
122405
122493
  valueId: expectedValueId,
122406
- code,
122494
+ code: compiledCode,
122495
+ construction: authoredConstruction,
122407
122496
  storedConstructorArgs: storedConstructorArgs === null ? null : structuredClone(storedConstructorArgs),
122408
122497
  // Only a construction this pass could not apply is a conflict. A
122409
122498
  // re-projected one landed on the rows the canonical expression is
@@ -122435,7 +122524,7 @@ function lowerValueRow(context, member, sourceExpression, expectedValueId, sourc
122435
122524
  context,
122436
122525
  "value",
122437
122526
  expectedValueId,
122438
- { ...literalFields, init: { code } },
122527
+ { ...literalFields, init: { code: compiledCode } },
122439
122528
  source.source
122440
122529
  );
122441
122530
  return expectedValueId;
@@ -123815,7 +123904,7 @@ function requiredDecimal(expression) {
123815
123904
  }
123816
123905
  function sourceValueSymbol(context, expression) {
123817
123906
  const unwrapped = annotatedValue(expression).expression;
123818
- const path = memberPath(unwrapped);
123907
+ const path = memberPath2(unwrapped);
123819
123908
  return path === null ? null : context.staticValueIdsBySymbol.get(path) ?? null;
123820
123909
  }
123821
123910
  function resolveKeyReferenceMemberDefaultsV4(args) {
@@ -123899,12 +123988,12 @@ function referenceTargetSpelling(context, expression) {
123899
123988
  };
123900
123989
  }
123901
123990
  const resolved = referenceTargetBySymbol(context, argument2, genericTypeName);
123902
- const path = memberPath(argument2);
123991
+ const path = memberPath2(argument2);
123903
123992
  if (resolved === null || path === null) return null;
123904
123993
  return { spelling: "symbol", path, resolved };
123905
123994
  }
123906
123995
  function referenceTargetBySymbol(context, argument2, genericTypeName) {
123907
- const path = memberPath(argument2);
123996
+ const path = memberPath2(argument2);
123908
123997
  if (path === null) return null;
123909
123998
  const valueId = context.staticValueIdsBySymbol.get(path);
123910
123999
  if (valueId) {
@@ -123924,6 +124013,22 @@ function referenceTargetBySymbol(context, argument2, genericTypeName) {
123924
124013
  genericTypeName
123925
124014
  } : null;
123926
124015
  }
124016
+ function settledReferenceTarget(context, call) {
124017
+ const target = referenceTargetSpelling(context, call);
124018
+ if (target?.spelling === "symbol") {
124019
+ const typeName2 = target.resolved.genericTypeName ?? target.resolved.typeName;
124020
+ return typeName2 === null ? null : { id: target.resolved.id, typeName: typeName2 };
124021
+ }
124022
+ if (target?.spelling !== "local") return null;
124023
+ const declared = context.localValues.declaredTarget(target.name);
124024
+ if (declared === null) throw unidentifiedLocalReferenceError(target.name);
124025
+ const typeName = target.typeName ?? declared.typeName;
124026
+ if ("id" in declared) return { id: declared.id, typeName };
124027
+ return {
124028
+ id: context.staticValueIdsBySymbol.get(declared.ownerPath) ?? memberValueId(declared.ownerMemberId),
124029
+ typeName
124030
+ };
124031
+ }
123927
124032
  function referenceTargetById(context, id2, genericTypeName) {
123928
124033
  const pendingValue = context.pendingValues.get(id2);
123929
124034
  if (pendingValue !== void 0) {
@@ -124419,7 +124524,7 @@ function indexSourceStaticTargets(targets, state, analysis, manifest, parsedInit
124419
124524
  }
124420
124525
  }
124421
124526
  function sourceValueSymbolFromMap(targets, expression) {
124422
- const path = memberPath(annotatedValue(expression).expression);
124527
+ const path = memberPath2(annotatedValue(expression).expression);
124423
124528
  return path === null ? null : targets.get(path) ?? null;
124424
124529
  }
124425
124530
  function returnedSymbol(body) {
@@ -124437,7 +124542,7 @@ function returnedSymbol(body) {
124437
124542
  function firstReturnedMemberPath(statements) {
124438
124543
  for (const statement of statements) {
124439
124544
  if (statement.kind === "return") {
124440
- const path = statement.expr === null ? null : memberPath(statement.expr);
124545
+ const path = statement.expr === null ? null : memberPath2(statement.expr);
124441
124546
  if (path !== null) return path;
124442
124547
  continue;
124443
124548
  }
@@ -124560,7 +124665,7 @@ function classMemberByName(context, classId, name) {
124560
124665
  );
124561
124666
  }
124562
124667
  function lowerFunctionReference(context, expression, ownerClassId) {
124563
- const symbol = memberPath(expression);
124668
+ const symbol = memberPath2(expression);
124564
124669
  if (symbol === null || symbol.includes(".")) {
124565
124670
  throw new Error("FunctionRef values require a bare function symbol.");
124566
124671
  }
@@ -124609,7 +124714,7 @@ function lowerActionListener2(context, element, ownerClassId, index) {
124609
124714
  `NeoAction listener ${index} is a lambda. A listener must be a member reference: extract the body to an NSFunction member and subscribe that member instead.`
124610
124715
  );
124611
124716
  }
124612
- const path = memberPath(expression);
124717
+ const path = memberPath2(expression);
124613
124718
  if (path === null) {
124614
124719
  throw new Error(
124615
124720
  `NeoAction listener ${index} must name a function, NSFunction, NSDelegate, or NeoAction member on the current Class or a receiver reachable through root.`
@@ -124666,7 +124771,7 @@ function lowerDelegateValue(context, expression, ownerClassId, authoredSlice) {
124666
124771
  }
124667
124772
  return { code };
124668
124773
  }
124669
- const path = memberPath(expression);
124774
+ const path = memberPath2(expression);
124670
124775
  const symbol = path?.startsWith("this.") ? path.slice("this.".length) : path;
124671
124776
  if (symbol === null || symbol === void 0 || symbol.includes(".")) {
124672
124777
  throw new Error(
@@ -124687,7 +124792,7 @@ function lowerDelegateValue(context, expression, ownerClassId, authoredSlice) {
124687
124792
  return { memberId: target.id, valueId: null };
124688
124793
  }
124689
124794
  function fileTargetId(context, expression, registry) {
124690
- const path = memberPath(expression);
124795
+ const path = memberPath2(expression);
124691
124796
  if (path !== null) {
124692
124797
  if (!path.startsWith(`${registry}.`)) return null;
124693
124798
  return context.projectFileIdsBySymbol.get(path) ?? null;
@@ -124699,10 +124804,10 @@ function fileTargetId(context, expression, registry) {
124699
124804
  }
124700
124805
  return null;
124701
124806
  }
124702
- function memberPath(expression) {
124807
+ function memberPath2(expression) {
124703
124808
  if (expression.kind === "ident") return expression.name;
124704
124809
  if (expression.kind !== "member") return null;
124705
- const receiver = memberPath(expression.receiver);
124810
+ const receiver = memberPath2(expression.receiver);
124706
124811
  return receiver === null ? null : `${receiver}.${expression.name}`;
124707
124812
  }
124708
124813
  function annotatedValue(expression) {
@@ -126748,6 +126853,7 @@ var init_value_sources = __esm({
126748
126853
  init_initializer_replay();
126749
126854
  init_key_reference_spelling();
126750
126855
  init_local_values();
126856
+ init_initializer_reference_spellings();
126751
126857
  init_lower_members();
126752
126858
  init_lower_variants();
126753
126859
  init_member_kind_type_names();
@@ -128145,16 +128251,6 @@ var init_api = __esm({
128145
128251
  });
128146
128252
 
128147
128253
  // src/convex.ts
128148
- var convex_exports = {};
128149
- __export(convex_exports, {
128150
- api: () => api2,
128151
- convexHttpActionUrl: () => convexHttpActionUrl,
128152
- createConvexClient: () => createConvexClient,
128153
- createConvexClientForApi: () => createConvexClientForApi,
128154
- createConvexPushConnection: () => createConvexPushConnection,
128155
- mintConvexJwt: () => mintConvexJwt,
128156
- resolveConvexUrl: () => resolveConvexUrl
128157
- });
128158
128254
  import { gzipSync } from "node:zlib";
128159
128255
  import { ConvexClient, ConvexHttpClient } from "convex/browser";
128160
128256
  import { Buffer as Buffer2 } from "node:buffer";
@@ -129843,6 +129939,7 @@ __export(push_exports, {
129843
129939
  applyPushResult: () => applyPushResult,
129844
129940
  assignPendingIds: () => assignPendingIds,
129845
129941
  buildPostPushCompileSchema: () => buildPostPushCompileSchema,
129942
+ commitProjectVersionChanges: () => commitProjectVersionChanges,
129846
129943
  createPendingProjectSourceIdentityV4: () => createPendingProjectSourceIdentityV4,
129847
129944
  prepareCompleteNeoScriptBodyChanges: () => prepareCompleteNeoScriptBodyChanges,
129848
129945
  prepareLocalCandidateV4: () => prepareLocalCandidateV4,
@@ -130074,6 +130171,81 @@ function pendingInterfaceMemberSymbolOwner(value) {
130074
130171
  if (!/^\d+$/u.test(parts[4] ?? "")) return null;
130075
130172
  return owner;
130076
130173
  }
130174
+ async function commitProjectVersionChanges(args) {
130175
+ const { workspace } = args;
130176
+ const body = {
130177
+ operation: args.operation,
130178
+ changes: args.changes,
130179
+ authoredValueSeeds: [],
130180
+ initializerMaterialization: { roots: [] },
130181
+ stagedFiles: [],
130182
+ stagedUploadSessionId: null,
130183
+ // The asynchronous path keys reconnects on this identity; the rows name
130184
+ // the commit, so the same repair resubmitted is the same transaction.
130185
+ sourceHash: createHash10("sha256").update(
130186
+ JSON.stringify(
130187
+ args.changes.map((change) => `${change.recordKind}:${change.recordId}`).sort()
130188
+ )
130189
+ ).digest("hex"),
130190
+ pendingIdAssignments: {},
130191
+ summary: args.summary,
130192
+ headTransactionHash: workspace.state.headTransactionHash ?? null,
130193
+ derivedEdgeExtractorVersion: PROJECT_SNAPSHOT_DERIVED_EDGE_EXTRACTOR_VERSION,
130194
+ forceRecompile: false
130195
+ };
130196
+ const reporter = createPushProgressReporter(args.json, args.progressLabel);
130197
+ reporter.report({
130198
+ type: "project-transaction-progress",
130199
+ transactionId: null,
130200
+ phase: "submitting",
130201
+ totalChangeCount: args.changes.length,
130202
+ appliedChangeCount: 0,
130203
+ totalChunkCount: null,
130204
+ appliedChunkCount: 0,
130205
+ errorCode: null,
130206
+ errorMessage: null
130207
+ });
130208
+ try {
130209
+ const connection = await createConvexPushConnection(workspace);
130210
+ let response;
130211
+ try {
130212
+ response = await connection.submit(body, false);
130213
+ } catch (error) {
130214
+ if (!(error instanceof NeoApiError) || error.status !== 413 || !isObjectRecord2(error.body) || error.body.error !== "schema-commit-route-required")
130215
+ throw error;
130216
+ response = await NeoApiClient.forBaseUrl(
130217
+ workspace.config.apiBaseUrl
130218
+ ).post(
130219
+ `/api/projects/${workspace.config.projectId}/versions/${workspace.config.versionId}/schema/commit`,
130220
+ body
130221
+ );
130222
+ }
130223
+ const accepted = readAcceptedProjectVersionCommitResponse(response);
130224
+ if (accepted === null) {
130225
+ if (!isObjectRecord2(response) || typeof response.kind !== "string") {
130226
+ throw new Error(
130227
+ "Project transaction response is neither accepted nor an immediate commit result."
130228
+ );
130229
+ }
130230
+ return {
130231
+ kind: response.kind === "noop" ? "noop" : "committed",
130232
+ transactionId: immediateTransactionId(response)
130233
+ };
130234
+ }
130235
+ const completed = await waitForAcceptedProjectVersionTransaction({
130236
+ workspace,
130237
+ accepted,
130238
+ reporter,
130239
+ connection
130240
+ });
130241
+ return {
130242
+ kind: completed.totalChangeCount === 0 ? "noop" : "committed",
130243
+ transactionId: completed.transactionId
130244
+ };
130245
+ } finally {
130246
+ reporter.stop();
130247
+ }
130248
+ }
130077
130249
  function readAcceptedProjectVersionCommitResponse(value) {
130078
130250
  if (!isObjectRecord2(value) || value.kind !== "accepted") return null;
130079
130251
  if (typeof value.transactionId !== "string") {
@@ -130255,9 +130427,9 @@ function readNullableString(value, field) {
130255
130427
  function isProjectVersionTransactionCommitStatus(value) {
130256
130428
  return value === "preparing" || value === "waiting" || value === "queued" || value === "applying" || value === "reverting" || value === "noop" || value === "committed" || value === "failed";
130257
130429
  }
130258
- function createPushProgressReporter(json) {
130430
+ function createPushProgressReporter(json, label = "Pushing\u2026") {
130259
130431
  const animated = process.stdout.isTTY === true && !json;
130260
- const indicator = animated ? spinner("Pushing\u2026") : null;
130432
+ const indicator = animated ? spinner(label) : null;
130261
130433
  let lastStructuredEvent = "";
130262
130434
  return {
130263
130435
  report(event) {
@@ -138393,7 +138565,7 @@ var init_registry2 = __esm({
138393
138565
  "schema-contract/registry.mjs"() {
138394
138566
  "use strict";
138395
138567
  PROJECT_SCHEMA_CONTRACT = Object.freeze({
138396
- cliVersion: "0.53.1",
138568
+ cliVersion: "0.53.2",
138397
138569
  projectFileUploadBatchSize: 32,
138398
138570
  documentRecords: {
138399
138571
  member: {
@@ -141885,8 +142057,7 @@ async function repairUnprojectedValueRows(workspace, findings, yes) {
141885
142057
  return;
141886
142058
  }
141887
142059
  const rows = plan.roots.flatMap((root) => root.rows);
141888
- const pulledHeadTransactionHash = workspace.state.headTransactionHash;
141889
- if (typeof pulledHeadTransactionHash !== "string") {
142060
+ if (typeof workspace.state.headTransactionHash !== "string") {
141890
142061
  throw new Error(
141891
142062
  'This workspace has no recorded project head, so `neo doctor --fix` cannot prove its deletions land on the state the audit read. Run "neo pull", then rerun.'
141892
142063
  );
@@ -141920,7 +142091,7 @@ async function repairUnprojectedValueRows(workspace, findings, yes) {
141920
142091
  console.log("Cancelled. No records were deleted.");
141921
142092
  return;
141922
142093
  }
141923
- const { api: api3, createConvexClient: createConvexClient2 } = await Promise.resolve().then(() => (init_convex(), convex_exports));
142094
+ const { commitProjectVersionChanges: commitProjectVersionChanges2 } = await Promise.resolve().then(() => (init_push(), push_exports));
141924
142095
  const { createProjectVersionIntent: createProjectVersionIntent2 } = await Promise.resolve().then(() => (init_project_version_intents(), project_version_intents_exports));
141925
142096
  const changes = rows.map((row) => ({
141926
142097
  recordKind: "value",
@@ -141932,95 +142103,44 @@ async function repairUnprojectedValueRows(workspace, findings, yes) {
141932
142103
  source: "neo-cli-doctor"
141933
142104
  })
141934
142105
  }));
141935
- const batchSize = immediateCommitBatchSize(changes);
141936
- const convex = await createConvexClient2(workspace);
141937
- const progress = spinner(`Deleting ${rowLabel(rows.length)}\u2026`);
141938
- let deleted = 0;
141939
- let expectedHeadTransactionHash = pulledHeadTransactionHash;
141940
- for (let index = 0; index < changes.length; index += batchSize) {
141941
- const batch = changes.slice(index, index + batchSize);
141942
- let transactionHash;
141943
- try {
141944
- const result = await convex.mutation(
141945
- api3.serverProjectRecordOperations.commitFromSession,
141946
- {
141947
- projectId: workspace.config.projectId,
141948
- versionId: workspace.config.versionId,
141949
- operation: "delete",
141950
- changes: batch,
141951
- summary: `neo doctor --fix (${rowLabel(batch.length)})`,
141952
- expectedHeadTransactionHash
141953
- }
141954
- );
141955
- transactionHash = committedTransactionHash(result);
141956
- } catch (error) {
141957
- progress.fail(
141958
- deleted === 0 ? `Failed to delete ${rowLabel(batch.length)}.` : `Failed after deleting ${rowLabel(deleted)}.`
141959
- );
141960
- throw repairFailure(error, deleted);
141961
- }
141962
- if (transactionHash === null) continue;
141963
- expectedHeadTransactionHash = transactionHash;
141964
- deleted += batch.length;
141965
- progress.update(
141966
- `Deleting ${rowLabel(rows.length)}\u2026 ${String(deleted)} done`
141967
- );
141968
- }
141969
- progress.succeed(`Deleted ${rowLabel(deleted)} across ${rootLabel}.`);
141970
- console.log('Run "neo pull" to refresh the working copy.');
141971
- }
141972
- function immediateCommitBatchSize(changes) {
141973
- let fits = 0;
141974
- let low = 1;
141975
- let high = changes.length;
141976
- while (low <= high) {
141977
- const size = Math.floor((low + high) / 2);
141978
- if (planProjectVersionTransaction(changes.slice(0, size)).path === "immediate") {
141979
- fits = size;
141980
- low = size + 1;
141981
- } else {
141982
- high = size - 1;
141983
- }
141984
- }
141985
- if (fits === 0) {
141986
- throw new Error(
141987
- "Deleting a single value row exceeds the immediate transaction budget, so `neo doctor --fix` cannot commit anything. The transaction cost model needs to change before this repair can run."
141988
- );
141989
- }
141990
- return fits;
141991
- }
141992
- function committedTransactionHash(result) {
141993
- if (!isObjectRecord2(result)) {
141994
- throw new Error(
141995
- "Doctor repair committed a deletion but the server returned no transaction envelope."
141996
- );
142106
+ let committed;
142107
+ try {
142108
+ committed = await commitProjectVersionChanges2({
142109
+ workspace,
142110
+ operation: "delete",
142111
+ changes,
142112
+ summary: `neo doctor --fix (${rowLabel(rows.length)})`,
142113
+ progressLabel: `Deleting ${rowLabel(rows.length)}\u2026`,
142114
+ json: false
142115
+ });
142116
+ } catch (error) {
142117
+ throw repairFailure(error);
141997
142118
  }
141998
- if (result.transaction === null) return null;
141999
- const transactionHash = isObjectRecord2(result.transaction) ? result.transaction.transactionHash : void 0;
142000
- if (typeof transactionHash !== "string") {
142001
- throw new Error(
142002
- "Doctor repair committed a transaction that carries no hash, so the remaining deletions have no fast-forward base."
142119
+ if (committed.kind === "noop") {
142120
+ console.log(
142121
+ `${sym.info} Nothing to delete: the ${rowLabel(rows.length)} were already gone.`
142003
142122
  );
142123
+ } else {
142124
+ success(`Deleted ${rowLabel(rows.length)} across ${rootLabel}.`);
142004
142125
  }
142005
- return transactionHash;
142126
+ console.log('Run "neo pull" to refresh the working copy.');
142006
142127
  }
142007
- function repairFailure(error, deleted) {
142008
- const applied = deleted === 0 ? "" : ` ${rowLabel(deleted)} were already deleted.`;
142009
- const code = convexErrorCode(error);
142128
+ function repairFailure(error) {
142129
+ const code = writeRefusalCode(error);
142010
142130
  if (code === "non-fast-forward" || code === "base-hash-conflict") {
142011
142131
  return new Error(
142012
- `neo doctor --fix was refused: the project moved on since this workspace pulled, so the audit is stale.${applied} Run \`neo pull\` to re-derive it, then rerun.`,
142132
+ "neo doctor --fix was refused: the project moved on since this workspace pulled, so the audit is stale. Run `neo pull` to re-derive it, then rerun.",
142013
142133
  { cause: error }
142014
142134
  );
142015
142135
  }
142016
142136
  return new Error(
142017
- `neo doctor --fix could not delete the audited rows: ${errorMessage3(error)}${applied}`,
142137
+ `neo doctor --fix could not delete the audited rows: ${errorMessage3(error)}`,
142018
142138
  { cause: error }
142019
142139
  );
142020
142140
  }
142021
- function convexErrorCode(error) {
142141
+ function writeRefusalCode(error) {
142022
142142
  if (!isObjectRecord2(error)) return null;
142023
- const data = error.data;
142143
+ const data = error instanceof NeoApiError ? error.body : error.data;
142024
142144
  if (!isObjectRecord2(data)) return null;
142025
142145
  return typeof data.error === "string" ? data.error : null;
142026
142146
  }
@@ -142035,8 +142155,8 @@ var init_doctor = __esm({
142035
142155
  init_source_diagnostics();
142036
142156
  init_project_documents();
142037
142157
  init_project_integrity();
142038
- init_project_version_transaction_planning();
142039
142158
  init_projection();
142159
+ init_http();
142040
142160
  NEO_COMPILER_CONTRACT = "ProjectSourceAnalysisV4";
142041
142161
  NEO_VSCODE_EXTENSION_ID = "neocompose.neo-compose-neoscript";
142042
142162
  NEO_VSCODE_EXTENSION_CONTRACT_VERSION = "0.3.0";
@@ -144995,16 +145115,16 @@ function dryrunOwnership(document, valueById, saveBindings = /* @__PURE__ */ new
144995
145115
  return memberById2.get(memberId)?.valueId;
144996
145116
  };
144997
145117
  const visitedPlacements = /* @__PURE__ */ new Set();
144998
- const walkOwnedGraph = (memberPath2, valueId) => {
144999
- const memberId = memberPath2.at(-1);
145118
+ const walkOwnedGraph = (memberPath3, valueId) => {
145119
+ const memberId = memberPath3.at(-1);
145000
145120
  if (memberId === void 0) return;
145001
- const visitKey = `${memberPath2.join("/")}\0${valueId}`;
145121
+ const visitKey = `${memberPath3.join("/")}\0${valueId}`;
145002
145122
  if (visitedPlacements.has(visitKey)) return;
145003
145123
  visitedPlacements.add(visitKey);
145004
145124
  const value = valueById.get(valueId);
145005
145125
  const member = memberById2.get(memberId);
145006
145126
  if (value === void 0 || member === void 0) return;
145007
- const storage = storageResolver.effectiveStorageForPath(memberPath2);
145127
+ const storage = storageResolver.effectiveStorageForPath(memberPath3);
145008
145128
  if (storage === 2 /* Save */) saveOwned.add(valueId);
145009
145129
  if (storage === 3 /* Session */) sessionOwned.add(valueId);
145010
145130
  if (member.kind === 7 /* Class */ && isObjectRecord2(value.value)) {
@@ -145016,7 +145136,7 @@ function dryrunOwnership(document, valueById, saveBindings = /* @__PURE__ */ new
145016
145136
  for (const [key, childValueId] of Object.entries(value.value)) {
145017
145137
  const childMemberId = childMemberByKey.get(key);
145018
145138
  if (childMemberId !== void 0 && typeof childValueId === "string") {
145019
- walkOwnedGraph([...memberPath2, childMemberId], childValueId);
145139
+ walkOwnedGraph([...memberPath3, childMemberId], childValueId);
145020
145140
  }
145021
145141
  }
145022
145142
  return;
@@ -145027,7 +145147,7 @@ function dryrunOwnership(document, valueById, saveBindings = /* @__PURE__ */ new
145027
145147
  if (entryMemberId === void 0) return;
145028
145148
  for (const childValueId of membership.get(valueId) ?? []) {
145029
145149
  if (typeof childValueId === "string") {
145030
- walkOwnedGraph([...memberPath2, entryMemberId], childValueId);
145150
+ walkOwnedGraph([...memberPath3, entryMemberId], childValueId);
145031
145151
  }
145032
145152
  }
145033
145153
  return;
@@ -145038,7 +145158,7 @@ function dryrunOwnership(document, valueById, saveBindings = /* @__PURE__ */ new
145038
145158
  const childIds = Array.isArray(value.value) ? value.value : Object.values(value.value);
145039
145159
  for (const childValueId of childIds) {
145040
145160
  if (typeof childValueId === "string") {
145041
- walkOwnedGraph([...memberPath2, entryMemberId], childValueId);
145161
+ walkOwnedGraph([...memberPath3, entryMemberId], childValueId);
145042
145162
  }
145043
145163
  }
145044
145164
  }
@@ -146266,7 +146386,7 @@ There is no --keep-current: preserving current semantic state defines flatten.
146266
146386
  async function main() {
146267
146387
  const args = parseArgs(process.argv.slice(2));
146268
146388
  if (args.command === "--version") {
146269
- console.log("0.53.1");
146389
+ console.log("0.53.2");
146270
146390
  return;
146271
146391
  }
146272
146392
  if (args.command === null || args.command === "help" || args.command === "--help" || args.command === "-h") {