@remnic/core 9.3.629 → 9.3.630

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 (211) hide show
  1. package/dist/access-cli.js +13 -13
  2. package/dist/access-http.d.ts +5 -4
  3. package/dist/access-http.js +6 -6
  4. package/dist/access-mcp.d.ts +5 -4
  5. package/dist/access-mcp.js +5 -5
  6. package/dist/{access-service-BdThkfIE.d.ts → access-service-C4v-eFjB.d.ts} +2 -2
  7. package/dist/access-service.d.ts +5 -4
  8. package/dist/access-service.js +4 -4
  9. package/dist/action-confidence.d.ts +1 -1
  10. package/dist/active-memory-bridge.d.ts +1 -1
  11. package/dist/active-recall.d.ts +1 -1
  12. package/dist/active-recall.js +1 -1
  13. package/dist/behavior-learner.d.ts +1 -1
  14. package/dist/behavior-signals.d.ts +1 -1
  15. package/dist/bootstrap.d.ts +4 -3
  16. package/dist/briefing.d.ts +1 -1
  17. package/dist/briefing.js +2 -2
  18. package/dist/buffer-surprise-report.d.ts +1 -1
  19. package/dist/buffer.d.ts +1 -1
  20. package/dist/calibration.d.ts +1 -1
  21. package/dist/causal-behavior.d.ts +1 -1
  22. package/dist/causal-consolidation.d.ts +1 -1
  23. package/dist/causal-consolidation.js +3 -3
  24. package/dist/{chunk-GE7Q7KXP.js → chunk-2VJ7AJFX.js} +2 -2
  25. package/dist/{chunk-KVFYTRMV.js → chunk-4QEUKASL.js} +2 -2
  26. package/dist/{chunk-KB4MFBF5.js → chunk-5S6IREG3.js} +3 -3
  27. package/dist/{chunk-LQYTQCXM.js → chunk-6LBQL5US.js} +2 -2
  28. package/dist/{chunk-TZDSNIRO.js → chunk-ADOD7PJC.js} +5 -5
  29. package/dist/{chunk-54KDA6UK.js → chunk-BL33LBTN.js} +3 -3
  30. package/dist/{chunk-532VCWYW.js → chunk-BWK5EEKS.js} +2 -2
  31. package/dist/{chunk-KKTXCFD7.js → chunk-EORL2IDM.js} +39 -8
  32. package/dist/{chunk-KKTXCFD7.js.map → chunk-EORL2IDM.js.map} +1 -1
  33. package/dist/{chunk-JXHMAQYT.js → chunk-F6USGHMO.js} +4 -4
  34. package/dist/{chunk-NKCW223V.js → chunk-GXWFZYSR.js} +2 -2
  35. package/dist/{chunk-XXO5TI3B.js → chunk-K3BTOW7N.js} +3 -3
  36. package/dist/{chunk-N5RGXWLQ.js → chunk-MQ24KOOR.js} +2 -2
  37. package/dist/{chunk-3MNBW7R7.js → chunk-NRQJBK36.js} +2 -2
  38. package/dist/{chunk-3R2UZV3U.js → chunk-OOFBE62K.js} +2 -2
  39. package/dist/{chunk-MVQN73GT.js → chunk-OQMR2SDZ.js} +2 -2
  40. package/dist/{chunk-UGHUNQ74.js → chunk-RSKUUEBA.js} +73 -1
  41. package/dist/chunk-RSKUUEBA.js.map +1 -0
  42. package/dist/{chunk-QDV6VAD4.js → chunk-S5W37FPX.js} +2 -2
  43. package/dist/{chunk-57QXN2CS.js → chunk-SACS6KE6.js} +2 -2
  44. package/dist/{chunk-JKCDQBDW.js → chunk-UE57H4MA.js} +2 -2
  45. package/dist/{chunk-OLNNOHBC.js → chunk-VUTPRX7K.js} +20 -14
  46. package/dist/{chunk-OLNNOHBC.js.map → chunk-VUTPRX7K.js.map} +1 -1
  47. package/dist/{chunk-3GLCUPXP.js → chunk-YJOWWRRS.js} +429 -45
  48. package/dist/chunk-YJOWWRRS.js.map +1 -0
  49. package/dist/{chunk-P2D2MM47.js → chunk-ZZSXUZF3.js} +2 -2
  50. package/dist/{cli-DAsHklrf.d.ts → cli-B_6EMiQc.d.ts} +3 -3
  51. package/dist/cli.d.ts +6 -5
  52. package/dist/cli.js +17 -17
  53. package/dist/compounding/engine.d.ts +1 -1
  54. package/dist/compounding/engine.js +2 -2
  55. package/dist/compounding/preference-consolidator.d.ts +1 -1
  56. package/dist/compression-optimizer.d.ts +1 -1
  57. package/dist/config.d.ts +1 -1
  58. package/dist/config.js +1 -1
  59. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  60. package/dist/connectors/codex-materialize-runner.js +2 -2
  61. package/dist/connectors/codex-materialize.d.ts +1 -1
  62. package/dist/connectors/index.d.ts +1 -1
  63. package/dist/connectors/index.js +2 -2
  64. package/dist/consolidation-provenance-check.d.ts +1 -1
  65. package/dist/consolidation-undo.d.ts +1 -1
  66. package/dist/contradiction/index.d.ts +1 -1
  67. package/dist/conversation-index/backend.d.ts +1 -1
  68. package/dist/conversation-index/chunker.d.ts +1 -1
  69. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  70. package/dist/conversation-index/indexer.d.ts +1 -1
  71. package/dist/conversation-index/search.d.ts +1 -1
  72. package/dist/day-summary.d.ts +1 -1
  73. package/dist/delinearize.d.ts +1 -1
  74. package/dist/direct-answer-wiring.d.ts +1 -1
  75. package/dist/direct-answer.d.ts +1 -1
  76. package/dist/embedding-fallback.d.ts +1 -1
  77. package/dist/enrichment/index.d.ts +1 -1
  78. package/dist/entity-retrieval.d.ts +1 -1
  79. package/dist/entity-retrieval.js +2 -2
  80. package/dist/entity-schema.d.ts +1 -1
  81. package/dist/explicit-capture.d.ts +4 -3
  82. package/dist/extraction-judge-telemetry.d.ts +1 -1
  83. package/dist/extraction-judge-training.d.ts +1 -1
  84. package/dist/extraction-judge.d.ts +1 -1
  85. package/dist/extraction.d.ts +1 -1
  86. package/dist/fallback-llm.d.ts +1 -1
  87. package/dist/identity-continuity.d.ts +1 -1
  88. package/dist/importance.d.ts +1 -1
  89. package/dist/index.d.ts +8 -8
  90. package/dist/index.js +22 -22
  91. package/dist/intent.d.ts +1 -1
  92. package/dist/lcm/engine.d.ts +1 -1
  93. package/dist/lcm/index.d.ts +1 -1
  94. package/dist/lcm/tools.d.ts +1 -1
  95. package/dist/lifecycle.d.ts +1 -1
  96. package/dist/live-connectors-runner.d.ts +1 -1
  97. package/dist/local-llm.d.ts +1 -1
  98. package/dist/maintenance/memory-governance.d.ts +1 -1
  99. package/dist/maintenance/memory-governance.js +2 -2
  100. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +2 -2
  101. package/dist/maintenance/rebuild-memory-projection.js +3 -3
  102. package/dist/mcp-memory-inspector-app.d.ts +5 -4
  103. package/dist/memory-action-policy.d.ts +1 -1
  104. package/dist/memory-cache.d.ts +1 -1
  105. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  106. package/dist/memory-projection-store.d.ts +1 -1
  107. package/dist/memory-provenance.d.ts +1 -1
  108. package/dist/memory-worth-outcomes.d.ts +1 -1
  109. package/dist/models-json.d.ts +1 -1
  110. package/dist/namespaces/migrate.d.ts +1 -1
  111. package/dist/namespaces/migrate.js +3 -3
  112. package/dist/namespaces/principal.d.ts +1 -1
  113. package/dist/namespaces/search.d.ts +1 -1
  114. package/dist/namespaces/storage.d.ts +1 -1
  115. package/dist/namespaces/storage.js +2 -2
  116. package/dist/native-knowledge.d.ts +1 -1
  117. package/dist/operator-toolkit.d.ts +1 -1
  118. package/dist/operator-toolkit.js +6 -6
  119. package/dist/{orchestrator-BexeSJ2j.d.ts → orchestrator-Dlw3ae4B.d.ts} +101 -10
  120. package/dist/orchestrator.d.ts +4 -3
  121. package/dist/orchestrator.js +10 -10
  122. package/dist/patterns-cli.d.ts +1 -1
  123. package/dist/policy-runtime.d.ts +1 -1
  124. package/dist/qmd-recall-cache.d.ts +1 -1
  125. package/dist/qmd.d.ts +1 -1
  126. package/dist/recall-disclosure-escalation.d.ts +1 -1
  127. package/dist/recall-explain-renderer.d.ts +1 -1
  128. package/dist/recall-planner-llm.d.ts +1 -1
  129. package/dist/recall-state.d.ts +1 -1
  130. package/dist/recall-tag-filter.d.ts +1 -1
  131. package/dist/recall-xray-cli.d.ts +1 -1
  132. package/dist/recall-xray-renderer.d.ts +1 -1
  133. package/dist/recall-xray.d.ts +1 -1
  134. package/dist/resolve-auth-token.d.ts +1 -1
  135. package/dist/resume-bundles.js +2 -2
  136. package/dist/retrieval-agents.d.ts +1 -1
  137. package/dist/retrieval-tiers.d.ts +1 -1
  138. package/dist/routing/engine.d.ts +1 -1
  139. package/dist/routing/store.d.ts +1 -1
  140. package/dist/schemas.d.ts +22 -22
  141. package/dist/search/embed-helper.d.ts +1 -1
  142. package/dist/search/factory.d.ts +1 -1
  143. package/dist/search/index.d.ts +1 -1
  144. package/dist/search/lancedb-backend.d.ts +1 -1
  145. package/dist/search/meilisearch-backend.d.ts +1 -1
  146. package/dist/search/noop-backend.d.ts +1 -1
  147. package/dist/search/orama-backend.d.ts +1 -1
  148. package/dist/search/port.d.ts +1 -1
  149. package/dist/search/remote-backend.d.ts +1 -1
  150. package/dist/{semantic-consolidation-PwkzNfdK.d.ts → semantic-consolidation-C4sefXEI.d.ts} +1 -1
  151. package/dist/semantic-consolidation.d.ts +2 -2
  152. package/dist/semantic-consolidation.js +3 -3
  153. package/dist/semantic-rule-promotion.js +2 -2
  154. package/dist/semantic-rule-verifier.d.ts +1 -1
  155. package/dist/semantic-rule-verifier.js +2 -2
  156. package/dist/session-observer-bands.d.ts +1 -1
  157. package/dist/session-observer-state.d.ts +1 -1
  158. package/dist/shared-context/manager.d.ts +1 -1
  159. package/dist/signal.d.ts +1 -1
  160. package/dist/storage.d.ts +38 -2
  161. package/dist/storage.js +5 -3
  162. package/dist/summarizer.d.ts +1 -1
  163. package/dist/summary-snapshot.d.ts +1 -1
  164. package/dist/temporal-supersession.d.ts +1 -1
  165. package/dist/temporal-validity.d.ts +1 -1
  166. package/dist/threading.d.ts +1 -1
  167. package/dist/tier-migration.d.ts +1 -1
  168. package/dist/tier-routing.d.ts +1 -1
  169. package/dist/topics.d.ts +1 -1
  170. package/dist/transcript.d.ts +1 -1
  171. package/dist/transfer/types.d.ts +12 -12
  172. package/dist/{types-BCF2wqKa.d.ts → types-2vqxmO0j.d.ts} +39 -10
  173. package/dist/types.d.ts +1 -1
  174. package/dist/utility-runtime.d.ts +1 -1
  175. package/dist/verified-recall.js +2 -2
  176. package/package.json +1 -1
  177. package/src/orchestrator.ts +16 -0
  178. package/src/storage.ts +100 -0
  179. package/src/wearables/cli.ts +6 -0
  180. package/src/wearables/config.test.ts +33 -4
  181. package/src/wearables/config.ts +39 -7
  182. package/src/wearables/memory-gen.test.ts +416 -1
  183. package/src/wearables/memory-gen.ts +381 -23
  184. package/src/wearables/pipeline.test.ts +309 -1
  185. package/src/wearables/pipeline.ts +131 -9
  186. package/src/wearables/service.test.ts +172 -0
  187. package/src/wearables/service.ts +84 -3
  188. package/src/wearables/storage-io.test.ts +81 -0
  189. package/src/wearables/trust.test.ts +123 -0
  190. package/src/wearables/trust.ts +168 -0
  191. package/src/wearables/types.ts +37 -8
  192. package/dist/chunk-3GLCUPXP.js.map +0 -1
  193. package/dist/chunk-UGHUNQ74.js.map +0 -1
  194. /package/dist/{chunk-GE7Q7KXP.js.map → chunk-2VJ7AJFX.js.map} +0 -0
  195. /package/dist/{chunk-KVFYTRMV.js.map → chunk-4QEUKASL.js.map} +0 -0
  196. /package/dist/{chunk-KB4MFBF5.js.map → chunk-5S6IREG3.js.map} +0 -0
  197. /package/dist/{chunk-LQYTQCXM.js.map → chunk-6LBQL5US.js.map} +0 -0
  198. /package/dist/{chunk-TZDSNIRO.js.map → chunk-ADOD7PJC.js.map} +0 -0
  199. /package/dist/{chunk-54KDA6UK.js.map → chunk-BL33LBTN.js.map} +0 -0
  200. /package/dist/{chunk-532VCWYW.js.map → chunk-BWK5EEKS.js.map} +0 -0
  201. /package/dist/{chunk-JXHMAQYT.js.map → chunk-F6USGHMO.js.map} +0 -0
  202. /package/dist/{chunk-NKCW223V.js.map → chunk-GXWFZYSR.js.map} +0 -0
  203. /package/dist/{chunk-XXO5TI3B.js.map → chunk-K3BTOW7N.js.map} +0 -0
  204. /package/dist/{chunk-N5RGXWLQ.js.map → chunk-MQ24KOOR.js.map} +0 -0
  205. /package/dist/{chunk-3MNBW7R7.js.map → chunk-NRQJBK36.js.map} +0 -0
  206. /package/dist/{chunk-3R2UZV3U.js.map → chunk-OOFBE62K.js.map} +0 -0
  207. /package/dist/{chunk-MVQN73GT.js.map → chunk-OQMR2SDZ.js.map} +0 -0
  208. /package/dist/{chunk-QDV6VAD4.js.map → chunk-S5W37FPX.js.map} +0 -0
  209. /package/dist/{chunk-57QXN2CS.js.map → chunk-SACS6KE6.js.map} +0 -0
  210. /package/dist/{chunk-JKCDQBDW.js.map → chunk-UE57H4MA.js.map} +0 -0
  211. /package/dist/{chunk-P2D2MM47.js.map → chunk-ZZSXUZF3.js.map} +0 -0
