fix(cicd): expose reconcile timeline state summary

This commit is contained in:
Codex
2026-07-04 02:23:49 +00:00
parent bc681eddf8
commit 5e083e5fc6
4 changed files with 83 additions and 0 deletions
@@ -97,6 +97,7 @@ function compactStateText(text, includeCommand) {
timings: compactTimings(state.timings),
warnings: arrayStrings(state.warnings).slice(0, 6),
stateFormat: stringOrNull(state.stateFormat),
rawStateDiagnostic: rawStateDiagnostic(state, text),
};
if (includeCommand) compact.command = compactCommand(state.command);
return compact;
@@ -119,10 +120,73 @@ function compactCommand(command) {
exitCode: numberOrNull(value.exitCode),
timedOut: value.timedOut === true,
statusAuthority: stringOrNull(value.statusAuthority),
reconcileTimeline: compactReconcileTimeline(value.reconcileTimeline),
parsedDownstreamCliOutput: false,
};
}
function compactReconcileTimeline(reconcileTimeline) {
const value = recordOrNull(reconcileTimeline);
if (value === null) return null;
const steps = arrayRecords(value.steps).slice(-16).map((step) => ({
follower: stringOrNull(step.follower),
step: stringOrNull(step.step),
status: stringOrNull(step.status),
startedAt: stringOrNull(step.startedAt),
finishedAt: stringOrNull(step.finishedAt),
elapsedMs: numberOrNull(step.elapsedMs),
observedSha: stringOrNull(step.observedSha),
targetSha: stringOrNull(step.targetSha),
phase: stringOrNull(step.phase),
pipelineRun: stringOrNull(step.pipelineRun),
object: stringOrNull(step.object),
message: stringOrNull(step.message),
reason: stringOrNull(step.reason),
exitCode: numberOrNull(step.exitCode),
}));
return {
startedAt: stringOrNull(value.startedAt),
finishedAt: stringOrNull(value.finishedAt),
elapsedMs: numberOrNull(value.elapsedMs),
controller: value.controller === true,
dryRun: value.dryRun === true,
confirm: value.confirm === true,
wait: value.wait === true,
followerCount: numberOrNull(value.followerCount),
followers: arrayStrings(value.followers).slice(0, 8),
bounded: true,
omittedStepCount: Math.max(0, arrayRecords(value.steps).length - steps.length),
steps,
};
}
function rawStateDiagnostic(state, text) {
const command = recordOrNull(state.command);
const reconcileTimeline = recordOrNull(command?.reconcileTimeline);
return {
bounded: true,
valueBytes: Buffer.byteLength(text, "utf8"),
hasCommand: command !== null,
commandBytes: jsonBytes(command),
hasReconcileTimeline: reconcileTimeline !== null,
reconcileTimelineBytes: jsonBytes(reconcileTimeline),
reconcileTimelineStepCount: reconcileTimeline === null ? 0 : arrayRecords(reconcileTimeline.steps).length,
reconcileTimelineStartedAt: stringOrNull(reconcileTimeline?.startedAt),
reconcileTimelineFinishedAt: stringOrNull(reconcileTimeline?.finishedAt),
reconcileTimelineElapsedMs: numberOrNull(reconcileTimeline?.elapsedMs),
missingReason: reconcileTimeline === null ? command === null ? "command missing" : "command.reconcileTimeline missing" : null,
};
}
function jsonBytes(value) {
if (value === null) return null;
try {
return Buffer.byteLength(JSON.stringify(value), "utf8");
} catch {
return null;
}
}
function compactCloseout(closeout) {
const value = recordOrNull(closeout);
if (value === null) return null;