feat(resources): auto-ocultado opcional como política por emergencia#423
Open
nopestack wants to merge 6 commits into
Open
feat(resources): auto-ocultado opcional como política por emergencia#423nopestack wants to merge 6 commits into
nopestack wants to merge 6 commits into
Conversation
…lobalEmergency#171) Añade el flag por emergencia autoHideOnDispute (default off, migración 0059). Con la política activa, un handler de ResourceDisputed reutiliza el mismo camino de ResolveResourceDispute (confirm_closed) para cerrar el punto automáticamente al alcanzar el umbral de disputa, dejando traza en el audit trail atribuida a "system". Con la política desactivada, el comportamiento del MVP no cambia (el punto sigue visible con badge hasta que un coordinador confirma o descarta). - Emergency: autoHideOnDispute + SetEmergencyAutoHideOnDispute, endpoint PUT /emergencies/:id/auto-hide-on-dispute (permiso emergency:configure), expuesto en GET /emergencies/mine. - resources: AutoHideDisputedResource + handler de resource.disputed en el consumer existente, puertos EmergencyAutoHideOnDisputeReader y AuditTrail (adaptadores Drizzle compartidos, mismo patrón que el umbral de disputa). - web: toggle de la política en el panel de EmergencyControls (coordinación). - pnpm gen:api tras el nuevo endpoint/DTO.
|
@nopestack is attempting to deploy a commit to the GlobalEmergency Team on Vercel. A member of the Team first needs to authorize it. |
…, ambas ramas partieron del mismo main)
Contributor
Author
|
Nota: renombré la migración de |
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.
Closes #171
Resumen
Implementa la política opt-in por emergencia
autoHideOnDispute(§4 Futuro dedocs/features/15-reporte-validez-de-puntos.md): cuando está activa, un handler deResourceDisputedcierra el punto automáticamente al alcanzar el umbral de disputa, reutilizando el mismo camino deResolveResourceDispute(confirm_closed) que usa un coordinador humano — mismo estado (Closed), mismos efectos, y traza en el audit trail atribuida a"system". Por defecto está desactivada, así que el comportamiento del MVP (punto visible con badge, confirma un humano) no cambia para ninguna emergencia existente.Backend
Emergency: nuevo flagautoHideOnDispute(defaultfalse) +setAutoHideOnDispute(); migración0059_emergency_auto_hide_on_dispute.sql(columnaauto_hide_on_dispute boolean NOT NULL DEFAULT false, junto al umbral de disputa de Disputa: umbral configurable por emergencia #169).SetEmergencyAutoHideOnDispute(caso de uso) +PUT /emergencies/:emergencyId/auto-hide-on-dispute(emergency:configure, igual que el umbral); se expone enGET /emergencies/mine(vista autenticada, igual queresourceDisputeThreshold).resources: nuevo handler para el eventoresource.disputed(antes sin suscriptor) en la cola existente del consumerresources. El caso de usoAutoHideDisputedResource:EmergencyAutoHideOnDisputeReader(adaptador Drizzle compartido, mismo patrón que el umbral);ResolveResourceDispute.execute({ resolution: 'confirm_closed', coordinatorId: 'system' })— no una segunda vía para cerrar el recurso;AuditTrail(adaptador Drizzle compartido que escribe directo aaudit_log, ya que no hay request HTTP paraAuditInterceptor), conactorUserId: null/actorName: 'system'.Web
EmergencyControls(panel de coordinación/emergencies/[slug]/manage), junto a pausar/reanudar y el comunicado oficial — mismo patrón deuseActionState+ server action. El valor actual se obtiene deGET /emergencies/mine(no existía aún consumidor web para esa vista).pnpm gen:apiejecutado;packages/api-client/src/schema.tsyapps/api/openapi.jsonactualizados.Pendiente / fuera de alcance de este PR
No existe todavía una pantalla de "ajustes de emergencia" dedicada — el toggle se añadió al panel de coordinación existente (
EmergencyControls), en el lugar más consistente con el umbral de disputa (que tampoco tenía UI antes de este PR). Si se decide construir una pantalla de ajustes dedicada más adelante, ambos controles deberían migrar juntos.Test plan
pnpm install --frozen-lockfilepnpm --filter api buildpnpm --filter api exec eslint "{src,apps,libs,test}/**/*.ts" --max-warnings=0pnpm --filter api exec prettier --check "src/**/*.ts" "test/**/*.ts"pnpm --filter api test(256 suites / 1654 tests)pnpm --filter @reliefhub/api-client build && pnpm --filter web buildpnpm --filter web lint(1 warning preexistente sin relación,opengraph-image.tsx)pnpm --filter web test(118 tests)Emergency(política on/off),SetEmergencyAutoHideOnDispute,AutoHideDisputedResource(política off → no-op, política on → cierra + audita, idempotente si un humano ya resolvió),resourceDisputedHandler, DTO de validación.