BAT-006 (REQ-016/017/018): - client token 발급 경로 제거 (issue_client_token, POST /auth/tokens, 관련 스키마/테스트) - service-token rotate unique index revoked_at IS NULL 조건 추가 (Alembic CONCURRENTLY 마이그레이션) - POST /auth/service-tokens body daemon_id forward 누락 보정 (1-line fix) BAT-007 (REQ-022/023): - daemon deactivate 시 바인딩 service token 자동 revoke (CLI --force 옵션 + revoke_tokens_by_daemon_id) - NULL daemon_id legacy token 진단 CLI (migrate-null-daemon --dry-run) 거버넌스 문서: dcy-003/004 Discovery, REQ-016~023/025~032 신규, BAT-006/007 전체 산출물 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3.2 KiB
3.2 KiB
BAT-006 Implementation
- Status: completed
- Batch: BAT-006
Plan Summary
- REQ-017: rotate unique index 보강 Alembic migration + ensure_schema 갱신
- REQ-018: POST /auth/service-tokens daemon_id forward 1-line fix
- REQ-016: POST /auth/tokens 라우트·서비스·스키마 코드 제거
Changed Files
migrations/versions/20260520_0022_service_token_unique_index_fix.py— 신규 Alembic revision: DROP + CREATE UNIQUE INDEX CONCURRENTLYWHERE token_type='service' AND revoked_at IS NULL(REQ-017)app/repositories/postgres.py—ensure_schema()idx 정의 조건 갱신WHERE token_type='service' AND revoked_at IS NULL(REQ-017)app/api/auth_routes.py—daemon_id=payload.daemon_id추가 (REQ-018);CreateClientTokenRequest·IssuedClientTokenResponse·IssuedClientTokenimport 제거,_to_issued_token_response헬퍼 제거,create_token라우트 제거 (REQ-016)app/services/auth_service.py—CreateClientTokenRequestimport 제거,IssuedClientTokendataclass 제거,issue_client_token메서드 제거,_build_expiration정적 메서드 제거 (REQ-016)app/schemas/auth.py—CreateClientTokenRequest,IssuedClientTokenResponse클래스 제거 (REQ-016)tests/test_auth.py—get_daemon_by_id추가 to_AuthRepo; REQ-018 AC-1~3 서비스 계층 테스트 3개 추가; REQ-016 AC-2 HTTP 404/405 테스트 추가tests/test_auth_surface_after_client_deprecation.py— 신규: REQ-016 AC-1 grep 기반 잔여 심볼 검증 3개, AC-4 importlib 기반 심볼 제거 검증 2개tests/test_users.py—test_login_and_issue_client_token_flow제거 (POST /auth/tokens 폐지)
Execution Log
- REQ-017:
migrations/versions/20260520_0022_service_token_unique_index_fix.py신규 작성 (CONCURRENTLY + autocommit 패턴) - REQ-017:
app/repositories/postgres.py:ensure_schema()index 조건 갱신 - REQ-018:
app/api/auth_routes.pyissue_service_token()호출에daemon_id=payload.daemon_id추가 - REQ-016:
app/schemas/auth.py—CreateClientTokenRequest,IssuedClientTokenResponse제거 - REQ-016:
app/services/auth_service.py—IssuedClientTokendataclass,issue_client_token,_build_expiration제거 - REQ-016:
app/api/auth_routes.py— import,_to_issued_token_response,create_token라우트 제거 tests/test_users.py—test_login_and_issue_client_token_flow제거tests/test_auth.py—_AuthRepo.get_daemon_by_id추가; REQ-018 AC-1~3 테스트 추가; REQ-016 AC-2 HTTP 테스트 추가 (404/405 허용)tests/test_auth_surface_after_client_deprecation.py신규 생성 (REQ-016 AC-1/4)- pytest 255 passed 확인
Validation
- pytest 255 passed (8.13s) — regression 없음
- 신규 테스트: test_auth.py +4개, test_auth_surface_after_client_deprecation.py +5개 = 총 9개 추가
Remaining Risks
- REQ-017 CONCURRENTLY migration: 실 DB(
docker-compose.local-test.yml) 환경에서 AC-1~3 검증 미완료 (실 DB 없는 환경에서 단위 테스트만 수행) - REQ-016 AC-3: release 직전
SELECT COUNT(*) FROM auth_tokens WHERE token_type='client' AND revoked_at IS NULL→ COUNT=0 재확인은 release plan evidence로 남김