Files
DataMate/backend/services
Jerry Yan e9e4cf3b1c fix(kg): 修复知识图谱部署流程问题
修复从全新部署到运行的完整流程中的配置和路由问题。

## P0 修复(功能失效)

### P0-1: GraphRAG KG 服务 URL 错误
- config.py - GRAPHRAG_KG_SERVICE_URL 从 http://datamate-kg:8080 改为 http://datamate-backend:8080(容器名修正)
- kg_client.py - 修复 API 路径:/knowledge-graph/... → /api/knowledge-graph/...
- kb_access.py - 同类问题修复:/knowledge-base/... → /api/knowledge-base/...
- test_kb_access.py - 测试断言同步更新

根因:容器名 datamate-kg 不存在,且 httpx 绝对路径会丢弃 base_url 中的 /api 路径

### P0-2: Vite 开发代理剥离 /api 前缀
- vite.config.ts - 删除 /api/knowledge-graph 专用代理规则(剥离 /api 导致 404),统一走 ^/api 规则

## P1 修复(功能受损)

### P1-1: Gateway 缺少 KG Python 端点路由
- ApiGatewayApplication.java - 添加 /api/kg/** 路由(指向 kg-extraction Python 服务)
- ApiGatewayApplication.java - 添加 /api/graphrag/** 路由(指向 GraphRAG 服务)

### P1-2: DATA_MANAGEMENT_URL 默认值缺 /api
- KnowledgeGraphProperties.java - dataManagementUrl 默认值 http://localhost:8080http://localhost:8080/api
- KnowledgeGraphProperties.java - annotationServiceUrl 默认值 http://localhost:8081http://localhost:8080/api(同 JVM)
- application-knowledgegraph.yml - YAML 默认值同步更新

### P1-3: Neo4j k8s 安装链路失败
- Makefile - VALID_K8S_TARGETS 添加 neo4j
- Makefile - %-k8s-install 添加 neo4j case(显式 skip,提示使用 Docker 或外部实例)
- Makefile - %-k8s-uninstall 添加 neo4j case(显式 skip)

根因:install 目标无条件调用 neo4j-$(INSTALLER)-install,但 k8s 模式下 neo4j 不在 VALID_K8S_TARGETS 中,导致 "Unknown k8s target 'neo4j'" 错误

## P2 修复(次要)

### P2-1: Neo4j 加入 Docker install 流程
- Makefile - install target 增加 neo4j-$(INSTALLER)-install,在 datamate 之前启动
- Makefile - VALID_SERVICE_TARGETS 增加 neo4j
- Makefile - %-docker-install / %-docker-uninstall 增加 neo4j case

## 验证结果
- mvn test: 311 tests, 0 failures 
- eslint: 0 errors 
- tsc --noEmit: 通过 
- vite build: 成功 (17.71s) 
- Python tests: 46 passed 
- make -n install INSTALLER=k8s: 不再报 unknown target 
- make -n neo4j-k8s-install: 正确显示 skip 消息 
2026-02-23 01:15:31 +08:00
..
2025-12-22 15:41:17 +08:00
2025-12-22 15:41:17 +08:00