mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-09-19 02:56:17 +00:00
Replaces the pre-hexagonal scheduled-task implementation with a slice built to the layering spec: a pure domain (two aggregates, two state machines, the policy value object), output ports it declares itself, SQL/launcher/thread adapters implementing them under `app/adapters/`, and a composition root that is the one place any of them is instantiated. The old implementation mixed all of that into `app/scheduler/service.py` and a router that reached straight into repositories, so the rules that matter -- overlap policy, lease handling, which write owns which timestamp -- were only reachable through a live database. They are now unit-assertable on in-memory fakes, with the contract suite running each port against both the fake and real sqlite, and the concurrency invariants pinned by dedicated race tests. Two bugs the old shape hid are fixed on the way: a completion hook that replayed a stale snapshot and rolled back the launch write, and a corrupt stored row surfacing to the client as a 4xx. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
84 lines
2.0 KiB
Python
84 lines
2.0 KiB
Python
"""Schedule bounded context: standing instructions to run a prompt on time.
|
|
|
|
Public API of the context. Import domain objects, commands, errors, and the
|
|
service from here; import ports from `deerflow.domain.schedule.ports` -- they
|
|
are contracts consumed by adapters and tests, not everyday call-site symbols.
|
|
"""
|
|
|
|
from deerflow.domain.schedule.commands import (
|
|
UNSET,
|
|
ContextChange,
|
|
CreateScheduledTask,
|
|
DeleteTask,
|
|
PauseTask,
|
|
ResumeTask,
|
|
TriggerTask,
|
|
UnsetType,
|
|
UpdateScheduledTask,
|
|
)
|
|
from deerflow.domain.schedule.exceptions import (
|
|
ActiveRunConflictError,
|
|
CorruptStoredScheduleError,
|
|
InvalidContextModeError,
|
|
InvalidScheduleError,
|
|
LaunchFailedError,
|
|
ScheduleError,
|
|
TaskNotFoundError,
|
|
TaskNotMutableError,
|
|
ThreadBusyError,
|
|
ThreadNotFoundError,
|
|
)
|
|
from deerflow.domain.schedule.model import (
|
|
ACTIVE_RUN_STATUSES,
|
|
TERMINAL_RUN_STATUSES,
|
|
TERMINAL_TASK_STATUSES,
|
|
ContextMode,
|
|
DispatchOutcome,
|
|
RunStatus,
|
|
ScheduledRun,
|
|
ScheduledTask,
|
|
SchedulePolicy,
|
|
ScheduleSpec,
|
|
ScheduleType,
|
|
TaskStatus,
|
|
TriggerKind,
|
|
)
|
|
from deerflow.domain.schedule.service import DispatchResult, ScheduleService
|
|
|
|
__all__ = [
|
|
"ACTIVE_RUN_STATUSES",
|
|
"TERMINAL_RUN_STATUSES",
|
|
"TERMINAL_TASK_STATUSES",
|
|
"UNSET",
|
|
"ActiveRunConflictError",
|
|
"ContextChange",
|
|
"ContextMode",
|
|
"CorruptStoredScheduleError",
|
|
"CreateScheduledTask",
|
|
"DeleteTask",
|
|
"DispatchOutcome",
|
|
"DispatchResult",
|
|
"InvalidContextModeError",
|
|
"InvalidScheduleError",
|
|
"LaunchFailedError",
|
|
"PauseTask",
|
|
"ResumeTask",
|
|
"RunStatus",
|
|
"ScheduleError",
|
|
"SchedulePolicy",
|
|
"ScheduleService",
|
|
"ScheduleSpec",
|
|
"ScheduleType",
|
|
"ScheduledRun",
|
|
"ScheduledTask",
|
|
"TaskNotFoundError",
|
|
"TaskNotMutableError",
|
|
"TaskStatus",
|
|
"ThreadBusyError",
|
|
"ThreadNotFoundError",
|
|
"TriggerKind",
|
|
"TriggerTask",
|
|
"UnsetType",
|
|
"UpdateScheduledTask",
|
|
]
|