# BAT-005 Implementation Log - Status: completed - Batch: BAT-005 - Profile: batch-lite - Completed: 2026-05-03 ## 구현 내역 ### 1. `app/repositories/postgres.py` — `delete_broker_credential` 추가 ```python def delete_broker_credential(self, user_id: str, broker: str) -> bool: with self._connect().cursor() as cur: cur.execute( "DELETE FROM broker_credentials WHERE user_id = %s AND broker = %s", (user_id, broker), ) return cur.rowcount > 0 ``` ### 2. `app/cli/commands/credential.py` — 신규 생성 - `credential_app = typer.Typer(help="Broker credential management commands.")` - `_with_service(ctx, callback)`: repository 생성 → execute_command → finally close. RuntimeError도 캐치해 stdout 출력 후 exit 1. - `set` 명령: `--user`, `--broker` (기본값 `kis`), `--account-ref`, `--app-key`, `--app-secret`, `--force` - `list` 명령: `--user` — encrypted_payload 제외 dict 리스트 출력 - `remove` 명령: `--user`, `--broker`, `--force` — delete_broker_credential 호출 ### 3. `app/cli/main.py` — `credential_app` 등록 ```python from app.cli.commands.credential import credential_app ... app.add_typer(credential_app, name="credential") ``` ### 4. `tests/test_cli.py` - `FakeRepo.__init__`: `_broker_credentials: dict[tuple[str, str], BrokerCredential] = {}` 추가 - `FakeRepo.upsert/list/get/delete_broker_credential` 메서드 추가 - `_settings_with_enc_key()`, `build_runner_with_enc_key()` 헬퍼 추가 - 신규 테스트 5개 추가 ### 5. `docs/project-structure.md` — CLI 모듈 목록 갱신 - `app/cli/` 섹션에 `credential` 명령 그룹 추가 - primary runtime 설명에 `broker credentials` 추가 ## 설계 결정 - dict 리스트 출력은 `render_output`의 타입 매칭을 우회해 `console.print(item)` 직접 호출 (기존 render_output이 등록된 타입만 처리함) - `RuntimeError`(`CREDENTIAL_ENCRYPTION_KEY` 미설정)는 `_with_service` 헬퍼에서 캐치해 stdout으로 출력 후 exit 1 처리