Skip to content

fix: enforce architecture catalog group consistency - #1200

Merged
kang-heewon merged 4 commits into
trunkfrom
fix/1147-architecture-catalog-groups
Jul 4, 2026
Merged

fix: enforce architecture catalog group consistency#1200
kang-heewon merged 4 commits into
trunkfrom
fix/1147-architecture-catalog-groups

Conversation

@kang-heewon

@kang-heewon kang-heewon commented Jul 3, 2026

Copy link
Copy Markdown
Member

Fixes #1147.

Summary

  • Adds a package catalog versus architecture policy group consistency gate to architecture-policy:check.
  • Supports explicit packageCatalogGroupOverrides for intentional catalog/policy group differences.
  • Tightens croco.arch.json package groups so current public packages classify exactly once, with explicit overrides for @croco/events-tx and @croco/tx-drizzle.
  • Adds regression coverage for aligned packages, unclassified packages, missing catalog metadata, duplicate catalog assignments, duplicate architecture assignments, stale overrides, and mismatch handling.

Verification

  • corepack pnpm vitest run scripts/tests/architecture-policy-check.spec.ts
  • corepack pnpm architecture-policy:check
  • corepack pnpm check
  • corepack pnpm test
  • corepack pnpm typecheck
  • git diff --check

Review / QA

  • Code review: native code-reviewer verdict APPROVE, 0 findings.
  • UltraQA: temporary fixture matrix passed normal repeated runs, malformed catalog JSON, prompt-injection-like override text, path-traversal-like catalog values, misleading success output guard, and dirty-worktree cleanup audit.

Summary by CodeRabbit

  • Bug Fixes

    • 패키지 그룹 분류 기준이 더 정확하게 정리되어, 일부 패키지가 잘못 분류되거나 누락되는 문제를 줄였습니다.
    • 패키지 카탈로그와 정책 그룹 간 불일치를 자동으로 감지해, 설정 오류를 더 쉽게 확인할 수 있게 했습니다.
  • New Features

    • 아키텍처 정책 검증 결과에 패키지 카탈로그 그룹 일관성 검사 결과가 함께 표시됩니다.
    • 예외적으로 허용된 분류 매핑을 명시적으로 관리할 수 있게 되었습니다.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kang-heewon, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 44 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 95954285-8442-4f3d-abbd-56c6a98f3bbe

📥 Commits

Reviewing files that changed from the base of the PR and between 5307b41 and e254b6e.

📒 Files selected for processing (6)
  • .changeset/architecture-catalog-group-overrides.md
  • croco.arch.json
  • packages/architecture-policy/src/index.ts
  • packages/docs/src/content/docs/api/architecture-policy/src/type-aliases/ArchitecturePolicyManifest.md
  • scripts/architecture-policy-check.mts
  • scripts/tests/architecture-policy-check.spec.ts
📝 Walkthrough

Walkthrough

croco.arch.json의 패키지 그룹 구성을 재분류하고 카탈로그 그룹 오버라이드를 추가했으며, architecture-policy-check.mts에 공개 워크스페이스 패키지와 package-catalog.json 간 그룹 일관성을 검증하는 로직과 출력/종료코드 변경을 도입했다. 이를 검증하는 신규 Vitest 통합 테스트 스위트도 추가되었다.

Changes

패키지 카탈로그-정책 그룹 일관성 검증

