Skip to content

feat(workflow): add DSL to StateGraph compiler with strongly typed errors#1125

Open
Deepak-negi11 wants to merge 2 commits intomofa-org:mainfrom
Deepak-negi11:feat/dsl-compiler-clean
Open

feat(workflow): add DSL to StateGraph compiler with strongly typed errors#1125
Deepak-negi11 wants to merge 2 commits intomofa-org:mainfrom
Deepak-negi11:feat/dsl-compiler-clean

Conversation

@Deepak-negi11
Copy link
Copy Markdown
Contributor

🎯 Overview
This PR introduces the DslCompiler, bridging the gap between our declarative YAML/TOML workflow definitions and the StateGraph execution engine. It allows parsed DSLs to be natively compiled into a CompiledGraphImpl that can be invoked, streamed, or stepped through.

Additionally, this PR refactors the parser's error handling, replacing generic string-based validation errors with strongly typed thiserror variants for much better programmatic error matching and observability.

🚀 Key Changes
DslCompiler Implementation (compiler.rs)
Node Adapters: Implemented NodeFunc adapters to translate DSL nodes into executable graph nodes (PassthroughNode, DslTaskNode, DslConditionNode, DslJoinNode, DslTransformNode, DslAgentNode).

Agent Registry: Added support for resolving LlmAgent nodes against an injected HashMap registry of LLMAgent instances.

Condition Evaluation: Built a stateless JSON value comparator to handle edge routing conditions (==, >, <=, contains).

Topology Wiring: Implemented automatic graph wiring, connecting standard edges and mapping conditional branches.

Strongly Typed Errors (mod.rs & parser.rs)
Deprecated DslError::Validation(String) in favor of precise error variants.

Added specific variants for topology errors: MissingStartNode, MissingEndNode, DuplicateNodeId, InvalidEdge.

Added specific variants for execution/parsing errors: MissingAgentInRegistry, InlineAgentNotSupported, TomlToJsonConversion, MissingFileExtension, UnsupportedFileExtension.

Refactored WorkflowDslParser to utilize these new errors, cleaning up the TOML/YAML file extraction logic.

Comprehensive Testing
Added 1,000+ lines of tests verifying workflow roundtrips, conditional edge logic, transformation nodes, and proper error propagation for invalid schemas.

🔗 Related Issues
Fixes #691

@Deepak-negi11 Deepak-negi11 force-pushed the feat/dsl-compiler-clean branch from a57df6e to 0294ed2 Compare March 11, 2026 14:02
…rors

- Add DslCompiler that bridges YAML/TOML DSL to StateGraph
- Replace generic DslError::Validation(String) with strongly typed variants
- Add conditional routing deduplication and Command route/send builders
- Fix state_graph tests and node state keys to use node identifiers
- Add workflow_dsl example with real DSL compiler usage
- Add state_graph_core_fixes example

Fixes mofa-org#691
@Deepak-negi11 Deepak-negi11 force-pushed the feat/dsl-compiler-clean branch from 0294ed2 to d81ede1 Compare March 27, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] DSL to StateGraph compiler bridge — connect declarative YAML/TOML workflows to execution engine

1 participant