feat(ECR-023): AICoreConfig KnowledgeSource 只读并 Closed

运营可观测知识源目录(knowledge_sources + admin /ai),不含 Chunk/Embedding。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-08 01:49:58 +08:00
co-authored by Cursor
parent dd4d644eaa
commit bf1ae8bc53
25 changed files with 555 additions and 3 deletions
@@ -0,0 +1,24 @@
# Backend Design: ECR-023 KnowledgeSource
| ID | BD-2026-023 |
| Status | Approved |
| Coding | Loop authorized |
| Level | L2 |
| Migration | YES 000024 |
## Backend Change Boundary
```text
Domain: KnowledgeSource (read catalog only)
App: AdminHandler → admin.Service → AdminRepo
API: GET /admin/ai/knowledge-sources[+/:id]
Permission: admin.ai_config.read (reuse; no new perm)
Migration: 000024 knowledge_sources + seed ask_grounding
UI: admin-h5 /ai KnowledgeSource panel
```
## Out of boundary
KnowledgeChunk · Embedding · upload/publish · ToolDefinition · UGC · Payment · runtime RAG wiring
Rollback: down migration + remove routes/UI panel
+1
View File
@@ -2,6 +2,7 @@
## 2026-08-08
- **ECR-023 Closed**AICoreConfig KnowledgeSource`knowledge_sources` · admin-h5 `/ai` · migration 000024 · 只读)
- **ECR-022 Closed**CrisisCare CrisisPolicy`crisis_policies` · evaluate · admin-h5 `/crisis` · migration 000023
- **ECR-021 Closed**AICoreConfig SystemPrompt`system_prompts` · admin-h5 `/ai` · migration 000022 · 只读)
+8
View File
@@ -0,0 +1,8 @@
# CODE_REVIEW — ECR-023
**Verdict:** Approve → Closed
Date: 2026-08-08 · Loop continuous
- KnowledgeSource 只读;无 Chunk/Embedding/UGC
- Integration AC mapped · OpenAPI updated · 复用 admin.ai_config.read
+23
View File
@@ -0,0 +1,23 @@
ecr: ECR-023
capability: AICoreConfig
bounded_context: Ask_Ops
parent: WAVE0-FROZEN
predecessor: ECR-022
change:
type: additive
breaking_change: false
migration_required: true
compatibility_notes: >
Adds knowledge_sources catalog with system seed ask_grounding and read admin APIs.
Reuses admin.ai_config.read. Does not introduce KnowledgeChunk or embeddings.
apis:
- method: GET
path: /api/v1/admin/ai/knowledge-sources
change: added
- method: GET
path: /api/v1/admin/ai/knowledge-sources/{id}
change: added
perms:
- code: admin.ai_config.read
change: unchanged
+19
View File
@@ -0,0 +1,19 @@
# ECR-023
**Title:** AICoreConfig · KnowledgeSource(只读薄切片)
**Status:** **Closed**
**Closed:** 2026-08-08Loop continuous
**Parent:** WAVE0-FROZEN · **Predecessor:** ECR-022 Closed
**Change Level:** L2
## Change
`knowledge_sources` + `GET /admin/ai/knowledge-sources*`;复用 `admin.ai_config.read`;admin-h5「AI」页增知识源区。
## Forbidden
KnowledgeChunk/Embedding 写 · 源上传 · 在线发布 · UGC · 真支付
## Linked
Spec `ops-knowledge-source.md` · BD-2026-023 · CONTRACT_DIFF/ECR-023.yaml · TEST_REPORT/ECR-023.md
@@ -0,0 +1,7 @@
# ENGINEERING_SPEC — ECR-023
1. migration 000024 knowledge_sources + seed
2. AdminRepo list/get KnowledgeSource
3. Admin API + OpenAPI
4. admin-h5 /ai 知识源区
5. Integration · Closed
@@ -0,0 +1,4 @@
# HANDOFF — ECR-023 Architect → Engineer
Loop continuous · Approved + Coding. Migration 000024. Forbidden: Chunk/Embedding/UGC/真支付.
复用 admin.ai_config.read。
@@ -0,0 +1,3 @@
# HANDOFF — ECR-023 Engineer → Reviewer
TestAICoreKnowledgeSources PASS · /ai 知识源区 · Ready for Closed.
@@ -0,0 +1,3 @@
# PRODUCT_SPEC — ECR-023
对齐 ops-knowledge-source.md · Approved · Loop · L2 · KnowledgeSource 只读
+6
View File
@@ -0,0 +1,6 @@
# STATE — ECR-023
| Status | **Closed** |
| Phase | closed |
| Spec | ops-knowledge-source.md |
| Updated | 2026-08-08 |
+12
View File
@@ -0,0 +1,12 @@
id: TASK-023-ECR023
ecr: ECR-023
title: AICoreConfig KnowledgeSource read
role: engineer
status: closed
change_level: L2
parent: WAVE0-FROZEN
predecessor: ECR-022
acceptance:
- Spec AC mapped
- KnowledgeSource read only
- No Chunk / Embedding / UGC / payment
+33
View File
@@ -0,0 +1,33 @@
# TEST_REPORT — ECR-023 KnowledgeSource
Date: 2026-08-08 · Loop continuous · commit: `PENDING`
## Commands
```bash
cd apps/api && go test ./internal/integration/ -run TestAICoreKnowledgeSources -count=1
npm run build:admin
python3 scripts/ess-validate.py --phase review --ecr ECR-023
python3 scripts/ess-gate-check.py --ecr ECR-023
```
## Results
| Check | Result |
|-------|--------|
| TestAICoreKnowledgeSources | PASS |
| build:admin | PASS |
| ess-validate review | PASS |
| ess-gate-check | PASS |
## AC
| ID | Evidence |
|----|----------|
| AC-F-01 | list 含 ask_grounding |
| AC-F-02 | get source_kind 合法 |
| AC-F-03 | 未知 id → 404 |
| AC-S-01 | 无 token → 401 |
| AC-S-02 | 仅 users.read → 403 |
| AC-P-01 | list &lt; 500ms |
| AC-O-01 | N/A 只读 |
+1
View File
@@ -27,3 +27,4 @@
| ECR-020 | QualityFeedback | **Closed** | Spec ops-quality-feedback · BD-2026-020 · migration 000021 · TEST_REPORT · CODE_REVIEW · Loop continuous |
| ECR-021 | AICoreConfig | **Closed** | Spec ops-ai-core-config · BD-2026-021 · migration 000022 · TEST_REPORT · CODE_REVIEW · Loop continuous |
| ECR-022 | CrisisCare | **Closed** | Spec ops-crisis-care · BD-2026-022 · migration 000023 · TEST_REPORT · CODE_REVIEW · Loop continuous |
| ECR-023 | AICoreConfig · KnowledgeSource | **Closed** | Spec ops-knowledge-source · BD-2026-023 · migration 000024 · TEST_REPORT · CODE_REVIEW · Loop continuous |
+1 -1
View File
@@ -30,4 +30,4 @@ Human 明文:**直接用 Loop,不用人工确认。**
| Done | Next |
|------|------|
| ECR-013A…022 Closed | **ECR-023** KnowledgeSource 薄切片(只读优先)或 Banner/OpsCMS;禁真支付/UGC |
| ECR-013A…023 Closed | **ECR-024** Banner/OpsCMS 薄切片(只读优先)或 KnowledgeChunk;禁真支付/UGC |