Skip to content

ThomasMoreAI/legal-skills-open / br/general/skills/pjecalc-processamento-bragabarreto

pjecalc-processamento-bragabarreto

Verified

> Autoridade arquitetural: pjecalc-transformacao. Esta skill documenta a implementação > real das Fases 1–3 do pipeline. Em caso de conflito com pjecalc-transformacao, ela prevalece.

FileKindSize
LICENSEother1.0 KB
SKILL.mdskill md11.3 KB
references/regras-validacao.mdmarkdown4.0 KB
references/schema-contrato.mdmarkdown8.3 KB

references/regras-validacao.md

View on GitHub
# Regras de Validação e HITL Triggers

Implementado em `modules/extraction.py` (`ValidadorSentenca`, `_validar_e_completar`)
e `webapp.py` (pré-verificações antes de iniciar automação).

---

## ValidadorSentenca — API

```python
from modules.extraction import ValidadorSentenca

resultado = ValidadorSentenca(dados).validar()
# resultado.valido   → bool
# resultado.erros    → list[str]  (bloqueantes)
# resultado.avisos   → list[str]  (não bloqueantes)
```

---

## Erros bloqueantes (impedem automação)

| Campo | Regra |
|---|---|
| `processo.estado` | Obrigatório e não vazio |
| `contrato.admissao` | Obrigatório, formato DD/MM/AAAA |
| `contrato.ultima_remuneracao` | Obrigatório, > 0 |
| `contrato.demissao` | Se informado: deve ser > admissao |
| `contrato.ajuizamento` | Se informado: deve ser >= demissao |
| IA indisponível | `_erro_ia=True` → status="erro_ia", processamento bloqueado |

---

## Avisos (não bloqueantes — mostram alerta mas não impedem)

| Trigger | Condição | Ação |
|---|---|---|
| HITL 1 | confidence médio < 0.7 | Sugere revisão geral |
| HITL 2 | Campo crítico com confidence < 0.7 (admissão, remuneração, estado) | Destaca campo |
| HITL 3 | `campos_ausentes` não vazio | Lista campos obrigatórios ausentes |
| HITL 4 | tipo_rescisao × verbas incompatíveis | Ex: justa causa + aviso prévio |
| HITL 5 | > 3 verbas não mapeáveis | Sugere classificação manual |
| HITL 6 | `honorarios` vazio mas relatório menciona honorários | Alerta extração falhou |
| HITL 7 | `historico_salarial` vazio | Alerta histórico ausente |
| HITL 8 | `ferias` vazio mas sentença menciona férias | Alerta períodos não capturados |
| CNJ | Dígito verificador módulo 97 inválido | Log + aviso no SSE (não bloqueia) |

---

## Matriz de compatibilidade — tipo_rescisao × verbas

| Tipo de Rescisão | Aviso Prévio | Multa FGTS 40% | Seguro Desemprego |
|---|---|---|---|
| sem_justa_causa | ✓ | ✓ | ✓ |
| justa_causa | ✗ | ✗ | ✗ |
| pedido_demissao | ✗ | ✗ | ✗ |
| rescisao_indireta | ✓ | ✓ | ✓ |
| distrato | ✗ (parcial) | ✗ (20%) | ✗ |
| morte | N/A | ✓ | N/A |
| culpa_reciproca | ✗ (50%) | ✗ (20%) | ✗ |

---

## Validação CNJ módulo 97

```python
def _validar_cnj(numero_seq: str, digito: str, ano: str, regiao: str, vara: str) -> bool:
    """
    Fórmula CNJ Res. 65/2008:
    Montar: NNNNNNN + "00" + AAAA + "5" + TT + OOOO
    Calcular: resto = int(numero) % 97
    Dígito correto: 97 - resto
    """
    try:
        num = numero_seq + "00" + ano + "5" + regiao + vara
        resto = int(num) % 97
        return int(digito) == (97 - resto)
    except Exception:
        return True  # não bloquear se dados inválidos
```

Segmento "5" = Justiça do Trabalho (fixo).
O aviso CNJ é não bloqueante — o número pode estar correto no PJE-Calc mesmo que a
validação falhe (OCR pode ter capturado dígito errado).

---

## Pré-verificações em webapp.py (antes de iniciar Playwright)

Executadas na ordem em `executar_automacao_sse()`:

```python
# 1. Sessão existe
calculo = repo.buscar_por_sessao(sessao_id)
if not calculo:
    yield "data: ERRO_EXPORTAVEL::Sessão não encontrada\n\n"
    return

# 2. Lock — impede execuções paralelas
if sessao_id in _sessoes_automacao:
    yield "data: ERRO_EXPORTAVEL::Automação já em andamento\n\n"
    return

# 3. Prévia confirmada
if not calculo.confirmado_em:
    yield "data: ERRO_EXPORTAVEL::Prévia não confirmada\n\n"
    return

# 4. Validação dos dados
resultado = ValidadorSentenca(dados).validar()
if not resultado.valido:
    erros = "; ".join(resultado.erros[:3])
    yield f"data: ERRO_EXPORTAVEL::Validação falhou: {erros}\n\n"
    return

# 5. CNJ (aviso não bloqueante)
if _cnj_invalido:
    yield f"data: {json.dumps({'msg': '⚠ CNJ: dígito inválido — verifique o número'})}\n\n"

# 6. PJe-Calc disponível (polling até 600s — Tomcat pode demorar para subir)
# → aguarda localhost:9257 responder antes de iniciar Playwright
```
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 323kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall