fix: YAML-first 治理 CI/CD target (#919)
* docs: specify cicd yaml target governance * fix: resolve cicd targets from yaml --------- Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
// SPEC: PJ2026-01060505 Workbench Performance draft-2026-06-17-p0.
|
||||
// SPEC: PJ2026-01060508 Web哨兵 draft-2026-06-25-p0-web-probe-sentinel.
|
||||
// SPEC: PJ2026-01060308 cicd-yaml-targets draft-2026-06-25-cicd-yaml-targets.
|
||||
// Responsibility: YAML source-of-truth parsing for HWLAB node/lane Workbench observability.
|
||||
import { readFileSync } from "node:fs";
|
||||
import { rootPath } from "./config";
|
||||
|
||||
export type HwlabRuntimeLane = "v02" | "v03";
|
||||
export type HwlabRuntimeLane = string;
|
||||
|
||||
export interface HwlabRuntimeNodeSpec {
|
||||
readonly id: string;
|
||||
@@ -520,8 +521,8 @@ function nodeConfig(id: string, raw: Record<string, unknown>): HwlabRuntimeNodeS
|
||||
};
|
||||
}
|
||||
|
||||
function isSupportedLaneId(id: string): id is HwlabRuntimeLane {
|
||||
return id === "v02" || id === "v03";
|
||||
function assertYamlDeclaredLaneId(id: string, path: string): asserts id is HwlabRuntimeLane {
|
||||
if (!/^[A-Za-z0-9._-]+$/u.test(id)) throw new Error(`${path} has an unsupported lane id; lane ids must be YAML-declared simple ids`);
|
||||
}
|
||||
|
||||
function laneConfig(id: HwlabRuntimeLane, raw: Record<string, unknown>): HwlabLaneConfig {
|
||||
@@ -1043,12 +1044,13 @@ function readHwlabNodeLaneConfig(): HwlabNodeLaneConfig {
|
||||
);
|
||||
const laneEntries = sortedRecordEntries(parsed.lanes, "lanes");
|
||||
const lanes = Object.fromEntries(laneEntries.map(([id, item]) => {
|
||||
if (!isSupportedLaneId(id)) throw new Error(`lanes.${id} is not supported by this CLI build`);
|
||||
assertYamlDeclaredLaneId(id, `lanes.${id}`);
|
||||
return [id, laneConfig(id, item)];
|
||||
})) as Record<HwlabRuntimeLane, HwlabLaneConfig>;
|
||||
const laneTargets: Partial<Record<HwlabRuntimeLane, Record<string, HwlabLaneConfig>>> = {};
|
||||
})) as Record<string, HwlabLaneConfig>;
|
||||
const laneTargets: Partial<Record<string, Record<string, HwlabLaneConfig>>> = {};
|
||||
for (const [id, item] of laneEntries) {
|
||||
if (!isSupportedLaneId(id) || item.targets === undefined) continue;
|
||||
assertYamlDeclaredLaneId(id, `lanes.${id}`);
|
||||
if (item.targets === undefined) continue;
|
||||
laneTargets[id] = Object.fromEntries(sortedRecordEntries(item.targets, `lanes.${id}.targets`).map(([nodeId, target]) => [
|
||||
nodeId,
|
||||
laneTargetConfig(id, nodeId, item, target),
|
||||
@@ -1080,7 +1082,7 @@ function validateConfigEnvelope(parsed: Record<string, unknown>): void {
|
||||
|
||||
function parseDefaultTarget(raw: Record<string, unknown>): { readonly node: string; readonly lane: HwlabRuntimeLane } {
|
||||
const lane = stringField(raw, "lane", `${HWLAB_NODE_LANE_CONFIG_PATH}.defaults`);
|
||||
if (!isSupportedLaneId(lane)) throw new Error(`${HWLAB_NODE_LANE_CONFIG_PATH}.defaults.lane is not supported by this CLI build`);
|
||||
assertYamlDeclaredLaneId(lane, `${HWLAB_NODE_LANE_CONFIG_PATH}.defaults.lane`);
|
||||
return {
|
||||
node: stringField(raw, "node", `${HWLAB_NODE_LANE_CONFIG_PATH}.defaults`),
|
||||
lane,
|
||||
@@ -1145,7 +1147,7 @@ function buildRuntimeLaneSpec(config: HwlabLaneConfig): HwlabRuntimeLaneSpec {
|
||||
|
||||
const RUNTIME_LANE_SPECS = Object.fromEntries(
|
||||
Object.values(HWLAB_NODE_LANE_CONFIG.lanes).map((config) => [config.id, buildRuntimeLaneSpec(config)]),
|
||||
) as Record<HwlabRuntimeLane, HwlabRuntimeLaneSpec>;
|
||||
) as Record<string, HwlabRuntimeLaneSpec>;
|
||||
|
||||
export function isHwlabRuntimeLane(value: string): value is HwlabRuntimeLane {
|
||||
return Object.prototype.hasOwnProperty.call(RUNTIME_LANE_SPECS, value);
|
||||
|
||||
Reference in New Issue
Block a user