From eaecd0ab22da9aa772646cbac8080564fd6d0c8b Mon Sep 17 00:00:00 2001 From: cfdaily Date: Fri, 15 May 2026 23:26:21 +0800 Subject: [PATCH] auto-sync: 2026-05-15 23:26:21 --- .../design/topic6-experience-loop-proposal.md | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/design/topic6-experience-loop-proposal.md b/docs/design/topic6-experience-loop-proposal.md index eb54bf6..da12fca 100644 --- a/docs/design/topic6-experience-loop-proposal.md +++ b/docs/design/topic6-experience-loop-proposal.md @@ -229,7 +229,6 @@ CREATE TABLE experiences ( experience_id TEXT PRIMARY KEY, source TEXT NOT NULL, -- task_completion / error_correction / review_finding / manual task_id TEXT, -- 来源任务(FK → tasks) - tags TEXT NOT NULL, -- JSON array: ["vnpy", "strategy-coding"] summary TEXT NOT NULL, -- 经验摘要(200字以内) category TEXT NOT NULL, -- pitfall / best_practice / pattern / anti_pattern confidence REAL DEFAULT 0.8, -- 0-1 @@ -242,12 +241,24 @@ CREATE TABLE experiences ( updated_at TEXT, deprecated_reason TEXT ); + +-- tags 多对多关联表(替代 JSON array,走 B-tree 索引) +CREATE TABLE experience_tags ( + experience_id TEXT NOT NULL REFERENCES experiences(experience_id), + tag TEXT NOT NULL, + PRIMARY KEY (experience_id, tag) +); +CREATE INDEX idx_exptags_tag ON experience_tags(tag); ``` -**索引**: -- `idx_exp_tags`:tags(JSON)— 按标签检索 -- `idx_exp_status`:status — 按状态过滤 -- `idx_exp_category`:category — 按类型过滤 +**查询示例**(D6-5 注入逻辑): +```sql +SELECT DISTINCT e.* FROM experiences e +JOIN experience_tags et ON e.experience_id = et.experience_id +WHERE et.tag IN ('vnpy', 'strategy-coding') + AND e.status = 'active' +LIMIT 3; +``` ### D6-8:和课题4四层架构的关系