- src/muse 新版全模块(装配/共享/上下文/任务运行/作品规划/故事世界/正文写作/审校修订/知识方法/作者经验/效果评测/交付连载/资料研究/正式变更/元数据/接入/基础设施/编排)+ 测试树(单元/契约/集成/架构/迁移/端到端/夹具) - 129 项功能全部实现与自动验证(功能覆盖.json/矩阵),含 W31 补齐的规则与代价/节奏安排/伏笔与承诺 - 旧实现按处置清单退出(702 条中 324 删,保护合同与未迁移条目留存有据);web/app.py 旧工作台退役,新工作台为唯一写入口 - 数据库/旧库迁移:真实旧库内容批次迁移链(端点守卫/PG作品正文映射/质量资产缺省投影) - 运行手册 docs/运行手册.md;W30 本机服务阶段一已运行(infra PG 为正式内容权威) - R2 执行证据与私有运行材料在 .agents.local/改造/R2-20260909/(不入库)
82 lines
4.4 KiB
SQL
82 lines
4.4 KiB
SQL
-- B06 只登记作者控制的有限返修会话、轮任务引用和选择;实际模型任务与候选仍归 S02/B05。
|
|
CREATE TABLE public.muse_revision_session (
|
|
session_id uuid PRIMARY KEY,
|
|
author_id text NOT NULL,
|
|
create_command_id text NOT NULL,
|
|
request_hash text NOT NULL CHECK(request_hash ~ '^[0-9a-f]{64}$'),
|
|
work_id text NOT NULL REFERENCES public.muse_work(work_id),
|
|
chapter_id text NOT NULL REFERENCES public.muse_chapter(chapter_id),
|
|
branch_id text NOT NULL,
|
|
original_revision bigint NOT NULL CHECK(original_revision > 0),
|
|
original_document_hash text NOT NULL CHECK(original_document_hash ~ '^[0-9a-f]{64}$'),
|
|
source_kind text NOT NULL CHECK(source_kind IN ('diagnosis','selection')),
|
|
basis_hash text NOT NULL CHECK(basis_hash ~ '^[0-9a-f]{64}$'),
|
|
"authorization" jsonb NOT NULL CHECK(jsonb_typeof("authorization") = 'object'),
|
|
authorization_hash text NOT NULL CHECK(authorization_hash ~ '^[0-9a-f]{64}$'),
|
|
config_id text NOT NULL,
|
|
max_rounds integer NOT NULL CHECK(max_rounds BETWEEN 1 AND 5),
|
|
current_round integer NOT NULL DEFAULT 1 CHECK(current_round BETWEEN 1 AND 5),
|
|
state text NOT NULL CHECK(state IN ('preparing','running','awaiting_author','closed')),
|
|
stop_reason text,
|
|
stop_detail text,
|
|
author_choice text CHECK(author_choice IN ('original','candidate')),
|
|
selected_candidate_id uuid REFERENCES public.muse_writing_candidate(candidate_id),
|
|
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
|
updated_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
|
UNIQUE(author_id,create_command_id),
|
|
UNIQUE(session_id,author_id),
|
|
CHECK(current_round <= max_rounds),
|
|
CHECK((state = 'closed') = (stop_reason IS NOT NULL)),
|
|
CHECK(
|
|
(author_choice IS NULL AND selected_candidate_id IS NULL)
|
|
OR (author_choice = 'original' AND selected_candidate_id IS NULL)
|
|
OR (author_choice = 'candidate' AND selected_candidate_id IS NOT NULL)
|
|
)
|
|
);
|
|
|
|
CREATE TABLE public.muse_revision_round (
|
|
session_id uuid NOT NULL REFERENCES public.muse_revision_session(session_id),
|
|
round_number integer NOT NULL CHECK(round_number BETWEEN 1 AND 5),
|
|
task_command_id text NOT NULL UNIQUE,
|
|
task_request_hash text NOT NULL CHECK(task_request_hash ~ '^[0-9a-f]{64}$'),
|
|
task_id uuid UNIQUE REFERENCES public.muse_task(task_id),
|
|
state text NOT NULL CHECK(state IN ('preparing','running','candidate','original','rejected')),
|
|
outcome text CHECK(outcome IN ('candidate','original','rejected')),
|
|
candidate_id uuid REFERENCES public.muse_writing_candidate(candidate_id),
|
|
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
|
updated_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
|
PRIMARY KEY(session_id,round_number),
|
|
CHECK((task_id IS NULL) = (state = 'preparing')),
|
|
CHECK((outcome IS NULL) = (state IN ('preparing','running'))),
|
|
CHECK((outcome = 'candidate') = (candidate_id IS NOT NULL))
|
|
);
|
|
|
|
CREATE TABLE public.muse_revision_session_action (
|
|
action_id uuid PRIMARY KEY,
|
|
session_id uuid NOT NULL REFERENCES public.muse_revision_session(session_id),
|
|
author_id text NOT NULL,
|
|
command_id text NOT NULL,
|
|
expected_round integer NOT NULL CHECK(expected_round BETWEEN 1 AND 5),
|
|
candidate_id uuid NOT NULL REFERENCES public.muse_writing_candidate(candidate_id),
|
|
choice text NOT NULL CHECK(choice IN ('original','candidate','retry')),
|
|
request_hash text NOT NULL CHECK(request_hash ~ '^[0-9a-f]{64}$'),
|
|
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
|
UNIQUE(author_id,command_id),
|
|
FOREIGN KEY(session_id,author_id)
|
|
REFERENCES public.muse_revision_session(session_id,author_id)
|
|
);
|
|
|
|
CREATE TRIGGER muse_revision_session_action_immutable BEFORE UPDATE OR DELETE
|
|
ON public.muse_revision_session_action FOR EACH ROW
|
|
EXECUTE FUNCTION public.muse_guard_literary_history();
|
|
|
|
REVOKE ALL ON public.muse_revision_session,public.muse_revision_round,
|
|
public.muse_revision_session_action FROM PUBLIC,muse_app,muse_eval;
|
|
GRANT SELECT,INSERT ON public.muse_revision_session,public.muse_revision_round TO muse_app;
|
|
GRANT UPDATE(current_round,state,stop_reason,stop_detail,author_choice,
|
|
selected_candidate_id,updated_at)
|
|
ON public.muse_revision_session TO muse_app;
|
|
GRANT UPDATE(task_id,state,outcome,candidate_id,updated_at)
|
|
ON public.muse_revision_round TO muse_app;
|
|
GRANT SELECT,INSERT ON public.muse_revision_session_action TO muse_app;
|