Download node_validation_lab/fixtures/node_behavioral_fixtures.py from Rsnarsna/auto: direct link, hf CLI and curl.
- Browser
- Download file 39.5 kB
-
https://huggingface.co/spaces/Rsnarsna/auto/resolve/main/node_validation_lab/fixtures/node_behavioral_fixtures.py
- Command line
-
hf download hf://spaces/Rsnarsna/auto/node_validation_lab/fixtures/node_behavioral_fixtures.py
-
curl -L -o node_behavioral_fixtures.py https://huggingface.co/spaces/Rsnarsna/auto/resolve/main/node_validation_lab/fixtures/node_behavioral_fixtures.py
39.5 kB
| """Node behavioral fixtures for ALL 59 canonical nodes in ALLI. | |
| Phase 3: Visual Graph Validation & Flow Lab. | |
| Defines deterministic behavioral fixtures, valid/invalid configurations, | |
| runtime inputs, expected outputs, capabilities, and diagnostics for all 59 nodes. | |
| """ | |
| from __future__ import annotations | |
| from typing import Any, Dict, List, Optional | |
| from pydantic import BaseModel, Field | |
| from node_validation_lab.schemas.models import ValidationStatus | |
| class NodeBehavioralFixture(BaseModel): | |
| """Authoritative behavioral test fixture for a single canonical node.""" | |
| type: str = Field(description="Unique canonical node type, e.g. 'math.sqrt'") | |
| label: str = Field(description="Human-readable node label") | |
| category: str = Field(description="Taxonomy category") | |
| valid_params: Dict[str, Any] = Field(default_factory=dict, description="Valid configuration parameters") | |
| valid_inputs: Dict[str, Any] = Field(default_factory=dict, description="Valid test inputs for execution") | |
| expected_outputs: Dict[str, Any] = Field(default_factory=dict, description="Expected output port values or keys") | |
| invalid_params: Dict[str, Any] = Field(default_factory=dict, description="Invalid configuration for mutation testing") | |
| invalid_inputs: Dict[str, Any] = Field(default_factory=dict, description="Invalid input types or values") | |
| expected_error: Optional[str] = Field(default=None, description="Expected error substring on invalid config/input") | |
| capabilities: Dict[str, ValidationStatus] = Field( | |
| default_factory=lambda: { | |
| "backend_runtime": ValidationStatus.PASS, | |
| "frontend_runtime": ValidationStatus.PASS, | |
| "backend_codegen": ValidationStatus.PASS, | |
| "frontend_codegen": ValidationStatus.PASS, | |
| } | |
| ) | |
| unsupported_reason: Optional[str] = Field(default=None, description="Reason if runtime execution is unsupported") | |
| wireable_input_ports: List[str] = Field(default_factory=list, description="IDs of declared input ports") | |
| wireable_output_ports: List[str] = Field(default_factory=list, description="IDs of declared output ports") | |
| ALL_NODE_BEHAVIORAL_FIXTURES: Dict[str, NodeBehavioralFixture] = { | |
| # ─── 1. AI AGENT NODES (GUARDED / FAIL-CLOSED RUNTIMES) ────────────────── | |
| "agent.llm_config": NodeBehavioralFixture( | |
| type="agent.llm_config", | |
| label="LLM Configuration", | |
| category="AI & Agents", | |
| valid_params={"model": "gpt-4o", "temperature": 0.7, "max_tokens": 1024}, | |
| valid_inputs={}, | |
| expected_outputs={"llm_config": {"model": "gpt-4o", "temperature": 0.7}}, | |
| invalid_params={"temperature": 3.5}, | |
| invalid_inputs={}, | |
| expected_error="ERR-SECURITY-GUARDED-AGENT", | |
| capabilities={ | |
| "backend_runtime": ValidationStatus.UNSUPPORTED, | |
| "frontend_runtime": ValidationStatus.UNSUPPORTED, | |
| "backend_codegen": ValidationStatus.PASS, | |
| "frontend_codegen": ValidationStatus.PASS, | |
| }, | |
| unsupported_reason="Guarded AI agent node requires verified checkpointer credentials.", | |
| wireable_input_ports=[], | |
| wireable_output_ports=["llm_config"], | |
| ), | |
| "agent.memory_checkpointer": NodeBehavioralFixture( | |
| type="agent.memory_checkpointer", | |
| label="Memory Checkpointer", | |
| category="AI & Agents", | |
| valid_params={"checkpoint_saver": "MemorySaver", "session_id": "sess_default"}, | |
| valid_inputs={"state_in": {"turn": 1}}, | |
| expected_outputs={"checkpointer": "MemorySaver", "state_out": {"turn": 1}}, | |
| invalid_params={"checkpoint_saver": ""}, | |
| invalid_inputs={}, | |
| expected_error="ERR-SECURITY-GUARDED-AGENT", | |
| capabilities={ | |
| "backend_runtime": ValidationStatus.UNSUPPORTED, | |
| "frontend_runtime": ValidationStatus.UNSUPPORTED, | |
| "backend_codegen": ValidationStatus.PASS, | |
| "frontend_codegen": ValidationStatus.PASS, | |
| }, | |
| unsupported_reason="Autonomous memory checkpoints cannot run in untrusted sandbox.", | |
| wireable_input_ports=["state_in"], | |
| wireable_output_ports=["checkpointer", "state_out"], | |
| ), | |
| "agent.prompt_template": NodeBehavioralFixture( | |
| type="agent.prompt_template", | |
| label="Prompt Template", | |
| category="AI & Agents", | |
| valid_params={"template": "Hello {name}, your task is {task}.", "role": "system"}, | |
| valid_inputs={"name": "Alice", "task": "analysis"}, | |
| expected_outputs={"prompt": "Hello Alice, your task is analysis."}, | |
| invalid_params={"template": ""}, | |
| invalid_inputs={}, | |
| expected_error="ERR-SECURITY-GUARDED-AGENT", | |
| capabilities={ | |
| "backend_runtime": ValidationStatus.UNSUPPORTED, | |
| "frontend_runtime": ValidationStatus.UNSUPPORTED, | |
| "backend_codegen": ValidationStatus.PASS, | |
| "frontend_codegen": ValidationStatus.PASS, | |
| }, | |
| unsupported_reason="Guarded prompt reasoning nodes are restricted in client browser.", | |
| wireable_input_ports=["variables", "name", "task"], | |
| wireable_output_ports=["prompt"], | |
| ), | |
| "agent.react_agent": NodeBehavioralFixture( | |
| type="agent.react_agent", | |
| label="ReAct Agent", | |
| category="AI & Agents", | |
| valid_params={"max_iterations": 5, "system_message": "You are a helpful analyst."}, | |
| valid_inputs={"prompt": "Compute 12 * 2", "tools": []}, | |
| expected_outputs={"output": "24", "thought_steps": []}, | |
| invalid_params={"max_iterations": -1}, | |
| invalid_inputs={}, | |
| expected_error="ERR-SECURITY-GUARDED-AGENT", | |
| capabilities={ | |
| "backend_runtime": ValidationStatus.UNSUPPORTED, | |
| "frontend_runtime": ValidationStatus.UNSUPPORTED, | |
| "backend_codegen": ValidationStatus.PASS, | |
| "frontend_codegen": ValidationStatus.PASS, | |
| }, | |
| unsupported_reason="Fail-closed agent guard restricts autonomous loops.", | |
| wireable_input_ports=["prompt", "tools", "checkpointer"], | |
| wireable_output_ports=["output", "state", "thought_steps"], | |
| ), | |
| "agent.structured_output": NodeBehavioralFixture( | |
| type="agent.structured_output", | |
| label="Structured Output", | |
| category="AI & Agents", | |
| valid_params={"schema_name": "ResponseModel", "fields": "name: str, score: int"}, | |
| valid_inputs={"raw_text": '{"name": "Alice", "score": 95}'}, | |
| expected_outputs={"parsed": {"name": "Alice", "score": 95}}, | |
| invalid_params={"schema_name": ""}, | |
| invalid_inputs={}, | |
| expected_error="ERR-SECURITY-GUARDED-AGENT", | |
| capabilities={ | |
| "backend_runtime": ValidationStatus.UNSUPPORTED, | |
| "frontend_runtime": ValidationStatus.UNSUPPORTED, | |
| "backend_codegen": ValidationStatus.PASS, | |
| "frontend_codegen": ValidationStatus.PASS, | |
| }, | |
| unsupported_reason="Guarded schema output enforcement restricted in sandbox.", | |
| wireable_input_ports=["raw_text", "llm_config"], | |
| wireable_output_ports=["parsed"], | |
| ), | |
| "agent.tools_connector": NodeBehavioralFixture( | |
| type="agent.tools_connector", | |
| label="Tools Connector", | |
| category="AI & Agents", | |
| valid_params={"tool_names": "web_search, calculator"}, | |
| valid_inputs={}, | |
| expected_outputs={"tools_list": ["web_search", "calculator"]}, | |
| invalid_params={"tool_names": ""}, | |
| invalid_inputs={}, | |
| expected_error="ERR-SECURITY-GUARDED-AGENT", | |
| capabilities={ | |
| "backend_runtime": ValidationStatus.UNSUPPORTED, | |
| "frontend_runtime": ValidationStatus.UNSUPPORTED, | |
| "backend_codegen": ValidationStatus.PASS, | |
| "frontend_codegen": ValidationStatus.PASS, | |
| }, | |
| unsupported_reason="External tool execution connectors require signed tokens.", | |
| wireable_input_ports=[], | |
| wireable_output_ports=["tools_list"], | |
| ), | |
| # ─── 2. NETWORK & APIS ─────────────────────────────────────────────────── | |
| "api.http_request": NodeBehavioralFixture( | |
| type="api.http_request", | |
| label="HTTP Request", | |
| category="Network & APIs", | |
| valid_params={"method": "GET", "url": "https://api.example.com/data", "timeout": 5}, | |
| valid_inputs={"url": "https://api.example.com/data"}, | |
| expected_outputs={"status_code": 200, "is_success": True}, | |
| invalid_params={"method": "INVALID_VERB"}, | |
| invalid_inputs={"url": "http://127.0.0.1:8080/admin"}, | |
| expected_error="ERR-SECURITY-SSRF-BLOCKED", | |
| capabilities={ | |
| "backend_runtime": ValidationStatus.PASS, | |
| "frontend_runtime": ValidationStatus.PASS, | |
| "backend_codegen": ValidationStatus.PASS, | |
| "frontend_codegen": ValidationStatus.PASS, | |
| }, | |
| wireable_input_ports=["url", "payload", "headers"], | |
| wireable_output_ports=["response", "status_code", "is_success"], | |
| ), | |
| # ─── 3. CONSTANTS & PRIMITIVES ─────────────────────────────────────────── | |
| "constant.bool": NodeBehavioralFixture( | |
| type="constant.bool", | |
| label="Boolean Constant", | |
| category="Primitives & Variables", | |
| valid_params={"value": True}, | |
| valid_inputs={}, | |
| expected_outputs={"val": True, "result": True}, | |
| invalid_params={"value": "not_a_bool"}, | |
| invalid_inputs={}, | |
| expected_error="Invalid boolean", | |
| wireable_input_ports=[], | |
| wireable_output_ports=["val", "result"], | |
| ), | |
| "constant.float": NodeBehavioralFixture( | |
| type="constant.float", | |
| label="Float Constant", | |
| category="Primitives & Variables", | |
| valid_params={"value": 3.14159}, | |
| valid_inputs={}, | |
| expected_outputs={"val": 3.14159, "result": 3.14159}, | |
| invalid_params={"value": "not_a_float"}, | |
| invalid_inputs={}, | |
| expected_error="Invalid float", | |
| wireable_input_ports=[], | |
| wireable_output_ports=["val", "result"], | |
| ), | |
| "constant.int": NodeBehavioralFixture( | |
| type="constant.int", | |
| label="Integer Constant", | |
| category="Primitives & Variables", | |
| valid_params={"value": 42}, | |
| valid_inputs={}, | |
| expected_outputs={"val": 42, "result": 42}, | |
| invalid_params={"value": "invalid_int"}, | |
| invalid_inputs={}, | |
| expected_error="Invalid integer", | |
| wireable_input_ports=[], | |
| wireable_output_ports=["val", "result"], | |
| ), | |
| "constant.str": NodeBehavioralFixture( | |
| type="constant.str", | |
| label="String Constant", | |
| category="Primitives & Variables", | |
| valid_params={"value": "ALLI Visual Programming"}, | |
| valid_inputs={}, | |
| expected_outputs={"text": "ALLI Visual Programming", "val": "ALLI Visual Programming"}, | |
| invalid_params={}, | |
| invalid_inputs={}, | |
| wireable_input_ports=[], | |
| wireable_output_ports=["text", "val"], | |
| ), | |
| # ─── 4. CONTROL FLOW & LOOPS ───────────────────────────────────────────── | |
| "control.for_loop": NodeBehavioralFixture( | |
| type="control.for_loop", | |
| label="For Loop", | |
| category="Control Flow", | |
| valid_params={"mode": "iterable"}, | |
| valid_inputs={"iterable": [1, 2, 3]}, | |
| expected_outputs={"status": "success"}, | |
| invalid_params={"mode": "unknown_mode"}, | |
| invalid_inputs={"iterable": 12345}, # Non-iterable int | |
| expected_error="not iterable", | |
| wireable_input_ports=["iterable", "body_in"], | |
| wireable_output_ports=["item", "index", "body_out", "completed"], | |
| ), | |
| "control.if_else": NodeBehavioralFixture( | |
| type="control.if_else", | |
| label="If / Else Branch", | |
| category="Control Flow", | |
| valid_params={}, | |
| valid_inputs={"condition": True, "true_val": "yes", "false_val": "no"}, | |
| expected_outputs={"result": "yes", "val": "yes"}, | |
| invalid_params={}, | |
| invalid_inputs={"condition": None}, | |
| wireable_input_ports=["condition", "true_val", "false_val"], | |
| wireable_output_ports=["then", "else", "result", "val"], | |
| ), | |
| "control.loop_control": NodeBehavioralFixture( | |
| type="control.loop_control", | |
| label="Loop Control (Break/Continue)", | |
| category="Control Flow", | |
| valid_params={"action": "break"}, | |
| valid_inputs={"condition": True}, | |
| expected_outputs={"action": "break", "result": "break"}, | |
| invalid_params={"action": "invalid_action"}, | |
| invalid_inputs={}, | |
| expected_error="Invalid loop action", | |
| wireable_input_ports=["condition"], | |
| wireable_output_ports=["action", "result"], | |
| ), | |
| "control.try_except": NodeBehavioralFixture( | |
| type="control.try_except", | |
| label="Try / Except", | |
| category="Control Flow", | |
| valid_params={"exception_class": "ValueError"}, | |
| valid_inputs={"in_val": 42}, | |
| expected_outputs={"result": 42, "val": 42}, | |
| invalid_params={"exception_class": ""}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["in_val", "fallback_val"], | |
| wireable_output_ports=["try_out", "except_out", "result", "val"], | |
| ), | |
| "control.while_loop": NodeBehavioralFixture( | |
| type="control.while_loop", | |
| label="While Loop", | |
| category="Control Flow", | |
| valid_params={"max_iterations": 100}, | |
| valid_inputs={"condition": False}, | |
| expected_outputs={"status": "success"}, | |
| invalid_params={"max_iterations": -5}, | |
| invalid_inputs={}, | |
| expected_error="max_iterations", | |
| wireable_input_ports=["condition", "body_in"], | |
| wireable_output_ports=["iteration", "body_out", "completed"], | |
| ), | |
| # ─── 5. CORE OPERATORS & SCOPE ─────────────────────────────────────────── | |
| "core.binary_op": NodeBehavioralFixture( | |
| type="core.binary_op", | |
| label="Binary Operation", | |
| category="Operators & Expressions", | |
| valid_params={"operation": "+"}, | |
| valid_inputs={"a": 10, "b": 14}, | |
| expected_outputs={"result": 24, "val": 24}, | |
| invalid_params={"operation": "**invalid**"}, | |
| invalid_inputs={"a": "string", "b": 5}, | |
| expected_error="Unsupported operand types", | |
| wireable_input_ports=["a", "b"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "core.compare": NodeBehavioralFixture( | |
| type="core.compare", | |
| label="Comparison Operator", | |
| category="Operators & Expressions", | |
| valid_params={"operator": ">"}, | |
| valid_inputs={"a": 15, "b": 10}, | |
| expected_outputs={"result": True, "val": True}, | |
| invalid_params={"operator": "<=>"}, | |
| invalid_inputs={"a": None, "b": 10}, | |
| wireable_input_ports=["a", "b"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "core.constant": NodeBehavioralFixture( | |
| type="core.constant", | |
| label="Universal Constant", | |
| category="Primitives & Variables", | |
| valid_params={"value": 100}, | |
| valid_inputs={}, | |
| expected_outputs={"val": 100, "result": 100}, | |
| invalid_params={}, | |
| invalid_inputs={}, | |
| wireable_input_ports=[], | |
| wireable_output_ports=["val", "result"], | |
| ), | |
| "core.logical_op": NodeBehavioralFixture( | |
| type="core.logical_op", | |
| label="Logical Operation", | |
| category="Operators & Expressions", | |
| valid_params={"operator": "and"}, | |
| valid_inputs={"a": True, "b": False}, | |
| expected_outputs={"result": False, "val": False}, | |
| invalid_params={"operator": "nand_xor"}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["a", "b"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "core.scope": NodeBehavioralFixture( | |
| type="core.scope", | |
| label="Scope & Namespace Block", | |
| category="Modules & Organization", | |
| valid_params={"scope_name": "local_scope"}, | |
| valid_inputs={"in_val": 42}, | |
| expected_outputs={"out_val": 42, "result": 42}, | |
| invalid_params={"scope_name": ""}, | |
| invalid_inputs={}, | |
| capabilities={ | |
| "backend_runtime": ValidationStatus.UNSUPPORTED, | |
| "frontend_runtime": ValidationStatus.PASS, | |
| "backend_codegen": ValidationStatus.PASS, | |
| "frontend_codegen": ValidationStatus.PASS, | |
| }, | |
| unsupported_reason="Visual UI scope grouping block is handled client-side.", | |
| wireable_input_ports=["in_val"], | |
| wireable_output_ports=["out_val", "result"], | |
| ), | |
| "core.type_cast": NodeBehavioralFixture( | |
| type="core.type_cast", | |
| label="Type Cast", | |
| category="Operators & Expressions", | |
| valid_params={"target_type": "int"}, | |
| valid_inputs={"val": "42", "value": "42"}, | |
| expected_outputs={"result": 42, "val": 42}, | |
| invalid_params={"target_type": "invalid_type"}, | |
| invalid_inputs={"val": "not_an_int", "value": "not_an_int"}, | |
| expected_error="ValueError", | |
| wireable_input_ports=["val", "value"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "core.variable": NodeBehavioralFixture( | |
| type="core.variable", | |
| label="Variable Store", | |
| category="Primitives & Variables", | |
| valid_params={"name": "total", "default_value": 0}, | |
| valid_inputs={"value": 50}, | |
| expected_outputs={"val": 50, "result": 50}, | |
| invalid_params={"name": "123_invalid_ident"}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["value"], | |
| wireable_output_ports=["val", "result"], | |
| ), | |
| # ─── 6. CSV & JSON PARSING / STRINGIFY ─────────────────────────────────── | |
| "csv.parse": NodeBehavioralFixture( | |
| type="csv.parse", | |
| label="CSV Parser", | |
| category="Data Structures", | |
| valid_params={"delimiter": ","}, | |
| valid_inputs={"text": "id,val\n1,10\n2,20"}, | |
| expected_outputs={"rows": [{"id": "1", "val": "10"}, {"id": "2", "val": "20"}]}, | |
| invalid_params={}, | |
| invalid_inputs={"text": None}, | |
| wireable_input_ports=["text"], | |
| wireable_output_ports=["rows", "headers", "count"], | |
| ), | |
| "csv.stringify": NodeBehavioralFixture( | |
| type="csv.stringify", | |
| label="CSV Stringifier", | |
| category="Data Structures", | |
| valid_params={"delimiter": ","}, | |
| valid_inputs={"rows": [{"id": 1, "val": 10}, {"id": 2, "val": 20}]}, | |
| expected_outputs={"count": 2}, | |
| invalid_params={}, | |
| invalid_inputs={"rows": "not_a_list"}, | |
| expected_error="expected list of dicts", | |
| wireable_input_ports=["rows"], | |
| wireable_output_ports=["text", "count"], | |
| ), | |
| "data.dict": NodeBehavioralFixture( | |
| type="data.dict", | |
| label="Dictionary Operations", | |
| category="Data Structures", | |
| valid_params={"operation": "get", "key": "score"}, | |
| valid_inputs={"dict_in": {"score": 95}}, | |
| expected_outputs={"val": 95, "result": 95}, | |
| invalid_params={"operation": "unknown_op"}, | |
| invalid_inputs={"dict_in": [1, 2, 3]}, | |
| expected_error="dict", | |
| wireable_input_ports=["dict_in", "key", "value"], | |
| wireable_output_ports=["dict_out", "val", "result", "keys"], | |
| ), | |
| "data.list": NodeBehavioralFixture( | |
| type="data.list", | |
| label="List Operations", | |
| category="Data Structures", | |
| valid_params={"operation": "append"}, | |
| valid_inputs={"list_in": [1, 2], "item": 3}, | |
| expected_outputs={"list_out": [1, 2, 3], "length": 3}, | |
| invalid_params={"operation": "unsupported_list_op"}, | |
| invalid_inputs={"list_in": "not_a_list"}, | |
| expected_error="list", | |
| wireable_input_ports=["list_in", "item", "index"], | |
| wireable_output_ports=["list_out", "val", "result", "length"], | |
| ), | |
| "data.set": NodeBehavioralFixture( | |
| type="data.set", | |
| label="Set Operations", | |
| category="Data Structures", | |
| valid_params={"operation": "create"}, | |
| valid_inputs={"items": [1, 2, 3], "set_in": [1, 2, 3]}, | |
| expected_outputs={"length": 3}, | |
| invalid_params={"operation": "invalid_set_op"}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["items", "set_in", "item"], | |
| wireable_output_ports=["set_out", "result", "length"], | |
| ), | |
| "data.tuple": NodeBehavioralFixture( | |
| type="data.tuple", | |
| label="Tuple Operations", | |
| category="Data Structures", | |
| valid_params={"operation": "create"}, | |
| valid_inputs={"items": [10, 20]}, | |
| expected_outputs={"result": (10, 20), "length": 2}, | |
| invalid_params={"operation": "invalid_tuple_op"}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["item_1", "item_2", "item_3", "tuple_in", "items", "index"], | |
| wireable_output_ports=["tuple_out", "result", "val", "length"], | |
| ), | |
| "db.query": NodeBehavioralFixture( | |
| type="db.query", | |
| label="Database Query", | |
| category="Data Structures", | |
| valid_params={"predicate_key": "status", "predicate_value": "active"}, | |
| valid_inputs={"records_in": [{"id": 1, "status": "active"}, {"id": 2, "status": "disabled"}]}, | |
| expected_outputs={"result": 1, "count": 1}, | |
| invalid_params={}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["records_in"], | |
| wireable_output_ports=["records", "count", "first", "result"], | |
| ), | |
| # ─── 7. FILE I/O ───────────────────────────────────────────────────────── | |
| "file.read": NodeBehavioralFixture( | |
| type="file.read", | |
| label="File Read", | |
| category="System & I/O", | |
| valid_params={"file_path": "data.txt", "default_content": "sample content\n"}, | |
| valid_inputs={"file_path": "data.txt"}, | |
| expected_outputs={"content": "sample content\n"}, | |
| invalid_params={}, | |
| invalid_inputs={"file_path": "../../etc/passwd"}, | |
| expected_error="ERR-SECURITY-PATH-TRAVERSAL", | |
| wireable_input_ports=["file_path"], | |
| wireable_output_ports=["content", "lines", "bytes"], | |
| ), | |
| "file.write": NodeBehavioralFixture( | |
| type="file.write", | |
| label="File Write", | |
| category="System & I/O", | |
| valid_params={"file_path": "output.txt", "content": "Hello World\n"}, | |
| valid_inputs={"content": "Hello World\n"}, | |
| expected_outputs={"bytes_written": 12, "status": "success"}, | |
| invalid_params={}, | |
| invalid_inputs={"file_path": "..\\..\\Windows\\System32\\cmd.exe"}, | |
| expected_error="ERR-SECURITY-PATH-TRAVERSAL", | |
| wireable_input_ports=["file_path", "content"], | |
| wireable_output_ports=["bytes_written", "status"], | |
| ), | |
| # ─── 8. FUNCTIONS & RECURSION ──────────────────────────────────────────── | |
| "function.call": NodeBehavioralFixture( | |
| type="function.call", | |
| label="Function Call", | |
| category="Functions & Scope", | |
| valid_params={"function_name": "calc_total", "func_name": "calc_total", "arg": 10}, | |
| valid_inputs={"arg": 10, "arg_1": 10, "arg_2": 15}, | |
| expected_outputs={"result": 20, "val": 20}, | |
| invalid_params={"function_name": "123_invalid"}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["callable_fn", "arg", "function_ref", "arg_1", "arg_2"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "function.def": NodeBehavioralFixture( | |
| type="function.def", | |
| label="Function Definition", | |
| category="Functions & Scope", | |
| valid_params={"name": "calc_total", "parameters": "a, b"}, | |
| valid_inputs={}, | |
| expected_outputs={"func_ref": "calc_total", "name": "calc_total"}, | |
| invalid_params={"name": ""}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["body_in"], | |
| wireable_output_ports=["func_ref", "name", "body_out"], | |
| ), | |
| # ─── 9. GENERAL I/O (PRINT & INPUT) ────────────────────────────────────── | |
| "io.input": NodeBehavioralFixture( | |
| type="io.input", | |
| label="Graph Input", | |
| category="System & I/O", | |
| valid_params={"input_name": "user_id", "default_val": 42}, | |
| valid_inputs={"value": 42}, | |
| expected_outputs={"value": 42, "result": 42, "val": 42}, | |
| invalid_params={}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["value"], | |
| wireable_output_ports=["value", "result", "val"], | |
| ), | |
| "io.print": NodeBehavioralFixture( | |
| type="io.print", | |
| label="Print / Console Display", | |
| category="System & I/O", | |
| valid_params={"message": ""}, | |
| valid_inputs={"value": "Status: OK"}, | |
| expected_outputs={"printed": "Status: OK", "result": "Status: OK", "val": "Status: OK"}, | |
| invalid_params={}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["value", "val", "in"], | |
| wireable_output_ports=["printed", "result", "val"], | |
| ), | |
| # ─── 10. JSON PARSING & STRINGIFY ──────────────────────────────────────── | |
| "json.parse": NodeBehavioralFixture( | |
| type="json.parse", | |
| label="JSON Parser", | |
| category="Data Structures", | |
| valid_params={}, | |
| valid_inputs={"text": '{"count": 42, "status": "active"}'}, | |
| expected_outputs={"result": {"count": 42, "status": "active"}, "val": {"count": 42, "status": "active"}}, | |
| invalid_params={}, | |
| invalid_inputs={"text": "{malformed_json:!!}"}, | |
| expected_error="JSONDecodeError", | |
| wireable_input_ports=["text"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "json.stringify": NodeBehavioralFixture( | |
| type="json.stringify", | |
| label="JSON Stringifier", | |
| category="Data Structures", | |
| valid_params={"indent": 2}, | |
| valid_inputs={"data": {"score": 100}}, | |
| expected_outputs={"text": '{\n "score": 100\n}'}, | |
| invalid_params={}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["data"], | |
| wireable_output_ports=["text", "val"], | |
| ), | |
| # ─── 11. MODULE IMPORTS (LANG.IMPORT) ──────────────────────────────────── | |
| "lang.import": NodeBehavioralFixture( | |
| type="lang.import", | |
| label="Module Import", | |
| category="Modules & Organization", | |
| valid_params={"module_name": "json", "function_name": "loads", "default_input": '{"score": 95}'}, | |
| valid_inputs={"data_in": '{"score": 95}'}, | |
| expected_outputs={"result": {"score": 95}, "val": {"score": 95}, "module_ref": "json"}, | |
| invalid_params={"module_name": "os"}, | |
| invalid_inputs={"data_in": "{malformed:"}, | |
| expected_error="ERR-SECURITY-UNAUTHORIZED-MODULE", | |
| capabilities={ | |
| "backend_runtime": ValidationStatus.PASS, | |
| "frontend_runtime": ValidationStatus.PASS, | |
| "backend_codegen": ValidationStatus.PASS, | |
| "frontend_codegen": ValidationStatus.PASS, | |
| }, | |
| wireable_input_ports=["data_in"], | |
| wireable_output_ports=["result", "val", "module_ref", "out"], | |
| ), | |
| # ─── 12. MATHEMATICAL FUNCTIONS ────────────────────────────────────────── | |
| "math.abs": NodeBehavioralFixture( | |
| type="math.abs", | |
| label="Absolute Value", | |
| category="Math & Science", | |
| valid_params={}, | |
| valid_inputs={"x": -42.5}, | |
| expected_outputs={"result": 42.5, "val": 42.5}, | |
| invalid_params={}, | |
| invalid_inputs={"x": "not_a_number"}, | |
| expected_error="TypeError", | |
| wireable_input_ports=["x"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "math.ceil": NodeBehavioralFixture( | |
| type="math.ceil", | |
| label="Ceil (Round Up)", | |
| category="Math & Science", | |
| valid_params={}, | |
| valid_inputs={"x": 4.1}, | |
| expected_outputs={"result": 5, "val": 5}, | |
| invalid_params={}, | |
| invalid_inputs={"x": "bad"}, | |
| expected_error="TypeError", | |
| wireable_input_ports=["x"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "math.floor": NodeBehavioralFixture( | |
| type="math.floor", | |
| label="Floor (Round Down)", | |
| category="Math & Science", | |
| valid_params={}, | |
| valid_inputs={"x": 4.9}, | |
| expected_outputs={"result": 4, "val": 4}, | |
| invalid_params={}, | |
| invalid_inputs={"x": "bad"}, | |
| expected_error="TypeError", | |
| wireable_input_ports=["x"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "math.max": NodeBehavioralFixture( | |
| type="math.max", | |
| label="Maximum", | |
| category="Math & Science", | |
| valid_params={}, | |
| valid_inputs={"a": 10, "b": 25}, | |
| expected_outputs={"result": 25, "val": 25}, | |
| invalid_params={}, | |
| invalid_inputs={"a": "bad", "b": 5}, | |
| expected_error="TypeError", | |
| wireable_input_ports=["a", "b"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "math.min": NodeBehavioralFixture( | |
| type="math.min", | |
| label="Minimum", | |
| category="Math & Science", | |
| valid_params={}, | |
| valid_inputs={"a": 10, "b": 25}, | |
| expected_outputs={"result": 10, "val": 10}, | |
| invalid_params={}, | |
| invalid_inputs={"a": "bad", "b": 5}, | |
| expected_error="TypeError", | |
| wireable_input_ports=["a", "b"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "math.pow": NodeBehavioralFixture( | |
| type="math.pow", | |
| label="Power (x^y)", | |
| category="Math & Science", | |
| valid_params={}, | |
| valid_inputs={"base": 2, "exp": 3, "x": 2.0, "y": 3.0}, | |
| expected_outputs={"result": 8.0, "val": 8.0}, | |
| invalid_params={}, | |
| invalid_inputs={"base": "bad", "exp": 2, "x": "bad", "y": 2}, | |
| expected_error="TypeError", | |
| wireable_input_ports=["x", "y", "base", "exp"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "math.round": NodeBehavioralFixture( | |
| type="math.round", | |
| label="Round", | |
| category="Math & Science", | |
| valid_params={"precision": 2}, | |
| valid_inputs={"x": 3.14159}, | |
| expected_outputs={"result": 3.14, "val": 3.14}, | |
| invalid_params={"precision": -1}, | |
| invalid_inputs={"x": "bad"}, | |
| expected_error="TypeError", | |
| wireable_input_ports=["x"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| "math.sqrt": NodeBehavioralFixture( | |
| type="math.sqrt", | |
| label="Square Root", | |
| category="Math & Science", | |
| valid_params={}, | |
| valid_inputs={"x": 49.0}, | |
| expected_outputs={"result": 7.0, "val": 7.0}, | |
| invalid_params={}, | |
| invalid_inputs={"x": -1.0}, | |
| expected_error="math domain error", | |
| wireable_input_ports=["x"], | |
| wireable_output_ports=["result", "val"], | |
| ), | |
| # ─── 13. HEAVY EXTERNAL LIBRARIES (NUMPY / PANDAS) ─────────────────────── | |
| "numpy.array": NodeBehavioralFixture( | |
| type="numpy.array", | |
| label="NumPy Array", | |
| category="Math & Science", | |
| valid_params={"dtype": "float64"}, | |
| valid_inputs={"data_in": [1.0, 2.0, 3.0]}, | |
| expected_outputs={"shape": [3], "size": 3}, | |
| invalid_params={"dtype": "invalid_dtype"}, | |
| invalid_inputs={}, | |
| capabilities={ | |
| "backend_runtime": ValidationStatus.UNSUPPORTED, | |
| "frontend_runtime": ValidationStatus.UNSUPPORTED, | |
| "backend_codegen": ValidationStatus.PASS, | |
| "frontend_codegen": ValidationStatus.PASS, | |
| }, | |
| unsupported_reason="External library node requiring dynamic sandbox environment.", | |
| wireable_input_ports=["data_in"], | |
| wireable_output_ports=["array_out", "shape", "size"], | |
| ), | |
| "pandas.dataframe": NodeBehavioralFixture( | |
| type="pandas.dataframe", | |
| label="Pandas DataFrame", | |
| category="Math & Science", | |
| valid_params={"index_col": "id"}, | |
| valid_inputs={"records_in": [{"id": 1, "score": 90}, {"id": 2, "score": 95}]}, | |
| expected_outputs={"num_rows": 2, "columns": ["id", "score"]}, | |
| invalid_params={}, | |
| invalid_inputs={}, | |
| capabilities={ | |
| "backend_runtime": ValidationStatus.UNSUPPORTED, | |
| "frontend_runtime": ValidationStatus.UNSUPPORTED, | |
| "backend_codegen": ValidationStatus.PASS, | |
| "frontend_codegen": ValidationStatus.PASS, | |
| }, | |
| unsupported_reason="External library node requiring dynamic sandbox environment.", | |
| wireable_input_ports=["records_in"], | |
| wireable_output_ports=["df_out", "num_rows", "columns"], | |
| ), | |
| # ─── 14. OBJECT-ORIENTED PROGRAMMING (OOP) ─────────────────────────────── | |
| "oop.class_def": NodeBehavioralFixture( | |
| type="oop.class_def", | |
| label="Class Definition", | |
| category="Object-Oriented Programming", | |
| valid_params={"class_name": "Student", "attributes": "name, score"}, | |
| valid_inputs={}, | |
| expected_outputs={"class_ref": "Student", "class_name": "Student"}, | |
| invalid_params={"class_name": "123_invalid_class"}, | |
| invalid_inputs={}, | |
| expected_error="Invalid identifier", | |
| wireable_input_ports=[], | |
| wireable_output_ports=["class_ref", "class_name"], | |
| ), | |
| "oop.instance": NodeBehavioralFixture( | |
| type="oop.instance", | |
| label="Create Instance", | |
| category="Object-Oriented Programming", | |
| valid_params={"class_name": "Student", "arg_1_val": "Alice", "arg_2_val": 95}, | |
| valid_inputs={}, | |
| expected_outputs={"status": "created"}, | |
| invalid_params={"class_name": ""}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["class_in", "arg_1", "arg_2"], | |
| wireable_output_ports=["instance", "status"], | |
| ), | |
| "oop.method_call": NodeBehavioralFixture( | |
| type="oop.method_call", | |
| label="Method Call / Attribute Mutation", | |
| category="Object-Oriented Programming", | |
| valid_params={"method_name": "add_bonus", "default_arg": 5, "attribute_to_modify": "score", "operation": "increment"}, | |
| valid_inputs={"instance_in": {"name": "Alice", "score": 90}, "arg": 10}, | |
| expected_outputs={"result": 100}, | |
| invalid_params={"method_name": ""}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["instance_in", "arg"], | |
| wireable_output_ports=["instance_out", "result", "val"], | |
| ), | |
| # ─── 15. STRING MANIPULATION ───────────────────────────────────────────── | |
| "string.concat": NodeBehavioralFixture( | |
| type="string.concat", | |
| label="String Concatenate", | |
| category="Primitives & Variables", | |
| valid_params={"separator": " "}, | |
| valid_inputs={"a": "Hello", "b": "World"}, | |
| expected_outputs={"result": "Hello World", "length": 11}, | |
| invalid_params={}, | |
| invalid_inputs={}, | |
| wireable_input_ports=["a", "b"], | |
| wireable_output_ports=["result", "length"], | |
| ), | |
| "string.split": NodeBehavioralFixture( | |
| type="string.split", | |
| label="String Split", | |
| category="Primitives & Variables", | |
| valid_params={"delimiter": ","}, | |
| valid_inputs={"text": "apple,banana,orange"}, | |
| expected_outputs={"items": ["apple", "banana", "orange"], "count": 3}, | |
| invalid_params={}, | |
| invalid_inputs={"text": None}, | |
| wireable_input_ports=["text"], | |
| wireable_output_ports=["items", "count"], | |
| ), | |
| "string.transform": NodeBehavioralFixture( | |
| type="string.transform", | |
| label="String Transform", | |
| category="Primitives & Variables", | |
| valid_params={"operation": "upper"}, | |
| valid_inputs={"text": "hello", "text_in": "hello"}, | |
| expected_outputs={"text_out": "HELLO", "length": 5}, | |
| invalid_params={"operation": "invalid_transform_op"}, | |
| invalid_inputs={}, | |
| expected_error="Unsupported string operation", | |
| wireable_input_ports=["text", "text_in"], | |
| wireable_output_ports=["text_out", "length"], | |
| ), | |
| # ─── 16. SYSTEM FILE & TRIGGERS ────────────────────────────────────────── | |
| "sys.file": NodeBehavioralFixture( | |
| type="sys.file", | |
| label="Sandboxed System File", | |
| category="System & I/O", | |
| valid_params={"file_path": "audit.log", "mode": "write"}, | |
| valid_inputs={"content": "Log entry: OK\n"}, | |
| expected_outputs={"bytes": 14, "content": "Log entry: OK\n"}, | |
| invalid_params={"mode": "exec_untrusted"}, | |
| invalid_inputs={"file_path": "/root/secret.key"}, | |
| expected_error="ERR-SECURITY-PATH-TRAVERSAL", | |
| wireable_input_ports=["file_path", "content"], | |
| wireable_output_ports=["content", "lines", "bytes"], | |
| ), | |
| "trigger.schedule": NodeBehavioralFixture( | |
| type="trigger.schedule", | |
| label="Schedule Trigger", | |
| category="Triggers & Scheduling", | |
| valid_params={"cron_expression": "0 * * * *"}, | |
| valid_inputs={}, | |
| expected_outputs={"trigger": True}, | |
| invalid_params={"cron_expression": "invalid_cron_syntax"}, | |
| invalid_inputs={}, | |
| wireable_input_ports=[], | |
| wireable_output_ports=["trigger", "timestamp"], | |
| ), | |
| "trigger.webhook": NodeBehavioralFixture( | |
| type="trigger.webhook", | |
| label="Webhook Trigger", | |
| category="Triggers & Scheduling", | |
| valid_params={"path": "/hooks/user_created", "auth_required": True}, | |
| valid_inputs={}, | |
| expected_outputs={"trigger": True}, | |
| invalid_params={"path": ""}, | |
| invalid_inputs={}, | |
| wireable_input_ports=[], | |
| wireable_output_ports=["trigger", "payload", "headers"], | |
| ), | |
| "workflow.start": NodeBehavioralFixture( | |
| type="workflow.start", | |
| label="Workflow Start", | |
| category="System & I/O", | |
| valid_params={}, | |
| valid_inputs={}, | |
| expected_outputs={"trigger": True}, | |
| invalid_params={}, | |
| invalid_inputs={}, | |
| wireable_input_ports=[], | |
| wireable_output_ports=["trigger"], | |
| ), | |
| } | |
| def get_behavioral_fixture(node_type: str) -> Optional[NodeBehavioralFixture]: | |
| """Retrieve the authoritative behavioral fixture for a node type.""" | |
| return ALL_NODE_BEHAVIORAL_FIXTURES.get(node_type) | |
| def list_all_behavioral_fixtures() -> List[NodeBehavioralFixture]: | |
| """Return all 59 canonical behavioral fixtures in sorted order.""" | |
| return [ALL_NODE_BEHAVIORAL_FIXTURES[k] for k in sorted(ALL_NODE_BEHAVIORAL_FIXTURES.keys())] | |