@remnic/core 9.3.715 → 9.3.717

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.
Files changed (81) hide show
  1. package/dist/access-boundary.d.ts +2 -2
  2. package/dist/access-boundary.js +4 -3
  3. package/dist/access-cli.js +13 -12
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-http.d.ts +2 -2
  6. package/dist/access-http.js +8 -7
  7. package/dist/access-mcp.d.ts +2 -2
  8. package/dist/access-mcp.js +7 -6
  9. package/dist/access-operations-batch.js +5 -4
  10. package/dist/access-operations.d.ts +2 -2
  11. package/dist/access-operations.js +6 -5
  12. package/dist/{access-service-GgnA--CE.d.ts → access-service-d4Tk-Dlr.d.ts} +2 -2
  13. package/dist/access-service.d.ts +2 -2
  14. package/dist/access-service.js +3 -2
  15. package/dist/access-surface-catalog.d.ts +2 -2
  16. package/dist/bootstrap.d.ts +1 -1
  17. package/dist/{chunk-MECU6WSH.js → chunk-2B43BYYZ.js} +6 -6
  18. package/dist/chunk-2KF4HDG2.js +24 -0
  19. package/dist/chunk-2KF4HDG2.js.map +1 -0
  20. package/dist/{chunk-HHLWSWWF.js → chunk-BF2426TN.js} +2 -2
  21. package/dist/{chunk-RBHANGVX.js → chunk-BZAK3RBN.js} +2 -2
  22. package/dist/{chunk-YUJL27ET.js → chunk-CTUWGJRI.js} +40 -63
  23. package/dist/chunk-CTUWGJRI.js.map +1 -0
  24. package/dist/{chunk-6QUPUTT7.js → chunk-DZYARLJ7.js} +5 -9
  25. package/dist/{chunk-6QUPUTT7.js.map → chunk-DZYARLJ7.js.map} +1 -1
  26. package/dist/{chunk-CTAHKIG6.js → chunk-EM22PCQR.js} +7 -7
  27. package/dist/{chunk-SHRRWOVY.js → chunk-J6BH2OBA.js} +64 -21
  28. package/dist/chunk-J6BH2OBA.js.map +1 -0
  29. package/dist/{chunk-GM3BMWKR.js → chunk-KHQ433G5.js} +2 -2
  30. package/dist/{chunk-SYDHFFAW.js → chunk-OUDAU3T5.js} +4 -4
  31. package/dist/{chunk-OQH5XUH3.js → chunk-Q6IP2ARR.js} +2 -5
  32. package/dist/chunk-Q6IP2ARR.js.map +1 -0
  33. package/dist/{chunk-O62P2LFL.js → chunk-VZQXJNBD.js} +2 -2
  34. package/dist/{chunk-BNOAB5HH.js → chunk-YAINYEM3.js} +57 -48
  35. package/dist/chunk-YAINYEM3.js.map +1 -0
  36. package/dist/{chunk-3VUPWDSE.js → chunk-ZAVTEQFM.js} +4 -4
  37. package/dist/{chunk-IHMT6XTY.js → chunk-ZXLSNG3T.js} +3 -3
  38. package/dist/{cli-Do1YtfnH.d.ts → cli-insNLYs6.d.ts} +2 -2
  39. package/dist/cli.d.ts +3 -3
  40. package/dist/cli.js +12 -11
  41. package/dist/direct-answer-wiring.d.ts +9 -9
  42. package/dist/direct-answer-wiring.js +1 -1
  43. package/dist/explicit-capture.d.ts +1 -1
  44. package/dist/index.d.ts +4 -4
  45. package/dist/index.js +23 -22
  46. package/dist/index.js.map +1 -1
  47. package/dist/mcp-memory-inspector-app.d.ts +2 -2
  48. package/dist/operator-toolkit.js +5 -3
  49. package/dist/orchestration/maintenance.js +5 -2
  50. package/dist/{orchestrator-BOaVstFG.d.ts → orchestrator-XPKhY2OV.d.ts} +6 -7
  51. package/dist/orchestrator.d.ts +1 -1
  52. package/dist/orchestrator.js +7 -6
  53. package/dist/recall-planner-llm.d.ts +1 -1
  54. package/dist/recall-planner-llm.js +2 -2
  55. package/dist/recall-planner-llm.js.map +1 -1
  56. package/dist/schemas.d.ts +22 -22
  57. package/dist/transfer/types.d.ts +12 -12
  58. package/package.json +2 -2
  59. package/src/access-service.ts +56 -41
  60. package/src/capabilities.test.ts +28 -0
  61. package/src/direct-answer-wiring.test.ts +20 -13
  62. package/src/direct-answer-wiring.ts +9 -13
  63. package/src/maintenance/namespace-planner.ts +3 -10
  64. package/src/orchestrator.ts +42 -71
  65. package/src/recall-planner-llm.test.ts +30 -11
  66. package/src/recall-planner-llm.ts +4 -5
  67. package/src/scopes/scope-plan.test.ts +168 -1
  68. package/src/scopes/scope-plan.ts +163 -0
  69. package/dist/chunk-BNOAB5HH.js.map +0 -1
  70. package/dist/chunk-OQH5XUH3.js.map +0 -1
  71. package/dist/chunk-SHRRWOVY.js.map +0 -1
  72. package/dist/chunk-YUJL27ET.js.map +0 -1
  73. /package/dist/{chunk-MECU6WSH.js.map → chunk-2B43BYYZ.js.map} +0 -0
  74. /package/dist/{chunk-HHLWSWWF.js.map → chunk-BF2426TN.js.map} +0 -0
  75. /package/dist/{chunk-RBHANGVX.js.map → chunk-BZAK3RBN.js.map} +0 -0
  76. /package/dist/{chunk-CTAHKIG6.js.map → chunk-EM22PCQR.js.map} +0 -0
  77. /package/dist/{chunk-GM3BMWKR.js.map → chunk-KHQ433G5.js.map} +0 -0
  78. /package/dist/{chunk-SYDHFFAW.js.map → chunk-OUDAU3T5.js.map} +0 -0
  79. /package/dist/{chunk-O62P2LFL.js.map → chunk-VZQXJNBD.js.map} +0 -0
  80. /package/dist/{chunk-3VUPWDSE.js.map → chunk-ZAVTEQFM.js.map} +0 -0
  81. /package/dist/{chunk-IHMT6XTY.js.map → chunk-ZXLSNG3T.js.map} +0 -0
