← Public packages
@kody/kody-factory
Forkable multi-project software factory: signals, priority queue, project UI, sweep job. Agent runners and Sentry reach it by events.
Files
import type { RunnerOs } from './shared.ts'
export type RunSummary = {
id: number
workflowId: number
workflowName: string
event: string
headBranch: string
headSha: string
status: string
conclusion: string | null
runAttempt: number
createdAt: string
runStartedAt: string
updatedAt: string
prNumbers: number[]
}
export type StepSummary = {
name: string
conclusion: string | null
startedAt: string | null
completedAt: string | null
}
export type JobSummary = {
id: number
runId: number
name: string
conclusion: string | null
status: string
createdAt: string | null
startedAt: string | null
completedAt: string | null
labels: string[]
runAttempt: number
steps: StepSummary[]
}
export type CacheEntry = {
key: string
sizeBytes: number
createdAt: string
lastAccessedAt: string
ref: string
}
export type WorkflowInfo = {
id: number
name: string
path: string
state: string
/** Runs created in the window (GitHub total_count). */
totalInWindow: number
/** Runs kept for analysis: default branch pushes and PR / merge queue runs. */
runs: RunSummary[]
/** Multiplier from listed runs to runs in the window (1 unless only a sample page was listed). */
listingScale: number
/** Raw workflow file text checks (null when not fetched). */
file: { hasPullRequestPaths: boolean; hasConcurrency: boolean; cancelInProgress: boolean } | null
}
export type BillableTiming = Partial<Record<string, { total_ms?: number; jobs?: number }>>
export type Dataset = {
repo: string
defaultBranch: string
since: string
until: string
workflows: WorkflowInfo[]
/** Latest-attempt jobs by run id (sampled runs only). */
jobsByRun: Record<string, JobSummary[]>
/** Jobs of the attempt before the latest, for reruns, by run id. */
previousAttemptJobs: Record<string, JobSummary[]>
timing: Record<string, BillableTiming>
caches: CacheEntry[] | null
/** Changed file paths by PR number (sampled PRs only). */
prFiles: Record<string, string[]>
apiCalls: number
maxApiCalls: number
notes: string[]
}
export type Percentiles = { p50: number; p90: number; n: number }
export type JobMetrics = {
key: string
workflow: string
job: string
os: RunnerOs
/** A short job that only reports other jobs' results. */
isGate: boolean
samples: number
/** Share of sampled workflow runs in which this job ran (0..1). */
presence: number
durationMin: Percentiles
queueMin: Percentiles
failures: number
soleFailures: number
soleFailuresFixedByCommit: number
soleFailuresPassedOnRerun: number
flakyFailures: number
alwaysPassed: boolean
/** Share of sampled runs where this job alone caught a problem a later commit fixed. */
catchRate: number
steps: Array<{ name: string; p50Min: number; n: number }>
}
export type WorkflowMetrics = {
id: number
name: string
path: string
runsInWindow: number
analyzedRuns: number
sampledRuns: number
events: Record<string, number>
conclusions: Record<string, number>
durationMin: Percentiles
rerunRate: number
flakyRate: number
flakyShas: number
supersededRuns: number
supersededMinutesPerWeek: number
runnerMinutesPerRun: number
runnerMinutesPerWeek: Record<RunnerOs, number>
file: WorkflowInfo['file']
}
export type CriticalPath = {
workflow: string
samples: number
chain: Array<{ job: string; queueP50Min: number; durationP50Min: number }>
totalP50Min: number
totalP90Min: number
}
export type Metrics = {
repo: string
defaultBranch: string
since: string
until: string
apiCalls: number
workflows: WorkflowMetrics[]
jobs: JobMetrics[]
runnerMinutesPerWeek: Record<RunnerOs, number> & { total: number; billableEquivalent: number }
billedMinutesPerWeek: Record<string, number | string> & { total: number; source: string }
prTimeToGreenMin: Percentiles & { lastWorkflow: Record<string, number> }
criticalPath: CriticalPath | null
caches: {
visible: boolean
entries: number
sizeMb: number
createdInWindow: number
reusedRate: number
byPrefix: Array<{ prefix: string; entries: number; reusedRate: number; sizeMb: number }>
}
setupSteps: Array<{ workflow: string; job: string; step: string; p50Min: number; os: RunnerOs }>
duplicates: Array<{ workflow: string; step: string; jobs: number; minutesPerRun: number; minutesPerWeek: number }>
coFailing: Array<{ workflow: string; jobs: string[]; failures: number }>
docsOnlyPrs: { sampled: number; docsOnly: number }
notes: string[]
}
export type ConfidenceEffect = 'none' | 'reduces'
/** `work`: safe win, a factory work card. `recommend`: trades coverage, a Needs-you card for the owner. */
export type Lane = 'work' | 'recommend'
export type Opportunity = {
id: string
kind:
| 'cache-setup'
| 'dedupe-setup'
| 'split-critical-path'
| 'cancel-in-progress'
| 'path-filter-docs'
| 'fix-flaky'
| 'speed-up-step'
| 'drop-redundant-variant'
| 'defer-zero-catch-job'
title: string
workflow: string
job: string | null
evidence: string
change: string
minutesSavedPerPr: number
runnerMinutesSavedPerWeek: number
billedMinutesSavedPerWeek: number
confidenceEffect: ConfidenceEffect
needsWorkflowEdit: boolean
/** Metric to watch after the change ships, e.g. `job:<key>:p50`. */
metricKey: string
baseline: number
}
export type RankedOpportunity = Opportunity & {
lane: Lane
deterministicScore: number
jevScore: number | null
jevCoverage: ConfidenceEffect | null
score: number
worthChanging: boolean
}