---
plan: "06.2-03"
phase: "06.2"
status: complete
started: "2026-05-31"
completed: "2026-05-31"
requirements: []
---

# Plan 06.2-03 Summary — Cloud-Delete Propagation Gap Closure

## What Was Built

Closed the cloud-delete correctness gap: deleting a cloud-stored document now propagates to the cloud provider rather than silently orphaning the file.

### Backend (Task 1)

- `services/storage.delete_document` gains `skip_quota: bool = False` — quota decrement gated on `not skip_quota`; cloud docs (never charged quota at upload) pass `skip_quota=True`.
- `DELETE /api/documents/{id}` gains `remove_only: bool = Query(default=False)`.
- Cloud routing: for non-minio docs without `remove_only`, calls `get_storage_backend_for_document()` then `backend.delete_object()`. On provider exception: returns HTTP 200 `{success: false, cloud_delete_failed: true}` — exception message never in response body (T-06.2-03-02).
- `remove_only=true`: skips cloud call, deletes DB row with `skip_quota=True`.
- 3 xfail stubs promoted to real tests (propagates, failure, remove_only).

### Frontend (Task 2)

- `api/client.js`: `deleteDocument(id, removeOnly=false)` appends `?remove_only=true` when set; `deleteDocumentRemoveOnly` convenience wrapper added.
- `DocumentView.vue`: `confirmDelete()` now calls `api.deleteDocument` directly and inspects `resp.cloud_delete_failed`; on true, maps `storage_backend` to provider name and shows warning modal.
- Inline `CloudDeleteWarningModal` (C-3 contract): "Remove from app" → `confirmRemoveOnly()` → DELETE `?remove_only=true` → navigate `/`; "Cancel" → closes modal, document not deleted.

## Test Results

```
backend/tests/test_documents.py — 24 passed, 4 xfailed, 0 failed
```

## Self-Check: PASSED

- [x] Cloud doc delete calls backend.delete_object — test_delete_cloud_document_propagates
- [x] Cloud failure → HTTP 200 cloud_delete_failed=True, DB row preserved — test_delete_cloud_document_failure
- [x] remove_only=true → DB removed, no quota decrement — test_delete_cloud_remove_only
- [x] DocumentView shows CloudDeleteWarningModal on cloud_delete_failed response
- [x] 24 tests pass, 0 fail
