# req-005: service-token 발급 시 runtime_id 동시 생성 - Status: Implemented - Type: Interface - Priority: High - Owner: repository-maintainers ## Intent - trex-basic 데몬은 GET /v1/user_info에서 runtime_id를 조회해 자신을 식별한다. - runtime_id는 service-token 발급 시 함께 생성되어 해당 토큰에 연결 저장되어야 한다. - CLI(pfhub service-token issue)와 API 엔드포인트 양쪽에서 발급 결과에 runtime_id가 포함되어야 한다. ## Requirement - pfhub service-token issue CLI 커맨드와 대응 API 엔드포인트는 service-token 발급 시 고유 runtime_id를 동시 생성하고 auth_tokens 테이블에 연결 저장한 뒤 발급 결과(token + runtime_id)를 반환해야 한다. - runtime_id는 해당 service-token에 1:1 연결되며, 동일 사용자의 다른 service-token은 각기 다른 runtime_id를 가진다. ## Acceptance Criteria 1. Given `pfhub service-token issue --user ` 실행 시, When 발급이 성공하면, Then 출력에 token 문자열과 runtime_id가 모두 포함되어야 한다. 2. Given API 엔드포인트(POST /auth/service-tokens)로 service-token 발급 시, When 성공 응답을 받으면, Then 응답 JSON에 token과 runtime_id가 포함되어야 한다. 3. Given runtime_id가 발급된 service-token으로 GET /v1/user_info를 호출하면, Then 응답의 runtime_id가 발급 시 생성된 값과 동일해야 한다. 4. Given 동일 사용자에 대해 두 번의 service-token 발급을 수행하면, Then 각각 다른 runtime_id가 반환되어야 한다. 5. Given auth_tokens 테이블을 직접 조회하면, Then 발급된 service-token 행에 runtime_id 값이 저장되어 있어야 한다. ## Impacted Area - Docs: docs/runtime-flows.md (REQ-011에서 갱신 예정) - Modules: app/cli/commands/service_tokens.py, app/api/auth_routes.py, app/domain/models.py (AuthToken.runtime_id 필드 추가), app/services/auth_service.py, app/repositories/postgres.py - Tests: tests/test_auth.py 확장 또는 tests/test_service_tokens.py (신규) ## Notes - runtime_id 포맷은 UUID v4를 권장한다. 설계 단계에서 확정한다. - auth_tokens 테이블에 runtime_id 컬럼 추가는 REQ-009 migration에서 처리한다. - 기존 service-token(runtime_id 없음) 처리 방식은 R-4로 식별됨. GET /v1/user_info(REQ-007) 설계 단계에서 결정한다. - Source Discovery: dcy-002 (FR-2, A-2) ## Change Log ### CHG-20260511-02 - Date: 2026-05-11 - Author: repository-maintainers #### Change Summary - REQ-005 AC-2의 API 경로를 실제 구현 경로인 `POST /auth/service-tokens`로 명확화 #### Intent - CONFLICT-4 분석 결과를 반영해 "POST /auth/tokens 또는 동등 경로"라는 모호한 표현을 제거하고, BAT-001 verification과 runtime flow에 이미 반영된 실제 엔드포인트로 REQ를 정렬한다. #### Acceptance Criteria Delta - Added: - none - Updated: - AC-2: API 발급 경로를 `POST /auth/service-tokens`로 구체화 - Removed: - none #### Impacted Area Delta - Docs: - `docs/srs/Interface/req-005_service-token-runtime-id-issuance.md`: AC-2 경로 문구 명확화 - Modules: - none - Tests: - none #### Delivery Trace Delta - Batches: - BAT-001 (release-candidate) — verification evidence는 이미 `POST /auth/service-tokens` 기준으로 정렬되어 있어 추가 재검증은 불필요 - Releases: - REL-001 (draft) — release scope 문서도 동일 경로를 사용 중이라 추가 수정 없음 #### Revalidation Impact - Reverification Needed: no - Existing Implementation Invalidated: no - Status Recommendation: keep-current - Follow-up Action: none #### Validation Plan - REQ-005 AC-2, BAT-001 verification evidence, runtime-flows.md의 API 경로가 모두 `POST /auth/service-tokens`로 일치하는지 코드 리뷰로 확인 ### CHG-20260511-01 - Date: 2026-05-11 - Author: repository-maintainers #### Change Summary - Implemented 전환 — BAT-001 re-verified verification passed, confirm-req-implemented 게이트 통과 #### Intent - BAT-001 verification.md (re-verified, 2026-05-03) AC-1~5 모두 PASS. Blocking Issues 없음. AC5 DB 미확인은 REQ-009와 동일 제약으로 non-blocker 처리. #### Acceptance Criteria Delta - none #### Impacted Area Delta - none #### Delivery Trace Delta - Batches: BAT-001 (release-candidate) - Releases: none #### Revalidation Impact - Reverification Needed: no - Existing Implementation Invalidated: no - Status Recommendation: implemented - Follow-up Action: draft-release (BAT-001) #### Validation Plan - BAT-001 verification.md (re-verified) AC-1~5 evidence 연결 확인 완료 ### CHG-20260502-02 - Date: 2026-05-02 - Author: repository-maintainers #### Change Summary - REQ-005 confirm-req 승인 전환 (Status: Proposed → Approved) #### Intent - 필수 필드(Status, Type, Priority, Owner, Intent, Requirement, Acceptance Criteria 5개, Impacted Area, Change Log) 모두 충족 확인 후 승인 #### Acceptance Criteria Delta - No change #### Impacted Area Delta - No change #### Delivery Trace Delta - Batches: - none - Releases: - none #### Revalidation Impact - Reverification Needed: no - Existing Implementation Invalidated: no - Status Recommendation: keep-current - Follow-up Action: suggest-batch-reqs → draft-batch ### CHG-20260502-01 - Date: 2026-05-02 - Author: repository-maintainers #### Change Summary - REQ-005 최초 생성 (source Discovery: dcy-002 FR-2) #### Intent - service-token 발급 시 runtime_id 동시 생성 요구사항을 REQ backlog로 정규화 #### Acceptance Criteria Delta - Added: - 전체 Acceptance Criteria 신규 작성 #### Impacted Area Delta - Docs: - docs/runtime-flows.md (REQ-011에서 갱신 예정) - Modules: - app/cli/commands/service_tokens.py - app/api/auth_routes.py - app/domain/models.py - Tests: - tests/test_auth.py 확장 또는 tests/test_service_tokens.py 신규 #### Delivery Trace Delta - Batches: - none - Releases: - none #### Revalidation Impact - Reverification Needed: no - Existing Implementation Invalidated: no - Status Recommendation: keep-current - Follow-up Action: confirm-req 후 batch 배정. REQ-009 migration과 함께 delivery 단위 구성 권장.