---
id: ADR-COM-CAT-012
title: Shared File Processing and Deferred Cleanup
product_area: commerce
module: catalog
revision: 1
status: proposed
design_intent: confirmed
source_sha:
  services-commerce: c8b66a98e2490617aec38ba5c8165dd9bd0a8f9b
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
decision: >-
  Assets are prepared before record saves, attached within them and settled later by scheduled,
  reference-aware cleanup.
constrains:
  - DOM-COM-CAT-002
  - DOM-COM-CAT-003
  - SVC-COM-CAT-catalog
  - SVC-COM-CAT-configuration
  - WF-COM-CAT-003
  - WF-COM-CAT-004
  - STATE-COM-CAT-004
origin: 'COMM-M1 D11 (images on listings: the platform pipeline already exists)'
alternatives:
  - option: Write raw storage references directly
    why_not: Unprepared references would bypass lifecycle checks and cleanup tracking.
  - option: Delete replaced assets before committing the save
    why_not: A rollback could leave the retained record referring to a removed file.
consequences:
  - Asset guards require references prepared for the saving record.
  - Individual cleanup failures retry and eventually reach operator review.
  - The console’s shared upload interaction remains deferred.
supersedes: []
evidence:
  - >-
    services-commerce at c8b66a98: modules/catalog/services/assets/*.ts;
    aws/logic/catalog-asset-cleanup.lambda.ts; aws/resources/catalog-asset-cleanup-queue.sqs.ts.
  - >-
    services-commerce at c8b66a98: docs/milestones/COMM-M1-set-up-what-you-sell.md (Decisions);
    docs/milestones/plans/COMM-M1-plan.md.
---

# Shared File Processing and Deferred Cleanup

## Context

Pictures and private files must survive refused saves while eventually releasing storage no record uses.

## Decision

Assets are prepared before record saves, attached within them and settled later by scheduled, reference-aware cleanup.

## Alternatives Considered

Write raw storage references directly. Unprepared references would bypass lifecycle checks and cleanup tracking.

Delete replaced assets before committing the save. A rollback could leave the retained record referring to a removed file.

## Consequences

Asset guards require references prepared for the saving record. Individual cleanup failures retry and eventually reach operator review. The console’s shared upload interaction remains deferred.
