feat(habit): add recurring domain and immutable history - #37
Conversation
|
Warning Review limit reached
Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthrough반복 습관 도메인 모델과 발생일 계산을 추가했습니다. Changes반복 습관 도메인
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant HabitService
participant InMemoryHabitRepository
Client->>HabitService: completeHabit 요청
HabitService->>InMemoryHabitRepository: 습관 및 예약일 확인
HabitService->>InMemoryHabitRepository: 완료 이벤트 저장
InMemoryHabitRepository-->>HabitService: 기존 또는 신규 이벤트 반환
HabitService-->>Client: 완료 이벤트 반환
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (1)
apps/habit-service/migrations/0001_recurring_habit_core.sql (1)
74-81: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win
listCompletions정렬용 인덱스를 추가하세요.
apps/habit-service/src/habit-domain.ts:262-332의listCompletions는(recordedAt, id)순서로 결과를 반환합니다. 현재 인덱스는scheduled_local_date를 먼저 포함합니다. 날짜 조건이 없으면 PostgreSQL 구현은 해당 정렬을 인덱스만으로 처리할 수 없습니다.(workspace_id, habit_id, recorded_at, id)인덱스를 추가하고 일정 조회 인덱스는 유지하세요.제안된 수정
CREATE INDEX completion_events_workspace_habit_schedule_idx ON habit.completion_events ( workspace_id, habit_id, scheduled_local_date ASC, recorded_at ASC, id ASC ); + +CREATE INDEX completion_events_workspace_habit_recorded_idx + ON habit.completion_events ( + workspace_id, + habit_id, + recorded_at ASC, + id ASC + );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/habit-service/migrations/0001_recurring_habit_core.sql` around lines 74 - 81, Update the migration near completion_events_workspace_habit_schedule_idx to add a separate index on completion_events using workspace_id, habit_id, recorded_at ASC, and id ASC for listCompletions ordering. Keep the existing schedule-date index unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 52-58: Remove the write-enabled Prettier invocation from the
“Render habit test formatting diff” workflow step, or restore
apps/habit-service/src/habit-domain.test.ts to its original state before the
“Check formatting” step runs, so pnpm format:check validates the unmodified
file.
In `@apps/habit-service/migrations/0001_recurring_habit_core.sql`:
- Around line 94-97: Update the completion_events append-only protection by
adding a separate BEFORE TRUNCATE FOR EACH STATEMENT trigger on
habit.completion_events, using the existing rejection function or equivalent
statement-level handler. Keep the UPDATE/DELETE trigger intact and ensure the
service role is not granted TRUNCATE permission.
In `@apps/habit-service/src/habit-domain.ts`:
- Around line 71-77: Update requireOpaqueId and the composite-key construction
in entityLookupKey and appendCompletion’s idempotencyLookup to use
delimiter-safe encoding before joining workspaceId, habitId, or entity IDs.
Ensure distinct component combinations always produce distinct keys while
preserving existing validation and lookup behavior.
- Around line 293-314: Update appendCompletion to compare a replayed
completion’s payload with the existing record found through
completionIdempotency, including scheduledLocalDate and completedAt (and any
other persisted completion fields that define the payload). Return the cloned
existing record only when the payload matches; otherwise throw an error for
idempotency-key reuse with conflicting data, while preserving the existing
inconsistency error.
---
Nitpick comments:
In `@apps/habit-service/migrations/0001_recurring_habit_core.sql`:
- Around line 74-81: Update the migration near
completion_events_workspace_habit_schedule_idx to add a separate index on
completion_events using workspace_id, habit_id, recorded_at ASC, and id ASC for
listCompletions ordering. Keep the existing schedule-date index unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4f5b7b8f-bf34-4d24-b188-2162d0de1865
📒 Files selected for processing (7)
.github/workflows/ci.ymlapps/habit-service/migrations/0001_recurring_habit_core.sqlapps/habit-service/migrations/README.mdapps/habit-service/src/habit-domain.test.tsapps/habit-service/src/habit-domain.tsdocs/superpowers/plans/2026-08-04-habit-recurring-domain-slice.mdpackage.json
Summary
Implements the first reviewable slice of #36.
Deferred
The parameterized PostgreSQL repository, pooled integration tests, validated runtime, NestJS HTTP surface, pause/archive workflows, streak projections, reminders, and controlled data-rights erasure remain separate reviewable slices.
Validation gate
Merge only when CI, AppGuardrail, Semgrep, Security Scan, Commercial Readiness, CodeRabbit, and all human/security review requirements pass on the exact head with no unresolved actionable findings.
Refs #36
Summary by CodeRabbit
새 기능
문서
테스트