muse-agent-example/数据库/迁移/V0035__评测逐例执行.sql
zizi 9e6f1c4481 R2 改造交付:新版模块化单体全量成果
- src/muse 新版全模块(装配/共享/上下文/任务运行/作品规划/故事世界/正文写作/审校修订/知识方法/作者经验/效果评测/交付连载/资料研究/正式变更/元数据/接入/基础设施/编排)+ 测试树(单元/契约/集成/架构/迁移/端到端/夹具)
- 129 项功能全部实现与自动验证(功能覆盖.json/矩阵),含 W31 补齐的规则与代价/节奏安排/伏笔与承诺
- 旧实现按处置清单退出(702 条中 324 删,保护合同与未迁移条目留存有据);web/app.py 旧工作台退役,新工作台为唯一写入口
- 数据库/旧库迁移:真实旧库内容批次迁移链(端点守卫/PG作品正文映射/质量资产缺省投影)
- 运行手册 docs/运行手册.md;W30 本机服务阶段一已运行(infra PG 为正式内容权威)
- R2 执行证据与私有运行材料在 .agents.local/改造/R2-20260909/(不入库)
2026-09-15 12:47:42 +08:00

44 lines
2.1 KiB
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- B10执行计划、单元归属和原始交付;任务/尝试/费用继续由S02拥有。
CREATE TABLE evaluation.muse_experiment_execution (
experiment_id uuid PRIMARY KEY REFERENCES evaluation.muse_experiment(experiment_id),
request_hash text NOT NULL,
plan jsonb NOT NULL,
plan_hash text NOT NULL,
created_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
CREATE TABLE evaluation.muse_evaluation_unit (
unit_id uuid PRIMARY KEY,
experiment_id uuid NOT NULL REFERENCES evaluation.muse_experiment_execution(experiment_id),
sample_id text NOT NULL,
kind text NOT NULL CHECK(kind IN ('generation','comparison')),
specification jsonb NOT NULL,
specification_hash text NOT NULL,
task_id uuid UNIQUE REFERENCES evaluation.muse_task(task_id)
);
CREATE TABLE evaluation.muse_evaluation_output (
unit_id uuid PRIMARY KEY REFERENCES evaluation.muse_evaluation_unit(unit_id),
task_id uuid NOT NULL REFERENCES evaluation.muse_task(task_id),
attempt_id uuid NOT NULL,
call_id text NOT NULL UNIQUE,
user_input_hash text NOT NULL,
output jsonb NOT NULL,
output_hash text NOT NULL,
evidence jsonb NOT NULL,
created_at timestamptz NOT NULL DEFAULT clock_timestamp()
);
CREATE TRIGGER evaluation_execution_guard BEFORE UPDATE OR DELETE ON evaluation.muse_experiment_execution
FOR EACH ROW EXECUTE FUNCTION public.muse_guard_literary_history();
CREATE TRIGGER evaluation_output_guard BEFORE UPDATE OR DELETE ON evaluation.muse_evaluation_output
FOR EACH ROW EXECUTE FUNCTION public.muse_guard_literary_history();
CREATE FUNCTION evaluation.muse_guard_unit_binding() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN
IF TG_OP='DELETE' THEN RAISE EXCEPTION 'evaluation unit is immutable'; END IF;
IF OLD.task_id IS NOT NULL OR NEW.task_id IS NULL OR
(to_jsonb(OLD)-'task_id') <> (to_jsonb(NEW)-'task_id') THEN
RAISE EXCEPTION 'only first task binding is allowed';
END IF;
RETURN NEW;
END $$;
CREATE TRIGGER evaluation_unit_guard BEFORE UPDATE OR DELETE ON evaluation.muse_evaluation_unit
FOR EACH ROW EXECUTE FUNCTION evaluation.muse_guard_unit_binding();