@@ -89,7 +89,7 @@ import {
89
89
  runOperatorInventory,
90
90
  runOperatorRepair,
91
91
  runOperatorSetup
92
- } from "./chunk-RBHANGVX.js";
92
+ } from "./chunk-BZAK3RBN.js";
93
93
  import {
94
94
  listNamespaces,
95
95
  runNamespaceMigration,
@@ -141,7 +141,7 @@ import {
141
141
  } from "./chunk-GY3SKOS4.js";
142
142
  import {
143
143
  formatNamespaceMaintenanceHealthText
144
- } from "./chunk-GM3BMWKR.js";
144
+ } from "./chunk-KHQ433G5.js";
145
145
  import {
146
146
  analyzeSessionIntegrity,
147
147
  applySessionRepair,
@@ -215,7 +215,7 @@ import {
215
215
  } from "./chunk-OADWQ5CR.js";
216
216
  import {
217
217
  EngramAccessHttpServer
218
- } from "./chunk-CTAHKIG6.js";
218
+ } from "./chunk-EM22PCQR.js";
219
219
  import {
220
220
  WearablesInputError
221
221
  } from "./chunk-7WV3F5DQ.js";
@@ -228,10 +228,10 @@ import {
228
228
  createProductionChatLlmAdapter,
229
229
  loadChatSession,
230
230
  sessionBelongsToPrincipal
231
- } from "./chunk-SYDHFFAW.js";
231
+ } from "./chunk-OUDAU3T5.js";
232
232
  import {
233
233
  EngramAccessService
234
- } from "./chunk-BNOAB5HH.js";
234
+ } from "./chunk-YAINYEM3.js";
235
235
  import {
236
236
  WorkStorage
237
237
  } from "./chunk-GDB4J2H3.js";
@@ -7496,4 +7496,4 @@ export {
7496
7496
  listMemoryMarkdownFilePaths,
7497
7497
  registerCli
7498
7498
  };
