feat: Workflow Composition API — compose_serial, trim_nodes, describe_nodes#962
Open
akashgit wants to merge 2 commits into
Open
feat: Workflow Composition API — compose_serial, trim_nodes, describe_nodes#962akashgit wants to merge 2 commits into
akashgit wants to merge 2 commits into
Conversation
New factory/workflow/composition.py with 6 functions: - prefix_nodes: namespace all node IDs with a prefix - find_terminal_nodes: discover nodes with no unconditional outgoing edges - compose_serial: chain two workflows end-to-end with conflict detection - trim_nodes: remove linear nodes and auto-reconnect (MVP: linear only) - validate_composition: graph + composition-specific validation - describe_nodes: topo-sorted node introspection (fast + LLM modes) Create mode integration: updated Builder and Strategist prompt_templates in create_workflow() to reference composition functions. SKILL.md files auto-regenerate from the updated Pydantic definitions at runtime. 18 test cases using real workflows from definitions.py. README Composition section with API table and examples. Note: composition.py is 570 lines (exceeds 500-line gate by 70). All 6 public functions share ~10 internal helpers with tight coupling; splitting would harm readability without reducing complexity. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sentrux Quality ReportAbsoluteDiff (vs base branch) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #962 +/- ##
==========================================
- Coverage 87.98% 87.97% -0.01%
==========================================
Files 104 105 +1
Lines 13316 13615 +299
==========================================
+ Hits 11716 11978 +262
- Misses 1600 1637 +37 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
asyncio.run() crashes with RuntimeError when called from within an existing async event loop (e.g. WorkflowExecutor). Detect running loop and use ThreadPoolExecutor fallback to avoid the crash. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #961
Changes
New module
factory/workflow/composition.pywith 6 functions:prefix_nodes(wf, prefix)— namespace all node IDs with a prefixfind_terminal_nodes(wf)— discover nodes with no unconditional outgoing edgescompose_serial(w1, w2, ...)— chain two workflows end-to-end with ID conflict detectiontrim_nodes(wf, node_ids)— remove linear nodes and auto-reconnect predecessors to successorsvalidate_composition(wf)— graph validation + composition-specific checks (fork targets, join sources)describe_nodes(wf, use_llm=False)— topo-sorted node introspection with fast extraction or LLM-powered summaries18 comprehensive test cases using real workflows (discover, build, improve, review) from
definitions.pyCreate mode integration — updated Builder and Strategist
prompt_templatefields increate_workflow()to reference composition functions. SKILL.md files auto-regenerate at runtime via the Pydantic → export-skills pipelineREADME documentation — added Composition section with API table, chaining/trimming examples, ID conflict resolution, and constraints
Test plan
pytest tests/test_workflow_composition.py -v)ruff checkclean on all changed filesmypyclean onfactory/workflow/composition.pyvalidate_composition()passes on all 13 registered workflows🤖 Generated with Claude Code