[FIX#288] parsing_rules mutation→cache invalidate decorator - #292
Conversation
이슈 #288 의 audit 결과: 현재 mutation 호출처 (llmgen.Insert / refiner.UpdatePathPattern) 는 모두 명시적 Invalidate 호출하여 누락 없음. 본 PR 은 향후 mutation 추가 시 누락 가능성을 방어하기 위해 **decorator 패턴** 으로 mutation→invalidate 결합을 자동화. 변경 사항: 1. internal/processor/parser/rule/invalidating_repo.go (신규): - CacheInvalidator 인터페이스 (Resolver 가 구조적 타이핑으로 만족) - WrapWithInvalidator(inner, invalidator) — ParsingRuleRepository decorator - 정책: · Insert 성공 / ErrDuplicate → Invalidate (host, target_type) · Update 성공 → Invalidate · UpdatePathPattern 성공 → 사전 GetByID 로 host/type lookup → Invalidate · Delete → ID 만 받음 — 호출자 책임 (decorator 미강제) - nil invalidator 주입 시 wrapper 무동작 (graceful) - nil inner 시 panic (wiring 버그 즉시 노출) 2. cmd/issuetracker/main.go: parsingRuleRepo := pgstore.NewParsingRuleRepository(...) parsingRuleRepo = rule.WrapWithInvalidator(parsingRuleRepo, ruleResolver) 3. 기존 명시적 Invalidate 호출 정리 (decorator 책임 위임): - llmgen/generator.go: Insert ErrDuplicate / 성공 시 Invalidate 제거 (decorator 가 처리) - refiner/refiner.go: UpdatePathPattern 성공 후 Invalidate 제거 - generator.go:376 의 pre-check Invalidate 는 유지 — mutation 아닌 stale cache 감지 테스트 10건 (test/internal/processor/parser/rule/invalidating_repo_test.go): - Insert 성공/ErrDuplicate/일반에러 — 처음 두 건만 invalidate - Update 성공/실패 - UpdatePathPattern 성공 (사전 GetByID + invalidate) / update 실패 / pre-fetch 실패 - Delete (invalidate 미호출) - nil invalidator wrapping (no-op) - nil inner (panic) 비고: Negative cache TTL 단축 (이슈 #288 작업 #2) — 이미 30s 로 설정되어 있어 별도 변경 없음 (이슈 본문이 stale). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
To continue reviewing without waiting, purchase usage credits in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a decorator pattern for the ParsingRuleRepository to automate cache invalidation during data mutations, specifically for Insert, Update, and UpdatePathPattern operations. This change centralizes the invalidation logic and removes the need for manual cache management in the LLM generator and refiner components. Feedback from the reviewer suggests extending this automatic invalidation to the Delete method by performing a pre-lookup of the record to maintain cache consistency, along with updating the associated documentation and unit tests.
gemini-code-assist 3건 모두 동일 의도: Delete 가 decorator 의 invalidate 책임에서 빠지면 \"mutation 호출처 누락 방지\" 라는 본 PR 의 핵심 목적과 충돌. UpdatePathPattern 과 동일 패턴 (사전 GetByID + invalidate) 적용. 변경: - Delete: 사전 GetByID 로 host/type lookup → 성공 시 Invalidate (TTL fallback 보유) - GoDoc 갱신: Delete 정책을 \"호출자 책임\" → \"사전 lookup 후 자동 invalidate\" 로 정정 - 테스트 갱신: · TestInvalidatingRepo_Delete_NoInvalidate (이전) 제거 · TestInvalidatingRepo_Delete_Success_PrefetchesAndInvalidates 추가 · TestInvalidatingRepo_Delete_PrefetchFails_NoInvalidate 추가 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
연관 이슈
구현 내용
Audit 결과
이슈 #288 의 mutation 경로 audit 결과, 현재 모든 호출처가 명시적 Invalidate 를 정상 호출하여 누락 없음:
Insertllmgen/generator.go:470UpdatePathPatternrefiner/refiner.go:317Update/Delete본 PR 의 가치 — decorator 패턴 도입
현재는 누락 없으나, 향후 mutation 호출처 추가 시 invalidate 까먹을 가능성 이 systemic 위험. 본 PR 은
invalidatingRepodecorator 를 도입하여 mutation→invalidate 결합을 단일 책임 지점에 모음.변경 사항
신규:
internal/processor/parser/rule/invalidating_repo.goCacheInvalidator인터페이스 — Resolver 가 구조적 타이핑으로 만족WrapWithInvalidator(inner, invalidator)— Repository decoratorInsert성공 /ErrDuplicate→Invalidate(host, target_type)Update성공 →InvalidateUpdatePathPattern성공 → 사전GetByID로 host/type lookup →InvalidateDelete→ ID 만 받음, 호출자 책임 (decorator 미강제)Wiring:
cmd/issuetracker/main.go기존 명시적 Invalidate 호출 정리 (decorator 책임 위임):
llmgen/generator.go: Insert ErrDuplicate / 성공 시 Invalidate 제거refiner/refiner.go: UpdatePathPattern 성공 후 Invalidate 제거generator.go:376의 pre-check Invalidate 는 유지 — mutation 이 아닌 stale cache 감지 경로테스트 10건
test/internal/processor/parser/rule/invalidating_repo_test.go:비고
이슈 본문의 작업 #2 (Negative cache TTL 단축) —
DefaultNegativeCacheTTL이 이미 30s 로 설정되어 있어 별도 변경 없음 (이슈 본문이 stale).CI / 머지 게이트 점검
변경 영향 범위
internal/processor/parser/rule,internal/processor/parser/rule/{llmgen,refiner},cmd/issuetracker,test/...LowRequired Status Checks
Commit LintPR Title LintLinked Issue CheckBuildTestLint로컬 검증
make fmt통과make build5개 binary 모두 통과go test -race ./...전체 통과 (신규 10건)go vet ./...통과롤백 계획
🤖 Generated with Claude Code