From 2f602801e42c052af1b7745724b30f51342a5d85 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 14 Jun 2026 06:59:52 +0000 Subject: [PATCH] fix: allow hwlab v03 control-plane rerun --- scripts/src/hwlab-g14.ts | 51 ++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/scripts/src/hwlab-g14.ts b/scripts/src/hwlab-g14.ts index 7ff0df47..2c794bd9 100644 --- a/scripts/src/hwlab-g14.ts +++ b/scripts/src/hwlab-g14.ts @@ -129,6 +129,7 @@ interface G14ControlPlaneOptions { dryRun: boolean; confirm: boolean; wait: boolean; + rerun: boolean; allowLiveDbRead: boolean; timeoutSeconds: number; minAgeMinutes: number; @@ -409,6 +410,7 @@ function parseControlPlaneOptions(args: string[]): G14ControlPlaneOptions { lane, confirm, wait: args.includes("--wait"), + rerun: args.includes("--rerun") || rawAction === "rerun-current", allowLiveDbRead, dryRun: actionRaw === "status" || actionRaw === "closeout" ? true : explicitDryRun || !confirm, timeoutSeconds: positiveIntegerOption(args, "--timeout-seconds", 120, 600), @@ -4315,6 +4317,11 @@ function runRuntimeLaneControlPlane(spec: HwlabRuntimeLaneSpec, options: G14Cont } let pipelineRun = runtimeLanePipelineRunName(spec, sourceCommit); let before = getPipelineRunCompact(pipelineRun); + const originalPipelineRun = pipelineRun; + if (options.rerun && before.exists === true) { + pipelineRun = runtimeLaneRerunPipelineRunName(spec, sourceCommit); + before = getPipelineRunCompact(pipelineRun); + } if (options.dryRun) { return { ok: true, @@ -4323,6 +4330,8 @@ function runRuntimeLaneControlPlane(spec: HwlabRuntimeLaneSpec, options: G14Cont mode: "dry-run", sourceCommit, pipelineRun, + rerun: options.rerun, + originalPipelineRun: options.rerun ? originalPipelineRun : undefined, before, gitMirrorSync: { mode: "skipped-dry-run", @@ -4383,19 +4392,35 @@ function runRuntimeLaneControlPlane(spec: HwlabRuntimeLaneSpec, options: G14Cont }; } if (before.exists === true && effectiveBeforeStatus !== null) { - return { - ok: false, - command: `hwlab g14 control-plane trigger-current --lane ${spec.lane}`, - lane: spec.lane, - mode: "confirmed-trigger", - sourceCommit, - pipelineRun, - before, - skipped: true, - reason: "existing-pipelinerun-terminal-failed", - degradedReason: "existing-pipelinerun-terminal-failed", - next: { status: `bun scripts/cli.ts hwlab g14 control-plane status --lane ${spec.lane} --pipeline-run ${pipelineRun}` }, - }; + if (options.rerun === true) { + pipelineRun = runtimeLaneRerunPipelineRunName(spec, sourceCommit); + before = getPipelineRunCompact(pipelineRun); + printRuntimeLaneTriggerProgress(spec, { + stage: "existing-pipelinerun", + status: "explicit-rerun-required", + sourceCommit, + pipelineRun, + previousPipelineRun: originalPipelineRun, + previousStatus: effectiveBeforeStatus, + }); + } else { + return { + ok: false, + command: `hwlab g14 control-plane trigger-current --lane ${spec.lane}`, + lane: spec.lane, + mode: "confirmed-trigger", + sourceCommit, + pipelineRun, + before, + skipped: true, + reason: "existing-pipelinerun-terminal-failed", + degradedReason: "existing-pipelinerun-terminal-failed", + next: { + rerun: `bun scripts/cli.ts hwlab g14 control-plane trigger-current --lane ${spec.lane} --confirm --rerun`, + status: `bun scripts/cli.ts hwlab g14 control-plane status --lane ${spec.lane} --pipeline-run ${pipelineRun}`, + }, + }; + } } printRuntimeLaneTriggerProgress(spec, { stage: "git-mirror-sync",