MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / writeLatestFacts

Function writeLatestFacts

packages/node-runtime/src/services/contacts/compute.ts:363–380  ·  view source on GitHub ↗
(
  adapter: SessionRuntimeAdapter,
  sessionId: string,
  factsCache: ContactsFactsCacheContext | null,
  data: ContactsSessionLatestFacts,
  expectedDbVersion: string
)

Source from the content-addressed store, hash-verified

361}
362
363function writeLatestFacts(
364 adapter: SessionRuntimeAdapter,
365 sessionId: string,
366 factsCache: ContactsFactsCacheContext | null,
367 data: ContactsSessionLatestFacts,
368 expectedDbVersion: string
369): void {
370 if (!factsCache) return
371 const dbVersion = getSessionDbVersion(adapter, sessionId)
372 if (dbVersion !== expectedDbVersion) {
373 appLogger.debug('contacts', 'skipped contacts latest facts cache write because db version changed', {
374 sessionId,
375 })
376 return
377 }
378 writeCachedContactsSessionLatest(sessionId, factsCache.dir, factsCache.latestKey, dbVersion, data)
379 factsCache.stats.writes++
380}
381
382function readSessionFacts(
383 sessionId: string,

Callers 1

Calls 3

getSessionDbVersionFunction · 0.70
debugMethod · 0.45

Tested by

no test coverage detected