Skip to content

Commit ce026ea

Browse files
committed
feat: implement auto-compaction CLI for intelligent data cleanup
This commit adds a comprehensive auto-compaction system for the Cortex CLI backend with the following features: Auto-Compaction Core (cortex-compact/src/auto_compaction.rs): - CompactionLock: File-based advisory locking with stale lock detection - atomic_write(): Atomic file operations using temp + rename + fsync pattern - LogPruner: Age-based and size-based log cleanup with rotation - DatabaseVacuumer: Session storage optimization and orphaned file cleanup - AutoCompactionScheduler: Background thread-based scheduler with configurable intervals CLI Commands (cortex-cli/src/compact_cmd.rs): - 'compact run': Full compaction cycle - 'compact logs': Log pruning only - 'compact vacuum': Database vacuuming only - 'compact status': Show compaction statistics - 'compact config': Configure auto-compaction settings (placeholder) Features: - Race condition protection via file-system-safe operations - JSON output support for automation - Dry-run mode for safety - Command aliases: gc, cleanup All operations follow file system safety principles with atomic writes, fsync for durability, and graceful error handling.
1 parent 8008824 commit ce026ea

File tree

8 files changed

+1847
-1
lines changed

8 files changed

+1847
-1
lines changed

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cortex-cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ cortex-update = { workspace = true }
3737
cortex-mcp-server = { workspace = true }
3838
cortex-share = { path = "../cortex-share" }
3939
cortex-snapshot = { workspace = true }
40+
cortex-compact = { path = "../cortex-compact" }
4041

4142
clap = { workspace = true }
4243
clap_complete = { workspace = true }

0 commit comments

Comments
 (0)