# Jobs Page Contract ## Purpose Jobs manages transcription processing runs. A Job belongs to one Document, links one or more Source pages, records processing provenance, and exposes lifecycle actions without making lifecycle fields directly editable. ## Routes | Route | Purpose | | --- | --- | | `/jobs` | Searchable processing Job list. | | `/jobs/new` | Create and queue a Job. | | `/jobs/{job_id}` | View status, execution logistics, and related records. | | `/jobs/{job_id}/cancel` | Confirm cancellation. | | `/jobs/{job_id}/resubmit` | Confirm resubmission of failed Sources. | | `/jobs/{job_id}/delete` | Confirm or block deletion. | ## List Behavior - The title is **Transcription Pipeline Jobs**. - **Create job** opens Job creation and **Refresh** reloads the table. - Columns are Job ID, Status, Source Filename, Retries, Created, and Updated. - Search covers Job ID, filename, and status. - Status is displayed as a semantic status chip. - Selecting a row opens Job Detail. - No records displays `No job records found in repository.` ## Create Behavior - A Target Document and at least one source file are required. - `document_id` may preselect a Target Document. - If no Documents exist, the page explains the prerequisite and links to Document creation with a return path. - Provider and Model are optional request overrides. - Upload accepts JPEG, PNG, TIFF, and PDF files and supports multiple/folder selection. - The visible upload queue is sorted alphabetically by original filename. - Files can be removed individually or cleared before submission. - Helper text explains numeric filename prefixes for page ordering. - Submission creates the Job, Source records, and JobSource links, notifies the worker, and opens Job Detail. ## Detail and Lifecycle Behavior - The heading shows Job ID and a status badge. - Execution Logistics shows provider, model, prompt, retry count, and last update. - Document Links open the parent Document and Job-filtered Sources. - Queued and processing Jobs show an auto-refresh notice and reload every four seconds. - Polling stops when the Job becomes terminal or a refresh fails. - Queued and processing Jobs expose **Cancel**. - Jobs other than `transcribed` expose **Resubmit** under the current UI rule. The service blocks resubmission while processing is active or when no failed Sources exist. - All Jobs expose **Delete Job**, subject to delete guardrails. - Invalid and missing IDs produce explicit states. ## Cancel Behavior - The confirmation explains that processing stops and remaining non-transcribed Sources become failed. - The service decides whether the current state permits cancellation. - Success updates the Job, notifies the worker, and returns to Job Detail. ## Resubmit Behavior - The page shows current status and failed Source count. - The page explicitly states: `Resubmit queues only failed linked sources. New results overwrite prior page-level results.` - The service blocks submission while processing is active or when no failed Sources exist. - Current behavior updates the existing page-level result when new output arrives. - Success reports the number of resubmitted Sources and returns to Job Detail. ## Delete Behavior - Deletion is blocked while status is `processing`. - Allowed deletion warns that related JobSource links are removed. - Success returns to the Jobs list. ## Acceptance Checklist - Job creation cannot proceed without a valid Document and at least one Source. - Upload ordering and removal controls match the displayed queue. - Detail shows current status and provenance summary with correct related links. - Active Jobs refresh without overlapping permanent polling after terminal state. - Cancel, resubmit, and delete honor service guardrails and show actionable failures. - Lifecycle fields cannot be edited directly. ## Implementation Anchors - `src/transcription/ui/pages/jobs_page.py` - `src/transcription/ui/components/table/jobs.py` - `src/transcription/services/jobs.py` - `src/transcription/services/store.py` - `src/transcription/services/workflows.py` - `tests/ui/test_jobs_page.py` - `tests/services/test_job_service.py` - `tests/services/test_store.py` ## Planned Change V4.2 replaces update-in-place retry evidence with append-only processing attempts and adds exact transport evidence. Until implemented, the current overwrite behavior must be labeled accurately rather than described as archival history. See the [V4.2 scope](../../ver4.2/scope_boundary_v4_2.md).