feat(hub): expose occurred_at on recent-errors for CRM deploy verification

Add ISO-8601 occurred_at to each row returned by GET /api/error-monitoring/recent-errors
so operators can script post-deploy stability checks (BIT-1048).

Extend verify_pmx_bet_due_time_deploy.sh with a hub mode that queries open CRM
incidents matching ERRSIG 90a47beec0d7 and fails if the latest occurrence is
within HUB_DUE_TIME_STABILITY_SEC (default 7200). Skips with exit 0 when no
resolve key is present.

Document the field in HTTP_CONTRACTS, ERROR_MONITORING_PUBLIC_API, and
RUNBOOK_REPORTER_CRM_TASKS_DUE_TIME §6.2.2.

Paperclip-Agent: 5d084b36-f38f-42a5-a92a-520005afda4f
Paperclip-Issue: BIT-1048
Paperclip-Run: 5138810f-9498-49a1-81eb-291fdeba8abc
This commit is contained in:
Peter Spark committed 2026-04-05 19:15:22 +00:00
1 parent 50282ab4dd
commit 410cd7e0aa
5 files changed
+100 -3

No files matched your search

+4 -1
View File
@@ -64,12 +64,15 @@ Alias: `GET /v1/paperclip/recent-errors` (same handler).
"severity": "high",
"unique_id": "12345",
"project_slug": "crm",
"environment": "production"
"environment": "production",
"occurred_at": "2026-04-05T12:34:56.789Z"
}
]
}
```
**`occurred_at`:** ISO-8601 time of the latest occurrence represented in the row (same as `unique_id` when that id is an occurrence id). Exposed for ops automation (e.g. post-deploy “no new events in *N* hours” checks).
**`stack_trace`:** The hub returns a **non-empty** string for every row. Ingest stores a synthesized stack when the reporter omits one; for legacy occurrences whose column is still null/blank, `recent-errors` applies the same synthesis at read time using `message` and `context_json` (BIT-1008).
```bash
@@ -114,6 +114,18 @@ Com token (`Authorization: token …`) com permissão de leitura sobre o reposit
**Nota:** em algumas versões de Gitea, `GET …/hooks/{id}/deliveries` devolve **404**; nesses casos a evidência de *Recent Deliveries* (HTTP 2xx) continua a ser obtida na **UI** ou nos logs do autodeploy no destino.
### 6.2.2 Hub — recência sem UI (ERRSIG `90a47beec0d7`)
Com `ERROR_RESOLVE_API_KEY` (ou `ERROR_REPORTING_API_KEY`) e `ER_API_BASE` apontando para produção:
```bash
ERROR_RESOLVE_API_KEY=… ./scripts/crm/verify_pmx_bet_due_time_deploy.sh hub
```
- Por omissão, `HUB_DUE_TIME_STABILITY_SEC=7200` (2h) e `HUB_DUE_TIME_HUB_QUERY=90a47beec0d7` (fingerprint no título/mensagem).
- A resposta `GET …/recent-errors` inclui `occurred_at` (última ocorrência por incidente) para comparar com o relógio local do operador.
- Sem chave no ambiente, o modo `hub` **sai 0** e imprime aviso (runners CI sem vault).
### 6.3 Confirmar deploy no guest CRM (VPN / SSH)
**Sem VPN**, muitos runners Paperclip **não têm rota** para o LXC interno — ver nota em [CRM `crm.pmx.bet` — PHP deploy](https://git.bitreport.pt/BitReport.pt/paperclip/src/branch/main/docs/runbooks/CRM_PMX_BET_PHP_MIGRATE_DEPLOY.md). Com acesso a **`10.10.20.22`**: