Repository navigation
fix(discovery): retry ledger rows stranded by an AI gateway 7005 - #774
harlan-github-agent[bot] wants to merge 1 commit into
Conversation
|
🟢 Ready · Checked: reconcileLedger branch ordering and the new 7005 retry branch against the staged jobs/failed_jobs fixtures, plus the sync-x-mentions submit/reconcile wiring and enqueue dedupe. Not checked: the live Cloudflare queue consumer's failed_jobs write path and the real outage cycle in production. 1 follow-up · none block mergeIn this change.
|
There was a problem hiding this comment.
🟢 Ready · 1 follow-up · read the review
Harlan Agent Kit automated review, not Harlan's · AI policy
| // other unmatched dead-letter. | ||
| const retriedPurpose = await input.db | ||
| .prepare( | ||
| `UPDATE discovery_ledger SET status = 'pending', submitted_at = NULL |
There was a problem hiding this comment.
⚪ Stale 7005 dead-letters loop later failures and mask stalls · 65/100 · does not block merge
The retriedPurpose UPDATE matches any historical failed_jobs row whose exception contains 'AiGatewayError: 7005:', with no recency bound and no exclusion for an active submission job, and nothing ever deletes failed_jobs rows. When a repo with 7005 history later dead-letters with any unmatched exception (for example 'Repository purpose classification failed: invalid_answer'), every 15-minute reconcile still matches the stale row, returns the row to pending, and re-enqueues a job that fails again forever while reconcileStalled reports 0. During an ongoing outage the branch also fires seconds after each fresh submission while the job's five attempts (about 15 minutes total at 60/120/240/480-second delays) are still running, so the retry cadence is ~15 minutes per dead-letter, not the ~90 minutes the PR documents.
Fix: Bound the match to the operative failure, for example the repo's newest failed_jobs row or a recency window, so older 7005 history cannot retry newer unrelated failures.
- Ask an agent to verify and fix this finding
Harlan Agent Kit automated review, not Harlan's · AI policy
🔗 Linked issue
Closes #772
❓ Type of change
📚 Description
A purpose classification runs inline inside
registry/repository-submission, so when the Cloudflare AI gateway is down the submission job exhausts its 5 attempts and dead-letters with the gateway's exception.reconcileLedgermatched onlyno_supported_skill_paths,root_skill_unsupportedandrepository_purpose_review_required, soghost-brief/skillssatsubmittedforever and alarmed as stalled nightly after the 2026-12-02T21:31Z run:7005 is the billing service being down, not a verdict about the repository, so the park branch from #605 does not fit: no reviewer action exists, and releasing a hold would re-run into the same outage. The row is judged transient infrastructure and returns to
pendingwithsubmitted_atcleared, so the submit loop classifies it again once the gateway recovers. The reconcile summary names this disposition asretriedPurposeand thesync-x-mentionsrun log carries it.A deterministic 7003 input error deliberately does not match. Returning it to pending would re-enqueue the same rejection every reconcile run; the scheduler owns that burn (#770, being fixed in #773), so the row stays stalled like any other unmatched dead-letter.
Open points:
AiGatewayError: 7005:, not every purpose-classification failure.Repository purpose classification failed: invalid_answer(an unparseable model answer) still stalls its row; retrying it is not obviously safe since the same evidence can produce the same unparseable answer, and it needs its own decision.