Layer / File(s) Summary
패키지 그룹 재분류 및 오버라이드 설정
croco.arch.json
framework/integrations/app 그룹의 packages 목록을 명시적으로 재구성하고, events-tx/tx-drizzle을 위한 packageCatalogGroupOverrides를 신설함.
CLI 엔트리 및 출력 흐름 변경
scripts/architecture-policy-check.mts
매니페스트 경로 해석 방식을 변경하고, 아키텍처 정책 리포트와 카탈로그 그룹 일관성 리포트를 함께 계산해 JSON/텍스트 출력과 종료 코드에 반영함.
카탈로그 그룹 일관성 검증 핵심 로직
scripts/architecture-policy-check.mts
공개 워크스페이스 패키지 조회, package-catalog.json 그룹 읽기, 오버라이드 파싱, 패턴 매칭 기반 정책 그룹 비교와 위반 사항 리포팅 로직을 구현함.
통합 테스트 스위트
scripts/tests/architecture-policy-check.spec.ts
임시 프로젝트로 스크립트를 spawnSync 실행해 다양한 성공/실패 및 오버라이드 시나리오를 검증하는 테스트와 파일 작성 헬퍼를 추가함.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI as architecture-policy-check.mts
  participant Manifest as croco.arch.json
  participant Catalog as docs/package-catalog.json
  participant Packages as packages/*

  CLI->>Manifest: resolveManifestPath 후 매니페스트 로드
  CLI->>Packages: readPublicWorkspacePackages 호출
  CLI->>Catalog: readPackageCatalogGroups 호출
  CLI->>Manifest: packageCatalogGroupOverrides 파싱
  CLI->>CLI: findMatchingArchitecturePackageGroups로 그룹 비교
  CLI-->>CLI: violations 누적 및 status 결정
  CLI-->>CLI: JSON/텍스트 출력 및 종료 코드 반환
Loading

Possibly related PRs

  • croco-dev/framework#1059: 동일한 scripts/architecture-policy-check.mts와 croco.arch.json 그룹/정책 매핑 로직을 도입한 기반 작업으로 직접적으로 연관됨.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 아키텍처 카탈로그 그룹 일관성 강제라는 핵심 변경을 정확하고 간결하게 요약합니다.
Linked Issues check ✅ Passed 공개 패키지와 카탈로그/아키텍처 그룹을 교차 검증하고, 명시적 오버라이드와 불일치 실패를 지원해 #1147 요구를 충족합니다.
Out of Scope Changes check ✅ Passed 카탈로그-정책 일치 검사와 관련된 manifest, 설정, 테스트 변경만 보여서 명백한 범위 외 변경은 보이지 않습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1147-architecture-catalog-groups

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.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

📊 Benchmark Results

✅ All benchmarks passed

Benchmark p75 Threshold Baseline vs Baseline Status Notes
CrocoApp constructor 8.8μs 30.0ms 8.2μs +7.7% -
CrocoApp lambdaHandler (10 controllers) 220.1μs 50.0ms 258.4μs -14.8% -
Lambda cold-start simulation 421.9μs 80.0ms 418.1μs +0.9% -
Lambda cold-start with headers 361.9μs 80.0ms 369.7μs -2.1% -
Lambda cold-start with binary body 333.2μs 80.0ms 339.1μs -1.7% -
Lambda cold-start with query params 274.6μs 80.0ms 301.3μs -8.9% -
Lambda cold-start with authorizer context 275.7μs 80.0ms 299.8μs -8.0% -
Lambda cold-start realistic scenario 274.4μs 80.0ms 299.2μs -8.3% -
EventBusConfig.start (10 handlers) 1.7μs 10.0ms 1.4μs +17.4% -
EventPublisher.publishNow single event 1.8μs 2.0ms 1.7μs +9.5% -
DefaultHandlerResolver.resolve × 10 0.1μs 5.0ms 0.1μs +0.0% -
Container.get singleton (cold) 57.5μs 5.0ms 70.3μs -18.1% -
Container.register × 50 components 3.0ms 10.0ms 3.2ms -6.8% -
Container.validate (50 components) 2.9ms 20.0ms 3.4ms -13.4% -
Container.get singleton (warm) 1.6μs 500.0μs 1.6μs -3.7% -
TelemetryRuntime.init (lambda preset) 2.0μs 200.0ms 1.1ms -99.8% -
lambdaPreset config creation 1.4μs 2.0ms 1.4μs -4.9% -

Updated: 2026-07-03T23:50:51.509Z · Commit: 8586d0e

@kang-heewon

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
croco.arch.json (1)

89-108: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

forbiddenImportsto.packages 목록이 integrations 그룹과 어긋남.

packageGroups.integrations.packages(89-108)에 @croco/telemetry-api가 추가되었지만, framework→provider 임포트를 막는 forbiddenImports 규칙의 to.packages(157-176)에는 반영되지 않았습니다. 두 목록이 수동으로 동기화되는 구조이기 때문에, framework 패키지가 @croco/telemetry-api를 임포트해도 이 규칙으로는 차단되지 않아 아키텍처 경계 정책에 구멍이 생깁니다.

🛠️ 제안 수정
             "`@croco/storage-r2`",
+            "`@croco/telemetry-api`",
             "`@croco/telemetry-sdk-node`",
             "`@croco/transports-`*",

Also applies to: 157-176

🤖 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 `@croco.arch.json` around lines 89 - 108, The forbiddenImports rule is missing
the newly added `@croco/telemetry-api` entry, so framework-to-provider imports are
not fully blocked. Update the forbiddenImports configuration’s to.packages list
to stay in sync with packageGroups.integrations.packages, using the same package
identifier(s) already present there, so the architecture boundary enforced by
this rule includes `@croco/telemetry-api`.
🤖 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 `@croco.arch.json`:
- Line 105: Remove `@croco/telemetry-api` from the integrations group in the arch
config, since it is a shared telemetry API package rather than an integration
module. Update the relevant grouping entry in croco.arch.json so only actual
integration packages remain, and keep the API surface that provides Trace,
withSpan, recordError, getTracer, and the browser correlation bridge out of that
group.

In `@scripts/architecture-policy-check.mts`:
- Around line 3-68: The manifest is being read twice because
`checkPackageCatalogGroupConsistency` re-parses the same file with a separate
raw JSON path just to access `packageCatalogGroupOverrides`. Add
`packageCatalogGroupOverrides` to the `ArchitecturePolicyManifest` schema used
by `readArchitecturePolicyManifest`, then update
`checkPackageCatalogGroupConsistency` to consume the parsed manifest directly
instead of introducing `readJsonFile<RawManifest>`, keeping the logic centered
around `checkArchitecturePolicy`, `formatArchitecturePolicyDiagnostic`, and
`readArchitecturePolicyManifest`.
- Around line 320-334: `readPackageCatalogGroups` is reading
`docs/package-catalog.json` without a file-existence guard, so a missing catalog
crashes the check instead of recording a violation. Update
`readPackageCatalogGroups` to mirror the `readPublicWorkspacePackages` pattern
by checking for the catalog file before calling `readJsonFile`, and if it is
absent push a `PackageCatalogGroupViolation` with an actionable
message/recovery/evidence and return an empty map.
- Around line 178-188: The package catalog consistency check is hardcoded to
read only the default workspace set and ignores the manifest’s packageRoots.
Update checkPackageCatalogGroupConsistency to derive the workspace package list
from the manifest configuration and pass the configured roots into
readPublicWorkspacePackages so apps/libs-style additions are included. Use the
existing symbols checkPackageCatalogGroupConsistency,
readPublicWorkspacePackages, and ArchitecturePolicyManifest to wire the
manifest-driven roots through this path.

---

Outside diff comments:
In `@croco.arch.json`:
- Around line 89-108: The forbiddenImports rule is missing the newly added
`@croco/telemetry-api` entry, so framework-to-provider imports are not fully
blocked. Update the forbiddenImports configuration’s to.packages list to stay in
sync with packageGroups.integrations.packages, using the same package
identifier(s) already present there, so the architecture boundary enforced by
this rule includes `@croco/telemetry-api`.
🪄 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: ASSERTIVE

Plan: Pro

Run ID: fde6f63b-e5e3-4d14-8846-97951a4e4a41

📥 Commits

Reviewing files that changed from the base of the PR and between ebd9874 and 5307b41.

📒 Files selected for processing (3)
  • croco.arch.json
  • scripts/architecture-policy-check.mts
  • scripts/tests/architecture-policy-check.spec.ts

Comment thread croco.arch.json Outdated
Comment thread scripts/architecture-policy-check.mts
Comment thread scripts/architecture-policy-check.mts
Comment thread scripts/architecture-policy-check.mts
@kang-heewon
kang-heewon merged commit c35f4d9 into trunk Jul 4, 2026
8 of 9 checks passed
@kang-heewon
kang-heewon deleted the fix/1147-architecture-catalog-groups branch July 4, 2026 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[architecture] Validate architecture-policy package groups against the package catalog

1 participant