7499
- //# sourceMappingURL=chunk-MECU6WSH.js.map
7499
+ //# sourceMappingURL=chunk-2B43BYYZ.js.map
@@ -0,0 +1,24 @@
1
+ // src/procedural/reinforcement-core.ts
2
+ function clusterByKey(items, keyFn) {
3
+ const clusters = /* @__PURE__ */ new Map();
4
+ for (const item of items) {
5
+ const key = keyFn(item);
6
+ if (typeof key !== "string") {
7
+ throw new TypeError(
8
+ `clusterByKey: keyFn must return a string, got ${key === null ? "null" : typeof key}`
9
+ );
10
+ }
11
+ const existing = clusters.get(key);
12
+ if (existing) {
13
+ existing.push(item);
14
+ } else {
15
+ clusters.set(key, [item]);
16
+ }
17
+ }
18
+ return clusters;
19
+ }
20
+
21
+ export {
22
+ clusterByKey
23
+ };
24
+ //# sourceMappingURL=chunk-2KF4HDG2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/procedural/reinforcement-core.ts"],"sourcesContent":["/**\n * Generic reinforcement-core primitives extracted from `procedure-miner.ts`\n * (issue #687 PR 1/4). Procedure-specific scoring (success rate, step\n * normalization) intentionally stays in the miner — this module only\n * exposes category-agnostic clustering and cluster summarization helpers\n * so future PRs can run reinforcement across non-procedural categories.\n *\n * Pure refactor — no behavior change.\n */\n\n/**\n * Group `items` into clusters keyed by `keyFn(item)`.\n *\n * - Preserves the original input order within each cluster's array.\n * - The returned `Map` insertion order matches first-seen key order, so\n * downstream iteration is deterministic for a given input.\n * - Throws `TypeError` if `keyFn` returns a non-string (e.g. `undefined`,\n * `null`, or a number). Callers must produce a stable string key.\n */\nexport function clusterByKey<T>(items: readonly T[], keyFn: (item: T) => string): Map<string, T[]> {\n const clusters = new Map<string, T[]>();\n for (const item of items) {\n const key = keyFn(item);\n if (typeof key !== \"string\") {\n throw new TypeError(\n `clusterByKey: keyFn must return a string, got ${key === null ? \"null\" : typeof key}`,\n );\n }\n const existing = clusters.get(key);\n if (existing) {\n existing.push(item);\n } else {\n clusters.set(key, [item]);\n }\n }\n return clusters;\n}\n\nexport interface ClusterSummary {\n /** Number of items in the cluster. */\n count: number;\n /** Earliest timestamp seen in the cluster (string min via `localeCompare`). */\n firstSeen: string;\n /** Latest timestamp seen in the cluster (string max via `localeCompare`). */\n lastSeen: string;\n}\n\n/**\n * Summarize a cluster by counting items and tracking earliest/latest\n * timestamps. Timestamp comparison uses `String#localeCompare`, which is\n * correct for ISO-8601 strings (lexicographic order matches chronological\n * order).\n *\n * - Throws `RangeError` on empty clusters — `firstSeen`/`lastSeen` are not\n * meaningful without at least one item.\n * - When all timestamps are equal, `firstSeen === lastSeen`.\n */\nexport function summarizeCluster<T>(\n cluster: readonly T[],\n extractTimestamp: (item: T) => string,\n): ClusterSummary {\n if (cluster.length === 0) {\n throw new RangeError(\"summarizeCluster: cluster must contain at least one item\");\n }\n let firstSeen = extractTimestamp(cluster[0]);\n let lastSeen = firstSeen;\n for (let i = 1; i < cluster.length; i += 1) {\n const ts = extractTimestamp(cluster[i]);\n if (ts.localeCompare(firstSeen) < 0) firstSeen = ts;\n if (ts.localeCompare(lastSeen) > 0) lastSeen = ts;\n }\n return { count: cluster.length, firstSeen, lastSeen };\n}\n"],"mappings":";AAmBO,SAAS,aAAgB,OAAqB,OAA8C;AACjG,QAAM,WAAW,oBAAI,IAAiB;AACtC,aAAW,QAAQ,OAAO;AACxB,UAAM,MAAM,MAAM,IAAI;AACtB,QAAI,OAAO,QAAQ,UAAU;AAC3B,YAAM,IAAI;AAAA,QACR,iDAAiD,QAAQ,OAAO,SAAS,OAAO,GAAG;AAAA,MACrF;AAAA,IACF;AACA,UAAM,WAAW,SAAS,IAAI,GAAG;AACjC,QAAI,UAAU;AACZ,eAAS,KAAK,IAAI;AAAA,IACpB,OAAO;AACL,eAAS,IAAI,KAAK,CAAC,IAAI,CAAC;AAAA,IAC1B;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EngramAccessInputError
3
- } from "./chunk-BNOAB5HH.js";
3
+ } from "./chunk-YAINYEM3.js";
4
4
  import {
5
5
  expandTildePath
6
6
  } from "./chunk-EYIEWJNI.js";
