Registry stack documentation: machine-readable Markdown.
Index of all pages: https://docs.registrystack.org/llms.txt
Full corpus: https://docs.registrystack.org/llms-full.txt

# Receive Casework completion wakes

> Authenticate, deduplicate and durably enqueue the review.completed wake that Registry Casework sends to your producer, then read the immutable result under your own authority.

A Registry Casework completion wakes your producer so it can read the immutable result under its own authority.
Authenticate and durably enqueue the wake before you acknowledge it.
A wake never authorises a source mutation.

{/* Evidence: crates/registry-casework/src/runtime.rs deliver_review_completion;
    crates/registry-casework/tests/review_postgres.rs at_least_once_completion_durably_deduplicates_after_lost_ack_and_exhausts_bounded_retries */}

## Wire and delivery contract

Casework sends a POST with a JSON body that carries exactly these business fields:

```json
{"type":"review.completed","eventId":"11111111-1111-4111-8111-111111111111","requestId":"22222222-2222-4222-8222-222222222222","resultId":"33333333-3333-4333-8333-333333333333","completedAt":"2026-09-19T12:34:56Z"}
```

The body contains event, request and result identifiers and a completion time.
It carries no review decision and no source record payload.

The request carries these headers:

- `Idempotency-Key` is the string form of `eventId`.
- `Registry-Recipient-Binding` is the producer's configured recipient binding.
- The destination presents either `Authorization: Bearer <secret>` or the configured named secret header.

Compare the expected secret and recipient before you accept a wake.
Make sure your HTTP framework logs redact credential headers.

{/* Evidence: crates/registry-casework/src/runtime.rs deliver_review_completion;
    crates/registry-casework/src/config.rs ReviewCompletionAuthConfig */}

### Acknowledgement

Any 2xx response acknowledges delivery.
Casework decides from the status line and drops the response without reading its body, including an unfinished stream.
Use an empty 204 for compatibility with releases through 0.43.0, which required that response.
Casework does not follow redirects.

{/* Evidence: crates/registry-casework/src/runtime.rs completion_acknowledged */}

### At-least-once delivery

Delivery is at-least-once: after a lost acknowledgement Casework can send again.
The same `eventId`, payload, recipient binding and idempotency key survive retries.
Receivers must durably deduplicate by `eventId` before they acknowledge.
This does not provide exactly-once delivery or exactly-once business effects.

{/* Evidence: crates/registry-casework/tests/review_postgres.rs at_least_once_completion_durably_deduplicates_after_lost_ack_and_exhausts_bounded_retries */}

### Retry bounds

Three settings on the completion destination control retries:

- `attemptTimeoutMilliseconds` defaults to 5000 and accepts 100 through 30000.
- `retryDelaySeconds` defaults to 30 and accepts 1 through 86400.
- `maximumAttempts` defaults to 12 and accepts 1 through 100.

A failed attempt returns to pending until the configured attempt bound or the retention deadline exhausts it.
Exhausted work is terminal for this dispatcher.
Recover missed work through the producer's authenticated result feed.

The outbox writes one value-free failure diagnostic per settled failed attempt and one terminal diagnostic at exhaustion.
Only the destination identifier, the attempt number and fixed failure or terminal labels are emitted.
URLs, credentials, payloads and subject identifiers stay absent.
A stale lease owner cannot settle or log another owner's attempt as exhausted.

{/* Evidence: crates/registry-casework/src/config.rs ReviewCompletionRuntimeConfig, MAXIMUM_REVIEW_COMPLETION_ATTEMPTS;
    crates/registry-casework/tests/review_postgres.rs completion_dispatcher_leases_one_at_a_time_and_fences_a_stale_owner */}
{/* TODO[evidence]: defaults 5000, 30 and 12 are in default_review_completion_* functions; no test asserts the default values */}

## Durable receiver examples

Create an adopter-owned inbox in the receiver database:

```sql
CREATE TABLE completion_inbox (
  event_id uuid PRIMARY KEY,
  payload text NOT NULL
);
```

These framework-neutral handlers assume your HTTP adapter has bounded the JSON body, rejected duplicate members, checked the five fields and their UUID and time types, and normalised header names to lowercase.
Pass an operator-resolved secret and recipient; never use event fields to select credentials or authority.
Return 503 when the database cannot commit.
Keep inbox entries until your own reconciliation is complete and your replay policy permits erasure.

Python with a psycopg connection:

```python
import hmac
import json


def receive_completion(headers, event, db, secret, recipient):
    if not hmac.compare_digest(headers.get("authorization", ""), "Bearer " + secret):
        return 401
    if headers.get("registry-recipient-binding") != recipient:
        return 403
    if event["type"] != "review.completed" or headers.get("idempotency-key") != event["eventId"]:
        return 400
    payload = json.dumps(event, sort_keys=True, separators=(",", ":"))
    with db.transaction():
        db.execute("INSERT INTO completion_inbox VALUES (%s,%s) ON CONFLICT DO NOTHING",
                   (event["eventId"], payload))
        stored = db.execute("SELECT payload FROM completion_inbox WHERE event_id=%s",
                            (event["eventId"],)).fetchone()[0]
        if stored != payload:
            return 409
    return 204  # The commit completed before acknowledgement.
```

Node with a `pg` pool (the SQL statement autocommits before its promise resolves):

```javascript
const { timingSafeEqual } = require('node:crypto');

async function receiveCompletion(headers, event, pool, secret, recipient) {
  const got = Buffer.from(headers.authorization ?? '');
  const expected = Buffer.from(`Bearer ${secret}`);
  if (got.length !== expected.length || !timingSafeEqual(got, expected)) return 401;
  if (headers['registry-recipient-binding'] !== recipient) return 403;
  if (event.type !== 'review.completed' || headers['idempotency-key'] !== event.eventId) return 400;
  const payload = JSON.stringify({ type: event.type, eventId: event.eventId,
    requestId: event.requestId, resultId: event.resultId, completedAt: event.completedAt });
  await pool.query('INSERT INTO completion_inbox VALUES ($1,$2) ON CONFLICT DO NOTHING',
    [event.eventId, payload]);
  const stored = await pool.query('SELECT payload FROM completion_inbox WHERE event_id=$1',
    [event.eventId]);
  return stored.rows[0].payload === payload ? 204 : 409;
}
```

A database error must reach your HTTP adapter as a safe 503; do not acknowledge an uncertain insert.
For named-header authentication, compare the configured header's raw value with the secret instead of constructing a bearer value.

## Read the result

A worker reads the persisted inbox and your application's previously accepted binding.
For Python, call `client.review_result(resource_token, requester_profile, persisted_accepted)`.
Node uses `client.reviewResult(resourceToken, requesterProfile, persistedAccepted)`.

Persisted acceptance has `requestId`, `policy`, `subject` and `submissionDigest`.
Validate that the event belongs to a known accepted request, then let the maintained client correlate the fetched result to that binding.
You may retain an unmatched authenticated wake until your request acceptance is durably recorded.
Neither the notification's `resultId` nor an approved result replaces the source's current authorisation, revision guards or transaction checks.

{/* Evidence: crates/registry-casework-client-py/src/lib.rs review_result;
    crates/registry-casework-client-node/src/lib.rs review_result */}

## Next

- [author a Casework policy](../casework/)
- [registry casework runtime configuration reference](../../reference/casework-configuration/)
- [deploy registry casework](../../operate/casework/)