Merge pull request #1508 from pikasTech/fix/1499-hwlab-pipeline-evidence

feat: add bounded branch-follower pipeline evidence
This commit is contained in:
Lyon
2026-07-04 10:56:04 +08:00
committed by GitHub
13 changed files with 287 additions and 3 deletions
+36
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);
const rawStateRows = followers.flatMap(rawStateRowsForFollower).slice(0, 24);
return [
@@ -122,6 +123,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)}`,
rawStateRows.length === 0 ? "" : `\nRAW STATE DIAGNOSTIC\n${table(["FOLLOWER", "STATE_BYTES", "COMMAND", "TIMELINE", "STEPS", "TIMELINE_BYTES", "REASON"], rawStateRows)}`,
errors.length === 0 ? "" : `\nERRORS\n${errors.map((item) => `- ${item}`).join("\n")}`,
@@ -235,6 +237,36 @@ 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);
rows.push([
item.id,
"refresh",
refresh === null ? "missing" : stringOrNull(refresh.status) ?? "-",
refresh === null
? stringOrNull(evidence.refreshBoundedReason) ?? "-"
: `${shortSha(stringOrNull(refresh.sourceCommit))}/${boolMatch(refresh.pipelineRefMatches)}/${boolMatch(refresh.pipelineSpecMatches)}`,
refresh === null ? "-" : stringOrNull(refresh.pipeline) ?? "-",
]);
return rows;
}
function reconcileRowsForFollower(item: Record<string, unknown>): unknown[][] {
return reconcileRowsForTimeline(asOptionalRecord(item.reconcileTimeline), stringOrNull(item.id));
}
@@ -277,6 +309,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;
}