MCPcopy Create free account
hub / github.com/Noumena-Network/code / pullTeamMemory

Function pullTeamMemory

src/services/teamMemorySync/index.ts:768–865  ·  view source on GitHub ↗
(
  state: SyncState,
  options?: { skipEtagCache?: boolean },
)

Source from the content-addressed store, hash-verified

766 * Returns true if any files were updated.
767 */
768export async function pullTeamMemory(
769 state: SyncState,
770 options?: { skipEtagCache?: boolean },
771): Promise<{
772 success: boolean
773 filesWritten: number
774 /** Number of entries the server returned, regardless of whether they were written to disk. */
775 entryCount: number
776 notModified?: boolean
777 error?: string
778}> {
779 const skipEtagCache = options?.skipEtagCache ?? false
780 const startTime = Date.now()
781
782 if (!isUsingOAuth()) {
783 logPull(startTime, { success: false, errorType: 'no_oauth' })
784 return {
785 success: false,
786 filesWritten: 0,
787 entryCount: 0,
788 error: 'OAuth not available',
789 }
790 }
791
792 const repoSlug = await getGithubRepo()
793 if (!repoSlug) {
794 logPull(startTime, { success: false, errorType: 'no_repo' })
795 return {
796 success: false,
797 filesWritten: 0,
798 entryCount: 0,
799 error: 'No git remote found',
800 }
801 }
802
803 const etag = skipEtagCache ? null : state.lastKnownChecksum
804 const result = await fetchTeamMemory(state, repoSlug, etag)
805 if (!result.success) {
806 logPull(startTime, {
807 success: false,
808 errorType: result.errorType,
809 status: result.httpStatus,
810 })
811 return {
812 success: false,
813 filesWritten: 0,
814 entryCount: 0,
815 error: result.error,
816 }
817 }
818 if (result.notModified) {
819 logPull(startTime, { success: true, notModified: true })
820 return { success: true, filesWritten: 0, entryCount: 0, notModified: true }
821 }
822 if (result.isEmpty || !result.data) {
823 // Server has no data — clear stale serverChecksums so the next push
824 // doesn't skip entries it thinks the server already has.
825 state.serverChecksums.clear()

Callers 2

startTeamMemoryWatcherFunction · 0.85
syncTeamMemoryFunction · 0.85

Calls 11

logPullFunction · 0.85
getGithubRepoFunction · 0.85
fetchTeamMemoryFunction · 0.85
entriesMethod · 0.80
setMethod · 0.80
keysMethod · 0.80
isUsingOAuthFunction · 0.70
logForDebuggingFunction · 0.50
clearMemoryFileCachesFunction · 0.50
clearMethod · 0.45

Tested by

no test coverage detected