[REFAC#417] fetcher/parser/validate stage 패키지 구조 정합화 - #418
Conversation
세 stage 의 비일관 구조 → canonical 패턴 정합:
<stage>/
stage.go # Stage adapter (top-level)
worker/ # worker pool 구현 + 부속 helpers
types/ # 도메인 인터페이스 + 결과 타입 (cyclic-free leaf)
<domain>|<rule>/ # 도메인 / rule engine
## Phase A — validate worker 서브디렉토리화
이동 (모두 package validate → worker):
- validate/worker.go → validate/worker/worker.go
- validate/validator.go → validate/worker/validator.go
- validate/reparse.go → validate/worker/reparse.go
validate 부모 패키지에는 stage.go 만 잔존 — Stage 가 *worker.Worker 보유.
stageName 상수 → worker.StageName (exported) — stage.go 와 worker.go 가 공유.
## Phase B — parser/stage 평탄화
- parser/stage/stage.go → parser/stage.go (top-level, package parser)
- cyclic 회피: parser 부모가 더 이상 rule/* 를 import 해도 사이클 없음 (interfaces 가 types/ 로 이동 후)
## Phase C — parser 인터페이스 진입점
- parser/parser.go → parser/types/types.go (package types)
- 외부 호출자 4 파일 갱신 (parser/rule/parser.go / discovery.go, parser/worker/parser_worker.go, fetcher/domain/general/convert.go)
- parser.Page / LinkItem / ContentParser / LinkListParser → types.X 일괄 치환
## cmd / test 갱신
- cmd/issuetracker: parserStage import 제거 + parser.NewStage 직접 호출 / validateWorkerPkg alias 추가
- cmd/processor: validateWorker import alias 도입 + worker.NewWorker 호출
- test/internal/processor/validate/{worker_test, reparse_test, processor_test}.go → worker/ 서브디렉토리 이동, package worker_test
- 신규 helpers_test.go — newNewsContent / newCommunityContent fixture 복사 (sub-package 분리로 cross-package 접근 불가)
## fetcher 예외
fetcher/core/ 는 http_client / retry / errors 등 helpers 다중 책임 보유 — types/ 로 단순 축소
불가. 의도된 foundation 패키지로 잔존. canonical 패턴의 stage.go / worker/ 부분은 일치.
## 도달 상태
| stage | stage.go | worker/ | types/ |
|---|---|---|---|
| fetcher | ✓ top | ✓ | core/ (확장 foundation) |
| parser | ✓ top (flatten) | ✓ | ✓ types/ (interfaces) |
| validate | ✓ top | ✓ (new) | ✓ types/ (interfaces) |
## 검증
- go build ./internal/... ./cmd/... ./test/... ./pkg/... ./examples/... — pass
- go test -race -count=1 -timeout=180s ./test/... — 전 패키지 통과 (회귀 0)
- gofmt clean
- 라이브 동작 영향 0 — 순수 패키지 위치 / import 경로 변경
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more 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 (6)
📝 WalkthroughWalkthroughParser types move to ChangesParser and Validate Package Restructuring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/processor/validate/worker/validator.go (1)
1-6:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUpdate package comment to match the actual package name.
The package comment on line 1 still says "Package validate" but the package declaration is
worker. This creates documentation inconsistency in godoc.📝 Proposed fix
-// Package validate 는 Content 검증 처리 단계를 구현합니다. +// Package worker 는 Content 검증 처리 단계를 구현합니다. // -// Package validate implements the content validation stage of the processing pipeline. +// Package worker implements the content validation stage of the processing pipeline. // It dispatches to source-type-specific validators (news, community) via NewValidator. // Worker 가 Validator 결과를 직접 사용 — 별도 ContentProcessor 어댑터 없음. package worker🤖 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 `@internal/processor/validate/worker/validator.go` around lines 1 - 6, Update the top-of-file package comment in validator.go so it matches the declared package name `worker` (e.g., begin the doc comment with "Package worker ..." instead of "Package validate"), keeping the existing descriptive text (Korean/English) intact and formatted as a proper package comment for godoc.
🧹 Nitpick comments (1)
test/internal/processor/validate/worker/helpers_test.go (1)
29-29: ⚡ Quick winConsider using fixed timestamps in test fixtures for determinism.
Both
newNewsContent()andnewCommunityContent()usetime.Now()to generatePublishedAtvalues. This introduces non-determinism that could lead to flaky tests, especially for time-sensitive validations.For better test reproducibility, consider using a fixed timestamp like
time.Date(2024, 1, 1, 12, 0, 0, 0, time.UTC).🕒 Suggested improvement
+var testPublishedAt = time.Date(2024, 1, 1, 12, 0, 0, 0, time.UTC) + func newNewsContent() *core.Content { return &core.Content{ ID: "content-001", ... - PublishedAt: time.Now(), + PublishedAt: testPublishedAt, ... } } func newCommunityContent() *core.Content { return &core.Content{ ID: "content-002", ... - PublishedAt: time.Now(), + PublishedAt: testPublishedAt, ... } }Also applies to: 47-47
🤖 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 `@test/internal/processor/validate/worker/helpers_test.go` at line 29, Replace non-deterministic time.Now() usage in the test fixtures by setting PublishedAt to a fixed timestamp to avoid flaky tests: update the functions newNewsContent and newCommunityContent to use a constant like time.Date(2024, 1, 1, 12, 0, 0, 0, time.UTC) for the PublishedAt field (instead of time.Now()) so tests are deterministic and reproducible.
🤖 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.
Outside diff comments:
In `@internal/processor/validate/worker/validator.go`:
- Around line 1-6: Update the top-of-file package comment in validator.go so it
matches the declared package name `worker` (e.g., begin the doc comment with
"Package worker ..." instead of "Package validate"), keeping the existing
descriptive text (Korean/English) intact and formatted as a proper package
comment for godoc.
---
Nitpick comments:
In `@test/internal/processor/validate/worker/helpers_test.go`:
- Line 29: Replace non-deterministic time.Now() usage in the test fixtures by
setting PublishedAt to a fixed timestamp to avoid flaky tests: update the
functions newNewsContent and newCommunityContent to use a constant like
time.Date(2024, 1, 1, 12, 0, 0, 0, time.UTC) for the PublishedAt field (instead
of time.Now()) so tests are deterministic and reproducible.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 80915296-284e-4cd7-b200-9d1bf43583b2
📒 Files selected for processing (16)
cmd/issuetracker/main.gocmd/processor/main.gointernal/processor/fetcher/domain/general/convert.gointernal/processor/parser/rule/discovery.gointernal/processor/parser/rule/parser.gointernal/processor/parser/stage.gointernal/processor/parser/types/types.gointernal/processor/parser/worker/parser_worker.gointernal/processor/validate/stage.gointernal/processor/validate/worker/reparse.gointernal/processor/validate/worker/validator.gointernal/processor/validate/worker/worker.gotest/internal/processor/validate/worker/helpers_test.gotest/internal/processor/validate/worker/processor_test.gotest/internal/processor/validate/worker/reparse_test.gotest/internal/processor/validate/worker/worker_test.go
There was a problem hiding this comment.
Code Review
This pull request refactors the parser and validate packages to resolve circular dependencies and improve project structure. Key changes include moving core interfaces and models to new types sub-packages and relocating worker logic to worker sub-packages. Additionally, test fixtures were consolidated within the worker test package to maintain accessibility while avoiding code duplication. The reviewer suggested consolidating test helper functions within the same package to improve reusability, which is a sound recommendation for Go testing patterns.
…성 (CodeRabbit) CodeRabbit 피드백 2건: 1. validator.go 의 \"// Package validate\" 주석이 실제 \"package worker\" 선언과 불일치 → godoc 표시 일관성을 위해 \"// Package worker\" 로 정정. 2. helpers_test.go 의 newNewsContent / newCommunityContent 가 time.Now() 사용 — 시간-민감한 validation 분기에서 flaky test 위험. 공유 fixed timestamp (2024-01-01T12:00:00Z) 로 변경. gemini 피드백 (helpers_test 위치) 는 이미 same-package *_test.go 패턴 적용 중 — 별도 testutil 패키지 아님. validate_test (parent) 와의 cross-package 중복은 Go 패키지 경계상 testutil 없이는 불가피. 본 PR scope 외 — 추후 community/news 테스트 재배치 시 추가 정리 가능. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
테스트 디렉토리 구조 규칙 (.claude/rules/05-testing.md) 일관성 — 소스가 sub-package 면 테스트도 동일 sub-package 미러: - test/internal/processor/validate/community_validator_test.go → test/internal/processor/validate/community/validator_test.go (package community_test) - test/internal/processor/validate/news_validator_test.go → test/internal/processor/validate/news/validator_test.go (package news_test) 각 sub-validator 테스트가 자기 패키지의 leaf test 로 위치 — 부모 validate_test 패키지가 더 이상 sub-validator 직접 테스트 보유 안 함. 신규 sub-validator 추가 시 자연스럽게 \`<sub>/validator_test.go\` 패턴 적용. 각 테스트는 자체 helper (newCommunityContent / newNewsContent) 를 로컬 유지 — 다른 sub-package 와 cross-package 공유 불가능 (Go 패키지 boundary). worker/helpers_test.go 의 사본은 worker 통합 테스트 fixture 로 그대로 잔존. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… (PR #418 추가) fetcher 가 domain/general / domain/search 패턴을 사용하는 것과 일관 — validate 의 source-type 별 검증기도 동일하게 domain/ 하위로 이동. 이동: - internal/processor/validate/community → internal/processor/validate/domain/community - internal/processor/validate/news → internal/processor/validate/domain/news - test 미러도 동일 경로 갱신 import path 갱신: - internal/processor/validate/worker/validator.go (NewValidator dispatcher) - test/.../validate/domain/{community,news}/validator_test.go 이전 평면 sub-package 보다 \"도메인 grouping\" 의도가 더 명확 — 신규 source type 추가 시도 domain/<new>/validator.go 로 자연스럽게 확장. fetcher 와 패턴 일치. stage.go doc 도 신구조 반영. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
연관 이슈
Closes #417
구현 내용
세 stage (fetcher / parser / validate) 의 비일관 패키지 구조를 canonical 패턴으로 정합. 라이브 동작 영향 0 — 순수 패키지 위치 / import 경로 변경.
Canonical 구조
Phase A — validate worker 서브디렉토리화
validate/worker.go(621라인, top-level)validate/worker/worker.go(package worker)validate/validator.go(NewValidator dispatcher / RunValidation)validate/worker/validator.govalidate/reparse.go(IsReparseEligible / readReparseCount)validate/worker/reparse.gostageName내부 상수worker.StageName(exported) — stage.go / worker.go 공유validate 부모 패키지에는
stage.go만 잔존 — Stage 가*worker.Worker보유.Phase B — parser/stage 평탄화
parser/stage/stage.go→parser/stage.go(top-level, package parser)parser/stage.NewStage→parser.NewStagePhase C — parser 인터페이스 진입점 → types/
parser/parser.go(interfaces) →parser/types/types.go(package types)parser.Page/LinkItem/ContentParser/LinkListParser→types.Xcyclic 회피 효과: parser 부모 (이제 stage.go) 가 rule/* 를 import 해도 사이클 없음 (rule/* 가 parser/types 만 import).
cmd / test 갱신
cmd/issuetracker/main.go: parserStage import 제거 +parser.NewStage직접 /validateWorkerPkgalias 추가cmd/processor/main.go:validateWorkeralias 도입 →worker.NewWorker호출validate/worker_test.go/reparse_test.go/processor_test.go→validate/worker/서브디렉토리 (package worker_test)helpers_test.go—newNewsContent/newCommunityContentfixture 복사 (sub-package 분리로 cross-package 접근 불가)fetcher 예외
fetcher/core/는 http_client / retry / errors 등 helpers 다중 책임 — 단순 types/ 로 축소 불가. 의도된 foundation 패키지로 잔존. canonical 패턴의 stage.go / worker/ 부분은 일치.도달 상태
CI / 머지 게이트 점검
gofmt -l— cleango build ./internal/... ./cmd/... ./pkg/... ./test/... ./examples/...— passgo test -race -count=1 -timeout=180s ./test/...— 전 패키지 통과 (회귀 0)[REFAC#417][REFAC]:prefix + 한국어변경 영향 범위 + 위험도
롤백 계획
PR revert 시 16 파일 동시 원복 — 디렉토리 / 패키지 / import 경로 모두 동시에 이전 상태 복귀.
🤖 Generated with Claude Code
Summary by CodeRabbit
Refactor
Tests