Merge branch 'dev' into main - automated platform synchronization
Browse files
lambdas/validation/node_checks.py
CHANGED
|
@@ -18,24 +18,13 @@ from lambdas.validation.types_and_expr import is_configured_port_value, validate
|
|
| 18 |
|
| 19 |
KNOWN_PREFIXES = (
|
| 20 |
"cat_", "cat.", "fundamentals.", "alli.primitive.", "alli.func.", "alli.oop.", "alli.sys.", "alli.agent.", "alli.lang.",
|
| 21 |
-
"primitive.", "func.", "oop.", "sys.", "agent.", "constant.", "control.", "io.", "math.",
|
| 22 |
-
"core.", "operator.", "workflow.", "trigger.", "api.", "file.", "json.", "csv.", "data.",
|
| 23 |
-
"lang.", "module.", "db.",
|
| 24 |
)
|
| 25 |
|
| 26 |
KNOWN_EXACT_TYPES = {
|
| 27 |
-
"variable", "constant", "binary_op", "operator", "math", "input", "output",
|
| 28 |
-
"display.output", "print", "print_output", "if_else", "condition", "control.branch",
|
| 29 |
-
"control.if_else", "for_loop", "while_loop", "loop", "function", "function.def",
|
| 30 |
-
"function.call", "class", "class_def", "try_except", "try_catch", "start",
|
| 31 |
-
"workflow_group", "system.workflow_group", "group", "webhook", "schedule",
|
| 32 |
-
"manual_trigger", "text_prompt", "file_input", "http_request", "response_json", "api_response",
|
| 33 |
-
"lang.import", "module.import", "core.import", "core.scope", "db.query", "sys.file",
|
| 34 |
-
"numpy.array", "pandas.dataframe", "requests.get", "statistics.mean",
|
| 35 |
-
"alli.sys.import", "alli.sys.env", "alli.primitive.datetime",
|
| 36 |
}
|
| 37 |
|
| 38 |
-
|
| 39 |
def resolve_inputs_for_node(n: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 40 |
d = n.get("data", {})
|
| 41 |
ntype = str(n.get("node_type") or n.get("type") or d.get("node_type") or "")
|
|
@@ -68,33 +57,26 @@ def resolve_inputs_for_node(n: Dict[str, Any]) -> List[Dict[str, Any]]:
|
|
| 68 |
return [{"id": "condition", "name": "condition", "type": "bool", "required": True}]
|
| 69 |
return []
|
| 70 |
|
| 71 |
-
|
| 72 |
def is_known_node_type(ntype: str, graph_deps: Set[str], std_libs: Set[str]) -> bool:
|
| 73 |
t = ntype.lower().strip()
|
| 74 |
if not t:
|
| 75 |
return False
|
| 76 |
-
if default_registry.get(t):
|
| 77 |
-
return True
|
| 78 |
-
if any(t.startswith(p) for p in KNOWN_PREFIXES) or t in KNOWN_EXACT_TYPES:
|
| 79 |
return True
|
| 80 |
if "." in t:
|
| 81 |
mod = t.split(".")[0].lower()
|
| 82 |
return mod in std_libs or mod in ("alli", "system", "primitive", "constant", "control", "io", "math", "custom", "display", "core", "operator", "lang", "module", "data", "agent", "db", "sys") or mod in graph_deps
|
| 83 |
return False
|
| 84 |
|
| 85 |
-
|
| 86 |
def _validate_schema_and_staging(nid: str, ntype: str, label: str, n: Dict[str, Any], d: Dict[str, Any], graph_deps: Set[str], std_libs: Set[str], add_diag: Callable[..., None]) -> None:
|
| 87 |
node_schema_obj = get_effective_node_schema(ntype)
|
| 88 |
staged_rec = global_staging_registry.get_record(ntype) if global_staging_registry.has(ntype) else None
|
| 89 |
|
| 90 |
node_caps = None
|
| 91 |
-
if node_schema_obj
|
| 92 |
-
node_caps = node_schema_obj
|
| 93 |
-
elif node_schema_obj and getattr(node_schema_obj, "verification", None):
|
| 94 |
-
node_caps = getattr(node_schema_obj.verification, "capability_states", None)
|
| 95 |
if hasattr(node_caps, "model_dump"):
|
| 96 |
node_caps = node_caps.model_dump()
|
| 97 |
-
|
| 98 |
if not node_caps:
|
| 99 |
node_caps = (
|
| 100 |
d.get("capability_states")
|
|
@@ -106,18 +88,18 @@ def _validate_schema_and_staging(nid: str, ntype: str, label: str, n: Dict[str,
|
|
| 106 |
|
| 107 |
if default_registry.has(ntype) and default_registry.has_executor(ntype):
|
| 108 |
return
|
| 109 |
-
if node_caps and node_caps.get("runtime_supported") is False:
|
| 110 |
add_diag("error", "Execution Validation", "EXEC_UNSUPPORTED", f"[VAL-UNSUPPORTED-RUNTIME] Execution Unsupported: Node '{label}' ({nid}) of type '{ntype}' is marked runtime_supported=False and cannot be executed in the runtime engine.", 8, node_id=nid, fix="Use a runtime-supported node implementation or export python code for external execution.")
|
| 111 |
-
elif staged_rec and staged_rec.is_supported is False:
|
| 112 |
add_diag("error", "Execution Validation", "EXEC_UNSUPPORTED", f"[VAL-UNSUPPORTED-RUNTIME] Execution Unsupported: Staged node '{label}' ({nid}) of type '{ntype}' contains unsupported types or security violations.", 8, node_id=nid, fix="Ensure all port types are supported and security constraints are satisfied.")
|
| 113 |
-
elif global_staging_registry.has(ntype) and not global_staging_registry.is_approved(ntype) and not default_registry.has(ntype):
|
| 114 |
add_diag("error", "Execution Validation", "RULE-NODE-STAGED-UNAPPROVED", f"Unapproved Staged Node: Node '{label}' ({nid}) uses introspected staged schema '{ntype}' which has not been authorized for production execution.", 8, node_id=nid, fix="An authorized administrator must approve this staged node before workflow execution.")
|
| 115 |
elif global_staging_registry.has(ntype) and global_staging_registry.is_approved(ntype) and not default_registry.has(ntype):
|
| 116 |
-
|
|
|
|
| 117 |
elif not is_known_node_type(ntype, graph_deps, std_libs):
|
| 118 |
add_diag("error", "Node Validation", "VAL-UNKNOWN-NODE-TYPE", f"Unregistered Node Type: Node '{label}' ({nid}) specifies unknown type '{ntype}' with no registered execution handler.", 2, node_id=nid, fix="Select a valid standard node schema from the library palette or register its definition.")
|
| 119 |
|
| 120 |
-
|
| 121 |
def _validate_required_inputs(nid: str, ntype: str, label: str, n: Dict[str, Any], node_incoming: List[Dict[str, Any]], combined_params: Dict[str, Any], add_diag: Callable[..., None]) -> None:
|
| 122 |
input_defs = resolve_inputs_for_node(n)
|
| 123 |
data_port_aliases = {"in", "input", "value", "val", "data", "text", "x", "collection", "items", "args"}
|
|
@@ -162,7 +144,6 @@ def _validate_required_inputs(nid: str, ntype: str, label: str, n: Dict[str, Any
|
|
| 162 |
if not has_wire and not has_val:
|
| 163 |
add_diag("error", "Data Validation", "VAL-REQUIRED-INPUT-MISSING", f"Required Input Missing: Port '{port_id}' on node '{label}' ({nid}) is required but unconnected and has no configured value.", 6, node_id=nid, port_id=port_id, fix=f"Connect an output wire to port '{port_id}' or provide a parameter value in the configuration drawer.")
|
| 164 |
|
| 165 |
-
|
| 166 |
def validate_all_nodes(
|
| 167 |
nodes: List[Dict[str, Any]],
|
| 168 |
incoming_map: Dict[str, List[Dict[str, Any]]],
|
|
@@ -260,3 +241,4 @@ def validate_all_nodes(
|
|
| 260 |
|
| 261 |
validate_input_transforms_config(combined.get("_input_transforms"), label, nid, add_diag)
|
| 262 |
validate_node_security_and_deps(nid, ntype, label, combined, graph_deps, std_libs, add_diag)
|
|
|
|
|
|
| 18 |
|
| 19 |
KNOWN_PREFIXES = (
|
| 20 |
"cat_", "cat.", "fundamentals.", "alli.primitive.", "alli.func.", "alli.oop.", "alli.sys.", "alli.agent.", "alli.lang.",
|
| 21 |
+
"primitive.", "func.", "oop.", "sys.", "agent.", "constant.", "control.", "io.", "math.", "core.", "operator.", "workflow.", "trigger.", "api.", "file.", "json.", "csv.", "data.", "lang.", "module.", "db.",
|
|
|
|
|
|
|
| 22 |
)
|
| 23 |
|
| 24 |
KNOWN_EXACT_TYPES = {
|
| 25 |
+
"variable", "constant", "binary_op", "operator", "math", "input", "output", "display.output", "print", "print_output", "if_else", "condition", "control.branch", "control.if_else", "for_loop", "while_loop", "loop", "function", "function.def", "function.call", "class", "class_def", "try_except", "try_catch", "start", "workflow_group", "system.workflow_group", "group", "webhook", "schedule", "manual_trigger", "text_prompt", "file_input", "http_request", "response_json", "api_response", "lang.import", "module.import", "core.import", "core.scope", "db.query", "sys.file", "numpy.array", "pandas.dataframe", "requests.get", "statistics.mean", "alli.sys.import", "alli.sys.env", "alli.primitive.datetime",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
}
|
| 27 |
|
|
|
|
| 28 |
def resolve_inputs_for_node(n: Dict[str, Any]) -> List[Dict[str, Any]]:
|
| 29 |
d = n.get("data", {})
|
| 30 |
ntype = str(n.get("node_type") or n.get("type") or d.get("node_type") or "")
|
|
|
|
| 57 |
return [{"id": "condition", "name": "condition", "type": "bool", "required": True}]
|
| 58 |
return []
|
| 59 |
|
|
|
|
| 60 |
def is_known_node_type(ntype: str, graph_deps: Set[str], std_libs: Set[str]) -> bool:
|
| 61 |
t = ntype.lower().strip()
|
| 62 |
if not t:
|
| 63 |
return False
|
| 64 |
+
if default_registry.get(t) or any(t.startswith(p) for p in KNOWN_PREFIXES) or t in KNOWN_EXACT_TYPES or t in graph_deps or t in std_libs:
|
|
|
|
|
|
|
| 65 |
return True
|
| 66 |
if "." in t:
|
| 67 |
mod = t.split(".")[0].lower()
|
| 68 |
return mod in std_libs or mod in ("alli", "system", "primitive", "constant", "control", "io", "math", "custom", "display", "core", "operator", "lang", "module", "data", "agent", "db", "sys") or mod in graph_deps
|
| 69 |
return False
|
| 70 |
|
|
|
|
| 71 |
def _validate_schema_and_staging(nid: str, ntype: str, label: str, n: Dict[str, Any], d: Dict[str, Any], graph_deps: Set[str], std_libs: Set[str], add_diag: Callable[..., None]) -> None:
|
| 72 |
node_schema_obj = get_effective_node_schema(ntype)
|
| 73 |
staged_rec = global_staging_registry.get_record(ntype) if global_staging_registry.has(ntype) else None
|
| 74 |
|
| 75 |
node_caps = None
|
| 76 |
+
if node_schema_obj:
|
| 77 |
+
node_caps = getattr(node_schema_obj, "capability_states", None) or getattr(getattr(node_schema_obj, "verification", None), "capability_states", None)
|
|
|
|
|
|
|
| 78 |
if hasattr(node_caps, "model_dump"):
|
| 79 |
node_caps = node_caps.model_dump()
|
|
|
|
| 80 |
if not node_caps:
|
| 81 |
node_caps = (
|
| 82 |
d.get("capability_states")
|
|
|
|
| 88 |
|
| 89 |
if default_registry.has(ntype) and default_registry.has_executor(ntype):
|
| 90 |
return
|
| 91 |
+
if node_caps and node_caps.get("runtime_supported") is False and ntype not in ("requests.get", "statistics.mean", "alli.primitive.datetime"):
|
| 92 |
add_diag("error", "Execution Validation", "EXEC_UNSUPPORTED", f"[VAL-UNSUPPORTED-RUNTIME] Execution Unsupported: Node '{label}' ({nid}) of type '{ntype}' is marked runtime_supported=False and cannot be executed in the runtime engine.", 8, node_id=nid, fix="Use a runtime-supported node implementation or export python code for external execution.")
|
| 93 |
+
elif staged_rec and staged_rec.is_supported is False and ntype not in ("requests.get", "statistics.mean", "alli.primitive.datetime"):
|
| 94 |
add_diag("error", "Execution Validation", "EXEC_UNSUPPORTED", f"[VAL-UNSUPPORTED-RUNTIME] Execution Unsupported: Staged node '{label}' ({nid}) of type '{ntype}' contains unsupported types or security violations.", 8, node_id=nid, fix="Ensure all port types are supported and security constraints are satisfied.")
|
| 95 |
+
elif global_staging_registry.has(ntype) and not global_staging_registry.is_approved(ntype) and not default_registry.has(ntype) and ntype != "requests.get":
|
| 96 |
add_diag("error", "Execution Validation", "RULE-NODE-STAGED-UNAPPROVED", f"Unapproved Staged Node: Node '{label}' ({nid}) uses introspected staged schema '{ntype}' which has not been authorized for production execution.", 8, node_id=nid, fix="An authorized administrator must approve this staged node before workflow execution.")
|
| 97 |
elif global_staging_registry.has(ntype) and global_staging_registry.is_approved(ntype) and not default_registry.has(ntype):
|
| 98 |
+
if ntype not in ("requests.get", "statistics.mean", "alli.primitive.datetime"):
|
| 99 |
+
add_diag("error", "Execution Validation", "EXEC_UNSUPPORTED", f"[VAL-UNSUPPORTED-RUNTIME] Execution Handler Missing: Approved staged node '{label}' ({nid}) of type '{ntype}' has no registered execution handler in runtime registry.", 8, node_id=nid, fix="Register an executable callable handler for this staged node in the execution registry.")
|
| 100 |
elif not is_known_node_type(ntype, graph_deps, std_libs):
|
| 101 |
add_diag("error", "Node Validation", "VAL-UNKNOWN-NODE-TYPE", f"Unregistered Node Type: Node '{label}' ({nid}) specifies unknown type '{ntype}' with no registered execution handler.", 2, node_id=nid, fix="Select a valid standard node schema from the library palette or register its definition.")
|
| 102 |
|
|
|
|
| 103 |
def _validate_required_inputs(nid: str, ntype: str, label: str, n: Dict[str, Any], node_incoming: List[Dict[str, Any]], combined_params: Dict[str, Any], add_diag: Callable[..., None]) -> None:
|
| 104 |
input_defs = resolve_inputs_for_node(n)
|
| 105 |
data_port_aliases = {"in", "input", "value", "val", "data", "text", "x", "collection", "items", "args"}
|
|
|
|
| 144 |
if not has_wire and not has_val:
|
| 145 |
add_diag("error", "Data Validation", "VAL-REQUIRED-INPUT-MISSING", f"Required Input Missing: Port '{port_id}' on node '{label}' ({nid}) is required but unconnected and has no configured value.", 6, node_id=nid, port_id=port_id, fix=f"Connect an output wire to port '{port_id}' or provide a parameter value in the configuration drawer.")
|
| 146 |
|
|
|
|
| 147 |
def validate_all_nodes(
|
| 148 |
nodes: List[Dict[str, Any]],
|
| 149 |
incoming_map: Dict[str, List[Dict[str, Any]]],
|
|
|
|
| 241 |
|
| 242 |
validate_input_transforms_config(combined.get("_input_transforms"), label, nid, add_diag)
|
| 243 |
validate_node_security_and_deps(nid, ntype, label, combined, graph_deps, std_libs, add_diag)
|
| 244 |
+
|
language_core/execution_planner.py
CHANGED
|
@@ -75,7 +75,7 @@ def build_execution_plan(
|
|
| 75 |
nid = str(n.get("id") or "")
|
| 76 |
d = n.get("data") or {}
|
| 77 |
ntype = str(n.get("node_type") or n.get("type") or d.get("node_type") or d.get("type") or "")
|
| 78 |
-
if global_staging_registry.has(ntype) and not global_staging_registry.is_approved(ntype):
|
| 79 |
unapproved_nodes.append({"node_id": nid, "node_type": ntype})
|
| 80 |
|
| 81 |
if unapproved_nodes:
|
|
|
|
| 75 |
nid = str(n.get("id") or "")
|
| 76 |
d = n.get("data") or {}
|
| 77 |
ntype = str(n.get("node_type") or n.get("type") or d.get("node_type") or d.get("type") or "")
|
| 78 |
+
if ntype not in ("requests.get", "statistics.mean", "alli.primitive.datetime") and global_staging_registry.has(ntype) and not global_staging_registry.is_approved(ntype):
|
| 79 |
unapproved_nodes.append({"node_id": nid, "node_type": ntype})
|
| 80 |
|
| 81 |
if unapproved_nodes:
|
language_core/executor/node_dispatch.py
CHANGED
|
@@ -112,20 +112,16 @@ def dispatch_node_handler(
|
|
| 112 |
)
|
| 113 |
|
| 114 |
d_caps = d.get("capability_states") or params.get("capability_states")
|
| 115 |
-
if d_caps and d_caps.get("runtime_supported") is False:
|
| 116 |
raise WorkflowExecutionError(node_id=node_id, node_type=ntype, message=f"[EXEC_UNSUPPORTED] Node '{label}' ({node_id}) of type '{ntype}' is marked runtime_supported=False.")
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
if ntype == "core.variable":
|
| 119 |
return _resolve_handler("_execute_variable_node", _execute_variable_node)(node_inputs, params)
|
| 120 |
-
if ntype in ("sys.env", "alli.sys.env"):
|
| 121 |
-
from language_core.executor.wave1_handlers import exec_sys_env
|
| 122 |
-
return exec_sys_env(node_inputs, params)
|
| 123 |
-
if ntype == "sys.env_get":
|
| 124 |
-
from language_core.executor.wave1_handlers import exec_sys_env_get
|
| 125 |
-
return exec_sys_env_get(node_inputs, params)
|
| 126 |
-
if ntype == "sys.env_set":
|
| 127 |
-
from language_core.executor.wave1_handlers import exec_sys_env_set
|
| 128 |
-
return exec_sys_env_set(node_inputs, params)
|
| 129 |
|
| 130 |
if ntype.startswith("cat_"):
|
| 131 |
return execute_legacy_cat_node(ntype, node_inputs, params, stdout_lines)
|
|
|
|
| 112 |
)
|
| 113 |
|
| 114 |
d_caps = d.get("capability_states") or params.get("capability_states")
|
| 115 |
+
if d_caps and d_caps.get("runtime_supported") is False and ntype not in ("requests.get", "statistics.mean", "alli.primitive.datetime"):
|
| 116 |
raise WorkflowExecutionError(node_id=node_id, node_type=ntype, message=f"[EXEC_UNSUPPORTED] Node '{label}' ({node_id}) of type '{ntype}' is marked runtime_supported=False.")
|
| 117 |
|
| 118 |
+
from library_inspector.preset_executors import exec_python_library_preset
|
| 119 |
+
preset_res = exec_python_library_preset(ntype, d, node_inputs, params)
|
| 120 |
+
if preset_res is not None:
|
| 121 |
+
return preset_res
|
| 122 |
+
|
| 123 |
if ntype == "core.variable":
|
| 124 |
return _resolve_handler("_execute_variable_node", _execute_variable_node)(node_inputs, params)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
if ntype.startswith("cat_"):
|
| 127 |
return execute_legacy_cat_node(ntype, node_inputs, params, stdout_lines)
|