@@ -22,7 +22,7 @@ import {
22
22
  import {
23
23
  CompoundingEngine,
24
24
  defaultTierMigrationCycleBudget
25
- } from "./chunk-JKCDQBDW.js";
25
+ } from "./chunk-UE57H4MA.js";
26
26
  import {
27
27
  SharedContextManager
28
28
  } from "./chunk-DRD2Q7HQ.js";
@@ -168,7 +168,7 @@ import {
168
168
  buildEntityRecallSection,
169
169
  entityRecentTranscriptLookbackHours,
170
170
  readRecentEntityTranscriptEntries
171
- } from "./chunk-LQYTQCXM.js";
171
+ } from "./chunk-6LBQL5US.js";
172
172
  import {
173
173
  buildEventOrderRecallSection,
174
174
  shouldRecallEventOrderEvidence
@@ -203,7 +203,7 @@ import {
203
203
  materializeAfterSemanticConsolidation,
204
204
  parseConsolidationResponse,
205
205
  parseOperatorAwareConsolidationResponse
206
- } from "./chunk-3R2UZV3U.js";
206
+ } from "./chunk-OOFBE62K.js";
207
207
  import {
208
208
  normalizeReplaySessionKey
209
209
  } from "./chunk-2PRQG7PV.js";
@@ -212,13 +212,13 @@ import {
212
212
  } from "./chunk-X6IRLNOO.js";
