mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-09-19 02:56:17 +00:00
Four Protocols the domain declares and the outer ring will implement, plus the two DTOs that keep infrastructure types out of the inner ring: - ScheduledTaskRepository / ScheduledRunRepository, exchanging domain objects rather than the bare dicts the current repositories return - RunLauncher, whose contract is that only ThreadBusyError or LaunchFailedError may escape -- that translation is what keeps the run runtime and the web framework out of the domain - ThreadLookup, one method rather than the whole thread store - LaunchedRun and RunOutcome, so the completion path stops taking a runtime record the purity test would reject Two deliberate departures from the earlier sketch. There is no Clock port: `now` is already an explicit parameter throughout, so the domain never reads a clock and the tests are already deterministic -- adding one would only create a second source of truth for the same value. And `record_launch` is not expressed as `save(task)`, because `protect_terminal` makes it a compare-and-set against a concurrently finalizing run; a read-modify-write through the aggregate would reintroduce the race the flag exists to close. The in-memory doubles model the active-slot rule rather than skipping it: a double that never refuses a second active run would let the service's conflict collapse go untested. Their semantics are pinned by test_schedule_fakes.py, which becomes the contract suite once the SQL adapters land and both tiers run the same cases. Concurrency is out of scope for the doubles and says so in their module docstring -- it stays covered against a real database in test_scheduled_task_dispatch_race.py.