Skip to content

fix(gh-17): cap collector entries, enforce max profile size, prune in chunks - #26

Merged
Nejcc merged 1 commit into
mainfrom
fix/gh-17-profile-caps
Oct 31, 2026
Merged

Nejcc merged 1 commit into
mainfrom
fix/gh-17-profile-caps

Conversation

@Nejcc

@Nejcc Nejcc commented Oct 31, 2026

Copy link
Copy Markdown
Member

Closes #17

What

  • Per-collector caps: limits.max_entries (default 500) per section and limits.max_string_length (default 10000) for SQL, log context and similar. query_count, query time and N+1 detection are computed before the cap, so they still count everything. Dropped counts go to _dropped.
  • Real size enforcement: enforceMaxSize() shortens bodies, drops bindings, then empties the largest sections until the JSON fits in max_profile_size_kb. _truncated is set only when something was cut.
  • Pruning: runs on prune_lottery (default 1 in 10 writes; [0, 1] turns it off for scheduler-only pruning) and deletes in chunks of 500, so large backlogs stay under SQLite's bound-parameter limit.

Checks

  • 6 new tests (caps, size enforcement keeps the smaller sections, untouched small profiles, lottery off, 1200-row chunked prune). composer test: 95 passed.
  • lint, analyse and gitleaks clean.

… chunks

- Each collector keeps at most limits.max_entries entries and long strings
  are shortened; totals and N+1 detection still use the full data.
- enforceMaxSize() re-checks the size and empties the largest sections
  until the profile fits, recording them in _dropped.
- Pruning runs on a configurable lottery and deletes in chunks of 500.

Closes #17
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Nejcc
Nejcc merged commit 16f5821 into main Oct 31, 2026
8 checks passed
@Nejcc
Nejcc deleted the fix/gh-17-profile-caps branch November 2, 2026 07:48
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.

Profile size cap not enforced; collectors unbounded; prune on every write

1 participant