# req-005: service-token 발급 시 runtime_id 동시 생성 - Status: Approved - 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/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-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 단위 구성 권장.