-- Wever Labs Runtime Smoke Tests v1
-- Run after deployment to confirm the main rail can store pilot records.

insert into agent_onboarding_records (onboarding_id, agent_id, manifest_url, trust_status, status_url, quote_path_url, run_contract_path_url, payload)
values ('onboard_smoke_tokenops_001', 'agent_smoke_001', 'https://weverlabs.com/agents.json', 'approved', '/api/agents/onboarding/onboard_smoke_tokenops_001', '/api/agents/onboarding/onboard_smoke_tokenops_001/quote-path', '/api/agents/contracts/contract_smoke_001', '{"tool":"tokenops","source":"smoke_test"}'::jsonb)
on conflict (onboarding_id) do update set trust_status = excluded.trust_status, payload = excluded.payload;

insert into agent_trust_profiles (trust_profile_id, agent_id, trust_state, allowed_tools, callback_url, payload)
values ('trust_smoke_001', 'agent_smoke_001', 'approved', array['tokenops','financeops','energyops'], 'https://example.com/wever-callback', '{"source":"smoke_test"}'::jsonb)
on conflict (trust_profile_id) do update set trust_state = excluded.trust_state, allowed_tools = excluded.allowed_tools;

insert into agent_quote_records (quote_id, agent_id, requested_tool, workflow_type, quoted_credits, quote_state, payload)
values ('quote_smoke_001', 'agent_smoke_001', 'tokenops', 'tokenized_asset_operations', 12, 'issued', '{"source":"smoke_test"}'::jsonb)
on conflict (quote_id) do update set quoted_credits = excluded.quoted_credits;

insert into settlement_provider_routes (route_id, provider, agent_id, quote_id, settlement_id, route_state, confirmation_status, payload)
values ('provider_route_smoke_001', 'stripe_stablecoin', 'agent_smoke_001', 'quote_smoke_001', 'settlement_smoke_001', 'confirmed', 'verified', '{"source":"smoke_test"}'::jsonb)
on conflict (route_id) do update set route_state = excluded.route_state, confirmation_status = excluded.confirmation_status;

insert into agent_credit_entitlements (credit_entitlement_id, agent_id, quote_id, settlement_id, credits_granted, credits_remaining, entitlement_state, payload)
values ('credit_smoke_001', 'agent_smoke_001', 'quote_smoke_001', 'settlement_smoke_001', 12, 12, 'active', '{"source":"smoke_test"}'::jsonb)
on conflict (credit_entitlement_id) do update set credits_remaining = excluded.credits_remaining;

insert into agent_run_contracts (contract_id, agent_id, requested_tool, workflow_type, contract_state, payload)
values ('contract_smoke_001', 'agent_smoke_001', 'tokenops', 'tokenized_asset_operations', 'active', '{"source":"smoke_test"}'::jsonb)
on conflict (contract_id) do update set contract_state = excluded.contract_state;

insert into wever_intake_work_order_dispatches (dispatch_id, intake_request_id, work_order_id, requested_tool, runtime_record_id, run_contract_id, quote_id, credit_entitlement_id, provider_route_id, queue_state, return_contract, evidence_bindings)
values ('dispatch_smoke_001', 'intake_smoke_001', 'wo_smoke_001', 'tokenops', 'runtime_smoke_001', 'contract_smoke_001', 'quote_smoke_001', 'credit_smoke_001', 'provider_route_smoke_001', 'queued', '{"result_contract":"pending"}'::jsonb, '[{"type":"manifest","status":"received"}]'::jsonb)
on conflict (dispatch_id) do update set queue_state = excluded.queue_state;
