- src/muse 新版全模块(装配/共享/上下文/任务运行/作品规划/故事世界/正文写作/审校修订/知识方法/作者经验/效果评测/交付连载/资料研究/正式变更/元数据/接入/基础设施/编排)+ 测试树(单元/契约/集成/架构/迁移/端到端/夹具) - 129 项功能全部实现与自动验证(功能覆盖.json/矩阵),含 W31 补齐的规则与代价/节奏安排/伏笔与承诺 - 旧实现按处置清单退出(702 条中 324 删,保护合同与未迁移条目留存有据);web/app.py 旧工作台退役,新工作台为唯一写入口 - 数据库/旧库迁移:真实旧库内容批次迁移链(端点守卫/PG作品正文映射/质量资产缺省投影) - 运行手册 docs/运行手册.md;W30 本机服务阶段一已运行(infra PG 为正式内容权威) - R2 执行证据与私有运行材料在 .agents.local/改造/R2-20260909/(不入库)
40 lines
2.5 KiB
SQL
40 lines
2.5 KiB
SQL
-- B07只追加带真实来源的运行观察;与V0046作者自报指标分开。
|
||
CREATE TABLE public.muse_run_observation (
|
||
observation_id uuid PRIMARY KEY,
|
||
author_id text NOT NULL CHECK (btrim(author_id) <> ''),
|
||
source_ids uuid[] NOT NULL CONSTRAINT muse_run_observation_source_ids_nonempty
|
||
CHECK (cardinality(source_ids) > 0 AND array_position(source_ids,NULL) IS NULL),
|
||
source_set_hash text NOT NULL CHECK (source_set_hash ~ '^[0-9a-f]{64}$'),
|
||
phenomenon text NOT NULL CHECK (length(btrim(phenomenon)) BETWEEN 1 AND 200),
|
||
issue_key text NOT NULL DEFAULT '',
|
||
state text NOT NULL DEFAULT 'observation' CHECK (state = 'observation'),
|
||
request_hash text NOT NULL CHECK (request_hash ~ '^[0-9a-f]{64}$'),
|
||
payload jsonb NOT NULL CONSTRAINT muse_run_observation_sources_present CHECK (
|
||
CASE WHEN jsonb_typeof(payload->'sources') = 'array' THEN
|
||
jsonb_array_length(payload->'sources') > 0 AND NOT jsonb_path_exists(payload,
|
||
'$.sources[*] ? (!exists(@.runtime.task_id) || !exists(@.runtime.attempt_id)
|
||
|| !exists(@.locator.content_hash) || @.runtime.task_id.type() != "string"
|
||
|| @.runtime.attempt_id.type() != "string" || @.locator.content_hash.type() != "string"
|
||
|| @.runtime.task_id == "" || @.runtime.attempt_id == "" || @.locator.content_hash == "")')
|
||
ELSE false END),
|
||
content_hash text NOT NULL CHECK (content_hash ~ '^[0-9a-f]{64}$'),
|
||
created_at timestamptz NOT NULL DEFAULT clock_timestamp(),
|
||
UNIQUE(author_id,source_set_hash,phenomenon)
|
||
);
|
||
CREATE INDEX ON public.muse_run_observation(author_id,issue_key,created_at);
|
||
CREATE TABLE public.muse_run_observation_command (
|
||
author_id text NOT NULL,
|
||
command_id text NOT NULL CHECK (btrim(command_id) <> ''),
|
||
observation_id uuid NOT NULL REFERENCES public.muse_run_observation(observation_id),
|
||
request_hash text NOT NULL CHECK (request_hash ~ '^[0-9a-f]{64}$'),
|
||
PRIMARY KEY(author_id,command_id)
|
||
);
|
||
CREATE TRIGGER muse_run_observation_immutable BEFORE UPDATE OR DELETE
|
||
ON public.muse_run_observation FOR EACH ROW
|
||
EXECUTE FUNCTION public.muse_guard_literary_history();
|
||
CREATE TRIGGER muse_run_observation_command_immutable BEFORE UPDATE OR DELETE
|
||
ON public.muse_run_observation_command FOR EACH ROW
|
||
EXECUTE FUNCTION public.muse_guard_literary_history();
|
||
REVOKE ALL ON public.muse_run_observation,public.muse_run_observation_command FROM muse_eval;
|
||
GRANT SELECT,INSERT ON public.muse_run_observation,public.muse_run_observation_command TO muse_app;
|