← Back to Pull requests

feat(drive): sweep chunks left by aborted uploads #191

Closed
unknown closed this pull request without merging on Nov 05, 2026 06:24 UTC
View on GitHub
unknown unknown commented on Nov 03, 2026 07:07 UTC
Author

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. VaultStore gains a listing that returns last_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 and GCP_PROJECT_ID.

  • platform-storage:

  • - VaultStore::list_entries returns each object's path, size and last-modified time (VaultEntry), from the same list_meta that usage uses.
    - TenantPaths::drive_chunk_parts and drive_manifest_parts parse 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 the tenants prefix. 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 than ORPHAN_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_sweeper runs it every hour (SWEEP_INTERVAL), first one interval after start. platform-api's main starts it, and failures are logged at warn.
  • docs/ARCHITECTURE.md (Drive) and CHANGELOG.md.
  • Limits, documented in the module and in ARCHITECTURE.md:

  • Ages come from the store's last-modified times, so the API host's clock must be within hours of the store's.

  • 24 hours is the longest an upload may take. Nothing on the server enforces it. The browser writes chunks back to back and then the manifest, so a real upload takes far less.

  • Each run lists every object under tenants/. That is fine at v1 sizes. Multiple replicas each sweep, and the duplicate deletes are harmless because NotFound counts as deleted.
  • How it was tested

    backend/crates/platform-api/tests/drive_sweep.rs uses 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_object and list_entries_reports_size_and_last_modified (platform-storage).

  • list_entries added to the outage-classification test.
  • scripts/check.sh passes locally.

    Checklist

  • scripts/check.sh passes locally

  • Every new refusal has a negative test (no new refusals; negative cases above)

  • Every new security decision emits a SECURITY_AUDIT_EVENT covered by audit_coverage.rs

  • Fails closed on missing configuration, key material, or attestation (any storage error stops the sweep without deleting more)

  • No new cryptographic primitives; suites stay behind their type aliases

  • Synthetic or public data only (docs/DATA_POLICY.md)

  • Docs and CHANGELOG.md updated for user-visible changes

  • Architectural decision recorded in docs/adr/ if one was made (not required, per P41)
  • Diff: 549 lines (+411 / -138) across 6 files Reviewer: abendrothj Review duration: 2837m
    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
    0.53
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 53.1% (MEDIUM) · Higher = larger blast radius
    53.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.0% · Safe to merge
    21.0%