Skip to content

fix: safe aging defaults — pinned protection + configurable thresholds - #453

Merged
ajianaz merged 1 commit into
developfrom
fix/safe-aging-thresholds
Jun 22, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/safe-aging-thresholds

Conversation

@ajianaz

@ajianaz ajianaz commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Safety Fixes for Auto-Aging

Critical Bug: Pinned memories could be deleted

find_aged() SQL query was missing AND pinned = 0 — pinned memories were NOT protected from auto-aging cleanup. Fixed.

Aggressive Defaults Fixed

Param Before After Rationale
max_age_days 180 365 6 months too aggressive for personal use
max_access_count 10000 10 10K means basically everything qualifies
max_cold_count 10000 1000 Lower trigger threshold

Mass Deletion Protection

MAX_DELETE_PER_CYCLE = 100 — never delete more than 100 memories per cycle, even if thresholds are misconfigured.

Configurable via [aging]

[aging]
max_age_days = 365
max_access_count = 10
max_cold_count = 1000

Cleanup Candidate Criteria (ALL must be true)

  • Older than max_age_days
  • access_count < max_access_count
  • Not pinned
  • Not deprecated
  • Not accessed since max_age_days ago

300 tests pass. Clippy clean.

- Pinned memories NEVER deleted (added pinned=0 to SQL)
- MAX_DELETE_PER_CYCLE=100 mass deletion protection
- max_access_count: 10 (was 10000)
- max_age_days: 365 (was 180)
- All configurable via [aging] section

300 tests pass.
.aging
.as_ref()
.and_then(|a| a.max_age_days)
.unwrap_or(365);
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

❌ Blocked — critical issues found.

🔴 Error (2)

  • crates/uteke-core/src/memory/aging.rs:46 — The aging query uses AND access_count <= ?3, but the new configuration and comments in crates/uteke-cli/src/config.rs describe the threshold as "access_count < max_access_count" / "accessed fewer than this many times". With the current SQL, a memory with access_count exactly equal to max_access_count will still be considered cold and eligible for cleanup, which contradicts the documented behavior.
  • crates/uteke-server/src/main.rs:1652 — The background aging task now reads max_age_days and max_access_count from config, but still calls u.aging_cleanup(age_days, max_access, None) without using aging.max_cold_count. Separately, crates/uteke-core/src/maintenance.rs hard-limits deletions to 100 per cycle. This means the documented max_cold_count setting in crates/uteke-cli/src/config.rs no longer affects server-side cleanup behavior, so operators cannot control when/how much cleanup runs as the config suggests.

Review powered by cora-cli · BYOK · MIT

@ajianaz
ajianaz merged commit 136ae3f into develop Jun 22, 2026
8 of 9 checks passed
@ajianaz
ajianaz deleted the fix/safe-aging-thresholds branch June 22, 2026 14:04
ajianaz added a commit that referenced this pull request Aug 13, 2026
#453)

- Pinned memories NEVER deleted (added pinned=0 to SQL)
- MAX_DELETE_PER_CYCLE=100 mass deletion protection
- max_access_count: 10 (was 10000)
- max_age_days: 365 (was 180)
- All configurable via [aging] section

300 tests pass.
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.

2 participants