Skip to content

feat(backend): audit-log retention, webhook latency histogram, and migration rollback runbook#1196

Merged
Emmyt24 merged 1 commit into
nova-launch01:mainfrom
jasmine874:feat/backend-1115-1116-1117-1118
May 28, 2026
Merged

feat(backend): audit-log retention, webhook latency histogram, and migration rollback runbook#1196
Emmyt24 merged 1 commit into
nova-launch01:mainfrom
jasmine874:feat/backend-1115-1116-1117-1118

Conversation

@jasmine874

@jasmine874 jasmine874 commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

closes #1115
closes #1116
closes #1117
closes #1118

Issue #1115 was already fully implemented in the same commit as the others —
backend/src/graphql/index.ts has the queryComplexity() function, configurable
MAX_COMPLEXITY/LIST_FIELD_COST env vars, and rejects queries over budget with a typed GraphQLError.

  • Implement audit-log retention policy enforcement #1116 — Added auditRetentionJob service that purges audit entries older than AUDIT_RETENTION_DAYS (default 90 days) on a configurable AUDIT_RETENTION_INTERVAL_MS schedule. Added Database.purgeAuditLogs() for idempotent, cutoff-based eviction. Job logs every run.
  • Instrument webhook delivery latency as a Prometheus histogram #1117 — Added webhookDeliveryLatency Prometheus histogram to lib/metrics with outcome and attempt_count labels. Buckets tuned for fast (<500 ms) and retried (≤60 s) deliveries. webhookDeliveryService now observes it after every completed delivery attempt.
  • Document and verify a safe database migration rollback procedure #1118 — Added docs/MIGRATION_ROLLBACK_RUNBOOK.md documenting the full Prisma rollback procedure (down SQL authoring, _prisma_migrations update, irreversible-operation guidance). Added migration-rollback.smoke.test.ts that applies and reverts a canary migration against a disposable Postgres schema; auto-skips when DATABASE_URL is unset.

Files changed

  • backend/src/services/auditRetentionJob.ts — retention job
  • backend/src/config/database.tspurgeAuditLogs() helper
  • backend/src/lib/metrics/index.ts — webhook latency histogram
  • backend/src/monitoring/metrics/prometheus-config.ts — NoOp stub registration
  • backend/src/services/webhookDeliveryService.ts — histogram observation
  • docs/MIGRATION_ROLLBACK_RUNBOOK.md — rollback runbook
  • backend/src/__tests__/migration-rollback.smoke.test.ts — smoke test

…webhook latency histogram, and migration rollback runbook

- nova-launch01#1115: Extend GraphQL endpoint with per-query cost analysis. Each field
  carries a cost of 1; list fields (tokens, burnRecords, streams, proposals,
  votes, campaigns) cost LIST_FIELD_COST (default 10) to penalise fan-out.
  Queries exceeding MAX_COMPLEXITY (default 100) are rejected with a typed
  GraphQLError before execution. MAX_DEPTH, MAX_COMPLEXITY, and
  LIST_FIELD_COST are all configurable via env vars.

- nova-launch01#1116: Add auditRetentionJob service that purges in-memory AuditLog entries
  older than AUDIT_RETENTION_DAYS (default 90 days) on a configurable
  AUDIT_RETENTION_INTERVAL_MS schedule. Adds Database.purgeAuditLogs() for
  idempotent, cutoff-based eviction. Job is idempotent and logs every run.

- nova-launch01#1117: Add webhookDeliveryLatency Prometheus histogram to lib/metrics with
  outcome and attempt_count labels and buckets tuned for fast (<500 ms) and
  retried (≤60 s) deliveries. webhookDeliveryService now observes it after
  every completed delivery attempt. NoOp stub added to prometheus-config.ts.

- nova-launch01#1118: Add MIGRATION_ROLLBACK_RUNBOOK.md documenting the full Prisma
  rollback procedure (down SQL authoring, _prisma_migrations update,
  irreversible-operation guidance). Add migration-rollback.smoke.test.ts
  that applies and reverts a canary migration against a disposable Postgres
  schema; auto-skips when DATABASE_URL is unset.

Closes nova-launch01#1115, nova-launch01#1116, nova-launch01#1117, nova-launch01#1118

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@drips-wave

drips-wave Bot commented May 28, 2026

Copy link
Copy Markdown

@jasmine874 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Emmyt24 Emmyt24 merged commit a3ea7a6 into nova-launch01:main May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants