Repository navigation
feat(integridad): verificador de integridad de solo lectura (PR-A) - #291
Merged
Merged
Conversation
Reglas V1–V13 y V15 del plan de integridad v1.2 §5.A como consultas SELECT que corren dentro de una transacción READ ONLY: Postgres rechaza cualquier escritura con 25006. El reporte se devuelve al llamador; no se persiste, no se notifica y no se corrige nada. Sin cron. - src/lib/integridad/: reglas + verificarIntegridad() + enSoloLectura() - GET /api/integridad (solo ADMIN) - scripts/verificar-integridad.ts (tabla o --json; exit 1 si hay CRÍTICAS) V2 excluye el Abono espejo que pagar-fiado crea junto al Pago, y resuelve el pedido de un abono suelto por su factura (Abono.pedidoId puede ser null). V14 depende de Pago.regularizacionId (PR-D) y se agrega con ese cambio. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01N4EvimoVAYZdhzbZsGvFNV
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Oct 22, 2026
Closed
Closed
Closed
This branch was successfully deployed
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.
Objetivo
PR-A del plan de integridad v1.2 §5.A: un verificador que solo lee. Corre las reglas de integridad y devuelve un reporte. No escribe en ninguna tabla, no notifica, no corrige y no agrega cron (eso es PR-A2, con autorización aparte).
Cambios
src/lib/integridad/reglas.ts: reglas V1–V13 y V15 como consultasSELECT. Cada hallazgo traeref,numeroydetalle(la evidencia).src/lib/integridad/verificar.ts:verificarIntegridad()corre todas las reglas dentro deenSoloLectura(), que haceSET TRANSACTION READ ONLY;GET /api/integridad: solo ADMIN.scripts/verificar-integridad.ts: muestra una tabla, o el reporte completo con--json. Sale con código 1 si hay hallazgos CRÍTICOS.AGENTS.md: fila en File Reference.Detalles de las reglas
totalPagado= Σ Pago + Σ Abono):Abonoespejo quepagar-fiadocrea junto a suPago(mismo pedido, monto y método, en la misma transacción);Abono.pedidoIdpuede venir vacío;ReceivableEntryenlazada por factura (abonos sueltos).Pago.regularizacionId(PR-D).diasReportado, que por defecto vale 3. Es configurable; falta que el negocio confirme el valor.Criterios de aceptación (plan §8, fila A)
pedidoId.Validaciones ejecutadas
npx tsc --noEmityeslintsobre los archivos tocados: limpios.npm run test: 372 archivos, 3.599 tests.verificador-integridad.test.ts): 15/15.SET TRANSACTION READ ONLY, falla la prueba de 25006;BEGIN TRANSACTION READ ONLY:Pedido_numero_seq, que corrige PR-C).Limitaciones conocidas
prisma/validate-data.ts(/api/validate-data) ya tiene checks parecidos, pero no corren en solo lectura y no excluyen el espejo. Este PR no lo modifica.E2E
Este PR no toca UI, fixtures ni flujos E2E. Cualquier fallo E2E debe estar en la línea base de
main(Known Issues #20).Merge
Requiere la autorización Z1 del PO. No se fusiona sin ella.
🤖 Generated with Claude Code
https://claude.ai/code/session_01N4EvimoVAYZdhzbZsGvFNV
Generated by Claude Code