-- AwoooP Phase 7 T1: outbound message truth-chain columns
--
-- Purpose:
--   Telegram must remain a summary channel, but the operator console needs a
--   complete redacted replay of the rendered card and the source envelope that
--   produced it. Store redacted content only; raw unredacted Telegram text stays
--   out of PostgreSQL.

ALTER TABLE awooop_outbound_message
    ADD COLUMN IF NOT EXISTS content_redacted TEXT,
    ADD COLUMN IF NOT EXISTS redaction_version VARCHAR(32) NOT NULL DEFAULT 'audit_sink_v1',
    ADD COLUMN IF NOT EXISTS source_envelope JSONB NOT NULL DEFAULT '{}'::jsonb;

COMMENT ON COLUMN awooop_outbound_message.content_redacted IS
    'Full rendered outbound content after audit_sink redaction; raw unredacted text is not stored.';

COMMENT ON COLUMN awooop_outbound_message.redaction_version IS
    'Redaction algorithm/version used for content_redacted and source_envelope.';

COMMENT ON COLUMN awooop_outbound_message.source_envelope IS
    'Redacted source metadata for replay/audit, including payload hash and adapter context.';
