feat(cicd): add bounded pipeline evidence

This commit is contained in:
Codex
2026-07-04 02:40:43 +00:00
parent bc681eddf8
commit 3886bbbb2c
13 changed files with 264 additions and 1 deletions
+28
View File
@@ -110,6 +110,7 @@ function renderStatusHuman(payload: Record<string, unknown>, _options: ParsedOpt
const next = asOptionalRecord(payload.next);
const errors = Array.isArray(payload.errors) ? payload.errors : [];
const timingRows = followers.flatMap(timingRowsForFollower).slice(0, 48);
const evidenceRows = followers.flatMap(evidenceRowsForFollower).slice(0, 48);
const reconcileRows = followers.flatMap(reconcileRowsForFollower).slice(0, 48);
return [
`CI/CD BRANCH-FOLLOWER STATUS (${payload.ok === false ? "degraded" : "ok"})`,
@@ -121,6 +122,7 @@ function renderStatusHuman(payload: Record<string, unknown>, _options: ParsedOpt
"",
table(["FOLLOWER", "PHASE", "ADAPTER", "OBSERVED", "TARGET", "TRIGGERED", "SUCCEEDED", "IN_FLIGHT", "BUDGET", "MESSAGE"], rows),
timingRows.length === 0 ? "" : `\nSTAGE TIMINGS\n${table(["FOLLOWER", "STAGE", "STATUS", "SECONDS", "BUDGET", "OBJECT"], timingRows)}`,
evidenceRows.length === 0 ? "" : `\nEVIDENCE\n${table(["FOLLOWER", "TYPE", "STATUS", "DETAIL", "OBJECT"], evidenceRows)}`,
reconcileRows.length === 0 ? "" : `\nRECONCILE TIMELINE\n${table(["FOLLOWER", "STEP", "STATUS", "SECONDS", "STARTED", "OBJECT"], reconcileRows)}`,
errors.length === 0 ? "" : `\nERRORS\n${errors.map((item) => `- ${item}`).join("\n")}`,
"",
@@ -233,6 +235,28 @@ function reconcileRowsFromRunOnce(payload: Record<string, unknown>, followers: R
return followers.flatMap(reconcileRowsForFollower);
}
function evidenceRowsForFollower(item: Record<string, unknown>): unknown[][] {
const evidence = asOptionalRecord(item.evidence);
if (evidence === null) return [];
const rows: unknown[][] = [];
rows.push([item.id, "pipelineRef", "observed", stringOrNull(evidence.pipelineRunRefName) ?? "-", stringOrNull(item.pipelineRun) ?? "-"]);
const pipeline = asOptionalRecord(evidence.pipeline);
if (pipeline !== null) {
const runtimeReady = asOptionalRecord(asOptionalRecord(pipeline.spec)?.runtimeReadyTask);
const when = arrayRecords(runtimeReady?.when)[0];
rows.push([
item.id,
"pipelineSpec",
runtimeReady?.present === true ? "runtime-ready-present" : "runtime-ready-absent",
when === undefined ? "-" : `${stringOrNull(when.input) ?? "-"} ${stringOrNull(when.operator) ?? "-"} ${arrayText(when.values) || "-"}`,
stringOrNull(asOptionalRecord(pipeline.metadata)?.name) ?? "-",
]);
}
const refresh = asOptionalRecord(evidence.refresh);
if (refresh !== null) rows.push([item.id, "refresh", stringOrNull(refresh.status) ?? "-", `${shortSha(stringOrNull(refresh.sourceCommit))}/${boolMatch(refresh.pipelineRefMatches)}/${boolMatch(refresh.pipelineSpecMatches)}`, stringOrNull(refresh.pipeline) ?? "-"]);
return rows;
}
function reconcileRowsForFollower(item: Record<string, unknown>): unknown[][] {
return reconcileRowsForTimeline(asOptionalRecord(item.reconcileTimeline), stringOrNull(item.id));
}
@@ -261,6 +285,10 @@ function formatSeconds(value: number | null): string {
return value === null ? "-" : `${value}s`;
}
function boolMatch(value: unknown): string {
return value === true ? "match" : value === false ? "mismatch" : "-";
}
function asOptionalRecord(value: unknown): Record<string, unknown> | null {
return typeof value === "object" && value !== null && !Array.isArray(value) ? value as Record<string, unknown> : null;
}