Commit ce026ea
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- cortex-cli
- src
- cortex-compact
- src
8 files changed
+1847
-1
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
0 commit comments