80 lines
3.5 KiB
SQL
80 lines
3.5 KiB
SQL
-- 复核意见挖掘(口径见 shared/src/review_mining.ts,实现见 control-server/src/review_mining.ts)。
|
|
--
|
|
-- 人工复核的打回意见本身在 tasks / features / security.review_history 里(JSON),这里不复制正文,
|
|
-- 只存三样派生物:每条意见的标签、每周归纳出的候选规范、本人确认过的个人口味。
|
|
-- 全是新表,不需要回填:回路进程第一次运行时按窗口把历史意见补标一遍。
|
|
|
|
-- 每条复核意见一行。key = <target_kind>:<target_id>:<note_at>:<note_source>,与 review_history 里的一条一一对应。
|
|
-- reviewer 是归属到的复核人(邮箱前缀),reviewer_via 说明怎么认出来的:
|
|
-- note = ReviewNote.reviewer(11-02 起打回时写入);transition = 打回那一刻的流转 actor(09-30 起有);null = 认不出。
|
|
-- 个人口味只认 note / transition,不拿建单人顶替(批量导入的单建单人是导入人,不是复核人)。
|
|
CREATE TABLE IF NOT EXISTS "review_note_labels" (
|
|
"key" text PRIMARY KEY,
|
|
"target_kind" text NOT NULL,
|
|
"target_id" text NOT NULL,
|
|
"note_at" bigint NOT NULL,
|
|
"note_round" bigint,
|
|
"note_source" text NOT NULL,
|
|
"platform" text,
|
|
"reviewer" text,
|
|
"reviewer_via" text,
|
|
"creator" text,
|
|
-- code_practice | process_practice | requirement_change | ui_spec | defect | verification | context_hint | ops | other
|
|
"cat" text NOT NULL,
|
|
-- 只在两类 practice 时有值:global | repo | personal
|
|
"scope" text,
|
|
"topic" text,
|
|
"rule" text,
|
|
"preventable" bigint NOT NULL DEFAULT 0,
|
|
"why" text,
|
|
"excerpt" text,
|
|
"labeler" text NOT NULL,
|
|
"labeled_at" bigint NOT NULL
|
|
);
|
|
CREATE INDEX IF NOT EXISTS "review_note_labels_target" ON "review_note_labels" ("target_kind", "target_id");
|
|
CREATE INDEX IF NOT EXISTS "review_note_labels_note_at" ON "review_note_labels" ("note_at" DESC);
|
|
|
|
-- 每周归纳出的候选规范。证据只存标签 key,统计由控制面按证据重算(不信模型报的数)。
|
|
-- status:pending → accepted(全局 / 仓库级:待改 shared/src/code_conventions.ts;个人:已发给本人确认)
|
|
-- → shipped(已落代码,填 shipped_ref)| rejected | superseded(同一题目有了更新的候选)
|
|
CREATE TABLE IF NOT EXISTS "convention_candidates" (
|
|
"id" text PRIMARY KEY,
|
|
"run_id" text NOT NULL,
|
|
"created_at" bigint NOT NULL,
|
|
"window_from" bigint NOT NULL,
|
|
"window_to" bigint NOT NULL,
|
|
"scope" text NOT NULL,
|
|
-- repo 级规则落在哪一端的平台段;global / personal 为 null
|
|
"platform" text,
|
|
-- personal 时是本人邮箱前缀
|
|
"owner" text,
|
|
"family" text NOT NULL,
|
|
"rule" text NOT NULL,
|
|
"rationale" text,
|
|
-- none | partial | full:现行代码规范块是否已经覆盖(模型判断,仅供参考)
|
|
"covered" text,
|
|
"evidence" text NOT NULL,
|
|
"conflicts" text,
|
|
"stats" text NOT NULL,
|
|
"status" text NOT NULL DEFAULT 'pending',
|
|
"decided_by" text,
|
|
"decided_at" bigint,
|
|
"decision_note" text,
|
|
"shipped_ref" text
|
|
);
|
|
CREATE INDEX IF NOT EXISTS "convention_candidates_status" ON "convention_candidates" ("status", "created_at" DESC);
|
|
|
|
-- 个人口味。只有本人点了确认(status = active)才会在派单时注入;proposed 只是等本人看。
|
|
CREATE TABLE IF NOT EXISTS "code_style_prefs" (
|
|
"id" text PRIMARY KEY,
|
|
"owner" text NOT NULL,
|
|
"rule" text NOT NULL,
|
|
"candidate_id" text,
|
|
-- proposed | active | declined | retired
|
|
"status" text NOT NULL DEFAULT 'proposed',
|
|
"created_at" bigint NOT NULL,
|
|
"updated_at" bigint NOT NULL,
|
|
"confirmed_at" bigint
|
|
);
|
|
CREATE INDEX IF NOT EXISTS "code_style_prefs_owner" ON "code_style_prefs" ("owner", "status");
|