Repository navigation
feat(dynaflow): typed node schema, graph serialization & custom node SDK (#282, #284) - #354
Merged
Kaap10 merged 1 commit intoNov 15, 2026
Conversation
…SDK (codeforstartups#282, codeforstartups#284) - Introduce PortCompatibilityError and is_port_type_compatible to enforce port typing - Add lossless Edge, NodePort, NodeSchema, and Node dictionary (de)serialization - Implement versioned SimpleGraph.to_dict(), to_json(), from_dict(), and from_json() - Enforce port compatibility validation in SimpleGraph.add_edge() and graph.validate() - Provide public custom node SDK with @custom_node decorator and @node_registry.register - Support custom node unregistration, dynamic inspection, and ReactFlow palette export - Add comprehensive documentation in docs/custom_nodes.md - Add end-to-end runnable example in examples/custom_nodes_sdk.py running in CI - Add 8 unit tests in tests/test_nodes.py (29 passed total) Closes codeforstartups#282 Closes codeforstartups#284
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.
Summary
Closes #282
Closes #284
Introduces the typed node system, graph JSON serialization/round-trip with port type compatibility enforcement (#282), and the public custom node SDK with function decorators, documentation, and executable examples (#284).
These features complete the core node contracts under the dynaflow agent orchestration engine without any merge conflicts across PRs.
Changes
1. Port Type Compatibility & Validation (#282)
PortCompatibilityError(inheriting fromTypeErrorandValueError) andis_port_type_compatible(source_type, target_type).SimpleGraph.add_edge(...)andSimpleGraph.validate()."any"wildcard ports, identical type matches, and JSON string ⇄ object deserialization bridges. Connecting incompatible ports (e.g.number->string,array->number) raisesPortCompatibilityError.ValueErrors if undeclared.2. Lossless Graph & Node JSON Round-Trip (#282)
GRAPH_SCHEMA_VERSION = "1.0".to_dict()andfrom_dict()acrossNodePort,NodeSchema,Node, andEdge.SimpleGraph.to_dict(),SimpleGraph.to_json(),SimpleGraph.from_dict(), andSimpleGraph.from_json().3. Custom Node SDK & Discoverability (#284)
Node, defineschema = NodeSchema(...), and register via@node_registry.register.@custom_node): Lightweight decorator turning Python functions into registeredNodeclasses with support for shorthand port specifications:[("text", "string")].NodeRegistry:@node_registry.registerdecorator syntax without arguments.unregister(node_type),has(node_type),get_schema(node_type), andclear().export_canvas_palette()for visual builder/ReactFlow interoperability.4. Documentation & Runnable Example (#284)
docs/custom_nodes.mddetailing architecture, port compatibility rules, schema definitions, and visual builder export.examples/custom_nodes_sdk.pyshowcasing an end-to-end pipeline with custom nodes, port validation, execution, and JSON round-tripping.test_custom_nodes_sdk_example_runs_in_cito guarantee example stability across releases.Verification & Testing
tests/test_nodes.py:test_port_type_compatibility_rules: Positive and negative port compatibility checks.test_edge_serialization_round_trip: Lossless Edge dictionary serialization.test_port_compatibility_validation_in_graph: CatchingPortCompatibilityErrorand undeclared port errors.test_graph_json_serialization_round_trip: Full graph JSON export, schema version checks, and reload.test_custom_node_subclass_and_registration: Custom class node lifecycle, canvas palette export, and execution.test_custom_node_decorator_and_round_trip: Functional@custom_nodewith custom registry and JSON round-trip.test_custom_node_pipeline_with_builtin_nodes: Composing custom nodes withRetrieverNodeandLLMNode.test_custom_nodes_sdk_example_runs_in_ci: Executingexamples/custom_nodes_sdk.py.pytest tests/test_nodes.py: 29 passed (100% offline, zero external dependencies).pytest tests/test_nodes.py tests/test_flow.py tests/test_agents.py tests/test_agent_state.py tests/test_checkpointer.py tests/test_supervisor.py tests/test_handoff.py: 68 passed.ruff check src benchmarks tests/test_nodes.py examples/custom_nodes_sdk.py: All checks passed.mypy src/dynavec/nodes tests/test_nodes.py: Success: no issues found in 7 source files.