MCPcopy
hub / github.com/CaviraOSS/OpenMemory / ver

Method ver

migrate/ver.js:11–39  ·  view source on GitHub ↗
(st)

Source from the content-addressed store, hash-verified

9 };
10 }
11 async ver(st) {
12 const w = [];
13 try {
14 console.log('[VERIFY] Checking memory count via API...');
15 const r = await fetch(`${this.u}/memory/search`, {
16 method: 'POST',
17 headers: this.h,
18 body: JSON.stringify({ query: '', limit: 10000 }),
19 });
20 if (!r.ok) {
21 return {
22 ok: false,
23 w: [`API verification unavailable: ${r.status}`],
24 };
25 }
26 const d = await r.json();
27 const mc = d.memories?.length || 0;
28 console.log(`[VERIFY] Found ${mc} memories in OpenMemory`);
29 if (Math.abs(mc - st.m) > st.m * 0.05)
30 w.push(`Memory count mismatch: expected ${st.m}, got ${mc}`);
31 console.log('[VERIFY] Checking for duplicates...');
32 const dups = await this.chkdup(d.memories || []);
33 if (dups > mc * 0.01)
34 w.push(`High duplicate rate: ${((dups / mc) * 100).toFixed(1)}%`);
35 return { ok: w.length === 0, w };
36 } catch (e) {
37 return { ok: false, w: [`Verification failed: ${e.message}`] };
38 }
39 }
40 async chkdup(mm) {
41 const h = new Set();
42 let d = 0;

Callers 1

runFunction · 0.95

Calls 1

chkdupMethod · 0.95

Tested by

no test coverage detected