mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-09-19 02:56:17 +00:00
The input port of the context: every scheduled-task use case, orchestrated over the four output ports. It holds no business rules -- each decision is delegated to the aggregate -- and `test_schedule_service.py` runs the complete lifecycle with no HTTP, no database and no run runtime, which is the acceptance criterion this migration was for. `dispatch_task` mirrors the pre-migration structure line for line, including its comments, and makes exactly three substitutions: bare dicts become domain objects, the HTTPException-409 sniffing becomes `except ThreadBusyError`, and the status-derivation static methods become aggregate methods. Its four exits and their two conflict paths are unchanged, and the tests pin the collapse: the fast-path rejection and the active-slot rejection must produce identical results, asserted over every field of DispatchResult. One behavioural narrowing, deliberate. The old code wrapped the launch *and* its follow-up writes in `except Exception`, so a failing bookkeeping write was recorded as a failed launch -- marking an execution that had actually started as failed. The port contract admits exactly two escapes from `launch`, so only the launch is guarded now and a genuine write fault propagates instead of being misreported. SchedulePolicy gains max_concurrent_runs and lease_seconds. Both are operator-tunable thresholds the domain needs but must not read, which is what that value object is for; the claiming process's identity stays a constructor argument since it is an identity, not a threshold.