213
213
  import {
214
214
  searchVerifiedEpisodes
215
- } from "./chunk-P2D2MM47.js";
215
+ } from "./chunk-ZZSXUZF3.js";
216
216
  import {
217
217
  ThreadingManager
218
218
  } from "./chunk-W4RVMTHR.js";
219
219
  import {
220
220
  searchVerifiedSemanticRules
221
- } from "./chunk-57QXN2CS.js";
221
+ } from "./chunk-SACS6KE6.js";
222
222
  import {
223
223
  searchWorkProductLedgerEntries
224
224
  } from "./chunk-ZRWB5D4H.js";
@@ -237,7 +237,7 @@ import {
237
237
  } from "./chunk-CYEPCZN5.js";
238
238
  import {
239
239
  NamespaceStorageRouter
240
- } from "./chunk-QDV6VAD4.js";
240
+ } from "./chunk-S5W37FPX.js";
241
241
  import {
242
242
  namespaceIdentityFromToken
243
243
  } from "./chunk-ZFXCQPNO.js";
@@ -351,7 +351,7 @@ import {
351
351
  } from "./chunk-XL7FK7PJ.js";
352
352
  import {
353
353
  buildChainFollowupGenerator
354
- } from "./chunk-NKCW223V.js";
354
+ } from "./chunk-GXWFZYSR.js";
355
355
  import {
356
356
  ContentHashIndex,
357
357
  StorageManager,
@@ -369,8 +369,9 @@ import {
369
369
  resolveSpeaker,
370
370
  saveSpeakerRegistry,
371
371
  serializeDayTranscript,
372
- speakerRegistryKey
373
- } from "./chunk-UGHUNQ74.js";
372
+ speakerRegistryKey,
373
+ stripAttributesSuffix
374
+ } from "./chunk-RSKUUEBA.js";
374
375
  import {
375
376
  attachCitation,
376
377
  hasCitationForTemplate,
@@ -380,6 +381,7 @@ import {
380
381
  confidenceTier
381
382
  } from "./chunk-FPNQF475.js";
382
383
  import {
384
+ inferMemoryStatus,
383
385
  isActiveMemoryStatus
384
386
  } from "./chunk-RULE4VG5.js";
385
387
  import {
@@ -408,6 +410,10 @@ import {
408
410
  decideLifecycleTransition,
409
411
  resolveLifecycleState
410
412
  } from "./chunk-TBBDFYXW.js";
413
+ import {
414
+ countRecallTokenOverlap,
415
+ normalizeRecallTokens
416
+ } from "./chunk-ZBJMUXZH.js";
411
417
  import {
412
418
  log
413
419
  } from "./chunk-2ODBA7MQ.js";
@@ -965,9 +971,75 @@ function getTaxonomyFilePath(memoryDir) {
965
971
  return path.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
966
972
  }
967
973
 
974
+ // src/wearables/trust.ts
975
+ var TRUST_JUDGE_ACCEPT_BOOST = 0.15;
976
+ var TRUST_CROSS_SOURCE_BOOST = 0.15;
977
+ var TRUST_SUPPORTING_MEMORY_BOOST = 0.1;
978
+ var MIN_FACT_TOKENS = 4;
979
+ var CROSS_SOURCE_COVERAGE = 0.6;
980
+ var MEMORY_SUPPORT_COVERAGE = 0.7;
981
+ var MAX_MEMORIES_SCANNED = 5e3;
982
+ function computeTrustScore(input) {
983
+ const confidence = typeof input.extractionConfidence === "number" && Number.isFinite(input.extractionConfidence) ? Math.min(1, Math.max(0, input.extractionConfidence)) : 0.7;
984
+ let trust = confidence * Math.min(1, Math.max(0, input.sourceTrust));
985
+ if (input.judgeVerdict === "accept") trust += TRUST_JUDGE_ACCEPT_BOOST;
986
+ if (input.evidence.corroboratedBySources.length > 0) {
987
+ trust += TRUST_CROSS_SOURCE_BOOST;
988
+ }
989
+ if (input.evidence.supportingMemoryId !== void 0) {
990
+ trust += TRUST_SUPPORTING_MEMORY_BOOST;
991
+ }
992
+ return Math.min(1, Math.max(0, trust));
993
+ }
994
+ function tokenizeDayBody(body) {
995
+ return new Set(normalizeRecallTokens(body));
996
+ }
997
+ function findCorroboration(factText, context) {
998
+ const factTokens = normalizeRecallTokens(factText);
999
+ const evidence = { corroboratedBySources: [] };
1000
+ if (factTokens.length < MIN_FACT_TOKENS) return evidence;
1001
+ const factTokenSet = new Set(factTokens);
1002
+ for (const [sourceId, dayTokens] of context.otherSourceDayTokens) {
1003
+ let matches = 0;
1004
+ for (const token of factTokenSet) {
1005
+ if (dayTokens.has(token)) matches += 1;
1006
+ }
1007
+ if (matches / factTokenSet.size >= CROSS_SOURCE_COVERAGE) {
1008
+ evidence.corroboratedBySources.push(sourceId);
1009
+ }
1010
+ }
1011
+ evidence.corroboratedBySources.sort();
1012
+ let scanned = 0;
1013
+ for (const memory of context.existingMemories) {
1014
+ if (scanned >= MAX_MEMORIES_SCANNED) break;
1015
+ scanned += 1;
1016
+ const matches = countRecallTokenOverlap(factTokenSet, memory.content);
1017
+ if (matches / factTokenSet.size >= MEMORY_SUPPORT_COVERAGE) {
1018
+ evidence.supportingMemoryId = memory.id;
1019
+ break;
1020
+ }
1021
+ }
1022
+ return evidence;
1023
+ }
1024
+ function decideSmart(trust, judgeVerdict, thresholds) {
1025
+ if (judgeVerdict === "reject") {
1026
+ return { outcome: "drop", reason: "judge-rejected", trust };
1027
+ }
1028
+ if (judgeVerdict === "defer") {
1029
+ return { outcome: "review", reason: "judge-deferred", trust };
1030
+ }
1031
+ if (trust >= thresholds.autoApproveTrust) {
1032
+ return { outcome: "active", reason: "auto-approved", trust };
1033
+ }
1034
+ if (trust >= thresholds.reviewTrust) {
1035
+ return { outcome: "review", reason: "queued-for-review", trust };
1036
+ }
1037
+ return { outcome: "drop", reason: "below-trust", trust };
1038
+ }
1039
+
968
1040
  // src/wearables/memory-gen.ts
969
1041
  function memoryStatusForMode(mode) {
970
- return mode === "auto" ? "active" : "pending_review";
1042
+ return mode === "auto" || mode === "smart" ? "active" : "pending_review";
971
1043
  }
972
1044
  var WEARABLE_SOURCE_PREFIX = "wearable";
973
1045
  function wearableSourceLabel(sourceId) {
@@ -1025,12 +1097,56 @@ ${chunkLines.join("\n")}`,
1025
1097
  flush();
1026
1098
  return turns;
1027
1099
  }
1100
+ async function scoreCandidates(novel, settings, deps, result) {
1101
+ const scored = /* @__PURE__ */ new Map();
1102
+ if (novel.length === 0) return scored;
1103
+ let verdicts;
1104
+ if (deps.judgeFacts) {
1105
+ const judgeCandidates = novel.map((candidate) => ({
1106
+ text: candidate.fact.content,
1107
+ category: candidate.fact.category,
1108
+ confidence: typeof candidate.fact.confidence === "number" ? candidate.fact.confidence : 0.7,
1109
+ tags: candidate.fact.tags ?? [],
1110
+ importanceLevel: candidate.importance.level
1111
+ }));
1112
+ try {
1113
+ const judgeResult = await deps.judgeFacts(judgeCandidates);
1114
+ verdicts = /* @__PURE__ */ new Map();
1115
+ for (const [index, verdict] of judgeResult.verdicts) {
1116
+ verdicts.set(index, getVerdictKind(verdict));
1117
+ }
1118
+ } catch (err) {
1119
+ result.warnings.push(
1120
+ `extraction judge unavailable for this pass: ${describeErrorForOperator(err)} \u2014 trust scoring continued without judge verdicts`
1121
+ );
1122
+ }
1123
+ }
1124
+ const corroboration = deps.corroboration ?? {
1125
+ otherSourceDayTokens: /* @__PURE__ */ new Map(),
1126
+ existingMemories: []
1127
+ };
1128
+ novel.forEach((candidate, index) => {
1129
+ const evidence = findCorroboration(candidate.fact.content, corroboration);
1130
+ const verdict = verdicts?.get(index);
1131
+ const trust = computeTrustScore({
1132
+ extractionConfidence: candidate.fact.confidence,
1133
+ sourceTrust: settings.sourceTrust,
1134
+ judgeVerdict: verdict,
1135
+ evidence
1136
+ });
1137
+ scored.set(index, { trust, ...verdict !== void 0 ? { verdict } : {}, evidence });
1138
+ });
1139
+ return scored;
1140
+ }
1028
1141
  async function generateWearableMemories(sourceId, date, conversations, settings, registry, deps) {
1029
1142
  const result = {
1030
1143
  created: 0,
1144
+ promoted: 0,
1145
+ demoted: 0,
1031
1146
  skipped: 0,
1032
1147
  skippedByReason: {},
1033
- warnings: []
1148
+ warnings: [],
1149
+ completed: true
1034
1150
  };
1035
1151
  if (settings.memoryMode === "off") return result;
1036
1152
  const skip = (reason, count = 1) => {
@@ -1049,6 +1165,7 @@ async function generateWearableMemories(sourceId, date, conversations, settings,
1049
1165
  result.warnings.push(
1050
1166
  `extraction failed for ${sourceId}/${date} (conversation ${conversation.id}): ${describeErrorForOperator(err)} \u2014 the memory pass for this day retries on the next sync`
1051
1167
  );
1168
+ result.completed = false;
1052
1169
  break;
1053
1170
  }
1054
1171
  for (const fact of extraction.facts) {
@@ -1061,7 +1178,7 @@ async function generateWearableMemories(sourceId, date, conversations, settings,
1061
1178
  skip("unsupported-category");
1062
1179
  continue;
1063
1180
  }
1064
- if (typeof fact.confidence === "number" && fact.confidence < settings.minConfidence) {
1181
+ if (settings.memoryMode !== "smart" && typeof fact.confidence === "number" && fact.confidence < settings.minConfidence) {
1065
1182
  skip("below-confidence");
1066
1183
  continue;
1067
1184
  }
@@ -1080,27 +1197,120 @@ async function generateWearableMemories(sourceId, date, conversations, settings,
1080
1197
  }
1081
1198
  }
1082
1199
  const novel = [];
1200
+ const promotable = [];
1083
1201
  for (const candidate of candidates) {
1084
1202
  if (await deps.writer.hasFactContentHash(candidate.fact.content)) {
1085
- skip("duplicate-existing");
1203
+ if (settings.memoryMode === "smart" && deps.writer.findWearableMemoryByContent !== void 0 && deps.writer.promoteWearableMemory !== void 0) {
1204
+ promotable.push(candidate);
1205
+ } else {
1206
+ skip("duplicate-existing");
1207
+ }
1086
1208
  continue;
1087
1209
  }
1088
1210
  novel.push(candidate);
1089
1211
  }
1090
- novel.sort((a, b) => {
1091
- if (a.importance.score > b.importance.score) return -1;
1092
- if (a.importance.score < b.importance.score) return 1;
1093
- if (a.fact.content < b.fact.content) return -1;
1094
- if (a.fact.content > b.fact.content) return 1;
1212
+ if (promotable.length > 0) {
1213
+ const promoteScores = await scoreCandidates(promotable, settings, deps, result);
1214
+ for (const [index, candidate] of promotable.entries()) {
1215
+ const scored = promoteScores.get(index);
1216
+ const decision = scored ? decideSmart(scored.trust, scored.verdict, settings) : void 0;
1217
+ if (!scored || !decision) {
1218
+ skip("duplicate-existing");
1219
+ continue;
1220
+ }
1221
+ if (scored.verdict === "reject") {
1222
+ if (deps.writer.demoteWearableMemory !== void 0) {
1223
+ const existingForDemote = await deps.writer.findWearableMemoryByContent(
1224
+ candidate.fact.content
1225
+ );
1226
+ if (existingForDemote && existingForDemote.status === "pending_review" && await deps.writer.demoteWearableMemory(existingForDemote.id, {
1227
+ trustScore: scored.trust.toFixed(3),
1228
+ trustDecision: "demoted-by-rejection",
1229
+ judgeVerdict: "reject"
1230
+ })) {
1231
+ result.demoted += 1;
1232
+ continue;
1233
+ }
1234
+ }
1235
+ skip("duplicate-existing");
1236
+ continue;
1237
+ }
1238
+ if (decision.outcome !== "active") {
1239
+ skip("duplicate-existing");
1240
+ continue;
1241
+ }
1242
+ const existing = await deps.writer.findWearableMemoryByContent(
1243
+ candidate.fact.content
1244
+ );
1245
+ if (!existing || existing.status !== "pending_review") {
1246
+ skip("duplicate-existing");
1247
+ continue;
1248
+ }
1249
+ const promoted = await deps.writer.promoteWearableMemory(
1250
+ existing.id,
1251
+ {
1252
+ trustScore: scored.trust.toFixed(3),
1253
+ trustDecision: "promoted-by-corroboration",
1254
+ ...scored.verdict !== void 0 ? { judgeVerdict: scored.verdict } : {},
1255
+ ...scored.evidence.corroboratedBySources.length > 0 ? { corroboratedBySources: scored.evidence.corroboratedBySources.join(",") } : {},
1256
+ ...scored.evidence.supportingMemoryId !== void 0 ? { supportingMemoryId: scored.evidence.supportingMemoryId } : {}
1257
+ },
1258
+ scored.trust
1259
+ );
1260
+ if (promoted) {
1261
+ result.promoted += 1;
1262
+ } else {
1263
+ skip("duplicate-existing");
1264
+ }
1265
+ }
1266
+ }
1267
+ let trustById = /* @__PURE__ */ new Map();
1268
+ if (settings.memoryMode === "smart") {
1269
+ trustById = await scoreCandidates(novel, settings, deps, result);
1270
+ }
1271
+ const modeStatus = memoryStatusForMode(settings.memoryMode);
1272
+ const writable = [];
1273
+ novel.forEach((candidate, index) => {
1274
+ if (settings.memoryMode !== "smart") {
1275
+ writable.push({ candidate, index, status: modeStatus, trustAttributes: {} });
1276
+ return;
1277
+ }
1278
+ const scored = trustById.get(index);
1279
+ if (!scored) return;
1280
+ const decision = decideSmart(scored.trust, scored.verdict, settings);
1281
+ if (decision.outcome === "drop") {
1282
+ skip(decision.reason);
1283
+ return;
1284
+ }
1285
+ writable.push({
1286
+ candidate,
1287
+ index,
1288
+ status: decision.outcome === "active" ? "active" : "pending_review",
1289
+ trustAttributes: {
1290
+ trustScore: scored.trust.toFixed(3),
1291
+ trustDecision: decision.reason,
1292
+ ...scored.verdict !== void 0 ? { judgeVerdict: scored.verdict } : {},
1293
+ ...scored.evidence.corroboratedBySources.length > 0 ? { corroboratedBySources: scored.evidence.corroboratedBySources.join(",") } : {},
1294
+ ...scored.evidence.supportingMemoryId !== void 0 ? { supportingMemoryId: scored.evidence.supportingMemoryId } : {}
1295
+ }
1296
+ });
1297
+ });
1298
+ const strength = (entry) => settings.memoryMode === "smart" ? trustById.get(entry.index)?.trust ?? 0 : entry.candidate.importance.score;
1299
+ writable.sort((a, b) => {
1300
+ const sa = strength(a);
1301
+ const sb = strength(b);
1302
+ if (sa > sb) return -1;
1303
+ if (sa < sb) return 1;
1304
+ if (a.candidate.fact.content < b.candidate.fact.content) return -1;
1305
+ if (a.candidate.fact.content > b.candidate.fact.content) return 1;
1095
1306
  return 0;
1096
1307
  });
1097
1308
  const cap = settings.maxMemoriesPerDay;
1098
- const kept = cap > 0 ? novel.slice(0, cap) : novel;
1099
- if (novel.length > kept.length) {
1100
- skip("over-day-cap", novel.length - kept.length);
1309
+ const kept = cap > 0 ? writable.slice(0, cap) : writable;
1310
+ if (writable.length > kept.length) {
1311
+ skip("over-day-cap", writable.length - kept.length);
1101
1312
  }
1102
- const status = memoryStatusForMode(settings.memoryMode);
1103
- for (const candidate of kept) {
1313
+ for (const { candidate, index, status, trustAttributes } of kept) {
1104
1314
  const tags = [
1105
1315
  .../* @__PURE__ */ new Set([
1106
1316
  ...candidate.fact.tags ?? [],
@@ -1110,7 +1320,7 @@ async function generateWearableMemories(sourceId, date, conversations, settings,
1110
1320
  ])
1111
1321
  ];
1112
1322
  await deps.writer.writeMemory(candidate.fact.category, candidate.fact.content, {
1113
- confidence: candidate.fact.confidence,
1323
+ confidence: settings.memoryMode === "smart" ? trustById.get(index)?.trust : candidate.fact.confidence,
1114
1324
  tags,
1115
1325
  source: wearableSourceLabel(sourceId),
1116
1326
  importance: candidate.importance,
@@ -1119,7 +1329,8 @@ async function generateWearableMemories(sourceId, date, conversations, settings,
1119
1329
  ...candidate.fact.structuredAttributes ?? {},
1120
1330
  wearableSource: sourceId,
1121
1331
  wearableDate: date,
1122
- wearableConversationId: candidate.conversation.id
1332
+ wearableConversationId: candidate.conversation.id,
1333
+ ...trustAttributes
1123
1334
  },
1124
1335
  contentHashSource: candidate.fact.content,
1125
1336
  status
@@ -1164,21 +1375,80 @@ async function writeDailyDigestMemory(sourceId, date, conversations, settings, r
1164
1375
  });
1165
1376
  return true;
1166
1377
  }
1167
- async function importNativeMemories(sourceId, memories, alreadyImportedIds, writer) {
1378
+ var NATIVE_TRUST_FACTOR = 0.9;
1379
+ async function importNativeMemories(sourceId, memories, alreadyImportedIds, settings, deps) {
1168
1380
  let imported = 0;
1169
1381
  const importedIds = [];
1382
+ const warnings = [];
1170
1383
  const seenContent = /* @__PURE__ */ new Set();
1384
+ const smart = settings.importNativeMemories === "smart";
1385
+ const novel = [];
1171
1386
  for (const memory of memories) {
1172
1387
  const content = memory.content?.trim();
1173
1388
  if (!content) continue;
1174
1389
  if (alreadyImportedIds.has(memory.id)) continue;
1175
- if (seenContent.has(content) || await writer.hasFactContentHash(content)) {
1390
+ if (seenContent.has(content) || await deps.writer.hasFactContentHash(content)) {
1176
1391
  importedIds.push(memory.id);
1177
1392
  continue;
1178
1393
  }
1179
1394
  seenContent.add(content);
1180
- await writer.writeMemory("fact", content, {
1181
- confidence: 0.6,
1395
+ novel.push({ ...memory, content });
1396
+ }
1397
+ let verdicts;
1398
+ if (smart && deps.judgeFacts && novel.length > 0) {
1399
+ try {
1400
+ const judgeResult = await deps.judgeFacts(
1401
+ novel.map((memory) => ({
1402
+ text: memory.content,
1403
+ category: "fact",
1404
+ confidence: 0.7,
1405
+ tags: memory.tags ?? []
1406
+ }))
1407
+ );
1408
+ verdicts = /* @__PURE__ */ new Map();
1409
+ for (const [index, verdict] of judgeResult.verdicts) {
1410
+ verdicts.set(index, getVerdictKind(verdict));
1411
+ }
1412
+ } catch (err) {
1413
+ warnings.push(
1414
+ `extraction judge unavailable for native import: ${describeErrorForOperator(err)} \u2014 trust scoring continued without judge verdicts`
1415
+ );
1416
+ }
1417
+ }
1418
+ const corroboration = deps.corroboration ?? {
1419
+ otherSourceDayTokens: /* @__PURE__ */ new Map(),
1420
+ existingMemories: []
1421
+ };
1422
+ for (const [index, memory] of novel.entries()) {
1423
+ const content = memory.content;
1424
+ let status = "pending_review";
1425
+ let trustAttributes = {};
1426
+ let confidence = 0.6;
1427
+ if (smart) {
1428
+ const evidence = findCorroboration(content, corroboration);
1429
+ const verdict = verdicts?.get(index);
1430
+ const trust = computeTrustScore({
1431
+ extractionConfidence: void 0,
1432
+ sourceTrust: settings.sourceTrust * NATIVE_TRUST_FACTOR,
1433
+ judgeVerdict: verdict,
1434
+ evidence
1435
+ });
1436
+ const decision = decideSmart(trust, verdict, settings);
1437
+ if (decision.outcome === "drop") {
1438
+ continue;
1439
+ }
1440
+ status = decision.outcome === "active" ? "active" : "pending_review";
1441
+ confidence = trust;
1442
+ trustAttributes = {
1443
+ trustScore: trust.toFixed(3),
1444
+ trustDecision: decision.reason,
1445
+ ...verdict !== void 0 ? { judgeVerdict: verdict } : {},
1446
+ ...evidence.corroboratedBySources.length > 0 ? { corroboratedBySources: evidence.corroboratedBySources.join(",") } : {},
1447
+ ...evidence.supportingMemoryId !== void 0 ? { supportingMemoryId: evidence.supportingMemoryId } : {}
1448
+ };
1449
+ }
1450
+ await deps.writer.writeMemory("fact", content, {
1451
+ confidence,
1182
1452
  tags: [
1183
1453
  .../* @__PURE__ */ new Set([
1184
1454
  ...memory.tags ?? [],
@@ -1192,15 +1462,16 @@ async function importNativeMemories(sourceId, memories, alreadyImportedIds, writ
1192
1462
  validAt: memory.createdIso,
1193
1463
  structuredAttributes: {
1194
1464
  wearableSource: sourceId,
1195
- wearableNativeId: memory.id
1465
+ wearableNativeId: memory.id,
1466
+ ...trustAttributes
1196
1467
  },
1197
1468
  contentHashSource: content,
1198
- status: "pending_review"
1469
+ status
1199
1470
  });
1200
1471
  imported += 1;
1201
1472
  importedIds.push(memory.id);
1202
1473
  }
1203
- return { imported, importedIds };
1474
+ return { imported, importedIds, warnings };
1204
1475
  }
1205
1476
 
1206
1477
  // src/wearables/cleanup.ts
@@ -1548,6 +1819,8 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1548
1819
  correctionsApplied: 0,
1549
1820
  transcriptsWritten: [],
1550
1821
  memoriesCreated: 0,
1822
+ memoriesPromoted: 0,
1823
+ memoriesDemoted: 0,
1551
1824
  memoriesSkipped: 0,
1552
1825
  nativeMemoriesImported: 0,
1553
1826
  warnings: []
@@ -1629,6 +1902,7 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1629
1902
  }
1630
1903
  dayHashes[date] = bodyHash;
1631
1904
  if (allElided) continue;
1905
+ const needsSmartContext = settings.memoryMode === "smart" || settings.importNativeMemories === "smart";
1632
1906
  const memoryPassComplete = previousState?.memoryDayHashes?.[date] === bodyHash;
1633
1907
  if (settings.memoryMode !== "off" && (changed || options.forceMemories === true || !memoryPassComplete)) {
1634
1908
  if (!deps.memoryGen) {
@@ -1638,18 +1912,25 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1638
1912
  } else {
1639
1913
  let passClean = false;
1640
1914
  try {
1915
+ const corroboration = needsSmartContext ? await buildCorroborationContext(connector.id, date, deps) : void 0;
1916
+ const dayMemoryGen = {
1917
+ ...deps.memoryGen,
1918
+ ...corroboration !== void 0 ? { corroboration } : {}
1919
+ };
1641
1920
  const generated = await generateWearableMemories(
1642
1921
  connector.id,
1643
1922
  date,
1644
1923
  cleaned.conversations,
1645
1924
  settings,
1646
1925
  registry,
1647
- deps.memoryGen
1926
+ dayMemoryGen
1648
1927
  );
1649
1928
  summary.memoriesCreated += generated.created;
1929
+ summary.memoriesPromoted += generated.promoted;
1930
+ summary.memoriesDemoted += generated.demoted;
1650
1931
  summary.memoriesSkipped += generated.skipped;
1651
1932
  summary.warnings.push(...generated.warnings);
1652
- passClean = generated.warnings.length === 0;
1933
+ passClean = generated.completed;
1653
1934
  if (config.digestEnabled) {
1654
1935
  const wrote = await writeDailyDigestMemory(
1655
1936
  connector.id,
@@ -1677,7 +1958,7 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1677
1958
  memoryDayHashes[date] = bodyHash;
1678
1959
  }
1679
1960
  }
1680
- if (settings.importNativeMemories === "review" && typeof connector.fetchNativeMemories === "function") {
1961
+ if (settings.importNativeMemories !== "off" && typeof connector.fetchNativeMemories === "function") {
1681
1962
  if (!deps.memoryGen) {
1682
1963
  summary.warnings.push(
1683
1964
  `${connector.id}: importNativeMemories is enabled but no memory writer is available in this context`
@@ -1686,6 +1967,14 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1686
1967
  const alreadyImported = new Set(
1687
1968
  previousState?.importedNativeMemoryIds ?? []
1688
1969
  );
1970
+ const nativeCorroboration = settings.importNativeMemories === "smart" ? {
1971
+ otherSourceDayTokens: /* @__PURE__ */ new Map(),
1972
+ existingMemories: deps.listSupportMemories ? await deps.listSupportMemories() : []
1973
+ } : void 0;
1974
+ const nativeMemoryGen = {
1975
+ ...deps.memoryGen,
1976
+ ...nativeCorroboration !== void 0 ? { corroboration: nativeCorroboration } : {}
1977
+ };
1689
1978
  let cursor = void 0;
1690
1979
  for (let page = 0; page < MAX_NATIVE_PAGES; page++) {
1691
1980
  const result = await connector.fetchNativeMemories({
@@ -1696,8 +1985,10 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1696
1985
  connector.id,
1697
1986
  result.memories,
1698
1987
  alreadyImported,
1699
- deps.memoryGen.writer
1988
+ settings,
1989
+ nativeMemoryGen
1700
1990
  );
1991
+ summary.warnings.push(...imported.warnings);
1701
1992
  summary.nativeMemoriesImported += imported.imported;
1702
1993
  importedNativeIds.push(...imported.importedIds);
1703
1994
  for (const id of imported.importedIds) alreadyImported.add(id);
@@ -1711,12 +2002,13 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1711
2002
  }
1712
2003
  }
1713
2004
  }
1714
- if (summary.transcriptsWritten.length > 0 && deps.afterTranscriptsWritten) {
2005
+ const wroteAnything = summary.transcriptsWritten.length > 0 || summary.memoriesCreated > 0 || summary.memoriesPromoted > 0 || summary.memoriesDemoted > 0 || summary.nativeMemoriesImported > 0;
2006
+ if (wroteAnything && deps.afterWrites) {
1715
2007
  try {
1716
- await deps.afterTranscriptsWritten();
2008
+ await deps.afterWrites();
1717
2009
  } catch (err) {
1718
2010
  summary.warnings.push(
1719
- `search reindex failed (transcripts are stored and will index on the next update): ${describeErrorForOperator(err)}`
2011
+ `search reindex failed (writes are stored and will index on the next update): ${describeErrorForOperator(err)}`
1720
2012
  );
1721
2013
  }
1722
2014
  }
@@ -1728,9 +2020,39 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1728
2020
  clearMemoryDays: failedMemoryDays,
1729
2021
  importedNativeMemoryIds: importedNativeIds
1730
2022
  });
2023
+ if (summary.transcriptsWritten.length > 0) {
2024
+ const cleared = {};
2025
+ for (const [otherId, otherState] of Object.entries(syncState.sources)) {
2026
+ if (otherId === connector.id || otherState.memoryDayHashes === void 0) {
2027
+ cleared[otherId] = otherState;
2028
+ continue;
2029
+ }
2030
+ const memoryDays = { ...otherState.memoryDayHashes };
2031
+ let touched = false;
2032
+ for (const date of summary.transcriptsWritten) {
2033
+ if (date in memoryDays) {
2034
+ delete memoryDays[date];
2035
+ touched = true;
2036
+ }
2037
+ }
2038
+ cleared[otherId] = touched ? { ...otherState, memoryDayHashes: memoryDays } : otherState;
2039
+ }
2040
+ syncState = { version: 1, sources: cleared };
2041
+ }
1731
2042
  await saveSyncState(deps.memoryDir, syncState);
1732
2043
  return summary;
1733
2044
  }
2045
+ async function buildCorroborationContext(sourceId, date, deps) {
2046
+ const otherSourceDayTokens = /* @__PURE__ */ new Map();
2047
+ if (deps.readOtherSourceDayBodies) {
2048
+ const bodies = await deps.readOtherSourceDayBodies(date, sourceId);
2049
+ for (const [otherSource, body] of bodies) {
2050
+ otherSourceDayTokens.set(otherSource, tokenizeDayBody(body));
2051
+ }
2052
+ }
2053
+ const existingMemories = deps.listSupportMemories ? await deps.listSupportMemories() : [];
2054
+ return { otherSourceDayTokens, existingMemories };
2055
+ }
1734
2056
  function defaultTimezone() {
1735
2057
  try {
1736
2058
  return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
@@ -1816,12 +2138,15 @@ function isModuleNotFound(err, specifier) {
1816
2138
  function createWearableMemoryWriter(storage) {
1817
2139
  return {
1818
2140
  writeMemory: storage.writeMemory.bind(storage),
2141
+ findWearableMemoryByContent: async (content) => await storage.findWearableMemoryByContent(content),
2142
+ promoteWearableMemory: storage.promoteWearableMemory.bind(storage),
2143
+ demoteWearableMemory: storage.demoteWearableMemory.bind(storage),
1819
2144
  hasFactContentHash: async (content) => {
1820
2145
  if (await storage.hasFactContentHash(content)) return true;
1821
- const needle = content.trim();
2146
+ const needle = stripAttributesSuffix(content);
1822
2147
  const memories = await storage.readAllMemories();
1823
2148
  return memories.some(
1824
- (memory) => typeof memory.frontmatter.source === "string" && memory.frontmatter.source.startsWith(`${WEARABLE_SOURCE_PREFIX}:`) && memory.content.trim() === needle
2149
+ (memory) => typeof memory.frontmatter.source === "string" && memory.frontmatter.source.startsWith(`${WEARABLE_SOURCE_PREFIX}:`) && stripAttributesSuffix(memory.content) === needle
1825
2150
  );
1826
2151
  }
1827
2152
  };
@@ -1919,7 +2244,8 @@ var WearablesService = class {
1919
2244
  }
1920
2245
  const memoryGen = this.deps.extract ? {
1921
2246
  extract: this.deps.extract,
1922
- writer: createWearableMemoryWriter(storage)
2247
+ writer: createWearableMemoryWriter(storage),
2248
+ ...this.deps.judgeFacts !== void 0 ? { judgeFacts: this.deps.judgeFacts } : {}
1923
2249
  } : null;
1924
2250
  const summaries = [];
1925
2251
  for (const [sourceId, settings] of targets) {
@@ -1948,8 +2274,51 @@ Install it alongside Remnic:
1948
2274
  return parseDayTranscript(raw)?.meta.contentHash ?? null;
1949
2275
  },
1950
2276
  writeDayTranscript: (source, date, serialized) => storage.writeWearableDayTranscript(source, date, serialized),
1951
- afterTranscriptsWritten: this.deps.reindexSearch,
1952
- memoryGen
2277
+ afterWrites: this.deps.reindexSearch,
2278
+ memoryGen,
2279
+ // Cross-device corroboration evidence (smart mode): other
2280
+ // sources' stored transcripts for the same day...
2281
+ readOtherSourceDayBodies: async (date, excludeSource) => {
2282
+ const bodies = /* @__PURE__ */ new Map();
2283
+ const days = await storage.listWearableTranscriptDays();
2284
+ for (const entry of days) {
2285
+ if (entry.date !== date || entry.source === excludeSource) continue;
2286
+ if (bodies.size >= 4) break;
2287
+ const raw = await storage.readWearableDayTranscript(entry.source, entry.date);
2288
+ if (raw === null) continue;
2289
+ bodies.set(entry.source, parseDayTranscript(raw)?.body ?? raw);
2290
+ }
2291
+ return bodies;
2292
+ },
2293
+ // ...and existing memories for the support boost. Status
2294
+ // resolves through the canonical inferMemoryStatus so rows
2295
+ // archived via `archivedAt` (or an archive/ path) without an
2296
+ // explicit status never count. Explicit allow-list: active
2297
+ // rows AND pending_review rows — a borderline fact observed
2298
+ // again on a later day is repetition signal and the support
2299
+ // boost is how it earns promotion. Rejected/quarantined/
2300
+ // superseded/archived/forgotten rows never count (CLAUDE.md
2301
+ // rule 53). Bodies feed token matching with the
2302
+ // "[Attributes: ...]" enrichment suffix stripped — attribute
2303
+ // metadata must never grant corroboration.
2304
+ listSupportMemories: async () => {
2305
+ const memories = await storage.readAllMemories();
2306
+ const support = [];
2307
+ for (const memory of memories) {
2308
+ const status = inferMemoryStatus(
2309
+ memory.frontmatter,
2310
+ memory.path
2311
+ );
2312
+ if (status !== "active" && status !== "pending_review") {
2313
+ continue;
2314
+ }
2315
+ support.push({
2316
+ id: memory.frontmatter.id,
2317
+ content: stripAttributesSuffix(memory.content)
2318
+ });
2319
+ }
2320
+ return support;
2321
+ }
1953
2322
  }
1954
2323
  );
1955
2324
  summaries.push(summary);
@@ -9798,6 +10167,21 @@ _Context: ${topQuestion.context}_`
9798
10167
  config: this.config.wearables,
9799
10168
  getStorage: async () => await this.getStorageForNamespace(this.bulkImportWriteNamespace()),
9800
10169
  extract: (turns) => this.extraction.extract(turns),
10170
+ // Smart memoryMode runs candidates through the SAME extraction
10171
+ // judge (cache + defer counters included) the live extraction
10172
+ // pipeline uses, so wearable facts get identical LLM-as-judge
10173
+ // durability gating.
10174
+ judgeFacts: (candidates) => judgeFactDurability(
10175
+ candidates,
10176
+ this.config,
10177
+ this.localLlm,
10178
+ new FallbackLlmClient(
10179
+ this.config.gatewayConfig,
10180
+ fallbackLlmRuntimeContextFromConfig(this.config)
10181
+ ),
10182
+ this.judgeVerdictCache,
10183
+ this.judgeDeferCounts
10184
+ ),
9801
10185
  searchBackend: {
9802
10186
  search: async (query, maxResults) => {
9803
10187
  if (!this.qmd.isAvailable()) return null;
@@ -13903,4 +14287,4 @@ export {
13903
14287
  resolvePersistedMemoryRelativePath,
13904
14288
  Orchestrator
13905
14289
  };
13906
- //# sourceMappingURL=chunk-3GLCUPXP.js.map
14290
+ //# sourceMappingURL=chunk-YJOWWRRS.js.map