MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / stampSyncedWithHealth

Function stampSyncedWithHealth

packages/core/sdk/src/executor.ts:3588–3614  ·  view source on GitHub ↗
(reason: string, health?: HealthCheckResult)

Source from the content-addressed store, hash-verified

3586 // reconnect re-syncs tools anyway); at worst the skipped
3587 // `tools_synced_at` stamp makes the next read re-attempt the sync.
3588 const stampSyncedWithHealth = (reason: string, health?: HealthCheckResult) =>
3589 findConnectionRow(ref).pipe(
3590 Effect.flatMap((fresh) =>
3591 fresh === null
3592 ? Effect.void
3593 : core
3594 .updateMany("connection", {
3595 where: (b: AnyCb) =>
3596 b.and(
3597 connectionWhere(b),
3598 b("updated_at", "=", fresh.updated_at),
3599 fresh.tools_synced_at == null
3600 ? b.isNull("tools_synced_at")
3601 : b("tools_synced_at", "=", fresh.tools_synced_at),
3602 ),
3603 set:
3604 oauthReauthRequiredFromProviderState(fresh.provider_state) !== null
3605 ? { tools_synced_at: Date.now() }
3606 : {
3607 tools_synced_at: Date.now(),
3608 last_health: health ?? toolSyncHealth(reason),
3609 updated_at: new Date(),
3610 },
3611 })
3612 .pipe(Effect.asVoid),
3613 ),
3614 );
3615
3616 // Defense in depth (and cleanup for rows created before the create-time
3617 // guard, or emptied by an external edit): a credentialed non-OAuth

Callers 1

Calls 4

findConnectionRowFunction · 0.85
connectionWhereFunction · 0.85
toolSyncHealthFunction · 0.85

Tested by

no test coverage detected