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

Function stampSyncedWithHealth

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

Source from the content-addressed store, hash-verified

3523 // reconnect re-syncs tools anyway); at worst the skipped
3524 // `tools_synced_at` stamp makes the next read re-attempt the sync.
3525 const stampSyncedWithHealth = (reason: string, health?: HealthCheckResult) =>
3526 findConnectionRow(ref).pipe(
3527 Effect.flatMap((fresh) =>
3528 fresh === null
3529 ? Effect.void
3530 : core
3531 .updateMany("connection", {
3532 where: (b: AnyCb) =>
3533 b.and(
3534 connectionWhere(b),
3535 b("updated_at", "=", fresh.updated_at),
3536 fresh.tools_synced_at == null
3537 ? b.isNull("tools_synced_at")
3538 : b("tools_synced_at", "=", fresh.tools_synced_at),
3539 ),
3540 set:
3541 oauthReauthRequiredFromProviderState(fresh.provider_state) !== null
3542 ? { tools_synced_at: Date.now() }
3543 : {
3544 tools_synced_at: Date.now(),
3545 last_health: health ?? toolSyncHealth(reason),
3546 updated_at: new Date(),
3547 },
3548 })
3549 .pipe(Effect.asVoid),
3550 ),
3551 );
3552
3553 // Defense in depth (and cleanup for rows created before the create-time
3554 // 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