Core Implementation (BAT-010):
- Add daemon registry schema and CRUD operations (req-023)
- Implement single-daemon asset assignment constraint (one asset per daemon)
- Add daemon_id field to service_token for daemon identification
- Add daemon.py CLI module for daemon management commands
- Add 20260513_0016_daemon_model.py migration for daemon tables
API Changes:
- GET /v1/assets: include daemon_id in AssetResponse
- POST /v1/assets/{asset_id}/ledger/trades: require daemon token binding
- GET /v1/user_info: include daemon metadata
- Enhanced service-token rotate to preserve daemon bindings
CLI Commands:
- pfhub daemon register --name <name> --runtime-id <runtime-id>
- pfhub daemon list
- pfhub daemon get <daemon-id>
- pfhub daemon revoke <daemon-id>
Requirements (REQ-023, REQ-028):
- REQ-023: Daemon Registry and Service Token Daemon Binding (Interface, Approved)
* AC-1: daemon CRUD operations
* AC-2: service token daemon binding for POST /v1/assets/{asset_id}/ledger/trades
* AC-3: single daemon per asset (exact-one assignment model)
- REQ-028: README.md Daemon Provisioning Runbook update (Documentation, Approved)
Documentation:
- Add dcy-006 Discovery for daemon-id and single-daemon asset assignment
- Update README.md with Daemon Provisioning Runbook section
- Add BAT-010 batch documentation with planning, implementation, verification
- Update rel-006 release document (daemon model implementation)
- Update data-model.md with daemon and daemon_asset_assignment tables
- Update interface-contract.md with daemon registry APIs
- Update runtime-flows.md with daemon lifecycle flows
Breaking Changes:
- REQ-005~009, REQ-011~012 status reverted to Approved due to revised contract
* daemon_id field addition and exact-one asset assignment requirement
* Existing Implemented evidence invalidated by contract revision
* BAT-001/002/008 re-verification required
Testing:
- Add test_daemon_registry.py for daemon CRUD operations
- Add test_daemon_assignment.py for single-asset assignment constraints
- Update test_auth.py, test_cli.py, test_v1.py for daemon support
- Verify daemon token binding in trade endpoint authorization
Impact:
- Database: 2 new tables (daemons, daemon_asset_assignments)
- Migration: 20260513_0016 creates daemon model schema
- CLI: 4 new daemon subcommands
- API: daemon_id propagation through v1 endpoints
- Verification: BAT-001/002/008 re-verification gates next release
8.0 KiB
8.0 KiB
req-007: GET /v1/user_info 엔드포인트 구현
- Status: Approved
- Type: Interface
- Priority: High
- Owner: repository-maintainers
Intent
- trex-basic 데몬이 사용자 거래 가능 여부와 브로커 인증 정보를 조회할 수 있도록 한다.
runtime_id는 인증 service-token의 런타임 세대 식별자이고,daemon_id는 stable logical identity로 함께 반환되어야 한다.- credential_payload는 DB에서 Fernet 복호화 후 반환한다(NFR-3/REQ-010 의존).
Requirement
- GET /v1/user_info는 service-token bearer 인증으로
runtime_id,daemon_id,trading_enabled(users.is_active 매핑),disabled_reason,brokers[](broker, account_ref, credential_payload, credential_version, last_rotated_at)를 반환해야 한다. - environment 필드를 응답에 포함하지 않는다.
- credential_payload는 Fernet으로 복호화된 JSON을 반환한다.
- transition 구간의 legacy token은
daemon_id = null을 진단용으로 반환할 수 있어야 하며,runtime_id가 없는 구형 token 처리 규칙은 기존 v1 contract를 유지한다.
Acceptance Criteria
- Given
runtime_id가 연결된 service-token으로GET /v1/user_info호출 시, Then HTTP 200과 응답 JSON에runtime_id,daemon_id,trading_enabled,brokers[]필드가 포함되어야 한다. - Given GET /v1/user_info 응답을 확인하면, Then environment 필드가 존재하지 않아야 한다.
- Given users.is_active가 true인 사용자의 service-token으로 호출 시, Then 응답의 trading_enabled가 true여야 한다.
- Given users.is_active가 false인 사용자의 service-token으로 호출 시, Then 응답의 trading_enabled가 false여야 한다.
- Given broker_credentials에 KIS credential이 저장된 사용자의 토큰으로 호출 시, When 응답의 brokers[] 항목을 확인하면, Then credential_payload가 복호화된 JSON({app_key, app_secret})으로 반환되어야 한다.
- Given runtime_id가 없는 구형 service-token으로 호출 시, Then 설계 단계에서 확정된 오류 응답이 반환되어야 한다(R-4, 404 또는 즉시 runtime_id 생성 중 선택).
- Given 인증 없이 요청 시, Then HTTP 401이 반환되어야 한다.
- Given
daemon_id = NULL로 backfill된 legacy service-token으로 호출 시, Then HTTP 200 응답이 유지되고daemon_id필드는null로 노출되어야 한다.
Impacted Area
- Docs: docs/interface-contract.md (REQ-011에서 갱신 예정), docs/data-model.md (REQ-011에서 갱신 예정)
- Modules: app/api/v1_user_info.py, app/schemas/v1.py, app/core/auth.py, app/domain/models.py, app/services/, app/repositories/postgres.py, app/main.py
- Tests: tests/test_v1.py, tests/test_auth.py
Notes
- trading_enabled는 users.is_active 단순 매핑이다(A-4 Confirmed). 별도 trading 전용 상태 필드는 이번 반복 Out of Scope.
- disabled_reason: trading_enabled가 false일 때 이유 문자열. 이번 반복에서는 is_active가 false인 경우 "account_inactive" 고정값을 사용하는 방안을 설계 단계에서 확정한다.
daemon_id = NULLlegacy token은 transition diagnostics 대상으로 허용되지만, daemon-scoped read/write endpoint에서는 fail-closed가 적용된다.- R-4(기존 service-token에 runtime_id 없는 경우 처리): 404 또는 즉시 생성 중 설계 단계에서 결정. 이 REQ의 Acceptance Criteria 6번은 runtime_id 부재 처리 규칙에 한해 유지한다.
- Fernet 복호화는 REQ-010에서 정의한 암호화 유틸리티를 사용한다.
- Source Discovery: dcy-002 (FR-4, NFR-1, A-4), dcy-006 (FR-1, FR-5, NFR-1)
Change Log
CHG-20260513-01
- Date: 2026-05-13
- Author: repository-maintainers
Change Summary
/v1/user_info응답 요구사항에 stabledaemon_iddiagnostics를 추가하고, runtime_id-only 구현 증거를 무효화하여 Status를 Approved로 되돌림
Intent
- dcy-006은
/v1/user_info를 runtime 세대 식별과 daemon binding diagnostics를 함께 제공하는 endpoint로 재정의한다. 현재 구현/verification은runtime_id만 기준으로 삼아 revised contract를 충족하지 못한다.
Acceptance Criteria Delta
- Added:
- AC-8: legacy token의
daemon_id = nulldiagnostics
- AC-8: legacy token의
- Updated:
- AC-1: 응답 필수 필드에
daemon_id추가
- AC-1: 응답 필수 필드에
- Removed:
- none
Impacted Area Delta
- Docs:
docs/interface-contract.md,docs/data-model.md,docs/runtime-flows.md
- Modules:
app/api/v1_user_info.py,app/schemas/v1.py,app/core/auth.py,app/repositories/postgres.py
- Tests:
tests/test_v1.py,tests/test_auth.py
Delivery Trace Delta
- Batches:
- BAT-001 (release-candidate; REL-001 released input) —
/v1/user_infoevidence를 daemon diagnostics 기준으로 재검증해야 함
- BAT-001 (release-candidate; REL-001 released input) —
- Releases:
- REL-001 (released) — released smoke는
runtime_id만 확인했으므로 revised REQ 충족 증거로 재사용 불가
- REL-001 (released) — released smoke는
Revalidation Impact
- Reverification Needed: yes
- Existing Implementation Invalidated: yes
- Status Recommendation: rollback-to-approved
- Follow-up Action: dcy-006 후속 batch에서
daemon_idschema/API contract와 legacy diagnostic behavior를 구현한다.
Validation Plan
app/api/v1_user_info.py,app/schemas/v1.py현재 구현에daemon_id가 없는지 코드 리뷰로 확인한다.- 구현 후 daemon-bound token, legacy daemon-less token, runtime_id-missing token 시나리오를 분리해 targeted pytest를 추가한다.
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~7 모두 PASS. Blocking Issues 없음.
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~7 evidence 연결 확인 완료
CHG-20260502-02
- Date: 2026-05-02
- Author: repository-maintainers
Change Summary
- REQ-007 confirm-req 승인 전환 (Status: Proposed → Approved)
Intent
- 필수 필드(Status, Type, Priority, Owner, Intent, Requirement, Acceptance Criteria 7개, Impacted Area, Change Log) 모두 충족 확인 후 승인
- 설계 의존성 주의: AC #6(runtime_id 없는 구형 토큰 R-4 처리: 404 또는 즉시 생성)은 설계 단계에서 확정 필요. 핵심 Requirement가 명확하고 Notes에 명시적으로 deferred 처리됨 — 승인 게이트 통과 판단.
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. 설계 단계에서 R-4 처리 방식 확정 후 AC #6 구체화.
CHG-20260502-01
- Date: 2026-05-02
- Author: repository-maintainers
Change Summary
- REQ-007 최초 생성 (source Discovery: dcy-002 FR-4)
Intent
- trex-basic Consumer-Driven Contract의 GET /v1/user_info 요구사항을 REQ backlog로 정규화
Acceptance Criteria Delta
- Added:
- 전체 Acceptance Criteria 신규 작성
Impacted Area Delta
- Docs:
- docs/interface-contract.md (REQ-011에서 갱신 예정)
- Modules:
- app/api/v1_user_info.py 신규
- app/domain/models.py BrokerCredential 추가
- Tests:
- tests/test_v1_user_info.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(broker_credentials 테이블), REQ-010(Fernet 암호화), REQ-005(runtime_id)와 함께 delivery 단위 구성 권장.