refactor(runtime): add run DDD boundary skeleton#3331
Open
rayhpeng wants to merge 2 commits into
Open
Conversation
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.
背景
这是 Run Runtime DDD 重构的第一步。本 PR 先建立
deerflow.runtime.runs内部的分层结构和领域模型骨架,为后续拆分 Application、Repository、Stream、Execution 以及移动 app infrastructure 实现做准备。本 PR 不迁移 SQL、Gateway 装配或现有 API 行为。
修改内容
新增
deerflow.runtime.runs.domainRun聚合根。RunStatus、DisconnectMode、RunScope、EventSeq等领域值对象。RunCreated、RunStarted、RunCompleted、RunFailed、RunCancelled等领域事件。InvalidRunTransition,显式约束 Run 状态流转。新增 DDD 分层骨架
application/:命令、查询、DTO、RunsApplicationService边界。repositories/:RunRepository、RunEventLog协议。streams/:RunStreamBroker协议。execution/:RunExecutionScheduler、RunSupervisor、RunExecutor协议。保持兼容导出
runtime/runs/schemas.py继续导出RunStatus和DisconnectMode,但来源切换为 domain。runtime/runs/__init__.py增加新的 domain 类型导出。RunManager、RunRecord、run_agent路径保持不变。新增领域测试
pending -> running -> success状态流转。EventSeq和空 ID 校验。不包含
deerflow.persistence中的 SQL 实现。RunManager执行路径。stream_bridge到RunStreamBroker,只先定义新协议边界。验证
已通过:
uv run ruff check packages/harness/deerflow/runtime/runs tests/test_run_domain.pyuv run pytest tests/test_run_domain.py tests/test_run_manager.pygit diff --check结果:
51 passed。