Add Fathom media storage foundation

Merged
EH
2mo ago
+1412-4

Stack

  1. #25432 — Fathom media storage foundation
  2. #25433 — Asynchronous Fathom media import
  3. #25434 — Local recovery and disconnect cleanup

Supersedes closed #25337. All changes are inside the Fathom app; no Twenty server, core, or SDK changes.

Scope

Add the durable media state and streaming storage path without activating background imports. Additive metadata only; #25433 supplies the callers.

  • Track connected-account owner, download ID, expiring claim, failure reason, and upload checkpoint.
  • Stream Fathom media directly to Twenty's presigned target, with bounded memory, size validation, and cancellation through body consumption.
  • Persist the upload checkpoint after PUT and before file completion. Retries can complete and attach that file without repeating the upload.
  • Fence checkpoint, attachment, and failure writes by owner, claim, and download ID; guard CallRecording completion with its read snapshot.
  • Share the media-kind schema and cover media-state mapping and download-result classification.

Review follow-up

Fixed the body-timeout and synchronous-request cleanup leaks, checkpoint ordering, async server-callback assertions, duplicated media-kind definition, and missing mapper coverage.

The inactive foundation is intentional. Successful attachment explicitly clears the media failure reason in its caller. The sync-fields type describes writes, not nullable query results. Two small HTTP fixtures remain local rather than introducing another test abstraction.

Verification

Independently verified at this layer: typecheck, lint, 57 unit/real-HTTP tests across 16 files, and application build (24 files). No service-mock suites or code comments added.

Review size: 989 non-test additions. Integration of this path is activated and checked by the subsequent stack layers.