Skip to content

feat(wizard): /setup — 비개발자용 DSN 없는 DB 연결 flow#230

Merged
seyoung4503 merged 2 commits into
masterfrom
feat/setup-wizard
May 30, 2026
Merged

feat(wizard): /setup — 비개발자용 DSN 없는 DB 연결 flow#230
seyoung4503 merged 2 commits into
masterfrom
feat/setup-wizard

Conversation

@seyoung4503
Copy link
Copy Markdown
Collaborator

무엇

비개발자가 DSN/터미널을 한 번도 안 보고 Discord 안에서 DB 연결 완료할 수 있게 하는 `/setup` 슬래시 명령. 드롭다운 → 폼 → 연결 테스트 → 암호화 저장. 그 길드의 다음 메시지부터 그 DB 자동 사용.

v4.1 plan은 "Discord 1급 frontend"인데 `/connect `은 개발자 워크플로우임. 비개발자는 DSN 모름. 폼 UX가 진짜 사용성.

흐름

```
/setup
→ "데이터베이스 종류를 골라주세요" (드롭다운, 6종)
→ "Connect to PostgreSQL" 폼 (host/port/db/user/password)
→ 제출 → 🔌 연결 테스트 → "✅ PostgreSQL 연결 성공! 테이블 12개 발견."
```
DSN을 한 번도 안 봄. 비밀번호는 Fernet으로 암호화 저장 (`EncryptedSecrets`).

포함

  • `adapters/db/dsn_builder.py` — 폼 필드 → DSN/extras 조립 (Postgres/MySQL/Snowflake/BigQuery/DuckDB/D1). 비밀번호 URL-encode, `FIELD_SCHEMA`로 폼 메타데이터 노출. 순수 함수.
  • `adapters/db/factory.py` — `build_explorer(extras=...)` 지원, D1 토큰을 URL 밖에서 받아 D1Explorer에 주입.
  • `frontends/discord/setup_wizard.py` — `discord.ui` Modal + Select. ephemeral.
  • `frontends/discord/commands.py: register_db_for_guild` — DSN 조립 → 연결 테스트(`list_tables`) → 성공 시 EncryptedSecrets에 길드 scope로 암호화 저장 → scope 캐시 무효화. 친절한 에러(드라이버 미설치/연결실패).
  • `frontends/discord/bot.py` — `/setup` 슬래시 명령 등록.
  • `tenancy/concierge.py` — per-scope explorer 캐시 + DSN 라우팅. build_context가 guild scope의 `db_dsn`(+`d1_token`)을 읽어 explorer 동적 생성/캐시. `forget_explorer(scope)`로 cache bust.

아키텍처 원칙

discord.py는 `bot.py`/`setup_wizard.py`에만. 로직(`register_db_for_guild`, `dsn_builder`)은 discord.py 비의존 순수층 → 유닛테스트 가능.

검증

  • 106개 테스트 통과 (93 + 13 신규)
  • dsn_builder 폼→DSN 조립 (특수문자 URL-encode 포함)
  • 드라이버 미설치 시 친절한 에러 (`uv sync --extra snowflake`)
  • per-scope DSN 라우팅 (길드별로 다른 explorer 사용)
  • D1 토큰 extras를 secrets로 분리 저장/주입
  • forget_explorer cache bust
  • 위저드 import는 토큰 없이 OK
  • 라이브: 실제 Discord 테스트 서버에 `/setup` 등록 확인

🤖 Generated with Claude Code

비개발자가 DSN/터미널 안 보고 Discord 안에서 DB 연결 완료.

- adapters/db/dsn_builder.py: 폼 필드 → DSN/extras 조립 (PostgreSQL/MySQL/
  Snowflake/BigQuery/DuckDB/D1). 비밀번호 URL-encode, FIELD_SCHEMA로 폼
  메타데이터 노출. 순수 함수, 테스트 용이.
- adapters/db/factory.py: build_explorer(extras=...) 지원, D1 토큰을 URL
  밖에서 받아 D1Explorer에 주입.
- frontends/discord/setup_wizard.py: discord.ui Modal + Select. /setup →
  드롭다운(DB 종류) → 종류별 폼(5필드 이내) → submit. ephemeral.
- frontends/discord/commands.py: register_db_for_guild(identity, db_type,
  fields) — DSN 조립 → 연결 테스트(list_tables) → EncryptedSecrets 저장 →
  scope 캐시 무효화. 친절한 에러(드라이버 미설치/연결실패).
- frontends/discord/bot.py: /setup 슬래시 명령 등록.
- tenancy/concierge.py: per-scope explorer 캐시 + DSN 라우팅.
  build_context가 guild scope의 db_dsn(+d1_token)을 읽어 explorer 동적
  생성/캐시. forget_explorer(scope)로 cache bust.

검증: 106 테스트 통과(93+13), 위저드 import 토큰 없이 OK.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@seyoung4503 seyoung4503 changed the base branch from feat/db-explorer-adapters to master May 30, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant