Skip to content

feat(dynaflow): typed node schema, graph serialization & custom node SDK (#282, #284) - #354

Merged
Kaap10 merged 1 commit into
codeforstartups:developmentfrom
shivamm-gupta:issue-282-284-typed-nodes-sdk
Nov 15, 2026
Merged

Kaap10 merged 1 commit into
codeforstartups:developmentfrom
shivamm-gupta:issue-282-284-typed-nodes-sdk

Conversation

@shivamm-gupta

Copy link
Copy Markdown
Collaborator

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)

  • Added PortCompatibilityError (inheriting from TypeError and ValueError) and is_port_type_compatible(source_type, target_type).
  • Validates edge connections in SimpleGraph.add_edge(...) and SimpleGraph.validate().
  • Supports symmetric "any" wildcard ports, identical type matches, and JSON string ⇄ object deserialization bridges. Connecting incompatible ports (e.g. number -> string, array -> number) raises PortCompatibilityError.
  • Validates that connected port names exist on node schemas, raising clear descriptive ValueErrors if undeclared.

2. Lossless Graph & Node JSON Round-Trip (#282)

  • Added GRAPH_SCHEMA_VERSION = "1.0".
  • Implemented to_dict() and from_dict() across NodePort, NodeSchema, Node, and Edge.
  • Implemented SimpleGraph.to_dict(), SimpleGraph.to_json(), SimpleGraph.from_dict(), and SimpleGraph.from_json().
  • Validates graph schema version and unregistered node types during deserialization.
  • Reconstructs node instances, port connections, custom configurations, and execution orders from JSON.

3. Custom Node SDK & Discoverability (#284)

  • Class-Based Subclassing: Users can inherit from Node, define schema = NodeSchema(...), and register via @node_registry.register.
  • Functional Decorator (@custom_node): Lightweight decorator turning Python functions into registered Node classes with support for shorthand port specifications: [("text", "string")].
  • Enhanced NodeRegistry:
    • Added support for @node_registry.register decorator syntax without arguments.
    • Added unregister(node_type), has(node_type), get_schema(node_type), and clear().
    • Registered custom nodes are automatically discovered in export_canvas_palette() for visual builder/ReactFlow interoperability.

4. Documentation & Runnable Example (#284)

  • Created docs/custom_nodes.md detailing architecture, port compatibility rules, schema definitions, and visual builder export.
  • Created examples/custom_nodes_sdk.py showcasing an end-to-end pipeline with custom nodes, port validation, execution, and JSON round-tripping.
  • Added CI test test_custom_nodes_sdk_example_runs_in_ci to guarantee example stability across releases.

Verification & Testing

  • Added 8 unit tests in 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: Catching PortCompatibilityError and 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_node with custom registry and JSON round-trip.
    • test_custom_node_pipeline_with_builtin_nodes: Composing custom nodes with RetrieverNode and LLMNode.
    • test_custom_nodes_sdk_example_runs_in_ci: Executing examples/custom_nodes_sdk.py.
  • Suite results:
    • 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.

…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

@Kaap10 Kaap10 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Excellent implementation of typed node schemas, port compatibility validation, lossless graph JSON serialization, and the custom node SDK (#282, #284). All flow tests, examples, linter, and type checks pass cleanly.

@Kaap10
Kaap10 merged commit abe2955 into codeforstartups:development Nov 15, 2026
4 checks passed
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.

Custom nodes via the SDK Typed node system / node schema (ReactFlow-compatible)

2 participants