openai / gpt-6-astra / high / high effort preferred over openai / gpt-6-luna / low / low effort · clear win.
Primary judge: Sol 6.1, requested Low. Effective provider effort and internal attempts were not verified. A close win is still a scored preference; it does not establish a material defect.
Reviewed public evidence
Task goal
Design a durable webhook inbox for one PostgreSQL database and multiple workers. An authenticated source supplies eventID, accountID and payload; deliveries are duplicated and reordered. Persist acknowledgement before returning success, deduplicate by source/account/eventID, process with expiring leases and fencing, preserve per-account dependencies, bound retries and poison events, and recover crashes without claiming exactly-once external effects. Define state transitions, transaction boundaries, backpressure and acceptance failure cases.
Give one coherent design with explicit requirements, assumptions and alternatives, state/invariant/transaction details appropriate to the stated scope, and measurable pass/fail acceptance checks. Do not invent benchmark measurements, provider costs, source inspection, executed tests or objective passes. Every contributor must independently answer the complete identical question; there are no separate roles, files or tool evidence.
openai / gpt-6-astra / high / high effort answer
## Recommendation and assumptions
Use PostgreSQL as the durable acceptance ledger, dependency scheduler, and fencing authority. Serialize processing **per canonical account**, while allowing different accounts to run concurrently. Commit local business changes and external-effect intents together; deliver those intents separately with at-least-once semantics.
This is an independent, reasoning-based design. No source inspection, benchmarks, or tests were performed.
### Required contracts
1. **Identity:** derive `source` from authenticated credentials. Verify authorization for `accountID`; never trust a caller-supplied source identity.
2. **Deduplication:** `(source, accountID, eventID)` identifies one immutable event. Reusing that key with different content is a conflict.
3. **Dependencies:** event IDs and arrival order do **not** reveal causal order. Require either:
- explicit predecessor identities, supplied in or deterministically extracted from payload; or
- an authoritative per-account sequence, including its starting position and gap-resolution rules.
This design uses explicit predecessor identities. Missing predecessors may arrive later. If the source supplies neither dependency information nor sufficient domain semantics, preserving unknown dependencies is impossible; reject or quarantine events requiring that guarantee.
4. Dependencies are within one canonical account. Cross-source dependencies must name the source as well as event ID. Cross-account dependencies require an extension.
5. Sources retry transient failures and uncertain acknowledgements using the same identity and content.
6. PostgreSQL uses durable commits. Any failover configuration must preserve acknowledged commits; asynchronous failover alone cannot guarantee this.
7. Ordering guarantees cover committed local processing. Ordering and uniqueness of actual external effects additionally depend on the receiver’s protocol.
## State and invariants
### Durable records
| Record | Important fields |
|---|---|
| `inbox` | Internal ID; source/account/event identity; immutable payload and content digest; accepted time; state; attempts; next-attempt time; processing deadline; current fencing token; error |
| `dependency` | Child inbox ID; predecessor source/account/event identity; uniqueness constraint |
| `account_lane` | Canonical account ID; monotonically increasing generation; current event and worker; lease expiry |
| `outbox` | Immutable effect ID, originating event, destination, payload, dependencies, delivery state, attempts, lease/token, receipt |
| `quota` | Transactionally maintained capacity reservations, where needed |
| `audit` | Operator resolution, quarantine, replay, and conflict decisions |
The inbox has a unique constraint on `(source, accountID, eventID)`.
Store dependency identities independently of predecessor rows, so a child can be accepted before its parent. An absent parent does not satisfy a dependency.
### Inbox states
```text
PENDING ──eligible claim──> RUNNING ──atomic completion──> SUCCEEDED
│
├──retryable failure / expired lease──> RETRY_WAIT
└──permanent failure / budget exhausted──> DEAD
RETRY_WAIT ──due and eligible claim──> RUNNING
PENDING / RETRY_WAIT ──dependency deadline or impossible dependency──> DEAD
```
Eligibility is a predicate, not another state:
- every required predecessor is `SUCCEEDED`;
- retry time has arrived;
- attempts and deadlines permit another attempt;
- the account lane is available;
- any required external-effect receipts exist.
`DEAD` and `SUCCEEDED` are terminal under normal operation. Keep operator overrides explicit and audited.
### Core invariants
- Every successful acknowledgement corresponds to a committed inbox identity and payload.
- One identity cannot represent two accepted payloads.
- At most one current processing lease exists per account.
- A stale worker cannot commit business changes, mark completion, renew a lease, or release another worker’s lease.
- Dependency failure never silently becomes dependency satisfaction.
- Local business mutations, effect intents, and inbox completion commit together or all roll back.
- Acknowledgement means **durable acceptance**, not successful processing or external delivery.
A paused worker can continue executing after its lease expires. Thus “one current lease” does not mean “one executing process”; fencing is essential.
## Transaction boundaries
### 1. Authenticate and accept
Before the transaction, authenticate, authorize the account, enforce request-size limits, and validate the envelope and dependency format.
In one short transaction:
1. Check for an existing deduplication key.
2. If present, compare the immutable content, including dependencies and schema version:
- matching content: return its existing acceptance identity after the transaction completes;
- different content: return a conflict; do not modify the original event.
3. For a new event, reserve capacity transactionally.
4. Create the account lane if needed; persist the complete inbox event and dependency edges.
5. Commit with the required durability policy.
Return `202 Accepted` only after commit confirmation. A matching duplicate also receives a successful acceptance response, including when the original has subsequently become `DEAD`.
Concurrent insert races are resolved by the unique constraint; the losing transaction rereads and compares the winner. Rolled-back reservations must not consume quota.
If the connection fails during commit, the outcome is unknown. Do not manufacture a success response. A retry with the same identity resolves whether the commit occurred.
Use a specified canonical representation for semantic payload comparison, or require byte-identical retries. Do not accidentally treat harmless JSON formatting differences as conflicts without documenting that choice.
### 2. Claim work
In a short transaction:
1. Select candidate account lanes with `FOR UPDATE SKIP LOCKED`.
2. After locking, recheck lane availability and event eligibility.
3. Select one eligible event for that account using a stable fairness policy.
4. Increment the account generation and event attempt count.
5. Set the event to `RUNNING`, storing the generation as its token.
6. Set lane owner, event, and expiry using database time.
7. Commit and return payload plus token.
All eligibility decisions are rechecked under the account lock. Same-account dependency completion also takes this lock.
Choose runnable events rather than blindly processing arrival order: a child arriving first must not prevent its later-arriving parent from running. Unrelated eligible events may proceed while another event waits for retry or dependencies.
Multiple independent roots have no causal ordering guarantee. If total order is required, use the sequence-based alternative.
### 3. Execute and renew
Perform expensive computation outside transactions. Bound execution time and heartbeat regularly.
A heartbeat locks the lane and succeeds only when:
- account, event, owner, and token match;
- the event remains `RUNNING`;
- the lease has not already expired.
An expired heartbeat cannot resurrect ownership.
Use database time consistently. Clock jumps can affect availability and reclaim timing; token checks and row locking provide database safety independently of worker clocks.
### 4. Commit processing
In one short transaction:
1. Lock the account lane.
2. Check current event, token, owner, running state, and unexpired lease.
3. Validate any business preconditions again.
4. Apply local business mutations.
5. Insert immutable outbox effects using stable, unique effect IDs.
6. Mark the inbox event `SUCCEEDED`.
7. Release the lane.
8. Commit.
Any failed ownership check rolls back the entire transaction.
Lease expiry makes a lane reclaimable; it does not interrupt an already-authorized transaction holding the lane lock. A replacement cannot receive a newer token until that transaction releases the lock. Keep these transactions short and enforce database timeouts.
Workers must not have an alternative write path that bypasses the fencing check. Encapsulate finalization in a restricted database interface or consistently enforced transaction boundary.
### 5. Failure and recovery
A worker reporting failure must perform the same ownership check before changing state.
- Retryable failure: move to `RETRY_WAIT`, schedule bounded exponential backoff with jitter, release the lane.
- Permanent failure or exhausted budget: move to `DEAD`, record the reason, release the lane.
A recovery process locks expired lanes and rechecks their current state. It invalidates ownership by advancing the generation, transitions the abandoned event to retry or dead, and releases the lane.
**Claims consume attempts**, including claims abandoned by crashes. Otherwise repeated crashes could bypass retry limits.
Use consistent lock ordering across ingestion, quota updates, workers, recovery, and administrative operations. Deadlocks or serialization failures are retryable transaction failures, never acceptance successes.
## Dependencies, poison events, and external effects
### Dependency handling
- An absent predecessor blocks the child without occupying a worker lease.
- Reject self-dependencies and detect cycles where practical.
- Use a finite dependency-wait deadline to contain unresolved cycles or permanently missing events.
- A dead predecessor blocks descendants; eventually mark them dead with a dependency-failure reason.
- Do not automatically skip a poison event to advance dependent work.
- Operators may repair and explicitly requeue an event with a fresh bounded retry budget, or explicitly waive a dependency. Record the actor, justification, and changed semantics.
Bound attempts, processing age, dependency-wait age, payload size, and dependency count. A retry cap alone does not bound events that never become runnable.
### External effects
Inbox `SUCCEEDED` means local changes and external-effect intents are durably committed. It does not mean the remote effect happened.
An outbox dispatcher uses its own leases, fencing, retry budgets, and durable receipts:
1. Claim an effect.
2. Call the receiver outside a database transaction.
3. Persist the result only if the dispatcher still owns the current token.
Use the **same stable idempotency key for every retry of a logical effect**. Do not use the lease token as the idempotency key.
A crash after the receiver performs an effect but before PostgreSQL records its receipt creates an unavoidable ambiguity:
- with durable receiver-side idempotency or a reliable lookup API, reconcile or retry the same effect;
- without it, duplicate effects are possible. Use an explicit unknown-outcome state and reconciliation policy, or accept documented at-least-once duplicates.
Database fencing cannot stop a stale process from sending an HTTP request. Receiver-enforced fencing helps reject superseded owners, but does not replace logical-effect deduplication.
Where a child requires a parent’s **external completion**, require the parent’s receipt before claiming the child, or encode the dependency between their outbox effects. Local inbox completion alone is insufficient. Strict external ordering requires receiver semantics that also handle delayed requests and repeated effects.
## Backpressure and retention
Set measurable, configurable bounds for:
- outstanding events and bytes globally and per account;
- outbox backlog;
- database storage headroom;
- concurrent workers and database connections;
- execution duration, attempts, and dependency waits.
Perform capacity reservation in the acceptance transaction. Return:
- `429` with `Retry-After` for quota/rate limits;
- `503` for unavailable database or global resource pressure;
- appropriate `4xx` for authentication, authorization, invalid input, or identity conflicts.
An authenticated matching duplicate should not require another capacity reservation.
Reject new work before storage exhaustion. Pausing workers alone is not admission control. Ensure failed or unresolved external delivery eventually creates admission pressure rather than an unbounded outbox.
Retain deduplication identities for at least the agreed redelivery horizon. If redelivery can occur forever, durable tombstones must also be retained forever, or the deduplication guarantee must explicitly expire. Payload archival must preserve identity, comparison information, terminal outcome, and dependency evidence needed by retained events.
Monitor queue age, blocked-dependency age, retry/dead counts, lease expirations, fencing failures, outbox age, quota use, and database headroom.
## Acceptance checks
These are proposed pass/fail checks, not executed results. Fix lease duration `L`, recovery polling interval `R`, retry limit `N`, deadlines, quotas, and acknowledgement latency targets before testing.
| Scenario | Pass condition |
|---|---|
| Concurrent identical deliveries | Exactly one inbox identity and one capacity reservation; all successful responses identify that acceptance |
| Same identity, different payload | Conflict returned; original content and processing outcome remain unchanged |
| Cross-account/source identity reuse | Correctly separate identities; unauthorized account access rejected |
| Crash before acceptance commit | No success response; no partial inbox, dependency, or quota records |
| Commit succeeds, response is lost | Retry finds the existing event and does not create another |
| Database crash/failover after acknowledgement | Every acknowledged event survives within the declared durability model |
| Reordered parent and child | Child cannot commit before required parent completion; late parent remains runnable |
| Missing parent, cycle, poison predecessor | No dependent business effect; bounded transition to a diagnosable terminal condition |
| Multiple workers on one account | No two current leases; every committed mutation used the current token |
| Worker pauses beyond `L` and resumes | After reclaim, stale finalization, heartbeat, and release all fail |
| Worker dies while holding a lease | Under stated available-capacity assumptions, recovery occurs within `L + R` plus the declared scheduling allowance |
| Repeated crashes or transient errors | No more than `N` claims per configured processing budget; deadlines also enforced |
| Crash during finalization | Business state, outbox intents, and inbox success are either all present or all absent |
| Remote success followed by dispatcher crash | Retry uses the same effect key; duplicates are prevented only where receiver guarantees support that result |
| External prerequisite | Child remains ineligible until the specified remote-completion evidence exists |
| Capacity race at limit | Concurrent requests cannot oversubscribe configured reservations; rejected requests have no partial acceptance |
| Hot or poisoned account | Other accounts continue within the configured fairness and resource limits |
| Retention boundary | Duplicates remain suppressed throughout the promised horizon; later behavior matches the documented policy |
## Alternatives, confidence, and next action
- **Authoritative sequence numbers** simplify strict per-account order but require gap handling, stream-start rules, and coordination across sources.
- **A single account worker without fencing** is insufficient: reassignment after a pause permits stale writes.
- **Holding a transaction open during remote calls** creates long locks and still cannot atomically commit an ordinary HTTP effect with PostgreSQL.
- **Exactly-once external effects from PostgreSQL alone** is not a defensible guarantee.
Confidence is high in the transactional and fencing design, conditional on all mutation paths enforcing it. Deployment durability, workload capacity, dependency semantics, and receiver capabilities remain unspecified.
**Next action:** establish the dependency contract and external-completion semantics, then implement the schema and fenced transactions and run the fault-injection acceptance checks above.openai / gpt-6-luna / low / low effort answer
## Durable inbox design
### Requirements and assumptions
- One PostgreSQL database is the authority for inbox state; workers may run concurrently.
- Authenticate the source before accepting a delivery. Enforce an appropriate request-size limit and validate required identifiers and payload structure.
- Deduplicate on `(source_id, account_id, event_id)`. Assume this key identifies one logical event; if the same key arrives with a different payload, treat that as a conflict, not a replacement.
- Acknowledge only after the event and its durable scheduling state commit. A successful acknowledgement means “durably accepted,” not “processed” or “external effects completed.”
- Preserve dependencies within an account: process only the earliest nonterminal event for that account. This deliberately allows a poison event to block later events for that account until an operator resolves or explicitly skips it.
- Use bounded retries and lease fencing for database state changes. External effects are not exactly-once unless the downstream system independently supports idempotency or fencing.
### State and invariants
An inbox row contains the dedupe key, payload, payload hash, acceptance time, account sequence, state, attempt count, next-attempt time, lease owner, lease expiry, monotonically increasing lease generation, and terminal/error metadata. Suggested states:
`ready → leased → done`
`leased → ready` on retryable failure or expired lease, subject to retry limits.
`ready/leased → dead` on permanent failure or exhausted retries. `dead → ready` only through an explicit audited operator retry; an explicit skip/resolve action may unblock the account.
Unique constraint on the dedupe key prevents duplicate logical rows. Assign a per-account sequence in the acceptance transaction, serialized using an account cursor row (or equivalent locking mechanism); do not rely on timestamps to order dependencies. Only the lowest-sequence nonterminal row for an account is eligible. Keep terminal rows, or equivalent dedupe tombstones, for the full required dedupe-retention period.
A lease has an expiry and generation. Every claim increments the generation. A worker must include its claimed generation in all inbox updates; updates succeed only if the row remains leased to that worker/generation. Expiry permits reclamation, but does not prove the prior worker stopped. Fencing protects database state, not arbitrary external side effects.
### Transaction boundaries
1. **Accept:** Authenticate and validate before database work. In one transaction, reserve/lock the account cursor, insert the inbox row and assign its sequence, and commit. If the unique key already exists, compare payload hash: identical content is an idempotent duplicate; differing content is a conflict to record/alert and reject or quarantine according to policy. Return success only after commit. Acknowledgement loss after commit is safe: redelivery hits the unique key.
2. **Claim:** In a short transaction, select eligible account heads with row locks (`FOR UPDATE SKIP LOCKED` or equivalent), mark them leased, increment generation and attempts, set expiry, then commit. Do not hold database locks while processing.
3. **Process:** Perform work outside the claim transaction. For effects in the same database, write effects and mark the inbox row done in one transaction, checking lease generation. For external effects, use a stable idempotency key derived from the dedupe key where supported; otherwise acknowledge that crash/retry can repeat effects. A transactional outbox can durably record intended external work, but cannot alone guarantee the remote effect happened exactly once.
4. **Complete/retry:** In a short transaction, conditionally update using row ID, leased state, owner/generation. Mark done, or set ready with backoff and `next_attempt_at`; if the retry budget is exhausted or error is permanent, mark dead. Stale workers’ conditional updates affect zero rows and must not overwrite newer state.
### Backpressure and failures
Bound request size, database connections, queue growth, and worker concurrency. Monitor oldest ready age, queue depth, lease expirations, retry counts, dead rows, and per-account blockage. Apply admission limits or return a retryable overload response before acceptance when capacity is exhausted; never return success for an uncommitted event. If commit outcome is uncertain, return a retryable failure: a later duplicate is safe. Database unavailability, authentication failure, malformed input, key/payload conflict, and capacity rejection must not be reported as successful acceptance. Use exponential backoff with jitter and a maximum attempt count; classify permanent errors explicitly. Alert and provide audited replay/skip procedures for poison events.
### Acceptance checks
Pass only if tests or operational checks demonstrate:
- Concurrent duplicate deliveries create one logical row; same-key/different-payload deliveries are surfaced as conflicts.
- No success acknowledgement is emitted before durable commit; redelivery after an acknowledgement loss does not create a second row.
- Reordered deliveries are processed in assigned per-account order; different accounts can progress independently.
- Concurrent workers cannot claim the same current lease; after expiry, a new generation can reclaim it, and stale-generation updates cannot change inbox state.
- Crash before commit yields no accepted event; crash after commit but before acknowledgement is recoverable by redelivery; crash after claim is recoverable after lease expiry.
- Retryable failures back off and stop at the configured bound; permanent/exhausted failures become dead and visibly block later events for that account until explicit resolution.
- External-effect tests explicitly demonstrate the documented duplicate-effect behavior or verify downstream idempotency; they do not assert generic exactly-once behavior.
- Overload and database failure produce no false success, and queue/age/lease/dead-letter metrics and alerts have configured thresholds.
Thresholds, retention durations, retry limits, and downstream idempotency capabilities are deployment-specific and must be set and tested; none can be inferred from the supplied task. The main alternative is partitioning/streaming infrastructure, but it is unnecessary for the stated single-database scope and does not remove the need for durable acknowledgement, dedupe, fencing, and explicit external-effect semantics.
**Next useful action:** choose concrete retention, retry, lease, capacity, and poison-event policies, then validate the listed checks against the application’s actual downstream effects.
Primary judge's stated reason
B is preferred clearly because it addresses a central correctness requirement that A's arrival-assigned sequence does not establish. This is a substantive design gap, not a preference for additional detail: reordered dependent events require dependency evidence or an explicit limitation. B supplies both a conditional mechanism and failure handling. Deployment correctness remains unverified, and this judgment does not claim executed tests or successful implementation.
This reason is the judge's assessment. No independent factual-defect finding is asserted by this record.
Battle wave: 5b3a3868-ff64-4c03-9e3c-d769b74c6749. Pair: brp1_338a1c6bc9304818b3264e49232820f9f1abaceb1163bfdcbd6aac69c8b7a565. A separate independent review is required before calling a concern a verified factual defect. Judge disagreement is not recorded here.