feat(deploy): add execution plan sandbox runtime transition

This commit is contained in:
Codex
2026-07-24 18:17:05 +03:00
parent a9fe5f44e3
commit f0a4fb43c5
3 changed files with 974 additions and 0 deletions
+428
View File
@@ -817,6 +817,40 @@ ENGINE_MCP_L1_CREDENTIAL_PROVENANCE_TARGET_SHA256 = {
ENGINE_MCP_L1_CREDENTIAL_PROVENANCE_NEW_PATHS = (
ENGINE_MCP_L1_CREDENTIAL_PROVENANCE_DESCRIPTOR_REL,
)
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_DESCRIPTOR_REL = (
"nodedc-source/server/deployTransitions/executionPlanSandboxRuntimeV4.json"
)
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_ARTIFACT_ENTRIES = (
"nodedc-source/server/l2ExecutionPlan/compiler.js",
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_DESCRIPTOR_REL,
)
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_PREDECESSOR_SHA256 = {
"nodedc-source/server/l2ExecutionPlan/compiler.js":
"01958d541c778002d33e3aead0cfe02df2084eb7222ce941cc7149d73a10f135",
}
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_FOUNDATION_SHA256 = {
"nodedc-source/server/l2ExecutionPlan/materializer.js":
"dabf0073520049d7a04d1962b29e591ae092b87b287a50534ad2d98b03ae683c",
"nodedc-source/server/routes/engineAgentGateway.js":
"4a9524fd954320277042c783b7b19cbb2172f075f27652c0eebfd743ffc47872",
"nodedc-source/server/assets/execution-plans/v1/catalog.json":
"2b8e5ee3d73d16f3cd6e34d1f7394946a6270a17b0e9e6511f12921ba2561fd3",
"nodedc-source/server/assets/provider-packages/v1/catalog.json":
"fe5256fd2ba295819daecc8d2acae34687e807978a6730dfa20703cb3bab0c1b",
ENGINE_MCP_NORMALIZED_IDENTITY_SEARCH_DESCRIPTOR_REL:
"41738185fe103642912b0aa1c29c51860970c38f9f916cc3725e79e258b9ea7e",
ENGINE_MCP_L1_CREDENTIAL_PROVENANCE_DESCRIPTOR_REL:
"5887da6e5cb611450e03a110be9786acbe47ae1b00217b8bf09e0967f71f6a3d",
}
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_TARGET_SHA256 = {
"nodedc-source/server/l2ExecutionPlan/compiler.js":
"64f5196a83018505c6dac77a0f8674c27941257a874eed9b024c1c94f169be2b",
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_DESCRIPTOR_REL:
"a4692643afb86dfeeee6ca24aefcc181913e715eff38fa158667d2f10b901847",
}
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_NEW_PATHS = (
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_DESCRIPTOR_REL,
)
ENGINE_AGENT_FULL_GRANT_MIGRATION_ARTIFACT_ENTRIES = (
ENGINE_AGENT_FULL_GRANT_MIGRATION_STORE_REL,
)
@@ -4843,6 +4877,44 @@ process.stdout.write('engine-mcp-normalized-identity-search:0.11.0:canonical-fac
}
def accept_engine_mcp_execution_plan_sandbox_runtime():
root = component_root("engine")
validate_engine_mcp_execution_plan_sandbox_runtime_slice(
root,
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_ARTIFACT_ENTRIES,
)
live = run_engine_backend_probe(
(
"node",
"--input-type=module",
"-e",
"""
const fs=await import('node:fs/promises');
const compiler=await fs.readFile('/app/server/l2ExecutionPlan/compiler.js','utf8');
const start=compiler.indexOf('const encodedBytes = (value) => {');
const end=compiler.indexOf('for (const raw of input) {',start);
const byteCounter=start>=0&&end>start?compiler.slice(start,end):'';
if(!byteCounter.includes('encoded.charCodeAt(index)')||!byteCounter.includes('length += 4')||byteCounter.includes('TextEncoder')||!compiler.includes('return extracted.map((source) => ({ json: { source, collectionReceivedAt: receivedAt } }))')||/gelios|robot2b/i.test(compiler))process.exit(2);
process.stdout.write('engine-mcp-execution-plan-sandbox-runtime:0.11.0:n8n-2.3.2:pure-js-utf8:v4');
""".strip(),
),
"Engine MCP execution plan sandbox runtime",
container_id=engine_backend_container_id(),
)
expected = (
"engine-mcp-execution-plan-sandbox-runtime:"
"0.11.0:n8n-2.3.2:pure-js-utf8:v4"
)
if live != expected:
die("Engine MCP execution plan sandbox runtime live acceptance mismatch")
return {
"target_sha256": dict(
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_TARGET_SHA256
),
"live": live,
}
def accept_engine_mcp_l1_credential_reuse_runtime():
root = component_root("engine")
validate_engine_mcp_l1_credential_reuse_slice(
@@ -6418,6 +6490,97 @@ def validate_engine_mcp_l1_credential_provenance_slice(payload_dir, entries):
)
def validate_engine_mcp_execution_plan_sandbox_runtime_slice(
payload_dir,
entries,
):
if (
tuple(entries)
!= ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_ARTIFACT_ENTRIES
):
die(
"Engine MCP execution plan sandbox runtime files.txt exact "
"set/order mismatch"
)
for rel, expected_sha256 in (
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_TARGET_SHA256.items()
):
path = payload_dir / rel
try:
path_stat = path.lstat()
except FileNotFoundError:
die(
"Engine MCP execution plan sandbox runtime target is "
f"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(
"Engine MCP execution plan sandbox runtime target sha256 "
f"mismatch: {rel}"
)
descriptor = read_strict_json(
payload_dir / ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_DESCRIPTOR_REL,
"Engine MCP execution plan sandbox runtime descriptor",
max_bytes=32 * 1024,
)
expected_descriptor = {
"schemaVersion": "nodedc.engine.deploy-transition/v1",
"id": "engine-mcp-l2-execution-plan-sandbox-runtime-v4",
"component": "engine",
"scope": "external-mcp-l2-authoring-runtime",
"mcpVersion": "0.11.0",
"sourcePath": "nodedc-source/server/l2ExecutionPlan/compiler.js",
"predecessor": "engine-mcp-l1-credential-provenance-v2",
"runtimeCompatibility": {
"n8nVersion": "2.3.2",
"codeNodeMode": "runOnceForAllItems",
"sandboxGlobalDependencies": [],
"responseByteBudget": "bounded-pure-javascript-utf8",
"returnedItems": "n8n-object-json-envelope",
},
"dataBoundary": {
"providerResponses": "bounded-by-trusted-profile",
"rawProviderPayloadAtPublish": "forbidden",
"canonicalFactsOnlyAtPublish": True,
},
"providerLogicAuthority": "trusted-provider-package",
"engineProviderHardcode": False,
"n8nCoreChanged": False,
"l1Changed": False,
"credentialsChanged": False,
}
if descriptor != expected_descriptor:
die("Engine MCP execution plan sandbox runtime descriptor mismatch")
compiler = (
payload_dir / "nodedc-source/server/l2ExecutionPlan/compiler.js"
).read_text(encoding="utf-8")
for marker in (
"const encodedBytes = (value) => {",
"encoded.charCodeAt(index)",
"length += 4",
"return extracted.map((source) => ({ json:",
):
if marker not in compiler:
die(
"Engine MCP execution plan sandbox runtime compiler marker "
f"missing: {marker}"
)
if (
"new TextEncoder().encode(JSON.stringify(value ?? null))" in compiler
or re.search(r"gelios|robot2b", compiler, re.IGNORECASE)
):
die(
"Engine MCP execution plan sandbox runtime provider-neutral "
"boundary 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")
@@ -6934,6 +7097,14 @@ def load_artifact(artifact, work_dir):
payload_dir,
entries,
)
if is_engine_mcp_execution_plan_sandbox_runtime_slice(
manifest["component"],
entries,
):
validate_engine_mcp_execution_plan_sandbox_runtime_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):
@@ -6979,6 +7150,10 @@ def load_artifact(artifact, work_dir):
manifest["component"],
entries,
)
and not is_engine_mcp_execution_plan_sandbox_runtime_slice(
manifest["component"],
entries,
)
and (
touches_engine_data_product_publish_grant(entries)
or ENGINE_DATA_PRODUCT_PUBLISH_GRANT_OVERRIDE_REL in entries
@@ -7226,6 +7401,15 @@ def is_engine_mcp_l1_credential_provenance_slice(component, entries):
)
def is_engine_mcp_execution_plan_sandbox_runtime_slice(component, entries):
return (
component == "engine"
and entries is not None
and tuple(entries)
== ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_ARTIFACT_ENTRIES
)
def is_engine_agent_full_grant_migration_slice(component, entries):
return (
component == "engine"
@@ -8197,6 +8381,85 @@ def preflight_engine_mcp_l1_credential_provenance_predecessor():
}
def preflight_engine_mcp_execution_plan_sandbox_runtime_predecessor():
root = component_root("engine")
actual = {}
for rel, expected_sha256 in (
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_PREDECESSOR_SHA256.items()
):
path = root / rel
try:
path_stat = path.lstat()
except FileNotFoundError:
die(
"Engine MCP execution plan sandbox runtime predecessor is "
f"missing: {rel}"
)
if stat.S_ISLNK(path_stat.st_mode) or not stat.S_ISREG(path_stat.st_mode):
die(
"Engine MCP execution plan sandbox runtime predecessor is "
f"unsafe: {rel}"
)
actual_sha256 = sha256_file(path)
if actual_sha256 != expected_sha256:
die(
"Engine MCP execution plan sandbox runtime predecessor drift "
f"detected: path={rel} expected={expected_sha256} "
f"actual={actual_sha256}"
)
actual[rel] = actual_sha256
foundation = {}
for rel, expected_sha256 in (
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_FOUNDATION_SHA256.items()
):
path = root / rel
try:
path_stat = path.lstat()
except FileNotFoundError:
die(
"Engine MCP execution plan sandbox runtime foundation is "
f"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(
"Engine MCP execution plan sandbox runtime foundation drift "
f"detected: {rel}"
)
foundation[rel] = expected_sha256
for rel in ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_NEW_PATHS:
path = root / rel
if path.exists() or path.is_symlink():
die(
"Engine MCP execution plan sandbox runtime new path already "
f"exists: {rel}"
)
backend = preflight_engine_credential_backend_runtime()
if backend["mode"] != "verified-derived-retry":
die(
"Engine MCP execution plan sandbox runtime requires the active "
"immutable backend"
)
return {
"mode": "l1-credential-provenance-v2-to-sandbox-runtime-v4",
"predecessor_sha256": actual,
"foundation_sha256": foundation,
"target_sha256": dict(
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_TARGET_SHA256
),
"new_paths": tuple(
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_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
@@ -8258,6 +8521,7 @@ def component_services(component, entries=None):
or is_engine_mcp_normalized_identity_search_slice(component, entries)
or is_engine_mcp_l1_credential_reuse_slice(component, entries)
or is_engine_mcp_l1_credential_provenance_slice(component, entries)
or is_engine_mcp_execution_plan_sandbox_runtime_slice(component, entries)
or is_engine_provider_security_catalog_slice(component, entries)
):
# This slice updates only the existing Engine backend control plane.
@@ -10474,6 +10738,7 @@ def plan_artifact(artifact):
mcp_normalized_identity_search_preflight = None
mcp_l1_credential_reuse_preflight = None
mcp_l1_credential_provenance_preflight = None
mcp_execution_plan_sandbox_runtime_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))
@@ -10581,6 +10846,13 @@ def plan_artifact(artifact):
mcp_l1_credential_provenance_preflight = (
preflight_engine_mcp_l1_credential_provenance_predecessor()
)
if is_engine_mcp_execution_plan_sandbox_runtime_slice(
manifest["component"],
entries,
):
mcp_execution_plan_sandbox_runtime_preflight = (
preflight_engine_mcp_execution_plan_sandbox_runtime_predecessor()
)
if is_engine_provider_security_catalog_slice(manifest["component"], entries):
provider_catalog_preflight = preflight_engine_provider_security_catalog_predecessor()
@@ -10653,6 +10925,9 @@ def plan_artifact(artifact):
touches_mcp_l1_credential_provenance = (
is_engine_mcp_l1_credential_provenance_slice(component, entries)
)
touches_mcp_execution_plan_sandbox_runtime = (
is_engine_mcp_execution_plan_sandbox_runtime_slice(component, entries)
)
touches_agent_grant_migration = is_engine_agent_full_grant_migration_slice(
component,
entries,
@@ -10676,6 +10951,7 @@ def plan_artifact(artifact):
or touches_mcp_normalized_identity_search
or touches_mcp_l1_credential_reuse
or touches_mcp_l1_credential_provenance
or touches_mcp_execution_plan_sandbox_runtime
or touches_agent_grant_migration
):
credential_backend_preflight = preflight_engine_credential_backend_runtime()
@@ -10780,6 +11056,17 @@ def plan_artifact(artifact):
"Engine MCP L1 credential provenance requires the active "
"immutable credential backend"
)
if touches_mcp_execution_plan_sandbox_runtime:
if mcp_execution_plan_sandbox_runtime_preflight is None:
die(
"Engine MCP execution plan sandbox runtime preflight is "
"missing"
)
if credential_backend_preflight["mode"] != "verified-derived-retry":
die(
"Engine MCP execution plan sandbox runtime requires the "
"active immutable credential backend"
)
if touches_agent_grant_migration:
agent_grant_migration_predecessor_sha256 = (
preflight_engine_agent_full_grant_migration_predecessor()
@@ -11583,6 +11870,76 @@ def plan_artifact(artifact):
print("credentials=preserved")
print("mcp_nginx=untouched")
print("embedded_ai_workspace=untouched")
if mcp_execution_plan_sandbox_runtime_preflight:
print(
"engine_mcp_execution_plan_sandbox_runtime_transition="
f"{mcp_execution_plan_sandbox_runtime_preflight['mode']}"
)
print("engine_mcp_version=0.11.0")
print("engine_mcp_execution_plan_compiler_version=1.4.0")
print("engine_mcp_execution_runtime=n8n-2.3.2-code")
print("engine_mcp_execution_sandbox_global_dependencies=none")
print("engine_mcp_execution_byte_budget=pure-js-utf8")
print("engine_mcp_provider_logic=trusted-package")
print("engine_mcp_provider_hardcode=no")
print("engine_mcp_raw_provider_publish=forbidden")
for foundation_path, foundation_sha256 in (
mcp_execution_plan_sandbox_runtime_preflight[
"foundation_sha256"
].items()
):
print(
"engine_mcp_execution_plan_sandbox_runtime_foundation_sha256"
f"[{foundation_path}]={foundation_sha256}"
)
for changed_path in (
ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_ARTIFACT_ENTRIES
):
print(
"engine_mcp_execution_plan_sandbox_runtime_changed_path="
f"{changed_path}"
)
if changed_path in (
mcp_execution_plan_sandbox_runtime_preflight[
"predecessor_sha256"
]
):
print(
"engine_mcp_execution_plan_sandbox_runtime_predecessor_sha256"
f"[{changed_path}]="
f"{mcp_execution_plan_sandbox_runtime_preflight['predecessor_sha256'][changed_path]}"
)
elif changed_path in (
mcp_execution_plan_sandbox_runtime_preflight["new_paths"]
):
print(
"engine_mcp_execution_plan_sandbox_runtime_predecessor_state"
f"[{changed_path}]=absent"
)
else:
die(
"Engine MCP execution plan sandbox runtime plan has no "
f"predecessor state: {changed_path}"
)
print(
"engine_mcp_execution_plan_sandbox_runtime_target_sha256"
f"[{changed_path}]="
f"{mcp_execution_plan_sandbox_runtime_preflight['target_sha256'][changed_path]}"
)
print(
"backend_current_barrier="
f"{mcp_execution_plan_sandbox_runtime_preflight['backend_mode']}"
)
print("backend_force_recreate=yes")
print("backend_pull=never")
print("l2_graph=untouched")
print("n8n_l1=untouched")
print("n8n_core=untouched")
print("engine_ui=untouched")
print("engine_databases=untouched")
print("credentials=preserved")
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']}")
@@ -12722,6 +13079,10 @@ def component_healthchecks(component, entries=None, services=None):
component,
entries,
)
or is_engine_mcp_execution_plan_sandbox_runtime_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)
@@ -13169,6 +13530,9 @@ def run_healthchecks(component, entries=None, services=None):
touches_mcp_l1_credential_provenance = (
is_engine_mcp_l1_credential_provenance_slice(component, entries)
)
touches_mcp_execution_plan_sandbox_runtime = (
is_engine_mcp_execution_plan_sandbox_runtime_slice(component, entries)
)
touches_agent_grant_migration = is_engine_agent_full_grant_migration_slice(
component,
entries,
@@ -13193,6 +13557,7 @@ def run_healthchecks(component, entries=None, services=None):
or touches_mcp_normalized_identity_search
or touches_mcp_l1_credential_reuse
or touches_mcp_l1_credential_provenance
or touches_mcp_execution_plan_sandbox_runtime
or touches_agent_grant_migration
or touches_mcp_control_plane
or touches_mcp_ontology_sdk
@@ -13221,6 +13586,7 @@ def run_healthchecks(component, entries=None, services=None):
or touches_mcp_normalized_identity_search
or touches_mcp_l1_credential_reuse
or touches_mcp_l1_credential_provenance
or touches_mcp_execution_plan_sandbox_runtime
or touches_agent_grant_migration
or touches_mcp_control_plane
or touches_mcp_ontology_sdk
@@ -13618,6 +13984,48 @@ def run_healthchecks(component, entries=None, services=None):
"Engine MCP L1 credential provenance installed state is "
"neither target nor rollback predecessor"
)
if touches_mcp_execution_plan_sandbox_runtime:
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_PLAN_SANDBOX_RUNTIME_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_EXECUTION_PLAN_SANDBOX_RUNTIME_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_EXECUTION_PLAN_SANDBOX_RUNTIME_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_EXECUTION_PLAN_SANDBOX_RUNTIME_FOUNDATION_SHA256.items()
)
) and all(
not (root / rel).exists() and not (root / rel).is_symlink()
for rel in ENGINE_MCP_EXECUTION_PLAN_SANDBOX_RUNTIME_NEW_PATHS
)
if target_state:
accept_engine_mcp_execution_plan_sandbox_runtime()
elif not predecessor_state:
die(
"Engine MCP execution plan sandbox runtime installed state is "
"neither target nor rollback predecessor"
)
container_name = COMPONENTS[component].get("health_container")
if container_name:
healthcheck_container(container_name)
@@ -13831,6 +14239,22 @@ def apply_artifact(artifact):
"Engine MCP L1 credential provenance requires the "
"active immutable credential backend"
)
if is_engine_mcp_execution_plan_sandbox_runtime_slice(
component,
entries,
):
preflight_engine_mcp_execution_plan_sandbox_runtime_predecessor()
execution_plan_sandbox_runtime_backend_preflight = (
preflight_engine_credential_backend_runtime()
)
if (
execution_plan_sandbox_runtime_backend_preflight["mode"]
!= "verified-derived-retry"
):
die(
"Engine MCP execution plan sandbox runtime 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()
@@ -14112,6 +14536,10 @@ def apply_artifact(artifact):
component,
entries,
)
or is_engine_mcp_execution_plan_sandbox_runtime_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)