Repository navigation
fix(admin): bound audit log memory retention and add pagination (closes #926) - #938
Closed
mopxam-art wants to merge 1 commit into
Closed
mopxam-art wants to merge 1 commit into
mopxam-art wants to merge 1 commit into
Conversation
…obond#926) - Cap in-memory audit log retention to MAX_AUDIT_LOG_ENTRIES (default: 1000) with automatic FIFO eviction - Add limit and offset pagination to GET /admin/audit with total, count, and has_more metadata - Document query parameters and memory retention in API.md - Add comprehensive test suite covering retention, eviction, filters, pagination, CSV format, and stress load
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.
Why
src/lib/audit.tsdeclared an unbounded in-memory arraystorethat grew on everyPOST /admin/update-scoresinvocation without any retention cap or eviction. Furthermore,GET /admin/auditreturned the entire filtered array without pagination support, leading to unbounded memory growth and large payload responses.What
src/lib/audit.ts(MAX_AUDIT_LOG_ENTRIES, default 1,000, configurable via environment variable) with automatic FIFO eviction when capacity is exceeded.setMaxAuditLogEntries,getMaxAuditLogEntries, andgetAuditStoreSizefor runtime configuration and memory inspection.limitclamped between 1 and 100, default 50;offset, default 0) toGET /admin/auditinsrc/routes/admin.ts.total,count,limit,offset, andhas_more.API.md.src/__tests__/audit-ring-buffer.test.ts) covering boundary limits, filtering combinations, CSV export, validation, and high-throughput memory stability.Verified
jest src/__tests__/audit-ring-buffer.test.ts, 54 tests pass).npx tsc --noEmit) and linter (npm run lint) clean with 0 errors.npm run build) succeeds cleanly.Closes #926