feat(ECR-016): UserIntelligence 用户洞察只读切片并 Closed

聚合 GET /admin/users/:id/insight(报告类型/派生标签/行为快照),admin-h5 洞察 Tab;无 migration / 无 UGC / 无真支付。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-07 18:31:06 +08:00
co-authored by Cursor
parent 1afda1d389
commit 61ae3b0451
27 changed files with 807 additions and 115 deletions
@@ -0,0 +1,24 @@
# Backend Design: ECR-016 UserIntelligence
| ID | BD-2026-016 |
| Status | Approved |
| Coding | Loop authorized |
| Level | L2 |
| Migration | NO |
## Backend Change Boundary
```text
Domain: UserInsight read model (BehaviorSnapshot · PsychologicalTagSet derived)
App: AdminHandler → admin.Service → AdminRepo aggregates
API: GET /api/v1/admin/users/{id}/insight
Permission: admin.users.read
Migration: NO
UI: admin-h5 UserDetail「洞察」Tab
```
## Out of boundary
Write tags · new tables · Ask body edit · UGC · true payment
Rollback: remove route + UI tab(无 schema
+1
View File
@@ -2,6 +2,7 @@
## 2026-08-07
- **ECR-016 Closed**UserIntelligence`GET /admin/users/:id/insight` 只读聚合 · admin-h5 洞察 Tab · Migration NO
- **ECR-015 Closed**RedemptionCode(批次生成 · C端兑码 · 作废 · 审计)
- **ECR-014 Closed**MembershipPlan(套餐表 · admin 配置 · Grant/CreateOrder 读表)
- **LOOP continuous**`docs/WAVE0/LOOP_AUTHORIZATION.md` — Human 授权免逐闸确认
+9
View File
@@ -0,0 +1,9 @@
# CODE_REVIEW — ECR-016
**Verdict:** Approve → Closed
Date: 2026-08-07 · Loop continuous
- Additive GET insight onlyMigration NO
- Handler → Service → Repository;无 UGC / 真支付
- Integration AC mapped · OpenAPI updated
+17
View File
@@ -0,0 +1,17 @@
ecr: ECR-016
capability: UserIntelligence
bounded_context: Identity_Profile
parent: WAVE0-FROZEN
predecessor: ECR-015
change:
type: additive
breaking_change: false
migration_required: false
compatibility_notes: >
Additive read API GET /admin/users/{id}/insight.
No schema change; aggregates existing tables.
apis:
- method: GET
path: /api/v1/admin/users/{id}/insight
change: added
+19
View File
@@ -0,0 +1,19 @@
# ECR-016
**Title:** UserIntelligence(用户洞察只读薄切片)
**Status:** **Closed**
**Closed:** 2026-08-07Loop continuous
**Parent:** WAVE0-FROZEN · **Predecessor:** ECR-015 Closed
**Change Level:** L2
## Change
`GET /admin/users/:id/insight` 聚合报告/标签/行为快照;admin-h5 用户详情「洞察」区。
## Forbidden
新表 · 写标签 · Ask 正文编辑 · 真支付 · UGC
## Linked
Spec `ops-user-intelligence.md` · BD-2026-016 · CONTRACT_DIFF/ECR-016.yaml · TEST_REPORT/ECR-016.md
@@ -0,0 +1,8 @@
# ENGINEERING_SPEC — ECR-016
1. Repo Insight 聚合查询
2. GET /users/:id/insight + OpenAPI
3. admin-h5 用户详情洞察区
4. Integration · Closed
Migration: **NO**
@@ -0,0 +1,3 @@
# HANDOFF — ECR-016 Architect → Engineer
Loop continuous · Approved + Coding. Migration NO. Forbidden: 写模型/UGC/真支付.
@@ -0,0 +1,3 @@
# HANDOFF — ECR-016 Engineer → Reviewer
TestUserInsight PASS · admin-h5 洞察 Tab · Ready for Closed.
@@ -0,0 +1,3 @@
# PRODUCT_SPEC — ECR-016
对齐 ops-user-intelligence.md · Approved · Loop · L2 · 只读聚合
+6
View File
@@ -0,0 +1,6 @@
# STATE — ECR-016
| Status | **Closed** |
| Phase | closed |
| Spec | ops-user-intelligence.md |
| Updated | 2026-08-07 |
+11
View File
@@ -0,0 +1,11 @@
id: TASK-016-ECR016
ecr: ECR-016
title: UserIntelligence implement
role: engineer
status: closed
change_level: L2
parent: WAVE0-FROZEN
predecessor: ECR-015
acceptance:
- Spec AC mapped
- No migration / no UGC / no payment
+31
View File
@@ -0,0 +1,31 @@
# TEST_REPORT — ECR-016 UserIntelligence
Date: 2026-08-07 · Loop continuous · commit: (pending this commit)
## Commands
```bash
cd apps/api && go test ./internal/integration/ -run TestUserInsight -count=1
npm run build:admin
python3 scripts/ess-validate.py --phase review --ecr ECR-016
```
## Results
| Check | Result |
|-------|--------|
| TestUserInsight | PASS |
| build:admin | PASS |
| ess-validate review | PASS |
## AC
| ID | Evidence |
|----|----------|
| AC-F-01 | insight.reports_by_type 含 portrait |
| AC-F-02 | tags 含 portrait 映射标签 |
| AC-F-03 | behavior.events=[] 仍 200 |
| AC-S-01 | 无 token → 401 |
| AC-S-02 | RequireAdminPermission(admin.users.read) |
| AC-P-01 | GET insight &lt; 500ms |
| AC-O-01 | N/A 只读 |
+3
View File
@@ -18,3 +18,6 @@
| WAVE-0 | Ops Contract-First Foundation | **FROZEN** (`WAVE0-FROZEN` @ 27f27a1) | `docs/WAVE0/` · HUMAN_REVIEW FREEZE · boundary-rules · glossary · contract template |
| ECR-013A | Admin RBAC | **Closed** | Spec ops-rbac · BD-2026-013A · migration 000015 · TEST_REPORT · CODE_REVIEW Approve · Parent WAVE0-FROZEN |
| ECR-015 | RedemptionCode | **Closed** | Spec ops-redemption-code · migration 000018 · TEST_REPORT · Loop continuous |
| ECR-013B | AccountLifecycle | **Closed** | Spec ops-account-lifecycle · BD-2026-013B · TEST_REPORT · Parent WAVE0-FROZEN |
| ECR-014 | MembershipPlan | **Closed** | Spec ops-membership-plan · BD-2026-014 · TEST_REPORT · Loop continuous |
| ECR-016 | UserIntelligence | **Closed** | Spec ops-user-intelligence · BD-2026-016 · TEST_REPORT · CODE_REVIEW · Loop continuous |
+1 -1
View File
@@ -30,4 +30,4 @@ Human 明文:**直接用 Loop,不用人工确认。**
| Done | Next |
|------|------|
| ECR-013A/B/014/015 Closed | **ECR-016** UserIntelligence 薄切片(只读洞察);禁真支付/UGC |
| ECR-013A/B/014/015/016 Closed | **ECR-017** AskOperations 薄切片(只读会话视图优先);禁真支付/UGC |