fix: stabilize sentinel BuildKit evidence

This commit is contained in:
Codex
2026-07-13 16:25:28 +02:00
parent 58df3731b4
commit ca312ae714
5 changed files with 147 additions and 14 deletions
@@ -748,7 +748,7 @@ function envReuseForPipelineRun(namespace, name, taskRuns) {
const terminalRecords = contractTaskRuns.map(taskTerminalRecord).filter(Boolean);
const logErrors = [];
let logs = '';
for (const item of contractTaskRuns) {
for (const item of matching) {
const podName = item.status?.podName;
if (!podName) {
logErrors.push({ taskRun: item.metadata?.name || null, reason: 'pod-name-missing' });
@@ -792,6 +792,7 @@ function envReuseForPipelineRun(namespace, name, taskRuns) {
state.sourceObservation = state.artifact.sourceObservation;
state.collector = {
mode: state.source,
matchingTaskCount: matching.length,
contractTaskCount: contractTaskRuns.length,
terminalRecordCount: terminalRecords.length,
logErrorCount: logErrors.length,
@@ -1006,7 +1007,7 @@ const contractTaskRuns = taskRuns.filter((item) => taskTerminalRecord(item) !==
const terminalRecords = contractTaskRuns.map(taskTerminalRecord).filter(Boolean);
const logErrors = [];
let logText = '';
for (const item of contractTaskRuns) {
for (const item of taskRuns) {
const podName = item.status?.podName;
if (!podName) {
logErrors.push({ taskRun: item.metadata?.name || null, reason: 'pod-name-missing' });
@@ -1064,6 +1065,7 @@ out.firstBreak = diagnostic.firstBreak;
out.error = diagnostic.error;
out.collector = {
mode,
matchingTaskCount: taskRuns.length,
contractTaskCount: contractTaskRuns.length,
terminalRecordCount: terminalRecords.length,
logErrorCount: logErrors.length,
@@ -1701,6 +1703,10 @@ function breakAt(code, stage, reason) {
if (historyErrors.length > 0) breakAt('target-read-failed', 'target-read', historyErrors[0]?.error || historyErrors[0]?.stderr || 'target-side history read failed');
if (Object.keys(row).length === 0) breakAt('pipeline-run-not-found', 'pipeline-run', `PipelineRun ${process.env.UNIDESK_PAC_HISTORY_ID || '-'} was not found for the selected consumer`);
if (Object.keys(row).length > 0 && row.deliveryAuthorityEligible !== true) breakAt('pipeline-run-not-delivery-authority', 'pipeline-run', `PipelineRun is classified as ${row.deliveryClass || 'unknown'}; only an outer PaC event can drive delivery closeout`);
if (Object.keys(row).length > 0 && Object.keys(record(row.firstBreak)).length > 0) {
const typed = record(row.firstBreak);
breakAt(typed.code || 'pipeline-run-not-succeeded', typed.phase || typed.stage || 'pipeline-run', typed.reason || `PipelineRun terminal status is ${row.status || row.reason || 'unknown'}`);
}
if (Object.keys(row).length > 0 && row.status !== 'True') breakAt('pipeline-run-not-succeeded', 'pipeline-run', `PipelineRun terminal status is ${row.status || row.reason || 'unknown'}`);
if (Object.keys(row).length > 0 && Object.keys(sourceObservation).length === 0) breakAt('source-observation-missing', 'plan-artifacts', 'delivery plan structured evidence is missing');
if (sourceObservation.sourceMatched !== true) breakAt('source-observation-mismatch', 'plan-artifacts', 'delivery plan source commit does not match the selected PipelineRun');
@@ -1756,12 +1762,15 @@ const realRun = {
},
collector: {
mode: collector.mode || null,
matchingTaskCount: collector.matchingTaskCount ?? null,
contractTaskCount: collector.contractTaskCount ?? null,
terminalRecordCount: collector.terminalRecordCount ?? null,
logErrorCount: collector.logErrorCount ?? null,
logErrors: Array.isArray(collector.logErrors) ? collector.logErrors : [],
valuesPrinted: false,
},
traceId: row.traceId || null,
error: Object.keys(record(row.error)).length === 0 ? null : record(row.error),
firstBreak,
valuesPrinted: false,
};