feat(deploy): register Engine telemetry catalog transition

This commit is contained in:
Codex
2026-07-23 14:55:56 +03:00
parent e4383b6162
commit f97a9d924d
4 changed files with 865 additions and 0 deletions
+323
View File
@@ -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)