@@ -104,4 +104,4 @@ export {
104
104
  listRegisteredOperations,
105
105
  __resetRegistryForTest
106
106
  };
107
- //# sourceMappingURL=chunk-HHLWSWWF.js.map
107
+ //# sourceMappingURL=chunk-BF2426TN.js.map
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-YBPYIAA5.js";
10
10
  import {
11
11
  summarizeNamespaceMaintenanceHealth
12
- } from "./chunk-GM3BMWKR.js";
12
+ } from "./chunk-KHQ433G5.js";
13
13
  import {
14
14
  analyzeSessionIntegrity,
15
15
  applySessionRepair,
@@ -1440,4 +1440,4 @@ export {
1440
1440
  runBenchmarkRecall,
1441
1441
  runOperatorRepair
1442
1442
  };
1443
- //# sourceMappingURL=chunk-RBHANGVX.js.map
1443
+ //# sourceMappingURL=chunk-BZAK3RBN.js.map
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-DGTDRIUO.js";
8
8
  import {
9
9
  MaintenanceScheduler
10
- } from "./chunk-O62P2LFL.js";
10
+ } from "./chunk-VZQXJNBD.js";
11
11
  import {
12
12
  migrateFromEngram
13
13
  } from "./chunk-7HYPN2GC.js";
@@ -168,7 +168,7 @@ import {
168
168
  } from "./chunk-XHYGJVXL.js";
169
169
  import {
170
170
  tryDirectAnswer
171
- } from "./chunk-OQH5XUH3.js";
171
+ } from "./chunk-Q6IP2ARR.js";
172
172
  import {
173
173
  EmbeddingFallback
174
174
  } from "./chunk-ZA2S2VLL.js";
@@ -206,11 +206,11 @@ import {
206
206
  import {
207
207
  runNamespaceMaintenanceFanout,
208
208
  summarizeNamespaceMaintenanceHealth
209
- } from "./chunk-GM3BMWKR.js";
209
+ } from "./chunk-KHQ433G5.js";
210
210
  import {
211
211
  NamespaceCatalog,
212
212
  planNamespaceMaintenance
213
- } from "./chunk-6QUPUTT7.js";
213
+ } from "./chunk-DZYARLJ7.js";
214
214
  import {
215
215
  NamespaceStorageRouter
216
216
  } from "./chunk-MPHDVHIB.js";
@@ -295,12 +295,8 @@ import {
295
295
  describeErrorForOperator
296
296
  } from "./chunk-7WV3F5DQ.js";
