Skip to content

[entitlements-core] Entitlement Guard를 route/service 경계에 연결한다 #920

Description

@kang-heewon

Summary

entitlements-core를 route, command, service method 경계에서 선언적으로 검사할 수 있는 Entitlement Guard 기능으로 확장한다.

SaaS 앱에서 plan/seat/usage entitlement는 비즈니스 로직 내부에 흩어지기 쉽다. Croco가 이를 guard contract로 노출하면 실패 이유, 복구 경로, API 문서, 테스트 fixture가 모두 같은 정책을 읽을 수 있다.

Proposed Scope

  • requiresEntitlement 또는 동등한 route/service metadata contract.
  • entitlement check result union: allowed, denied, soft-limit, overage-allowed, unknown.
  • Problem mapping: missing plan, exceeded quota, inactive subscription, provider unavailable.
  • access policy와 tenant context 연동.
  • generated contract/OpenAPI extension에 entitlement requirement 노출.
  • test helper for granted/denied scenarios.

Acceptance Criteria

  • handler 실행 전에 entitlement가 검사되고 실패는 표준 Problem으로 반환된다.
  • entitlement requirement가 contract artifact에 포함된다.
  • tenant/user/resource context가 guard input에 명시적으로 전달된다.
  • billing/metering 패키지와 결합하되 core가 provider 구현체에 오염되지 않는다.
  • guard success/failure가 telemetry와 audit evidence로 남는다.

Validation

  • pnpm test --filter=@croco/entitlements-core
  • pnpm test --filter=@croco/access-core
  • route guard fixture
  • contract artifact snapshot test

Metadata

Metadata

Assignees

Labels

P0Priority 0 issueapi-contractAPI, RPC, route, and schema contract workenhancementNew feature or requestfeatureProduct feature or roadmap capabilityruntimeRuntime behavior, lifecycle, and environment capability work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions