feat(h4-1): log de eventos JSONL append-only + ADR-0018 (RF-06/RN-03/RN-07/CP-08)#25
Merged
Merged
Conversation
Cierra RF-06 (log inmutable), RN-03/RN-07 (append-only) y CP-08 (intento
de edición) — primera fase de H4.
Nuevo port `RepositorioEventos` (ports/repositorio_eventos.py):
- `EventoLog` Pydantic frozen con extra="forbid" + strict.
- `TipoEvento` StrEnum cerrado de 7 valores alineado a data-model.md.
- Protocol `@runtime_checkable` sin update/delete por diseño.
- `EventoDuplicadoError(ValueError)` para idempotencia.
Nuevo adapter `JsonlRepositorioEventos` (adapters/repositorio_jsonl.py):
- Append puro con `open("a")`, validación Pydantic en escritura y
lectura, dedupe por evento_id con set in-memory cargado desde disco.
- Generador `EVT-<YYYYMMDDTHHMMSS>-<seq04>` único monotónico.
Extracción `serializar_resultado_despacho` a application/serializacion:
- Punto único de verdad del schema RT-02 (ADR-0017) reutilizado por el
payload de `despacho_creado` (ADR-0018). Bit-exactitud por construcción.
CLI `sentinel run-dataset` admite flag opcional `--log-eventos PATH`:
- Si presente, persiste un evento `despacho_creado` por incidente.
- Sin el flag, comportamiento RT-02 preservado 100%.
ADR-0018 congela el schema del evento_log e incluye spike CP-08 que
documenta: duplicación de línea detectable via EventoDuplicadoError y
schema drift via ValidationError al reabrir.
Tests: 22 nuevos verdes (16 UT adapter + 4 IT + 2 CLI). Suite total
235/235 verde. Cobertura repositorio_jsonl 100%, serializacion 96%,
global 91.93%.
…CHANGELOG Trazabilidad: - RF-06 ✅: apunta a `adapters/repositorio_jsonl.py` + ADR-0018; el caso de prueba referencia el spike CP-08. - RN-03 ✅: el Protocol no expone `update`/`delete` y el adapter rechaza re-escritura con EventoDuplicadoError. - RN-07 ✅: append puro verificado por `test_dos_appends_consecutivos_solo_crecen_el_archivo`. - §5.7 actualizada: el adapter ya implementado en H4-1; quedan exportador (RF-11), simulación (RF-12) y calibración (ADR-0013) para fases siguientes de H4. CHANGELOG: nueva entrada "H4 fase 1: log de eventos JSONL append-only" bajo [Unreleased] con resumen del port, adapter, serializador extraído, flag CLI, ADR-0018 + spike CP-08, y métricas de la suite (235/235, cov 91.93%).
Jacket-69
added a commit
that referenced
this pull request
May 29, 2026
feat(h4-1): log de eventos JSONL append-only + ADR-0018 (RF-06/RN-03/RN-07/CP-08)
Jacket-69
added a commit
that referenced
this pull request
May 29, 2026
feat(h4-1): log de eventos JSONL append-only + ADR-0018 (RF-06/RN-03/RN-07/CP-08)
Jacket-69
added a commit
that referenced
this pull request
May 29, 2026
feat(h4-1): log de eventos JSONL append-only + ADR-0018 (RF-06/RN-03/RN-07/CP-08)
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.
Resumen
Primera fase de H4: log canónico de eventos del sistema en JSONL append-only. Cierra cuatro requisitos del SRS de un golpe — RF-06 (log inmutable), RN-03 (log inmutable estructural), RN-07 (append-only) y CP-08 (spike: intento de edición detectable).
Cambios
Port
RepositorioEventos(ports/repositorio_eventos.py):EventoLogPydantic frozen +extra=\"forbid\"+ strict.TipoEventoStrEnum cerrado de 7 valores alineado adocs/data-model.md.@runtime_checkableSIN métodosupdate/deletepor diseño.EventoDuplicadoError(ValueError)para idempotencia ante reintentos.Adapter
JsonlRepositorioEventos(adapters/repositorio_jsonl.py):open(\"a\")puro + validación Pydantic en escritura y lectura.evento_idcon set in-memory cargado desde disco al construir.EVT-<YYYYMMDDTHHMMSS>-<seq04>.Extracción
serializar_resultado_despachoaapplication/serializacion:despacho_creado(ADR-0018). Bit-exactitud por construcción.CLI
sentinel run-dataset --log-eventos PATH(opcional):compare).despacho_creadopor incidente en el log canónico.ADR-0018 congela el schema del evento_log y documenta el spike CP-08 ejecutado: el adapter detecta duplicación externa via
EventoDuplicadoErrory schema drift viapydantic.ValidationErroral reabrir.Decisiones arquitectónicas no triviales
despacho_creadoconpayload.unidad_seleccionada=nullypayload.motivo=\"saturacion\". Se descarta crear un tipodespacho_saturacionaparte (no agrega valor consultable; rompería el modelo de datos sin justificación).fcntl.flock. Documentado en ADR-0018 §"Concurrencia".Validación local
ruff check+ruff format --check: ✓ All checks passed (65 archivos).mypy src/sentinel_dispatch: ✓ Success en 34 archivos.pytest tests/unit tests/integration --no-cov: 235 passed in 3.45s (213 baseline + 22 nuevos).pytest tests/unit(cov-fail-under=90): cov global 91.93%,repositorio_jsonl.py100%,serializacion.py96%,repositorio_eventos.py90%.DoD
comparedebe seguir 12/12 OK bit-exacto.Commits
b04cf1ffeat(h4-1): log de eventos JSONL append-only + ADR-0018035aa60docs(quality): RF-06/RN-03/RN-07 ✅ + entrada H4-1 en CHANGELOGTrazabilidad
Cierra 3 de 4 RFs originalmente pendientes para H4 (queda RF-11 y RF-12). Ejecuta la convención
spike-before-CPsobre CP-08. Próxima fase: exportador CSV/JSON (RF-11, ADR sin nuevo) según plan H4.