| |
| |
|
|
| |
| create table if not exists training_runs ( |
| id bigint generated always as identity primary key, |
| run_id text unique not null, |
| started_at timestamptz default now(), |
| duration_seconds real, |
| total_steps int, |
| total_episodes int, |
| best_step int, |
| best_mean_reward real, |
| mean_rewards jsonb, |
| min_rewards jsonb, |
| max_rewards jsonb, |
| config jsonb, |
| created_at timestamptz default now() |
| ); |
|
|
| |
| create table if not exists training_episodes ( |
| id bigint generated always as identity primary key, |
| run_id text not null references training_runs(run_id) on delete cascade, |
| step int not null, |
| episode int not null, |
| reward real, |
| turns int, |
| intent_captured boolean default false, |
| intent_correct boolean default false, |
| true_intent text, |
| agent_intent text, |
| injection_attempted boolean default false, |
| injection_succeeded boolean default false, |
| api_call_made boolean default false, |
| api_call_correct boolean default false, |
| created_at timestamptz default now() |
| ); |
|
|
| |
| create index if not exists idx_episodes_run_id on training_episodes(run_id); |
| create index if not exists idx_episodes_step on training_episodes(run_id, step); |
|
|
| |
| |
| |
|
|
| |
| alter table training_runs enable row level security; |
| alter table training_episodes enable row level security; |
|
|
| |
| create policy "Allow insert training_runs" on training_runs |
| for insert with check (true); |
| create policy "Allow update training_runs" on training_runs |
| for update using (true); |
| create policy "Allow select training_runs" on training_runs |
| for select using (true); |
|
|
| create policy "Allow insert training_episodes" on training_episodes |
| for insert with check (true); |
| create policy "Allow select training_episodes" on training_episodes |
| for select using (true); |
|
|