-- B08固定交付清单与导出字节;正文仍以B05版本为唯一权威。 CREATE TABLE public.muse_delivery ( delivery_id uuid PRIMARY KEY, author_id text NOT NULL, work_id text NOT NULL, revision integer NOT NULL CHECK(revision > 0), manifest jsonb NOT NULL, manifest_hash text NOT NULL CHECK(manifest_hash ~ '^[0-9a-f]{64}$'), created_at timestamptz NOT NULL DEFAULT clock_timestamp(), UNIQUE(work_id,revision), CHECK(jsonb_array_length(manifest->'chapters') > 0) ); CREATE TABLE public.muse_delivery_artifact ( artifact_id uuid PRIMARY KEY, delivery_id uuid NOT NULL REFERENCES public.muse_delivery, format text NOT NULL CHECK(format IN ('txt','md','docx','epub')), formatter_version text NOT NULL, data bytea NOT NULL, content_hash text NOT NULL CHECK(content_hash ~ '^[0-9a-f]{64}$'), verification jsonb NOT NULL, task_id uuid, created_at timestamptz NOT NULL DEFAULT clock_timestamp(), UNIQUE(delivery_id,format,formatter_version), CHECK(octet_length(data) > 0) ); CREATE TRIGGER muse_delivery_immutable BEFORE UPDATE OR DELETE ON public.muse_delivery FOR EACH ROW EXECUTE FUNCTION public.muse_guard_literary_history(); CREATE TRIGGER muse_delivery_artifact_immutable BEFORE UPDATE OR DELETE ON public.muse_delivery_artifact FOR EACH ROW EXECUTE FUNCTION public.muse_guard_literary_history(); REVOKE ALL ON public.muse_delivery,public.muse_delivery_artifact FROM muse_eval; GRANT SELECT,INSERT ON public.muse_delivery,public.muse_delivery_artifact TO muse_app;