fix: hide v02 historical pipeline runs by default
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { activeV02PipelineRuns, g14ObservabilityQueryAssertion, gitMirrorFlushJobManifest, gitMirrorStatusSummary, gitMirrorSyncJobManifest, gitMirrorV02SyncRequirement, hwlabG14Help, hwlabG14MonitorStateFileName, parseGitMirrorStatusRefs, parseK8sCpuMillicores, parseK8sMemoryMiB, parsePipelineTaskRunMetrics, parseV02TriggerSnapshot, rolloutRecordBody, semanticChangelogBullets, summarizeV02CdStatus, v02CloseoutVerdict, v02CommitAlignment, v02ControlPlaneRefreshScriptHash, v02ControlPlaneRenderScript, v02ExistingPipelineRunReuseDecision, v02FalseGreenGuard, v02GitMirrorPreSyncWaitMs, v02LatestOnlyTargetValidation, v02PipelineServiceIds, v02PrAutomationCommentBody, v02ReusableGitMirrorPreSyncMarker, v02ReusableRefreshMarker, v02TaskRunPerformanceSummary } from "./src/hwlab-g14";
|
||||
import { activeV02PipelineRuns, g14ObservabilityQueryAssertion, gitMirrorFlushJobManifest, gitMirrorStatusSummary, gitMirrorSyncJobManifest, gitMirrorV02SyncRequirement, hwlabG14Help, hwlabG14MonitorStateFileName, parseGitMirrorStatusRefs, parseK8sCpuMillicores, parseK8sMemoryMiB, parsePipelineTaskRunMetrics, parseV02TriggerSnapshot, rolloutRecordBody, semanticChangelogBullets, summarizeV02CdStatus, v02CloseoutVerdict, v02CommitAlignment, v02ControlPlaneRefreshScriptHash, v02ControlPlaneRenderScript, v02ExistingPipelineRunReuseDecision, v02FalseGreenGuard, v02GitMirrorPreSyncWaitMs, v02LatestOnlyTargetValidation, v02PipelineServiceIds, v02PrAutomationCommentBody, v02ReusableGitMirrorPreSyncMarker, v02ReusableRefreshMarker, v02StatusHistoryPolicy, v02TaskRunPerformanceSummary } from "./src/hwlab-g14";
|
||||
import { runCommand } from "./src/command";
|
||||
|
||||
function assertCondition(condition: unknown, message: string, detail: unknown = {}): void {
|
||||
@@ -36,6 +36,7 @@ const hwlabHelpUsage = Array.isArray(hwlabG14Help().usage) ? hwlabG14Help().usag
|
||||
assertCondition(
|
||||
hwlabHelpUsage.some((line) => line.includes("control-plane status --lane v02 --pipeline-run"))
|
||||
&& hwlabHelpUsage.some((line) => line.includes("control-plane status --lane v02 --source-commit"))
|
||||
&& hwlabHelpUsage.some((line) => line.includes("control-plane status --lane v02 --history"))
|
||||
&& hwlabHelpUsage.some((line) => line.includes("control-plane closeout --lane v02 --pipeline-run"))
|
||||
&& hwlabHelpUsage.some((line) => line.includes("control-plane closeout --lane v02 --source-commit"))
|
||||
&& hwlabHelpUsage.some((line) => line.includes("control-plane cleanup-runs --lane v02 --pipeline-run"))
|
||||
@@ -557,6 +558,29 @@ assertCondition(
|
||||
"v0.2 active PipelineRun helper must accept the status.activePipelineRuns array shape",
|
||||
activeRunSummary,
|
||||
);
|
||||
const hiddenHistoryPolicy = v02StatusHistoryPolicy({
|
||||
activePipelineRuns: [],
|
||||
history: {
|
||||
included: false,
|
||||
note: "recent PipelineRun history is hidden by default so old manifest/service-id failures do not pollute the current-target verdict; rerun with --history to inspect it",
|
||||
command: "hwlab g14 control-plane status --lane v02 --history",
|
||||
},
|
||||
});
|
||||
const explicitHistoryPolicy = v02StatusHistoryPolicy({
|
||||
activePipelineRuns: [],
|
||||
recentPipelineRuns: { items: [{ name: "hwlab-v02-ci-poll-aaaaaaaaaaaa", status: "False" }] },
|
||||
history: { included: true },
|
||||
});
|
||||
assertCondition(
|
||||
hiddenHistoryPolicy.included === false
|
||||
&& hiddenHistoryPolicy.recentPipelineRunsVisible === false
|
||||
&& hiddenHistoryPolicy.activePipelineRunsVisible === true
|
||||
&& String(hiddenHistoryPolicy.command).includes("--history")
|
||||
&& explicitHistoryPolicy.included === true
|
||||
&& explicitHistoryPolicy.recentPipelineRunsVisible === true,
|
||||
"v0.2 status must hide historical PipelineRun lists by default and expose them only via --history",
|
||||
{ hiddenHistoryPolicy, explicitHistoryPolicy },
|
||||
);
|
||||
|
||||
const falseGreenPassed = v02FalseGreenGuard({
|
||||
sourceCommit: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
|
||||
@@ -138,6 +138,7 @@ interface G14ControlPlaneOptions {
|
||||
limit: number;
|
||||
sourceCommit?: string;
|
||||
pipelineRun?: string;
|
||||
history: boolean;
|
||||
}
|
||||
|
||||
type V02StatusTargetMode = "latest-source-head" | "source-commit" | "pipeline-run";
|
||||
@@ -146,6 +147,7 @@ interface V02ControlPlaneStatusTarget {
|
||||
sourceCommit?: string | null;
|
||||
pipelineRun?: string | null;
|
||||
mode?: V02StatusTargetMode;
|
||||
includeHistory?: boolean;
|
||||
}
|
||||
|
||||
interface G14ToolsImageOptions {
|
||||
@@ -382,6 +384,7 @@ function parseControlPlaneOptions(args: string[]): G14ControlPlaneOptions {
|
||||
limit: positiveIntegerOption(args, "--limit", 20, 200),
|
||||
sourceCommit: sourceCommitRaw === undefined ? undefined : validateFullShaOption(sourceCommitRaw, "--source-commit"),
|
||||
pipelineRun: pipelineRunRaw === undefined ? undefined : validateV02PipelineRunOption(pipelineRunRaw),
|
||||
history: args.includes("--history"),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2938,6 +2941,7 @@ function createV02PipelineRun(sourceCommit: string, timeoutSeconds: number): Com
|
||||
function v02ControlPlaneStatus(target: V02ControlPlaneStatusTarget = {}): Record<string, unknown> {
|
||||
const targetMode: V02StatusTargetMode = target.mode
|
||||
?? (target.pipelineRun !== undefined && target.pipelineRun !== null ? "pipeline-run" : target.sourceCommit !== undefined ? "source-commit" : "latest-source-head");
|
||||
const includeHistory = target.includeHistory === true;
|
||||
const strictHeadAlignment = targetMode === "latest-source-head";
|
||||
const bundle = v02ControlPlaneStatusBundle({ ...target, mode: targetMode });
|
||||
const sections = parseShellSections(statusText(bundle));
|
||||
@@ -3135,7 +3139,16 @@ function v02ControlPlaneStatus(target: V02ControlPlaneStatusTarget = {}): Record
|
||||
falseGreenGuard,
|
||||
webAssets,
|
||||
activePipelineRuns,
|
||||
recentPipelineRuns,
|
||||
history: {
|
||||
included: includeHistory,
|
||||
activePipelineRunCount: activePipelineRuns.length,
|
||||
recentPipelineRunCount: Array.isArray(recentPipelineRuns.items) ? recentPipelineRuns.items.length : 0,
|
||||
note: includeHistory
|
||||
? "recentPipelineRuns is included because --history was requested; historical runs are diagnostic evidence, not the default current-target verdict"
|
||||
: "recent PipelineRun history is hidden by default so old manifest/service-id failures do not pollute the current-target verdict; rerun with --history to inspect it",
|
||||
command: statusCommand.includes("--history") ? statusCommand : `${statusCommand} --history`,
|
||||
},
|
||||
...(includeHistory ? { recentPipelineRuns } : {}),
|
||||
query: {
|
||||
ok: isCommandSuccess(bundle),
|
||||
exitCode: bundle.exitCode,
|
||||
@@ -3155,17 +3168,17 @@ function runV02ControlPlane(options: G14ControlPlaneOptions): Record<string, unk
|
||||
if (options.action === "cleanup-runs") return runControlPlaneCleanup(options);
|
||||
if (options.action === "cleanup-released-pvs") return runControlPlaneReleasedPvCleanup(options);
|
||||
if ((options.action === "status" || options.action === "closeout") && options.pipelineRun !== undefined) {
|
||||
const status = v02ControlPlaneStatus({ pipelineRun: options.pipelineRun, mode: "pipeline-run" });
|
||||
const status = v02ControlPlaneStatus({ pipelineRun: options.pipelineRun, mode: "pipeline-run", includeHistory: options.history });
|
||||
if (options.action === "closeout") return v02ControlPlaneCloseout(status);
|
||||
return status;
|
||||
}
|
||||
if ((options.action === "status" || options.action === "closeout") && options.sourceCommit !== undefined) {
|
||||
const status = v02ControlPlaneStatus({ sourceCommit: options.sourceCommit, mode: "source-commit" });
|
||||
const status = v02ControlPlaneStatus({ sourceCommit: options.sourceCommit, mode: "source-commit", includeHistory: options.history });
|
||||
if (options.action === "closeout") return v02ControlPlaneCloseout(status);
|
||||
return status;
|
||||
}
|
||||
if (options.action === "closeout") {
|
||||
const status = v02ControlPlaneStatus();
|
||||
const status = v02ControlPlaneStatus({ includeHistory: options.history });
|
||||
return v02ControlPlaneCloseout(status);
|
||||
}
|
||||
const snapshot = options.action === "trigger-current" ? getV02TriggerSnapshot() : null;
|
||||
@@ -3200,7 +3213,7 @@ function runV02ControlPlane(options: G14ControlPlaneOptions): Record<string, unk
|
||||
return { ok: false, command: `hwlab g14 control-plane ${options.action} --lane v02`, degradedReason: "v02-head-unresolved", sourceRepo: V02_CICD_REPO, workspace: V02_WORKSPACE, headProbe: compactCommandResult(head.result) };
|
||||
}
|
||||
if (options.action === "runtime-migration") return runV02RuntimeMigration(options, sourceCommit);
|
||||
if (options.action === "status") return v02ControlPlaneStatus({ sourceCommit, mode: "latest-source-head" });
|
||||
if (options.action === "status") return v02ControlPlaneStatus({ sourceCommit, mode: "latest-source-head", includeHistory: options.history });
|
||||
if (options.action === "apply") {
|
||||
const render = runV02RenderToTemp(sourceCommit);
|
||||
if (!isCommandSuccess(render.result)) {
|
||||
@@ -7094,6 +7107,17 @@ export function activeV02PipelineRuns(status: Record<string, unknown>): Record<s
|
||||
return items.map((item) => record(item)).filter((item) => String(item.status ?? "") === "Unknown");
|
||||
}
|
||||
|
||||
export function v02StatusHistoryPolicy(status: Record<string, unknown>): Record<string, unknown> {
|
||||
const history = record(status.history);
|
||||
return {
|
||||
included: history.included === true,
|
||||
recentPipelineRunsVisible: Object.hasOwn(status, "recentPipelineRuns"),
|
||||
activePipelineRunsVisible: Object.hasOwn(status, "activePipelineRuns"),
|
||||
note: history.note ?? null,
|
||||
command: history.command ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
function v02PrCommentSignature(input: V02PrCommentInput): string {
|
||||
const summary = input.preflight ?? {};
|
||||
const cd = input.cd ?? {};
|
||||
@@ -7634,6 +7658,7 @@ export function hwlabG14Help(): Record<string, unknown> {
|
||||
"bun scripts/cli.ts hwlab g14 monitor-prs --lane v02 --once --dry-run",
|
||||
"bun scripts/cli.ts hwlab g14 record-rollout --pr <number> [--source-commit sha]",
|
||||
"bun scripts/cli.ts hwlab g14 control-plane status --lane v02",
|
||||
"bun scripts/cli.ts hwlab g14 control-plane status --lane v02 --history",
|
||||
"bun scripts/cli.ts hwlab g14 control-plane status --lane v02 --pipeline-run hwlab-v02-ci-poll-<short-sha>",
|
||||
"bun scripts/cli.ts hwlab g14 control-plane status --lane v02 --source-commit <full-sha>",
|
||||
"bun scripts/cli.ts hwlab g14 control-plane closeout --lane v02 --pipeline-run hwlab-v02-ci-poll-<short-sha>",
|
||||
|
||||
Reference in New Issue
Block a user