Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ public class ChatServiceImpl implements ChatService {
@Value("${proovy.ai.host}")
private String proovyAiHost;

// 지원되는 기능 목록 (향후 확장 가능)
// 지원되는 기능 목록 - DB toolCode(대문자)와 AI feature명(PascalCase) 모두 허용
private static final Set<String> SUPPORTED_FEATURES = Set.of(
"Solve", "Check", "Explain", "Variant", "Practice"
"Solve", "Check", "Explain", "Variant", "Practice",
"Solution", "SOLUTION",
"VARIATION",
"GRAPH", "CreateGraph"
);
Comment on lines +70 to 76
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Search for VARIATION, VARIANT patterns and related feature code
rg -n --type=java 'VARIATION|VARIANT' -B2 -A2

Repository: Team-Proovy/Proovy-server

Length of output: 1794


🏁 Script executed:

# Look at the ChatServiceImpl file around the SUPPORTED_FEATURES
sed -n '65,85p' src/main/java/com/proovy/domain/conversation/service/ChatServiceImpl.java

Repository: Team-Proovy/Proovy-server

Length of output: 915


🏁 Script executed:

# Check how validateFeatures and credit deduction use SUPPORTED_FEATURES
rg -n --type=java 'validateFeatures|SUPPORTED_FEATURES' src/main/java/com/proovy/domain/conversation/service/ChatServiceImpl.java -B1 -A3

Repository: Team-Proovy/Proovy-server

Length of output: 876


🏁 Script executed:

# Search for toolCode references in entity definitions or migrations
find . -type f \( -name "*.java" -o -name "*.sql" \) | xargs rg -l 'toolCode|TOOL_CODE' 2>/dev/null | head -20

Repository: Team-Proovy/Proovy-server

Length of output: 901


🏁 Script executed:

# Check Tool entity definition
cat src/main/java/com/proovy/global/tool/entity/Tool.java

Repository: Team-Proovy/Proovy-server

Length of output: 1775


🏁 Script executed:

# Check the full ToolDataInitializer to see all tool initializations
cat src/main/java/com/proovy/global/tool/config/ToolDataInitializer.java

Repository: Team-Proovy/Proovy-server

Length of output: 2117


🏁 Script executed:

# Search for all toolCode initializations to see the complete list
rg -n 'toolCode\(' src/main/java/com/proovy/global/tool/config/ToolDataInitializer.java -B1 -A1

Repository: Team-Proovy/Proovy-server

Length of output: 457


🏁 Script executed:

# Check if there are migrations that define toolCode values
find . -type f -name "*.sql" | xargs rg 'SOLVE|CHECK|EXPLAIN|VARIANT|PRACTICE|SOLUTION|GRAPH' 2>/dev/null | head -30

Repository: Team-Proovy/Proovy-server

Length of output: 51


🏁 Script executed:

# Check how features are used in credit deduction and feature validation
sed -n '280,310p' src/main/java/com/proovy/domain/conversation/service/ChatServiceImpl.java

Repository: Team-Proovy/Proovy-server

Length of output: 1836


🏁 Script executed:

# Search for where feature names map to tools/toolCodes
rg -n 'featureName|chosenFeatures' src/main/java/com/proovy/domain/conversation/service/ChatServiceImpl.java -B2 -A2

Repository: Team-Proovy/Proovy-server

Length of output: 673


🏁 Script executed:

# Check if there's any normalization or conversion between feature names and toolCodes
rg -n 'toLowerCase|toUpperCase|normalize' src/main/java/com/proovy/domain/conversation/service/ChatServiceImpl.java

Repository: Team-Proovy/Proovy-server

Length of output: 51


🏁 Script executed:

# Look for the AI router or feature name conversion logic
rg -n 'Solve|Check|Explain|Variant|Practice' src/main/java/com/proovy/domain/conversation/service/ChatServiceImpl.java

Repository: Team-Proovy/Proovy-server

Length of output: 135


🏁 Script executed:

# Search for AI feature mapping or conversion logic
rg -n '"Solve"|"Check"|"Explain"|"Variant"|"Practice"' --type=java -B2 -A2

Repository: Team-Proovy/Proovy-server

Length of output: 4339


🏁 Script executed:

# Check if there are any tests or documentation about supported features
find . -type f \( -name "*Test.java" -o -name "*.md" \) | xargs rg -l 'SUPPORTED_FEATURES|feature' 2>/dev/null | head -10

Repository: Team-Proovy/Proovy-server

Length of output: 51


🏁 Script executed:

# Look at the complete MessageTool entity to understand tool usage
cat src/main/java/com/proovy/domain/conversation/entity/MessageTool.java

Repository: Team-Proovy/Proovy-server

Length of output: 832


🏁 Script executed:

# Check if there are any other places where features are validated or mapped
rg -n 'validateFeatures|chosenFeatures' --type=java -B3 -A3

Repository: Team-Proovy/Proovy-server

Length of output: 4366


🏁 Script executed:

# Check CreditUseService to see how it looks up feature cost
sed -n '25,50p' src/main/java/com/proovy/domain/credit/service/CreditUseService.java

Repository: Team-Proovy/Proovy-server

Length of output: 770


🏁 Script executed:

# Search for where the feature name gets passed to credit service and how it's handled
rg -n 'getFeatureCost|FEATURE_BASE_COST' src/main/java/com/proovy/domain/credit/service/CreditUseService.java -B2 -A5

Repository: Team-Proovy/Proovy-server

Length of output: 1241


🏁 Script executed:

# Check if there's any normalization when passing feature to credit service
sed -n '285,310p' src/main/java/com/proovy/domain/conversation/service/ChatServiceImpl.java

Repository: Team-Proovy/Proovy-server

Length of output: 1508


🏁 Script executed:

# Look at how "Practice" feature is handled (it's in SUPPORTED_FEATURES but not in some mappings)
rg -n 'Practice' --type=java

Repository: Team-Proovy/Proovy-server

Length of output: 209


대문자 기능명의 크레딧 차감 비용 매핑 누락

현재 코드는 "SOLUTION", "VARIATION", "GRAPH" 같은 대문자 기능명을 SUPPORTED_FEATURES에 추가했으나, 이들 기능이 실제로 크레딧 차감 시 비용 매핑에서 빠져 있습니다.

문제 상황:

  1. 대문자 기능명 비용 매핑 누락

    • 클라이언트가 "SOLUTION" 전송 → 검증 통과 ✓
    • 크레딧 차감 시 CreditUseService.useCredit() 호출 (line 293)
    • FEATURE_BASE_COST 맵에는 "Solution"만 있고 "SOLUTION"은 없음
    • getOrDefault() 호출로 기본값 5 크레딧으로 처리 (line 161, silent fallback)
    • 실제 비용("Solution": 20 크레딧)과 다른 금액 차감
  2. "Practice" 기능의 비용 매핑 누락

    • SUPPORTED_FEATURES"Practice"가 있음 (line 72)
    • FEATURE_BASE_COST에는 없음 (line 28-34)
    • "Practice" 기능 사용 시 기본값 5 크레딧으로 차감
  3. DB 도구 불일치

    • ToolDataInitializer는 3개 도구만 생성: GRAPH, SOLUTION, VARIATION
    • "Solve", "Check", "Explain", "Variant", "Practice"는 DB 도구 등록 없음

수정 방법:

대문자 기능명이 Spring 검증 단계에서 도착하면, 크레딧 차감 전에 정규화된 형태로 변환하거나, FEATURE_BASE_COST에 모든 기능명 변형(대문자 포함)을 추가하세요.

private static final Map<String, Integer> FEATURE_BASE_COST = Map.of(
        "Solve", 10,
        "Explain", 5,
        "CreateGraph", 5,
        "Variant", 5,
        "Solution", 20,
        "Check", 3,
+       "SOLUTION", 20,
+       "VARIATION", 5,
+       "GRAPH", 5,
+       "Practice", 5  // 누락된 기능
);

또는 검증 후 정규화: feature.toLowerCase() 또는 case-insensitive 비용 조회 로직 추가.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/com/proovy/domain/conversation/service/ChatServiceImpl.java`
around lines 70 - 76, SUPPORTED_FEATURES contains uppercase variants
("SOLUTION", "VARIATION", "GRAPH") and "Practice", but FEATURE_BASE_COST lookups
are case-sensitive so CreditUseService.useCredit() can charge the default 5
instead of the intended value; fix by normalizing feature names before cost
lookup (e.g., map incoming feature via a canonicalizer like feature =
normalizeFeature(feature) or feature =
StringUtils.capitalize(feature.toLowerCase())/toLowerCase()) or make
FEATURE_BASE_COST case-insensitive by populating both variants (add entries for
"SOLUTION", "VARIATION", "GRAPH" and "Practice") and ensure ToolDataInitializer
and any registration logic use the same canonical form so
CreditUseService.useCredit() and FEATURE_BASE_COST use the same symbol set.


@Override
Expand Down