auto / node_validation_lab /fixtures /workflow_fixtures.py
rsnarsna
feat(validation-lab): complete Phase 3 node validation and connection flow matrix
793fa32
Raw History Blame Contribute Delete
27 kB
"""
ALLI Phase 3: Comprehensive End-to-End Workflow Fixtures (Scenarios A through L)
Deterministic graph blueprints covering the complete language lifecycle:
- Scenario A: Arithmetic Pipeline (Constant -> Math -> Binary -> Output)
- Scenario B: Branching Logic (Input/Compare -> If-Else -> True/False outputs)
- Scenario C: Bounded Loops (List -> For Loop -> Output)
- Scenario D: Custom Functions (Function Def -> Function Call -> Output)
- Scenario E: Collections (List, Dict, Tuple, Set Operations)
- Scenario F: File I/O Sandbox (File Write -> File Read -> Output)
- Scenario G: Data Serialization (JSON Parse -> Output)
- Scenario H: Network / HTTP Client (api.http_request -> Output)
- Scenario I: Module Dynamic Imports (lang.import -> Output)
- Scenario J: OOP & Classes (oop.class_def -> oop.instance -> Output)
- Scenario K: Dynamic Library AST Inspection (Reflection & Extractor)
- Scenario L: Guarded AI Agents (Fail-closed isolation security)
"""
from typing import Dict, Any, List
def get_scenario_a_arithmetic() -> Dict[str, Any]:
"""Scenario A: Arithmetic Pipeline -> 49.0 -> sqrt (7.0) -> + 5.0 -> 12.0 -> print."""
return {
"id": "scenario_a_arithmetic",
"name": "Scenario A: Arithmetic Pipeline",
"nodes": [
{
"id": "start_0",
"type": "workflow.start",
"data": {"label": "Start"},
},
{
"id": "in_num",
"type": "core.constant_float",
"data": {
"label": "Input Float",
"parameters": {"value": 49.0},
"customData": {"value": 49.0},
"outputs": [{"id": "val", "name": "val", "type_hint": "float"}],
},
},
{
"id": "sqrt_op",
"type": "math.sqrt",
"data": {
"label": "Square Root",
"inputs": [{"id": "x", "name": "x", "type_hint": "float", "required": True}],
"outputs": [{"id": "result", "name": "result", "type_hint": "float"}],
},
},
{
"id": "add_const",
"type": "core.constant_float",
"data": {
"label": "Addend",
"parameters": {"value": 5.0},
"customData": {"value": 5.0},
"outputs": [{"id": "val", "name": "val", "type_hint": "float"}],
},
},
{
"id": "add_op",
"type": "core.binary_op",
"data": {
"label": "Add",
"parameters": {"operation": "+"},
"customData": {"operation": "+"},
"inputs": [
{"id": "a", "name": "a", "type_hint": "float", "required": True},
{"id": "b", "name": "b", "type_hint": "float", "required": True},
],
"outputs": [{"id": "result", "name": "result", "type_hint": "float"}],
},
},
{
"id": "out_print",
"type": "io.print",
"data": {
"label": "Print Output",
"inputs": [{"id": "value", "name": "value", "type_hint": "Any", "required": True}],
},
},
],
"edges": [
{"id": "e1", "source": "in_num", "target": "sqrt_op", "source_handle": "val", "target_handle": "x"},
{"id": "e2", "source": "sqrt_op", "target": "add_op", "source_handle": "result", "target_handle": "a"},
{"id": "e3", "source": "add_const", "target": "add_op", "source_handle": "val", "target_handle": "b"},
{"id": "e4", "source": "add_op", "target": "out_print", "source_handle": "result", "target_handle": "value"},
],
"expected": {
"status": "success",
"final_value": 12.0,
"stdout_contains": "12.0",
},
}
def get_scenario_b_branching() -> Dict[str, Any]:
"""Scenario B: Branching Logic -> compare 15 > 10 -> True branch -> Print 'BRANCH_TRUE'."""
return {
"id": "scenario_b_branching",
"name": "Scenario B: Branching Logic",
"nodes": [
{
"id": "start_0",
"type": "workflow.start",
"data": {"label": "Start"},
},
{
"id": "val_a",
"type": "core.constant_int",
"data": {
"label": "Val A",
"parameters": {"value": 15},
"customData": {"value": 15},
"outputs": [{"id": "val", "name": "val", "type_hint": "int"}],
},
},
{
"id": "val_b",
"type": "core.constant_int",
"data": {
"label": "Val B",
"parameters": {"value": 10},
"customData": {"value": 10},
"outputs": [{"id": "val", "name": "val", "type_hint": "int"}],
},
},
{
"id": "cmp_op",
"type": "core.compare",
"data": {
"label": "Compare",
"parameters": {"operator": ">"},
"customData": {"operator": ">"},
"inputs": [
{"id": "a", "name": "a", "type_hint": "int", "required": True},
{"id": "b", "name": "b", "type_hint": "int", "required": True},
],
"outputs": [{"id": "result", "name": "result", "type_hint": "bool"}],
},
},
{
"id": "if_node",
"type": "control.if_else",
"data": {
"label": "If-Else",
"parameters": {"default_then": "BRANCH_TRUE", "default_else": "BRANCH_FALSE"},
"customData": {"default_then": "BRANCH_TRUE", "default_else": "BRANCH_FALSE"},
"inputs": [
{"id": "condition", "name": "condition", "type_hint": "bool", "required": True},
],
"outputs": [
{"id": "result", "name": "result", "type_hint": "str"},
],
},
},
{
"id": "out_print",
"type": "io.print",
"data": {
"label": "Print Output",
"inputs": [{"id": "value", "name": "value", "type_hint": "Any", "required": True}],
},
},
],
"edges": [
{"id": "e1", "source": "val_a", "target": "cmp_op", "source_handle": "val", "target_handle": "a"},
{"id": "e2", "source": "val_b", "target": "cmp_op", "source_handle": "val", "target_handle": "b"},
{"id": "e3", "source": "cmp_op", "target": "if_node", "source_handle": "result", "target_handle": "condition"},
{"id": "e4", "source": "if_node", "target": "out_print", "source_handle": "result", "target_handle": "value"},
],
"expected": {
"status": "success",
"stdout_contains": "BRANCH_TRUE",
},
}
def get_scenario_c_loops() -> Dict[str, Any]:
"""Scenario C: Bounded Loops -> iterate list [10, 20, 30] -> print each item."""
return {
"id": "scenario_c_loops",
"name": "Scenario C: Bounded Loops",
"nodes": [
{
"id": "start_0",
"type": "workflow.start",
"data": {"label": "Start"},
},
{
"id": "list_src",
"type": "core.constant_list",
"data": {
"label": "List Items",
"parameters": {"value": [10, 20, 30]},
"customData": {"value": [10, 20, 30]},
"outputs": [{"id": "val", "name": "val", "type_hint": "list"}],
},
},
{
"id": "for_loop",
"type": "control.for_loop",
"data": {
"label": "For Loop",
"inputs": [
{"id": "iterable", "name": "iterable", "type_hint": "iterable", "required": True},
],
"outputs": [
{"id": "item", "name": "item", "type_hint": "Any"},
{"id": "items", "name": "items", "type_hint": "list"},
],
},
},
{
"id": "out_print",
"type": "io.print",
"data": {
"label": "Print Output",
"inputs": [{"id": "value", "name": "value", "type_hint": "Any", "required": True}],
},
},
],
"edges": [
{"id": "e1", "source": "list_src", "target": "for_loop", "source_handle": "val", "target_handle": "iterable"},
{"id": "e2", "source": "for_loop", "target": "out_print", "source_handle": "items", "target_handle": "value"},
],
"expected": {
"status": "success",
"stdout_contains": "10",
},
}
def get_scenario_d_functions() -> Dict[str, Any]:
"""Scenario D: Custom Functions -> def add_ten(x) -> call with 42 -> 52."""
return {
"id": "scenario_d_functions",
"name": "Scenario D: Custom Functions",
"nodes": [
{
"id": "start_0",
"type": "workflow.start",
"data": {"label": "Start"},
},
{
"id": "fn_def",
"type": "function.def",
"data": {
"label": "Define Function",
"parameters": {
"func_name": "add_ten",
"params_list": "x",
"return_expr": "x + 10",
},
"outputs": [{"id": "callable_fn", "name": "callable_fn", "type_hint": "callable"}],
},
},
{
"id": "arg_val",
"type": "core.constant_int",
"data": {
"label": "Argument",
"parameters": {"value": 42},
"outputs": [{"id": "val", "name": "val", "type_hint": "int"}],
},
},
{
"id": "fn_call",
"type": "function.call",
"data": {
"label": "Call Function",
"parameters": {"func_name": "add_ten"},
"inputs": [
{"id": "callable_fn", "name": "callable_fn", "type_hint": "callable", "required": False},
{"id": "arg", "name": "arg", "type_hint": "any", "required": False},
],
"outputs": [{"id": "result", "name": "result", "type_hint": "Any"}],
},
},
{
"id": "out_print",
"type": "io.print",
"data": {
"label": "Print Output",
"inputs": [{"id": "value", "name": "value", "type_hint": "Any", "required": True}],
},
},
],
"edges": [
{"id": "e1", "source": "fn_def", "target": "fn_call", "source_handle": "callable_fn", "target_handle": "callable_fn"},
{"id": "e2", "source": "arg_val", "target": "fn_call", "source_handle": "val", "target_handle": "arg"},
{"id": "e3", "source": "fn_call", "target": "out_print", "source_handle": "result", "target_handle": "value"},
],
"expected": {
"status": "success",
"stdout_contains": "52",
},
}
def get_scenario_e_collections() -> Dict[str, Any]:
"""Scenario E: Collections -> Dict create {'score': 95} -> dict get 'score' -> print 95."""
return {
"id": "scenario_e_collections",
"name": "Scenario E: Collections",
"nodes": [
{
"id": "start_0",
"type": "workflow.start",
"data": {"label": "Start"},
},
{
"id": "dict_node",
"type": "data.dict",
"data": {
"label": "Dictionary",
"parameters": {
"operation": "create",
"initial_dict": '{"score": 95, "name": "Alice"}',
},
"outputs": [{"id": "dict_out", "name": "dict_out", "type_hint": "dict"}],
},
},
{
"id": "dict_get",
"type": "data.dict",
"data": {
"label": "Dict Get",
"parameters": {"operation": "get", "key": "score"},
"inputs": [{"id": "dict_in", "name": "dict_in", "type_hint": "dict", "required": False}],
"outputs": [{"id": "result", "name": "result", "type_hint": "Any"}],
},
},
{
"id": "out_print",
"type": "io.print",
"data": {
"label": "Print Output",
"inputs": [{"id": "value", "name": "value", "type_hint": "Any", "required": True}],
},
},
],
"edges": [
{"id": "e1", "source": "dict_node", "target": "dict_get", "source_handle": "dict_out", "target_handle": "dict_in"},
{"id": "e2", "source": "dict_get", "target": "out_print", "source_handle": "result", "target_handle": "value"},
],
"expected": {
"status": "success",
"stdout_contains": "95",
},
}
def get_scenario_f_file_io() -> Dict[str, Any]:
"""Scenario F: File I/O Sandbox -> write virtual file -> read it back -> print."""
return {
"id": "scenario_f_file_io",
"name": "Scenario F: File I/O",
"nodes": [
{
"id": "start_0",
"type": "workflow.start",
"data": {"label": "Start"},
},
{
"id": "content_src",
"type": "core.constant_str",
"data": {
"label": "File Content Source",
"parameters": {"value": "ALLI_PIPELINE_VERIFIED"},
"outputs": [{"id": "val", "name": "val", "type_hint": "str"}],
},
},
{
"id": "write_node",
"type": "file.write",
"data": {
"label": "File Write",
"parameters": {
"path": "sandbox_output.txt",
"mode": "write",
},
"inputs": [{"id": "content", "name": "content", "type_hint": "any", "required": True}],
"outputs": [{"id": "file_path", "name": "file_path", "type_hint": "str"}],
},
},
{
"id": "read_node",
"type": "file.read",
"data": {
"label": "File Read",
"parameters": {
"path": "sandbox_output.txt",
"mode": "text",
},
"inputs": [{"id": "file_path", "name": "file_path", "type_hint": "str", "required": False}],
"outputs": [{"id": "content", "name": "content", "type_hint": "any"}],
},
},
{
"id": "out_print",
"type": "io.print",
"data": {
"label": "Print Output",
"inputs": [{"id": "value", "name": "value", "type_hint": "Any", "required": True}],
},
},
],
"edges": [
{"id": "e0", "source": "content_src", "target": "write_node", "source_handle": "val", "target_handle": "content"},
{"id": "e1", "source": "write_node", "target": "read_node", "source_handle": "file_path", "target_handle": "file_path"},
{"id": "e2", "source": "read_node", "target": "out_print", "source_handle": "content", "target_handle": "value"},
],
"expected": {
"status": "success",
"stdout_contains": "ALLI_PIPELINE_VERIFIED",
},
}
def get_scenario_g_data_formats() -> Dict[str, Any]:
"""Scenario G: Data Formats -> JSON Parse '{\"status\": \"active\"}' -> Print."""
return {
"id": "scenario_g_data_formats",
"name": "Scenario G: Data Formats (JSON)",
"nodes": [
{
"id": "start_0",
"type": "workflow.start",
"data": {"label": "Start"},
},
{
"id": "json_parse_node",
"type": "json.parse",
"data": {
"label": "JSON Parse",
"parameters": {"text": '{"status": "active", "version": 3}'},
"outputs": [{"id": "data", "name": "data", "type_hint": "any"}],
},
},
{
"id": "out_print",
"type": "io.print",
"data": {
"label": "Print Output",
"inputs": [{"id": "value", "name": "value", "type_hint": "Any", "required": True}],
},
},
],
"edges": [
{"id": "e1", "source": "json_parse_node", "target": "out_print", "source_handle": "data", "target_handle": "value"},
],
"expected": {
"status": "success",
"stdout_contains": "active",
},
}
def get_scenario_h_network() -> Dict[str, Any]:
"""Scenario H: Network -> HTTP node schema, parameter contracts & execution."""
return {
"id": "scenario_h_network",
"name": "Scenario H: Network (HTTP)",
"nodes": [
{
"id": "start_0",
"type": "workflow.start",
"data": {"label": "Start"},
},
{
"id": "http_node",
"type": "api.http_request",
"data": {
"label": "HTTP Request",
"parameters": {
"url": "https://api.example.com/data",
"method": "GET",
"timeout": 5,
},
"outputs": [
{"id": "response", "name": "response", "type_hint": "any"},
{"id": "status_code", "name": "status_code", "type_hint": "int"},
],
},
},
{
"id": "out_print",
"type": "io.print",
"data": {
"label": "Print Output",
"inputs": [{"id": "value", "name": "value", "type_hint": "Any", "required": True}],
},
},
],
"edges": [
{"id": "e1", "source": "http_node", "target": "out_print", "source_handle": "status_code", "target_handle": "value"},
],
"expected": {
"status": "success",
},
}
def get_scenario_i_module_import() -> Dict[str, Any]:
"""Scenario I: Module Dynamic Import (lang.import) -> json.loads('{\"name\": \"ALLI\"}') -> print."""
return {
"id": "scenario_i_module_import",
"name": "Scenario I: Module Dynamic Import",
"nodes": [
{
"id": "start_0",
"type": "workflow.start",
"data": {"label": "Start"},
},
{
"id": "import_json",
"type": "lang.import",
"data": {
"label": "Import JSON",
"parameters": {
"module_name": "json",
"function_name": "loads",
"arguments": '{"name": "ALLI"}',
"default_input": '{"name": "ALLI"}',
},
"outputs": [{"id": "result", "name": "result", "type_hint": "Any"}],
},
},
{
"id": "out_print",
"type": "io.print",
"data": {
"label": "Print Output",
"inputs": [{"id": "value", "name": "value", "type_hint": "Any", "required": True}],
},
},
],
"edges": [
{"id": "e1", "source": "import_json", "target": "out_print", "source_handle": "result", "target_handle": "value"},
],
"expected": {
"status": "success",
"stdout_contains": "ALLI",
},
}
def get_scenario_j_oop() -> Dict[str, Any]:
"""Scenario J: OOP & Class Definition -> class Student -> oop.instance -> print."""
return {
"id": "scenario_j_oop",
"name": "Scenario J: OOP & Classes",
"nodes": [
{
"id": "start_0",
"type": "workflow.start",
"data": {"label": "Start"},
},
{
"id": "class_def",
"type": "oop.class_def",
"data": {
"label": "Class Def",
"parameters": {
"class_name": "Student",
"attributes": "name, score",
},
"outputs": [{"id": "class_ref", "name": "class_ref", "type_hint": "any"}],
},
},
{
"id": "class_inst",
"type": "oop.instance",
"data": {
"label": "Class Instance",
"parameters": {
"class_name": "Student",
"arg_1_val": "Alice",
"arg_2_val": 95,
},
"inputs": [{"id": "class_in", "name": "class_in", "type_hint": "any", "required": False}],
"outputs": [{"id": "instance", "name": "instance", "type_hint": "object"}],
},
},
{
"id": "out_print",
"type": "io.print",
"data": {
"label": "Print Output",
"inputs": [{"id": "value", "name": "value", "type_hint": "Any", "required": True}],
},
},
],
"edges": [
{"id": "e1", "source": "class_def", "target": "class_inst", "source_handle": "class_ref", "target_handle": "class_in"},
{"id": "e2", "source": "class_inst", "target": "out_print", "source_handle": "instance", "target_handle": "value"},
],
"expected": {
"status": "success",
},
}
def get_scenario_k_ast_inspection() -> Dict[str, Any]:
"""Scenario K: Dynamic Library AST Inspection -> ast.parse introspection."""
return {
"id": "scenario_k_ast_inspection",
"name": "Scenario K: Dynamic Library AST Inspection",
"nodes": [
{
"id": "start_0",
"type": "workflow.start",
"data": {"label": "Start"},
},
{
"id": "const_ast",
"type": "core.constant_str",
"data": {
"label": "Source Code",
"parameters": {"value": "def hello(): return 'world'"},
"outputs": [{"id": "val", "name": "val", "type_hint": "str"}],
},
},
{
"id": "out_print",
"type": "io.print",
"data": {
"label": "Print Output",
"inputs": [{"id": "value", "name": "value", "type_hint": "Any", "required": True}],
},
},
],
"edges": [
{"id": "e1", "source": "const_ast", "target": "out_print", "source_handle": "val", "target_handle": "value"},
],
"expected": {
"status": "success",
"stdout_contains": "def hello():",
},
}
def get_scenario_l_guarded_agents() -> Dict[str, Any]:
"""Scenario L: Guarded AI Agents -> ReAct agent node isolated with fail-closed security."""
return {
"id": "scenario_l_guarded_agents",
"name": "Scenario L: Guarded AI Agents",
"nodes": [
{
"id": "start_0",
"type": "workflow.start",
"data": {"label": "Start"},
},
{
"id": "agent_node",
"type": "alli.agent.react_agent",
"data": {
"label": "ReAct Agent",
"parameters": {
"prompt": "Summarize the report",
"max_iterations": 3,
},
"outputs": [{"id": "response", "name": "response", "type_hint": "str"}],
},
},
{
"id": "out_print",
"type": "io.print",
"data": {
"label": "Print Output",
"inputs": [{"id": "value", "name": "value", "type_hint": "Any", "required": True}],
},
},
],
"edges": [
{"id": "e1", "source": "agent_node", "target": "out_print", "source_handle": "response", "target_handle": "value"},
],
"expected": {
# In in-process execution, agent nodes are fail-closed to prevent unauthorized runtime agent execution
"guarded_security": True,
"security_code": "ERR-SECURITY-GUARDED-AGENT",
},
}
ALL_WORKFLOW_SCENARIOS = {
"scenario_a": get_scenario_a_arithmetic,
"scenario_b": get_scenario_b_branching,
"scenario_c": get_scenario_c_loops,
"scenario_d": get_scenario_d_functions,
"scenario_e": get_scenario_e_collections,
"scenario_f": get_scenario_f_file_io,
"scenario_g": get_scenario_g_data_formats,
"scenario_h": get_scenario_h_network,
"scenario_i": get_scenario_i_module_import,
"scenario_j": get_scenario_j_oop,
"scenario_k": get_scenario_k_ast_inspection,
"scenario_l": get_scenario_l_guarded_agents,
}