MCPcopy
hub / github.com/Doorman11991/smallcode / recordEvidence

Function recordEvidence

src/memory/evidence.js:160–184  ·  view source on GitHub ↗

* Persist evidence to a memory store. Returns the stored memory object or * null if storage failed or trace was uninteresting. * * @param {object} memoryStore - The MemoryStore instance from budget-aware-mcp * @param {object} trace - Trace from TraceRecorder * @param {object} options

(memoryStore, trace, options = {})

Source from the content-addressed store, hash-verified

158 * @param {object} options
159 */
160function recordEvidence(memoryStore, trace, options = {}) {
161 if (!memoryStore || typeof memoryStore.remember !== 'function') return null;
162 if (process.env.SMALLCODE_EVIDENCE_DISABLE === 'true') return null;
163 const summary = summarizeTrace(trace, options);
164 if (!summary) return null;
165
166 try {
167 // budget-aware-mcp signature: remember({ type, title, content, tags, files, symbols })
168 // Local fallback memory.js signature: remember(type, title, content, opts)
169 // We try the object form first; on TypeError fall back to positional.
170 let result;
171 try {
172 result = memoryStore.remember(summary);
173 } catch (e) {
174 // Positional fallback
175 result = memoryStore.remember(summary.type, summary.title, summary.content, {
176 tags: summary.tags,
177 files: summary.files,
178 });
179 }
180 return result;
181 } catch {
182 return null;
183 }
184}
185
186// ─── Helpers ───────────────────────────────────────────────────────────────
187

Callers 1

runAgentLoopFunction · 0.85

Calls 2

summarizeTraceFunction · 0.85
rememberMethod · 0.80

Tested by

no test coverage detected