MCPcopy
hub / github.com/KeygraphHQ/shannon / runPreflightValidation

Function runPreflightValidation

apps/worker/src/temporal/activities.ts:442–503  ·  view source on GitHub ↗
(input: ActivityInput)

Source from the content-addressed store, hash-verified

440 * NOT using runAgentActivity — preflight doesn't run an agent via the SDK.
441 */
442export async function runPreflightValidation(input: ActivityInput): Promise<void> {
443 const startTime = Date.now();
444 const attemptNumber = Context.current().info.attempt;
445
446 const heartbeatInterval = setInterval(() => {
447 const elapsed = Math.floor((Date.now() - startTime) / 1000);
448 heartbeat({ phase: 'preflight', elapsedSeconds: elapsed, attempt: attemptNumber });
449 }, HEARTBEAT_INTERVAL_MS);
450
451 try {
452 const logger = createActivityLogger();
453 logger.info('Running preflight validation...', { attempt: attemptNumber });
454
455 const result = await runPreflightChecks(
456 input.webUrl,
457 input.repoPath,
458 input.configPath,
459 logger,
460 input.apiKey,
461 input.providerConfig,
462 );
463
464 if (isErr(result)) {
465 const classified = classifyErrorForTemporal(result.error);
466 const message = truncateErrorMessage(result.error.message);
467
468 if (classified.retryable) {
469 const failure = ApplicationFailure.create({
470 message,
471 type: classified.type,
472 details: [{ phase: 'preflight', attemptNumber, elapsed: Date.now() - startTime }],
473 });
474 truncateStackTrace(failure);
475 throw failure;
476 } else {
477 const failure = ApplicationFailure.nonRetryable(message, classified.type, [
478 { phase: 'preflight', attemptNumber, elapsed: Date.now() - startTime },
479 ]);
480 truncateStackTrace(failure);
481 throw failure;
482 }
483 }
484
485 logger.info('Preflight validation passed');
486 } catch (error) {
487 if (error instanceof ApplicationFailure) {
488 throw error;
489 }
490
491 const classified = classifyErrorForTemporal(error);
492 const rawMessage = error instanceof Error ? error.message : String(error);
493 const message = truncateErrorMessage(rawMessage);
494
495 const failure = ApplicationFailure.nonRetryable(message, classified.type, [
496 { phase: 'preflight', attemptNumber, elapsed: Date.now() - startTime },
497 ]);
498 truncateStackTrace(failure);
499 throw failure;

Callers

nothing calls this directly

Calls 7

createActivityLoggerFunction · 0.85
runPreflightChecksFunction · 0.85
isErrFunction · 0.85
classifyErrorForTemporalFunction · 0.85
truncateErrorMessageFunction · 0.85
truncateStackTraceFunction · 0.85
infoMethod · 0.65

Tested by

no test coverage detected