---
id: WF-CMT-MTG-006
title: Prepare and Retire Meeting Files
trigger: 'Staff attach or remove packet files, or save and assemble minutes.'
product_area: committees
module: meetings
revision: 1
status: draft
design_intent: proposed
implementation_evidence: inconsistent
inference: []
source_sha:
  services-committees: 36129c24daeaadcdb339218c38cdeaff9861359d
implements:
  - CAP-CMT-MTG-005
  - CAP-CMT-MTG-007
crosses:
  - SVC-CMT-MTG-meetings
  - SVC-PFM-MTD-files
idempotency: >-
  The record accepts only references returned by asset preparation. Attachment
  and detachment commit with the reference change; cleanup checks whether a file
  remains referenced.
concurrency: >-
  Minutes saving checks its version again after preparation. Cleanup processes
  and settles each queued file separately.
hops:
  - 'n': 1
    actor_or_service: Meetings API
    action: Stage minutes text in the workspace upload area.
    anchor: >-
      services-committees:modules/meetings/services/minutes/minutes-body.ts:stageMinutesBody
    seam: sync
    on_failure: Stop before recording the body.
    left_inconsistent: An upload can remain staged until expiry.
    observer: The operation response.
    provenance: observed
    source: >-
      services-committees:modules/meetings/services/minutes/minutes-body.ts:stageMinutesBody
  - 'n': 2
    actor_or_service: File pipeline
    action: >-
      Prepare the file through inspection and permanent storage outside the
      record transaction; refuse foreign references and disallowed content.
    anchor: >-
      services-committees:modules/meetings/services/materials/material-assets.ts:materialAssets
    seam: sync
    on_failure: Reject the file.
    left_inconsistent: Staged data may remain for cleanup.
    observer: The operation response.
    provenance: observed
    source: >-
      services-committees:modules/meetings/services/materials/material-assets.ts:materialAssets
  - 'n': 3
    actor_or_service: Meetings API
    action: >-
      Lock and recheck the record, save its prepared reference and hash, and
      attach or detach assets together.
    anchor: 'services-committees:modules/meetings/services/minutes/minutes.ts:writeBody'
    seam: sync
    on_failure: Roll back the reference write.
    left_inconsistent: Prepared permanent content can remain unattached pending pipeline cleanup.
    observer: The operation response.
    provenance: observed
    source: 'services-committees:modules/meetings/services/minutes/minutes.ts:writeBody'
  - 'n': 4
    actor_or_service: Meetings API
    action: >-
      Remove a packet material and detach its managed file in the same
      transaction.
    anchor: >-
      services-committees:modules/meetings/services/persistence/meeting-materials.ts:deleteMaterial
    seam: sync
    on_failure: Roll back deletion and detachment.
    left_inconsistent: The original material remains attached.
    observer: The operation response.
    provenance: observed
    source: >-
      services-committees:modules/meetings/services/persistence/meeting-materials.ts:deleteMaterial
  - 'n': 5
    actor_or_service: Asset cleanup
    action: >-
      Sweep due asset rows every fifteen minutes and retire each queued file
      after the reference check.
    anchor: >-
      services-committees:modules/meetings/aws/lambda/ASSET_CLEANUP.handler.ts:handler
    seam: schedule
    on_failure: Redeliver cleanup messages that do not settle.
    left_inconsistent: Unreferenced files can remain longer.
    observer: The declared asset cleanup silence alarm.
    provenance: observed
    source: >-
      services-committees:modules/meetings/aws/lambda/ASSET_CLEANUP.handler.ts:handler
branches: []
waits: []
evidence:
  - >-
    services-committees at 36129c24:
    modules/meetings/services/materials/material-assets.ts;
    services/minutes/minutes-body.ts, minutes.ts;
    services/persistence/meeting-materials.ts; aws/lambda/ASSET_CLEANUP*.ts
controls:
  - TC-IAM-006
  - TC-AZ-001
  - TC-AZ-002
  - TC-AZ-003
  - TC-AZ-004
  - TC-AZ-006
  - TC-TEN-001
  - TC-TEN-002
  - TC-TEN-003
  - TC-SEC-001
  - TC-SEC-004
  - TC-CRY-004
  - TC-DAT-001
  - TC-DAT-002
  - TC-DAT-003
  - TC-DAT-004
  - TC-LOG-002
  - TC-LOG-003
  - TC-LOG-004
  - TC-LOG-005
  - TC-AVL-004
  - TC-MON-001
  - TC-MON-002
  - TC-PI-001
  - TC-PI-002
  - TC-PI-003
  - TC-PI-004
  - TC-PI-005
  - TC-PRV-001
  - TC-PRV-002
---
# Prepare and Retire Meeting Files

## What It Does

Staff attach or remove packet files, or save and assemble minutes. File preparation and database attachment are separate stages. A failed or stale record save does not undo the already prepared object; cleanup owns that residue. Minutes assembly is deterministic and makes no model call.

## The Flow

```mermaid
flowchart TD
  H1["Stage minutes text in the workspace upload area."]

  H2["Prepare the file through inspection and permanent storage outside the record transaction"]
  H3["Lock and recheck the record, save its prepared reference and hash, and attach or detach assets together."]
  H4["Remove a packet material and detach its managed file in the same transaction."]
  H5["Sweep due asset rows every fifteen minutes and retire each queued file after the reference check."]
  H1 --> H2
  H2 --> H3
  H3 --> H4
  H4 --> H5
```

Stage minutes text in the workspace upload area. Prepare the file through inspection and permanent storage outside the record transaction; refuse foreign references and disallowed content. Lock and recheck the record, save its prepared reference and hash, and attach or detach assets together. Remove a packet material and detach its managed file in the same transaction. Sweep due asset rows every fifteen minutes and retire each queued file after the reference check.

## When Something Fails

Stop before recording the body. An upload can remain staged until expiry. Reject the file. Staged data may remain for cleanup. Roll back the reference write. Prepared permanent content can remain unattached pending pipeline cleanup. Roll back deletion and detachment. The original material remains attached. Redeliver cleanup messages that do not settle. Unreferenced files can remain longer.

## Open Design Questions

File preparation and database attachment are separate stages. A failed or stale record save does not undo the already prepared object; cleanup owns that residue. Minutes assembly is deterministic and makes no model call.
