fix: bootstrap v03 provider secret

This commit is contained in:
Codex
2026-06-08 16:56:41 +00:00
parent 59b3b15328
commit d9e6f70e72
4 changed files with 391 additions and 45 deletions
+68 -6
View File
@@ -1,5 +1,5 @@
import { activeV02PipelineRuns, g14ObservabilityQueryAssertion, gitMirrorFlushJobManifest, gitMirrorStatusSummary, gitMirrorSyncJobManifest, gitMirrorV02SyncRequirement, hwlabG14Help, hwlabG14MonitorStateFileName, parseGitMirrorStatusRefs, parseK8sCpuMillicores, parseK8sMemoryMiB, parsePipelineTaskRunMetrics, parseV02TriggerSnapshot, rolloutRecordBody, runtimeLanePipelineRunManifest, semanticChangelogBullets, summarizeV02CdStatus, v02CloseoutVerdict, v02CommitAlignment, v02ControlPlaneRefreshScriptHash, v02ControlPlaneRenderScript, v02ExistingPipelineRunReuseDecision, v02FalseGreenGuard, v02GitMirrorPreSyncWaitMs, v02LatestOnlyTargetValidation, v02PipelineServiceIds, v02PrAutomationCommentBody, v02ReusableGitMirrorPreSyncMarker, v02ReusableRefreshMarker, v02StatusHistoryPolicy, v02TaskRunPerformanceSummary } from "./src/hwlab-g14";
import { hwlabNodeHelp } from "./src/hwlab-node";
import { activeV02PipelineRuns, cleanupPipelineRunTargetCandidateFromTextForTest, g14ObservabilityQueryAssertion, gitMirrorFlushJobManifest, gitMirrorStatusSummary, gitMirrorSyncJobManifest, gitMirrorV02SyncRequirement, hwlabG14Help, hwlabG14MonitorStateFileName, parseGitMirrorStatusRefs, parseK8sCpuMillicores, parseK8sMemoryMiB, parsePipelineTaskRunMetrics, parseV02TriggerSnapshot, rolloutRecordBody, runtimeLanePipelineRunManifest, semanticChangelogBullets, summarizeV02CdStatus, v02CloseoutVerdict, v02CommitAlignment, v02ControlPlaneRefreshScriptHash, v02ControlPlaneRenderScript, v02ExistingPipelineRunReuseDecision, v02FalseGreenGuard, v02GitMirrorPreSyncWaitMs, v02LatestOnlyTargetValidation, v02PipelineServiceIds, v02PrAutomationCommentBody, v02ReusableGitMirrorPreSyncMarker, v02ReusableRefreshMarker, v02StatusHistoryPolicy, v02TaskRunPerformanceSummary } from "./src/hwlab-g14";
import { hwlabNodeHelp, nodeSecretStatusFromTextForTest } from "./src/hwlab-node";
import { hwlabRequiredNoProxyEntries, hwlabRuntimeLaneConfigPath, hwlabRuntimeLaneIds, hwlabRuntimeLaneSpec } from "./src/hwlab-node-lanes";
import { runCommand } from "./src/command";
@@ -124,6 +124,50 @@ assertCondition(
"v0.2 secret help must expose controlled OpenFGA and master-server admin API key SecretRef bootstrap paths",
hwlabHelpUsage,
);
assertCondition(
hwlabHelpUsage.some((line) => line.includes("hwlab nodes secret status --node G14 --lane v03 --name hwlab-v03-code-agent-provider"))
&& hwlabHelpUsage.some((line) => line.includes("hwlab nodes secret ensure --node G14 --lane v03 --name hwlab-v03-code-agent-provider --confirm"))
&& hwlabNodeHelpJson.includes("hwlab nodes secret status --node G14 --lane v03 --name hwlab-v03-code-agent-provider")
&& hwlabNodeHelpJson.includes("hwlab nodes secret ensure --node G14 --lane v03 --name hwlab-v03-code-agent-provider --confirm"),
"v0.3 node-scoped secret help must expose the controlled code-agent provider SecretRef bootstrap path",
{ hwlabHelpUsage, hwlabNodeHelp: hwlabNodeHelp() },
);
const codeAgentProviderStatus = nodeSecretStatusFromTextForTest([
"namespace\thwlab-v03",
"secret\thwlab-v03-code-agent-provider",
"preset\tcode-agent-provider",
"sourceNamespace\thwlab-v02",
"sourceSecret\thwlab-v02-code-agent-provider",
"action\tcopied-from-source",
"dryRun\tfalse",
"mutation\ttrue",
"beforeExists\tno",
"beforeOpenaiPresent\tno",
"beforeOpenaiBytes\t0",
"beforeOpencodePresent\tno",
"beforeOpencodeBytes\t0",
"sourceExists\tyes",
"sourceOpenaiPresent\tyes",
"sourceOpenaiBytes\t48",
"sourceOpencodePresent\tyes",
"sourceOpencodeBytes\t64",
"afterExists\tyes",
"afterOpenaiPresent\tyes",
"afterOpenaiBytes\t48",
"afterOpencodePresent\tyes",
"afterOpencodeBytes\t64",
"applyExitCode\t0",
].join("\n"), true, 0, "");
assertCondition(
record(codeAgentProviderStatus).ok === true
&& record(codeAgentProviderStatus).valuesRedacted === true
&& record(record(codeAgentProviderStatus).after).requiredAnyProviderKeyPresent === true
&& JSON.stringify(codeAgentProviderStatus).includes("hwlab-v02-code-agent-provider")
&& !JSON.stringify(codeAgentProviderStatus).includes("sk-")
&& !JSON.stringify(codeAgentProviderStatus).includes("base64"),
"code-agent provider Secret status must be redacted while proving at least one runtime provider key is present",
codeAgentProviderStatus,
);
assertCondition(
hwlabHelpUsage.some((line) => line.includes("upstream-image status --name openfga --tag v1.17.0"))
&& hwlabHelpUsage.some((line) => line.includes("upstream-image ensure --name openfga --tag v1.17.0 --confirm")),
@@ -481,10 +525,28 @@ assertCondition(
"control-plane cleanup-runs must protect the latest PipelineRun per lane by default",
);
assertCondition(
sourceText.includes("selectedReason: ageMinutes === null ? \"missing-creation-timestamp\" : \"below-min-age\"")
&& sourceText.includes("target-pipelinerun-not-found-or-not-terminal")
&& sourceText.indexOf("const target = terminalRuns.find((item) => item.name === targetPipelineRun)") < sourceText.indexOf("target-pipelinerun-not-found-or-not-terminal"),
"targeted cleanup-runs must report below-min-age terminal PipelineRuns instead of hiding them as not found",
record(cleanupPipelineRunTargetCandidateFromTextForTest({
targetPipelineRun: "hwlab-v02-ci-poll-d6b01b261f1b",
text: "hwlab-v02-ci-poll-d6b01b261f1b\t2026-06-08T16:15:31Z\tTrue\tCompleted",
nowMs: Date.parse("2026-06-08T16:51:31Z"),
minAgeMinutes: 60,
})).selectedReason === "below-min-age"
&& record(cleanupPipelineRunTargetCandidateFromTextForTest({
targetPipelineRun: "hwlab-v02-ci-poll-d6b01b261f1b",
text: "hwlab-v02-ci-poll-d6b01b261f1b\t2026-06-08T16:15:31Z\tUnknown\tRunning",
nowMs: Date.parse("2026-06-08T18:00:00Z"),
})).selectedReason === "target-pipelinerun-not-terminal"
&& record(cleanupPipelineRunTargetCandidateFromTextForTest({
targetPipelineRun: "hwlab-v02-ci-poll-d6b01b261f1b",
text: "",
commandOk: false,
exitCode: 1,
stderr: "Error from server (NotFound): pipelineruns.tekton.dev \"hwlab-v02-ci-poll-d6b01b261f1b\" not found",
})).reason === "target-pipelinerun-not-found"
&& sourceText.includes("targetPipelineRun !== undefined")
&& sourceText.includes("cleanupPipelineRunFieldsJsonPath(false)")
&& !sourceText.includes("target-pipelinerun-not-found-or-not-terminal"),
"targeted cleanup-runs must query the requested PipelineRun directly and distinguish below-min-age, not-terminal, and not-found states",
);
assertCondition(
hwlabHelpUsage.some((line) => line.includes("hwlab nodes control-plane cleanup-runs --node G14 --lane v03 --pipeline-run"))