create table if not exists operator_notes ( id bigserial primary key, instrument_id bigint not null references instruments(id), note_scope text not null, session_code text, execution_id bigint references trade_executions(id), signal_id bigint references trade_signals(id), candidate_id bigint references trade_plan_candidates(id), decision_packet_id bigint references decision_packets(id), author text not null, body text not null, tags jsonb not null default '[]'::jsonb, created_ts timestamptz not null, updated_at timestamptz not null default now() ); create index if not exists idx_operator_notes_instrument_created_desc on operator_notes (instrument_id, created_ts desc, id desc);