feat(deploy): register Engine MCP profile decoder transition

This commit is contained in:
Codex
2026-07-23 14:38:12 +03:00
parent 50cba59bde
commit e4383b6162
3 changed files with 773 additions and 0 deletions
+272
View File
@@ -530,6 +530,23 @@ ENGINE_PROVIDER_TARGET_HOST_POLICY_PREDECESSOR_SHA256 = {
ENGINE_PROVIDER_TARGET_HOST_POLICY_TARGET_SHA256 = {
"nodedc-source/server/routes/n8n.js": "9bc3638e271102abec91bb80413329befb89d60c0e4dc0548f0dd11e93220d0a",
}
ENGINE_MCP_EXECUTION_PROFILE_DECODER_DESCRIPTOR_REL = (
"nodedc-source/server/deployTransitions/executionProfileDecoderV1.json"
)
ENGINE_MCP_EXECUTION_PROFILE_DECODER_ARTIFACT_ENTRIES = (
"nodedc-source/server/routes/n8n.js",
ENGINE_MCP_EXECUTION_PROFILE_DECODER_DESCRIPTOR_REL,
)
ENGINE_MCP_EXECUTION_PROFILE_DECODER_PREDECESSOR_SHA256 = {
"nodedc-source/server/routes/n8n.js": "752cb1524160adc1c95163c34e139b615c063d2ce8980f2a63879bddbd0f1e08",
}
ENGINE_MCP_EXECUTION_PROFILE_DECODER_TARGET_SHA256 = {
"nodedc-source/server/routes/n8n.js": "1c2427c1d5830c40b1e8ae05f3d683fc39d07d7e0fe2431b0f6efbbb1d3fcb88",
ENGINE_MCP_EXECUTION_PROFILE_DECODER_DESCRIPTOR_REL: "93e431902e9bcd3b828a82ed6b42b48d939051f21bf8824dafcf2addac8a711c",
}
ENGINE_MCP_EXECUTION_PROFILE_DECODER_NEW_PATHS = (
ENGINE_MCP_EXECUTION_PROFILE_DECODER_DESCRIPTOR_REL,
)
ENGINE_AGENT_FULL_GRANT_MIGRATION_ARTIFACT_ENTRIES = (
ENGINE_AGENT_FULL_GRANT_MIGRATION_STORE_REL,
)
@@ -4307,6 +4324,41 @@ process.stdout.write('engine-provider-target-host-policy:exact-literal-host:v1')
}
def accept_engine_mcp_execution_profile_decoder_runtime():
root = component_root("engine")
validate_engine_mcp_execution_profile_decoder_slice(
root,
ENGINE_MCP_EXECUTION_PROFILE_DECODER_ARTIFACT_ENTRIES,
)
live = run_engine_backend_probe(
(
"node",
"--input-type=module",
"-e",
"""
const module=await import('file:///app/server/routes/n8n.js');
const execution={id:'profile-decoder-acceptance',data:JSON.stringify([{resultData:'1'},{runData:'2'},{Probe:'3'},['4'],{data:'5'},{main:'6'},[['7']],{json:'8'},{params:'9'},{VS_43:'10',mcc:'11',sats:9},'16','250'])};
const profile=module.toSafeNodeOutputProfile(execution,'Probe');
const paths=new Map(profile.paths.map((item)=>[item.path,item]));
if(!profile.found||profile.valuesIncluded!==false||paths.get('$.params.VS_43')?.types?.join(',')!=='string'||paths.get('$.params.VS_43')?.minLength!==2||paths.get('$.params.mcc')?.types?.join(',')!=='string'||paths.get('$.params.mcc')?.minLength!==3||paths.get('$.params.sats')?.types?.join(',')!=='number'||profile.paths.some((item)=>item.path.includes('.json.fact')))process.exit(2);
process.stdout.write('engine-mcp-execution-profile-decoder:flatted-numeric-strings:safe-profile:v1');
""".strip(),
),
"Engine MCP execution profile decoder",
container_id=engine_backend_container_id(),
)
expected = (
"engine-mcp-execution-profile-decoder:"
"flatted-numeric-strings:safe-profile:v1"
)
if live != expected:
die("Engine MCP execution profile decoder live acceptance mismatch")
return {
"target_sha256": dict(ENGINE_MCP_EXECUTION_PROFILE_DECODER_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"):
@@ -4925,6 +4977,53 @@ def validate_engine_provider_target_host_policy_slice(payload_dir, entries):
die("Engine provider target host policy contract mismatch")
def validate_engine_mcp_execution_profile_decoder_slice(payload_dir, entries):
if tuple(entries) != ENGINE_MCP_EXECUTION_PROFILE_DECODER_ARTIFACT_ENTRIES:
die("Engine MCP execution profile decoder files.txt exact set/order mismatch")
for rel, expected_sha256 in ENGINE_MCP_EXECUTION_PROFILE_DECODER_TARGET_SHA256.items():
path = payload_dir / rel
try:
path_stat = path.lstat()
except FileNotFoundError:
die(f"Engine MCP execution profile decoder 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 execution profile decoder target sha256 mismatch: {rel}")
descriptor = read_strict_json(
payload_dir / ENGINE_MCP_EXECUTION_PROFILE_DECODER_DESCRIPTOR_REL,
"Engine MCP execution profile decoder descriptor",
max_bytes=16 * 1024,
)
expected_descriptor = {
"schemaVersion": "nodedc.engine.deploy-transition/v1",
"id": "engine-mcp-execution-profile-decoder-v1",
"component": "engine",
"scope": "external-mcp-observability",
"sourcePath": "nodedc-source/server/routes/n8n.js",
"behavior": "preserve-top-level-numeric-string-primitives-in-flatted-execution-data",
"acceptance": {
"tool": "engine_get_node_output_profile",
"valuesIncluded": False,
"rawExecutionDataIncluded": False,
},
}
if descriptor != expected_descriptor:
die("Engine MCP execution profile decoder descriptor contract mismatch")
source = (payload_dir / "nodedc-source/server/routes/n8n.js").read_text(
encoding="utf-8"
)
required_markers = (
"const compactReference = Symbol('n8nCompactReference')",
"Top-level string entries are primitive values.",
"valuesIncluded: false,",
)
if any(marker not in source for marker in required_markers):
die("Engine MCP execution profile decoder source 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")
@@ -5370,6 +5469,11 @@ def load_artifact(artifact, work_dir):
validate_engine_depttrans_zone_authority_v1_slice(payload_dir, entries)
if is_engine_provider_target_host_policy_slice(manifest["component"], entries):
validate_engine_provider_target_host_policy_slice(payload_dir, entries)
if is_engine_mcp_execution_profile_decoder_slice(
manifest["component"],
entries,
):
validate_engine_mcp_execution_profile_decoder_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):
@@ -5383,6 +5487,10 @@ def load_artifact(artifact, work_dir):
and not is_engine_provider_authority_diagnostics_slice(manifest["component"], entries)
and not is_engine_depttrans_zone_authority_v1_slice(manifest["component"], entries)
and not is_engine_provider_target_host_policy_slice(manifest["component"], entries)
and not is_engine_mcp_execution_profile_decoder_slice(
manifest["component"],
entries,
)
and (
touches_engine_data_product_publish_grant(entries)
or ENGINE_DATA_PRODUCT_PUBLISH_GRANT_OVERRIDE_REL in entries
@@ -5561,6 +5669,14 @@ def is_engine_provider_target_host_policy_slice(component, entries):
)
def is_engine_mcp_execution_profile_decoder_slice(component, entries):
return (
component == "engine"
and entries is not None
and tuple(entries) == ENGINE_MCP_EXECUTION_PROFILE_DECODER_ARTIFACT_ENTRIES
)
def is_engine_agent_full_grant_migration_slice(component, entries):
return (
component == "engine"
@@ -6004,6 +6120,42 @@ def preflight_engine_provider_target_host_policy_predecessor():
}
def preflight_engine_mcp_execution_profile_decoder_predecessor():
root = component_root("engine")
actual = {}
for rel, expected_sha256 in (
ENGINE_MCP_EXECUTION_PROFILE_DECODER_PREDECESSOR_SHA256.items()
):
path = root / rel
try:
path_stat = path.lstat()
except FileNotFoundError:
die(f"Engine MCP execution profile decoder 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 execution profile decoder predecessor is unsafe: {rel}")
actual_sha256 = sha256_file(path)
if actual_sha256 != expected_sha256:
die(
"Engine MCP execution profile decoder predecessor drift detected: "
f"path={rel} expected={expected_sha256} actual={actual_sha256}"
)
actual[rel] = actual_sha256
for rel in ENGINE_MCP_EXECUTION_PROFILE_DECODER_NEW_PATHS:
path = root / rel
if path.exists() or path.is_symlink():
die(f"Engine MCP execution profile decoder new path already exists: {rel}")
backend = preflight_engine_credential_backend_runtime()
if backend["mode"] != "verified-derived-retry":
die("Engine MCP execution profile decoder requires the active immutable backend")
return {
"mode": "exact-flatted-numeric-string-preservation",
"predecessor_sha256": actual,
"target_sha256": dict(ENGINE_MCP_EXECUTION_PROFILE_DECODER_TARGET_SHA256),
"new_paths": tuple(ENGINE_MCP_EXECUTION_PROFILE_DECODER_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
@@ -6057,6 +6209,7 @@ def component_services(component, entries=None):
or is_engine_provider_authority_diagnostics_slice(component, entries)
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_provider_security_catalog_slice(component, entries)
):
# This slice updates only the existing Engine backend control plane.
@@ -8265,6 +8418,7 @@ def plan_artifact(artifact):
provider_authority_diagnostics_preflight = None
depttrans_zone_authority_v1_preflight = None
provider_target_host_policy_preflight = None
mcp_execution_profile_decoder_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))
@@ -8319,6 +8473,13 @@ def plan_artifact(artifact):
provider_target_host_policy_preflight = (
preflight_engine_provider_target_host_policy_predecessor()
)
if is_engine_mcp_execution_profile_decoder_slice(
manifest["component"],
entries,
):
mcp_execution_profile_decoder_preflight = (
preflight_engine_mcp_execution_profile_decoder_predecessor()
)
if is_engine_provider_security_catalog_slice(manifest["component"], entries):
provider_catalog_preflight = preflight_engine_provider_security_catalog_predecessor()
@@ -8351,6 +8512,12 @@ def plan_artifact(artifact):
component,
entries,
)
touches_mcp_execution_profile_decoder = (
is_engine_mcp_execution_profile_decoder_slice(
component,
entries,
)
)
touches_agent_grant_migration = is_engine_agent_full_grant_migration_slice(
component,
entries,
@@ -8366,6 +8533,7 @@ def plan_artifact(artifact):
or touches_provider_authority_diagnostics
or touches_depttrans_zone_authority_v1
or touches_provider_target_host_policy
or touches_mcp_execution_profile_decoder
or touches_agent_grant_migration
):
credential_backend_preflight = preflight_engine_credential_backend_runtime()
@@ -8400,6 +8568,14 @@ def plan_artifact(artifact):
die("Engine provider target host policy preflight is missing")
if credential_backend_preflight["mode"] != "verified-derived-retry":
die("Engine provider target host policy requires the active immutable credential backend")
if touches_mcp_execution_profile_decoder:
if mcp_execution_profile_decoder_preflight is None:
die("Engine MCP execution profile decoder preflight is missing")
if credential_backend_preflight["mode"] != "verified-derived-retry":
die(
"Engine MCP execution profile decoder requires the active "
"immutable credential backend"
)
if touches_agent_grant_migration:
agent_grant_migration_predecessor_sha256 = (
preflight_engine_agent_full_grant_migration_predecessor()
@@ -8667,6 +8843,50 @@ def plan_artifact(artifact):
print("n8n_l1=untouched")
print("engine_ui=untouched")
print("engine_databases=untouched")
if mcp_execution_profile_decoder_preflight:
print(
"engine_mcp_observability_transition="
"exact-flatted-numeric-string-preservation"
)
print("engine_mcp_surface=external-codex")
print("engine_mcp_tool=engine_get_node_output_profile")
print("engine_mcp_profile_values_included=no")
print("engine_mcp_raw_execution_data_included=no")
for changed_path in ENGINE_MCP_EXECUTION_PROFILE_DECODER_ARTIFACT_ENTRIES:
print(f"engine_mcp_profile_decoder_changed_path={changed_path}")
if changed_path in mcp_execution_profile_decoder_preflight[
"predecessor_sha256"
]:
print(
f"engine_mcp_profile_decoder_predecessor_sha256[{changed_path}]="
f"{mcp_execution_profile_decoder_preflight['predecessor_sha256'][changed_path]}"
)
elif changed_path in mcp_execution_profile_decoder_preflight["new_paths"]:
print(
f"engine_mcp_profile_decoder_predecessor_state[{changed_path}]="
"absent"
)
else:
die(
"Engine MCP execution profile decoder plan has no predecessor "
f"state: {changed_path}"
)
print(
f"engine_mcp_profile_decoder_target_sha256[{changed_path}]="
f"{mcp_execution_profile_decoder_preflight['target_sha256'][changed_path]}"
)
print(
"backend_current_barrier="
f"{mcp_execution_profile_decoder_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']}")
@@ -9783,6 +10003,7 @@ def component_healthchecks(component, entries=None, services=None):
or is_engine_provider_authority_diagnostics_slice(component, entries)
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_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)
@@ -10190,6 +10411,12 @@ def run_healthchecks(component, entries=None, services=None):
component,
entries,
)
touches_mcp_execution_profile_decoder = (
is_engine_mcp_execution_profile_decoder_slice(
component,
entries,
)
)
touches_agent_grant_migration = is_engine_agent_full_grant_migration_slice(
component,
entries,
@@ -10206,6 +10433,7 @@ def run_healthchecks(component, entries=None, services=None):
or touches_provider_authority_diagnostics
or touches_depttrans_zone_authority_v1
or touches_provider_target_host_policy
or touches_mcp_execution_profile_decoder
or touches_agent_grant_migration
or touches_mcp_control_plane
or touches_mcp_ontology_sdk
@@ -10226,6 +10454,7 @@ def run_healthchecks(component, entries=None, services=None):
or touches_provider_authority_diagnostics
or touches_depttrans_zone_authority_v1
or touches_provider_target_host_policy
or touches_mcp_execution_profile_decoder
or touches_agent_grant_migration
or touches_mcp_control_plane
or touches_mcp_ontology_sdk
@@ -10311,6 +10540,32 @@ def run_healthchecks(component, entries=None, services=None):
accept_engine_provider_target_host_policy_runtime()
elif installed_sha256 != ENGINE_PROVIDER_TARGET_HOST_POLICY_PREDECESSOR_SHA256:
die("Engine provider target host policy installed state is neither target nor rollback predecessor")
if touches_mcp_execution_profile_decoder:
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_EXECUTION_PROFILE_DECODER_TARGET_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_EXECUTION_PROFILE_DECODER_PREDECESSOR_SHA256.items()
)
) and all(
not (root / rel).exists() and not (root / rel).is_symlink()
for rel in ENGINE_MCP_EXECUTION_PROFILE_DECODER_NEW_PATHS
)
if target_state:
accept_engine_mcp_execution_profile_decoder_runtime()
elif not predecessor_state:
die(
"Engine MCP execution profile decoder installed state is neither "
"target nor rollback predecessor"
)
container_name = COMPONENTS[component].get("health_container")
if container_name:
healthcheck_container(container_name)
@@ -10402,6 +10657,19 @@ def apply_artifact(artifact):
target_host_policy_backend_preflight = preflight_engine_credential_backend_runtime()
if target_host_policy_backend_preflight["mode"] != "verified-derived-retry":
die("Engine provider target host policy requires the active immutable credential backend")
if is_engine_mcp_execution_profile_decoder_slice(component, entries):
preflight_engine_mcp_execution_profile_decoder_predecessor()
profile_decoder_backend_preflight = (
preflight_engine_credential_backend_runtime()
)
if (
profile_decoder_backend_preflight["mode"]
!= "verified-derived-retry"
):
die(
"Engine MCP execution profile decoder 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()
@@ -10654,6 +10922,10 @@ def apply_artifact(artifact):
or is_engine_provider_authority_diagnostics_slice(component, entries)
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_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)