personal memory agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

retention: nudge in storage warnings when always-retain is on

+88 -10
+67
tests/test_retention.py
··· 668 668 assert "message" in w 669 669 assert "current" in w 670 670 assert "threshold" in w 671 + 672 + 673 + class TestStorageHealthNudge: 674 + def _make_summary(self): 675 + return StorageSummary( 676 + raw_media_bytes=int(10 * 1024**3), 677 + derived_bytes=0, 678 + total_segments=10, 679 + segments_with_raw=5, 680 + segments_purged=3, 681 + ) 682 + 683 + def _config(self, mode: str) -> dict: 684 + return { 685 + "retention": { 686 + "raw_media": mode, 687 + "storage_warning_disk_percent": 1, 688 + "storage_warning_raw_media_gb": 5.0, 689 + } 690 + } 691 + 692 + def _force_disk_warning(self, tmp_path, monkeypatch) -> None: 693 + usage_type = type(shutil.disk_usage(tmp_path)) 694 + monkeypatch.setattr( 695 + "shutil.disk_usage", 696 + lambda path: usage_type(1000, 950, 50), 697 + ) 698 + 699 + def test_keep_mode_appends_nudge(self, tmp_path, monkeypatch): 700 + self._force_disk_warning(tmp_path, monkeypatch) 701 + warnings = check_storage_health( 702 + self._make_summary(), 703 + tmp_path, 704 + config=self._config("keep"), 705 + ) 706 + assert {warning["type"] for warning in warnings} == { 707 + "disk_percent", 708 + "raw_media_gb", 709 + } 710 + assert all( 711 + "always retain observed media" in warning["message"] 712 + for warning in warnings 713 + ) 714 + 715 + def test_days_mode_does_not_append_nudge(self, tmp_path, monkeypatch): 716 + self._force_disk_warning(tmp_path, monkeypatch) 717 + warnings = check_storage_health( 718 + self._make_summary(), 719 + tmp_path, 720 + config=self._config("days"), 721 + ) 722 + assert all( 723 + "always retain observed media" not in warning["message"] 724 + for warning in warnings 725 + ) 726 + 727 + def test_processed_mode_does_not_append_nudge(self, tmp_path, monkeypatch): 728 + self._force_disk_warning(tmp_path, monkeypatch) 729 + warnings = check_storage_health( 730 + self._make_summary(), 731 + tmp_path, 732 + config=self._config("processed"), 733 + ) 734 + assert all( 735 + "always retain observed media" not in warning["message"] 736 + for warning in warnings 737 + )
+21 -10
think/retention.py
··· 282 282 config = get_config() 283 283 284 284 retention = config.get("retention", {}) 285 + keep_mode_nudge = ( 286 + " you're currently set to always retain observed media — consider " 287 + "choosing a retention value in settings to free up disk space." 288 + ) 289 + always_retain_enabled = retention.get("raw_media", "keep") == "keep" 285 290 warnings = [] 286 291 287 292 # Check disk usage percentage ··· 291 296 usage = shutil.disk_usage(str(journal_path)) 292 297 disk_percent = round(usage.used / usage.total * 100, 1) 293 298 if disk_percent >= disk_threshold: 299 + message = ( 300 + f"Disk is {disk_percent}% full (threshold: {disk_threshold}%). " 301 + "Consider adjusting retention settings or running Clean Up Now " 302 + "to free space." 303 + ) 304 + if always_retain_enabled: 305 + message += keep_mode_nudge 294 306 warnings.append( 295 307 { 296 308 "level": "warning", 297 309 "type": "disk_percent", 298 - "message": ( 299 - f"Disk is {disk_percent}% full (threshold: {disk_threshold}%). " 300 - "Consider adjusting retention settings or running Clean Up Now " 301 - "to free space." 302 - ), 310 + "message": message, 303 311 "current": disk_percent, 304 312 "threshold": disk_threshold, 305 313 } ··· 312 320 if raw_media_gb_threshold is not None: 313 321 raw_media_gb = round(summary.raw_media_bytes / (1024**3), 2) 314 322 if raw_media_gb >= raw_media_gb_threshold: 323 + message = ( 324 + f"Raw media is {raw_media_gb} GB (threshold: {raw_media_gb_threshold} GB). " 325 + "Consider adjusting retention settings or running Clean Up Now " 326 + "to free space." 327 + ) 328 + if always_retain_enabled: 329 + message += keep_mode_nudge 315 330 warnings.append( 316 331 { 317 332 "level": "warning", 318 333 "type": "raw_media_gb", 319 - "message": ( 320 - f"Raw media is {raw_media_gb} GB (threshold: {raw_media_gb_threshold} GB). " 321 - "Consider adjusting retention settings or running Clean Up Now " 322 - "to free space." 323 - ), 334 + "message": message, 324 335 "current": raw_media_gb, 325 336 "threshold": raw_media_gb_threshold, 326 337 }