@remnic/core 9.3.628 → 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 (231) hide show
  1. package/dist/access-cli.js +18 -18
  2. package/dist/access-http.d.ts +6 -4
  3. package/dist/access-http.js +7 -6
  4. package/dist/access-mcp.d.ts +6 -4
  5. package/dist/access-mcp.js +6 -5
  6. package/dist/{access-service-C_sfOHsX.d.ts → access-service-C4v-eFjB.d.ts} +2 -2
  7. package/dist/access-service.d.ts +6 -4
  8. package/dist/access-service.js +5 -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 +6 -4
  16. package/dist/briefing.d.ts +33 -2
  17. package/dist/briefing.js +5 -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/calibration.js +2 -2
  22. package/dist/causal-behavior.d.ts +1 -1
  23. package/dist/causal-consolidation.d.ts +1 -1
  24. package/dist/causal-consolidation.js +5 -5
  25. package/dist/{chunk-GE7Q7KXP.js → chunk-2VJ7AJFX.js} +2 -2
  26. package/dist/{chunk-KVFYTRMV.js → chunk-4QEUKASL.js} +2 -2
  27. package/dist/{chunk-KB4MFBF5.js → chunk-5S6IREG3.js} +3 -3
  28. package/dist/{chunk-LQYTQCXM.js → chunk-6LBQL5US.js} +2 -2
  29. package/dist/{chunk-KGIGRNR6.js → chunk-723OMPUI.js} +4 -4
  30. package/dist/{chunk-TZDSNIRO.js → chunk-ADOD7PJC.js} +5 -5
  31. package/dist/{chunk-SHV5Y2WU.js → chunk-BL33LBTN.js} +3 -3
  32. package/dist/{chunk-532VCWYW.js → chunk-BWK5EEKS.js} +2 -2
  33. package/dist/{chunk-KKTXCFD7.js → chunk-EORL2IDM.js} +39 -8
  34. package/dist/{chunk-KKTXCFD7.js.map → chunk-EORL2IDM.js.map} +1 -1
  35. package/dist/{chunk-F3FY3D3S.js → chunk-F6USGHMO.js} +10 -5
  36. package/dist/chunk-F6USGHMO.js.map +1 -0
  37. package/dist/{chunk-STDAAGH7.js → chunk-GXWFZYSR.js} +39 -3
  38. package/dist/chunk-GXWFZYSR.js.map +1 -0
  39. package/dist/{chunk-3VONWEQB.js → chunk-HZVIYZYN.js} +2 -2
  40. package/dist/{chunk-Y3TMFC6I.js → chunk-K3BTOW7N.js} +3 -3
  41. package/dist/{chunk-Z3CCEP6F.js → chunk-K47C6M2C.js} +5 -5
  42. package/dist/{chunk-N5RGXWLQ.js → chunk-MQ24KOOR.js} +2 -2
  43. package/dist/{chunk-3MNBW7R7.js → chunk-NRQJBK36.js} +2 -2
  44. package/dist/{chunk-MON3LMO7.js → chunk-NRST7W5Q.js} +5 -5
  45. package/dist/{chunk-3R2UZV3U.js → chunk-OOFBE62K.js} +2 -2
  46. package/dist/{chunk-MVQN73GT.js → chunk-OQMR2SDZ.js} +2 -2
  47. package/dist/{chunk-UGHUNQ74.js → chunk-RSKUUEBA.js} +73 -1
  48. package/dist/chunk-RSKUUEBA.js.map +1 -0
  49. package/dist/{chunk-QDV6VAD4.js → chunk-S5W37FPX.js} +2 -2
  50. package/dist/{chunk-57QXN2CS.js → chunk-SACS6KE6.js} +2 -2
  51. package/dist/{chunk-UELS6WWF.js → chunk-UE57H4MA.js} +2 -2
  52. package/dist/{chunk-2RHI3FGV.js → chunk-VUTPRX7K.js} +20 -14
  53. package/dist/{chunk-2RHI3FGV.js.map → chunk-VUTPRX7K.js.map} +1 -1
  54. package/dist/{chunk-AZ4RI3QD.js → chunk-YJOWWRRS.js} +450 -48
  55. package/dist/chunk-YJOWWRRS.js.map +1 -0
  56. package/dist/{chunk-P2D2MM47.js → chunk-ZZSXUZF3.js} +2 -2
  57. package/dist/{cli-EZv6YE6_.d.ts → cli-B_6EMiQc.d.ts} +3 -3
  58. package/dist/cli.d.ts +7 -5
  59. package/dist/cli.js +18 -17
  60. package/dist/compounding/engine.d.ts +1 -1
  61. package/dist/compounding/engine.js +2 -2
  62. package/dist/compounding/preference-consolidator.d.ts +1 -1
  63. package/dist/compression-optimizer.d.ts +1 -1
  64. package/dist/config.d.ts +1 -1
  65. package/dist/config.js +1 -1
  66. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  67. package/dist/connectors/codex-materialize-runner.js +2 -2
  68. package/dist/connectors/codex-materialize.d.ts +1 -1
  69. package/dist/connectors/index.d.ts +1 -1
  70. package/dist/connectors/index.js +2 -2
  71. package/dist/consolidation-provenance-check.d.ts +1 -1
  72. package/dist/consolidation-undo.d.ts +1 -1
  73. package/dist/contradiction/index.d.ts +1 -1
  74. package/dist/conversation-index/backend.d.ts +1 -1
  75. package/dist/conversation-index/chunker.d.ts +1 -1
  76. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  77. package/dist/conversation-index/indexer.d.ts +1 -1
  78. package/dist/conversation-index/search.d.ts +1 -1
  79. package/dist/day-summary.d.ts +1 -1
  80. package/dist/delinearize.d.ts +1 -1
  81. package/dist/direct-answer-wiring.d.ts +1 -1
  82. package/dist/direct-answer.d.ts +1 -1
  83. package/dist/embedding-fallback.d.ts +1 -1
  84. package/dist/enrichment/index.d.ts +1 -1
  85. package/dist/entity-retrieval.d.ts +1 -1
  86. package/dist/entity-retrieval.js +2 -2
  87. package/dist/entity-schema.d.ts +1 -1
  88. package/dist/explicit-capture.d.ts +6 -4
  89. package/dist/extraction-judge-telemetry.d.ts +1 -1
  90. package/dist/extraction-judge-training.d.ts +1 -1
  91. package/dist/extraction-judge.d.ts +1 -1
  92. package/dist/extraction-judge.js +3 -3
  93. package/dist/extraction.d.ts +1 -1
  94. package/dist/extraction.js +3 -3
  95. package/dist/fallback-llm.d.ts +1 -1
  96. package/dist/fallback-llm.js +2 -2
  97. package/dist/identity-continuity.d.ts +1 -1
  98. package/dist/importance.d.ts +1 -1
  99. package/dist/index.d.ts +9 -9
  100. package/dist/index.js +29 -27
  101. package/dist/index.js.map +1 -1
  102. package/dist/intent.d.ts +1 -1
  103. package/dist/lcm/engine.d.ts +1 -1
  104. package/dist/lcm/index.d.ts +1 -1
  105. package/dist/lcm/tools.d.ts +1 -1
  106. package/dist/lifecycle.d.ts +1 -1
  107. package/dist/live-connectors-runner.d.ts +1 -1
  108. package/dist/local-llm.d.ts +1 -1
  109. package/dist/maintenance/memory-governance.d.ts +1 -1
  110. package/dist/maintenance/memory-governance.js +2 -2
  111. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +2 -2
  112. package/dist/maintenance/rebuild-memory-projection.js +3 -3
  113. package/dist/mcp-memory-inspector-app.d.ts +6 -4
  114. package/dist/memory-action-policy.d.ts +1 -1
  115. package/dist/memory-cache.d.ts +1 -1
  116. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  117. package/dist/memory-projection-store.d.ts +1 -1
  118. package/dist/memory-provenance.d.ts +1 -1
  119. package/dist/memory-worth-outcomes.d.ts +1 -1
  120. package/dist/models-json.d.ts +1 -1
  121. package/dist/namespaces/migrate.d.ts +1 -1
  122. package/dist/namespaces/migrate.js +3 -3
  123. package/dist/namespaces/principal.d.ts +1 -1
  124. package/dist/namespaces/search.d.ts +1 -1
  125. package/dist/namespaces/storage.d.ts +1 -1
  126. package/dist/namespaces/storage.js +2 -2
  127. package/dist/native-knowledge.d.ts +1 -1
  128. package/dist/operator-toolkit.d.ts +1 -1
  129. package/dist/operator-toolkit.js +6 -6
  130. package/dist/{orchestrator-CEycaY3M.d.ts → orchestrator-Dlw3ae4B.d.ts} +111 -10
  131. package/dist/orchestrator.d.ts +5 -3
  132. package/dist/orchestrator.js +15 -14
  133. package/dist/patterns-cli.d.ts +1 -1
  134. package/dist/policy-runtime.d.ts +1 -1
  135. package/dist/qmd-recall-cache.d.ts +1 -1
  136. package/dist/qmd.d.ts +1 -1
  137. package/dist/recall-disclosure-escalation.d.ts +1 -1
  138. package/dist/recall-explain-renderer.d.ts +1 -1
  139. package/dist/recall-planner-llm.d.ts +1 -1
  140. package/dist/recall-planner-llm.js +2 -2
  141. package/dist/recall-state.d.ts +1 -1
  142. package/dist/recall-tag-filter.d.ts +1 -1
  143. package/dist/recall-xray-cli.d.ts +1 -1
  144. package/dist/recall-xray-renderer.d.ts +1 -1
  145. package/dist/recall-xray.d.ts +1 -1
  146. package/dist/resolve-auth-token.d.ts +1 -1
  147. package/dist/resume-bundles.js +2 -2
  148. package/dist/retrieval-agents.d.ts +1 -1
  149. package/dist/retrieval-tiers.d.ts +1 -1
  150. package/dist/routing/engine.d.ts +1 -1
  151. package/dist/routing/store.d.ts +1 -1
  152. package/dist/schemas.d.ts +24 -24
  153. package/dist/search/embed-helper.d.ts +1 -1
  154. package/dist/search/factory.d.ts +1 -1
  155. package/dist/search/index.d.ts +1 -1
  156. package/dist/search/lancedb-backend.d.ts +1 -1
  157. package/dist/search/meilisearch-backend.d.ts +1 -1
  158. package/dist/search/noop-backend.d.ts +1 -1
  159. package/dist/search/orama-backend.d.ts +1 -1
  160. package/dist/search/port.d.ts +1 -1
  161. package/dist/search/remote-backend.d.ts +1 -1
  162. package/dist/{semantic-consolidation-FbhPeJjB.d.ts → semantic-consolidation-C4sefXEI.d.ts} +1 -1
  163. package/dist/semantic-consolidation.d.ts +2 -2
  164. package/dist/semantic-consolidation.js +3 -3
  165. package/dist/semantic-rule-promotion.js +2 -2
  166. package/dist/semantic-rule-verifier.d.ts +1 -1
  167. package/dist/semantic-rule-verifier.js +2 -2
  168. package/dist/session-observer-bands.d.ts +1 -1
  169. package/dist/session-observer-state.d.ts +1 -1
  170. package/dist/shared-context/manager.d.ts +1 -1
  171. package/dist/signal.d.ts +1 -1
  172. package/dist/storage.d.ts +38 -2
  173. package/dist/storage.js +5 -3
  174. package/dist/summarizer.d.ts +1 -1
  175. package/dist/summarizer.js +3 -3
  176. package/dist/summary-snapshot.d.ts +1 -1
  177. package/dist/temporal-supersession.d.ts +1 -1
  178. package/dist/temporal-validity.d.ts +1 -1
  179. package/dist/threading.d.ts +1 -1
  180. package/dist/tier-migration.d.ts +1 -1
  181. package/dist/tier-routing.d.ts +1 -1
  182. package/dist/topics.d.ts +1 -1
  183. package/dist/transcript.d.ts +1 -1
  184. package/dist/transfer/types.d.ts +12 -12
  185. package/dist/{types-D5VRAI04.d.ts → types-2vqxmO0j.d.ts} +39 -10
  186. package/dist/types.d.ts +1 -1
  187. package/dist/utility-runtime.d.ts +1 -1
  188. package/dist/verified-recall.js +2 -2
  189. package/package.json +1 -1
  190. package/src/access-service.ts +7 -0
  191. package/src/briefing.ts +67 -1
  192. package/src/index.ts +2 -0
  193. package/src/orchestrator.ts +42 -0
  194. package/src/storage.ts +100 -0
  195. package/src/wearables/cli.ts +6 -0
  196. package/src/wearables/config.test.ts +33 -4
  197. package/src/wearables/config.ts +39 -7
  198. package/src/wearables/memory-gen.test.ts +416 -1
  199. package/src/wearables/memory-gen.ts +381 -23
  200. package/src/wearables/pipeline.test.ts +309 -1
  201. package/src/wearables/pipeline.ts +131 -9
  202. package/src/wearables/service.test.ts +172 -0
  203. package/src/wearables/service.ts +84 -3
  204. package/src/wearables/storage-io.test.ts +81 -0
  205. package/src/wearables/trust.test.ts +123 -0
  206. package/src/wearables/trust.ts +168 -0
  207. package/src/wearables/types.ts +37 -8
  208. package/dist/chunk-AZ4RI3QD.js.map +0 -1
  209. package/dist/chunk-F3FY3D3S.js.map +0 -1
  210. package/dist/chunk-STDAAGH7.js.map +0 -1
  211. package/dist/chunk-UGHUNQ74.js.map +0 -1
  212. /package/dist/{chunk-GE7Q7KXP.js.map → chunk-2VJ7AJFX.js.map} +0 -0
  213. /package/dist/{chunk-KVFYTRMV.js.map → chunk-4QEUKASL.js.map} +0 -0
  214. /package/dist/{chunk-KB4MFBF5.js.map → chunk-5S6IREG3.js.map} +0 -0
  215. /package/dist/{chunk-LQYTQCXM.js.map → chunk-6LBQL5US.js.map} +0 -0
  216. /package/dist/{chunk-KGIGRNR6.js.map → chunk-723OMPUI.js.map} +0 -0
  217. /package/dist/{chunk-TZDSNIRO.js.map → chunk-ADOD7PJC.js.map} +0 -0
  218. /package/dist/{chunk-SHV5Y2WU.js.map → chunk-BL33LBTN.js.map} +0 -0
  219. /package/dist/{chunk-532VCWYW.js.map → chunk-BWK5EEKS.js.map} +0 -0
  220. /package/dist/{chunk-3VONWEQB.js.map → chunk-HZVIYZYN.js.map} +0 -0
  221. /package/dist/{chunk-Y3TMFC6I.js.map → chunk-K3BTOW7N.js.map} +0 -0
  222. /package/dist/{chunk-Z3CCEP6F.js.map → chunk-K47C6M2C.js.map} +0 -0
  223. /package/dist/{chunk-N5RGXWLQ.js.map → chunk-MQ24KOOR.js.map} +0 -0
  224. /package/dist/{chunk-3MNBW7R7.js.map → chunk-NRQJBK36.js.map} +0 -0
  225. /package/dist/{chunk-MON3LMO7.js.map → chunk-NRST7W5Q.js.map} +0 -0
  226. /package/dist/{chunk-3R2UZV3U.js.map → chunk-OOFBE62K.js.map} +0 -0
  227. /package/dist/{chunk-MVQN73GT.js.map → chunk-OQMR2SDZ.js.map} +0 -0
  228. /package/dist/{chunk-QDV6VAD4.js.map → chunk-S5W37FPX.js.map} +0 -0
  229. /package/dist/{chunk-57QXN2CS.js.map → chunk-SACS6KE6.js.map} +0 -0
  230. /package/dist/{chunk-UELS6WWF.js.map → chunk-UE57H4MA.js.map} +0 -0
  231. /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-UELS6WWF.js";
