Skip to content

feat(logs): add generic eviction framework for pattern management#49217

Draft
DDuongNguyen wants to merge 1 commit into04-10-feat_logs_add_rust_ffi_tokenizer_bridge_with_flatbuffersfrom
04-10-feat_logs_add_generic_eviction_framework_for_pattern_management
Draft

feat(logs): add generic eviction framework for pattern management#49217
DDuongNguyen wants to merge 1 commit into04-10-feat_logs_add_rust_ffi_tokenizer_bridge_with_flatbuffersfrom
04-10-feat_logs_add_generic_eviction_framework_for_pattern_management

Conversation

@DDuongNguyen
Copy link
Copy Markdown
Contributor

@DDuongNguyen DDuongNguyen commented Apr 10, 2026

What does this PR do?

Introduces a generic eviction framework (pkg/logs/patterns/eviction/) that manages bounded-size collections with configurable eviction policies:

  • EvictionManager: Generic container that tracks items, enforces capacity limits, and evicts based on pluggable scoring
  • Eviction scoring (score.go): Frequency × recency scoring with configurable decay, plus threshold-based eviction triggers
  • Types: Evictable interface and EvictionConfig for downstream consumers (clustering, tags) to plug into

This is PR 3/6 in a stack. Depends on PR 2 (#49216). The clustering (PR 4) and tag management layers both use this framework.

Motivation

Pattern clustering and tag management both need bounded collections with LRU/LFU-style eviction. Rather than duplicating eviction logic, this PR extracts it into a reusable framework with well-tested scoring mechanics.

Describe how you validated your changes

  • Comprehensive unit tests for eviction manager lifecycle, capacity enforcement, and scoring
  • Score calculation tests covering decay, frequency weighting, and edge cases
  • All tests pass: go test ./pkg/logs/patterns/eviction/...

How to Review this PR

  1. types.go — the Evictable interface and EvictionConfig
  2. eviction_manager.go — the core generic manager
  3. score.go — the scoring algorithm
  4. Tests for each file verify the contract

Additional Notes

This is a self-contained package with no external dependencies beyond the standard library. ~1,350 lines including tests.

Copy link
Copy Markdown
Contributor Author

DDuongNguyen commented Apr 10, 2026

@DDuongNguyen DDuongNguyen force-pushed the 04-10-feat_logs_add_rust_ffi_tokenizer_bridge_with_flatbuffers branch from 9562664 to ad3c7b3 Compare April 10, 2026 22:06
@DDuongNguyen DDuongNguyen force-pushed the 04-10-feat_logs_add_generic_eviction_framework_for_pattern_management branch from a46a9dd to 82ac7b1 Compare April 10, 2026 22:06
@DDuongNguyen DDuongNguyen force-pushed the 04-10-feat_logs_add_generic_eviction_framework_for_pattern_management branch from 82ac7b1 to e4890f9 Compare April 14, 2026 16:34
@DDuongNguyen DDuongNguyen force-pushed the 04-10-feat_logs_add_rust_ffi_tokenizer_bridge_with_flatbuffers branch from ad3c7b3 to ff26d66 Compare April 14, 2026 16:34
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.

1 participant