feat: implement audit log pagination, bounded batch retention cleanup… - #614
Open
Fatimasanusi wants to merge 1 commit into
Open
Fatimasanusi wants to merge 1 commit into
Fatimasanusi wants to merge 1 commit into
Conversation
…, and moderation audit history with tests and runbooks
|
@Fatimasanusi 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! 🚀 |
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.
Description
This PR resolves four backend and smart contract operational issues: replacing collision-prone reward shop identifiers with deterministic UUIDs and idempotency protection, implementing the admin moderation audit query API with canonical auth, adding bounded retention cleanup cron jobs for high-volume append-only tables, and providing the contract pause and recovery runbook.
Closes #542
Closes #557
Closes #561
Closes #562
Key Changes by Issue
1. #542 Reward Shop Collision Fix & Idempotency
Date.now() + Math.randomwithuuidv4()inRewardShopService.idempotencyKeysupport inPurchaseItemDtoandpurchaseItem(). Retried requests with the same key return the existing record without deducting user points or inventory a second time.purchase-*records remain queryable viagetPurchaseById(); added readablereferenceId.2. #557 Admin Moderation Audit Query API
FilterAuditLogDtoandAuditLogService.findAll()to filter byactor/userId,targetType,targetId,action, and date ranges, with bounded pagination (limitcapped at 100) and deterministic ordering (timestamp DESC, id DESC).AuditLogControllerandModerationControlleron canonicalJwtAuthGuardandRolesGuard(AdminRole.ADMIN,AdminRole.SUPERADMIN).GET /admin/audit-logs/moderation/:reviewIdandGET /moderation/:reviewId/decision-historyto correlate moderation decisions with immutable audit log trails.docs/api.mdand test coverage inaudit-log.controller.spec.tsandaudit-log.service.spec.ts.3. #561 Retention Jobs for High-Volume Append-Only Records
docs/retention-policy.mddocumenting windows and separating user-facing history from operational telemetry:analytics_events: 90 days (recent solve history retained; historical totals preserved viapuzzle_stats_mv).audit_logs: 90 days (compliance audit trail).activity_logs: 30 days (operational debugging; user achievements stored in domain tables).puzzle_access_logs: 14 days (short-term trend telemetry).@Cron(CronExpression.EVERY_DAY_AT_MIDNIGHT)batch cleanup inAnalyticService,AuditLogService,UserActivityLogService, andPuzzleAccessLogService.FOR UPDATE SKIP LOCKEDand ID batching to prevent table locking and race conditions across replicas. Emits structured logs with duration and deleted counts per run.4. #562 Contract Pause & Recovery Operator Runbook
onchain/docs/pause-and-recovery-runbook.mdanddocs/pause-and-recovery-runbook.md.stellar_hunts), NFT Contract Pause (stellar_hunts_nft), and Backend Maintenance Mode.stellar contract invokeandcurlcommands, expected returns, and halt verification steps.Verification
reward-shop,audit-log,analytic,user-activity-log, andpuzzle-access-log.Math.randomreferences removed fromreward-shop.docs/api.md.