Derive progress from accepted work that can still be recovered. A job that archives 100 files, for example, can report how many artifacts have been durably recorded against the current scope. How many attempts a worker made, or how far a loop ran, is useful for troubleshooting. It does not establish how much is ready to deliver. Give each public status snapshot a revision so that the client applies only newer responses. Retain reusable milestones during retries. When the scope or the artifacts really change, recalculate and explain the change.
Separate acceptance, execution and delivery
In RFC 9110, HTTP 202 indicates that a request has been accepted for processing and that processing has not finished. It provides no assurance that the job will succeed. An archive API can persist a request, return a job identifier and a status location, and allow clients to poll on the documented schedule. Submit the same business request with a stable idempotency key and look up its status if submission returned an uncertain result. The read API tells the caller how far the job has reached, when the result is available and whether an operator needs to act. Refreshing the browser should never enqueue another archive job.
Treat lifecycle as a different field from progress. Queued, running, waiting to retry, final validation, succeeded, failed and canceled describe stages or outcomes. Progress can include verified milestones, reusable work per stage and current counts. An estimate uses arrival rates and processing time and is additional information. If there is no reliable denominator, report the phase, the reason for waiting and the last update rather than guessing a percentage. Microsoft's Asynchronous Request-Reply pattern makes a percentage optional and suggests including creation and last-update timestamps. Google's AIP-151 similarly uses operation metadata for process information and distinct fields for the result or final error.
Acceptance of an item differs from availability of the overall delivery. A checked artifact in staging is reusable in later aggregation. Releasing an archive can still require checking the manifest, promoting the result pointer and confirming the necessary access. If the final step fails, retain the useful fact that 100 items were processed, and report validation or a wait to retry release. Progress at 100 usually invites an attempt to download. Define precisely when the API can expose that value.
Base progress on records that can be audited
A file archive can use a job record, a frozen manifest and per-item completion records. The job record carries job_id, scope_revision, state_version, the current worker generation, lifecycle and a result reference. The manifest lists logical input IDs, versions and the relevant acceptance configuration. An item record is uniquely identified by job_id, scope_revision and item_id and retains verified artifact references and acceptance results. A large file that requires several artifacts only counts once all of its required outputs pass. When two logical items share the same physical contents, decide whether they count separately in the delivery contract. A temporary file path cannot make that decision.
Tie the artifact and completion record to the same business identity. Within a database, a unique key can limit an item to one completion record and a transaction can commit both that record and its count update. A blob upload and the database commit will generally occur in separate systems. Upload a new staging version, read it back and verify its checksum, and record an immutable version in the final database commit. A crash after upload can leave a staging artifact. On recovery, resolve the staged output using the same business ID, confirm its input version and checksum, then register the verified result or regenerate it. Remove unused staging artifacts according to the retention policy.
Takeover must also account for a late write from the previous worker. Each time a worker obtains ownership, persist an increasing generation. Check that generation at the actual write boundary when registering items or publishing the final state. The previous process can remain alive and keep computing briefly. Its late writes have to be rejected after takeover. Where object storage cannot perform the same conditional write, store each attempt under an immutable key and let readers follow only the committed reference. An old artifact can then be abandoned without overwriting the selected result. Apply the ownership check to item acceptance, the final manifest pointer and lifecycle changes. See resource-side checks for stale workers for the database takeover protocol and the final write condition. The same boundary protects the progress displayed here.
The status version identifies the newer snapshot, independently of worker ownership. One worker generation may complete many items, so the version increases each time a changed snapshot becomes visible. Read the count and version together under the same consistency boundary. A version from a new commit paired with a count from an old cache will still mislead the client. One implementation updates materialized counts and state in the same transaction. Another computes a snapshot from an event stream and identifies the consumed stream position, with counts and scope computed from the same view. Gaps between published versions can be valid. Clients need a comparable order, not consecutive integers on every read.
Calculate progress for 100 files
These are constructed numbers. The weights describe milestone completion and do not measure time. An archive job starts with 100 files at fixed input versions. Recording the input manifest is worth 10 points. Validating access to the inputs is worth 20. Processing and accepting items accounts for 60. Final manifest validation and delivery are the last 10. During processing the score is 30 + floor(60 × accepted items ÷ 100), capped at 90. The final 10 become visible together when the result is available under the delivery contract. The UI can also show “80 of 100 accepted, waiting to retry” so the reader sees both scope and cause.
A job that is still discovering its inputs should show the current phase until it can establish the denominator. In the example, progress reaches 30 when the manifest and input checks are complete. Eighty accepted items give 78. If the worker dies while processing item 81, the 80 accepted results are still readable and the replacement starts at 78. It computes the outstanding set by comparing the manifest against the completion records. A duplicate event for item 50 adds nothing. At 100 accepted files the score is 90, and the interface reports that the final manifest is being verified. Once access and manifest checks succeed, commit the result pointer and success state before exposing 100.
Parallelism does not alter the definition of completion. Thirty small files can finish quickly while the final two run for much longer. Showing the number of slow items, the reason for the block and the next retry time is more useful than treating the score as a clock. If the product needs an ETA, estimate a range from remaining work size, available concurrency and measured service rate. Mark estimation unavailable when sizes are unknown or external quotas block progress. Scores from different jobs also have different scope and stage assumptions. One job's 78 does not imply the same remaining time as another's.
If validation discovers that 20 accepted results used the wrong input version, retaining a permanently increasing bar would hide real rework. Where the delivery contract allows corrections, save a new scope revision with the reason and re-validate the 60 reusable items. The new score is 30 + floor(60 × 60 ÷ 100) = 66. If the actual scope expands to 125 validated inputs and all 80 previously accepted results still qualify, the score becomes 30 + floor(60 × 80 ÷ 125) = 68. Show that the previous 78 described a different revision. If the original delivery cannot expand, keep the original submission and create a separate business job for the additional items.
Use the same snapshot rules for polling and push
A status read should return the job identifier, increasing state version, scope revision, lifecycle, phase and counts. Add the server update time, failure information and result reference where useful. Neither the percentage nor the update time establishes which of two responses is newer. Several updates can share a timestamp and worker clocks can disagree. Compare server versions for the same job. On a fetch failure, preserve the last confirmed progress and show its age or the connection problem. Change the lifecycle to failed only after a confirmed service result.
Suppose two concurrent polls return version 12, score 78 and waiting to retry, and version 14, score 90 and checking the manifest. The later request may arrive first. After showing version 14, discard the state and counts from version 12. Accept a higher version belonging to a new scope, such as version 15, revision 2 and score 66, with an explanation that 20 outputs need renewed validation. When the user switches jobs, discard late responses for the original job and establish a version baseline for the newly selected one.
Push suits dashboards with tight latency or high polling load. On reconnection, load a current snapshot and resume updates, or backfill from a stream position when the server supports it. Deduplicate by version. Fetch again when losing the local view or detecting a gap that could affect current state. Include duplicated events, disconnected subscribers and distinct browser caches in the tests. A WebSocket connection's message order alone does not prove that a count incorporates all accepted results.
Give the status resource an appropriate cache policy. Private jobs with immediate consistency needs can prevent shared caching or use a deliberate conditional request policy instead of inheriting the caching used for a result download. Where reads go to a replica, lag may expose old snapshots. Client-side rejection prevents an older view from replacing a newer one, but a cold start or another device still requires a read path that meets the expected staleness bound. Record the version and snapshot source so that unexplained older reads can be diagnosed.
Choose phase-only reporting, durable snapshots or a workflow engine
A small implementation can report phases, item counts where available and a clear delivery result. That is a lower-maintenance option for infrequent jobs that are cheap to run again and have no reusable per-item results. Stable manifests make a per-item ledger attractive for many archive services. It provides precise, recoverable progress. Updating a single job row for every item can become a lock bottleneck. Higher-throughput systems can batch count updates, or aggregate shards into a coherent snapshot. Report the aggregation delay and check that repeated or replayed shard records cannot be counted twice.
A workflow engine may help with branching jobs, long execution windows and operator intervention. AWS Step Functions documents Standard Workflow redrive for eligible executions. It can resume from an unsuccessful step using the same input and preserve work from successful steps, subject to the documented behavior of each state. Temporal's workflow model keeps progress independent of an individual process lifetime. These facilities can support recovery. Derive the user-facing display independently from business acceptance. A started workflow or a returned activity does not establish that an archive is available. Safe retries of external effects and the conditions under which an artifact may be reused still belong in the workflow tests.
An equal item weighting can hide remaining effort when work sizes differ. Bytes or predefined size buckets are alternatives when they correlate with workload. Verify the relationship first, since a small compressed input can contain many records. Keep weights fixed within a scope revision. Counts and phases make a workable default, with estimates and weights added to solve observed problems. Avoid heavy extra writes solely for subsecond UI updates. Where tens of seconds of status delay are acceptable, throttle transient snapshots and always verify the final state on readback.
When changing an existing API, compute both definitions in parallel for a sample of retried, resized, failed and successful jobs. Explain the differences from the underlying records. Clients that keep the historical maximum must learn about scope changes before showing the new score. Introduce the new fields to a small cohort and verify receipts. If the UI needs rollback, revert to phases and item counts while retaining durable completion records, versions and published results. Historical terminal states can be reconstructed from validated manifests when available. Old running jobs with incomplete checkpoints should show the stages supported by the evidence.
Run seven failure tests before delivery
First, stop the worker before upload and after upload but before registration. Neither interruption should increment the confirmed count. On the second recovery path, check the input version, artifact reference, checksum and acceptance criteria to decide whether to register or regenerate the output. Confirm that cleanup cannot list published objects as abandoned staging artifacts.
Second, deliver two success events for the same item and replay one after the other has been accepted. Verify that there is one completion row and one count increment. For a derived snapshot, recalculate the count from the completion records for the active scope. Interleave delivery to expose a race that a sequential replay would miss.
Third, hold the old worker's write until a new worker has acquired a higher generation. Exercise item registration, failure reporting and publication of the result. Each write boundary must reject the stale generation. Compare both status and result reference to ensure the replacement's work remained intact.
Fourth, deliver polling version 14 before version 12. The UI must keep version 14. Push version 14 a second time and then complete a pending read for an earlier job after switching tabs or tasks. The view must retain only the current job's snapshot, and diagnostics should identify the reason each response was discarded.
Fifth, restart after 80 accepted items. The reusable score stays at 78 and the ledger still contains 80 accepted records. Invalidate 20 with a new input version. Check that the revision, reason and recalculated score of 66 appear. Reprocess the 20, recompute both numerator and denominator, and confirm the history is traceable.
Sixth, accept all 100 items and fail final manifest or access validation. Public progress cannot exceed 90 and the result cannot be retrieved. Retry the final phase and test the actual authorized download before exposing success and 100 together. Simulate a timeout after the successful commit. A subsequent status read must return the recorded result without repeating the external publication.
Seventh, simulate a slow result store, a dropped network connection and expiration of the status record. Connection loss should preserve and label the last confirmed snapshot. Expired jobs should return the documented expiration response and point to the available route for historical results or a new request. Where retention and retry windows overlap, keep the evidence for active jobs until completion before applying the published retention policy.
Retain the manifest version, sample input, status snapshots, item evidence, write generations, test times and outcomes. Monitor wait time, time since the last progress update, accepted counts and failure causes. If a job stays in one stage for a long time, it should be possible to tell whether it is waiting on an external quota, contending for a write or rechecking a result. A status API becomes dependable when it can explain each visible transition and prove what remains valid after takeover.
