feat(deploy): register Engine telemetry catalog transition
This commit is contained in:
parent
e4383b6162
commit
f97a9d924d
|
|
@ -0,0 +1,189 @@
|
|||
#!/usr/bin/env node
|
||||
import { createHash } from "node:crypto";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { copyFile, lstat, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url));
|
||||
const workspaceRoot = resolve(here, "../../..");
|
||||
const engineRoot = resolve(
|
||||
process.env.NODEDC_ENGINE_SOURCE_ROOT || join(workspaceRoot, "NODEDC_ENGINE_INFRA"),
|
||||
);
|
||||
const artifactRoot = resolve(
|
||||
process.env.NODEDC_DEPLOY_ARTIFACT_DIR || resolve(here, "../deploy-artifacts"),
|
||||
);
|
||||
const [patchId = "", ...extra] = process.argv.slice(2);
|
||||
if (
|
||||
extra.length
|
||||
|| !/^engine-mcp-telemetry-catalog-\d{8}-\d{3}$/.test(patchId)
|
||||
) {
|
||||
throw new Error(
|
||||
"usage: build-engine-mcp-telemetry-catalog-artifact.mjs "
|
||||
+ "<engine-mcp-telemetry-catalog-YYYYMMDD-NNN>",
|
||||
);
|
||||
}
|
||||
|
||||
const descriptorPath =
|
||||
"nodedc-source/server/deployTransitions/telemetryReadingCatalogV1.json";
|
||||
const targetSha256 = Object.freeze({
|
||||
"nodedc-source/server/routes/n8n.js":
|
||||
"903245ae363e9b9ac161498f17988a38876a0e0ac8d80f3fa1b0112ceb7fe906",
|
||||
"nodedc-source/server/routes/engineAgentGateway.js":
|
||||
"69bfc91e913a3fad04e13aca86efb9d62f73c0c7d1f8f7200907494b29fa9e8d",
|
||||
[descriptorPath]:
|
||||
"b25ab8b6e6ad8ac24614c4630cc3635abe453464466d5a72238b05e48a24d882",
|
||||
});
|
||||
const entries = Object.freeze(Object.keys(targetSha256));
|
||||
const artifact = join(artifactRoot, `nodedc-${patchId}.tgz`);
|
||||
|
||||
await assertFresh(artifact);
|
||||
await assertExactSources();
|
||||
const stage = await mkdtemp(join(tmpdir(), "nodedc-engine-mcp-telemetry-catalog-"));
|
||||
try {
|
||||
const payload = join(stage, "payload");
|
||||
for (const relativePath of entries) {
|
||||
const destination = join(payload, relativePath);
|
||||
await mkdir(dirname(destination), { recursive: true });
|
||||
await copyFile(join(engineRoot, relativePath), destination);
|
||||
}
|
||||
await writeFile(
|
||||
join(stage, "manifest.env"),
|
||||
`id=${patchId}\ncomponent=engine\ntype=app-overlay\n`,
|
||||
{ encoding: "utf8", flag: "wx", mode: 0o644 },
|
||||
);
|
||||
await writeFile(join(stage, "files.txt"), `${entries.join("\n")}\n`, {
|
||||
encoding: "utf8",
|
||||
flag: "wx",
|
||||
mode: 0o644,
|
||||
});
|
||||
await mkdir(artifactRoot, { recursive: true });
|
||||
run("python3", ["-c", canonicalTarScript(), artifact, stage]);
|
||||
console.log(JSON.stringify({
|
||||
ok: true,
|
||||
patchId,
|
||||
artifact,
|
||||
sha256: digest(await readFile(artifact)),
|
||||
entries,
|
||||
targetSha256,
|
||||
services: ["nodedc-backend"],
|
||||
transition: "execution-profile-decoder-v1-to-telemetry-catalog-v1",
|
||||
mcpVersion: "0.8.0",
|
||||
mcpSurface: "external-codex",
|
||||
mcpTool: "engine_get_telemetry_reading_catalog",
|
||||
readingValuesIncluded: false,
|
||||
rawExecutionDataIncluded: false,
|
||||
untouched: [
|
||||
"L2 graph",
|
||||
"n8n",
|
||||
"L1",
|
||||
"Engine UI",
|
||||
"node-intelligence image",
|
||||
"databases",
|
||||
"credentials",
|
||||
"MCP Nginx",
|
||||
"embedded AI Workspace",
|
||||
],
|
||||
}, null, 2));
|
||||
} finally {
|
||||
await rm(stage, { recursive: true, force: true });
|
||||
}
|
||||
|
||||
async function assertExactSources() {
|
||||
for (const [relativePath, expected] of Object.entries(targetSha256)) {
|
||||
const sourcePath = join(engineRoot, relativePath);
|
||||
const info = await lstat(sourcePath);
|
||||
if (!info.isFile() || info.isSymbolicLink()) {
|
||||
throw new Error(`engine_mcp_telemetry_catalog_source_unsafe:${relativePath}`);
|
||||
}
|
||||
const actual = digest(await readFile(sourcePath));
|
||||
if (actual !== expected) {
|
||||
throw new Error(
|
||||
`engine_mcp_telemetry_catalog_target_mismatch:${relativePath}:`
|
||||
+ `expected=${expected}:actual=${actual}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const n8nSource = await readFile(
|
||||
join(engineRoot, "nodedc-source/server/routes/n8n.js"),
|
||||
"utf8",
|
||||
);
|
||||
for (const marker of [
|
||||
"function toSafeTelemetryReadingCatalog",
|
||||
"key === 'sensor_readings' && pathName.endsWith('.attributes')",
|
||||
"rawExecutionDataIncluded: false,",
|
||||
]) {
|
||||
if (!n8nSource.includes(marker)) {
|
||||
throw new Error(`engine_mcp_telemetry_catalog_marker_missing:${marker}`);
|
||||
}
|
||||
}
|
||||
|
||||
const gatewaySource = await readFile(
|
||||
join(engineRoot, "nodedc-source/server/routes/engineAgentGateway.js"),
|
||||
"utf8",
|
||||
);
|
||||
for (const marker of [
|
||||
"const ENGINE_AGENT_MCP_VERSION = '0.8.0'",
|
||||
"name: 'engine_get_telemetry_reading_catalog'",
|
||||
"/telemetry-reading-catalog?",
|
||||
]) {
|
||||
if (!gatewaySource.includes(marker)) {
|
||||
throw new Error(`engine_mcp_telemetry_catalog_gateway_marker_missing:${marker}`);
|
||||
}
|
||||
}
|
||||
|
||||
const descriptor = JSON.parse(await readFile(join(engineRoot, descriptorPath), "utf8"));
|
||||
if (
|
||||
descriptor?.schemaVersion !== "nodedc.engine.deploy-transition/v1"
|
||||
|| descriptor?.id !== "engine-mcp-telemetry-reading-catalog-v1"
|
||||
|| descriptor?.mcpVersion !== "0.8.0"
|
||||
|| descriptor?.readsOnly !== "normalized-attributes.sensor_readings"
|
||||
|| descriptor?.neverReturns?.join(",")
|
||||
!== "reading-value,raw-execution-data,raw-provider-payload,credential-shaped-data"
|
||||
) {
|
||||
throw new Error("engine_mcp_telemetry_catalog_descriptor_contract_mismatch");
|
||||
}
|
||||
}
|
||||
|
||||
async function assertFresh(path) {
|
||||
try {
|
||||
await lstat(path);
|
||||
} catch (error) {
|
||||
if (error?.code === "ENOENT") return;
|
||||
throw error;
|
||||
}
|
||||
throw new Error("artifact_already_exists");
|
||||
}
|
||||
|
||||
function canonicalTarScript() {
|
||||
return [
|
||||
"import gzip,io,pathlib,sys,tarfile",
|
||||
"root=pathlib.Path(sys.argv[2])",
|
||||
"with open(sys.argv[1],'xb') as out:",
|
||||
" with gzip.GzipFile(filename='',mode='wb',fileobj=out,compresslevel=9,mtime=0) as gz:",
|
||||
" with tarfile.open(fileobj=gz,mode='w',format=tarfile.PAX_FORMAT) as tar:",
|
||||
" for top in ('manifest.env','files.txt','payload'):",
|
||||
" p=root/top; paths=[p]+(sorted(p.rglob('*')) if p.is_dir() else [])",
|
||||
" for x in paths:",
|
||||
" info=tar.gettarinfo(str(x),arcname=x.relative_to(root).as_posix())",
|
||||
" info.uid=info.gid=0; info.uname=info.gname='root'; info.mtime=0; info.mode=0o755 if info.isdir() else 0o644",
|
||||
" with (open(x,'rb') if info.isfile() else io.BytesIO()) as src: tar.addfile(info,src if info.isfile() else None)",
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
function digest(value) {
|
||||
return createHash("sha256").update(value).digest("hex");
|
||||
}
|
||||
|
||||
function run(command, args) {
|
||||
const result = spawnSync(command, args, {
|
||||
encoding: "utf8",
|
||||
maxBuffer: 128 * 1024 * 1024,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
});
|
||||
if (result.status !== 0) {
|
||||
throw new Error(`${command}_failed:${result.stderr || result.stdout}`);
|
||||
}
|
||||
}
|
||||
|
|
@ -547,6 +547,29 @@ ENGINE_MCP_EXECUTION_PROFILE_DECODER_TARGET_SHA256 = {
|
|||
ENGINE_MCP_EXECUTION_PROFILE_DECODER_NEW_PATHS = (
|
||||
ENGINE_MCP_EXECUTION_PROFILE_DECODER_DESCRIPTOR_REL,
|
||||
)
|
||||
ENGINE_MCP_TELEMETRY_CATALOG_DESCRIPTOR_REL = (
|
||||
"nodedc-source/server/deployTransitions/telemetryReadingCatalogV1.json"
|
||||
)
|
||||
ENGINE_MCP_TELEMETRY_CATALOG_ARTIFACT_ENTRIES = (
|
||||
"nodedc-source/server/routes/n8n.js",
|
||||
"nodedc-source/server/routes/engineAgentGateway.js",
|
||||
ENGINE_MCP_TELEMETRY_CATALOG_DESCRIPTOR_REL,
|
||||
)
|
||||
ENGINE_MCP_TELEMETRY_CATALOG_PREDECESSOR_SHA256 = {
|
||||
"nodedc-source/server/routes/n8n.js": "1c2427c1d5830c40b1e8ae05f3d683fc39d07d7e0fe2431b0f6efbbb1d3fcb88",
|
||||
"nodedc-source/server/routes/engineAgentGateway.js": "4f600a2781be9118bec891fa2a6f20d7f55e0892ef2f06af24059193cebd28f4",
|
||||
}
|
||||
ENGINE_MCP_TELEMETRY_CATALOG_FOUNDATION_SHA256 = {
|
||||
ENGINE_MCP_EXECUTION_PROFILE_DECODER_DESCRIPTOR_REL: "93e431902e9bcd3b828a82ed6b42b48d939051f21bf8824dafcf2addac8a711c",
|
||||
}
|
||||
ENGINE_MCP_TELEMETRY_CATALOG_TARGET_SHA256 = {
|
||||
"nodedc-source/server/routes/n8n.js": "903245ae363e9b9ac161498f17988a38876a0e0ac8d80f3fa1b0112ceb7fe906",
|
||||
"nodedc-source/server/routes/engineAgentGateway.js": "69bfc91e913a3fad04e13aca86efb9d62f73c0c7d1f8f7200907494b29fa9e8d",
|
||||
ENGINE_MCP_TELEMETRY_CATALOG_DESCRIPTOR_REL: "b25ab8b6e6ad8ac24614c4630cc3635abe453464466d5a72238b05e48a24d882",
|
||||
}
|
||||
ENGINE_MCP_TELEMETRY_CATALOG_NEW_PATHS = (
|
||||
ENGINE_MCP_TELEMETRY_CATALOG_DESCRIPTOR_REL,
|
||||
)
|
||||
ENGINE_AGENT_FULL_GRANT_MIGRATION_ARTIFACT_ENTRIES = (
|
||||
ENGINE_AGENT_FULL_GRANT_MIGRATION_STORE_REL,
|
||||
)
|
||||
|
|
@ -3244,6 +3267,7 @@ def validate_engine_node_intelligence_transition(payload_dir, entries):
|
|||
"const ENGINE_AGENT_MCP_VERSION = '0.5.0'",
|
||||
"const ENGINE_AGENT_MCP_VERSION = '0.6.0'",
|
||||
"const ENGINE_AGENT_MCP_VERSION = '0.7.0'",
|
||||
"const ENGINE_AGENT_MCP_VERSION = '0.8.0'",
|
||||
)
|
||||
):
|
||||
die("Engine node-intelligence gateway MCP version is not registered")
|
||||
|
|
@ -4359,6 +4383,42 @@ process.stdout.write('engine-mcp-execution-profile-decoder:flatted-numeric-strin
|
|||
}
|
||||
|
||||
|
||||
def accept_engine_mcp_telemetry_catalog_runtime():
|
||||
root = component_root("engine")
|
||||
validate_engine_mcp_telemetry_catalog_slice(
|
||||
root,
|
||||
ENGINE_MCP_TELEMETRY_CATALOG_ARTIFACT_ENTRIES,
|
||||
)
|
||||
live = run_engine_backend_probe(
|
||||
(
|
||||
"node",
|
||||
"--input-type=module",
|
||||
"-e",
|
||||
"""
|
||||
const n8n=await import('file:///app/server/routes/n8n.js');
|
||||
const gateway=await import('file:///app/server/routes/engineAgentGateway.js');
|
||||
const execution={id:'telemetry-catalog-acceptance',data:{resultData:{runData:{Mapper:[{data:{main:[[{json:{fact:{attributes:{sensor_readings:[{id:'engine.rpm',label:'Engine RPM',unit:'rpm',value:1350},{id:'tracker.status',label:'Bearer provider-token-must-not-escape',value:'provider-token-must-not-escape'}]}},lastMsg:{params:{sensor_readings:[{id:'raw.must-not-enter',label:'Raw',value:'raw-provider-value'}]}}}}]]}}]}}}};
|
||||
const catalog=n8n.toSafeTelemetryReadingCatalog(execution,'Mapper');
|
||||
const rpm=catalog.readings.find((item)=>item.id==='engine.rpm');
|
||||
const status=catalog.readings.find((item)=>item.id==='tracker.status');
|
||||
const serialized=JSON.stringify(catalog);
|
||||
const tool=gateway.engineAgentTools.find((item)=>item.name==='engine_get_telemetry_reading_catalog');
|
||||
if(gateway.ENGINE_AGENT_MCP_VERSION!=='0.8.0'||!tool||!catalog.found||catalog.valuesIncluded!==false||catalog.rawExecutionDataIncluded!==false||rpm?.label!=='Engine RPM'||rpm?.unit!=='rpm'||rpm?.valueTypes?.join(',')!=='number'||status?.label!==undefined||catalog.readings.some((item)=>item.id==='raw.must-not-enter')||serialized.includes('1350')||serialized.includes('provider-token-must-not-escape')||serialized.includes('raw-provider-value'))process.exit(2);
|
||||
process.stdout.write('engine-mcp-telemetry-catalog:0.8.0:normalized-metadata-only:v1');
|
||||
""".strip(),
|
||||
),
|
||||
"Engine MCP telemetry reading catalog",
|
||||
container_id=engine_backend_container_id(),
|
||||
)
|
||||
expected = "engine-mcp-telemetry-catalog:0.8.0:normalized-metadata-only:v1"
|
||||
if live != expected:
|
||||
die("Engine MCP telemetry reading catalog live acceptance mismatch")
|
||||
return {
|
||||
"target_sha256": dict(ENGINE_MCP_TELEMETRY_CATALOG_TARGET_SHA256),
|
||||
"live": live,
|
||||
}
|
||||
|
||||
|
||||
def validate_no_lifecycle_scripts(payload_dir, label):
|
||||
forbidden = ("preinstall", "install", "postinstall", "prepare", "prepack", "postpack")
|
||||
for package_path in payload_dir.rglob("package.json"):
|
||||
|
|
@ -5024,6 +5084,80 @@ def validate_engine_mcp_execution_profile_decoder_slice(payload_dir, entries):
|
|||
die("Engine MCP execution profile decoder source contract mismatch")
|
||||
|
||||
|
||||
def validate_engine_mcp_telemetry_catalog_slice(payload_dir, entries):
|
||||
if tuple(entries) != ENGINE_MCP_TELEMETRY_CATALOG_ARTIFACT_ENTRIES:
|
||||
die("Engine MCP telemetry catalog files.txt exact set/order mismatch")
|
||||
for rel, expected_sha256 in ENGINE_MCP_TELEMETRY_CATALOG_TARGET_SHA256.items():
|
||||
path = payload_dir / rel
|
||||
try:
|
||||
path_stat = path.lstat()
|
||||
except FileNotFoundError:
|
||||
die(f"Engine MCP telemetry catalog target is missing: {rel}")
|
||||
if (
|
||||
stat.S_ISLNK(path_stat.st_mode)
|
||||
or not stat.S_ISREG(path_stat.st_mode)
|
||||
or sha256_file(path) != expected_sha256
|
||||
):
|
||||
die(f"Engine MCP telemetry catalog target sha256 mismatch: {rel}")
|
||||
descriptor = read_strict_json(
|
||||
payload_dir / ENGINE_MCP_TELEMETRY_CATALOG_DESCRIPTOR_REL,
|
||||
"Engine MCP telemetry catalog descriptor",
|
||||
max_bytes=16 * 1024,
|
||||
)
|
||||
expected_descriptor = {
|
||||
"schemaVersion": "nodedc.engine.deploy-transition/v1",
|
||||
"id": "engine-mcp-telemetry-reading-catalog-v1",
|
||||
"component": "engine",
|
||||
"scope": "external-mcp-observability",
|
||||
"mcpVersion": "0.8.0",
|
||||
"sourcePaths": [
|
||||
"nodedc-source/server/routes/n8n.js",
|
||||
"nodedc-source/server/routes/engineAgentGateway.js",
|
||||
],
|
||||
"readsOnly": "normalized-attributes.sensor_readings",
|
||||
"returns": [
|
||||
"reading-id",
|
||||
"safe-label",
|
||||
"safe-unit",
|
||||
"value-types",
|
||||
"coverage-counts",
|
||||
],
|
||||
"neverReturns": [
|
||||
"reading-value",
|
||||
"raw-execution-data",
|
||||
"raw-provider-payload",
|
||||
"credential-shaped-data",
|
||||
],
|
||||
}
|
||||
if descriptor != expected_descriptor:
|
||||
die("Engine MCP telemetry catalog descriptor contract mismatch")
|
||||
n8n_source = (payload_dir / "nodedc-source/server/routes/n8n.js").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
gateway_source = (
|
||||
payload_dir / "nodedc-source/server/routes/engineAgentGateway.js"
|
||||
).read_text(encoding="utf-8")
|
||||
if any(
|
||||
marker not in n8n_source
|
||||
for marker in (
|
||||
"function toSafeTelemetryReadingCatalog",
|
||||
"key === 'sensor_readings' && pathName.endsWith('.attributes')",
|
||||
"valuesIncluded: false,",
|
||||
"rawExecutionDataIncluded: false,",
|
||||
)
|
||||
):
|
||||
die("Engine MCP telemetry catalog backend contract mismatch")
|
||||
if any(
|
||||
marker not in gateway_source
|
||||
for marker in (
|
||||
"const ENGINE_AGENT_MCP_VERSION = '0.8.0'",
|
||||
"name: 'engine_get_telemetry_reading_catalog'",
|
||||
"/telemetry-reading-catalog?",
|
||||
)
|
||||
):
|
||||
die("Engine MCP telemetry catalog gateway contract mismatch")
|
||||
|
||||
|
||||
def validate_engine_agent_full_grant_migration_slice(payload_dir, entries):
|
||||
if tuple(entries) != ENGINE_AGENT_FULL_GRANT_MIGRATION_ARTIFACT_ENTRIES:
|
||||
die("Engine agent full grant migration files.txt exact set/order mismatch")
|
||||
|
|
@ -5474,6 +5608,8 @@ def load_artifact(artifact, work_dir):
|
|||
entries,
|
||||
):
|
||||
validate_engine_mcp_execution_profile_decoder_slice(payload_dir, entries)
|
||||
if is_engine_mcp_telemetry_catalog_slice(manifest["component"], entries):
|
||||
validate_engine_mcp_telemetry_catalog_slice(payload_dir, entries)
|
||||
if is_engine_provider_security_catalog_slice(manifest["component"], entries):
|
||||
validate_engine_provider_security_catalog_payload(payload_dir, entries)
|
||||
if touches_engine_credential_sink(manifest["component"], entries):
|
||||
|
|
@ -5491,6 +5627,10 @@ def load_artifact(artifact, work_dir):
|
|||
manifest["component"],
|
||||
entries,
|
||||
)
|
||||
and not is_engine_mcp_telemetry_catalog_slice(
|
||||
manifest["component"],
|
||||
entries,
|
||||
)
|
||||
and (
|
||||
touches_engine_data_product_publish_grant(entries)
|
||||
or ENGINE_DATA_PRODUCT_PUBLISH_GRANT_OVERRIDE_REL in entries
|
||||
|
|
@ -5677,6 +5817,14 @@ def is_engine_mcp_execution_profile_decoder_slice(component, entries):
|
|||
)
|
||||
|
||||
|
||||
def is_engine_mcp_telemetry_catalog_slice(component, entries):
|
||||
return (
|
||||
component == "engine"
|
||||
and entries is not None
|
||||
and tuple(entries) == ENGINE_MCP_TELEMETRY_CATALOG_ARTIFACT_ENTRIES
|
||||
)
|
||||
|
||||
|
||||
def is_engine_agent_full_grant_migration_slice(component, entries):
|
||||
return (
|
||||
component == "engine"
|
||||
|
|
@ -6156,6 +6304,55 @@ def preflight_engine_mcp_execution_profile_decoder_predecessor():
|
|||
}
|
||||
|
||||
|
||||
def preflight_engine_mcp_telemetry_catalog_predecessor():
|
||||
root = component_root("engine")
|
||||
actual = {}
|
||||
for rel, expected_sha256 in ENGINE_MCP_TELEMETRY_CATALOG_PREDECESSOR_SHA256.items():
|
||||
path = root / rel
|
||||
try:
|
||||
path_stat = path.lstat()
|
||||
except FileNotFoundError:
|
||||
die(f"Engine MCP telemetry catalog predecessor is missing: {rel}")
|
||||
if stat.S_ISLNK(path_stat.st_mode) or not stat.S_ISREG(path_stat.st_mode):
|
||||
die(f"Engine MCP telemetry catalog predecessor is unsafe: {rel}")
|
||||
actual_sha256 = sha256_file(path)
|
||||
if actual_sha256 != expected_sha256:
|
||||
die(
|
||||
"Engine MCP telemetry catalog predecessor drift detected: "
|
||||
f"path={rel} expected={expected_sha256} actual={actual_sha256}"
|
||||
)
|
||||
actual[rel] = actual_sha256
|
||||
foundation = {}
|
||||
for rel, expected_sha256 in ENGINE_MCP_TELEMETRY_CATALOG_FOUNDATION_SHA256.items():
|
||||
path = root / rel
|
||||
try:
|
||||
path_stat = path.lstat()
|
||||
except FileNotFoundError:
|
||||
die(f"Engine MCP telemetry catalog foundation is missing: {rel}")
|
||||
if (
|
||||
stat.S_ISLNK(path_stat.st_mode)
|
||||
or not stat.S_ISREG(path_stat.st_mode)
|
||||
or sha256_file(path) != expected_sha256
|
||||
):
|
||||
die(f"Engine MCP telemetry catalog foundation drift detected: {rel}")
|
||||
foundation[rel] = expected_sha256
|
||||
for rel in ENGINE_MCP_TELEMETRY_CATALOG_NEW_PATHS:
|
||||
path = root / rel
|
||||
if path.exists() or path.is_symlink():
|
||||
die(f"Engine MCP telemetry catalog new path already exists: {rel}")
|
||||
backend = preflight_engine_credential_backend_runtime()
|
||||
if backend["mode"] != "verified-derived-retry":
|
||||
die("Engine MCP telemetry catalog requires the active immutable backend")
|
||||
return {
|
||||
"mode": "execution-profile-decoder-v1-to-telemetry-catalog-v1",
|
||||
"predecessor_sha256": actual,
|
||||
"foundation_sha256": foundation,
|
||||
"target_sha256": dict(ENGINE_MCP_TELEMETRY_CATALOG_TARGET_SHA256),
|
||||
"new_paths": tuple(ENGINE_MCP_TELEMETRY_CATALOG_NEW_PATHS),
|
||||
"backend_mode": backend["mode"],
|
||||
}
|
||||
|
||||
|
||||
def preflight_engine_agent_full_grant_migration_predecessor():
|
||||
root = component_root("engine")
|
||||
store_path = root / ENGINE_AGENT_FULL_GRANT_MIGRATION_STORE_REL
|
||||
|
|
@ -6210,6 +6407,7 @@ def component_services(component, entries=None):
|
|||
or is_engine_depttrans_zone_authority_v1_slice(component, entries)
|
||||
or is_engine_provider_target_host_policy_slice(component, entries)
|
||||
or is_engine_mcp_execution_profile_decoder_slice(component, entries)
|
||||
or is_engine_mcp_telemetry_catalog_slice(component, entries)
|
||||
or is_engine_provider_security_catalog_slice(component, entries)
|
||||
):
|
||||
# This slice updates only the existing Engine backend control plane.
|
||||
|
|
@ -8419,6 +8617,7 @@ def plan_artifact(artifact):
|
|||
depttrans_zone_authority_v1_preflight = None
|
||||
provider_target_host_policy_preflight = None
|
||||
mcp_execution_profile_decoder_preflight = None
|
||||
mcp_telemetry_catalog_preflight = None
|
||||
provider_catalog_preflight = None
|
||||
with tempfile.TemporaryDirectory(prefix="plan-", dir=TMP_DIR) as tmp:
|
||||
manifest, entries, payload_dir = load_artifact(artifact, Path(tmp))
|
||||
|
|
@ -8480,6 +8679,10 @@ def plan_artifact(artifact):
|
|||
mcp_execution_profile_decoder_preflight = (
|
||||
preflight_engine_mcp_execution_profile_decoder_predecessor()
|
||||
)
|
||||
if is_engine_mcp_telemetry_catalog_slice(manifest["component"], entries):
|
||||
mcp_telemetry_catalog_preflight = (
|
||||
preflight_engine_mcp_telemetry_catalog_predecessor()
|
||||
)
|
||||
if is_engine_provider_security_catalog_slice(manifest["component"], entries):
|
||||
provider_catalog_preflight = preflight_engine_provider_security_catalog_predecessor()
|
||||
|
||||
|
|
@ -8518,6 +8721,10 @@ def plan_artifact(artifact):
|
|||
entries,
|
||||
)
|
||||
)
|
||||
touches_mcp_telemetry_catalog = is_engine_mcp_telemetry_catalog_slice(
|
||||
component,
|
||||
entries,
|
||||
)
|
||||
touches_agent_grant_migration = is_engine_agent_full_grant_migration_slice(
|
||||
component,
|
||||
entries,
|
||||
|
|
@ -8534,6 +8741,7 @@ def plan_artifact(artifact):
|
|||
or touches_depttrans_zone_authority_v1
|
||||
or touches_provider_target_host_policy
|
||||
or touches_mcp_execution_profile_decoder
|
||||
or touches_mcp_telemetry_catalog
|
||||
or touches_agent_grant_migration
|
||||
):
|
||||
credential_backend_preflight = preflight_engine_credential_backend_runtime()
|
||||
|
|
@ -8576,6 +8784,14 @@ def plan_artifact(artifact):
|
|||
"Engine MCP execution profile decoder requires the active "
|
||||
"immutable credential backend"
|
||||
)
|
||||
if touches_mcp_telemetry_catalog:
|
||||
if mcp_telemetry_catalog_preflight is None:
|
||||
die("Engine MCP telemetry catalog preflight is missing")
|
||||
if credential_backend_preflight["mode"] != "verified-derived-retry":
|
||||
die(
|
||||
"Engine MCP telemetry catalog requires the active immutable "
|
||||
"credential backend"
|
||||
)
|
||||
if touches_agent_grant_migration:
|
||||
agent_grant_migration_predecessor_sha256 = (
|
||||
preflight_engine_agent_full_grant_migration_predecessor()
|
||||
|
|
@ -8887,6 +9103,58 @@ def plan_artifact(artifact):
|
|||
print("engine_databases=untouched")
|
||||
print("mcp_nginx=untouched")
|
||||
print("embedded_ai_workspace=untouched")
|
||||
if mcp_telemetry_catalog_preflight:
|
||||
print(
|
||||
"engine_mcp_observability_transition="
|
||||
f"{mcp_telemetry_catalog_preflight['mode']}"
|
||||
)
|
||||
print("engine_mcp_version=0.8.0")
|
||||
print("engine_mcp_surface=external-codex")
|
||||
print("engine_mcp_tool=engine_get_telemetry_reading_catalog")
|
||||
print("engine_mcp_reading_values_included=no")
|
||||
print("engine_mcp_raw_execution_data_included=no")
|
||||
for foundation_path, foundation_sha256 in (
|
||||
mcp_telemetry_catalog_preflight["foundation_sha256"].items()
|
||||
):
|
||||
print(
|
||||
f"engine_mcp_telemetry_catalog_foundation_sha256[{foundation_path}]="
|
||||
f"{foundation_sha256}"
|
||||
)
|
||||
for changed_path in ENGINE_MCP_TELEMETRY_CATALOG_ARTIFACT_ENTRIES:
|
||||
print(f"engine_mcp_telemetry_catalog_changed_path={changed_path}")
|
||||
if changed_path in mcp_telemetry_catalog_preflight[
|
||||
"predecessor_sha256"
|
||||
]:
|
||||
print(
|
||||
f"engine_mcp_telemetry_catalog_predecessor_sha256[{changed_path}]="
|
||||
f"{mcp_telemetry_catalog_preflight['predecessor_sha256'][changed_path]}"
|
||||
)
|
||||
elif changed_path in mcp_telemetry_catalog_preflight["new_paths"]:
|
||||
print(
|
||||
f"engine_mcp_telemetry_catalog_predecessor_state[{changed_path}]="
|
||||
"absent"
|
||||
)
|
||||
else:
|
||||
die(
|
||||
"Engine MCP telemetry catalog plan has no predecessor state: "
|
||||
f"{changed_path}"
|
||||
)
|
||||
print(
|
||||
f"engine_mcp_telemetry_catalog_target_sha256[{changed_path}]="
|
||||
f"{mcp_telemetry_catalog_preflight['target_sha256'][changed_path]}"
|
||||
)
|
||||
print(
|
||||
"backend_current_barrier="
|
||||
f"{mcp_telemetry_catalog_preflight['backend_mode']}"
|
||||
)
|
||||
print("backend_force_recreate=yes")
|
||||
print("backend_pull=never")
|
||||
print("l2_graph=untouched")
|
||||
print("n8n_l1=untouched")
|
||||
print("engine_ui=untouched")
|
||||
print("engine_databases=untouched")
|
||||
print("mcp_nginx=untouched")
|
||||
print("embedded_ai_workspace=untouched")
|
||||
if transition_descriptor:
|
||||
print(f"n8n_transition={transition_descriptor['action']}")
|
||||
print(f"n8n_version={transition_descriptor['n8nVersion']}")
|
||||
|
|
@ -10004,6 +10272,7 @@ def component_healthchecks(component, entries=None, services=None):
|
|||
or is_engine_depttrans_zone_authority_v1_slice(component, entries)
|
||||
or is_engine_provider_target_host_policy_slice(component, entries)
|
||||
or is_engine_mcp_execution_profile_decoder_slice(component, entries)
|
||||
or is_engine_mcp_telemetry_catalog_slice(component, entries)
|
||||
or is_engine_agent_full_grant_migration_slice(component, entries)
|
||||
or is_engine_mcp_control_plane_slice(component, entries)
|
||||
or is_engine_mcp_ontology_sdk_slice(component, entries)
|
||||
|
|
@ -10417,6 +10686,10 @@ def run_healthchecks(component, entries=None, services=None):
|
|||
entries,
|
||||
)
|
||||
)
|
||||
touches_mcp_telemetry_catalog = is_engine_mcp_telemetry_catalog_slice(
|
||||
component,
|
||||
entries,
|
||||
)
|
||||
touches_agent_grant_migration = is_engine_agent_full_grant_migration_slice(
|
||||
component,
|
||||
entries,
|
||||
|
|
@ -10434,6 +10707,7 @@ def run_healthchecks(component, entries=None, services=None):
|
|||
or touches_depttrans_zone_authority_v1
|
||||
or touches_provider_target_host_policy
|
||||
or touches_mcp_execution_profile_decoder
|
||||
or touches_mcp_telemetry_catalog
|
||||
or touches_agent_grant_migration
|
||||
or touches_mcp_control_plane
|
||||
or touches_mcp_ontology_sdk
|
||||
|
|
@ -10455,6 +10729,7 @@ def run_healthchecks(component, entries=None, services=None):
|
|||
or touches_depttrans_zone_authority_v1
|
||||
or touches_provider_target_host_policy
|
||||
or touches_mcp_execution_profile_decoder
|
||||
or touches_mcp_telemetry_catalog
|
||||
or touches_agent_grant_migration
|
||||
or touches_mcp_control_plane
|
||||
or touches_mcp_ontology_sdk
|
||||
|
|
@ -10566,6 +10841,40 @@ def run_healthchecks(component, entries=None, services=None):
|
|||
"Engine MCP execution profile decoder installed state is neither "
|
||||
"target nor rollback predecessor"
|
||||
)
|
||||
if touches_mcp_telemetry_catalog:
|
||||
root = component_root("engine")
|
||||
target_state = all(
|
||||
(root / rel).is_file()
|
||||
and not (root / rel).is_symlink()
|
||||
and sha256_file(root / rel) == expected
|
||||
for rel, expected in ENGINE_MCP_TELEMETRY_CATALOG_TARGET_SHA256.items()
|
||||
) and all(
|
||||
(root / rel).is_file()
|
||||
and not (root / rel).is_symlink()
|
||||
and sha256_file(root / rel) == expected
|
||||
for rel, expected in ENGINE_MCP_TELEMETRY_CATALOG_FOUNDATION_SHA256.items()
|
||||
)
|
||||
predecessor_state = all(
|
||||
(root / rel).is_file()
|
||||
and not (root / rel).is_symlink()
|
||||
and sha256_file(root / rel) == expected
|
||||
for rel, expected in ENGINE_MCP_TELEMETRY_CATALOG_PREDECESSOR_SHA256.items()
|
||||
) and all(
|
||||
(root / rel).is_file()
|
||||
and not (root / rel).is_symlink()
|
||||
and sha256_file(root / rel) == expected
|
||||
for rel, expected in ENGINE_MCP_TELEMETRY_CATALOG_FOUNDATION_SHA256.items()
|
||||
) and all(
|
||||
not (root / rel).exists() and not (root / rel).is_symlink()
|
||||
for rel in ENGINE_MCP_TELEMETRY_CATALOG_NEW_PATHS
|
||||
)
|
||||
if target_state:
|
||||
accept_engine_mcp_telemetry_catalog_runtime()
|
||||
elif not predecessor_state:
|
||||
die(
|
||||
"Engine MCP telemetry catalog installed state is neither target "
|
||||
"nor rollback predecessor"
|
||||
)
|
||||
container_name = COMPONENTS[component].get("health_container")
|
||||
if container_name:
|
||||
healthcheck_container(container_name)
|
||||
|
|
@ -10670,6 +10979,19 @@ def apply_artifact(artifact):
|
|||
"Engine MCP execution profile decoder requires the "
|
||||
"active immutable credential backend"
|
||||
)
|
||||
if is_engine_mcp_telemetry_catalog_slice(component, entries):
|
||||
preflight_engine_mcp_telemetry_catalog_predecessor()
|
||||
telemetry_catalog_backend_preflight = (
|
||||
preflight_engine_credential_backend_runtime()
|
||||
)
|
||||
if (
|
||||
telemetry_catalog_backend_preflight["mode"]
|
||||
!= "verified-derived-retry"
|
||||
):
|
||||
die(
|
||||
"Engine MCP telemetry catalog requires the active "
|
||||
"immutable credential backend"
|
||||
)
|
||||
if is_engine_agent_full_grant_migration_slice(component, entries):
|
||||
preflight_engine_agent_full_grant_migration_predecessor()
|
||||
migration_backend_preflight = preflight_engine_credential_backend_runtime()
|
||||
|
|
@ -10926,6 +11248,7 @@ def apply_artifact(artifact):
|
|||
component,
|
||||
entries,
|
||||
)
|
||||
or is_engine_mcp_telemetry_catalog_slice(component, entries)
|
||||
or is_engine_agent_full_grant_migration_slice(component, entries)
|
||||
or is_engine_mcp_control_plane_slice(component, entries)
|
||||
or is_engine_mcp_ontology_sdk_slice(component, entries)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,324 @@
|
|||
import hashlib
|
||||
import importlib.machinery
|
||||
import importlib.util
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tarfile
|
||||
import tempfile
|
||||
import unittest
|
||||
from contextlib import redirect_stdout
|
||||
from unittest import mock
|
||||
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
RUNNER_PATH = SCRIPT_DIR / "nodedc-deploy"
|
||||
BUILDER_PATH = SCRIPT_DIR / "build-engine-mcp-telemetry-catalog-artifact.mjs"
|
||||
ENGINE_ROOT = SCRIPT_DIR.parent.parent.parent / "NODEDC_ENGINE_INFRA"
|
||||
PATCH_ID = "engine-mcp-telemetry-catalog-20991231-999"
|
||||
|
||||
|
||||
def load_runner():
|
||||
loader = importlib.machinery.SourceFileLoader(
|
||||
"nodedc_engine_mcp_telemetry_catalog",
|
||||
str(RUNNER_PATH),
|
||||
)
|
||||
spec = importlib.util.spec_from_loader(loader.name, loader)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
RUNNER = load_runner()
|
||||
|
||||
|
||||
class EngineMcpTelemetryCatalogTest(unittest.TestCase):
|
||||
def require_current_target_source(self):
|
||||
for relative_path, expected in (
|
||||
RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_TARGET_SHA256.items()
|
||||
):
|
||||
path = ENGINE_ROOT / relative_path
|
||||
if (
|
||||
not path.is_file()
|
||||
or hashlib.sha256(path.read_bytes()).hexdigest() != expected
|
||||
):
|
||||
self.skipTest(
|
||||
"telemetry catalog source has advanced to its exact successor"
|
||||
)
|
||||
|
||||
def build(self, artifact_dir):
|
||||
environment = os.environ.copy()
|
||||
environment["NODEDC_ENGINE_SOURCE_ROOT"] = str(ENGINE_ROOT)
|
||||
environment["NODEDC_DEPLOY_ARTIFACT_DIR"] = str(artifact_dir)
|
||||
completed = subprocess.run(
|
||||
["node", str(BUILDER_PATH), PATCH_ID],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
env=environment,
|
||||
)
|
||||
return json.loads(completed.stdout)
|
||||
|
||||
def test_builder_emits_exact_deterministic_backend_only_slice(self):
|
||||
self.require_current_target_source()
|
||||
with tempfile.TemporaryDirectory(
|
||||
prefix="nodedc-engine-mcp-telemetry-catalog-"
|
||||
) as directory:
|
||||
root = Path(directory)
|
||||
first = self.build(root / "first")
|
||||
second = self.build(root / "second")
|
||||
first_artifact = Path(first["artifact"])
|
||||
second_artifact = Path(second["artifact"])
|
||||
self.assertEqual(first_artifact.read_bytes(), second_artifact.read_bytes())
|
||||
self.assertEqual(
|
||||
first["sha256"],
|
||||
hashlib.sha256(first_artifact.read_bytes()).hexdigest(),
|
||||
)
|
||||
self.assertEqual(first["services"], ["nodedc-backend"])
|
||||
self.assertEqual(first["mcpVersion"], "0.8.0")
|
||||
self.assertEqual(first["readingValuesIncluded"], False)
|
||||
self.assertEqual(first["rawExecutionDataIncluded"], False)
|
||||
self.assertEqual(
|
||||
tuple(first["entries"]),
|
||||
RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_ARTIFACT_ENTRIES,
|
||||
)
|
||||
|
||||
extract = root / "extract"
|
||||
with tarfile.open(first_artifact, "r:gz") as archive:
|
||||
archive.extractall(extract, filter="data")
|
||||
entries = tuple(
|
||||
(extract / "files.txt").read_text(encoding="utf-8").splitlines()
|
||||
)
|
||||
payload = extract / "payload"
|
||||
self.assertTrue(
|
||||
RUNNER.is_engine_mcp_telemetry_catalog_slice("engine", entries)
|
||||
)
|
||||
self.assertFalse(
|
||||
RUNNER.is_engine_mcp_execution_profile_decoder_slice(
|
||||
"engine",
|
||||
entries,
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
RUNNER.component_services("engine", entries),
|
||||
("nodedc-backend",),
|
||||
)
|
||||
self.assertEqual(
|
||||
RUNNER.component_healthchecks(
|
||||
"engine",
|
||||
entries,
|
||||
("nodedc-backend",),
|
||||
),
|
||||
("http://127.0.0.1:3001/health",),
|
||||
)
|
||||
RUNNER.validate_engine_mcp_telemetry_catalog_slice(payload, entries)
|
||||
with tempfile.TemporaryDirectory(
|
||||
prefix="nodedc-engine-mcp-telemetry-load-"
|
||||
) as load_directory:
|
||||
loaded = RUNNER.load_artifact(
|
||||
first_artifact,
|
||||
Path(load_directory),
|
||||
)
|
||||
self.assertEqual(loaded[0]["component"], "engine")
|
||||
self.assertEqual(tuple(loaded[1]), entries)
|
||||
|
||||
def test_preflight_requires_032_foundation_and_absent_new_descriptor(self):
|
||||
with tempfile.TemporaryDirectory(
|
||||
prefix="nodedc-engine-mcp-telemetry-preflight-"
|
||||
) as directory:
|
||||
root = Path(directory)
|
||||
hashes = {}
|
||||
for mapping in (
|
||||
RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_PREDECESSOR_SHA256,
|
||||
RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_FOUNDATION_SHA256,
|
||||
):
|
||||
for relative_path, expected in mapping.items():
|
||||
path = root / relative_path
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text("installed\n", encoding="utf-8")
|
||||
hashes[path] = expected
|
||||
|
||||
with (
|
||||
mock.patch.object(RUNNER, "component_root", return_value=root),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"sha256_file",
|
||||
side_effect=lambda path: hashes[Path(path)],
|
||||
),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"preflight_engine_credential_backend_runtime",
|
||||
return_value={"mode": "verified-derived-retry"},
|
||||
),
|
||||
):
|
||||
result = RUNNER.preflight_engine_mcp_telemetry_catalog_predecessor()
|
||||
self.assertEqual(
|
||||
result["mode"],
|
||||
"execution-profile-decoder-v1-to-telemetry-catalog-v1",
|
||||
)
|
||||
self.assertEqual(
|
||||
result["foundation_sha256"],
|
||||
RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_FOUNDATION_SHA256,
|
||||
)
|
||||
|
||||
descriptor = root / RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_DESCRIPTOR_REL
|
||||
descriptor.parent.mkdir(parents=True, exist_ok=True)
|
||||
descriptor.write_text("{}\n", encoding="utf-8")
|
||||
with (
|
||||
mock.patch.object(RUNNER, "component_root", return_value=root),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"sha256_file",
|
||||
side_effect=lambda path: hashes[Path(path)],
|
||||
),
|
||||
):
|
||||
with self.assertRaises(RUNNER.DeployError):
|
||||
RUNNER.preflight_engine_mcp_telemetry_catalog_predecessor()
|
||||
|
||||
def test_plan_renders_exact_external_mcp_boundary(self):
|
||||
self.require_current_target_source()
|
||||
with tempfile.TemporaryDirectory(
|
||||
prefix="nodedc-engine-mcp-telemetry-plan-"
|
||||
) as directory:
|
||||
root = Path(directory)
|
||||
built = self.build(root / "artifacts")
|
||||
artifact = Path(built["artifact"])
|
||||
live_root = root / "live"
|
||||
live_root.mkdir()
|
||||
preflight = {
|
||||
"mode": "execution-profile-decoder-v1-to-telemetry-catalog-v1",
|
||||
"predecessor_sha256": dict(
|
||||
RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_PREDECESSOR_SHA256
|
||||
),
|
||||
"foundation_sha256": dict(
|
||||
RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_FOUNDATION_SHA256
|
||||
),
|
||||
"target_sha256": dict(
|
||||
RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_TARGET_SHA256
|
||||
),
|
||||
"new_paths": tuple(
|
||||
RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_NEW_PATHS
|
||||
),
|
||||
"backend_mode": "verified-derived-retry",
|
||||
}
|
||||
output = io.StringIO()
|
||||
with (
|
||||
mock.patch.object(RUNNER, "validate_artifact_location"),
|
||||
mock.patch.object(RUNNER, "ensure_layout"),
|
||||
mock.patch.object(RUNNER, "TMP_DIR", root),
|
||||
mock.patch.object(RUNNER, "component_root", return_value=live_root),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"component_compose_root",
|
||||
return_value=live_root,
|
||||
),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"preflight_engine_mcp_telemetry_catalog_predecessor",
|
||||
return_value=preflight,
|
||||
),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"preflight_engine_credential_backend_runtime",
|
||||
return_value={"mode": "verified-derived-retry"},
|
||||
),
|
||||
mock.patch.object(RUNNER, "state_has_sha", return_value=False),
|
||||
mock.patch.object(RUNNER, "state_has_patch_id", return_value=False),
|
||||
redirect_stdout(output),
|
||||
):
|
||||
RUNNER.plan_artifact(artifact)
|
||||
plan = output.getvalue()
|
||||
self.assertIn("services=nodedc-backend", plan)
|
||||
self.assertIn("engine_mcp_version=0.8.0", plan)
|
||||
self.assertIn("engine_mcp_surface=external-codex", plan)
|
||||
self.assertIn(
|
||||
"engine_mcp_tool=engine_get_telemetry_reading_catalog",
|
||||
plan,
|
||||
)
|
||||
self.assertIn("engine_mcp_reading_values_included=no", plan)
|
||||
self.assertIn("mcp_nginx=untouched", plan)
|
||||
self.assertIn("embedded_ai_workspace=untouched", plan)
|
||||
self.assertIn(
|
||||
"engine_mcp_telemetry_catalog_predecessor_state"
|
||||
f"[{RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_DESCRIPTOR_REL}]=absent",
|
||||
plan,
|
||||
)
|
||||
self.assertIn("state=new", plan)
|
||||
|
||||
def test_healthchecks_dispatch_safe_catalog_acceptance(self):
|
||||
entries = RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_ARTIFACT_ENTRIES
|
||||
with tempfile.TemporaryDirectory(
|
||||
prefix="nodedc-engine-mcp-telemetry-health-"
|
||||
) as directory:
|
||||
root = Path(directory)
|
||||
all_hashes = {
|
||||
**RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_TARGET_SHA256,
|
||||
**RUNNER.ENGINE_MCP_TELEMETRY_CATALOG_FOUNDATION_SHA256,
|
||||
}
|
||||
for relative_path in all_hashes:
|
||||
path = root / relative_path
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text("target\n", encoding="utf-8")
|
||||
|
||||
def target_hash(path):
|
||||
relative_path = Path(path).relative_to(root).as_posix()
|
||||
return all_hashes[relative_path]
|
||||
|
||||
with (
|
||||
mock.patch.object(RUNNER, "component_root", return_value=root),
|
||||
mock.patch.object(RUNNER, "sha256_file", side_effect=target_hash),
|
||||
mock.patch.object(RUNNER, "healthcheck_compose_service"),
|
||||
mock.patch.object(RUNNER, "component_healthchecks", return_value=()),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"preflight_engine_credential_backend_runtime",
|
||||
return_value={"mode": "verified-derived-retry"},
|
||||
),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"accept_engine_mcp_telemetry_catalog_runtime",
|
||||
return_value={"live": "accepted"},
|
||||
) as acceptance,
|
||||
mock.patch.object(RUNNER, "healthcheck_container"),
|
||||
):
|
||||
RUNNER.run_healthchecks(
|
||||
"engine",
|
||||
entries,
|
||||
("nodedc-backend",),
|
||||
)
|
||||
acceptance.assert_called_once_with()
|
||||
|
||||
def test_live_acceptance_uses_normalized_metadata_only_contract(self):
|
||||
self.require_current_target_source()
|
||||
expected_live = (
|
||||
"engine-mcp-telemetry-catalog:"
|
||||
"0.8.0:normalized-metadata-only:v1"
|
||||
)
|
||||
with (
|
||||
mock.patch.object(RUNNER, "component_root", return_value=ENGINE_ROOT),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"engine_backend_container_id",
|
||||
return_value="backend",
|
||||
),
|
||||
mock.patch.object(
|
||||
RUNNER,
|
||||
"run_engine_backend_probe",
|
||||
return_value=expected_live,
|
||||
) as backend_probe,
|
||||
):
|
||||
result = RUNNER.accept_engine_mcp_telemetry_catalog_runtime()
|
||||
self.assertEqual(result["live"], expected_live)
|
||||
self.assertEqual(
|
||||
backend_probe.call_args.args[1],
|
||||
"Engine MCP telemetry reading catalog",
|
||||
)
|
||||
probe_source = backend_probe.call_args.args[0][-1]
|
||||
self.assertIn("toSafeTelemetryReadingCatalog", probe_source)
|
||||
self.assertIn("engine_get_telemetry_reading_catalog", probe_source)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
|
|
@ -147,6 +147,35 @@ class EngineNodeIntelligenceTest(unittest.TestCase):
|
|||
)
|
||||
self.assertEqual(actual, descriptor)
|
||||
|
||||
def test_gateway_accepts_registered_0_8_and_rejects_unknown_successors(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
payload, descriptor = self.make_activation_payload(Path(directory))
|
||||
gateway = payload / RUNNER.ENGINE_NODE_INTELLIGENCE_GATEWAY_REL
|
||||
gateway_text = gateway.read_text(encoding="utf-8")
|
||||
self.assertIn("const ENGINE_AGENT_MCP_VERSION = '0.8.0'", gateway_text)
|
||||
gateway.write_text(
|
||||
gateway_text.replace(
|
||||
"const ENGINE_AGENT_MCP_VERSION = '0.8.0'",
|
||||
"const ENGINE_AGENT_MCP_VERSION = '9.9.9'",
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
descriptor["source"]["gatewaySha256"] = sha256(gateway)
|
||||
(
|
||||
payload / RUNNER.ENGINE_NODE_INTELLIGENCE_DESCRIPTOR_REL
|
||||
).write_text(
|
||||
json.dumps(descriptor, indent=2) + "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
with self.assertRaisesRegex(
|
||||
RUNNER.DeployError,
|
||||
"gateway MCP version is not registered",
|
||||
):
|
||||
RUNNER.validate_engine_node_intelligence_transition(
|
||||
payload,
|
||||
RUNNER.ENGINE_NODE_INTELLIGENCE_ARTIFACT_ENTRIES,
|
||||
)
|
||||
|
||||
def test_archive_tamper_and_embedded_authority_fail_closed(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
|
|
|
|||
Loading…
Reference in New Issue