Skip to content

fix(reporting): report unsettled notification retries and abandonment as typed errors - #3774

Merged
bokelley merged 3 commits into
mainfrom
fix/reporting-unsettled-retry-error
Nov 24, 2026
Merged

bokelley merged 3 commits into
mainfrom
fix/reporting-unsettled-retry-error

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Problem

The production training agent posts a "System error" to Slack about every 6 minutes:

Durable reporting scheduler failed
diagnostic: Reporting notification delivery is not settled for 1 recipient(s); retrying

This is an expected retry. One reporting.* webhook subscriber is not accepting deliveries. A claim whose emission returns with a recipient still outstanding (a 5xx, a 429, a transport error, a timeout or an emitter failure) is released and retried. recoverOnce({ onError }) received a plain Error, so hosts could not tell this retry from a storage failure, and they logged every retry at error level. (The 6-minute cadence comes from the host's 5-minute Slack throttle. The retry itself runs about every 30-45 s: retryAfterMs defaults to 30 s and the scheduler interval is 15 s.)

The production service also calls its scheduler onError(error) without the claim, so the host had no way to find which subscriber was failing.

Change

  • ReportingNotificationUnsettledError (exported from @adcp/reporting-storage/notifications) replaces the plain Error.
    • It carries transitionId, unsettled, attempt, maxAttempts and up to ten recipients.
    • Each recipient has its scope, subscriberId, destinationGeneration, a reason (delivery_failed / delivery_runtime_error / retryable_suppression) and finalStatus when the last attempt got an HTTP response. The URL and any credential are never included.
    • The message is unchanged, except on the final attempt, where it ends attempt N of M, not retrying.
    • A retryable suppression on the first outstanding recipient still raises ReportingNotificationRetryableSuppressionError.
  • ReportingNotificationAbandonedError is reported to the same onError after a claim reaches maxAttempts and the abandonment succeeds. Its cause is the final attempt's error.
  • The canonical wiring in docs/guides/REPORTING-LEDGER.md now logs the unsettled error at warn. That section now documents both errors.
  • Retry, lease and abandonment behaviour is unchanged. The new errors are additive, but hosts that alert on onError get one extra call per abandoned claim. Patch changeset for @adcp/reporting-storage, which is @experimental and pre-1.0.

Are retries bounded?

Yes, per activity:

  • The activity claim is abandoned after maxAttempts (default 100).
  • Independently, the webhook binding goes terminal after its 24 h retry horizon (deliveryRetryHorizonSeconds), which settles the recipient as terminal.

They are not bounded across activities. A subscriber that stays dead is addressed again by every new activity on that account, and each activity runs its own bounded cycle. A subscription-level circuit breaker (deactivate after N consecutive failures) would touch protocol-visible subscription state, so this PR does not add one. It is proposed as a follow-up.

Tests

packages/reporting-storage/test/reporting-notification-activity-pg.test.js (57/57 locally against PostgreSQL 16):

  • A subscriber answering 503 produces a typed unsettled error with the right identifiers, finalStatus: 503, and no URL.
  • A persistent 503 with maxAttempts: 3 reports attempts 1 and 2 as retrying. Attempt 3 says attempt 3 of 3, not retrying and is followed by exactly one abandoned error whose cause is that same object. A further pass is silent.
  • A transport error gives delivery_failed with no finalStatus.
  • The existing over-fanout abandonment test now asserts that it reports an abandoned error, and that its cause is not an unsettled error.

Not covered by a test: delivery_runtime_error, which needs the emitter itself to throw and cannot be reached without stubbing runtime internals. A cap test with more than 10 recipients was skipped because the setup is heavy.

The host-side change (warn instead of error, with subscriber identifiers) is in adcontextprotocol/adcp, on branch fix/training-reporting-retry-noise.

🤖 Generated with Claude Code

bokelley and others added 2 commits November 23, 2026 10:26
… as typed errors

A claim whose recipient is still outstanding threw a plain Error that
hosts could not tell apart from a storage failure, so every expected
retry was logged at error level. Raise ReportingNotificationUnsettledError
with transitionId, unsettled, attempt, maxAttempts and the outstanding
recipients (identifiers, reason, final HTTP status; never URLs or
credentials), and report ReportingNotificationAbandonedError when a claim
reaches maxAttempts and is abandoned.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
aao-secretariat[bot]
aao-secretariat Bot previously approved these changes Nov 23, 2026

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Approve

Approve — additive error-typing on the experimental @adcp/reporting-storage notification recovery path with no blocking findings.

What I checked:

  • New ReportingNotificationUnsettledError / ReportingNotificationAbandonedError are carried on onError only; retry/lease/abandon semantics and durable state are unchanged (notification-activity.ts:1203-1222 throw path, classifyDelivery:2063-2070).
  • Witness hygiene is correct: recipient payloads carry scope/subscriberId/destinationGeneration + reason + optional final_status (a real emitter field, webhook-emitter.ts:492), never the URL or credentials. Three new pg tests assert non-leakage.
  • Changeset present (.changeset/reporting-notification-unsettled-error.md); patch type is consistent with this package's experimental semver posture and the additive, non-breaking change.
  • No wire-shape fabrication, no re-shaping at a seam, no minor-release pathway obligation (error typing, not a wire-field change).

Non-blocking observation (advisory only): the delivery_runtime_error reason at the delivery.failure !== undefined || !delivery.result branch is documented as "emitter threw," which strictly holds only for the !delivery.result sub-case; a non-terminal structured failure block would also be labeled that way. No correctness impact.

No critical/high/medium findings. gated_paths is false; review_decision is REVIEW_REQUIRED but the gate only applies when gated_paths is true. No team gate, no high-risk flag. Falls through to row 9.

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ladon verdict: Approve

Approve — test-only delta since prior clean approve, no blocking or medium findings.

What I checked:

  • Delta since the prior approve is confined to one test file (packages/reporting-storage/test/reporting-notification-activity-pg.test.js): a comment clarified to "fetch override by URL" and the fetchHook(url, body) call dropped its unused body arg to match the single-arg requestUrl => ... hooks for the new unsettled/abandonment tests. Test-only, no production or wire surface touched.
  • No no-auto-approve team match; gated_paths: false; high_risk: false.
  • review_decision is REVIEW_REQUIRED, but no gate (path-based or prose) applies, so this does not force escalate.
  • No critical/high/medium findings in this run; prior pass was clean.

Decision table: rows 1–8 do not fire (no findings, no gates, no team match) → row 9 approve.

@bokelley
bokelley merged commit 5548655 into main Nov 24, 2026
45 checks passed
@bokelley
bokelley deleted the fix/reporting-unsettled-retry-error branch November 24, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant