-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
RepoDiffer currently mixes multiple concerns in one type:
- domain diff logic
- Azure DevOps provider calls
- Tokio worker orchestration (
mpsc, interval, retry) - cache/state ownership
- notification side effects
This creates tight coupling between domain logic and provider/runtime details, and makes it harder to evolve pull request monitoring toward the same hexagonal structure used by time tracking.
Goal
Refactor PR monitoring so business logic is provider-agnostic and runtime/provider specifics are isolated in adapters.
Proposed architecture
Inbound ports (use-cases)
PullRequestMonitorServicestart(repo_key, interval)stop(repo_key)force_update(repo_key)get_status(repo_key)/list_statuses()
PullRequestReadServiceget_cached_repo_pull_requests(repo_key)get_followed_pull_requests(user_id)get_most_recent_commits(repo_key)
Outbound ports
PullRequestProvider- fetch open PRs + required details (threads, commits, work items, identities)
PullRequestCache- read/write snapshots, identities cache, monitor status, timestamps
PullRequestNotifier- publish PR change events / notify affected users
Domain services
PullRequestPollingServiceImpl- orchestrates provider fetch -> diff -> cache update -> notify
PullRequestDiffEngine- pure PR snapshot diffing (testable, provider-independent)
Adapter boundaries
adapters/outbound/azure_devops/*implementsPullRequestProvider- cache adapter in
adapters/outbound/{postgres|memory}implementsPullRequestCache - notification adapter wraps existing notification flow behind
PullRequestNotifier - background worker (
tokio::spawn, channels, retry policy) moved to an inbound/background adapter; domain service does not ownmpsc/interval loop.
Migration plan (incremental)
- Add PR ports + domain service interfaces (no behavior change yet).
- Extract diff logic from
RepoDiffer::tickintoPullRequestDiffEngine. - Introduce
PullRequestProviderAzure adapter. - Introduce
PullRequestCacheadapter (memory first to preserve current behavior). - Add background worker adapter and route
/differsendpoints throughPullRequestMonitorService. - Migrate pull request read endpoints (and work-item PR enrichment usage) to
PullRequestReadService. - Remove legacy
RepoDifferruntime maps/channels fromAppState.
Acceptance criteria
- Domain PR monitoring logic no longer imports
az_devops::*or Tokio channel/runtime primitives. RepoDifferis removed or reduced to adapter-level code.- Routes depend on inbound service traits rather than direct
AppStateinternals. - Existing behavior preserved:
- start/stop/force differ actions
- cached PR reads
- change notifications
- PR monitoring is structured for additional SCM providers without modifying domain services.
Out of scope
- Full multi-provider implementation in this issue (only architecture + Azure adapter migration).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request