feat(drive): sweep chunks left by aborted uploads #191
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.53) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.53 · 549 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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.378
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #191"
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." A drive upload writes its chunks first and its manifest last, so an upload that stops partway leaves chunks nothing points to. After this, #172 stays open only for the P18 (#42) startup refusal andGCP_PROJECT_ID.platform-storage:-
VaultStore::list_entriesreturns each object's path, size and last-modified time (VaultEntry), from the samelist_metathatusageuses.-
TenantPaths::drive_chunk_partsanddrive_manifest_partsparse drive paths back to(TenantId, ObjectId). Each accepts only its own kind of path, with a valid tenant id, object id and an 8-digit chunk index.-
TenantPaths::all_tenants()is thetenantsprefix. It is for the control plane only, and its doc comment says no tenant-scoped operation may use it.platform_api::sweep:-
sweep_orphaned_chunks(vault, now)lists every tenant's entries once. It groups chunks by(tenant, object)and skips any object that has a manifest. It also skips any object whose newest chunk is newer thanORPHAN_MIN_AGE(24 hours). Before deleting, it re-reads the manifest in case one was written after the listing. Chunks already gone (NotFound) count as deleted.- Each object it deletes emits a
data.access"ok" audit event with the object id and chunk count, or "failed" if a delete fails. It stops at the first storage error, and the next run continues.-
spawn_sweeperruns it every hour (SWEEP_INTERVAL), first one interval after start.platform-api'smainstarts it, and failures are logged atwarn.docs/ARCHITECTURE.md(Drive) andCHANGELOG.md.Limits, documented in the module and in
ARCHITECTURE.md:tenants/. That is fine at v1 sizes. Multiple replicas each sweep, and the duplicate deletes are harmless becauseNotFoundcounts as deleted.How it was tested
backend/crates/platform-api/tests/drive_sweep.rsuses a vault that reports chosen last-modified times:aborted_upload_is_swept: three old chunks and no manifest are all deleted.recent_upload_is_left_alone: chunks under 24 hours old are kept.the_newest_chunk_decides_an_objects_age: one old chunk and one recent chunk are both kept.complete_objects_are_never_swept: old chunks that have a manifest are kept.delete_that_failed_partway_is_finished_by_the_sweep_only_without_a_manifest: a partial delete that still has its manifest is left for the client to retry. Stranded chunks with no manifest are swept.a_manifest_is_matched_only_within_its_own_tenant: the same object id in another tenant does not protect the orphan.a_manifest_written_after_the_listing_saves_the_object: the re-read before deleting catches a manifest the listing missed.other_tenant_data_is_ignored: old connector snapshots and enrollments are never touched.a_listing_outage_fails_the_sweep_and_deletes_nothing: the error is retryable.Also:
orphan_sweep_deletions_are_audited(audit_coverage.rs).drive_paths_parse_back_to_tenant_and_objectandlist_entries_reports_size_and_last_modified(platform-storage).list_entriesadded to the outage-classification test.scripts/check.shpasses locally.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)