Skip to content

fix: disable unsafe CAS garbage collection - #312

Merged
bobtista merged 3 commits into
developmentfrom
fix/disable-unsafe-cas-gc
Jul 29, 2026
Merged

fix: disable unsafe CAS garbage collection#312
bobtista merged 3 commits into
developmentfrom
fix/disable-unsafe-cas-gc

Conversation

@bobtista

@bobtista bobtista commented Jul 29, 2026

Copy link
Copy Markdown

Summary

Disables the destructive CAS garbage collection path fail-closed until reference tracking is provably complete.

Changes

  • CasService.RunGarbageCollectionAsync no longer deletes objects; it returns an explicit CasGarbageCollectionResult.CreateDisabled() and logs why.
  • CasLifecycleManager propagates the disabled/failed state instead of reporting a successful run.
  • Settings surfaces the disabled state; collection statistics types gain a Disabled flag.
  • Tests assert no deletion occurs (CasGarbageCollectionDisabledTests, orchestrator GC tests).

Why

The reference tracker does not cover every live reference source (persisted manifests, existing workspaces, user-data links, CAS pools), so live blobs can be classified unreachable and permanently deleted — surfacing later as failed or silently incomplete workspace preparation. Re-enable criteria are listed in #310.

Testing

  • 62 affected tests pass locally (GarbageCollection, SettingsViewModel, ContentReconciliation filters).
  • Note: local verification required cherry-picking a one-line Split overload disambiguation in GitHubTopicsDiscoverer.cs (not included here) because development does not compile on .NET SDK 8.0.129; CI SDKs are unaffected.

Risks and rollback

Low risk: no behavior removed except deletion itself; revert restores previous GC.

Fixes #310

Greptile Summary

This PR disables destructive CAS garbage collection until reachability tracking is complete.

  • Direct and lifecycle GC APIs now return explicit disabled results with zero deletion statistics.
  • Reconciliation and settings flows surface disabled collection as a warning rather than successful cleanup.
  • Audit metadata and result models retain the disabled state, with focused tests confirming that storage is not accessed or deleted.

Confidence Score: 4/5

The destructive collection path appears safely disabled, but completion-event reporting remains incomplete and should be reconciled with the existing operation-status contract.

Audit records now preserve disabled-GC warnings, while successful replacement events still omit them and successful removal operations publish no completion event; no current recipient of these events was found, limiting the present impact.

Files Needing Attention: GenHub/GenHub/Features/Content/Services/Reconciliation/ContentReconciliationOrchestrator.cs; GenHub/GenHub.Core/Models/Content/ReconciliationCompletedEvent.cs

Important Files Changed

Filename Overview
GenHub/GenHub/Features/Storage/Services/CasService.cs Replaces destructive garbage collection with an explicit fail-closed disabled result.
GenHub/GenHub/Features/Storage/Services/CasLifecycleManager.cs Maps the service-level disabled result into lifecycle statistics without reporting deletion.
GenHub/GenHub/Features/Content/Services/Reconciliation/ContentReconciliationOrchestrator.cs Propagates disabled collection through reconciliation results and audit metadata.
GenHub/GenHub/Features/Settings/ViewModels/SettingsViewModel.cs Displays an informational disabled-cleanup notification instead of a success notification.
GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Storage/CasGarbageCollectionDisabledTests.cs Verifies direct and lifecycle collection remain disabled without accessing CAS storage.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Caller["Settings, maintenance, or reconciliation flow"] --> Lifecycle["CasLifecycleManager"]
    Lifecycle --> Service["CasService.RunGarbageCollectionAsync"]
    Service --> Disabled["CreateDisabled result"]
    Disabled --> NoAccess["No CAS scan or deletion"]
    Disabled --> Propagate["Disabled stats and warning propagated"]
    Propagate --> UI["Settings notification"]
    Propagate --> Result["Reconciliation result and audit metadata"]
Loading

Reviews (2): Last reviewed commit: "fix: record reconciliation warnings in a..." | Re-trigger Greptile

Context used:

@bobtista bobtista added this to the Alpha 4 milestone Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@bobtista, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d86dded7-1e08-4927-85b2-f66aad9a2143

📥 Commits

Reviewing files that changed from the base of the PR and between 4977fba and f87fa5e.