25
+ } from "./chunk-UE57H4MA.js";
26
26
  import {
27
27
  SharedContextManager
28
28
  } from "./chunk-DRD2Q7HQ.js";
@@ -57,7 +57,7 @@ import {
57
57
  } from "./chunk-VOUOLGIP.js";
58
58
  import {
59
59
  HourlySummarizer
60
- } from "./chunk-3VONWEQB.js";
60
+ } from "./chunk-HZVIYZYN.js";
61
61
  import {
62
62
  SessionObserverState
63
63
  } from "./chunk-MHQC2WU2.js";
@@ -147,10 +147,10 @@ import {
147
147
  getVerdictKind,
148
148
  judgeFactDurability,
149
149
  validateProcedureExtraction
150
- } from "./chunk-Z3CCEP6F.js";
150
+ } from "./chunk-K47C6M2C.js";
151
151
  import {
152
152
  ExtractionEngine
153
- } from "./chunk-MON3LMO7.js";
153
+ } from "./chunk-NRST7W5Q.js";
154
154
  import {
155
155
  parseMemoryActionEligibilityContext
156
156
  } from "./chunk-ROZJACKP.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";
@@ -284,7 +284,7 @@ import {
284
284
  import {
285
285
  FallbackLlmClient,
286
286
  fallbackLlmRuntimeContextFromConfig
287
- } from "./chunk-KGIGRNR6.js";
287
+ } from "./chunk-723OMPUI.js";
288
288
  import {
289
289
  applyCorrections,
290
290
  applyOffTheRecord,
@@ -349,6 +349,9 @@ import {
349
349
  import {
350
350
  GraphIndex
351
351
  } from "./chunk-XL7FK7PJ.js";
352
+ import {
353
+ buildChainFollowupGenerator
354
+ } from "./chunk-GXWFZYSR.js";
352
355
  import {
353
356
  ContentHashIndex,
354
357
  StorageManager,
@@ -366,8 +369,9 @@ import {
366
369
  resolveSpeaker,
367
370
  saveSpeakerRegistry,
368
371
  serializeDayTranscript,
369
- speakerRegistryKey
370
- } from "./chunk-UGHUNQ74.js";
372
+ speakerRegistryKey,
373
+ stripAttributesSuffix
374
+ } from "./chunk-RSKUUEBA.js";
371
375
  import {
372
376
  attachCitation,
373
377
  hasCitationForTemplate,
@@ -377,6 +381,7 @@ import {
377
381
  confidenceTier
378
382
  } from "./chunk-FPNQF475.js";
379
383
  import {
384
+ inferMemoryStatus,
380
385
  isActiveMemoryStatus
381
386
  } from "./chunk-RULE4VG5.js";
382
387
  import {
@@ -405,6 +410,10 @@ import {
405
410
  decideLifecycleTransition,
406
411
  resolveLifecycleState
407
412
  } from "./chunk-TBBDFYXW.js";
413
+ import {
414
+ countRecallTokenOverlap,
415
+ normalizeRecallTokens
416
+ } from "./chunk-ZBJMUXZH.js";
408
417
  import {
409
418
  log
410
419
  } from "./chunk-2ODBA7MQ.js";
@@ -962,9 +971,75 @@ function getTaxonomyFilePath(memoryDir) {
962
971
  return path.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
963
972
  }
964
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
+
965
1040
  // src/wearables/memory-gen.ts
966
1041
  function memoryStatusForMode(mode) {
967
- return mode === "auto" ? "active" : "pending_review";
1042
+ return mode === "auto" || mode === "smart" ? "active" : "pending_review";
968
1043
  }
969
1044
  var WEARABLE_SOURCE_PREFIX = "wearable";
970
1045
  function wearableSourceLabel(sourceId) {
@@ -1022,12 +1097,56 @@ ${chunkLines.join("\n")}`,
1022
1097
  flush();
1023
1098
  return turns;
1024
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
+ }
1025
1141
  async function generateWearableMemories(sourceId, date, conversations, settings, registry, deps) {
1026
1142
  const result = {
1027
1143
  created: 0,
1144
+ promoted: 0,
1145
+ demoted: 0,
1028
1146
  skipped: 0,
1029
1147
  skippedByReason: {},
1030
- warnings: []
1148
+ warnings: [],
1149
+ completed: true
1031
1150
  };
1032
1151
  if (settings.memoryMode === "off") return result;
1033
1152
  const skip = (reason, count = 1) => {
@@ -1046,6 +1165,7 @@ async function generateWearableMemories(sourceId, date, conversations, settings,
1046
1165
  result.warnings.push(
1047
1166
  `extraction failed for ${sourceId}/${date} (conversation ${conversation.id}): ${describeErrorForOperator(err)} \u2014 the memory pass for this day retries on the next sync`
1048
1167
  );
1168
+ result.completed = false;
1049
1169
  break;
1050
1170
  }
1051
1171
  for (const fact of extraction.facts) {
@@ -1058,7 +1178,7 @@ async function generateWearableMemories(sourceId, date, conversations, settings,
1058
1178
  skip("unsupported-category");
1059
1179
  continue;
1060
1180
  }
1061
- if (typeof fact.confidence === "number" && fact.confidence < settings.minConfidence) {
1181
+ if (settings.memoryMode !== "smart" && typeof fact.confidence === "number" && fact.confidence < settings.minConfidence) {
1062
1182
  skip("below-confidence");
1063
1183
  continue;
1064
1184
  }
@@ -1077,27 +1197,120 @@ async function generateWearableMemories(sourceId, date, conversations, settings,
1077
1197
  }
1078
1198
  }
1079
1199
  const novel = [];
1200
+ const promotable = [];
1080
1201
  for (const candidate of candidates) {
1081
1202
  if (await deps.writer.hasFactContentHash(candidate.fact.content)) {
1082
- 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
+ }
1083
1208
  continue;
1084
1209
  }
1085
1210
  novel.push(candidate);
1086
1211
  }
1087
- novel.sort((a, b) => {
1088
- if (a.importance.score > b.importance.score) return -1;
1089
- if (a.importance.score < b.importance.score) return 1;
1090
- if (a.fact.content < b.fact.content) return -1;
1091
- 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;
1092
1306
  return 0;
1093
1307
  });
1094
1308
  const cap = settings.maxMemoriesPerDay;
1095
- const kept = cap > 0 ? novel.slice(0, cap) : novel;
1096
- if (novel.length > kept.length) {
1097
- 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);
1098
1312
  }
1099
- const status = memoryStatusForMode(settings.memoryMode);
1100
- for (const candidate of kept) {
1313
+ for (const { candidate, index, status, trustAttributes } of kept) {
1101
1314
  const tags = [
1102
1315
  .../* @__PURE__ */ new Set([
1103
1316
  ...candidate.fact.tags ?? [],
@@ -1107,7 +1320,7 @@ async function generateWearableMemories(sourceId, date, conversations, settings,
1107
1320
  ])
1108
1321
  ];
1109
1322
  await deps.writer.writeMemory(candidate.fact.category, candidate.fact.content, {
1110
- confidence: candidate.fact.confidence,
1323
+ confidence: settings.memoryMode === "smart" ? trustById.get(index)?.trust : candidate.fact.confidence,
1111
1324
  tags,
1112
1325
  source: wearableSourceLabel(sourceId),
1113
1326
  importance: candidate.importance,
@@ -1116,7 +1329,8 @@ async function generateWearableMemories(sourceId, date, conversations, settings,
1116
1329
  ...candidate.fact.structuredAttributes ?? {},
1117
1330
  wearableSource: sourceId,
1118
1331
  wearableDate: date,
1119
- wearableConversationId: candidate.conversation.id
1332
+ wearableConversationId: candidate.conversation.id,
1333
+ ...trustAttributes
1120
1334
  },
1121
1335
  contentHashSource: candidate.fact.content,
1122
1336
  status
@@ -1161,21 +1375,80 @@ async function writeDailyDigestMemory(sourceId, date, conversations, settings, r
1161
1375
  });
1162
1376
  return true;
1163
1377
  }
1164
- async function importNativeMemories(sourceId, memories, alreadyImportedIds, writer) {
1378
+ var NATIVE_TRUST_FACTOR = 0.9;
1379
+ async function importNativeMemories(sourceId, memories, alreadyImportedIds, settings, deps) {
1165
1380
  let imported = 0;
1166
1381
  const importedIds = [];
1382
+ const warnings = [];
1167
1383
  const seenContent = /* @__PURE__ */ new Set();
1384
+ const smart = settings.importNativeMemories === "smart";
1385
+ const novel = [];
1168
1386
  for (const memory of memories) {
1169
1387
  const content = memory.content?.trim();
1170
1388
  if (!content) continue;
1171
1389
  if (alreadyImportedIds.has(memory.id)) continue;
1172
- if (seenContent.has(content) || await writer.hasFactContentHash(content)) {
1390
+ if (seenContent.has(content) || await deps.writer.hasFactContentHash(content)) {
1173
1391
  importedIds.push(memory.id);
1174
1392
  continue;
1175
1393
  }
1176
1394
  seenContent.add(content);
1177
- await writer.writeMemory("fact", content, {
1178
- 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,
1179
1452
  tags: [
1180
1453
  .../* @__PURE__ */ new Set([
1181
1454
  ...memory.tags ?? [],
@@ -1189,15 +1462,16 @@ async function importNativeMemories(sourceId, memories, alreadyImportedIds, writ
1189
1462
  validAt: memory.createdIso,
1190
1463
  structuredAttributes: {
1191
1464
  wearableSource: sourceId,
1192
- wearableNativeId: memory.id
1465
+ wearableNativeId: memory.id,
1466
+ ...trustAttributes
1193
1467
  },
1194
1468
  contentHashSource: content,
1195
- status: "pending_review"
1469
+ status
1196
1470
  });
1197
1471
  imported += 1;
1198
1472
  importedIds.push(memory.id);
1199
1473
  }
1200
- return { imported, importedIds };
1474
+ return { imported, importedIds, warnings };
1201
1475
  }
1202
1476
 
1203
1477
  // src/wearables/cleanup.ts
@@ -1545,6 +1819,8 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1545
1819
  correctionsApplied: 0,
1546
1820
  transcriptsWritten: [],
1547
1821
  memoriesCreated: 0,
1822
+ memoriesPromoted: 0,
1823
+ memoriesDemoted: 0,
1548
1824
  memoriesSkipped: 0,
1549
1825
  nativeMemoriesImported: 0,
1550
1826
  warnings: []
@@ -1626,6 +1902,7 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1626
1902
  }
1627
1903
  dayHashes[date] = bodyHash;
1628
1904
  if (allElided) continue;
1905
+ const needsSmartContext = settings.memoryMode === "smart" || settings.importNativeMemories === "smart";
1629
1906
  const memoryPassComplete = previousState?.memoryDayHashes?.[date] === bodyHash;
1630
1907
  if (settings.memoryMode !== "off" && (changed || options.forceMemories === true || !memoryPassComplete)) {
1631
1908
  if (!deps.memoryGen) {
@@ -1635,18 +1912,25 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1635
1912
  } else {
1636
1913
  let passClean = false;
1637
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
+ };
1638
1920
  const generated = await generateWearableMemories(
1639
1921
  connector.id,
1640
1922
  date,
1641
1923
  cleaned.conversations,
1642
1924
  settings,
1643
1925
  registry,
1644
- deps.memoryGen
1926
+ dayMemoryGen
1645
1927
  );
1646
1928
  summary.memoriesCreated += generated.created;
1929
+ summary.memoriesPromoted += generated.promoted;
1930
+ summary.memoriesDemoted += generated.demoted;
1647
1931
  summary.memoriesSkipped += generated.skipped;
1648
1932
  summary.warnings.push(...generated.warnings);
1649
- passClean = generated.warnings.length === 0;
1933
+ passClean = generated.completed;
1650
1934
  if (config.digestEnabled) {
1651
1935
  const wrote = await writeDailyDigestMemory(
1652
1936
  connector.id,
@@ -1674,7 +1958,7 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1674
1958
  memoryDayHashes[date] = bodyHash;
1675
1959
  }
1676
1960
  }
1677
- if (settings.importNativeMemories === "review" && typeof connector.fetchNativeMemories === "function") {
1961
+ if (settings.importNativeMemories !== "off" && typeof connector.fetchNativeMemories === "function") {
1678
1962
  if (!deps.memoryGen) {
1679
1963
  summary.warnings.push(
1680
1964
  `${connector.id}: importNativeMemories is enabled but no memory writer is available in this context`
@@ -1683,6 +1967,14 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1683
1967
  const alreadyImported = new Set(
1684
1968
  previousState?.importedNativeMemoryIds ?? []
1685
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
+ };
1686
1978
  let cursor = void 0;
1687
1979
  for (let page = 0; page < MAX_NATIVE_PAGES; page++) {
1688
1980
  const result = await connector.fetchNativeMemories({
@@ -1693,8 +1985,10 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1693
1985
  connector.id,
1694
1986
  result.memories,
1695
1987
  alreadyImported,
1696
- deps.memoryGen.writer
1988
+ settings,
1989
+ nativeMemoryGen
1697
1990
  );
1991
+ summary.warnings.push(...imported.warnings);
1698
1992
  summary.nativeMemoriesImported += imported.imported;
1699
1993
  importedNativeIds.push(...imported.importedIds);
1700
1994
  for (const id of imported.importedIds) alreadyImported.add(id);
@@ -1708,12 +2002,13 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1708
2002
  }
1709
2003
  }
1710
2004
  }
1711
- 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) {
1712
2007
  try {
1713
- await deps.afterTranscriptsWritten();
2008
+ await deps.afterWrites();
1714
2009
  } catch (err) {
1715
2010
  summary.warnings.push(
1716
- `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)}`
1717
2012
  );
1718
2013
  }
1719
2014
  }
@@ -1725,9 +2020,39 @@ async function syncWearableSource(connector, settings, config, options, deps) {
1725
2020
  clearMemoryDays: failedMemoryDays,
1726
2021
  importedNativeMemoryIds: importedNativeIds
1727
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
+ }
1728
2042
  await saveSyncState(deps.memoryDir, syncState);
1729
2043
  return summary;
1730
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
+ }
1731
2056
  function defaultTimezone() {
1732
2057
  try {
1733
2058
  return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
@@ -1813,12 +2138,15 @@ function isModuleNotFound(err, specifier) {
1813
2138
  function createWearableMemoryWriter(storage) {
1814
2139
  return {
1815
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),
1816
2144
  hasFactContentHash: async (content) => {
1817
2145
  if (await storage.hasFactContentHash(content)) return true;
1818
- const needle = content.trim();
2146
+ const needle = stripAttributesSuffix(content);
1819
2147
  const memories = await storage.readAllMemories();
1820
2148
  return memories.some(
1821
- (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
1822
2150
  );
1823
2151
  }
1824
2152
  };
@@ -1916,7 +2244,8 @@ var WearablesService = class {
1916
2244
  }
1917
2245
  const memoryGen = this.deps.extract ? {
1918
2246
  extract: this.deps.extract,
1919
- writer: createWearableMemoryWriter(storage)
2247
+ writer: createWearableMemoryWriter(storage),
2248
+ ...this.deps.judgeFacts !== void 0 ? { judgeFacts: this.deps.judgeFacts } : {}
1920
2249
  } : null;
1921
2250
  const summaries = [];
1922
2251
  for (const [sourceId, settings] of targets) {
@@ -1945,8 +2274,51 @@ Install it alongside Remnic:
1945
2274
  return parseDayTranscript(raw)?.meta.contentHash ?? null;
1946
2275
  },
1947
2276
  writeDayTranscript: (source, date, serialized) => storage.writeWearableDayTranscript(source, date, serialized),
1948
- afterTranscriptsWritten: this.deps.reindexSearch,
1949
- 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
+ }
1950
2322
  }
1951
2323
  );
1952
2324
  summaries.push(summary);
@@ -3633,6 +4005,21 @@ var Orchestrator = class _Orchestrator {
3633
4005
  })
3634
4006
  };
3635
4007
  }
4008
+ /**
4009
+ * Build a briefing follow-up generator backed by the configured LLM chain
4010
+ * (gateway model source or local LLM). Returns `undefined` when no chain
4011
+ * is available so `buildBriefing` can surface a clear unavailable reason
4012
+ * instead of failing at call time. Used by the access service and CLI as
4013
+ * the fallback when no direct `openaiApiKey` is configured, so briefing
4014
+ * follow-ups ride the same routing as every other fast-tier LLM feature.
4015
+ */
4016
+ get briefingChainFollowupGenerator() {
4017
+ const chainAvailable = this.config.modelSource === "gateway" ? this._fastGatewayLlm?.isAvailable(
4018
+ this.config.fastGatewayAgentId || this.config.gatewayAgentId || void 0
4019
+ ) === true : this.config.localLlmEnabled;
4020
+ if (!chainAvailable) return void 0;
4021
+ return buildChainFollowupGenerator(this.fastLlmForRerank);
4022
+ }
3636
4023
  async initialize() {
3637
4024
  this.deferredReady = new Promise((resolve) => {
3638
4025
  this.resolveDeferredReady = resolve;
@@ -9780,6 +10167,21 @@ _Context: ${topQuestion.context}_`
9780
10167
  config: this.config.wearables,
9781
10168
  getStorage: async () => await this.getStorageForNamespace(this.bulkImportWriteNamespace()),
9782
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
+ ),
9783
10185
  searchBackend: {
9784
10186
  search: async (query, maxResults) => {
9785
10187
  if (!this.qmd.isAvailable()) return null;
@@ -13885,4 +14287,4 @@ export {
13885
14287
  resolvePersistedMemoryRelativePath,
13886
14288
  Orchestrator
13887
14289
  };
13888
- //# sourceMappingURL=chunk-AZ4RI3QD.js.map
14290
+ //# sourceMappingURL=chunk-YJOWWRRS.js.map