Skip to content

WA.Auto: incluir processos encerrados com movimentação comprovada - #44

Merged
W1CAPITAL merged 6 commits into
mainfrom
fix/waauto-include-closed-updates-20261009
Oct 9, 2026
Merged

W1CAPITAL merged 6 commits into
mainfrom
fix/waauto-include-closed-updates-20261009

Conversation

@W1CAPITAL

Copy link
Copy Markdown
Owner

Objetivo

Notificar clientes de toda a carteira W1 Capital, incluindo registros marcados ENCERRADO, quando há nova movimentação DataJud/DJEN posterior ao último retorno.

Alterações

  • A seleção de campanhas de movimentação e a fila do scanner incluem também encerrados, sem anunciar encerramento a partir do campo de status interno.
  • Retornos periódicos (due) mantêm a regra anterior para evitar comunicações sem novidade.
  • Preservadas validação de consentimento/opt-out, CNJ, frescor da consulta, prova DJEN, deduplicação no Supabase e pausa em envio incerto.
  • Prévia indica o número de encerrados elegíveis; testes de regressão cobrem encerrado elegível, evento repetido e opt-out.

Segurança de produção

O Supabase mostra automação diária desativada, campanha mais recente pausada e cron lexis-wa-movement desativado. Este PR não os reativa e não faz disparos; a conexão real WA.Auto precisa ser conferida antes de retomar envio em massa.

Verificação

Executar testes CI e conferir previamente uma amostra dos avisos/entregas no WA.Auto.

@vercel

vercel Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Deployment failed for project private with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/assecom?upgradeToPro=build-rate-limit

@strix-security

strix-security Bot commented Oct 9, 2026

Copy link
Copy Markdown

Strix is installed on this repository, but we couldn't run this PR security review because this workspace's trial has ended. Add a card to resume code reviews here.

@netlify

netlify Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for lexispredict ready!

Name Link
🔨 Latest commit 09b482f
🔍 Latest deploy log https://app.netlify.com/projects/lexispredict/deploys/6ac95556ee38ca00087d80a5
😎 Deploy Preview https://deploy-preview-44--lexispredict.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T21:02:24.037554Z bad063f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@W1CAPITAL
W1CAPITAL merged commit d3ea6d2 into main Oct 9, 2026
5 of 8 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bad063feaa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +49 to +50
const allowed=prepareMovementAlert(closed);
expect(allowed.reason).toBe('ok');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the conflicting closed-case regression test

This new ok expectation directly conflicts with src/lib/wa-movement-builder.test.ts:36-38, which still expects the same prepareMovementAlert({...base, status:'ENCERRADO'}) call to return closed. Because prepareMovementAlert now always passes includeClosed:true, the pre-existing test will receive ok, causing the full Vitest suite to fail until that assertion is updated.

Useful? React with 👍 / 👎.

} else entries.push(alert);
} else {
entries.push(alert);
if(isCasoEncerrado(row))counts.closedEligible++;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Count closed eligibility after removing prior notices

Incrementing closedEligible here counts every otherwise valid closed alert before wa_notice_prior removes already queued or sent events. For example, a portfolio containing one previously sent closed-case event produces eligible: 0 but closedEligible: 1, while the UI describes that case as eligible and included in the selection. Derive this count from pending, or preserve closed status on alerts so the preview reports only notices that can actually be queued.

Useful? React with 👍 / 👎.

Comment on lines 174 to +176
{kind==='publication'
? 'Considera toda a carteira da empresa, de todos os responsáveis. Envia apenas para processos abertos com movimentação DataJud/DJEN posterior ao último retorno marcado. Eventos antigos e processos encerrados são excluídos.'
: 'Consulta toda a carteira da empresa. Prepara um aviso somente quando há movimentação posterior ao último retorno, excluindo encerrados, bloqueados e avisos já registrados.'}
? 'Considera toda a carteira da empresa, de todos os responsáveis. Considera também processos marcados como encerrados. Envia somente movimentação DataJud/DJEN posterior ao último retorno, com teor oficial verificável, consentimento e sem bloqueio.'
: 'Consulta toda a carteira da empresa. Prepara um aviso por novidade posterior ao último retorno, inclusive de processos marcados como encerrados. Bloqueios, avisos repetidos e eventos sem prova verificável são excluídos.'}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove the contradictory closed-case exclusion notice

The updated description tells managers that closed processes are included, but the same confirmation dialog still states at lines 256-259 that the system excludes closed processes. Since the backend now includes them, an operator can start a customer-facing bulk campaign based on a false exclusion summary; the final notice should accurately describe the recipients before enabling the send.

Useful? React with 👍 / 👎.

Comment on lines +70 to +73
// Movimento posterior confirmado pode ocorrer em uma carteira marcada como encerrada.
// Apenas os avisos de movimentação da carteira optam por incluir esses casos;
// um status interno nunca é prova de encerramento definitivo no tribunal.
if(isCasoEncerrado(row) && !opts.includeClosed)return {ready:null,reason:'closed'};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow verified terminal events for already-closed cases

When an already-closed case has a fresh official terminal event, this new bypass lets it reach the source checks, but the unchanged guards at lines 103-104 and 115-117 still return needs_source_review for terminal DataJud descriptions and verified DJEN evidence. Those guards previously only encountered open cases—the DJEN comment explicitly says they prevent announcing closure while the portfolio remains open—so the newly supported closed case is never queued for precisely the extinction, final dismissal, or archival movement that commonly accompanies closure. Apply the terminal safeguard conditionally when the portfolio is still open, or otherwise handle verified terminal evidence for closed rows.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant