pi-mega-compact 0.20.86 → 0.20.88

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 (34) hide show
  1. package/dist/config.js +9 -0
  2. package/dist/extensions/dashboard-server/routes-rag-settings-helpers.js +1 -0
  3. package/dist/extensions/mega-config.js +6 -0
  4. package/dist/extensions/mega-events/context-handler/injectionConfirm.fixture.js +63 -0
  5. package/dist/extensions/mega-events/context-handler/injectionConfirm.js +107 -0
  6. package/dist/extensions/mega-events/context-handler/triggerGuard.js +11 -17
  7. package/dist/extensions/mega-events/context-handler.js +17 -1
  8. package/dist/extensions/mega-pipeline/recall/impl.js +258 -0
  9. package/dist/extensions/mega-pipeline/recall.js +6 -253
  10. package/dist/src/config.js +9 -0
  11. package/dist/src/failback/floor.js +35 -0
  12. package/dist/src/recall/readonly.js +39 -0
  13. package/dist/src/recall/recall3wf.fixture.js +67 -0
  14. package/dist/src/recall/validator.js +99 -0
  15. package/dist/src/recall/vote.js +217 -0
  16. package/dist/src/store/sqlite/fts5-search.js +26 -0
  17. package/extensions/dashboard-server/routes-rag-settings-helpers.ts +1 -0
  18. package/extensions/mega-config-types.ts +5 -0
  19. package/extensions/mega-config.ts +6 -0
  20. package/extensions/mega-events/context-handler/injectionConfirm.fixture.ts +90 -0
  21. package/extensions/mega-events/context-handler/injectionConfirm.ts +168 -0
  22. package/extensions/mega-events/context-handler/triggerGuard.ts +14 -22
  23. package/extensions/mega-events/context-handler.ts +16 -1
  24. package/extensions/mega-pipeline/recall/impl.ts +312 -0
  25. package/extensions/mega-pipeline/recall.ts +10 -306
  26. package/package.json +1 -1
  27. package/src/config.ts +12 -0
  28. package/src/failback/floor.ts +71 -0
  29. package/src/failback/types.ts +44 -0
  30. package/src/recall/readonly.ts +57 -0
  31. package/src/recall/recall3wf.fixture.ts +87 -0
  32. package/src/recall/validator.ts +137 -0
  33. package/src/recall/vote.ts +240 -0
  34. package/src/store/sqlite/fts5-search.ts +40 -0
@@ -13,6 +13,7 @@
13
13
  */
14
14
 
15
15
  import type { DatabaseSync } from "node:sqlite";
16
+ import { listCheckpoints } from "./checkpoints.js";
16
17
 
17
18
  export interface Fts5Hit {
18
19
  /** checkpoint id (chkpt_001 etc.) from the context_chunks_trgm row. */
@@ -88,3 +89,42 @@ export function fts5SearchScoped(
88
89
  // No session filter — plain FTS5 search across all sessions.
89
90
  return fts5Search(query, reader, limit);
90
91
  }
92
+
93
+ /** A hydrated FTS5 hit: the id + BM25 score joined with its checkpoint summary. */
94
+ export interface HydratedFts5Hit {
95
+ /** checkpoint id the FTS5 row referred to. */
96
+ checkpointId: string;
97
+ /** BM25 relevance score carried over from the FTS5 row. */
98
+ score: number;
99
+ /** The joined checkpoint's summary text (content basis for L0 digest dedup). */
100
+ summary: string;
101
+ }
102
+
103
+ /**
104
+ * Hydrate FTS5 hits (which only carry checkpoint `id` + BM25 `score`, with NO
105
+ * checkpoint object) by joining against the real stored checkpoints. Mirrors the
106
+ * private `hydrateHits` in tieredRouter.ts (listCheckpoints → Map on
107
+ * checkpointId → join, dropping ids with no checkpoint).
108
+ *
109
+ * The joined `summary` is returned alongside the id because the 3WF-3 voter
110
+ * dedups candidates on the L0 CONTENT digest — hashing the id string instead
111
+ * would be a no-op tier (ids are already unique), silently disabling the check.
112
+ *
113
+ * @param hits Raw Fts5Hit rows (id + BM25 score).
114
+ * @param sessionId Session scope used to fetch the checkpoint set.
115
+ * @param stateDir On-disk state dir for the sync store.
116
+ */
117
+ export function hydrateFts5Hits(
118
+ hits: Fts5Hit[],
119
+ sessionId: string,
120
+ stateDir: string,
121
+ ): HydratedFts5Hit[] {
122
+ const cps = listCheckpoints(sessionId, stateDir);
123
+ const cpMap = new Map(cps.map((cp) => [cp.checkpointId, cp]));
124
+ const out: HydratedFts5Hit[] = [];
125
+ for (const h of hits) {
126
+ const cp = cpMap.get(h.id);
127
+ if (cp) out.push({ checkpointId: h.id, score: h.score, summary: cp.summary });
128
+ }
129
+ return out;
130
+ }