recent-errors built its result by ranking ALL occurrences of every
matching incident with ROW_NUMBER() before applying LIMIT, so
status=resolved (the majority, longest-lived incident state) forced a
scan of the full historical occurrence log just to return one page.
admin/incidents.ts already filters/orders er_incidents directly for
this reason; apply the same pattern here: page through er_incidents
first (small, indexed by current_state), then rank occurrences only
for that page. The q= search path is kept on the old occurrence-first
query since it needs to match occurrence content across an incident's
full history.
Adds er_incidents_state_seen_idx (current_state, last_seen_at) so the
new incident-first path stays indexed even without a project_slug
filter, and backfills the docker/local migration runners that had
drifted behind deploy/lxc/run-migrate.sh (missing three prior
migrations), since the new migration needs to run through them too.
Verified locally against MariaDB (docker compose) with 3k resolved /
20 open incidents and ~90k synthetic occurrences: the reported repro
curls now return HTTP 200 in <100ms (previously reproduced as a hang
via manual EXPLAIN/timing of the old query, ~2s at this seed size and
scaling with total occurrence history).
Block ingest for retired WDMI slugs, purge project data via migration,
remove WDMI runbooks, and add offboard-project helper for future retirements.
Co-authored-by: Cursor <[email protected]>
Document LAN sanity (gateway + CT 220 vs Importer-only failure). On SSH
failure, print neighbour state and point operators to --diagnose.
Paperclip-Issue: BIT-1044
Paperclip-Run: 147742f4-8b99-40fa-8e50-d4e8c4b052a4
Paperclip-Agent: 5d084b36-f38f-42a5-a92a-520005afda4f
Add operational checklist for Paperclip host to WDMI Importer (192.168.1.123):
network prerequisites, authorized_keys for paperclip@bitreport-cto, Proxmox
alternative path, and an executable acceptance script.
Cross-link from RUNBOOK_REPORTER_WDMI_CACHE_MKDIR.md.
Paperclip-Issue: BIT-1044
Paperclip-Run: b99b90b0-311f-442e-82ce-5c8644abffb1
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
Add scripts/crm/verify_pmx_bet_profile_and_limit_deploy.sh (gitea + runtime) to assert
CRM_Project main contains the BIT-881 UserController/Sanitize fix and the DatabaseManager
LIMIT/OFFSET integer bind chain (c0afd0183). Document §6 in the Sanitize and SQL LIMIT
runbooks for operators closing the error loop after deploy.
Paperclip: BIT-881, BIT-937
Paperclip-Run-Id: b075f087-a1e8-47cd-aca7-fbfcec7a21bb
Paperclip-Agent: d706f4e6-5d05-4cec-b6e8-f8fb1f203aae
Made-with: Cursor
Add scripts/crm/verify_pmx_bet_due_time_deploy.sh with gitea (ancestor
check vs CRM_Project main) and runtime (SSH to crm-repo) modes. Point
the due_time runbook at the script for operators without VPN on runners.
Paperclip-Issue: BIT-1049
The single-domain deployment (errors.bitreport.pt) routed all traffic
through the admin-ui, whose auth middleware redirected /v1/ingest/events
and /health to /login — making the ingest API unreachable from outside.
- middleware.ts: pass through /v1/* and /health without auth redirect
- next.config.ts: rewrite /v1/* and /health to ingest-api backend
(INGEST_API_URL env, default http://127.0.0.1:3041)
- docker-compose.yml: set INGEST_API_URL=http://ingest-api:3041
- env examples: document INGEST_API_URL
- scripts/onboard-project.sh: generate project + ingest key SQL
Paperclip-Agent: peter-spark
Paperclip-Issue: BIT-750
Paperclip-Run: dc5b7949-b24d-4867-a2cd-cf4f47477ef8
Add canonical HTTP_CONTRACTS with curl for hub + ingest endpoints, operator
runbooks for ingest debugging and five common hub flows, and Grafana/Prometheus
scraping notes. Extend ERROR_MONITORING_PUBLIC_API with stats + curl examples;
align purge and resolve-by-pattern docs with the Fastify implementation.
Add optional smoke scripts under scripts/examples/.
Paperclip-Agent: 5d084b36-f38f-42a5-a92a-520005afda4f
Paperclip-Issue: BIT-736
Paperclip-Run: ad2c5129-df54-44aa-afd4-6f9f7486c1a1
Made-with: Cursor
- scripts/er-cli.sh: CLI operacional sem UI com comandos list-open,
export, resolve, resolve-by-pattern e purge; idempotente, dry-run
em resolve-by-pattern e purge, autenticação via ERROR_RESOLVE_API_KEY
- docs/RUNBOOK_TRIAGE.md: runbook completo de triagem, resolução, deploy
e fecho com checklist de validação pós-deploy e tabela de escalada
Paperclip-Issue: BIT-730
Paperclip-Run: f06292f3-5ab7-4715-9b61-6dee07a47ad7
Replace Postgres with MariaDB 11 in docker-compose; convert all
database/error_reporting and db/migrations SQL to InnoDB-friendly syntax
(DATETIME(6), AUTO_INCREMENT, ON DUPLICATE KEY). Run admin portal DDL in the
same migrate one-shot as error_reporting.
Switch ingest-api, collector-worker, and api from pg to mysql2 (pools,
parameterized queries, transactions). Align ingest writes with
er_incident_occurrences and include project_id on idempotency inserts.
Add scripts/run-mysql-migrations.sh for host-side applies; update LXC
run-migrate/verify, deployment docs, and .env.example (mysql://, ER_MYSQL_*).
Verified: npm run build + npm test in ingest-api and collector-worker;
npm run build in api. Full docker compose not run here (no local daemon).
Co-Authored-By: Paperclip <[email protected]>