graph.py refactoring and If node optimization#9030
Conversation
graph.py refactoring and If node optimization
88c7e7c to
0098df4
Compare
Code Review:
|
| Severity | Count | Description |
|---|---|---|
| Important | 3 | Missing executed_history for skipped nodes; dead wrapper methods; sentinel return value |
| Suggestion | 4 | Minor style/clarity improvements |
| Missing tests | 3 | One-sided branch, two independent Ifs, nested Ifs |
| Test results | ✅ | 89 passed, 2 xfailed (intentional) |
🤖 Generated with Claude Code
0098df4 to
b31ef6d
Compare
|
The |
|
@lstein I believe all of that feedback has been addressed. |
Summary
Feature and refactor.
This PR changes
IfInvocationexecution from eager branch evaluation to lazy branch selection. The scheduler now resolves the condition first, executes only the selected branch, and skips branch-exclusive nodes on the unselected side while still executing shared ancestors that are needed elsewhere. This avoids wasted work in graphs with expensive true/false subgraphs.The PR also adds targeted graph-execution tests for simple, shared-ancestor, and iterated
Ifcases, and refactorsgraph.pyinto smaller internal helpers to make the scheduling and validation logic easier to follow. The shared graph design README was updated to match the current runtime behavior.Related Issues / Discussions
QA Instructions
Run:
pytest tests/test_graph_execution_state.pypytest tests/test_node_graph.pypytest tests/test_session_queue.pyFor manual review, inspect an
Ifgraph where both branches have upstream work. Confirm that only the selected branch executes and that shared ancestors still execute when needed by another live path.Merge Plan
Checklist
What's Newcopy (if doing a release after this PR)