Files
kandev/docs/plans/watch-task-cleanup/task-01-github-candidates.md
2026-09-23 13:31:12 +01:00

3.3 KiB

id, title, status, wave, depends_on, plan, requirements, acceptance_criteria, system_design
id title status wave depends_on plan requirements acceptance_criteria system_design
01-github-candidates Filter GitHub cleanup candidates done 1
plan.md
REQ-INTEGRATIONS-WATCH-CLEANUP-001
AC-INTEGRATIONS-WATCH-CLEANUP-001.1
AC-INTEGRATIONS-WATCH-CLEANUP-001.2
AC-INTEGRATIONS-WATCH-CLEANUP-001.3
AC-INTEGRATIONS-WATCH-CLEANUP-001.4
AC-INTEGRATIONS-WATCH-CLEANUP-001.5
../../specs/integrations/system-design/watch-task-cleanup.md

Task 01: Filter GitHub cleanup candidates

Summary

Filter GitHub cleanup candidates. Implement with TDD and record the regression results.

In scope

Add mixed-state regressions in store_task_cleanup_test.go and service_review_cleanup_test.go. Name the new tests TestCleanupCandidateListsExcludeHistoricalTasks and TestCleanupMergedReviewTasksSkipsHistoricalTasks. Cover by-watch, global, orphan, and workspace cleanup for reviews and issues. Assert zero upstream calls for archived and missing tasks. Cover terminal and nonterminal empty reservations, all policies, engagement, and lifecycle prompts.

Apply the candidate predicate to all four GitHub list methods. Preserve explicit watch deletion with unfiltered task-ID queries in service_reviews.go and service_issues.go. Add archived-child deletion assertions to existing watch deletion tests. Assert deduplication remains present through unfiltered lookups, not filtered cleanup queries.

Update obsolete missing-task cleanup expectations to zero provider calls and zero deletions. Keep task-not-found race coverage by deleting an initially eligible task after selection.

Out of scope

New policies, UI, schema migrations, and unrelated provider changes.

Acceptance

  • Mixed candidate lists and store-backed cleanup satisfy AC 001.1 through 001.4.
  • Explicit watch deletion, reset, scope, and deduplication satisfy AC 001.5.
  • Regression tests fail before the query changes and pass afterward.

Verification

Run from the repository root.

(cd apps/backend && go test ./internal/github -count=1)
git diff --check

Files likely touched

  • apps/backend/internal/github/store.go
  • apps/backend/internal/github/service_reviews.go
  • apps/backend/internal/github/service_issues.go
  • apps/backend/internal/github/store_task_cleanup_test.go
  • apps/backend/internal/github/service_review_cleanup_test.go
  • apps/backend/internal/github/service_cleanup_policy_test.go
  • apps/backend/internal/github/store_watch_reset_test.go
  • apps/backend/internal/github/store_watch_disable_test.go

Dependencies

None.

Risks

Preserve task inventory outside cleanup. Seed actual active tasks in fixtures.

Parallelism

sequential

Inputs

Results

Implemented the task eligibility predicate for all four GitHub cleanup list queries. Explicit watch deletion keeps its unfiltered task-ID inventory, so archived and missing task rows are preserved for deduplication while active tasks and empty reservations remain cleanup candidates. Added mixed-state store and service regressions, updated active-task fixtures, and retained a post-selection task-not-found race regression.

Verification: go test ./internal/github -count=1 passed.