Skip to content

feat(BA-6154): add upload session state model#11765

Closed
jopemachine wants to merge 1 commit into
mainfrom
fix/BA-6154-upload-state-model
Closed

feat(BA-6154): add upload session state model#11765
jopemachine wants to merge 1 commit into
mainfrom
fix/BA-6154-upload-state-model

Conversation

@jopemachine
Copy link
Copy Markdown
Member

@jopemachine jopemachine commented May 22, 2026

📚 Stacked PRs

This PR is part of a 6-PR stack implementing BA-3974 (epic: BA-6153). Merge in order:

  1. 👉 feat(BA-6154): add upload session state model #11765feat(BA-6154): add upload session state model ← you are here
  2. ⬇️ feat(BA-6155): add metadata-driven chunk-store upload session engine #11766feat(BA-6155): add TusUploadSession storage class
  3. ⬇️ fix(BA-6156): rewire TUS PATCH/HEAD to chunk-based store #11767fix(BA-6156): rewire TUS PATCH/HEAD to chunk-based store (user-visible fix)
  4. ⬇️ test(BA-6157): add multi-proxy NFS race regression test #11768test(BA-6157): add multi-proxy NFS race regression test
  5. ⬇️ feat(BA-6158): support TUS Checksum extension #11769feat(BA-6158): support TUS Checksum extension
  6. ⬇️ feat(BA-6159): add /upload/status endpoint and progress headers #11770feat(BA-6159): add /upload/status endpoint + progress headers

Summary

  • Introduce pure data classes (`ChunkRecord`, `SessionState`, `ChunkAcceptance`) that will back the chunk-based TUS upload session designed for BA-3974.
  • Add `SessionState` computed properties: `committed_offset` (contiguous prefix used as TUS `Upload-Offset`), `missing_ranges`, and `progress_percent`.
  • Add `ChunkConflictError` (409) and `UploadSessionCorruptedError` (500) in a new `storage/errors/upload.py`.
  • No HTTP wiring or filesystem I/O yet; this PR is additive and behavior-neutral.

Resolves BA-6154. Part of epic BA-6153 (implements BA-3974).

Introduce the pure data layer for the chunk-based TUS upload session that
will land in BA-3974. No HTTP wiring or filesystem I/O yet — this commit
only defines:

- `ChunkRecord(offset, length, sha256)`: a single received chunk's record.
- `SessionState(session_id, total_size, received, status)`: the source of
  truth for an upload session, with computed properties for
  `committed_offset` (the contiguous prefix end used as TUS Upload-Offset),
  `missing_ranges` (gaps the client still needs to send), and
  `progress_percent`.
- `ChunkAcceptance(state, committed, completed_now)`: the result the
  storage class will return after each commit attempt.
- New error module `storage/errors/upload.py` with `ChunkConflictError`
  (409) and `UploadSessionCorruptedError` (500) — the only errors this
  data layer can raise (the latter from `SessionState.from_json`).

Parametric unit tests cover every computed property, plus JSON roundtrip
and corruption handling. No production code paths consume these classes
yet, so this PR is additive and behavior-neutral.

Resolves BA-6154.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jopemachine
Copy link
Copy Markdown
Member Author

Closing in favor of #11766: the session-state model and the on-disk storage class both live in tus_session.py and the model has no consumer on its own, so splitting them across two PRs hurt reviewability. #11766 now contains the combined chunk-store engine (model + storage class + tests). The work tracked here is absorbed into BA-6155.

@jopemachine jopemachine deleted the fix/BA-6154-upload-state-model branch May 26, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:storage-proxy Related to Storage proxy component size:L 100~500 LoC skip:changelog Make the action workflow to skip towncrier check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant