Skip to content

Conversation

@BeautyyuYanli
Copy link
Contributor

@BeautyyuYanli BeautyyuYanli commented Jan 29, 2026

Context

Part of #31680 (A2 stage: workflow engine & nodes).

What this PR does

Unblocks running ty on the workflow engine/nodes layer by tightening types, improving narrowing, and removing a few cross-layer import/typing issues.

Key changes:

  • Typed workflow node config

    • Introduces core.workflow.entities.graph_config with NodeConfigDict + NodeConfigDictAdapter.
    • Updates workflow graph parsing (core.workflow.graph.graph.Graph) to validate node configs via Pydantic TypeAdapter and use typed indexing.
    • Updates Workflow.get_node_config_by_id() and workflow entry code to use the typed node config.
  • Protocol-friendly dependency injection for HTTP request node

    • Adds thin adapters:
      • core.helper.ssrf_proxy.SSRFProxy implementing HttpClientProtocol
      • core.file.file_manager.FileManager implementing FileManagerProtocol
    • Updates HttpRequestNode / executor and DifyNodeFactory to accept optional injected deps with safe defaults (no behavioral change intended).
  • Type/narrowing cleanups inside workflow code

    • Reduces cast() usage where types are already structurally guaranteed.
    • Improves runtime narrowing (isinstance) and a few small typing fixes in nodes (e.g. LLM prompt content handling, list operator file field extraction, datasource type conversion).
  • Tooling

    • Bumps ty to >=0.0.14 and updates ty.toml rules/excludes for this stage.

Why

The workflow codebase has import-linter enforced layering, including that core.workflow.nodes.* must not import core.workflow.graph.*.

During the A2 work, models/workflow.py importing node-config typing from core.workflow.graph.graph created an indirect dependency chain that broke the rule once graph parsing started depending on node-typed configs.

Moving the shared node-config TypedDict into core.workflow.entities keeps the architecture boundary intact while still allowing Graph/Workflow/factories to share the same validated config shape.

Testing

  • uv run --directory api --dev ty check
  • uv run --directory api --dev lint-imports

@gemini-code-assist

This comment was marked as outdated.

@BeautyyuYanli BeautyyuYanli changed the title refactor(typing): A1 - runtime typing for core contracts refactor(typing): Fixup typing A2 - workflow engine & nodes Jan 29, 2026
gemini-code-assist[bot]

This comment was marked as off-topic.

BeautyyuYanli and others added 3 commits January 30, 2026 02:44
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@BeautyyuYanli BeautyyuYanli marked this pull request as ready for review January 29, 2026 20:05
Copilot AI review requested due to automatic review settings January 29, 2026 20:05
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. 🌊 feat:workflow Workflow related stuff. labels Jan 29, 2026

This comment was marked as off-topic.

@asukaminato0721
Copy link
Contributor

@BeautyyuYanli
Copy link
Contributor Author

https://typing.python.org/en/latest/spec/callables.html#unpack-kwargs

Thx. Any is enough in this case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌊 feat:workflow Workflow related stuff. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants