feat: add summary moderation schema (migration 013)#189
Open
ODenteAzul wants to merge 1 commit into
Open
Conversation
Add PostgreSQL schema for content safety guardrails tracking: - summary_blocked (BOOLEAN): flag de bloqueio - summary_blocked_reason (TEXT): razão do bloqueio - summary_blocked_at (TIMESTAMP): quando foi bloqueado Inclui: - Índices otimizados para queries de auditoria - View news_moderation_log: log de bloqueios - View news_moderation_stats: estatísticas diárias - Script de ROLLBACK para reverter se necessário Issue: #187 (sub-issue de #176) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 2: data-platform (database schema)
Título
feat: add summary moderation schema (migration 013)
Body
Summary
Adiciona campos na tabela
newspara tracking de moderação de resumos gerados por LLM, suportando os guardrails de segurança implementados no data-science.Changes
Migration 013: Summary Moderation Fields
Campos:
summary_blocked: Flag indicando se resumo foi bloqueado (TRUE = bloqueado, FALSE = aprovado)summary_blocked_reason: Motivo do bloqueio (ex: "regex: CPF detectado", "llm: linguagem ofensiva")summary_blocked_at: Timestamp de quando foi bloqueadoÍndices para Performance
Benefícios:
Views de Auditoria
1. news_moderation_log - Log completo de bloqueios
Uso: Auditoria e investigação de bloqueios individuais
2. news_moderation_stats - Estatísticas diárias
Uso: Dashboard de moderação (taxa de bloqueio ao longo do tempo)
Rollback Incluído
Arquivo
013_add_summary_moderation_ROLLBACK.sqlpara reverter se necessário:Use Cases
1. Auditar bloqueios recentes
2. Taxa de bloqueio por dia
3. Distribuição de motivos de bloqueio
4. Notícias bloqueadas de uma agência específica
Migration Safety
Backward compatible:
IF NOT EXISTSevita erro se colunas já existiremDEFAULT FALSEnão afeta registros existentesNULLouFALSEpor padrão (sem impacto)No downtime:
ADD COLUMNé operação rápida (não reescreve tabela)Rollback seguro:
Testing
Expected Impact
Related Issues & PRs
How to Apply
Staging:
Production:
# Via workflow manual dispatch gh workflow run db-migrate.yaml --field migration=013Rollback (se necessário):
Generated with Claude Code (https://claude.com/claude-code)