Skip to content

fix(lifecycle): enrichment reconciliation backs off and gives up - #1107

Open
blove wants to merge 1 commit into
mainfrom
blove/enrich-retry-cap
Open

blove wants to merge 1 commit into
mainfrom
blove/enrich-retry-cap

Conversation

@blove

@blove blove commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Root cause

The enrich handler's defer helper in apps/lifecycle/src/enrichment/dawn-jobs.ts deferred with a fixed 15 second delay, and its only terminal condition was the research_attempt.expiresAt deadline in the job payload. That key only exists once a Dawn research attempt has been submitted. Production evidence: every runaway job had payload ? 'research_attempt' = false, so expiresAt was undefined, the guard never fired, and the job re-deferred every 15 seconds indefinitely on dawn_reconciliation_required. Four jobs reached 2,267-2,414 attempts over six days and were only stopped by an operator suppressing the contacts.

Changes

Two changes, to the enrich handler's defer helper only (the research_cleanup handler's separate defer is untouched):

  1. Payload-independent attempt cap. MAX_RECONCILIATION_ATTEMPTS = 20; once job.attempts reaches it the job fails with dawn_reconciliation_exhausted for manual review instead of deferring.
  2. Exponential backoff with a ceiling. The fixed 15s becomes min(15 min, 15s * 2 ** min(attempts, 10)).

The existing expiresAt deadline check stays first and unchanged, so nothing regresses for jobs that do carry an attempt.

Test plan

New tests in dawn-jobs.spec.ts, reusing the file's existing fixture() harness:

  • A job with no research_attempt defers, and the availableAt delay grows with attempts and never exceeds the 15 minute ceiling.
  • A job with no research_attempt at the cap fails with dawn_reconciliation_exhausted and does not defer. Confirmed failing before the fix (returned deferred).
  • The existing dawn_recovery_deadline test still passes.

nx test lifecycle --skip-nx-cache, nx lint lifecycle, nx build lifecycle all green.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Sep 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
threadplane Ready Ready Preview Sep 18, 2026 6:42pm UTC

Request Review

@blove
blove enabled auto-merge (squash) September 18, 2026 18:27

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated approval: this PR received an intelligent (AI) code review. See the review comments on this PR.

@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Claude finished @blove's task in 0s —— View job


I'll analyze this and get back to you.

A job that fails before a Dawn research attempt is submitted carries no
research_attempt deadline, so the only terminal condition never applied and the
job deferred every fifteen seconds forever. Four production jobs reached ~2,400
attempts. Reconciliation now backs off exponentially to a fifteen minute
ceiling and fails for manual review after a bounded number of attempts.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@blove
blove force-pushed the blove/enrich-retry-cap branch from 923e9c6 to 3b79389 Compare September 18, 2026 18:33
@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Claude finished @blove's task in 0s —— View job


I'll analyze this and get back to you.

This branch was successfully deployed

1 active deployment
Preview – threadplane 3b793897 Deployed Sep 18, 2026 by vercel[bot]
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