Skip to content

[FIX#288] parsing_rules mutation→cache invalidate decorator - #292

Merged
juhy0987 merged 2 commits into
mainfrom
fix/#288/invalidating-repo
May 7, 2026
Merged

juhy0987 merged 2 commits into
mainfrom
fix/#288/invalidating-repo

Conversation

@juhy0987

@juhy0987 juhy0987 commented May 7, 2026

Copy link
Copy Markdown
Member

연관 이슈


구현 내용

Audit 결과

이슈 #288 의 mutation 경로 audit 결과, 현재 모든 호출처가 명시적 Invalidate 를 정상 호출하여 누락 없음:

Mutation 호출처 Invalidate 호출 상태
Insert llmgen/generator.go:470 line 480 (ErrDuplicate) + line 500 (성공)
UpdatePathPattern refiner/refiner.go:317 line 327
Update / Delete 호출처 없음 N/A

본 PR 의 가치 — decorator 패턴 도입

현재는 누락 없으나, 향후 mutation 호출처 추가 시 invalidate 까먹을 가능성 이 systemic 위험. 본 PR 은 invalidatingRepo decorator 를 도입하여 mutation→invalidate 결합을 단일 책임 지점에 모음.

변경 사항

신규: internal/processor/parser/rule/invalidating_repo.go

  • CacheInvalidator 인터페이스 — Resolver 가 구조적 타이핑으로 만족
  • WrapWithInvalidator(inner, invalidator) — Repository decorator
  • 정책:
    • Insert 성공 / ErrDuplicateInvalidate(host, target_type)
    • Update 성공 → Invalidate
    • UpdatePathPattern 성공 → 사전 GetByID 로 host/type lookup → Invalidate
    • Delete → ID 만 받음, 호출자 책임 (decorator 미강제)

Wiring: cmd/issuetracker/main.go

parsingRuleRepo := pgstore.NewParsingRuleRepository(pool, log)
parsingRuleRepo = rule.WrapWithInvalidator(parsingRuleRepo, ruleResolver)

기존 명시적 Invalidate 호출 정리 (decorator 책임 위임):

  • llmgen/generator.go: Insert ErrDuplicate / 성공 시 Invalidate 제거
  • refiner/refiner.go: UpdatePathPattern 성공 후 Invalidate 제거
  • 단, generator.go:376pre-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)

비고

이슈 본문의 작업 #2 (Negative cache TTL 단축) — DefaultNegativeCacheTTL 이 이미 30s 로 설정되어 있어 별도 변경 없음 (이슈 본문이 stale).


CI / 머지 게이트 점검

CI 운영 규약Required Status Checks 단일 소스에 따라 작성합니다.

변경 영향 범위

  • 영향 패키지: internal/processor/parser/rule, internal/processor/parser/rule/{llmgen,refiner}, cmd/issuetracker, test/...
  • 위험도: Low
    • 기존 명시적 Invalidate 호출은 decorator 가 동등하게 호출 (정상 흐름 보존)
    • decorator 미주입 시 inner repo 동작 동일 (graceful fallback)

Required Status Checks

  • 통과 확인 대상:
    • Commit Lint
    • PR Title Lint
    • Linked Issue Check
    • Build
    • Test
    • Lint

로컬 검증

  • make fmt 통과
  • make build 5개 binary 모두 통과
  • go test -race ./... 전체 통과 (신규 10건)
  • go vet ./... 통과

롤백 계획

  • decorator 미주입 시 inner repo 그대로 사용 — 기존 명시적 Invalidate 호출이 제거됐으므로 cache stale 위험 발생 가능. 롤백 시 explicit 호출 복원 필요 (또는 decorator wiring 만 토글)
  • 단순 revert 만으로 즉시 롤백 가능

🤖 Generated with Claude Code

이슈 #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>
Copilot AI review requested due to automatic review settings May 7, 2026 03:50
@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@juhy0987 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 7 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 975ba200-6b0c-4d4d-8401-0791d9e6ad1a

📥 Commits

Reviewing files that changed from the base of the PR and between b881d81 and 816b743.

📒 Files selected for processing (5)
  • cmd/issuetracker/main.go
  • internal/processor/parser/rule/invalidating_repo.go
  • internal/processor/parser/rule/llmgen/generator.go
  • internal/processor/parser/rule/refiner/refiner.go
  • test/internal/processor/parser/rule/invalidating_repo_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/#288/invalidating-repo

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@juhy0987 juhy0987 added the bug Something isn't working label May 7, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/processor/parser/rule/invalidating_repo.go Outdated
Comment thread internal/processor/parser/rule/invalidating_repo.go Outdated
Comment thread test/internal/processor/parser/rule/invalidating_repo_test.go Outdated
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@juhy0987 juhy0987 self-assigned this May 7, 2026
@juhy0987
juhy0987 merged commit 191ae5c into main May 7, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX] parsing_rules mutation 경로 cache invalidate audit + 누락 보강

2 participants