cursor_Setup
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s

This commit is contained in:
Lars committed 2026-04-04 14:05:50 +02:00
1 parent c607cd1833
commit dc87e7f3b8
13 files changed
+1328

No files matched your search

+94
View File
@@ -0,0 +1,94 @@
-- Phase 3 E2E Test: Branching Workflow
-- Test workflow: body analysis → logic (if relevanz = "decrease") → then/else paths
-- 1. Cleanup (use slug for lookup)
DELETE FROM workflow_executions WHERE workflow_id IN (
SELECT id FROM workflow_definitions WHERE slug = 'phase3-e2e-branching'
);
DELETE FROM workflow_definitions WHERE slug = 'phase3-e2e-branching';
-- 2. Create test workflow
INSERT INTO workflow_definitions (name, slug, description, graph, active)
VALUES (
'Phase 3 E2E Test - Branching',
'phase3-e2e-branching',
'Test workflow with logic node and conditional branching',
'{
"nodes": [
{
"id": "start",
"type": "start",
"position": {"x": 100, "y": 100}
},
{
"id": "body_analysis",
"type": "analysis",
"prompt_slug": "pipeline_body",
"question_augmentations": [
{
"id": "q1",
"type": "relevanz",
"question": "Hat sich die Fettmasse relevant verändert?",
"answer_spectrum": ["increase", "stable", "decrease"],
"reasoning_required": true
}
],
"position": {"x": 100, "y": 200}
},
{
"id": "logic_check",
"type": "logic",
"condition": {
"expression": {
"operator": "eq",
"ref": "body_analysis.relevanz",
"value": "decrease"
},
"then_path": "e3",
"else_path": "e4"
},
"fallback": {
"strategy": "default_path"
},
"position": {"x": 100, "y": 300}
},
{
"id": "decrease_path",
"type": "analysis",
"prompt_slug": "pipeline_body",
"position": {"x": 50, "y": 400}
},
{
"id": "not_decrease_path",
"type": "analysis",
"prompt_slug": "pipeline_body",
"position": {"x": 150, "y": 400}
},
{
"id": "end",
"type": "end",
"position": {"x": 100, "y": 500}
}
],
"edges": [
{"id": "e1", "from": "start", "to": "body_analysis"},
{"id": "e2", "from": "body_analysis", "to": "logic_check"},
{"id": "e3", "from": "logic_check", "to": "decrease_path", "label": "then"},
{"id": "e4", "from": "logic_check", "to": "not_decrease_path", "label": "else"},
{"id": "e5", "from": "decrease_path", "to": "end"},
{"id": "e6", "from": "not_decrease_path", "to": "end"}
]
}',
true
);
-- 3. Verify workflow was created
SELECT
id,
name,
slug,
active,
jsonb_array_length(graph->'nodes') as node_count,
jsonb_array_length(graph->'edges') as edge_count
FROM workflow_definitions
WHERE slug = 'phase3-e2e-branching';
+123
View File
@@ -0,0 +1,123 @@
-- Phase 4 E2E Test: Branching + Join Workflow
-- Test workflow mit 2 parallelen Pfaden, die wieder zusammengeführt werden
-- 1. Insert workflow definition
INSERT INTO workflow_definitions (
id,
name,
description,
graph,
active,
created_by
) VALUES (
'phase4-join-test',
'Phase 4 Join Test Workflow',
'Test workflow with branching and join node',
'{
"nodes": [
{
"id": "start",
"type": "start",
"position": {"x": 100, "y": 100}
},
{
"id": "body_analysis",
"type": "analysis",
"prompt_slug": "body",
"position": {"x": 100, "y": 200},
"question_augmentations": [
{
"id": "relevanz",
"type": "relevanz",
"question": "Ist eine Gewichtsveränderung relevant?",
"answer_spectrum": ["ja", "nein", "unklar"]
}
]
},
{
"id": "decision_logic",
"type": "logic",
"position": {"x": 100, "y": 300},
"condition": {
"type": "if",
"expression": {
"operator": "eq",
"ref": "body_analysis.relevanz",
"value": "ja"
}
},
"fallback": {
"strategy": "default_path"
}
},
{
"id": "path_a_nutrition",
"type": "analysis",
"prompt_slug": "nutrition",
"position": {"x": 50, "y": 400},
"question_augmentations": [
{
"id": "prioritaet",
"type": "prioritaet",
"question": "Wie wichtig ist Ernährungsoptimierung?",
"answer_spectrum": ["hoch", "mittel", "niedrig", "unklar"]
}
]
},
{
"id": "path_b_activity",
"type": "analysis",
"prompt_slug": "activity",
"position": {"x": 150, "y": 400},
"question_augmentations": [
{
"id": "prioritaet",
"type": "prioritaet",
"question": "Wie wichtig ist Trainingsoptimierung?",
"answer_spectrum": ["hoch", "mittel", "niedrig", "unklar"]
}
]
},
{
"id": "join_consolidation",
"type": "join",
"position": {"x": 100, "y": 500},
"join_strategy": "best_effort",
"skip_handling": "ignore_skipped"
},
{
"id": "end",
"type": "end",
"position": {"x": 100, "y": 600}
}
],
"edges": [
{"id": "e1", "from_node": "start", "to_node": "body_analysis"},
{"id": "e2", "from_node": "body_analysis", "to_node": "decision_logic"},
{"id": "e3", "from_node": "decision_logic", "to_node": "path_a_nutrition", "label": "then"},
{"id": "e4", "from_node": "decision_logic", "to_node": "path_b_activity", "label": "else"},
{"id": "e5", "from_node": "path_a_nutrition", "to_node": "join_consolidation"},
{"id": "e6", "from_node": "path_b_activity", "to_node": "join_consolidation"},
{"id": "e7", "from_node": "join_consolidation", "to_node": "end"}
]
}'::jsonb,
true,
'test-user'
);
-- 2. Verify workflow was created
SELECT
id,
name,
active,
jsonb_array_length(graph->'nodes') as node_count,
jsonb_array_length(graph->'edges') as edge_count
FROM workflow_definitions
WHERE id = 'phase4-join-test';
-- Expected result:
-- id: phase4-join-test
-- name: Phase 4 Join Test Workflow
-- active: true
-- node_count: 7
-- edge_count: 7
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env python3
"""Quick test for deployed join_evaluator.py"""
from join_evaluator import evaluate_join_node
from workflow_models import (
WorkflowNode, WorkflowGraph, WorkflowEdge,
JoinStrategy, NodeStatus, NodeExecutionState
)
# Minimal test: 2 paths → join
join_node = WorkflowNode(
id="test_join",
type="join",
join_strategy=JoinStrategy.BEST_EFFORT
)
graph = WorkflowGraph(
nodes=[
WorkflowNode(id="path_a", type="analysis"),
WorkflowNode(id="path_b", type="analysis"),
join_node
],
edges=[
WorkflowEdge(id="e1", from_node="path_a", to_node="test_join"),
WorkflowEdge(id="e2", from_node="path_b", to_node="test_join")
]
)
context = {
"node_results": {
"path_a": NodeExecutionState(
node_id="path_a",
status=NodeStatus.EXECUTED,
analysis_core="Analysis from path A"
),
"path_b": NodeExecutionState(
node_id="path_b",
status=NodeStatus.EXECUTED,
analysis_core="Analysis from path B"
)
}
}
# Execute
result = evaluate_join_node(join_node, graph, context)
# Verify
print(f"✅ Ready: {result.ready}")
print(f"✅ Consolidated cores: {len(result.consolidated_analysis_core)}")
print(f"✅ Executed paths: {result.metadata.get('executed_paths')}")
print(f"✅ Strategy: {result.metadata.get('join_strategy')}")
assert result.ready is True
assert len(result.consolidated_analysis_core) == 2
assert "path_a" in result.consolidated_analysis_core
assert "path_b" in result.consolidated_analysis_core
print("\n🎉 Phase 4 Join Evaluator: DEPLOYED AND WORKING!")
+105
View File
@@ -0,0 +1,105 @@
#!/usr/bin/env python3
"""Integration test: Full workflow with join node"""
import asyncio
import sys
from workflow_executor import execute_node
from workflow_models import (
WorkflowNode, WorkflowGraph, WorkflowEdge,
JoinStrategy, NodeStatus, NodeExecutionState
)
async def test_join_node_integration():
"""Test execute_join_node via execute_node dispatcher"""
# Setup: 2 executed paths
path_a_state = NodeExecutionState(
node_id="path_a",
status=NodeStatus.EXECUTED,
analysis_core="Path A completed successfully"
)
path_b_state = NodeExecutionState(
node_id="path_b",
status=NodeStatus.EXECUTED,
analysis_core="Path B completed successfully"
)
# Join node
join_node = WorkflowNode(
id="join",
type="join",
join_strategy=JoinStrategy.WAIT_ALL
)
# Graph
graph = WorkflowGraph(
nodes=[
WorkflowNode(id="path_a", type="analysis"),
WorkflowNode(id="path_b", type="analysis"),
join_node
],
edges=[
WorkflowEdge(id="e1", from_node="path_a", to_node="join"),
WorkflowEdge(id="e2", from_node="path_b", to_node="join")
]
)
# Context with previous node results
context = {
"variables": {},
"profile_id": "test-profile",
"node_results": {
"path_a": path_a_state,
"path_b": path_b_state
},
"active_edges": {}
}
# Execute join node via dispatcher
async def mock_llm(prompt, model):
return "Mock LLM response"
result = await execute_node(
node=join_node,
context=context,
catalog={},
graph=graph,
openrouter_call_func=mock_llm
)
# Verify
print(f"✅ Node executed: {result.node_id}")
print(f"✅ Status: {result.status.value}")
print(f"✅ Analysis core exists: {result.analysis_core is not None}")
assert result.node_id == "join"
assert result.status == NodeStatus.EXECUTED
assert result.analysis_core is not None
# Check consolidated data
import json
consolidated = json.loads(result.analysis_core)
print(f"✅ Consolidated paths: {len(consolidated)}")
assert len(consolidated) == 2
assert "path_a" in consolidated
assert "path_b" in consolidated
print(f"✅ Path A analysis: {consolidated['path_a'][:50]}...")
print(f"✅ Path B analysis: {consolidated['path_b'][:50]}...")
print("\n🎉 Integration Test: JOIN NODE WORKING IN WORKFLOW EXECUTOR!")
print(" - Both paths consolidated successfully")
print(" - Analysis cores merged correctly")
print(" - Join strategy executed properly")
return True
if __name__ == "__main__":
try:
success = asyncio.run(test_join_node_integration())
sys.exit(0 if success else 1)
except Exception as e:
print(f"❌ Test failed: {e}")
import traceback
traceback.print_exc()
sys.exit(1)