feat(ql3): reconcile legacy shadow runs on startup

This commit is contained in:
whyour
2026-08-18 09:26:12 +08:00
parent 1ff5aed844
commit 6cb9a075d7
12 changed files with 1691 additions and 8 deletions
@@ -0,0 +1,71 @@
import type {
ExecutionOrigin,
RunAttemptStatus,
RunStatus,
} from '../domain/run';
export const MAX_LEGACY_SHADOW_STARTUP_BATCH_SIZE = 64;
export const MAX_LEGACY_SHADOW_STARTUP_EVIDENCE = 8;
export interface LegacyShadowStartupCursor {
createdAtMs: number;
runId: string;
}
export interface LegacyShadowStartupAttempt {
attemptId: string;
status: RunAttemptStatus;
pid?: number;
logArtifactId?: string;
createdAtMs: number;
startedAtMs?: number;
}
export interface LegacyShadowStartupCandidate {
runId: string;
legacyCronId?: number;
origin: ExecutionOrigin;
runStatus: RunStatus;
createdAtMs: number;
activeAttemptCount: number;
attempt?: LegacyShadowStartupAttempt;
}
export interface LegacyShadowStartupPage {
candidates: readonly LegacyShadowStartupCandidate[];
truncated: boolean;
nextCursor?: LegacyShadowStartupCursor;
}
export type LegacyRunningInstanceOutcome =
| 'running'
| 'succeeded'
| 'failed'
| 'stopped';
export interface LegacyRunningInstanceEvidence {
pid?: number;
logArtifactId?: string;
startedAtMs: number;
finishedAtMs?: number;
outcome: LegacyRunningInstanceOutcome;
exitCode?: number;
}
export interface LegacyRunningInstanceEvidencePage {
evidence: readonly LegacyRunningInstanceEvidence[];
truncated: boolean;
}
export interface LegacyShadowStartupRecoverySource {
listCandidates(options: {
origins: readonly ExecutionOrigin[];
cursor?: LegacyShadowStartupCursor;
limit?: number;
}): Promise<LegacyShadowStartupPage>;
listRunningInstanceEvidence(options: {
legacyCronId: number;
limit?: number;
}): Promise<LegacyRunningInstanceEvidencePage>;
}