Files
portfolio-hub/docs/batches/bat-001_20260502_trex-basic-v1-api-contract/index.md
T
genichin 829629fa8f feat: implement portfolio UUID migration and v1 API finalization (BAT-006, BAT-001 re-verified)
Core Changes:
- Migrate portfolio_id from string to UUID in schema and repository layer
- Update portfolio CLI commands to use name+user combination for identification
- Update HTTP API to accept portfolio_id as UUID path parameter
- Implement portfolio ownership validation in repository queries

Requirements Completed (REQ-016 to REQ-019):
- REQ-016: portfolios table UUID schema migration with data migration script
- REQ-017: CLI portfolio commands with name+user identification
- REQ-018: HTTP API portfolio path parameters and v1 asset_id UUID returns
- REQ-019: Portfolio UUID baseline documentation updates

BAT-001 Re-verification:
- REQ-004~010 marked as Implemented after verification evidence validation
- All v1 API endpoints verified with comprehensive test coverage

Documentation Updates:
- Update data-model.md with portfolio UUID structure
- Update interface-contract.md with UUID path parameters
- Update runtime-flows.md with ownership-based resolution flows
- Update project-structure.md with database layer changes
- Add migration script for portfolio UUID transition

Testing:
- Add test_portfolio_uuid.py for migration validation
- Update test_cli.py and test_portfolio_ownership.py for ownership checks
2026-05-11 09:27:57 +00:00

68 lines
2.8 KiB
Markdown

# BAT-001 Index
- Status: release-candidate
- Batch: BAT-001
- Profile: standard
- Created: 2026-05-02
## Included REQ
| REQ | 제목 | Type | Priority |
|-----|------|------|----------|
| REQ-004 | GET /health 응답 스키마 확장 | Interface | High |
| REQ-005 | service-token 발급 시 runtime_id 동시 생성 | Interface | High |
| REQ-006 | GET /v1/assets 엔드포인트 구현 | Interface | High |
| REQ-007 | GET /v1/user_info 엔드포인트 구현 | Interface | High |
| REQ-008 | POST /v1/assets/{asset_id}/ledger/trades 구현 | Interface | High |
| REQ-009 | v1 API DB 스키마 migration 추가 | Migration | High |
| REQ-010 | credential_payload Fernet 암호화 및 startup validation | Non-Functional | High |
## Source Discovery
- dcy-002: trex-basic Consumer-Driven Contract 반영
## Scope Summary
- GET /health 응답 확장 (service, version, checked_at 필드 추가)
- service-token 발급 시 runtime_id UUID v4 동시 생성 및 auth_tokens 저장
- GET /v1/assets 엔드포인트 신규 구현 (portfolio → asset 뷰 변환)
- GET /v1/user_info 엔드포인트 신규 구현 (runtime_id, trading_enabled, brokers[] 복호화 반환)
- POST /v1/assets/{asset_id}/ledger/trades 엔드포인트 신규 구현 (idempotent 체결 기록)
- Alembic migration: portfolios.market 컬럼, auth_tokens.runtime_id 컬럼, broker_credentials 테이블, ledger_trades 테이블 추가
- Fernet 암복호화 유틸리티 신규 구현 및 startup validation
## Impacted Area
- Docs: docs/project-structure.md, docs/runtime-flows.md (design 완료 후 갱신)
- Modules:
- app/api/health.py (수정)
- app/api/auth_routes.py (수정)
- app/api/v1_assets.py (신규)
- app/api/v1_user_info.py (신규)
- app/api/v1_ledger.py (신규)
- app/main.py (수정: /v1 라우터 등록)
- app/cli/commands/service_tokens.py (수정)
- app/core/config.py (수정: CREDENTIAL_ENCRYPTION_KEY 추가)
- app/core/encryption.py (신규: Fernet 유틸리티)
- app/domain/models.py (수정: AuthToken.runtime_id, BrokerCredential, LedgerTrade 추가)
- app/services/auth_service.py (수정)
- app/services/ (신규 서비스 메서드)
- app/schemas/ (신규 v1 스키마)
- app/repositories/postgres.py (수정: 신규 테이블 쿼리)
- migrations/versions/ (신규 migration 파일)
- Tests:
- tests/test_app.py 또는 tests/test_health.py (신규/확장)
- tests/test_auth.py (확장)
- tests/test_v1_assets.py (신규)
- tests/test_v1_user_info.py (신규)
- tests/test_v1_ledger.py (신규)
## Stage Documents
| Stage | File | Status |
|-------|------|--------|
| Planning | [planning.md](./planning.md) | confirmed |
| Design | [design.md](./design.md) | confirmed |
| Implementation | [implementation.md](./implementation.md) | completed |
| Verification | [verification.md](./verification.md) | re-verified |