297
297
  import {
298
- clusterByKey,
299
- combineNamespaces,
300
- resolveCodingNamespaceOverlay,
301
- resolveScopePlan,
302
- resolveScopeProfilePlan
303
- } from "./chunk-SHRRWOVY.js";
298
+ clusterByKey
299
+ } from "./chunk-2KF4HDG2.js";
304
300
  import {
305
301
  listTrustZoneRecords,
306
302
  searchTrustZoneRecords
@@ -311,6 +307,14 @@ import {
311
307
  import {
312
308
  buildXraySnapshot
313
309
  } from "./chunk-AJOIM6UR.js";
310
+ import {
311
+ combineNamespaces,
312
+ getConfiguredNamespaces,
313
+ resolveCodingNamespaceOverlay,
314
+ resolveNamespaceFromStorageDir,
315
+ resolveScopePlan,
316
+ resolveScopeProfilePlan
317
+ } from "./chunk-J6BH2OBA.js";
314
318
  import {
315
319
  NamespaceSearchRouter
316
320
  } from "./chunk-CTOQEZSN.js";
@@ -2081,7 +2085,7 @@ function resolveRecallModeDecision(options) {
2081
2085
  }
2082
2086
  async function resolveRecallModeDecisionAsync(options) {
2083
2087
  const heuristicDecision = resolveRecallModeDecision(options);
2084
- const plannerLlmEnabled = options.caps?.recallPlannerLlm ?? options.config.recallPlannerLlmEnabled;
2088
+ const plannerLlmEnabled = options.caps.recallPlannerLlm;
2085
2089
  if (!options.plannerEnabled || !plannerLlmEnabled) {
2086
2090
  return heuristicDecision;
2087
2091
  }
@@ -2090,9 +2094,9 @@ async function resolveRecallModeDecisionAsync(options) {
2090
2094
  options.prompt,
2091
2095
  options.hints,
2092
2096
  options.config,
2097
+ options.caps,
2093
2098
  options.llm,
2094
- options.signal,
2095
- options.caps
2099
+ options.signal
2096
2100
  );
2097
2101
  if (options.config.recallPlannerShadowMode) {
2098
2102
  return {
@@ -2779,16 +2783,8 @@ var Orchestrator = class _Orchestrator {
2779
2783
  const ns = typeof namespace === "string" && namespace.trim().length > 0 ? namespace.trim() : this.config.defaultNamespace;
2780
2784
  return this.storageRouter.storageFor(ns);
2781
2785
  }
2782
- configuredNamespaces() {
2783
- return Array.from(
2784
- new Set(
2785
- [
2786
- this.config.defaultNamespace,
2787
- this.config.sharedNamespace,
2788
- ...this.config.namespacePolicies.map((policy) => policy.name)
2789
- ].map((value) => value.trim()).filter(Boolean)
2790
- )
2791
- );
2786
+ configuredNamespaceList() {
2787
+ return getConfiguredNamespaces(this.config);
2792
2788
  }
2793
2789
  rememberNamespaceStorageDirHint(namespace, storageDir) {
2794
2790
  if (!this.config.namespacesEnabled || !storageDir) return;
@@ -2880,7 +2876,7 @@ var Orchestrator = class _Orchestrator {
2880
2876
  }
2881
2877
  }
2882
2878
  const configured = new Set(
2883
- this.configuredNamespaces().map((namespace) => normalizeNamespaceIdentity(namespace))
2879
+ this.configuredNamespaceList().map((namespace) => normalizeNamespaceIdentity(namespace))
2884
2880
  );
2885
2881
  const preferredByStorageDir = /* @__PURE__ */ new Map();
2886
2882
  for (const record of compactedByNamespace.values()) {
@@ -2959,7 +2955,7 @@ var Orchestrator = class _Orchestrator {
2959
2955
  }
2960
2956
  const namespaces = this.config.namespacesEnabled ? Array.from(
2961
2957
  new Set(
2962
- (options.namespaces?.length ? options.namespaces : this.configuredNamespaces()).map((value) => value.trim()).filter(Boolean)
2958
+ (options.namespaces?.length ? options.namespaces : this.configuredNamespaceList()).map((value) => value.trim()).filter(Boolean)
2963
2959
  )
2964
2960
  ) : [this.config.defaultNamespace];
2965
2961
  if (!this.config.namespacesEnabled) {
@@ -4089,7 +4085,7 @@ ${doc.content}` : doc.content,
4089
4085
  if (options?.dryRun !== true) {
4090
4086
  try {
4091
4087
  await this.processEntitySynthesisQueue(
4092
- this.namespaceFromStorageDir(targetStorage.dir),
4088
+ this.storageDirNamespace(targetStorage.dir),
4093
4089
  5
4094
4090
  );
4095
4091
  } catch (error) {
@@ -11274,7 +11270,7 @@ ${normalized}`).digest("hex");
11274
11270
  const shouldPromoteToShared = (targetStorage, category, confidence) => {
11275
11271
  if (!this.config.namespacesEnabled || !profileAllowsSharedWrites || !sharedAutoPromotionAllows(category, confidence))
11276
11272
  return false;
11277
- if (this.namespaceFromStorageDir(targetStorage.dir) === this.config.sharedNamespace)
11273
+ if (this.storageDirNamespace(targetStorage.dir) === this.config.sharedNamespace)
11278
11274
  return false;
11279
11275
  return true;
11280
11276
  };
@@ -11714,7 +11710,7 @@ ${normalized}`).digest("hex");
11714
11710
  const biTemporal = this.config.temporalBiTemporal && sourceContext?.validAt ? resolveFactEventTime(fact.eventTime, sourceContext.validAt) : void 0;
11715
11711
  let writeCategory = fact.category;
11716
11712
  let targetStorage = storage;
11717
- let targetNamespaceName = baseNamespace && baseNamespace.length > 0 ? baseNamespace : this.namespaceFromStorageDir(targetStorage.dir);
11713
+ let targetNamespaceName = baseNamespace && baseNamespace.length > 0 ? baseNamespace : this.storageDirNamespace(targetStorage.dir);
11718
11714
  let routedRuleId;
11719
11715
  let routedNamespaceExplicit = false;
11720
11716
  if (routeRules.length > 0) {
@@ -11741,7 +11737,7 @@ ${normalized}`).digest("hex");
11741
11737
  }
11742
11738
  }
11743
11739
  if (this.config.extractionScopeClassificationEnabled && this.config.namespacesEnabled && fact.scope === "global" && !routedNamespaceExplicit) {
11744
- const currentNs = this.namespaceFromStorageDir(targetStorage.dir);
11740
+ const currentNs = this.storageDirNamespace(targetStorage.dir);
11745
11741
  if (currentNs !== this.config.sharedNamespace && profileAllowsSharedWrites) {
11746
11742
  try {
11747
11743
  targetStorage = await this.storageRouter.storageFor(
@@ -11889,7 +11885,7 @@ ${normalized}`).digest("hex");
11889
11885
  let links = [];
11890
11886
  let contradictionDetected = false;
11891
11887
  if (this.config.contradictionDetectionEnabled && this.qmd.isAvailable() && faithfulnessEnforceStatus !== "pending_review") {
11892
- const targetNamespace = this.namespaceFromStorageDir(targetStorage.dir);
11888
+ const targetNamespace = this.storageDirNamespace(targetStorage.dir);
11893
11889
  const contradiction = await this.checkForContradiction(
11894
11890
  fact.content,
11895
11891
  writeCategory,
@@ -12154,7 +12150,7 @@ ${normalized}`).digest("hex");
12154
12150
  memoryId: parentId,
12155
12151
  category: writeCategory,
12156
12152
  content: fact.content,
12157
- namespace: this.namespaceFromStorageDir(targetStorage.dir),
12153
+ namespace: this.storageDirNamespace(targetStorage.dir),
12158
12154
  confidence: fact.confidence,
12159
12155
  source: "extraction"
12160
12156
  })
@@ -12163,7 +12159,7 @@ ${normalized}`).digest("hex");
12163
12159
  }
12164
12160
  }
12165
12161
  if (this.config.memoryLinkingEnabled && this.qmd.isAvailable()) {
12166
- const targetNamespace = this.namespaceFromStorageDir(targetStorage.dir);
12162
+ const targetNamespace = this.storageDirNamespace(targetStorage.dir);
12167
12163
  const suggestedLinks = await this.suggestLinksForMemory(
12168
12164
  fact.content,
12169
12165
  writeCategory,
@@ -12232,7 +12228,7 @@ ${normalized}`).digest("hex");
12232
12228
  memoryId,
12233
12229
  category: writeCategory,
12234
12230
  content: fact.content,
12235
- namespace: this.namespaceFromStorageDir(targetStorage.dir),
12231
+ namespace: this.storageDirNamespace(targetStorage.dir),
12236
12232
  confidence: fact.confidence,
12237
12233
  source: "extraction"
12238
12234
  })
@@ -12330,7 +12326,7 @@ ${normalized}`).digest("hex");
12330
12326
  let durableNonFactWritten = false;
12331
12327
  let durableNonFactTouchRecorded = false;
12332
12328
  const touchBaseNonFactNamespace = () => {
12333
- const baseTouchNamespace = baseNamespace && baseNamespace.length > 0 ? baseNamespace : this.namespaceFromStorageDir(storage.dir);
12329
+ const baseTouchNamespace = baseNamespace && baseNamespace.length > 0 ? baseNamespace : this.storageDirNamespace(storage.dir);
12334
12330
  };
12335
12331
  const recordDurableNonFactWrite = () => {
12336
12332
  durableNonFactWritten = true;
@@ -13905,7 +13901,7 @@ ${lines.join("\n\n")}`;
13905
13901
  seenStorageDirs.add(storageKey);
13906
13902
  storages.push(storage);
13907
13903
  };
13908
- const fallbackNamespace = fallbackStorageDir !== null ? this.namespaceFromStorageDir(fallbackStorageDir) : this.config.defaultNamespace;
13904
+ const fallbackNamespace = fallbackStorageDir !== null ? this.storageDirNamespace(fallbackStorageDir) : this.config.defaultNamespace;
13909
13905
  if (recallNamespaces.length === 0 || !this.config.namespacesEnabled || recallNamespaces.includes(fallbackNamespace)) {
13910
13906
  addStorage(fallbackStorage);
13911
13907
  }
@@ -14052,7 +14048,7 @@ ${lines.join("\n\n")}`;
14052
14048
  seenDirs.add(candidateRoot);
14053
14049
  matches.push({ storage, dir: candidateRoot, namespace });
14054
14050
  };
14055
- const fallbackNamespace = fallbackStorageDir !== null ? this.namespaceFromStorageDir(fallbackStorageDir) : this.config.defaultNamespace;
14051
+ const fallbackNamespace = fallbackStorageDir !== null ? this.storageDirNamespace(fallbackStorageDir) : this.config.defaultNamespace;
14056
14052
  maybeAddStorage(fallbackStorage, fallbackNamespace);
14057
14053
  const candidateNamespaces = /* @__PURE__ */ new Set();
14058
14054
  candidateNamespaces.add(this.config.defaultNamespace);
@@ -15324,32 +15320,13 @@ ${lines.join("\n\n")}`;
15324
15320
  if (!m?.[1]) return this.config.defaultNamespace;
15325
15321
  return namespaceIdentityFromToken(m[1]) ?? m[1];
15326
15322
  }