📒 Files selected for processing (4)
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/GameProfiles/ViewModels/SettingsViewModelTests.cs
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Reconciliation/ContentReconciliationOrchestratorGarbageCollectionTests.cs
  • GenHub/GenHub/Features/Content/Services/Reconciliation/ContentReconciliationOrchestrator.cs
  • GenHub/GenHub/Features/Settings/ViewModels/SettingsViewModel.cs
📝 Walkthrough

Walkthrough

CAS garbage collection now fails closed with an explicit disabled result and zero deletion statistics. Lifecycle, reconciliation, maintenance, and Settings flows propagate or display the disabled state, with tests covering the updated behavior.

Changes

CAS garbage collection disablement

Layer / File(s) Summary
Disabled GC contracts and result shapes
GenHub/GenHub.Core/Constants/CasDefaults.cs, GenHub/GenHub.Core/Models/Results/CAS/CasGarbageCollectionResult.cs, GenHub/GenHub.Core/Models/Storage/GarbageCollectionStats.cs, GenHub/GenHub.Core/Models/Content/ContentRemovalResult.cs, GenHub/GenHub.Core/Interfaces/Storage/*
Adds disabled GC messages, result and statistics flags, a disabled result factory, removal warnings, and updated API documentation.
Disabled GC execution and lifecycle propagation
GenHub/GenHub/Features/Storage/Services/CasService.cs, CasLifecycleManager.cs, CasMaintenanceService.cs
Stops destructive CAS deletion, returns a disabled result, propagates failed disabled statistics, and logs disabled maintenance.
Warning propagation and presentation
GenHub/GenHub/Features/Content/Services/ContentReconciliationService.cs, Reconciliation/ContentReconciliationOrchestrator.cs, GenHub/GenHub/Features/Settings/ViewModels/SettingsViewModel.cs
Propagates GC failures as reconciliation warnings and displays disabled cleanup status in Settings notifications.
Disabled GC behavior tests
GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Storage/*, Features/Reconciliation/*, Integration/ContentReconciliationServiceTests.cs, Features/GameProfiles/ViewModels/SettingsViewModelTests.cs
Covers disabled result construction, no storage access, lifecycle propagation, reconciliation warnings, service failure results, and informational Settings notifications.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SettingsViewModel
  participant CasLifecycleManager
  participant CasService
  participant CASStorage
  SettingsViewModel->>CasLifecycleManager: Request CAS cleanup
  CasLifecycleManager->>CasService: RunGarbageCollectionAsync(force)
  CasService-->>CasLifecycleManager: Disabled result with zero deletions
  CasLifecycleManager-->>SettingsViewModel: Failed result with disabled stats
  SettingsViewModel-->>SettingsViewModel: Show CAS Cleanup Disabled
  Note over CasService,CASStorage: No storage scan or deletion occurs
Loading

Possibly related PRs

Poem

I’m a rabbit guarding blobs tonight,
No risky cleanup, locked up tight.
Disabled flags hop through the chain,
Warnings bloom instead of pain.
Zero bytes freed, safe and bright!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes implement #310 by returning disabled GC results, preserving stats, surfacing disabled state, and adding no-deletion tests.
Out of Scope Changes check ✅ Passed The diff stays focused on GC disablement, status propagation, notifications, and related tests.
Docstring Coverage ✅ Passed Docstring coverage is 76.92% which is sufficient. The required threshold is 50.00%.
Title check ✅ Passed The title uses a conventional commit prefix and clearly summarizes the PR’s CAS garbage collection disablement.
Description check ✅ Passed The description is directly related to the change and accurately describes the disabled CAS garbage collection flow.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/disable-unsafe-cas-gc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kilo-code-bot

kilo-code-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/GameProfiles/ViewModels/SettingsViewModelTests.cs
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Reconciliation/ContentReconciliationOrchestratorGarbageCollectionTests.cs
  • GenHub/GenHub/Features/Content/Services/Reconciliation/ContentReconciliationOrchestrator.cs
  • GenHub/GenHub/Features/Settings/ViewModels/SettingsViewModel.cs

Incremental Review: All issues from the previous review have been addressed:

  1. Audit metadata fix - The Greptile comment about persisting disabled-GC warnings has been resolved by adding warnings to audit metadata in both replacement and removal flows.

  2. Notification duration bug - The CodeRabbit comment about incorrect notification duration has been fixed by changing .Milliseconds to (int)TimeIntervals.NotificationHideDelay.TotalMilliseconds.

  3. Test improvements - Added proper audit entry capture and assertions to verify warnings are logged correctly.

All changes are minimal, focused, and address the previous code review findings without introducing new issues.

Previous Review Summary (commit 4977fba)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 4977fba)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (17 files)
  • GenHub/GenHub.Core/Constants/CasDefaults.cs
  • GenHub/GenHub.Core/Interfaces/Storage/ICasLifecycleManager.cs
  • GenHub/GenHub.Core/Interfaces/Storage/ICasService.cs
  • GenHub/GenHub.Core/Models/Content/ContentRemovalResult.cs
  • GenHub/GenHub.Core/Models/Results/CAS/CasGarbageCollectionResult.cs
  • GenHub/GenHub.Core/Models/Storage/GarbageCollectionStats.cs
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/GameProfiles/ViewModels/SettingsViewModelTests.cs
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Reconciliation/ContentReconciliationOrchestratorGarbageCollectionTests.cs
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Storage/CasGarbageCollectionDisabledTests.cs
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Storage/CasGarbageCollectionResultTests.cs
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Integration/ContentReconciliationServiceTests.cs
  • GenHub/GenHub/Features/Content/Services/ContentReconciliationService.cs
  • GenHub/GenHub/Features/Content/Services/Reconciliation/ContentReconciliationOrchestrator.cs
  • GenHub/GenHub/Features/Settings/ViewModels/SettingsViewModel.cs
  • GenHub/GenHub/Features/Storage/Services/CasLifecycleManager.cs
  • GenHub/GenHub/Features/Storage/Services/CasMaintenanceService.cs
  • GenHub/GenHub/Features/Storage/Services/CasService.cs

Reviewed by glm-4.7 · Input: 44.4K · Output: 3K · Cached: 121.2K

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@GenHub/GenHub/Features/Settings/ViewModels/SettingsViewModel.cs`:
- Around line 1118-1125: Update the notification calls in the SettingsViewModel
cleanup result handling, including the branch around result.Disabled, to pass
the full NotificationHideDelay duration rather than its Milliseconds component.
Convert the TimeSpan using TotalMilliseconds so the configured 3000 ms delay is
preserved.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 828d7d05-8545-4c08-a0d6-145d0ce33552

📥 Commits

Reviewing files that changed from the base of the PR and between 5ba2a51 and 4977fba.

📒 Files selected for processing (17)
  • GenHub/GenHub.Core/Constants/CasDefaults.cs
  • GenHub/GenHub.Core/Interfaces/Storage/ICasLifecycleManager.cs
  • GenHub/GenHub.Core/Interfaces/Storage/ICasService.cs
  • GenHub/GenHub.Core/Models/Content/ContentRemovalResult.cs
  • GenHub/GenHub.Core/Models/Results/CAS/CasGarbageCollectionResult.cs
  • GenHub/GenHub.Core/Models/Storage/GarbageCollectionStats.cs
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/GameProfiles/ViewModels/SettingsViewModelTests.cs
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Reconciliation/ContentReconciliationOrchestratorGarbageCollectionTests.cs
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Storage/CasGarbageCollectionDisabledTests.cs
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Features/Storage/CasGarbageCollectionResultTests.cs
  • GenHub/GenHub.Tests/GenHub.Tests.Core/Integration/ContentReconciliationServiceTests.cs
  • GenHub/GenHub/Features/Content/Services/ContentReconciliationService.cs
  • GenHub/GenHub/Features/Content/Services/Reconciliation/ContentReconciliationOrchestrator.cs
  • GenHub/GenHub/Features/Settings/ViewModels/SettingsViewModel.cs
  • GenHub/GenHub/Features/Storage/Services/CasLifecycleManager.cs
  • GenHub/GenHub/Features/Storage/Services/CasMaintenanceService.cs
  • GenHub/GenHub/Features/Storage/Services/CasService.cs

Comment thread GenHub/GenHub/Features/Settings/ViewModels/SettingsViewModel.cs
@bobtista
bobtista merged commit a783b36 into development Jul 29, 2026
7 checks passed
@kilo-code-bot kilo-code-bot Bot mentioned this pull request Jul 30, 2026
6 tasks
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