express · Medium · upload lifecycle
A production API needs a upload command ownership repair at its service boundary. A React upload panel lets the user replace a file while the previous upload is still running. Progress and completion from the old upload currently overwrite the new file.
Task
Implement the upload command ownership contract used by the supplied HTTP adapter. Reduce choose, progress, complete, fail and remove events so only the current upload owns visible state.
Contract
Input is {events}. choose carries id and name; other events carry id. Return {fileName,progress,status,error,aborted}.
Acceptance criteria
- Choosing a file aborts the previous active ID.
- Ignore stale progress and settlements.
- Clamp current progress to 0..100.
- Remove aborts current work and clears visible state.
- Return a deterministic JSON-serializable result for the HTTP adapter.
Constraints
- Do not mutate caller-owned input.
- Keep the supplied framework adapter and public contract unchanged.
- Add candidate tests for at least one boundary not covered by the public cases.
Editable files
src/repair.js— Task-specific state or service boundarytests/candidate.test.js— Candidate-authored regression