Skip to content

[Feat] Discord Webhook 발송 트리거 추가 및 구조 개선 (#72)#73

Open
iamb0ttle wants to merge 7 commits intomainfrom
feat/discord-webhook-trigger-enhancement-and-structure-refactor
Open

[Feat] Discord Webhook 발송 트리거 추가 및 구조 개선 (#72)#73
iamb0ttle wants to merge 7 commits intomainfrom
feat/discord-webhook-trigger-enhancement-and-structure-refactor

Conversation

@iamb0ttle
Copy link
Copy Markdown
Member

@iamb0ttle iamb0ttle commented Apr 11, 2026

1. 개요

2. 작업 내용

  • app/services/webhook_notification.py에 공통 pipeline event 포맷을 추가하고, 서버/HTTP/작업 완료/콜백 실패 이벤트를 일관된 필드로 정리했습니다.
  • app/core/llm_router.py에 LLM 호출 성공, 실패, 재시도, fallback 성공/실패 웹훅을 추가해 모델 라우팅 흐름을 추적할 수 있게 했습니다.
  • 생성 파이프라인과 수정 파이프라인에 start / 중간 단계 / 완료 이벤트를 분리해 전송하도록 반영했습니다.
  • 작업 로그와 단계별 웹훅이 함께 남도록 정리하고, 웹훅 payload 포맷과 LLM 라우터 이벤트를 검증하는 테스트를 추가했습니다.

3. AI 활용 및 검증

  • AI가 생성한 코드 포함

  • 100% 직접 작성

  • 검증 방법:

    • git diff --check 통과 확인
    • 로컬에 uv/pytest 실행기가 없어 uv run pytest는 실행하지 못함
    • 웹훅 payload 형식과 라우터/파이프라인 트리거 테스트 파일 추가

4. 스크린샷 (선택)

  • 없음

5. 체크리스트

  • uv run pre-commit run --all-files를 실행하여 통과했는가?
  • 스스로 코드를 한 번 리뷰했는가? (AI가 짠 코드 맹신 금지)
  • 불필요한 주석이나 print 문을 제거했는가?

Summary by CodeRabbit

릴리스 노트

  • 새 기능

    • 파이프라인 이벤트 웹훅 알림 추가: 채팅, 생성, 로드맵 등 주요 처리 단계에서 실시간 웹훅 이벤트 알림 제공
    • 작업 진행 추적 개선: LLM 라우터, 의도 분석, 데이터 변경 등 세부 처리 단계별 상태 알림 기능 추가
  • 테스트

    • 웹훅 알림 시스템 및 파이프라인 통합에 대한 포괄적인 테스트 모음 추가

@iamb0ttle iamb0ttle self-assigned this Apr 11, 2026
@iamb0ttle iamb0ttle requested a review from zweadfx as a code owner April 11, 2026 11:56
@iamb0ttle iamb0ttle linked an issue Apr 11, 2026 that may be closed by this pull request
11 tasks
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2026

Warning

Rate limit exceeded

@iamb0ttle has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 20 minutes and 4 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 20 minutes and 4 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ebdd8820-7764-403f-b5c4-2e5800b08eaa

📥 Commits

Reviewing files that changed from the base of the PR and between b6acb46 and 3375caa.

📒 Files selected for processing (2)
  • app/core/llm_router.py
  • tests/test_llm_router_webhooks.py

워크스루

여러 서비스 및 그래프 노드에 걸쳐 웹훅 기반 파이프라인 이벤트 알림 시스템을 구현했습니다. 새로운 notify_pipeline_event()schedule_webhook() 헬퍼 함수를 도입하고 LLM 라우터, 채팅 노드, 로드맵 노드, 그리고 서비스 계층에 이벤트 방출을 통합했으며 종합적인 테스트를 추가했습니다.

변경 사항

코호트 / 파일 요약
코어 인프라
app/core/job_log_context.py, app/services/webhook_notification.py
get_current_job_id() 헬퍼를 추가하고 notify_pipeline_event(), schedule_webhook(), 색상/필드 포매팅 함수를 도입했으며 기존 알림 함수들을 새로운 파이프라인으로 리팩토링했습니다.
LLM 라우터 통합
app/core/llm_router.py
invoke/ainvoke에서 성공, 실패, 재시도, 폴백 결과에 대한 4가지 LLM 이벤트 유형(llm_call_success, llm_call_failed, llm_call_retry, llm_fallback_success/failed)을 동기/비동기 웹훅 함수로 방출합니다.
채팅 파이프라인 노드
app/graph/chat/nodes/analyze_intent.py, app/graph/chat/nodes/mutate.py, app/graph/chat/nodes/respond.py
의도 분석(라우팅/거부/파싱), 뮤테이션 완료, 응답 완료 단계에서 각각 웹훅 이벤트를 방출합니다.
로드맵 파이프라인 노드
app/graph/roadmap/nodes/finalize.py, app/graph/roadmap/nodes/places.py, app/graph/roadmap/nodes/skeleton.py
최종화, 장소 페칭, 스켈레톤 생성 단계에서 웹훅 알림을 추가합니다.
서비스 계층
app/services/chat_service.py, app/services/generate_service.py
process_chat_request()process_generate_request()에서 시작 및 완료 이벤트를 방출합니다.
테스트
tests/test_llm_router_webhooks.py, tests/test_pipeline_webhooks.py, tests/test_webhook_notification.py
LLM 라우터, 파이프라인 서비스/노드, 웹훅 알림 구성에 대한 새로운 테스트 모듈을 추가했습니다.

시퀀스 다이어그램

sequenceDiagram
    actor Service/Node as 서비스/노드
    participant notify as notify_pipeline_event()
    participant scheduler as schedule_webhook()
    participant discord as Discord 웹훅 API
    
    Service/Node->>notify: event_type, severity, stage, status 등
    notify->>notify: 임베드 페이로드 구성
    notify->>scheduler: 웹훅 코루틴 전달
    scheduler->>discord: await 또는 create_task()로 임베드 전송
    discord-->>scheduler: 성공/실패 응답
Loading

예상 코드 리뷰 노력

🎯 3 (Moderate) | ⏱️ ~25 분

관련 가능성이 있는 이슈

관련 가능성이 있는 PR

제안된 라벨

feature

제안된 리뷰어

  • zweadfx
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.81% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed 제목은 Discord Webhook 트리거 추가 및 구조 개선이라는 주요 변경사항을 명확하게 반영하고 있습니다.
Description check ✅ Passed PR 설명이 템플릿의 주요 섹션(개요, 작업 내용, AI 활용 및 검증, 체크리스트)을 포함하고 있으며 충분히 상세합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/discord-webhook-trigger-enhancement-and-structure-refactor

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/core/llm_router.py`:
- Around line 13-17: 현재 import 블록에서 동일 모듈을 여러 줄로 나눠 임포트하고 있으니
app.core.job_log_context의 append_job_log와 get_current_job_id를 단일 import로 병합하고,
다른 임포트들과 일관되게 정렬하세요; 즉 변경 대상은 append_job_log, get_current_job_id, get_logger,
get_timeout_policy, notify_pipeline_event, schedule_webhook를 포함하는 import 블록이며 동일
모듈의 중복 import를 하나로 합치고 (원하면 알파벳순으로 정렬) 불필요한 공백을 제거하세요.

In `@app/graph/chat/nodes/analyze_intent.py`:
- Around line 583-594: The code only emits chat_intent_routed for the
GENERAL_CHAT branch, so add the same _emit_intent_event call for the
non-GENERAL_CHAT routing path (e.g., the MODIFY_REQUEST/other intent_type
branch) before returning; ensure you call
_emit_intent_event("chat_intent_routed","info", route.intent_type, a suitable
message like "수정 요청으로 분류되었습니다." or the existing message, and include the same
metadata array with {"name":"Action","value":route.requested_action or
"N/A","inline":True} and {"name":"Scope","value":route.target_scope or
"N/A","inline":True}, then return the updated state with "intent_type":
route.intent_type so the routing event is always emitted (refer to
_emit_intent_event and where intent_type is set).

In `@tests/test_llm_router_webhooks.py`:
- Around line 24-25: The one-line list comprehension in _event_names is too long
and triggers E501; break it into multiple lines to satisfy line-length limits by
either converting the comprehension into an explicit for-loop that builds and
returns a list or by reformatting the list comprehension across lines with
surrounding parentheses (keep the function name _event_names and the inner
next(...) expression intact), ensuring the return annotation list[str] remains
and tests still receive the same list of event_type values.

In `@tests/test_pipeline_webhooks.py`:
- Around line 117-121: The long inline lambda passed to monkeypatch.setattr for
analyze_intent._classify_intent_route is exceeding the line-length lint (Ruff
E501); replace the single long lambda with a short named helper function (e.g.,
def _fake_classify_intent(*args, **kwargs): return
SimpleNamespace(intent_type="MODIFICATION", requested_action="ADD",
target_scope="ITEM")) or format the lambda across multiple lines so the line
length is under the limit, and update the monkeypatch.setattr calls that
reference analyze_intent._classify_intent_route (including the other similar
occurrences) to use the helper function or properly wrapped/line-broken lambda.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a9f92be7-ba0d-4656-91b2-7bb42bc88af0

📥 Commits

Reviewing files that changed from the base of the PR and between a69502b and b6acb46.

📒 Files selected for processing (14)
  • app/core/job_log_context.py
  • app/core/llm_router.py
  • app/graph/chat/nodes/analyze_intent.py
  • app/graph/chat/nodes/mutate.py
  • app/graph/chat/nodes/respond.py
  • app/graph/roadmap/nodes/finalize.py
  • app/graph/roadmap/nodes/places.py
  • app/graph/roadmap/nodes/skeleton.py
  • app/services/chat_service.py
  • app/services/generate_service.py
  • app/services/webhook_notification.py
  • tests/test_llm_router_webhooks.py
  • tests/test_pipeline_webhooks.py
  • tests/test_webhook_notification.py

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.

[Feat] Discord Webhook 발송 트리거 추가 및 구조 개선

1 participant