agent-recall-core 3.4.47 → 3.4.49

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 (221) hide show
  1. package/README.md +25 -0
  2. package/dist/digest/store.d.ts +15 -6
  3. package/dist/digest/store.d.ts.map +1 -1
  4. package/dist/digest/store.js +33 -20
  5. package/dist/digest/store.js.map +1 -1
  6. package/dist/embeddings/chunker.d.ts +102 -0
  7. package/dist/embeddings/chunker.d.ts.map +1 -0
  8. package/dist/embeddings/chunker.js +260 -0
  9. package/dist/embeddings/chunker.js.map +1 -0
  10. package/dist/embeddings/config.d.ts +93 -0
  11. package/dist/embeddings/config.d.ts.map +1 -0
  12. package/dist/embeddings/config.js +174 -0
  13. package/dist/embeddings/config.js.map +1 -0
  14. package/dist/embeddings/index-store.d.ts +61 -0
  15. package/dist/embeddings/index-store.d.ts.map +1 -0
  16. package/dist/embeddings/index-store.js +158 -0
  17. package/dist/embeddings/index-store.js.map +1 -0
  18. package/dist/embeddings/indexer.d.ts +75 -0
  19. package/dist/embeddings/indexer.d.ts.map +1 -0
  20. package/dist/embeddings/indexer.js +196 -0
  21. package/dist/embeddings/indexer.js.map +1 -0
  22. package/dist/embeddings/runtime.d.ts +66 -0
  23. package/dist/embeddings/runtime.d.ts.map +1 -0
  24. package/dist/embeddings/runtime.js +197 -0
  25. package/dist/embeddings/runtime.js.map +1 -0
  26. package/dist/helpers/associative-link.d.ts.map +1 -1
  27. package/dist/helpers/associative-link.js +26 -1
  28. package/dist/helpers/associative-link.js.map +1 -1
  29. package/dist/helpers/tokenize.d.ts +1 -0
  30. package/dist/helpers/tokenize.d.ts.map +1 -1
  31. package/dist/helpers/tokenize.js +18 -0
  32. package/dist/helpers/tokenize.js.map +1 -1
  33. package/dist/index.d.ts +27 -10
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +50 -6
  36. package/dist/index.js.map +1 -1
  37. package/dist/palace/awareness.d.ts +34 -10
  38. package/dist/palace/awareness.d.ts.map +1 -1
  39. package/dist/palace/awareness.js +249 -180
  40. package/dist/palace/awareness.js.map +1 -1
  41. package/dist/palace/consolidate.d.ts +1 -1
  42. package/dist/palace/consolidate.d.ts.map +1 -1
  43. package/dist/palace/consolidate.js +9 -9
  44. package/dist/palace/consolidate.js.map +1 -1
  45. package/dist/palace/decay-pass.d.ts +1 -1
  46. package/dist/palace/decay-pass.d.ts.map +1 -1
  47. package/dist/palace/decay-pass.js +2 -2
  48. package/dist/palace/decay-pass.js.map +1 -1
  49. package/dist/palace/fan-out.d.ts +1 -1
  50. package/dist/palace/fan-out.d.ts.map +1 -1
  51. package/dist/palace/fan-out.js +5 -5
  52. package/dist/palace/fan-out.js.map +1 -1
  53. package/dist/palace/index-manager.d.ts +1 -1
  54. package/dist/palace/index-manager.d.ts.map +1 -1
  55. package/dist/palace/index-manager.js +1 -1
  56. package/dist/palace/index-manager.js.map +1 -1
  57. package/dist/palace/insights-index.d.ts +19 -6
  58. package/dist/palace/insights-index.d.ts.map +1 -1
  59. package/dist/palace/insights-index.js +36 -13
  60. package/dist/palace/insights-index.js.map +1 -1
  61. package/dist/palace/keystone.d.ts +1 -1
  62. package/dist/palace/keystone.d.ts.map +1 -1
  63. package/dist/palace/keystone.js +2 -2
  64. package/dist/palace/keystone.js.map +1 -1
  65. package/dist/palace/rooms.d.ts +3 -3
  66. package/dist/palace/rooms.d.ts.map +1 -1
  67. package/dist/palace/rooms.js +34 -6
  68. package/dist/palace/rooms.js.map +1 -1
  69. package/dist/retrieval/candidates.d.ts +27 -2
  70. package/dist/retrieval/candidates.d.ts.map +1 -1
  71. package/dist/retrieval/candidates.js +170 -3
  72. package/dist/retrieval/candidates.js.map +1 -1
  73. package/dist/retrieval/contradiction.d.ts +65 -13
  74. package/dist/retrieval/contradiction.d.ts.map +1 -1
  75. package/dist/retrieval/contradiction.js +40 -17
  76. package/dist/retrieval/contradiction.js.map +1 -1
  77. package/dist/retrieval/query-memory.d.ts +112 -9
  78. package/dist/retrieval/query-memory.d.ts.map +1 -1
  79. package/dist/retrieval/query-memory.js +623 -62
  80. package/dist/retrieval/query-memory.js.map +1 -1
  81. package/dist/retrieval/semantic-leg.d.ts +74 -0
  82. package/dist/retrieval/semantic-leg.d.ts.map +1 -0
  83. package/dist/retrieval/semantic-leg.js +180 -0
  84. package/dist/retrieval/semantic-leg.js.map +1 -0
  85. package/dist/storage/archive-write.d.ts.map +1 -1
  86. package/dist/storage/archive-write.js +29 -8
  87. package/dist/storage/archive-write.js.map +1 -1
  88. package/dist/storage/capture-router.d.ts +1 -1
  89. package/dist/storage/capture-router.d.ts.map +1 -1
  90. package/dist/storage/capture-router.js +26 -9
  91. package/dist/storage/capture-router.js.map +1 -1
  92. package/dist/storage/consolidation-queue.d.ts +11 -2
  93. package/dist/storage/consolidation-queue.d.ts.map +1 -1
  94. package/dist/storage/consolidation-queue.js +45 -16
  95. package/dist/storage/consolidation-queue.js.map +1 -1
  96. package/dist/storage/corrections.d.ts +185 -6
  97. package/dist/storage/corrections.d.ts.map +1 -1
  98. package/dist/storage/corrections.js +525 -126
  99. package/dist/storage/corrections.js.map +1 -1
  100. package/dist/storage/durable-intent.d.ts.map +1 -1
  101. package/dist/storage/durable-intent.js +24 -1
  102. package/dist/storage/durable-intent.js.map +1 -1
  103. package/dist/storage/filelock.d.ts +84 -12
  104. package/dist/storage/filelock.d.ts.map +1 -1
  105. package/dist/storage/filelock.js +309 -47
  106. package/dist/storage/filelock.js.map +1 -1
  107. package/dist/storage/fs-utils.d.ts +20 -0
  108. package/dist/storage/fs-utils.d.ts.map +1 -1
  109. package/dist/storage/fs-utils.js +27 -0
  110. package/dist/storage/fs-utils.js.map +1 -1
  111. package/dist/storage/paths.d.ts +34 -0
  112. package/dist/storage/paths.d.ts.map +1 -1
  113. package/dist/storage/paths.js +71 -0
  114. package/dist/storage/paths.js.map +1 -1
  115. package/dist/storage/pending.d.ts +154 -0
  116. package/dist/storage/pending.d.ts.map +1 -0
  117. package/dist/storage/pending.js +454 -0
  118. package/dist/storage/pending.js.map +1 -0
  119. package/dist/storage/project.d.ts.map +1 -1
  120. package/dist/storage/project.js +68 -16
  121. package/dist/storage/project.js.map +1 -1
  122. package/dist/storage/session-card.d.ts +13 -0
  123. package/dist/storage/session-card.d.ts.map +1 -1
  124. package/dist/storage/session-card.js +34 -3
  125. package/dist/storage/session-card.js.map +1 -1
  126. package/dist/storage/unclaimed.d.ts +165 -0
  127. package/dist/storage/unclaimed.d.ts.map +1 -0
  128. package/dist/storage/unclaimed.js +442 -0
  129. package/dist/storage/unclaimed.js.map +1 -0
  130. package/dist/storage/working-memory.d.ts.map +1 -1
  131. package/dist/storage/working-memory.js +19 -1
  132. package/dist/storage/working-memory.js.map +1 -1
  133. package/dist/supabase/recall-backend.d.ts +29 -2
  134. package/dist/supabase/recall-backend.d.ts.map +1 -1
  135. package/dist/supabase/recall-backend.js +231 -29
  136. package/dist/supabase/recall-backend.js.map +1 -1
  137. package/dist/supabase/sync.d.ts.map +1 -1
  138. package/dist/supabase/sync.js +13 -0
  139. package/dist/supabase/sync.js.map +1 -1
  140. package/dist/tools-logic/alignment-check.js +1 -1
  141. package/dist/tools-logic/alignment-check.js.map +1 -1
  142. package/dist/tools-logic/awareness-update.d.ts.map +1 -1
  143. package/dist/tools-logic/awareness-update.js +25 -16
  144. package/dist/tools-logic/awareness-update.js.map +1 -1
  145. package/dist/tools-logic/check-action.js +1 -1
  146. package/dist/tools-logic/check-action.js.map +1 -1
  147. package/dist/tools-logic/check.d.ts +55 -1
  148. package/dist/tools-logic/check.d.ts.map +1 -1
  149. package/dist/tools-logic/check.js +230 -57
  150. package/dist/tools-logic/check.js.map +1 -1
  151. package/dist/tools-logic/confidence.d.ts +11 -6
  152. package/dist/tools-logic/confidence.d.ts.map +1 -1
  153. package/dist/tools-logic/confidence.js +11 -6
  154. package/dist/tools-logic/confidence.js.map +1 -1
  155. package/dist/tools-logic/context-synthesize.js +2 -2
  156. package/dist/tools-logic/context-synthesize.js.map +1 -1
  157. package/dist/tools-logic/digest-read.js +2 -2
  158. package/dist/tools-logic/digest-read.js.map +1 -1
  159. package/dist/tools-logic/digest-recall.js +1 -1
  160. package/dist/tools-logic/digest-recall.js.map +1 -1
  161. package/dist/tools-logic/insight-promotion.d.ts +1 -1
  162. package/dist/tools-logic/insight-promotion.d.ts.map +1 -1
  163. package/dist/tools-logic/insight-promotion.js +17 -6
  164. package/dist/tools-logic/insight-promotion.js.map +1 -1
  165. package/dist/tools-logic/journal-capture.js +3 -3
  166. package/dist/tools-logic/journal-capture.js.map +1 -1
  167. package/dist/tools-logic/journal-write.js +3 -3
  168. package/dist/tools-logic/journal-write.js.map +1 -1
  169. package/dist/tools-logic/knowledge-write.js +2 -2
  170. package/dist/tools-logic/knowledge-write.js.map +1 -1
  171. package/dist/tools-logic/palace-lint.js +1 -1
  172. package/dist/tools-logic/palace-lint.js.map +1 -1
  173. package/dist/tools-logic/palace-read.js +1 -1
  174. package/dist/tools-logic/palace-read.js.map +1 -1
  175. package/dist/tools-logic/palace-search.js +1 -1
  176. package/dist/tools-logic/palace-search.js.map +1 -1
  177. package/dist/tools-logic/palace-walk.js +3 -3
  178. package/dist/tools-logic/palace-walk.js.map +1 -1
  179. package/dist/tools-logic/palace-write.js +4 -4
  180. package/dist/tools-logic/palace-write.js.map +1 -1
  181. package/dist/tools-logic/predict-correction.js +1 -1
  182. package/dist/tools-logic/predict-correction.js.map +1 -1
  183. package/dist/tools-logic/recall-backend.d.ts +11 -2
  184. package/dist/tools-logic/recall-backend.d.ts.map +1 -1
  185. package/dist/tools-logic/recall-backend.js +2 -2
  186. package/dist/tools-logic/recall-backend.js.map +1 -1
  187. package/dist/tools-logic/resurrect.d.ts.map +1 -1
  188. package/dist/tools-logic/resurrect.js +9 -1
  189. package/dist/tools-logic/resurrect.js.map +1 -1
  190. package/dist/tools-logic/safety-consolidation.d.ts.map +1 -1
  191. package/dist/tools-logic/safety-consolidation.js +32 -30
  192. package/dist/tools-logic/safety-consolidation.js.map +1 -1
  193. package/dist/tools-logic/session-end.d.ts +8 -0
  194. package/dist/tools-logic/session-end.d.ts.map +1 -1
  195. package/dist/tools-logic/session-end.js +51 -13
  196. package/dist/tools-logic/session-end.js.map +1 -1
  197. package/dist/tools-logic/session-start.d.ts +23 -0
  198. package/dist/tools-logic/session-start.d.ts.map +1 -1
  199. package/dist/tools-logic/session-start.js +44 -1
  200. package/dist/tools-logic/session-start.js.map +1 -1
  201. package/dist/tools-logic/smart-recall.d.ts +185 -10
  202. package/dist/tools-logic/smart-recall.d.ts.map +1 -1
  203. package/dist/tools-logic/smart-recall.js +364 -60
  204. package/dist/tools-logic/smart-recall.js.map +1 -1
  205. package/dist/tools-logic/store-doctor.d.ts.map +1 -1
  206. package/dist/tools-logic/store-doctor.js +7 -4
  207. package/dist/tools-logic/store-doctor.js.map +1 -1
  208. package/dist/tools-logic/store-repair.js +1 -1
  209. package/dist/tools-logic/store-repair.js.map +1 -1
  210. package/dist/tools-logic/supersession.d.ts +64 -3
  211. package/dist/tools-logic/supersession.d.ts.map +1 -1
  212. package/dist/tools-logic/supersession.js +155 -50
  213. package/dist/tools-logic/supersession.js.map +1 -1
  214. package/dist/types.d.ts +12 -1
  215. package/dist/types.d.ts.map +1 -1
  216. package/dist/types.js +1 -1
  217. package/dist/vector/embedding.d.ts +8 -0
  218. package/dist/vector/embedding.d.ts.map +1 -1
  219. package/dist/vector/embedding.js +8 -0
  220. package/dist/vector/embedding.js.map +1 -1
  221. package/package.json +1 -1
@@ -104,6 +104,7 @@
104
104
  * pass key on INSTEAD of `excerpt` when present.
105
105
  */
106
106
  import { type VerbatimKey } from "./drill-down.js";
107
+ import type { SemanticLegNote } from "../retrieval/semantic-leg.js";
107
108
  export interface RecallFeedback {
108
109
  id?: string;
109
110
  title?: string;
@@ -121,23 +122,40 @@ export interface SmartRecallInput {
121
122
  /** Bridge kill-switch (Wave 4). When false, no verbatim drill-down is attached.
122
123
  * Default true. */
123
124
  drilldown?: boolean;
125
+ /** fix4b (2026-09-12) — legacy multiplicative hot-window boost, explicit
126
+ * opt-in, default OFF (threaded to `QueryMemoryInput.freshnessBias` — see
127
+ * that field's doc comment for the full contract). Exists for the ONE
128
+ * audited caller whose downstream score floor was calibrated against
129
+ * boosted magnitudes (the CLI ambient-injection hook); every default
130
+ * surface gets the honest un-multiplied ranking, with no post-fusion
131
+ * freshness signal (measured product-behavior change, fix4b report). Local
132
+ * backend only — the remote (Supabase) backend has its own scoring and
133
+ * ignores this. */
134
+ freshnessBias?: boolean;
124
135
  }
125
136
  export interface SmartRecallResultItem {
126
137
  id: string;
127
138
  /** Primary/display source — whichever source's RRF pass inserted this
128
- * canonical entry first (palace, then journal, then insight). Kept
129
- * singular for backward compatibility with existing consumers.
130
- * "archive" (F4, 2026-07-31) is DIFFERENT from the other three: it never
139
+ * canonical entry first (palace, then journal, then insight, then
140
+ * corrections). Kept singular for backward compatibility with existing
141
+ * consumers.
142
+ * "corrections" (fix4 S1, 2026-09-11) is a real competing RRF tier —
143
+ * smart_recall now requests it by default (the S2-standard eval found
144
+ * 9/10 correction-homed golden facts unreachable because this surface
145
+ * never asked for the tier queryMemory() already had). ADDITIVE contract
146
+ * widening: existing consumers see a new possible string value on an
147
+ * already-string field, plus new result rows they previously never got.
148
+ * "archive" (F4, 2026-07-31) is DIFFERENT from the other four: it never
131
149
  * competes inside the RRF fusion — it is appended separately by
132
150
  * smartRecall() only when the fused top confidence from
133
- * palace/journal/insight is below medium (see the archive-fallback gate
134
- * below). */
135
- source: "palace" | "journal" | "insight" | "archive";
151
+ * palace/journal/insight/corrections is below medium (see the
152
+ * archive-fallback gate below). */
153
+ source: "palace" | "journal" | "insight" | "corrections" | "archive";
136
154
  /** Other sources that ALSO matched this same canonical memory (same
137
155
  * normalized excerpt) during RRF fusion. Present only when the item was
138
156
  * found in more than one source — see Fix 5 in the file header.
139
157
  * Never set for "archive" items — they are appended post-fusion. */
140
- alsoFoundIn?: Array<"palace" | "journal" | "insight" | "archive">;
158
+ alsoFoundIn?: Array<"palace" | "journal" | "insight" | "corrections" | "archive">;
141
159
  title: string;
142
160
  excerpt: string;
143
161
  score: number;
@@ -177,6 +195,56 @@ export interface SmartRecallResultItem {
177
195
  * W5a salvage visibility fix this field shares.
178
196
  */
179
197
  conflictsWith?: string[];
198
+ /**
199
+ * fix4 S2 (2026-09-11) — 1-hop graph-linked room slugs attached to the TOP
200
+ * result as metadata (replaces the old synthetic "↳ linked: <room>" stub
201
+ * ROWS, which burned 24/100 top-5 slots at the S2-standard baseline —
202
+ * see localRecallSearch's graph-walk comment). Attached to the FUSION-TIME
203
+ * rank-1 item, only when its room has graph edges to real on-disk rooms
204
+ * not already visible among the results, capped at 2 — the same signal
205
+ * the stubs carried, in a slot-free form. Review L5 (same day): the
206
+ * post-fusion Beta-feedback re-sort in smartRecall() can displace the
207
+ * carrier from rank 1, so a consumer must key on the FIELD, not on
208
+ * position — the same displacement class the old 0.6× stub rows had.
209
+ * Additive: absent everywhere else.
210
+ */
211
+ alsoLinked?: string[];
212
+ /**
213
+ * remote-fusion wave #24 (2026-09-09) — the raw `deriveSlug()`-shaped
214
+ * identity string (`sync.ts`'s `journal--${fileName}` /
215
+ * `palace--${room}--${fileName}`). Present on remote-origin items (passed
216
+ * through verbatim by `supabase/recall-backend.ts`'s `mapSemanticRows`/
217
+ * `mapFtsRows`); absent on local-origin items, which instead reconstruct
218
+ * an equivalent identity from `verbatimKey` inside `fuseRemoteWithLocal`
219
+ * (see that function's own doc comment) rather than populating this field
220
+ * — the field only ever needs to be READ by that one function, never
221
+ * written by the local pipeline. Purely additive; no other consumer reads
222
+ * it.
223
+ */
224
+ slug?: string;
225
+ /**
226
+ * remote-fusion wave #24 (2026-09-09) — set `true` on a LOCAL-origin item
227
+ * when `AGENT_RECALL_RECALL_FUSION=1` fusion found the SAME canonical
228
+ * memory in the remote backend's own results too (see
229
+ * `fuseRemoteWithLocal`). Deliberately a SEPARATE field from
230
+ * `alsoFoundIn`: that field's values are competing-TIER names
231
+ * (palace/journal/insight/archive) from the local pipeline's OWN internal
232
+ * RRF fusion, not a local-vs-remote BACKEND distinction — overloading it
233
+ * here would conflate two different fusion layers. Never set when the
234
+ * flag is off, fusion didn't run, or this item is remote-only.
235
+ */
236
+ foundInRemote?: boolean;
237
+ /**
238
+ * fix7 (2026-09-12, opt-in embeddings) — `true` ONLY on an item the
239
+ * semantic leg ORIGINATED (a candidate no lexical tier surfaced — the
240
+ * paraphrase class the leg exists for). Mirrors `foundInRemote`'s shape:
241
+ * a separate additive field, never overloading `alsoFoundIn` (whose
242
+ * values are competing-TIER names). Structurally absent whenever
243
+ * AGENT_RECALL_EMBEDDINGS is off (flag-off output stays byte-identical
244
+ * to fix4b — the same hard equivalence invariant recall_path carries for
245
+ * the remote-fusion flag).
246
+ */
247
+ foundBySemantic?: boolean;
180
248
  }
181
249
  /** A verbatim source attached when a low-confidence top hit was drilled into. */
182
250
  export interface BridgedSource {
@@ -189,11 +257,19 @@ export interface SmartRecallDegraded {
189
257
  backend: string;
190
258
  }
191
259
  /** Raw per-source candidate counts, captured BEFORE RRF fusion collapses
192
- * same-excerpt cross-source duplicates into one canonical entry (Fix 4/5). */
260
+ * same-excerpt cross-source duplicates into one canonical entry (Fix 4/5).
261
+ * fix4 S1 (2026-09-11): `corrections` added — additive field, matching the
262
+ * tier's promotion to a default competing source.
263
+ * fix4 unit-semantics note (review L4, same day): `palace` now counts
264
+ * DOCUMENTS (one-doc-one-vote, post-bestByDoc) and `journal` counts
265
+ * post-perSectionDedupe rows on this surface — both smaller than the old
266
+ * per-line counts for an identical store. Diagnostic-only field; no
267
+ * consumer treats it as a stable cross-version metric. */
193
268
  export interface CandidatesBySource {
194
269
  palace: number;
195
270
  journal: number;
196
271
  insight: number;
272
+ corrections: number;
197
273
  }
198
274
  export interface SmartRecallResult {
199
275
  query: string;
@@ -203,13 +279,56 @@ export interface SmartRecallResult {
203
279
  guidance?: string;
204
280
  /** Present when semantic backend timed out or errored and local fallback was used. */
205
281
  degraded?: SmartRecallDegraded;
282
+ /**
283
+ * fix6-locks (review LOW-3 — "never silent" doctrine): set when the
284
+ * feedback entries submitted WITH this call could not be persisted to
285
+ * feedback-log.json because another live process held the feedback-log
286
+ * lock past the timeout. Ranking for THIS call used the on-disk log;
287
+ * the submitted entries were dropped (resubmit to persist them).
288
+ */
289
+ feedback_log_skipped?: true;
206
290
  /** Verbatim sources attached for low-confidence top hits (Wave 4 bridge). */
207
291
  bridged?: BridgedSource[];
208
292
  /** Diagnostic: raw per-source candidate counts before RRF fusion (Fix 4/5).
209
293
  * Present only when results came from the local multi-source pipeline
210
294
  * (localRecallSearch); absent for remote/vector-backend results, which
211
- * don't have a "before fusion across 3 sources" notion. */
295
+ * don't have a "before fusion across 4 sources" notion. */
212
296
  candidates_by_source?: CandidatesBySource;
297
+ /**
298
+ * remote-fusion wave #24 (2026-09-09) — observability: which of the 3
299
+ * remote-configured-route outcomes produced `results`. ONLY set when
300
+ * `AGENT_RECALL_RECALL_FUSION=1` — kept OFF the default output entirely so
301
+ * flag-off behavior stays byte-identical to pre-wave (a hard equivalence
302
+ * invariant/test for this build; see `fuseRemoteWithLocal`'s own header).
303
+ * Absent for the `since`/pure-local-backend routes — this diagnostic only
304
+ * distinguishes the outcomes inside smartRecall()'s `isRemote` branch.
305
+ * - "fused": both local+remote answered non-empty and
306
+ * `fuseRemoteWithLocal()` ran.
307
+ * - "remote": remote answered NON-EMPTY (fusion did not run because
308
+ * local was empty) — `results` is genuinely remote's data.
309
+ * - "local" (pre-ship gate fix, 2026-09-09, F-1): remote answered (no
310
+ * timeout) but was EMPTY — including the both-empty case — so
311
+ * `results` is local data (possibly itself empty). Previously this
312
+ * branch ALSO reported "remote", regardless of which side's data was
313
+ * actually in `results` — a caller reading `recall_path` would see
314
+ * "remote" on a call where every item came from the local pipeline.
315
+ * Fixed: the label now reflects which side's data is actually
316
+ * returned, never a hardcoded value for "fusion didn't run".
317
+ * - "local-timeout": remote timed out/errored — same case `degraded` is
318
+ * set for.
319
+ */
320
+ recall_path?: "fused" | "remote" | "local" | "local-timeout";
321
+ /**
322
+ * fix7 (2026-09-12) — semantic-leg diagnostics (status/model/coverage),
323
+ * threaded from `QueryMemoryResult.semanticLeg`. ONLY present when the
324
+ * AGENT_RECALL_EMBEDDINGS opt-in was ON for this call AND the results
325
+ * came from the local pipeline — flag-off output stays byte-identical to
326
+ * fix4b (the recall_path/RECALL_FUSION equivalence convention). A
327
+ * degraded status ("index-missing", "model-unavailable", "index-corrupt",
328
+ * …) means lexical-only results with the reason carried here, never an
329
+ * error on the recall path.
330
+ */
331
+ semantic_leg?: SemanticLegNote;
213
332
  }
214
333
  /**
215
334
  * localRecallSearch — the core local search logic (palace + journal + insight).
@@ -234,6 +353,62 @@ export interface SmartRecallResult {
234
353
  * side-channel contract are UNCHANGED, since those are real, direct external
235
354
  * callers, not just smartRecall()'s own internals.
236
355
  */
237
- export declare function localRecallSearch(query: string, project: string | undefined, limit: number, since?: string): Promise<SmartRecallResultItem[]>;
356
+ export declare function localRecallSearch(query: string, project: string | undefined, limit: number, since?: string, freshnessBias?: boolean): Promise<SmartRecallResultItem[]>;
357
+ /**
358
+ * remote-fusion wave #24 (2026-09-09) — rank-based RRF fusion of the local
359
+ * keyword-search results and the remote (Supabase) semantic-search results.
360
+ *
361
+ * THE BUG THIS FIXES: today, `smartRecall()`'s remote path is
362
+ * `results = remoteResults.length > 0 ? remoteResults : localResults` — the
363
+ * moment the remote backend answers with ANY non-empty result set, the ENTIRE
364
+ * local result set is discarded, even a genuine local-only hit the remote
365
+ * backend simply missed (e.g. a very recent journal entry not yet
366
+ * embedded/synced to Supabase — sync is fire-and-forget, see `sync.ts`'s
367
+ * `syncToSupabase()`). This function merges instead of replacing.
368
+ *
369
+ * RANK-BASED, NEVER RAW-SCORE (see this file's header, Fix 1, and
370
+ * confidence.ts's own header for the bug class this avoids): local's native
371
+ * score scale (~0..0.12, a 3-tier internal RRF) and remote's (~0..0.049, a
372
+ * 3-leg internal RRF, itself already re-labeled through a THIRD "cosine"/
373
+ * "rrf-supabase" scale) are mutually incompatible — summing them directly
374
+ * would let one origin systematically dominate, exactly the
375
+ * cross-source-raw-score-averaging bug this codebase has already fixed once.
376
+ * So neither list's `.score` is read here — only each item's RANK (its
377
+ * position within its OWN already-sorted list) feeds the RRF contribution
378
+ * `1/(FUSION_RRF_K+rank)`, the identical formula `query-memory.ts`'s
379
+ * `applyRRF` uses one layer down (there: fusing TIERS; here: fusing
380
+ * BACKENDS).
381
+ *
382
+ * ON A DUP (same `fusionIdentity()`): the LOCAL item's fields ALWAYS win —
383
+ * richer (real trust-filtered annotations: `supersededBy`/`conflictsWith`,
384
+ * match-anchored excerpt, `verbatimKey` for the Bridge) — only `.score` is
385
+ * replaced (the summed RRF contribution, used for this array's own sort
386
+ * order) and `foundInRemote` is set. `.confidence`/`.calibrated` are NEVER
387
+ * recomputed here: they stay exactly whatever the SURVIVING item's own
388
+ * origin already computed them as at ITS OWN scoring time (local items:
389
+ * "rrf-local" scale, set in `localRecallSearch`; remote-only items: "cosine"/
390
+ * "rrf-supabase", set in `recall-backend.ts`'s row mappers) — this is the
391
+ * safest possible way to keep `calibrated` correctly scaled to each item's
392
+ * ORIGIN: never re-deriving it from the new blended rank-score at all means
393
+ * it can never be accidentally run through the WRONG scale (Risk #8,
394
+ * confidence.ts's own header — the exact hazard this satisfies rather than
395
+ * reintroduces).
396
+ *
397
+ * Both input lists are assumed already rank-sorted (best first) — exactly
398
+ * what `localRecallSearch()`'s and `SupabaseRecallBackend.search()`'s own
399
+ * return values already are. Each input list is ALSO assumed to already be
400
+ * internally deduped (unique `fusionIdentity()` within its own list) —
401
+ * true today for both origins (`SupabaseRecallBackend.search()` already
402
+ * dedupes by id then by normalized excerpt before returning;
403
+ * `localRecallSearch()`'s own pipeline dedupes via `fuseCanonical()`). If
404
+ * that precondition were ever violated, a second same-identity item WITHIN
405
+ * one origin's own list would fold into the FIRST-seen item's map entry
406
+ * (same-origin collision, not a cross-origin one) — for a remote-side
407
+ * collision this would incorrectly leave `foundInRemote` at its default
408
+ * `false` (the field's own contract is "found in the OTHER origin", not
409
+ * "found more than once"); not a live bug given the precondition above, but
410
+ * worth knowing if either origin's own de-dup is ever relaxed.
411
+ */
412
+ export declare function fuseRemoteWithLocal(localResults: SmartRecallResultItem[], remoteResults: SmartRecallResultItem[]): SmartRecallResultItem[];
238
413
  export declare function smartRecall(input: SmartRecallInput): Promise<SmartRecallResult>;
239
414
  //# sourceMappingURL=smart-recall.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"smart-recall.d.ts","sourceRoot":"","sources":["../../src/tools-logic/smart-recall.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwGG;AAWH,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAQlE,MAAM,WAAW,cAAc;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B;;qDAEiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;wBACoB;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX;;;;;;;kBAOc;IACd,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IACrD;;;yEAGqE;IACrE,WAAW,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,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