feat(drive): sweep chunks left by aborted uploads #198
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.53) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.53 · 515 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.374
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #198"
general
weight: 0.35
abendrothj
What and why
P41 (#172), item "A sweep deletes drive chunk prefixes that have no manifest and are older than a documented age longer than the longest allowed upload, so it never deletes an upload in progress.
VaultStoregains a listing that returnslast_modified." Supersedes #191, with that review addressed, as one commit.A drive upload writes its chunks first and its manifest last, so an upload that stops partway leaves chunks nothing points to.
platform-storage:-
VaultStore::list_entriesreturns each object's path, size and last-modified time (VaultEntry).-
TenantPaths::drive_chunk_partsanddrive_manifest_partsparse drive paths back to(TenantId, ObjectId).-
list_drive_entries_all_tenantsis the only cross-tenant listing. Thetenantsprefix it lists is private to the crate, and it returns only parsed drive entries, each with its own tenant's path, so no path spanning tenants leavesplatform-storage. TheTHREAT_MODEL.mdcross-tenant row says so.platform-api:-
PUT /api/v1/drive/objects/{id}/manifestreturns 409, audited asdata.access"denied", unless every chunk0..chunk_countis stored. An upload that paused long enough to be swept now fails visibly instead of committing a file whose chunks 404.-
sweep::sweep_orphaned_chunksdeletes the chunks of objects with no manifest and no chunk written forORPHAN_MIN_AGE(24 hours). Just before deleting, it re-reads the manifest and re-lists the object's chunks, so a manifest or chunk written since the first listing saves the object.- Only chunks this run deleted are counted, and an object it deleted nothing from (another replica got there first) emits no "ok" audit event.
- A storage error on one object no longer stops the run; the other objects are swept and the first error is returned.
-
spawn_sweeperruns it hourly frommain.docs/ARCHITECTURE.md,docs/THREAT_MODEL.md,CHANGELOG.md.Limits, documented in the module and
ARCHITECTURE.md:How it was tested
backend/crates/platform-api/tests/drive_sweep.rs, with a vault that reports chosen last-modified times:aborted_upload_is_swept,recent_upload_is_left_alone,the_newest_chunk_decides_an_objects_age,complete_objects_are_never_swept.delete_that_failed_partway_is_finished_by_the_sweep_only_without_a_manifest,a_manifest_is_matched_only_within_its_own_tenant,other_tenant_data_is_ignored.a_manifest_written_after_the_listing_saves_the_object,a_chunk_rewritten_after_the_listing_saves_the_object.chunks_already_deleted_are_not_counted,one_failing_object_does_not_stop_the_others,a_listing_outage_fails_the_sweep_and_deletes_nothing.a_swept_upload_cannot_commit_its_manifest: through the API, the swept upload's manifest gets 409 and nothing is listed.drive_api.rs:a_manifest_needs_every_chunk_it_names(no chunks, a gap, then accepted) andan_empty_file_needs_no_chunks. Existing drive tests now upload chunks before the manifest, as the client does.audit_coverage.rs:orphan_sweep_deletions_are_audited,a_manifest_missing_chunks_is_audited_as_denied.platform-storage:drive_paths_parse_back_to_tenant_and_object,list_entries_reports_size_and_last_modified, andlist_entriesin the outage-classification test.Checklist
scripts/check.shpasses locallySECURITY_AUDIT_EVENTcovered byaudit_coverage.rsdocs/DATA_POLICY.md)CHANGELOG.mdupdated for user-visible changesdocs/adr/if one was made (not required, per P41)