15327
- namespaceFromStorageDir(storageDir) {
15328
- if (!this.config.namespacesEnabled) return this.config.defaultNamespace;
15329
- const resolvedStorageDir = path2.resolve(storageDir);
15330
- const resolvedMemoryDir = path2.resolve(this.config.memoryDir);
15331
- if (resolvedStorageDir === resolvedMemoryDir)
15332
- return this.config.defaultNamespace;
15333
- const m = resolvedStorageDir.match(/[\\/]namespaces[\\/]([^\\/]+)$/);
15334
- if (!m?.[1]) return this.config.defaultNamespace;
15335
- const dirName = m[1];
15336
- if (this.configuredNamespaces().includes(dirName)) {
15337
- return dirName;
15338
- }
15339
- this.loadNamespaceStorageDirHintsFromCatalog();
15340
- const hintedNamespaces = this.namespaceStorageDirHints.get(resolvedStorageDir);
15341
- if (hintedNamespaces?.has(dirName)) {
15342
- return dirName;
15343
- }
15344
- if (hintedNamespaces?.size === 1) {
15345
- const [hintedNamespace] = hintedNamespaces;
15346
- if (hintedNamespace) return hintedNamespace;
15347
- }
15348
- const decoded = namespaceIdentityFromToken(dirName);
15349
- if (decoded && namespaceIdentityToken(decoded) === dirName) {
15350
- return decoded;
15351
- }
15352
- return dirName;
15323
+ storageDirNamespace(storageDir) {
15324
+ return resolveNamespaceFromStorageDir(storageDir, {
15325
+ config: this.config,
15326
+ configuredNamespaces: this.configuredNamespaceList(),
15327
+ hints: this.namespaceStorageDirHints,
15328
+ loadHints: () => this.loadNamespaceStorageDirHintsFromCatalog()
15329
+ });
15353
15330
  }
15354
15331
  // #1522: catalog touch methods removed — touches now happen at the storage chokepoint.
15355
15332
  /**
@@ -15437,4 +15414,4 @@ export {
15437
15414
  resolvePersistedMemoryRelativePath,
15438
15415
  Orchestrator
15439
15416
  };
15440
- //# sourceMappingURL=chunk-YUJL27ET.js.map
15417
+ //# sourceMappingURL=chunk-CTUWGJRI.js.map