feat: REQ-001~018 Implemented 전환, REQ-010 GET /v1/assets admin catalog 재정의, REL-001 draft

- confirm-req-implemented: REQ-001~018 (17건, REQ-013 제외) Approved → Implemented
  - BAT-001(REQ-009/011/014), BAT-002(REQ-010/012/015), BAT-003(REQ-001/002/003/006)
  - BAT-004(REQ-004/005), BAT-005(REQ-007/008), BAT-006(REQ-016/017/018)
  - CHG-20260521-01 entry 각 REQ에 추가; SRS index Recent Change Log 갱신

- REQ-010 CHG-20260521-02: GET /v1/assets admin catalog 전용 재정의
  - 기존 token_type 분기 portfolio 조회 코드 제거, admin permission + list_assets() 호출로 대체
  - AssetCatalogListResponse 스키마 추가 (items/total)
  - REQ-010 Status: Implemented → Approved (재검증 필요)
  - 테스트 343건 전체 통과: service/user token 403, admin token 200 + catalog schema 검증

- migration 보강: portfolios_asset_migration market 컬럼 부재 fallback,
  portfolio_tags 빈 테이블 early-return, service_token index fix autocommit_block 정리

- docs/releases/rel-001: REL-001 draft 추가 (BAT-001~011 포함)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-21 10:17:39 +00:00
co-authored by Claude Sonnet 4.6
parent 4bf6b554a7
commit 6add0ade29
28 changed files with 894 additions and 393 deletions
+29 -1
View File
@@ -1,6 +1,6 @@
# REQ-004: tags 마스터 HTTP API
- Status: Approved
- Status: Implemented
- Type: Interface
- Priority: High
- Owner: Justin Ko
@@ -48,6 +48,34 @@
## Change Log
### CHG-20260521-01
- Date: 2026-05-21
- Author: Justin Ko
#### Change Summary
- Status: Approved → Implemented
#### Intent
- BAT-004 confirm-batch-verification 완료. POST/GET /v1/tags, PATCH /v1/tags/{id}/deactivate 권한 분기·소문자 정규화·멱등성 모든 AC 검증 통과.
#### Acceptance Criteria Delta
- No change
#### Impacted Area Delta
- No change
#### Delivery Trace Delta
- Batches:
- BAT-004
- Releases:
- REL-001
#### Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: implemented
- Follow-up Action: none
### CHG-20260519-02
- Date: 2026-05-19
- Author: Justin Ko
@@ -1,6 +1,6 @@
# REQ-005: 태그 적용·해제 HTTP API
- Status: Approved
- Status: Implemented
- Type: Interface
- Priority: High
- Owner: Justin Ko
@@ -48,6 +48,34 @@
## Change Log
### CHG-20260521-01
- Date: 2026-05-21
- Author: Justin Ko
#### Change Summary
- Status: Approved → Implemented
#### Intent
- BAT-004 confirm-batch-verification 완료. asset/portfolio 태그 적용·해제 HTTP API 정책 검증·403/404 분기 모든 AC 검증 통과.
#### Acceptance Criteria Delta
- No change
#### Impacted Area Delta
- No change
#### Delivery Trace Delta
- Batches:
- BAT-004
- Releases:
- REL-001
#### Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: implemented
- Follow-up Action: none
### CHG-20260519-02
- Date: 2026-05-19
- Author: Justin Ko
+29 -1
View File
@@ -1,6 +1,6 @@
# REQ-007: pfhub tag CLI 명령어
- Status: Approved
- Status: Implemented
- Type: Interface
- Priority: Medium
- Owner: Justin Ko
@@ -47,6 +47,34 @@
## Change Log
### CHG-20260521-01
- Date: 2026-05-21
- Author: Justin Ko
#### Change Summary
- Status: Approved → Implemented
#### Intent
- BAT-005 confirm-batch-verification 완료. pfhub tag create/list/deactivate/apply/remove CLI 모든 AC 검증 통과. 기존 pfhub portfolio tag add/list/remove 제거 확인.
#### Acceptance Criteria Delta
- No change
#### Impacted Area Delta
- No change
#### Delivery Trace Delta
- Batches:
- BAT-005
- Releases:
- REL-001
#### Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: implemented
- Follow-up Action: none
### CHG-20260519-02
- Date: 2026-05-19
- Author: Justin Ko
@@ -17,7 +17,8 @@
- HTTP API: `POST /v1/assets` — admin token 필요. request body에 symbol, markets, display_name. 성공 시 HTTP 201 + 생성된 asset 반환.
- HTTP API: `PATCH /v1/assets/{asset_id}` — admin token 필요. markets, display_name 변경 가능. 성공 시 HTTP 200 + 갱신된 asset 반환.
- HTTP API: `PATCH /v1/assets/{asset_id}/deactivate` — admin token 필요. `status='inactive'`로 변경. 성공 시 HTTP 200.
- admin 이외의 token으로 POST/PATCH 요청 시 HTTP 403을 반환한다.
- HTTP API: `GET /v1/assets` — admin token 필요. query param `status` (active|inactive|all, 기본 `active`), `market` (선택, MarketCode 1개). 응답: `{ items: [{ asset_id, symbol, markets, display_name, status, created_at, updated_at }] }` 형식. 응답 본문에 portfolio 관련 필드는 포함하지 않는다(path 의미 분리 — portfolio 조회는 `GET /v1/portfolios`).
- admin 이외의 token으로 POST/PATCH/GET 요청 시 HTTP 403을 반환한다.
- asset hard DELETE는 제공하지 않는다(soft delete 전용).
- `app/cli/commands/asset.py` 신규 파일로 pfhub asset 커맨드 그룹을 구현한다.
- `app/cli/main.py`에 `app.add_typer(asset_app, name="asset")`을 추가한다.
@@ -32,28 +33,104 @@
6. Given admin 토큰, When `PATCH /v1/assets/{asset_id}` with updated markets, Then HTTP 200과 변경된 asset이 반환된다.
7. Given admin 토큰, When `PATCH /v1/assets/{asset_id}/deactivate`, Then HTTP 200과 status='inactive'가 반환된다.
8. Given non-admin token (user 또는 service token), When `POST /v1/assets` 요청, Then HTTP 403이 반환된다.
9. Given admin 토큰 + active/inactive asset 혼재, When `GET /v1/assets`, Then HTTP 200 + status='active' 항목만 포함된 `{items: [...]}` 응답. 각 item은 `asset_id, symbol, markets, display_name, status, created_at, updated_at` 필드만 포함하고 portfolio 관련 필드(`portfolio_id`, `owner_user_id`, `cash_balance` 등)는 포함하지 않는다.
10. Given admin 토큰 + active/inactive asset 혼재, When `GET /v1/assets?status=all`, Then 두 상태 모두 포함; `GET /v1/assets?status=inactive`, Then inactive만 포함.
11. Given admin 토큰 + 서로 다른 markets 값을 가진 asset 다수, When `GET /v1/assets?market=KRX`, Then `markets`에 `KRX`가 포함된 asset만 응답된다.
12. Given non-admin token (read/trade-write 권한 또는 service token), When `GET /v1/assets`, Then HTTP 403이 반환된다.
## Impacted Area
- Docs:
- docs/project-structure.md — `app/cli/` Command groups에 `asset` 추가 (REQ-015에서 처리)
- docs/interface-contract.md — POST/PATCH /v1/assets 엔드포인트 명세 추가 (REQ-015에서 처리)
- docs/interface-contract.md — POST/PATCH/GET /v1/assets 엔드포인트 명세 추가 (CHG-20260521-02에서 GET 추가; 후속 docs sync 필요 시 별도 REQ)
- Modules:
- `app/cli/commands/asset.py` — 신규 파일, pfhub asset 커맨드 그룹
- `app/cli/main.py` — `app.add_typer(asset_app, name="asset")` 추가
- `app/services/` — asset create/update/deactivate/list 서비스 메서드 추가
- `app/api/v1_assets.py` — POST, PATCH 라우트 추가
- `app/schemas/` — `CreateAssetRequest`, `UpdateAssetRequest`, `AssetCatalogResponse` 스키마 추가
- `app/api/v1_assets.py` — POST, PATCH 라우트 추가; GET /v1/assets 라우트는 admin catalog 조회로 재정의(기존 token_type 분기 portfolio 조회 코드 제거)
- `app/schemas/v1.py` — `CreateAssetRequest`, `UpdateAssetRequest`, `AssetCatalogItem`, `AssetCatalogListResponse` 스키마 추가
- Tests:
- `tests/test_asset_catalog.py` (신규) — admin CRUD CLI/API AC 검증, non-admin 403 검증
- `tests/test_asset_catalog.py` (신규) — admin CRUD CLI/API AC 검증, non-admin 403 검증, GET /v1/assets AC-9~12 검증
- `tests/test_v1.py` (기존) — GET /v1/assets에 portfolio 응답을 기대하는 케이스가 있다면 GET /v1/portfolios로 이전 또는 catalog 응답 schema로 갱신
## Notes
- `pfhub asset list`의 HTTP 대응(catalog 전용 GET): dcy-003 옵션 B(path 명명 분리) 결정에 따라 REQ-013(GET /v1/assets 포트폴리오 조회)이 Deprecated(2026-05-20) 처리되어 path 충돌 우려가 해소됨. **`GET /v1/assets`는 admin catalog 조회 전용**으로 본 REQ에서 다루며, dcy-001 batch design 단계에서 본 REQ에 GET 명세를 보강(change-req)하거나 별도 신규 REQ로 분리한다. 포지션 조회 `GET /v1/portfolios`는 dcy-003의 별도 신규 REQ로 분리 예정.
- `pfhub asset list`의 HTTP 대응(catalog 전용 GET): dcy-003 옵션 B(path 명명 분리) 결정에 따라 REQ-013(GET /v1/assets 포트폴리오 조회)이 Deprecated(2026-05-20) 처리되어 path 충돌 우려 해소. **`GET /v1/assets`는 admin catalog 조회 전용**으로 본 REQ에서 다룬다(2026-05-21 CHG-20260521-02로 augmentation 적용). 포지션 조회 `GET /v1/portfolios`는 REQ-028에서 분리 구현됨.
- deactivate 후 해당 asset을 참조하는 기존 portfolio는 보존된다. 신규 portfolio 생성만 거부(REQ-012에서 처리).
- REQ-009 선행 필요.
- Source: dcy-001 FR-2, NFR-3
- Source: dcy-001 FR-2, NFR-3; CHG-20260521-02 augmentation는 dcy-003 옵션 B (REQ-013 Deprecation) 후속 작업.
## Change Log
### CHG-20260521-02
- Date: 2026-05-21
- Author: Justin Ko
#### Change Summary
- Status: Implemented → Approved (REL-001 smoke 검증에서 GET /v1/assets가 dcy-001 시점 portfolio 조회 코드를 유지 중인 불일치 확인. 본 REQ Notes의 1순위 경로(REQ-010 augmentation)에 따라 GET 명세를 추가하고 기존 구현을 재정의.)
#### Intent
- dcy-003 옵션 B로 REQ-013 Deprecated 후 본 REQ Notes에 명시된 "GET /v1/assets는 admin catalog 조회 전용" 재정의가 미구현 상태로 잔존. REL-001 배포 직전 로컬 smoke([rel-001.md:50](../../releases/rel-001_20260521_v1-api-full-surface.md#L50))에서 admin session token → HTTP 403 "Unsupported token type" 발생으로 release 체크리스트와 코드 상태 불일치 확인. 본 augmentation으로 GET /v1/assets를 admin catalog 조회로 재정의해 path 분리 정책(dcy-003 옵션 B)을 코드에 반영.
#### Acceptance Criteria Delta
- Added:
- AC-9 (admin token GET 200 + asset catalog 응답)
- AC-10 (`status=all`/`status=inactive` 필터)
- AC-11 (`market=<code>` 필터)
- AC-12 (non-admin token → HTTP 403)
- 기존 AC-1~8: 변경 없음.
#### Impacted Area Delta
- Modules added:
- `app/api/v1_assets.py` — GET /v1/assets 라우트를 portfolio 조회에서 asset catalog 조회로 재정의 (token_type 분기 제거, admin permission 검증 + `list_assets` 호출)
- `app/schemas/v1.py` — `AssetCatalogItem`, `AssetCatalogListResponse` 신규 schema
- Tests added/updated:
- `tests/test_asset_catalog.py` — GET /v1/assets AC-9~12 검증 신규 케이스 (기존 portfolio 조회 의미의 GET /v1/assets 테스트가 있다면 제거/대체)
- `tests/test_v1.py` — 기존 GET /v1/assets 호출 패턴이 portfolio 응답을 기대한다면 GET /v1/portfolios로 이전 또는 응답 schema 변경 반영
- Repository:
- `app/repositories/postgres.py` — `list_assets` 메서드가 이미 존재하면 재사용; 없으면 보강
#### Delivery Trace Delta
- Batches:
- BAT-002 (asset-catalog-api-completion) — augmentation 누적, verification 재실행 필요
- Releases:
- REL-001 — scope 잔존, 본 augmentation 포함 (`docs/releases/rel-001_20260521_v1-api-full-surface.md`)
#### Revalidation Impact
- Reverification Needed: yes
- Existing Implementation Invalidated: yes (기존 GET /v1/assets portfolio 조회 동작이 제거됨)
- Status Recommendation: revert-to-approved
- Follow-up Action: 구현 → pytest 회귀 → 로컬 smoke 재실행 → confirm-req-implemented 재진입
#### Validation Plan
- pytest로 AC-9~12 검증; 로컬 smoke로 admin session token + GET /v1/assets → HTTP 200 + asset catalog 응답 확인
### CHG-20260521-01
- Date: 2026-05-21
- Author: Justin Ko
#### Change Summary
- Status: Approved → Implemented
#### Intent
- BAT-002 confirm-batch-verification 완료. admin asset catalog CRUD CLI/HTTP API(POST/PATCH/deactivate), non-admin 403 모든 AC 검증 통과.
#### Acceptance Criteria Delta
- No change
#### Impacted Area Delta
- No change
#### Delivery Trace Delta
- Batches:
- BAT-002
- Releases:
- REL-001
#### Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: implemented
- Follow-up Action: none
### CHG-20260519-02
- Date: 2026-05-19
- Author: Justin Ko
@@ -1,6 +1,6 @@
# REQ-012: portfolio 생성 CLI catalog 검증
- Status: Approved
- Status: Implemented
- Type: Interface
- Priority: High
- Owner: Justin Ko
@@ -36,6 +36,34 @@
## Change Log
### CHG-20260521-01
- Date: 2026-05-21
- Author: Justin Ko
#### Change Summary
- Status: Approved → Implemented
#### Intent
- BAT-002 confirm-batch-verification 완료. pfhub portfolio create --asset-id/--symbol catalog 검증(존재·비활성 거부) 모든 AC 검증 통과.
#### Acceptance Criteria Delta
- No change
#### Impacted Area Delta
- No change
#### Delivery Trace Delta
- Batches:
- BAT-002
- Releases:
- REL-001
#### Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: implemented
- Follow-up Action: none
### CHG-20260519-02
- Date: 2026-05-19
- Author: Justin Ko
@@ -1,6 +1,6 @@
# REQ-016: client token 발급 경로 코드 폐지
- Status: Approved
- Status: Implemented
- Type: Interface
- Priority: High
- Owner: Justin Ko
@@ -40,6 +40,34 @@
## Change Log
### CHG-20260521-01
- Date: 2026-05-21
- Author: Justin Ko
#### Change Summary
- Status: Approved → Implemented
#### Intent
- BAT-006 confirm-batch-verification 완료. client token 발급 경로(POST /auth/tokens, issue_client_token) 코드 제거, HTTP 404 확인, token_type 게이트 회귀 없음 확인(AC-1/2/4). AC-3(release 직전 DATA-1 재확인)은 운영 릴리즈 단계에서 evidence 수집 예정.
#### Acceptance Criteria Delta
- No change
#### Impacted Area Delta
- No change
#### Delivery Trace Delta
- Batches:
- BAT-006
- Releases:
- REL-001
#### Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: implemented
- Follow-up Action: REL-001 배포 직전 DATA-1 SELECT COUNT 재확인(AC-3) evidence를 release execution evidence에 첨부
### CHG-20260520-02
- Date: 2026-05-20
- Author: Justin Ko
@@ -1,6 +1,6 @@
# REQ-018: POST /auth/service-tokens body daemon_id forward 보정
- Status: Approved
- Status: Implemented
- Type: Interface
- Priority: High
- Owner: Justin Ko
@@ -38,6 +38,34 @@
## Change Log
### CHG-20260521-01
- Date: 2026-05-21
- Author: Justin Ko
#### Change Summary
- Status: Approved → Implemented
#### Intent
- BAT-006 confirm-batch-verification 완료. POST /auth/service-tokens daemon_id forward 1-line 보정 구현. HTTP/CLI daemon binding 동등성, non-existing daemon 4xx 분기 모든 AC 검증 통과.
#### Acceptance Criteria Delta
- No change
#### Impacted Area Delta
- No change
#### Delivery Trace Delta
- Batches:
- BAT-006
- Releases:
- REL-001
#### Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: implemented
- Follow-up Action: none
### CHG-20260520-02
- Date: 2026-05-20
- Author: Justin Ko