---
title: Conversation files
description: Immutable uploads and current conversation access protect stored evidence.
owner: engineering
sourceFiles:
  - packages/contracts/src/server/files.ts
  - packages/db/src/schema/files.ts
  - apps/server/src/domain/files/files.ts
  - apps/server/src/domain/files/validation.ts
  - apps/server/src/domain/files/publication-access.ts
  - apps/server/src/domain/conversations/publications.ts
  - apps/web/src/features/conversation/components/conversation-files.tsx
  - apps/web/src/features/conversation/components/saved-file-rows.tsx
  - apps/web/src/features/conversation/components/saved-file-dialog.tsx
  - apps/server/src/domain/files/data.ts
  - apps/server/src/file-storage.ts
  - apps/server/src/domain/space-storage/service.ts
  - apps/server/src/runtime/space-storage.ts
  - infra/storage/space-buckets.ts
  - apps/web/src/components/files/file-viewer.tsx
  - apps/web/src/components/files/file-viewer-policy.ts
  - apps/web/src/components/files/pdf-viewer.tsx
  - apps/web/vite.config.ts
  - apps/web/src/features/conversation/interactions-api.ts
---

Upload original evidence to an explicitly authorized conversation. Metadata and downloads use the same current conversation access check, including membership, audience, grants and the bound business relationship. A client contribution does not grant access to its parent task or other files.

## Upload and recovery

`POST /conversations/:conversationId/files` accepts one multipart `file` with a UUID `idempotency-key` header. The maximum file size is 10 MiB. Accepted types are PDF with a PDF header, XLSX with a ZIP header, CSV, UTF-8 text, Python source and valid UTF-8 JSON, using supported filename extensions and matching MIME types. Empty or `application/octet-stream` metadata is accepted only for these extensions, with the same content checks. CSV also accepts `application/vnd.ms-excel`, `text/plain`, `application/csv` and `text/x-csv`; JSON accepts `text/json`; Python accepts `text/x-python` and `application/x-python-code`. Saved MIME types are canonical (`text/plain` for Python). Downloads remain attachments with `nosniff`, and saving never executes the source. XLSX bytes are opaque; the upload check does not validate workbook contents. Empty, unsupported and malformed uploads fail explicitly. File validation does not perform malware scanning, PDF parsing or financial extraction.

The server resolves the authorized conversation's ready storage location, generates file and version UUIDs and computes SHA-256. Pending shared storage is verified automatically before accepting a new upload. Missing, failing or mismatched storage returns 503 without acknowledging a saved file. The persisted owner is the conversation's organization; the creator is the initiating user. Filenames are display metadata and never storage paths. Each file has one immutable version in this first slice.

Each file pins an immutable storage-location ID, verified against its conversation's space and owner. Retries use that recorded location rather than resolving a different bucket; internal location and binding coordinates are absent from public metadata.

A pending metadata record reserves the initiating user's request key within the exact conversation. Bytes go to a create-once private object key before the record becomes ready. Only ready files appear in the catalog. Repeating the same request reconciles the reserved object and returns the same reference. Reusing its key with changed content or metadata returns a conflict.

Storage failure returns an unavailable response. A failed or interrupted save may retain pending metadata or private bytes; it is not acknowledged as saved. Retry with the same key and original bytes. No automatic broad cleanup deletes uncertain evidence.

## Read boundary

`GET /conversations/:conversationId/files` returns the newest 100 ready files, ordered newest first. A file's metadata is at `/conversations/:conversationId/files/:fileId/versions/:versionId`; append `/content` for its bytes. Downloads are authenticated attachments with no public URL and no browser execution. The server verifies the stored length and hash before returning bytes; unavailable or inconsistent storage returns an error.

References contain `{fileId, versionId, sha256}`. Normal origin reads require access to that exact conversation. Copying a reference into another conversation does not grant access. Message attachment metadata pins only ready versions in that same conversation. [Output publication](/architecture/conversations#files-and-shared-output-cards) creates an explicitly authorized Client copy and an immutable card; source linkage stays server-side and the copy grants no access to Team history or future revisions.

Private-agent uploads reuse the file metadata, validation and environment bucket with a separate ownership mapping and prefix. See [private files](/architecture/personal-agent#private-files); shared conversation grants never authorize private files.

## Storage ownership

The [Space storage catalog](/architecture/space-storage) records immutable logical locations. Alchemy binds one private evidence bucket per environment for new spaces; legacy locations keep their dedicated buckets. Shared object keys include the owning organization and space, while current database grants enforce access. File operations consume native bindings and never provision buckets or use deployment credentials. Space creation attempts shared-location verification automatically, and the next authorized upload retries after a storage outage. The firm space Apps & Files tab lists authorized space-level Team conversation files through the same file service. Agent completion refreshes that saved-file list. Metadata lives in PlanetScale Postgres; saved binary payloads stay in R2. Deleting a conversation removes its metadata through foreign keys. Deleting a space queues cleanup of its own shared prefixes or dedicated bucket, preserving other spaces' files.

The Computer filesystem is the durable working environment for agents. Uploading evidence does not itself import it into that workspace or grant tool/provider authority. Team tools import an exact authorized version into the operation's Computer filesystem and save a named snapshot through the same R2/file-metadata service. Native public asset links do not replace current Workbench grants. Viewer editing, revisions, extraction, external imports, deletion/retention policy and disaster recovery remain separate work.

## Native previews

Open a saved file in the conversation or Team Apps & Files tab to preview it. Download is inside the preview dialog, and also beside a file in a conversation. Apps & Files rows show the date without a name: Wes saves a file as the person who asked, so the stored user does not say who made it. Each opening revalidates current conversation access and the immutable version/SHA-256 reference through a metadata read. TanStack Query retains immutable preview bytes in memory for five minutes, keyed by user, organization, space, task, conversation, file, version and hash; reopening reuses those bytes after the access read succeeds. Denied reads remove cached bytes; scope changes clear actor-scoped caches. Failed reads never render file content, and retry performs another authorized read.

Text, Python and JSON display as inert UTF-8 source. Markdown uses Workbench typography with HTML skipped, links rendered as text and images rendered as alt text, preventing embedded execution and external image requests. CSV displays a native table without assuming a header row, preserves quoted commas, multiline values and empty cells, and treats formulas as text. Text previews accept at most 512 KiB; CSV renders at most 200 rows and 50 columns with a visible limit notice. CSV keeps a readable minimum table width and scrolls horizontally on narrow screens. Download retains the complete file.

PDF.js renders one page at a time with page navigation, 50–200% zoom and expandable extracted page text. It uses a bundled local worker, fonts, character maps and image decoders and does not run PDF scripts, annotations or external viewer pages. PDFs are limited to 10 MiB and each rendered canvas to 4096 pixels on its longest side, with decoded images limited to 16 megapixels and image resize canvases to 64 MiB. A visible notice explains that large images may be omitted; pages that fail to render retain a download fallback. Password-protected, unreadable and unsupported files show a download fallback. Scanned pages have no extracted text without OCR. Excel preview remains outside this initial scope. The shared Base UI dialog supplies focus containment, Escape dismissal and trigger focus restoration.
