fix(triggers): durable completion-hook delivery — retry, dead-letter, redeliver (closes #97)#123
Open
umi-appcoder[bot] wants to merge 1 commit into
Open
fix(triggers): durable completion-hook delivery — retry, dead-letter, redeliver (closes #97)#123umi-appcoder[bot] wants to merge 1 commit into
umi-appcoder[bot] wants to merge 1 commit into
Conversation
… redeliver (#97) _fire_completion_hook was fire-and-forget: a single network blip dropped the callback, which is silent data loss for triggers whose whole point is the response_url POST. Backend (server.py): - _deliver_hook: bounded exponential-backoff retry (KC_HOOK_MAX_ATTEMPTS, default 4); a permanent 4xx (except 429) is not retried. Records delivery state on the task meta: hook_delivery={state:'delivered', attempts, status, delivered_at} on success, or {state:'failed', attempts, last_error, last_attempt_at} (the dead-letter) on exhaustion. - _build_hook_request: extracted so fire + redeliver share payload/HMAC. - redeliver_hook + POST /api/claude/tasks/{id}/redeliver-hook (auth + readonly gated) to re-attempt a failed delivery. - At-most-once on *success* is preserved (hook_fired_at marks the initial fire under lock); retries run in the daemon thread, off the request path. SPA: TaskDetail Info tab surfaces hook_delivery state (delivered / failed + attempts + error), with the redeliver endpoint noted; TaskDetail type gains HookDelivery. Tests: tests/completion_hook_delivery_test.py (7) — success records delivered, retry→dead-letter, permanent-4xx no-retry, 429 retried, redeliver missing/no-url/runs-delivery. Python suite 473, SPA 120, OK. Closes #97 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes completion-hook delivery durable — bounded retries, a dead-letter record on exhaustion, and a redeliver endpoint. Closes #97 — PR 5 (finale) of the reliability-hardening series. Builds on the merged #96 reconcile loop.
Why
_fire_completion_hookwas fire-and-forget — a single network blip dropped the callback, which is silent data loss for webhook/cron triggers whose whole purpose is theresponse_urlPOST.Backend (
server.py)_deliver_hook— bounded exponential-backoff retry (KC_HOOK_MAX_ATTEMPTS, default 4); a permanent 4xx (except 429) isn't retried. Records delivery state on the task meta:hook_delivery = {state:'delivered', attempts, status, delivered_at}hook_delivery = {state:'failed', attempts, last_error, last_attempt_at}— the dead-letter._build_hook_request— extracted so fire + redeliver share payload/HMAC.redeliver_hook+POST /api/claude/tasks/{id}/redeliver-hook(auth + readonly gated) to re-attempt a failed delivery.hook_fired_atmarks the initial fire under lock); retries run in the daemon thread, off the request path.SPA
TaskDetail Info tab surfaces
hook_deliverystate (delivered / failed + attempts + error, with the redeliver endpoint noted);TaskDetailtype gainsHookDelivery.Tests
tests/completion_hook_delivery_test.py(7): success→delivered, retry→dead-letter, permanent-4xx no-retry, 429 retried, redeliver missing/no-url/runs-delivery. Python suite 473, SPA 120, OK.Closes #97
🤖 Generated with Claude Code