MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / getOwnerConfig

Function getOwnerConfig

services/security-sync/src/sync.ts:277–405  ·  view source on GitHub ↗
(
  db: WorkerDb,
  owner: SecurityReviewOwner
)

Source from the content-addressed store, hash-verified

275
276function toSyncRunProgress(
277 runId: string,
278 result: SyncResult,
279 completedRepos: string[],
280 chunkIndex: number,
281 noProgressChunks: number
282): SyncRunProgressWrite {
283 return {
284 runId,
285 completedRepos,
286 staleRepos: result.staleRepos,
287 authInvalidRepos: result.authInvalidRepos,
288 synced: result.synced,
289 errors: result.errors,
290 skipped: result.skipped,
291 authInvalid: result.authInvalid,
292 reauthRequired: result.reauthRequired,
293 noProgressChunks,
294 chunkIndex,
295 };
296}
297
298function readLastCompletedRunId(runtimeState: Record<string, unknown>): string | null {
299 const value = runtimeState.last_completed_run_id;
300 return typeof value === 'string' ? value : null;
301}
302
303function readSyncRunRunId(runtimeState: Record<string, unknown>): string | null {
304 const value = runtimeState.sync_run;
305 if (
306 value &&
307 typeof value === 'object' &&
308 typeof (value as { runId?: unknown }).runId === 'string'
309 ) {
310 return (value as { runId: string }).runId;
311 }
312 return null;
313}
314
315type SyncLeaseReadOutcome =
316 | { kind: 'completed' }
317 | { kind: 'stale_chunk'; holderRunId: string | null; holderChunkIndex: number | null }
318 | { kind: 'superseded'; holderRunId: string | null; holderChunkIndex: number | null };
319
320/**
321 * Classifies a runtime_state read that did not acquire the lease. `completed`
322 * means this run already finished. `stale_chunk` means a newer chunk of this
323 * same run holds the lease, or no different run id is visible at all (the lease
324 * vanished in a millisecond race). `superseded` means a different run id is
325 * actually visible on the lease or the cursor.
326 */
327function classifySyncLeaseRead(
328 runtimeState: Record<string, unknown>,
329 runId: string,
330 chunkIndex: number
331): SyncLeaseReadOutcome {
332 if (readLastCompletedRunId(runtimeState) === runId) return { kind: 'completed' };
333 const parsedLease = SyncLeaseSchema.safeParse(runtimeState.sync_lease);
334 const lease = parsedLease.success ? parsedLease.data : null;

Callers 1

syncOwnerFunction · 0.85

Calls 7

ownerFilterFunction · 0.85
integrationOwnerFilterFunction · 0.85
isOrgOwnerFunction · 0.85
analysisOwnerStateFilterFunction · 0.85
hasMethod · 0.80
limitMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected