Skip to content

feat: AI Runtime HTTP 연결과 장애 격리 구현 - #56

Draft
hywznn wants to merge 5 commits into
mainfrom
agent/8-ai-runtime-http
Draft

feat: AI Runtime HTTP 연결과 장애 격리 구현#56
hywznn wants to merge 5 commits into
mainfrom
agent/8-ai-runtime-http

Conversation

@hywznn

@hywznn hywznn commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

연결 이슈

Refs #8

왜 필요한가요?

기존 구현은 Server가 AI Runtime에 보낼 수 있는 비식별 계약과 응답 검증까지만 제공했습니다.
실제 배포 환경에서 fowoco/ai를 안전하게 호출하려면 서비스 간 인증, 제한시간, 장애 격리,
응답 크기 제한과 안정적인 실패 분류가 추가로 필요합니다.

현재 fowoco/ai에는 /internal/v1/analyses 원본 계약이 아직 release되지 않았으므로,
통합 기능은 기본 비활성화하고 설정을 명시적으로 켠 환경에서만 호출하도록 했습니다.

무엇이 바뀌나요?

  • Provider 중립적인 AiRuntimeClient 뒤에 RemoteAiRuntimeClient를 추가했습니다.
  • ADR-0002에 맞춰 Authorization: Bearer <service-credential>, X-Request-Id, 선택적 W3C
    traceparent를 전달합니다.
  • 요청의 deadlineMs와 Server 상한 중 더 짧은 전체 deadline을 적용합니다.
  • fail-fast 동시 호출 제한(bulkhead)과 연속 장애 circuit breaker를 적용합니다.
  • 응답을 모두 메모리에 쌓기 전에 크기 제한을 적용하고, camelCase 전용 strict JSON mapper로
    알 수 없는 필드를 거부합니다.
  • HTTP·timeout·parsing·인증·rate limit 오류를 안전한 AiRuntimeFailureCode로 분류합니다.
  • 자동 HTTP retry는 하지 않습니다. 재시도는 #24가 새 AiAttempt를 기록한 뒤 명시적으로
    수행해야 합니다.
  • 미설정 환경에서는 DisabledAiRuntimeClientRUNTIME_DISABLED로 안전하게 실패합니다.

설정

  • 기본값: AI_RUNTIME_ENABLED=false
  • 통합 환경: AI_RUNTIME_ENDPOINT, AI_RUNTIME_SERVICE_CREDENTIAL을 배포 Secret으로 주입
  • 세부 timeout, 응답 크기, 동시 호출 수, circuit breaker 설정을 .env.example에 문서화

검증

  • ./gradlew test --tests 'com.fowoco.server.aiintegration.*'
  • ./gradlew test
  • WireMock으로 인증·추적 헤더, camelCase body, strict JSON, 1회 호출, timeout,
    oversized response, bulkhead, circuit breaker를 검증했습니다.

이번 PR에 포함하지 않은 것

리뷰 포인트

  1. AiRuntimeFailureCode 분류가 #24에서 저장할 진단값으로 충분한지
  2. 기본 비활성화와 환경 Secret 주입 방식이 데모 배포 환경에 맞는지
  3. timeout·bulkhead·circuit breaker 기본값이 현재 예상 트래픽에 적절한지
  4. camelCase 계약을 fowoco/ai 원본 계약으로 확정해도 되는지

hywznn added 3 commits July 26, 2026 20:47
표준 Bearer 인증과 요청 추적 헤더를 사용해 versioned internal API를 정확히 한 번 호출합니다.

기본 비활성화 설정, 전체 deadline, 동시 호출 제한, circuit breaker, 응답 크기 및 JSON 검증을 추가합니다.
WireMock standalone으로 인증·추적 헤더, camelCase 요청, strict JSON 응답을 검증합니다.

자동 재시도 금지, deadline, 응답 크기, bulkhead와 circuit breaker 동작을 함께 확인합니다.
초보자도 설정과 장애 코드를 이해할 수 있도록 기본 비활성화 이유, 배포 순서, 오류별 대응을 문서화합니다.

ADR에 맞춰 표준 Authorization Bearer 인증과 요청 추적 규칙을 명시합니다.
@hywznn
hywznn requested review from chaeliki and krestar July 26, 2026 15:24
@hywznn hywznn added area:server Spring Boot API·도메인·DB·tenant·Task Workflow 영역; Prompt·모델·Provider 구현 제외 area:ai-integration Server ↔ AI Runtime 내부 계약·Client·검증·trace 연동 영역; Prompt·모델·Provider 구현은 ai 저장소 소유 priority:P0 MVP 진행을 막는 최우선 핵심 작업 status:in-review 구현을 마치고 리뷰 또는 병합을 기다리는 작업 security:privacy 개인정보·접근권한·토큰·보안 영향이 있는 작업 type:integration 외부 LLM·DB·스토리지 등 시스템 간 연동 작업 labels Jul 26, 2026
AI 후보가 요청에 포함된 stay_expiry_date를 다른 값으로 바꾸면 CORE_VALUE_MISMATCH로 거부합니다.
@hywznn hywznn closed this Jul 27, 2026
@hywznn hywznn reopened this Jul 27, 2026
@hywznn
hywznn marked this pull request as draft July 27, 2026 23:37

@krestar krestar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

408 타임아웃이 INVALID_REQUEST_CONTRACT로 처리되는걸로 보이는데, 문제 없을 것 같으면 나머지 리뷰 포인트 2~4번은 적절해보여서 PR 내용 괜찮아 보입니다

);
}

private AiRuntimeCallException classifyStatus(int status) {

@krestar krestar Jul 28, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

408도 따로 처리 안해도 괜찮으려나요

@hywznn hywznn changed the title [AI Integration] AI Runtime HTTP 연결과 장애 격리 구현 feat: AI Runtime HTTP 연결과 장애 격리 구현 Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai-integration Server ↔ AI Runtime 내부 계약·Client·검증·trace 연동 영역; Prompt·모델·Provider 구현은 ai 저장소 소유 area:server Spring Boot API·도메인·DB·tenant·Task Workflow 영역; Prompt·모델·Provider 구현 제외 priority:P0 MVP 진행을 막는 최우선 핵심 작업 security:privacy 개인정보·접근권한·토큰·보안 영향이 있는 작업 status:in-review 구현을 마치고 리뷰 또는 병합을 기다리는 작업 type:integration 외부 LLM·DB·스토리지 등 시스템 간 연동 작업

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants