Process out-of-order PDF webhook events
3 November 2026
To process out-of-order PDF webhook events when a completion notification arrives before an earlier running-state notification, if the provider supplies an authoritative job revision, compare it with the last accepted state for the same tenant and job. Apply only allowed state transitions, while logging distinct event identifiers in the audit log without rolling back a completed job state.
Out-of-order delivery mechanics and state guardrails
If the provider can deliver notifications out of order, receipt time alone cannot determine which state is current. When integrating automated PDF processing workflows, a terminal completion notification may land prior to an earlier processing notification.
Consider the completion-before-running exercise. In this exercise, a completion notification arrives before an earlier running-state event, testing whether the system preserves event identities and job revision ordering while preventing a delayed message from rolling back a completed job.
Rather than relying on timestamps, this fixture orders transitions by the explicit job_revision counter. For a service without comparable revisions, reconcile an ambiguous update against its authorised job-status record before applying it. When a payload carries a lower revision number than the current persisted job state, the event must be logged for audit tracing, but the job's state must remain unchanged at its higher terminal revision. Event contract · Signed event results
Evaluation ledger for synthetic execution fixture
The behaviour of out-of-order event evaluation is documented in the synthetic test fixture signed-event-results.json. This local contract test was executed using Python 3.12.14 with 0 network calls and a clock set to 2026-10-31T12:00:00Z (1793448000 Unix timestamp), operating within a 300-second freshness window. Server status is recorded as NOT_RUN, establishing a local test harness rather than a live network endpoint. Event contract · Signed event results
In this test environment, signatures are validated using HMAC-SHA256(timestamp + dot + exact UTF-8 body). Across 9 evaluated test cases, the fixture verified state transition rules for out-of-order payloads. Event contract · Signed event results
| Delivery Order | Event ID | Job ID | Job Revision | Payload State | Timestamp | Expected Action | Observed Result | Final Job State |
|---|---|---|---|---|---|---|---|---|
| 1st Delivered | E02 | SYN-J01 | 2 | SUCCEEDED | 1793448000 | APPLIED | APPLIED | Revision 2 (SUCCEEDED) |
| 2nd Delivered | E02 | SYN-J01 | 2 | SUCCEEDED | 1793448000 | DUPLICATE | DUPLICATE | Revision 2 (SUCCEEDED) |
| 3rd Delivered | E01 | SYN-J01 | 1 | RUNNING | 1793448000 | RECORDED_STALE_EVENT | RECORDED_STALE_EVENT | Revision 2 (SUCCEEDED) |
Completion event E02 (revision 2, SUCCEEDED) arrives first and transitions the job to SUCCEEDED. When delayed running event E01 (revision 1, RUNNING) subsequently arrives, the evaluation handler marks the event action as RECORDED_STALE_EVENT. The system logs E01 as one of 2 distinct event records while preserving final job state at revision 2 (SUCCEEDED). Signed event results
Event sequence decision record and unresolved conflict case
Integration engineers should record out-of-order event decisions in an operational audit log. The worked decision record below illustrates the fields required to trace incoming payloads and resolve state conflicts.
Worked decision record (Example: Tenant SYN-T01 / Job SYN-J01)
- Tenant ID:
SYN-T01 - Job ID:
SYN-J01 - Current Model Revision: 2 (State:
SUCCEEDED) - Incoming Event ID:
E01 - Incoming Job Revision: 1
- Incoming State:
RUNNING - Signature Verification: Valid (
45e13861e678...) - Freshness Check: Passed (Timestamp
1793448000, offset 0s) - Evaluated Rule:
Incoming Revision (1) < Current Revision (2) - Action Applied:
RECORDED_STALE_EVENT - Recorded Model State: Revision 2 (
SUCCEEDED) - Audit Status: Recorded locally (
distinct_event_records: 2); durability was not tested
Event contract · Signed event results
Complex conflict result requiring operational intervention
While stale lower-revision events are safely absorbed as RECORDED_STALE_EVENT, payload conflicts at the same revision level require operational escalation. Signed event results
In test case same_event_id_different_signed_body, an event arrives with ID E02 and revision 2, but carries state FAILED with signature 843bdf916acf9afc..., contradicting the previously applied E02 SUCCEEDED payload. The system returns REJECTED_EVENT_ID_CONFLICT. Signed event results
- Next Step Owner: Integration Operations Lead
- Closure Requirement: Manual investigation of upstream webhook logs to determine if event ID re-use or payload mutation occurred. Until resolved, job state remains locked at revision 2 (
SUCCEEDED) and the local model records the conflict; no production queue was exercised.
Payloads carrying unknown schema versions (such as schema_version: "9") result in HELD_SCHEMA. Local test limitations apply: no durable queue, provider redelivery, TLS transport, or vendor API calls were exercised. Signed event results
Implementation checklist for PDF webhook sequence handling
- Authenticate the event and scope. Check the provider’s exact signing rule, authorised source, tenant, job and allowed schema. Use the contract’s freshness policy; 300 seconds belongs to this local fixture.
- Check event identity. If the same scoped event ID and bytes have already been accepted, record the new delivery as a duplicate and avoid another downstream action. If the same event ID arrives with different authenticated bytes, hold it as an identity conflict. A different event at the same revision may need reconciliation under the provider’s contract.
- Check the transition. An earlier running revision should not make a completed job run again. Record it as a distinct stale event. Even a higher revision needs an allowed transition; investigate any proposal to reopen a terminal job.
- Make concurrent handlers safe. Test a conditional write or transaction that couples the state transition with the deduplication record. Race the two synthetic deliveries, then inspect both the final job and the number of downstream actions. The source demonstrated local ordering; persistence, redelivery policy and crash recovery remain to be tested.
Event contract · Signed event results
Next step
Execute the local synthetic contract test suite against your webhook ingestion logic to confirm that out-of-order RUNNING events return RECORDED_STALE_EVENT while maintaining job state at SUCCEEDED revision 2.
Part of the Test duplicate and out-of-order PDF webhook events guide.
Published by Arke Technologies (Pty) Ltd, Johannesburg. Drafted with NotebookLM. Source checks and editing by Kairos (Codex).
