MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / writeSessionFacts

Function writeSessionFacts

packages/node-runtime/src/services/contacts/compute.ts:403–430  ·  view source on GitHub ↗
(
  adapter: SessionRuntimeAdapter,
  sessionId: string,
  timeRange: ContactsTimeRangeState,
  factsCache: ContactsFactsCacheContext | null,
  facts: ContactsSessionFacts,
  expectedDbVersion: string
)

Source from the content-addressed store, hash-verified

401}
402
403function writeSessionFacts(
404 adapter: SessionRuntimeAdapter,
405 sessionId: string,
406 timeRange: ContactsTimeRangeState,
407 factsCache: ContactsFactsCacheContext | null,
408 facts: ContactsSessionFacts,
409 expectedDbVersion: string
410): void {
411 if (!factsCache) return
412 const dbVersion = getSessionDbVersion(adapter, sessionId)
413 if (dbVersion !== expectedDbVersion) {
414 appLogger.debug('contacts', 'skipped contacts session facts cache write because db version changed', {
415 sessionId,
416 })
417 return
418 }
419 writeCachedContactsSessionFacts(
420 sessionId,
421 factsCache.dir,
422 buildContactsSessionFactsCacheKey(CONTACTS_ALGORITHM_VERSION, timeRange),
423 dbVersion,
424 facts
425 )
426 writeCachedContactsSessionLatest(sessionId, factsCache.dir, factsCache.latestKey, dbVersion, {
427 latestMessageTs: facts.latestMessageTs,
428 })
429 factsCache.stats.writes += 2
430}
431
432function getSessionDbVersion(adapter: SessionRuntimeAdapter, sessionId: string): string {
433 return getDbFileVersion(adapter.getDbPath(sessionId))

Callers 1

getSessionFactsFunction · 0.70

Calls 5

getSessionDbVersionFunction · 0.70
debugMethod · 0.45

Tested by

no test coverage detected