Skip to content

[codex] Structure relay delivery attempt errors#3312

Merged
juliusmarminge merged 1 commit into
mainfrom
codex/relay-delivery-attempt-errors
Jun 20, 2026
Merged

[codex] Structure relay delivery attempt errors#3312
juliusmarminge merged 1 commit into
mainfrom
codex/relay-delivery-attempt-errors

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • attach the persistence operation and available delivery/job correlation fields to relay delivery-attempt failures
  • preserve the original database or crypto cause for complete error chains
  • derive the generic persistence message from the structured operation and construct errors directly at each boundary
  • add focused coverage for record, claim, and completion failure mappings

Validation

  • vp check (passes with 20 pre-existing warnings)
  • vp run typecheck
  • /Users/julius/.codex/worktrees/d5fa/codething-mvp/node_modules/.bin/vp test infra/relay/src/agentActivity/DeliveryAttempts.test.ts --no-cache (7 tests)

Overlap audit

  • no overlap with another active error-audit/service-refactor PR
  • the same paths also appear in broad draft feat(relay): enforce resource limits #2925 (feat(relay): enforce resource limits); that unrelated overlap is reported here for visibility

Note

Low Risk
Observability-only error shaping on audit persistence; no change to claim/record/completion behavior or public method signatures beyond richer error payloads.

Overview
DeliveryAttemptRecordPersistenceError now carries which operation failed (record, claim-source-job, complete-source-job) plus correlation fields (sourceJobId, user/env/thread/device, kind) while still wrapping the underlying DB/crypto cause. Messages are derived from the operation (e.g. during claim-source-job).

Persistence mapping is applied per boundary in DeliveryAttempts instead of a single generic mapError, so success paths and tracing are unchanged but failures are easier to log and debug. A new test asserts all three operations preserve context and the original cause.

Reviewed by Cursor Bugbot for commit a83db42. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Structure DeliveryAttemptRecordPersistenceError with operation context and input identifiers

  • Adds operation (one of record, claim-source-job, complete-source-job), contextual IDs (sourceJobId, userId, environmentId, threadId, deviceId, kind), and cause fields to DeliveryAttemptRecordPersistenceError in DeliveryAttempts.ts.
  • Each handler now uses Effect.mapError scoped only to the persistence block, so span annotation failures before the db call are no longer wrapped in DeliveryAttemptRecordPersistenceError.
  • The error message now reads 'Failed to persist APNs delivery attempt during ${operation}.' for easier triage.
  • Adds a test in DeliveryAttempts.test.ts covering all three operations with a fake RelayDb that forces insert/update failures.

Macroscope summarized a83db42.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e044fc51-d9b8-4a1e-ad52-8888f3c2eb5b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/relay-delivery-attempt-errors

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This change enriches error objects with additional context fields (operation, IDs, kind) for debugging purposes. The error handling flow remains unchanged - errors are thrown in the same situations with the same effects, just with more diagnostic information attached.

You can customize Macroscope's approvability policy. Learn more.

@juliusmarminge
juliusmarminge merged commit e85144a into main Jun 20, 2026
16 checks passed
@juliusmarminge
juliusmarminge deleted the codex/relay-delivery-attempt-errors branch June 20, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant