fix: remove legacy simulator runtime defaults

This commit is contained in:
Codex
2026-05-29 13:28:22 +08:00
parent e3b0571cc3
commit 5c9d04766b
22 changed files with 48 additions and 1248 deletions
+8 -87
View File
@@ -6,17 +6,13 @@ import {
DEV_CODE_AGENT_PROVIDER_CONTRACT,
codeAgentSecretRefPlaceholder
} from "../../internal/cloud/code-agent-contract.ts";
import {
HWLAB_M3_IO_API_BASE_URL_ENV,
HWLAB_M3_IO_DEV_SERVICE_BASE_URL
} from "../../skills/hwlab-agent-runtime/scripts/src/m3-io-skill-client.mjs";
import { HWLAB_M3_IO_API_BASE_URL_ENV } from "../../skills/hwlab-agent-runtime/scripts/src/m3-io-skill-client.mjs";
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const expectedPorts = Object.freeze({ frontend: 16666, api: 16667 });
const codeAgentBackendTimeoutMs = "1200000";
const codeAgentTransportTimeoutMs = "1260000";
const legacyPublicPorts = new Set([6666, 6667]);
const duplicateMappingAllowed = new Set(["hwlab-box-simu", "hwlab-gateway-simu"]);
const tomlBareKeyPattern = /^[A-Za-z0-9_-]+$/u;
function parseArgs(argv) {
@@ -226,19 +222,14 @@ function validateSource(ctx, manifest) {
expectEqual(ctx, manifest.profiles?.dev?.endpoint, endpoints.api?.url, "$.profiles.dev.endpoint", "DEV profile endpoint");
const cloudApi = servicesById.get("hwlab-cloud-api");
const tunnelClient = servicesById.get("hwlab-tunnel-client");
const cli = servicesById.get("hwlab-cli");
const patchPanel = servicesById.get("hwlab-patch-panel");
const cloudWeb = servicesById.get("hwlab-cloud-web");
const edgeProxy = servicesById.get("hwlab-edge-proxy");
expectEqual(ctx, cloudApi?.env?.HWLAB_PUBLIC_ENDPOINT, endpoints.api?.url, "$.services.hwlab-cloud-api.env.HWLAB_PUBLIC_ENDPOINT", "cloud API public endpoint env");
validateCloudApiDbSource(ctx, cloudApi?.env ?? {});
validateCloudApiCodeAgentSource(ctx, cloudApi?.env ?? {});
validateCodeAgentProxyTimeoutSource(ctx, { cloudApi, cloudWeb, edgeProxy });
validateM3PatchPanelSource(ctx, patchPanel);
expectEqual(ctx, cli?.env?.HWLAB_CLI_ENDPOINT, endpoints.api?.url, "$.services.hwlab-cli.env.HWLAB_CLI_ENDPOINT", "CLI endpoint env");
expectEqual(ctx, tunnelClient?.env?.HWLAB_FRP_PUBLIC_PORT, String(expectedPorts.api), "$.services.hwlab-tunnel-client.env.HWLAB_FRP_PUBLIC_PORT", "tunnel API public port env");
expectEqual(ctx, tunnelClient?.env?.HWLAB_FRP_WEB_PUBLIC_PORT, String(expectedPorts.frontend), "$.services.hwlab-tunnel-client.env.HWLAB_FRP_WEB_PUBLIC_PORT", "tunnel frontend public port env");
const proxies = manifest.frp?.proxies ?? [];
const proxyNames = new Set();
@@ -265,7 +256,7 @@ function validateSource(ctx, manifest) {
mappingNames.add(mapping.name);
expect(
ctx,
!mappingIds.has(mapping.serviceId) || duplicateMappingAllowed.has(mapping.serviceId),
!mappingIds.has(mapping.serviceId),
"duplicate_source",
`${basePath}.serviceId`,
`duplicate k3s mapping ${mapping.serviceId}`
@@ -278,78 +269,6 @@ function validateSource(ctx, manifest) {
return { manifest, endpoints, servicesById, proxies, serviceMappings, healthPath: manifest.health?.path };
}
function requiredM3Route() {
return {
fromResourceId: "res_boxsimu_1",
fromPort: "DO1",
patchPanelServiceId: "hwlab-patch-panel",
toResourceId: "res_boxsimu_2",
toPort: "DI1"
};
}
function parseJsonEnv(ctx, value, jsonPath, label) {
try {
return JSON.parse(String(value ?? ""));
} catch (error) {
addDiagnostic(ctx, "invalid_json", jsonPath, `${label} must be JSON`, {
actual: error instanceof Error ? error.message : String(error)
});
return null;
}
}
function validateM3PatchPanelSource(ctx, patchPanel) {
const route = requiredM3Route();
expectEqual(ctx, patchPanel?.m3Route?.fromResourceId, route.fromResourceId, "$.services.hwlab-patch-panel.m3Route.fromResourceId", "patch panel first-class M3 source resource");
expectEqual(ctx, patchPanel?.m3Route?.fromPort, route.fromPort, "$.services.hwlab-patch-panel.m3Route.fromPort", "patch panel first-class M3 source port");
expectEqual(ctx, patchPanel?.m3Route?.patchPanelServiceId, route.patchPanelServiceId, "$.services.hwlab-patch-panel.m3Route.patchPanelServiceId", "patch panel first-class M3 route owner");
expectEqual(ctx, patchPanel?.m3Route?.toResourceId, route.toResourceId, "$.services.hwlab-patch-panel.m3Route.toResourceId", "patch panel first-class M3 target resource");
expectEqual(ctx, patchPanel?.m3Route?.toPort, route.toPort, "$.services.hwlab-patch-panel.m3Route.toPort", "patch panel first-class M3 target port");
const endpointMap = parseJsonEnv(
ctx,
patchPanel?.env?.HWLAB_PATCH_PANEL_ENDPOINT_MAP,
"$.services.hwlab-patch-panel.env.HWLAB_PATCH_PANEL_ENDPOINT_MAP",
"patch panel endpoint map"
);
expectEqual(
ctx,
endpointMap?.res_boxsimu_2,
"http://hwlab-box-simu-2.hwlab-dev.svc.cluster.local:7201",
"$.services.hwlab-patch-panel.env.HWLAB_PATCH_PANEL_ENDPOINT_MAP.res_boxsimu_2",
"patch panel M3 target endpoint"
);
const wiring = parseJsonEnv(
ctx,
patchPanel?.env?.HWLAB_PATCH_PANEL_WIRING_CONFIG,
"$.services.hwlab-patch-panel.env.HWLAB_PATCH_PANEL_WIRING_CONFIG",
"patch panel wiring config"
);
const connection = wiring?.connections?.[0];
expectEqual(ctx, wiring?.status, "active", "$.services.hwlab-patch-panel.env.HWLAB_PATCH_PANEL_WIRING_CONFIG.status", "patch panel M3 wiring status");
expectEqual(
ctx,
wiring?.constraints?.propagation,
"patch-panel-only",
"$.services.hwlab-patch-panel.env.HWLAB_PATCH_PANEL_WIRING_CONFIG.constraints.propagation",
"patch panel M3 wiring propagation"
);
expectEqual(
ctx,
wiring?.constraints?.localLoopbackSubstituteAllowed,
false,
"$.services.hwlab-patch-panel.env.HWLAB_PATCH_PANEL_WIRING_CONFIG.constraints.localLoopbackSubstituteAllowed",
"patch panel M3 wiring forbids loopback substitute"
);
expectEqual(ctx, connection?.from?.resourceId, route.fromResourceId, "$.services.hwlab-patch-panel.env.HWLAB_PATCH_PANEL_WIRING_CONFIG.connections[0].from.resourceId", "patch panel M3 source resource");
expectEqual(ctx, connection?.from?.port, route.fromPort, "$.services.hwlab-patch-panel.env.HWLAB_PATCH_PANEL_WIRING_CONFIG.connections[0].from.port", "patch panel M3 source port");
expectEqual(ctx, connection?.to?.resourceId, route.toResourceId, "$.services.hwlab-patch-panel.env.HWLAB_PATCH_PANEL_WIRING_CONFIG.connections[0].to.resourceId", "patch panel M3 target resource");
expectEqual(ctx, connection?.to?.port, route.toPort, "$.services.hwlab-patch-panel.env.HWLAB_PATCH_PANEL_WIRING_CONFIG.connections[0].to.port", "patch panel M3 target port");
expectEqual(ctx, connection?.mode, "exclusive", "$.services.hwlab-patch-panel.env.HWLAB_PATCH_PANEL_WIRING_CONFIG.connections[0].mode", "patch panel M3 route mode");
}
function validateCloudApiDbSource(ctx, env) {
const alias = DEV_DB_ENV_CONTRACT.dns;
expectEqual(ctx, env.HWLAB_CLOUD_DB_URL, "secretRef:hwlab-cloud-api-dev-db/database-url", "$.services.hwlab-cloud-api.env.HWLAB_CLOUD_DB_URL", "cloud API DB URL Secret reference");
@@ -397,9 +316,9 @@ function validateCloudApiCodeAgentSource(ctx, env) {
expectEqual(
ctx,
env[HWLAB_M3_IO_API_BASE_URL_ENV],
HWLAB_M3_IO_DEV_SERVICE_BASE_URL,
undefined,
`$.services.hwlab-cloud-api.env.${HWLAB_M3_IO_API_BASE_URL_ENV}`,
"cloud API Code Agent Skill CLI HWLAB API service-local base URL"
"legacy M3 Skill CLI HWLAB API base URL is removed from default cloud-api config"
);
expectEqual(ctx, env.HWLAB_CODE_AGENT_CODEX_STDIO_ENABLED, "1", "$.services.hwlab-cloud-api.env.HWLAB_CODE_AGENT_CODEX_STDIO_ENABLED", "cloud API Codex stdio adapter enabled flag");
expectEqual(ctx, env.HWLAB_CODE_AGENT_CODEX_STDIO_SUPERVISOR, "repo-owned", "$.services.hwlab-cloud-api.env.HWLAB_CODE_AGENT_CODEX_STDIO_SUPERVISOR", "cloud API Codex stdio supervisor mode");
@@ -548,6 +467,8 @@ function validateK3sArtifacts(ctx, source, rendered, services, workloads, health
expectEqual(ctx, masterEdge.endpoint, source.endpoints.api?.url, "deploy/master-edge/health-contract.json.endpoint", "master edge endpoint");
flagLegacyPublicPort(ctx, "deploy/master-edge/health-contract.json.reverseLink.publicPort", masterEdge.reverseLink?.publicPort, expectedPorts.api, "master edge API");
flagLegacyPublicPort(ctx, "deploy/master-edge/health-contract.json.reverseLink.webPublicPort", masterEdge.reverseLink?.webPublicPort, expectedPorts.frontend, "master edge frontend");
expectEqual(ctx, masterEdge.reverseLink?.direction, "edge-proxy-only", "deploy/master-edge/health-contract.json.reverseLink.direction", "master edge reverse link no longer models a tunnel-client service");
expectEqual(ctx, masterEdge.reverseLink?.client, undefined, "deploy/master-edge/health-contract.json.reverseLink.client", "master edge reverse link does not name removed tunnel-client");
expectEqual(ctx, masterEdge.prodAcceptance, false, "deploy/master-edge/health-contract.json.prodAcceptance", "master edge PROD acceptance");
}
@@ -606,9 +527,9 @@ function validateCloudApiCodeAgentArtifacts(ctx, workloads) {
expectEqual(
ctx,
env.get(HWLAB_M3_IO_API_BASE_URL_ENV)?.value,
HWLAB_M3_IO_DEV_SERVICE_BASE_URL,
undefined,
`deploy/k8s/base/workloads.yaml.hwlab-cloud-api.env.${HWLAB_M3_IO_API_BASE_URL_ENV}`,
"cloud API workload Code Agent Skill CLI HWLAB API service-local base URL"
"legacy M3 Skill CLI HWLAB API base URL is removed from default cloud-api workload"
);
expectEqual(ctx, env.get("HWLAB_CODE_AGENT_CODEX_STDIO_ENABLED")?.value, "1", "deploy/k8s/base/workloads.yaml.hwlab-cloud-api.env.HWLAB_CODE_AGENT_CODEX_STDIO_ENABLED", "cloud API workload Codex stdio adapter enabled flag");
expectEqual(ctx, env.get("HWLAB_CODE_AGENT_CODEX_STDIO_SUPERVISOR")?.value, "repo-owned", "deploy/k8s/base/workloads.yaml.hwlab-cloud-api.env.HWLAB_CODE_AGENT_CODEX_STDIO_SUPERVISOR", "cloud API workload Codex stdio supervisor mode");