Skip to content

test: guard the disclosure a delegation is required to point at - #276

Merged
kcrmin merged 1 commit into
developfrom
feature/491-disclosure-policy-guard
Aug 9, 2026
Merged

test: guard the disclosure a delegation is required to point at#276
kcrmin merged 1 commit into
developfrom
feature/491-disclosure-policy-guard

Conversation

@kcrmin

@kcrmin kcrmin commented Aug 9, 2026

Copy link
Copy Markdown
Member

후속: Idea2Strategy/Idea2Strategy#479

왜 필요한가

identity.delegated_authorizations.disclosure_policy_document_id 는 NOT NULL 이다. 즉 이 문서가
없으면 위임 기능이 조용히 저하되는 게 아니라 완전히 멈춘다. 그런데 "이 정책 코드에는 항상
유효한 문서가 정확히 하나 있다" 를 검사하는 곳이 없었다.

이번 주에 그 상태를 두 번 만들었다.

  1. v2 를 미래 시각으로 발행 — v1 은 은퇴되고 v2 는 아직 선택 불가라 유효 문서 0건이 됐다.
    모든 위임 발급이 실패했다. CI 가 잡았지만, 그건 무관한 발급 테스트가 우연히 그 문서를 읽었기
    때문이지 이 불변조건을 검사해서가 아니다.
  2. is_required = true 로 발행 — 모든 계정이 인증을 마치려면 동의해야 하는 집합에 들어가
    위임을 쓰지 않는 사용자의 로그인까지 막았다.

둘 다 리뷰 중인 마이그레이션 파일만 봐서는 보이지 않는다. 이 테스트에서는 보인다.

무엇을 고정하는가

검사 막는 것
유효 문서가 정확히 1건 위임 기능 전면 중단
is_required 가 절대 참이 아님 전 사용자 로그인 차단
content_hashcontent_text 와 일치 본문과 해시의 드리프트
본문이 컨테이너 생성과 금지 항목을 언급 권한은 넓어졌는데 고지가 좁아지는 것

마지막 항목이 이 문서의 존재 이유다. 위임 범위가 커질 때 고지가 따라가지 않으면, 사용자는 자기가
허용한 것보다 넓은 권한을 준 것이 된다.

검증

:modules:backend-persistence:test --tests '*DelegationDisclosurePolicyMigration*' 통과.

가드가 실제로 깨지는지도 확인했다 — v2 의 published_at 을 미래로 옮기면 유효 문서 수가
1 → 0 으로 떨어지고, 되돌리면 다시 1이 된다.

🤖 Generated with Claude Code

disclosure_policy_document_id is NOT NULL, so this document is not decoration: when
the policy code resolves to nothing, delegation does not degrade, it stops. Both ways
that has already happened this week are now pinned.

Publishing v2 with a future published_at retired v1 while v2 was not yet selectable
and left the code with zero current documents; every grant failed. Publishing the
disclosure as is_required put it in the set every account must consent to before it
can finish authenticating, blocking login for customers who never delegate anything.
Neither is visible in the migration file under review, and the first was only caught
because unrelated grant tests happened to read the document.

The remaining two assertions cover drift rather than outage: the stored hash must
still describe the stored text, and the disclosure must still say the tool can build
the strategy itself. A disclosure that quietly narrows while the capability widens is
the one failure this document exists to prevent.

Refs #479

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@kcrmin
kcrmin merged commit bfbcdd5 into develop Aug 9, 2026
2 checks passed
@kcrmin
kcrmin deleted the feature/491-disclosure-policy-guard branch August 9, 2026 16:57
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.

1 participant