Repository navigation
[Refactor] 활성 루틴 요일 불변식을 한 곳으로 모은다 - #233
Merged
Merged
Conversation
"활성 루틴끼리 요일이 겹치면 안 된다"가 두 곳에 각자 구현돼 있었다. UseCase는 저장 전에 충돌 루틴을 찾아 교체를 묻고(RoutineSettingUseCase), 리포지토리는 저장 트랜잭션 안에서 마지막 방어선으로 다시 검사했다 (SwiftDataRoutineRepository). 지금은 두 구현의 동작이 같다. 확인해 봤다 — saveRoutine이 saveRoutines로 위임하므로 가드가 두 경로를 다 덮고, isEnabled도 isActive를 따라간다. 문제는 살아 있는 버그가 아니라 드리프트다. 한쪽만 고치면 UI는 통과시키는데 저장이 throw하는 상태가 되고, 사용자에게는 저장 버튼이 말없이 안 먹는 것으로 보인다. 원인을 찾기도 어렵다. ActiveRoutineWeekdayPolicy에 판단 기준 하나를 두고 둘 다 위임한다. 두 호출자가 묻는 질문이 다르므로(UseCase는 "누구와 겹치나" — 교체 대상을 보여줘야 하니 ID가 필요하고, 리포지토리는 "겹치는 게 있나") 함수는 둘이되 기준은 하나다. 저장 트랜잭션 자체는 리포지토리에 남는다. 옮긴 것은 정책뿐이라 저장소를 띄우지 않고 규칙을 검증할 수 있게 됐고, 그래서 "두 질문이 같은 답을 낸다"를 테스트로 고정할 수 있었다. Co-Authored-By: Claude <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Comment |
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✨ PR 유형
어떤 변경 사항이 있나요??
스택 PR 1/5 · base:
main🛠️ 작업내용
[Refactor] 활성 루틴 요일 불변식을 한 곳으로 모은다
"활성 루틴끼리 요일이 겹치면 안 된다"가 두 곳에 각자 구현돼 있었다.
UseCase는 저장 전에 충돌 루틴을 찾아 교체를 묻고(RoutineSettingUseCase),
리포지토리는 저장 트랜잭션 안에서 마지막 방어선으로 다시 검사했다
(SwiftDataRoutineRepository).
지금은 두 구현의 동작이 같다. 확인해 봤다 — saveRoutine이 saveRoutines로
위임하므로 가드가 두 경로를 다 덮고, isEnabled도 isActive를 따라간다.
문제는 살아 있는 버그가 아니라 드리프트다. 한쪽만 고치면 UI는 통과시키는데
저장이 throw하는 상태가 되고, 사용자에게는 저장 버튼이 말없이 안 먹는 것으로
보인다. 원인을 찾기도 어렵다.
ActiveRoutineWeekdayPolicy에 판단 기준 하나를 두고 둘 다 위임한다. 두 호출자가
묻는 질문이 다르므로(UseCase는 "누구와 겹치나" — 교체 대상을 보여줘야 하니 ID가
필요하고, 리포지토리는 "겹치는 게 있나") 함수는 둘이되 기준은 하나다.
저장 트랜잭션 자체는 리포지토리에 남는다. 옮긴 것은 정책뿐이라 저장소를 띄우지
않고 규칙을 검증할 수 있게 됐고, 그래서 "두 질문이 같은 답을 낸다"를 테스트로
고정할 수 있었다.
Co-Authored-By: Claude noreply@anthropic.com
규모 — 5 files changed, 212 insertions(+), 20 deletions(-)
📋 추후 진행 상황
감사 문서 #4의 나머지 — 도메인 정책이 Data 리포지토리 안에 사는 문제. 같은 불변식의 이중 구현은 이걸로 끝났고, 남은 것은
SwiftDataRoutineRepository의 165줄 intent 파생이다.📌 리뷰 포인트
저장 트랜잭션을 옮기지 않은 것이 의도입니다. 리포지토리의 단일 트랜잭션 요구가 정당한 근거라서, 정책만 빼고 트랜잭션은 남겼습니다.
지금 두 구현이 실제로 갈라져 있지는 않았습니다 —
saveRoutine이saveRoutines로 위임해 가드가 두 경로를 다 덮고,isEnabled도isActive를 따라갑니다. 살아 있는 버그가 아니라 드리프트 위험을 막는 변경입니다.✅ Checklist
검증: 시뮬레이터 smoke 1,067개 통과(실패 0, 실기기 전용 3건 skip). 정적 게이트 3종 통과.
앞 PR이 머지되면 이 PR의 base는 자동으로
main이 된다. 순서대로 머지한다.🤖 Generated with Claude Code