Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions proposals/context-retained-video-2131/CONTRACT.md

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions proposals/context-retained-video-2131/fixtures.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- Test-only setup. Never part of retained-video.sql or a hosted migration.
CREATE SCHEMA video_fixture;
CREATE TABLE video_fixture.state(data jsonb);
GRANT USAGE ON SCHEMA video_fixture TO service_role;
GRANT SELECT ON video_fixture.state TO service_role;
CREATE FUNCTION video_fixture.seed() RETURNS jsonb LANGUAGE plpgsql AS $$
DECLARE owner_id uuid:='10000000-0000-4000-8000-000000000001'; actor uuid:='10000000-0000-4000-8000-000000000002';
outsider uuid:='10000000-0000-4000-8000-000000000003'; req jsonb; subject uuid; resource uuid; link uuid;
source uuid:=gen_random_uuid(); dependency uuid:=gen_random_uuid(); snapshot uuid:=gen_random_uuid(); version uuid:=gen_random_uuid();
e jsonb; manifest jsonb; state jsonb;
BEGIN
IF current_database() NOT IN ('video_normal','video_compat')
OR inet_server_addr() IS NOT NULL
OR current_setting('listen_addresses') <> ''
OR current_setting('video_fixture.expected_data_directory',true) IS DISTINCT FROM current_setting('data_directory')
OR current_setting('video_fixture.expected_socket_directory',true) IS DISTINCT FROM current_setting('unix_socket_directories') THEN
RAISE EXCEPTION 'Video fixture seeding is test-only' USING ERRCODE='42501';
END IF;
TRUNCATE public.accounts,public.context_resources,public.context_sources CASCADE;
Comment thread
sidneyswift marked this conversation as resolved.
Resolved
TRUNCATE video_fixture.state,public.account_organization_ids;
INSERT INTO public.accounts(id,name) VALUES(owner_id,'Fixture owner'),(actor,'Fixture member'),(outsider,'Fixture outsider');
INSERT INTO public.account_organization_ids(account_id,organization_id) VALUES(actor,owner_id);
req:=public.create_context_video_request(owner_id,actor,'AbCdEfGhI_1','locator');
SELECT resource_id,(output->'subjectIds'->>0)::uuid INTO resource,subject FROM public.context_requests WHERE id=(req->>'id')::uuid;
SELECT id INTO link FROM public.context_resource_links WHERE resource_id=resource AND subject_id=subject AND relation='identity';
e:=jsonb_build_object('requestId',req->>'id','ownerId',owner_id,'videoSubjectId',subject,'videoId','AbCdEfGhI_1',
'mediaVersion','upload-1','durationSeconds',120,'variant','unknown','title',E' Café 🎵\nTitle ','description',E'Original\n description ',
'channel',jsonb_build_object('id','channel-1','name','Uploader'),
'performers',jsonb_build_array(jsonb_build_object('name','Observed performer','sourceVersionIds',jsonb_build_array(version))),
'identity',jsonb_build_object('state','unresolved','reason','No recording identity established'),
'sources',jsonb_build_array(jsonb_build_object('versionId',snapshot,'videoId','AbCdEfGhI_1','mediaVersion','upload-1','retrievedAt','2026-11-18T00:00:00Z'),
jsonb_build_object('versionId',version,'videoId','AbCdEfGhI_1','mediaVersion','upload-1','retrievedAt','2026-11-18T00:00:00Z')),
'captions',jsonb_build_object('state','available','sourceVersionIds',jsonb_build_array(version),'segments',jsonb_build_array(jsonb_build_object('startSeconds',0,'endSeconds',10,'language','en','text','Retained words'))),
'analysis',jsonb_build_object('state','unavailable','reason','Analysis not retained'));
manifest:=jsonb_build_object('contextVideo',jsonb_build_object('contractVersion','retained-video-evidence-v1','requestId',req->>'id','videoSubjectId',subject,'videoId','AbCdEfGhI_1','mediaVersion','upload-1'));
INSERT INTO public.context_sources(id,owner_id,source_url,kind) VALUES(source,owner_id,'fixture:snapshot','provider_metadata'),(dependency,owner_id,'fixture:captions','provider_metadata');
INSERT INTO public.context_source_versions(id,owner_id,source_id,fingerprint,content,media_manifest,retrieved_at)
VALUES(snapshot,owner_id,source,encode(sha256(convert_to(e::text,'UTF8')),'hex'),e,manifest,'2026-11-18T00:00:00Z'),
(version,owner_id,dependency,repeat('a',64),jsonb_build_object('captions','Retained words'),manifest,'2026-11-18T00:00:00Z');
state:=jsonb_build_object('owner',owner_id,'actor',actor,'outsider',outsider,'request',req->>'id','subject',subject,'resource',resource,'link',link,'source',source,'dependency',dependency,'snapshot',snapshot,'version',version,'evidence',e);
INSERT INTO video_fixture.state VALUES(state);
RETURN state;
END $$;
REVOKE ALL ON FUNCTION video_fixture.seed() FROM PUBLIC,anon,authenticated,service_role;
CREATE FUNCTION video_fixture.raise_fault() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN RAISE EXCEPTION 'fixture write fault'; END $$;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- Synthetic legacy prerequisites only, inside the owned disposable cluster.
CREATE ROLE service_role BYPASSRLS;
CREATE ROLE anon;
CREATE ROLE authenticated;
CREATE SCHEMA storage;
CREATE TABLE storage.buckets(id text PRIMARY KEY,name text,public boolean,file_size_limit bigint);
CREATE TABLE storage.objects(id uuid PRIMARY KEY,bucket_id text);
CREATE TABLE public.accounts(id uuid PRIMARY KEY DEFAULT gen_random_uuid(),name text);
CREATE TABLE public.songs(isrc text PRIMARY KEY,name text,album text);
CREATE TABLE public.song_identifiers(song text,platform text,identifier_type text,value text);
CREATE TABLE public.account_artist_ids(account_id uuid,artist_id uuid);
CREATE TABLE public.catalogs(id uuid PRIMARY KEY,name text,updated_at timestamptz DEFAULT now());
CREATE TABLE public.account_catalogs(account uuid,catalog uuid);
CREATE TABLE public.account_organization_ids(account_id uuid,organization_id uuid,updated_at timestamptz DEFAULT now(),PRIMARY KEY(account_id,organization_id));
GRANT USAGE ON SCHEMA public TO service_role;
GRANT SELECT ON public.account_organization_ids TO service_role;
Loading
Loading