fix: switch monitor root via sentinel yaml

This commit is contained in:
Codex
2026-06-28 03:28:10 +00:00
parent f371008af9
commit e4b9446ca9
8 changed files with 173 additions and 25 deletions
+27 -5
View File
@@ -5,7 +5,7 @@ import { createHash } from "node:crypto";
import { existsSync, readFileSync } from "node:fs";
import { rootPath } from "./config";
import { HWLAB_WEB_PROBE_SENTINEL_CONFIG_REF_KEYS, type HwlabRuntimeLaneSpec, type HwlabRuntimeWebProbeSentinelConfigRefKey } from "./hwlab-node-lanes";
import { resolveWebProbeSentinel, webProbeSentinelRegistryRows, type WebProbeSentinelRegistryRow } from "./hwlab-node-web-sentinel-resolver";
import { effectiveWebProbeSentinelPublicExposure, resolveWebProbeSentinel, webProbeSentinelRegistryRows, type WebProbeSentinelRegistryRow } from "./hwlab-node-web-sentinel-resolver";
import type { RenderedCliResult } from "./output";
export type WebProbeSentinelConfigAction = "plan" | "status";
@@ -211,7 +211,9 @@ export function webProbeSentinelConfigPlan(spec: HwlabRuntimeLaneSpec, action: W
}
const selected = resolveWebProbeSentinel(spec, sentinelId);
const refs = HWLAB_WEB_PROBE_SENTINEL_CONFIG_REF_KEYS.map((key) => readSentinelConfigRef(key, selected.configRefs[key]));
const refs = HWLAB_WEB_PROBE_SENTINEL_CONFIG_REF_KEYS
.map((key) => readSentinelConfigRef(key, selected.configRefs[key]))
.map((ref) => effectiveConfigRefStatus(spec, selected.id, ref));
const conflicts = selected.enabled ? crossReferenceConflicts(spec, refs) : [];
const refBlocked = refs.some((ref) => !ref.present || !ref.targetPresent || ref.missingFields.length > 0 || ref.conflicts.length > 0 || ref.error !== null);
const ok = selected.enabled && !refBlocked && conflicts.length === 0;
@@ -232,6 +234,18 @@ export function webProbeSentinelConfigPlan(spec: HwlabRuntimeLaneSpec, action: W
};
}
function effectiveConfigRefStatus(spec: HwlabRuntimeLaneSpec, sentinelId: string, ref: InternalConfigRefStatus): InternalConfigRefStatus {
if (ref.key !== "publicExposure" || !isRecord(ref.target)) return ref;
const target = effectiveWebProbeSentinelPublicExposure(spec, sentinelId, ref.target);
return {
...ref,
targetKind: targetKindOf(target),
missingFields: missingFieldsForTarget(ref.key, target),
summary: summarizeTarget(ref.key, target),
target,
};
}
export function withWebProbeSentinelConfigRendered(value: WebProbeSentinelConfigPlan): RenderedCliResult {
return {
ok: value.ok,
@@ -416,7 +430,15 @@ function summarizeTarget(key: HwlabRuntimeWebProbeSentinelConfigRefKey, target:
if (key === "runtime") return `namespace=${textAt(target, "namespace")} service=${textAt(target, "serviceName")} image=${short(textAt(target, "imageRef"), 48)}`;
if (key === "promptSet") return `id=${textAt(target, "id")} provider=${textAt(target, "providerProfile")} prompts=${textAt(target, "promptCount")} markers=${arrayAt(target, "expectedMarkers").slice(0, 12).join(",") || "-"} source=${textAt(target, "promptSourceRef")}:${textAt(target, "promptSourceKey")}`;
if (key === "reportViews") return `default=${textAt(target, "defaultView")} views=${arrayAt(target, "views").length}`;
if (key === "publicExposure") return `enabled=${textAt(target, "enabled")} mode=${textAt(target, "mode")} url=${textAt(target, "publicBaseUrl")}`;
if (key === "publicExposure") {
const monitorRoot = textAt(target, "monitorRoot.enabled");
const rootOrder = textAt(target, "caddy.rootOrder");
const suffix = [
...(monitorRoot === "-" ? [] : [`monitorRoot=${monitorRoot}`]),
...(rootOrder === "-" ? [] : [`rootOrder=${rootOrder}`]),
].join(" ");
return `enabled=${textAt(target, "enabled")} mode=${textAt(target, "mode")} url=${textAt(target, "publicBaseUrl")}${suffix.length === 0 ? "" : ` ${suffix}`}`;
}
if (key === "cicd") return `gitops=${textAt(target, "gitopsPath")} image=${textAt(target, "image.repository")}:${textAt(target, "image.tagSource")} confirmWait=${textAt(target, "confirmWait.maxSeconds")} targetValidation=${textAt(target, "targetValidation.maxSeconds")}`;
if (key === "secrets") return `sources=${arrayAt(target, "sources").length} runtimeSecrets=${arrayAt(target, "runtimeSecrets").length}`;
return `keys=${Object.keys(target).length}`;
@@ -442,8 +464,8 @@ function renderWebProbeSentinelConfigPlan(value: WebProbeSentinelConfigPlan): st
...(value.sentinels.length === 0 ? [] : [
"",
sentinelTable(
["SENTINEL", "ENABLED", "CONFIG_REF"],
value.sentinels.map((item) => [item.id, item.enabled, short(item.configRef, 110)]),
["SENTINEL", "ENABLED", "ROOT", "CONFIG_REF"],
value.sentinels.map((item) => [item.id, item.enabled, item.monitorRoot ? "monitor-root" : "-", short(item.configRef, 110)]),
),
]),
...(value.refs.length === 0 ? [