refactor(schedule): group the adapters by context, not by technology

The inner ring is organised per bounded context; the outer ring was not,
so this context's adapters were split across app/infra/persistence/ and
app/infra/schedule/ with no principle separating them — one held the SQL
repositories, the other held the mapping they both consume, purely
because of what technology each touched.

Everything the outer ring provides to the schedule context now lives in
app/infra/schedule/, mirroring domain/schedule/. That also gives the two
remaining adapters an obvious home: the run launcher and the thread
lookup are neither persistence nor mapping, and would have needed a
third rule under the old layout.

Files are moved with git mv so history follows them. app/infra/
persistence/feedback.py stays where it is: it belongs to a separate
migration and moving it here would put that work in this diff. The
package docstring records the asymmetry rather than leaving it to be
rediscovered.
This commit is contained in:
rayhpeng 2026-07-28 14:55:29 +08:00
parent d4c24e3f6f
commit 9a724edcce
4 changed files with 14 additions and 3 deletions

View File

@ -1 +1,10 @@
"""Secondary adapters for the schedule bounded context."""
"""Secondary adapters for the schedule bounded context.
Grouped by context rather than by technology, mirroring `domain/schedule/`:
everything the outer ring provides to this one context lives here, whether it
talks to SQL (`task_sql`, `run_sql`), converts a wire/storage shape
(`spec_mapping`), or wraps a runtime.
`app/infra/persistence/feedback.py` still follows the older technology-first
layout because it belongs to a separate migration; the two will converge.
"""

View File

@ -1,5 +1,7 @@
"""SQL adapter for the schedule context's task repository.
Sibling of `run_sql.py`; both consume `spec_mapping` for the stored JSON spec.
Secondary adapter implementing `ScheduledTaskRepository`. SQL/ORM vocabulary
stops at this file: methods exchange domain objects and normalize SQLite's
tz-naive reads.

View File

@ -28,8 +28,8 @@ from schedule_fakes import (
InMemoryScheduledTaskRepository,
)
from app.infra.persistence.scheduled_task_runs import SqlScheduledRunRepository
from app.infra.persistence.scheduled_tasks import SqlScheduledTaskRepository
from app.infra.schedule.run_sql import SqlScheduledRunRepository
from app.infra.schedule.task_sql import SqlScheduledTaskRepository
from deerflow.config.database_config import DatabaseConfig
from deerflow.domain.schedule.model import (
ACTIVE_RUN_STATUSES,