Skip to content

fix(admin): bound audit log memory retention and add pagination (closes #926) - #938

Closed
mopxam-art wants to merge 1 commit into
Heliobond:mainfrom
mopxam-art:fix/audit-log-cap-and-pagination
Closed

mopxam-art wants to merge 1 commit into
Heliobond:mainfrom
mopxam-art:fix/audit-log-cap-and-pagination

Conversation

@mopxam-art

Copy link
Copy Markdown

Why

src/lib/audit.ts declared an unbounded in-memory array store that grew on every POST /admin/update-scores invocation without any retention cap or eviction. Furthermore, GET /admin/audit returned the entire filtered array without pagination support, leading to unbounded memory growth and large payload responses.

What

  • Added bounded in-memory retention cap in src/lib/audit.ts (MAX_AUDIT_LOG_ENTRIES, default 1,000, configurable via environment variable) with automatic FIFO eviction when capacity is exceeded.
  • Added helper functions setMaxAuditLogEntries, getMaxAuditLogEntries, and getAuditStoreSize for runtime configuration and memory inspection.
  • Added query parameter pagination (limit clamped between 1 and 100, default 50; offset, default 0) to GET /admin/audit in src/routes/admin.ts.
  • Retained backwards-compatible response metadata including total, count, limit, offset, and has_more.
  • Documented pagination query parameters and memory retention in API.md.
  • Added comprehensive unit and integration test suite (src/__tests__/audit-ring-buffer.test.ts) covering boundary limits, filtering combinations, CSV export, validation, and high-throughput memory stability.

Verified

  • All unit tests pass (jest src/__tests__/audit-ring-buffer.test.ts, 54 tests pass).
  • Full repository test suite passes (123/123 test suites, 1,473 tests pass).
  • TypeScript typecheck (npx tsc --noEmit) and linter (npm run lint) clean with 0 errors.
  • Production build (npm run build) succeeds cleanly.

Closes #926

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admin audit log store is an unbounded in-memory array that never evicts

2 participants