Skip to content

Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA

TypeScript
34.4 KB
Raw Blame
{
 "schema": "gstack-detector-corpus/v1",
 "case": "plan-eng-multi-finding-batching",
 "detector": "test/helpers/eng-seeded-coverage.ts#createEngBatchingIssueCounter",
 "series_identity": "a3e4c3429b2cfef8",
 "source": {
  "run": "37193478719",
  "sha": "9f357d9b9c75441b6a18e4f75174274954ba6f96",
  "lane": "periodic",
  "artifact": "paid-slice-1-a1",
  "path": "shards/skill-e2e-plan-eng-multi-finding-batching/pty-count/ci-37193478719-1-eval-slices-1/plan-eng-review-1791107629170-XPmpHH"
 },
 "census_outcome": "passed",
 "expected": "pass",
 "justification": "Census pass: three review-phase questions each bound to their own saved decision-ledger record (R IDs) in the plan; the counter credits each once.",
 "input": {
  "calls": [
   {
    "sessionId": "29344c71-f9f0-40f3-b654-20ee9525ca09",
    "toolUseId": "toolu_01CqY8j4zmo98BsVwYoFoZCF",
    "answeredAt": "2026-10-04T09:56:42.587Z",
    "answer": "Library hooks + custom curve (recommended)",
    "question": {
     "question": "D1 — Build the retry scheduler inline, or use the job library's retry hooks with a custom backoff curve?\nProject/branch/task: main — reviewing PLAN.md \"Add background job retry framework\"; the plan proposes a hand-rolled exponential-backoff scheduler inside each of 5 workers.\nELI10: The job library already knows how to retry a failed job: it stores the attempt count, waits, and re-runs it, and almost every mainstream library lets you plug in your own delay formula. The plan rebuilds that machinery inside each worker so \"we control the curve.\" That control is already available through the library's backoff callback, and the rebuilt version has to re-solve persistence, visibility and crash safety on its own.\nStakes if we pick wrong: an in-process retry timer dies with the worker, so a crash or deploy mid-backoff silently drops the job; retry counts and dead-letter state vanish from the library's dashboards and tooling.\nRecommendation: A because the library's hook gives the same curve control with persistence and tooling for free [Layer 1]; rebuilding it is accidental complexity in 5 places.\nCompleteness: A=9/10, B=4/10, C=n/a (bounded investigation, decides nothing)\nPros / cons:\nA) Library retry hooks + custom backoff callback (recommended)\n  ✅ Retry state (attempt count, next-run time, dead-letter) persists in the queue store and survives worker crashes and deploys\n  ✅ Existing library tooling (dashboards, admin retry, metrics) keeps working; one backoff function instead of five schedulers (human: ~1 day / CC: ~20 min)\n  ❌ Curve is bounded by the hook's inputs (often attempt number only), so error-specific delays like Retry-After need a small wrapper\nB) Custom inline scheduler in each worker (plan as written)\n  ✅ Unlimited control over delay math and per-error behavior without touching library config\n  ✅ No dependency on the library's backoff API shape or version\n  ❌ Retries live in worker memory unless you also build persistence; a crash during backoff loses the job silently and bypasses the library's retry visibility (human: ~1 week / CC: ~1 hr, plus 5 copies to maintain)\nC) Investigate first: bounded probe of the library's backoff hook\n  ✅ Confirms whether the installed library's hook supports the exact curve before committing either way\n  ✅ Cheap: read the library docs and one worker's current retry config (human: ~1 hr / CC: ~5 min)\n  ❌ Decides nothing; R1 stays pending and Sections 1–4 proceed against the plan as written\nNet: trading a bounded callback signature for crash-safe, observable retries you don't have to write five times.",
     "header": "Retry mechanism",
     "multiSelect": false,
     "options": [
      {
       "label": "Library hooks + custom curve (recommended)",
       "description": "Use the job library's built-in retry hooks and supply one custom backoff callback for the curve. ✅ Retry state (attempt count, next-run time, dead-letter) persists in the queue store and survives worker crashes and deploys. ✅ Existing library tooling (dashboards, admin retry, metrics) keeps working; one backoff function instead of five schedulers (human: ~1 day / CC: ~20 min). ❌ Curve is bounded by the hook's inputs (often attempt number only), so error-specific delays like Retry-After need a small wrapper. Completeness 9/10. R2–R5 stay pending."
      },
      {
       "label": "Custom inline scheduler",
       "description": "Keep the plan as written: a hand-rolled exponential-backoff scheduler inside each of the 5 workers. ✅ Unlimited control over delay math and per-error behavior without touching library config. ✅ No dependency on the library's backoff API shape or version. ❌ Retries live in worker memory unless you also build persistence; a crash during backoff loses the job silently and bypasses the library's retry visibility (human: ~1 week / CC: ~1 hr, plus 5 copies to maintain). Completeness 4/10. R2–R5 stay pending."
      },
      {
       "label": "Investigate library hook first",
       "description": "Bounded probe only: read the installed library's backoff hook docs and one worker's current retry config, then return to this question. ✅ Confirms whether the hook supports the exact curve before committing either way. ✅ Cheap (human: ~1 hr / CC: ~5 min). ❌ Decides nothing; R1 stays pending and Sections 1–4 proceed against the plan as written. No completeness score (investigation, not coverage). R2–R5 stay pending."
      }
     ]
    }
   },
   {
    "sessionId": "29344c71-f9f0-40f3-b654-20ee9525ca09",
    "toolUseId": "toolu_016iX2cRJrKmjtB3yJQCScmd",
    "answeredAt": "2026-10-04T09:59:00.483Z",
    "answer": "Idempotent retried delivery (recommended)",
    "question": {
     "question": "D2 — What delivery guarantee does the retried processWebhookJob keep, and what regression test proves it?\nProject/branch/task: main — reviewing PLAN.md \"Add background job retry framework\"; the webhook job is rewritten under the new retry path and currently guarantees at-most-once delivery.\nELI10: Today a webhook is sent once; if it fails, it is gone. Adding retries means the same event can be sent again. Sometimes the first send actually arrived but the response got lost, so the retry delivers a duplicate. Receivers that bill, email or create records on each webhook will double-act unless we give them a way to recognise a repeat.\nStakes if we pick wrong: downstream systems process duplicate events (double charges, double notifications) with no test telling us the guarantee changed, or webhook failures stay unrecovered forever.\nRecommendation: A because it recovers failed sends and keeps receivers safe from duplicates, and the four assertions make the guarantee executable rather than implied.\nCompleteness: A=9/10, B=5/10, C=6/10\nPros / cons:\nA) Idempotent retried delivery (recommended)\n  ✅ Failed webhooks are retried, and a stable per-job idempotency-key header plus a persisted delivered marker let receivers and the worker dedup repeats\n  ✅ Four concrete assertions cover first-try success, 5xx-then-2xx, lost response and lost ack, so the regression test fails on any semantic slip (human: ~2 days / CC: ~30 min)\n  ❌ Receivers must honor the idempotency header to be fully safe; the marker adds one persisted field per job\nB) Explicit at-least-once\n  ✅ Simplest code: library retry with no key or marker; one changelog note documents the new semantics\n  ✅ Still recovers failed webhooks that were previously dropped\n  ❌ Duplicates reach receivers on every ambiguous outcome, and the only test is \"a 5xx schedules a retry\"\nC) Exclude webhooks from retry\n  ✅ Preserves the exact current at-most-once guarantee with a one-assertion regression test\n  ✅ Zero risk of duplicate side effects downstream\n  ❌ Webhook failures stay unrecovered, which is the problem this plan set out to fix; the webhook rewrite then has no purpose\nNet: trading one header and one persisted flag for retries that cannot double-act on receivers.",
     "header": "Webhook semantics",
     "multiSelect": false,
     "options": [
      {
       "label": "Idempotent retried delivery (recommended)",
       "description": "Retry failed webhook POSTs via the library hooks (D1), send a stable per-job idempotency-key header on every attempt, and persist a delivered marker on 2xx that is checked before each attempt. Regression contract: (1) 2xx on attempt 1 → exactly one POST, no retry; (2) 5xx then 2xx → two POSTs with identical key; (3) send succeeds, response times out → retry carries the same key; (4) marker set but ack lost → no second POST. ✅ Recovers failed sends and dedups repeats. ✅ Guarantee is executable, not implied (human: ~2 days / CC: ~30 min). ❌ Receivers must honor the header; one persisted field per job. Completeness 9/10. R2, R4, R6–R9 stay pending."
      },
      {
       "label": "Explicit at-least-once",
       "description": "Retry failed webhook POSTs with no key or marker; document at-least-once in the changelog. Regression contract: (1) 5xx → retry scheduled; (2) duplicates on ambiguous outcomes documented. ✅ Simplest code. ✅ Recovers failed webhooks. ❌ Duplicates reach receivers on every ambiguous outcome. Completeness 5/10. R2, R4, R6–R9 stay pending."
      },
      {
       "label": "Exclude webhooks from retry",
       "description": "processWebhookJob opts out of the retry hooks and keeps exact at-most-once. Regression contract: (1) 5xx → job lands in failed state once, no retry; (2) request shape unchanged. ✅ Exact current guarantee preserved. ✅ Zero duplicate risk. ❌ Webhook failures stay unrecovered and the rewrite loses its purpose. Completeness 6/10. R2, R4, R6–R9 stay pending."
      }
     ]
    }
   },
   {
    "sessionId": "29344c71-f9f0-40f3-b654-20ee9525ca09",
    "toolUseId": "toolu_01C1fNQhCuZ3ogymwmdD4fgu",
    "answeredAt": "2026-10-04T09:59:57.788Z",
    "answer": "Full jitter (recommended)",
    "question": {
     "question": "D3 — Should retry delays be randomized (jitter), and how?\nProject/branch/task: main — reviewing PLAN.md \"Add background job retry framework\"; the backoff callback approved in D1 needs its curve defined, starting with jitter.\nELI10: When a downstream service goes down, every job that failed at the same moment computes the same retry delay and comes back at the same moment, so the recovering service gets hit by a wave and falls over again. Jitter adds randomness to each delay so retries spread out. Full jitter picks any delay from zero up to the computed value; equal jitter keeps half the delay fixed and randomizes the other half.\nStakes if we pick wrong: synchronized retry storms after every outage, or (with equal jitter) a longer mandatory floor than needed.\nRecommendation: A because full jitter spreads load best for the same code size [Layer 1]; the only cost is that a retry can occasionally fire almost immediately.\nCompleteness: A=9/10, B=8/10, C=4/10\nPros / cons:\nA) Full jitter (recommended)\n  ✅ Spreads retries across the whole window, so a recovering service sees a trickle instead of a wave (human: ~2 hr / CC: ~5 min incl. seeded test)\n  ✅ Same one-line callback as the plain curve; well documented standard practice\n  ❌ A retry may fire almost immediately after failure, which wastes one attempt when the outage is still ongoing\nB) Equal jitter\n  ✅ Guarantees a minimum wait of half the computed delay, so no near-instant retry\n  ✅ Still breaks synchronization across jobs\n  ❌ Slightly more contention than full jitter and a larger mandatory floor at high attempt counts\nC) No jitter\n  ✅ Fully deterministic delays are easy to reason about and test exactly\n  ✅ Zero extra code\n  ❌ Every job that failed together retries together; the thundering-herd failure mode is left open\nNet: trading exact predictability of one delay for a recovering dependency that is not re-flattened by our own retries.",
     "header": "Backoff jitter",
     "multiSelect": false,
     "options": [
      {
       "label": "Full jitter (recommended)",
       "description": "Backoff callback returns random(0, base × 2^attempt). Unit test with seeded RNG: delay within [0, formula]; two jobs at the same attempt get different delays. ✅ Spreads retries across the whole window (human: ~2 hr / CC: ~5 min). ✅ One-line callback, standard practice. ❌ A retry may fire almost immediately. Completeness 9/10. R7, R8 pending (cap applies pre-jitter when decided); R2, R4, R9 pending."
      },
      {
       "label": "Equal jitter",
       "description": "Callback returns half the formula plus random(0, half). Unit test: delay within [half, full]; two jobs differ. ✅ Guaranteed minimum wait. ✅ Still desynchronizes. ❌ More contention than full jitter and a larger floor at high attempts. Completeness 8/10. R7, R8, R2, R4, R9 pending."
      },
      {
       "label": "No jitter",
       "description": "Callback returns base × 2^attempt exactly. Unit test: exact values per attempt. ✅ Deterministic and exact. ✅ Zero extra code. ❌ Thundering herd after outages stays open. Completeness 4/10. R7, R8, R2, R4, R9 pending."
      }
     ]
    }
   }
  ],
  "planEvents": [
   {
    "at": "2026-10-04T09:55:09.093Z",
    "write": "# Eng review working plan — Add background job retry framework\n\nReview target (fixed): `PLAN.md` in <fixture> (\"Plan: Add background job retry framework\"), branch `main`, commit d539bb1.\nReviewer: /plan-eng-review (claude host), session 692-1791107614-d3e1e871.\nEvidence limits: the repository contains only CLAUDE.md and PLAN.md. No worker source, job library manifest or tests are present, so every code-level claim below is marked unknown unless the plan text itself states it.\n\n## Original plan (unchanged copy)\n\n```markdown\n# Plan: Add background job retry framework\n\n## Architecture\nWe'll roll a custom exponential-backoff scheduler inline in each worker\nrather than use the existing job library's built-in retry hooks. Same\nshape as the library version, but we want full control over the curve.\n\n## Code quality\nThe retry envelope (compute delay, log attempt, dispatch) is duplicated\nacross 5 worker files with copy-pasted bodies. We will leave the\nduplication for now and refactor \"later.\"\n\n## Tests\nThe existing `processWebhookJob()` flow gets rewritten as part of this\nchange. No regression test for the prior at-most-once delivery guarantee\nis planned.\n\n## Performance\nOn every retry we re-fetch the full job payload from the database, then\niterate the payload to recompute the dependency graph. Could cache the\ngraph on the first attempt; not planned.\n```\n"
   },
   {
    "at": "2026-10-04T09:56:20.513Z",
    "old": "iterate the payload to recompute the dependency graph. Could cache the\ngraph on the first attempt; not planned.\n```\n",
    "new": "iterate the payload to recompute the dependency graph. Could cache the\ngraph on the first attempt; not planned.\n```\n\n## Scope Challenge\n\nComplexity gate: ~5 worker files + webhook job flow, 0–1 new component. Under 8 files and under 2 new classes, so B skipped. Search check (WebSearch, Aside absent): BullMQ exposes a custom `backoffStrategy` hook plus built-in fixed/exponential with jitter; documented pitfalls are hook inputs (attempt number only) and silent fallthrough on unknown strategy names.\n\nFindings:\n1. [P1] (confidence: 8/10) PLAN.md:7-9 — custom inline exponential-backoff scheduler per worker instead of the library's retry hooks. Reviewer: plan-eng-review (claude).\n\n## Decision ledger\n\n### R1: Retry mechanism — library retry hooks with custom backoff vs custom inline scheduler\nFinding: #1, P1, confidence 8/10, PLAN.md:7-9 (\"We'll roll a custom exponential-backoff scheduler inline in each worker rather than use the existing job library's built-in retry hooks. Same shape as the library version, but we want full control over the curve.\"), reviewer plan-eng-review (claude)\nPlan baseline: original proposal — custom inline scheduler in each of 5 workers; nothing approved yet\nRuntime evidence: unknown — no worker source or library manifest in this repo. External: BullMQ docs show a custom backoffStrategy hook and built-in exponential + jitter (https://docs.bullmq.io/guide/retrying-failing-jobs); other mainstream libraries (Sidekiq, Celery, Oban) expose equivalent per-job backoff callbacks (in-distribution knowledge, unverified against the installed library)\nComparison grid:\n\n| Choice | Current (plan) | A) Library hooks + custom curve | B) Custom inline scheduler | C) Investigate library hook first |\n|---|---|---|---|---|\n| R1 retry mechanism | custom inline scheduler per worker (unapproved proposal) | library retry hooks + one custom backoff callback; retry state persisted by the queue store | custom inline scheduler per worker (original) | undecided; bounded probe: read installed library's backoff hook docs + one worker's current retry config; approves nothing |\n| R2 retry-envelope duplication (5 copies) | copy-pasted, \"refactor later\" | pending (A shrinks its surface; still its own answer) | pending | pending |\n| R3 at-most-once regression coverage for processWebhookJob | none planned | pending | pending | pending |\n| R4 payload re-fetch / dependency-graph caching | re-fetch every retry, not planned | pending | pending | pending |\n| R5 delivery semantics (at-most-once → retried) | implicit, unstated | pending | pending | pending |\n\nQuestion D1:\nD1 — Build the retry scheduler inline, or use the job library's retry hooks with a custom backoff curve?\nProject/branch/task: main — reviewing PLAN.md \"Add background job retry framework\"; the plan proposes a hand-rolled exponential-backoff scheduler inside each of 5 workers.\nELI10: The job library already knows how to retry a failed job: it stores the attempt count, waits, and re-runs it, and almost every mainstream library lets you plug in your own delay formula. The plan rebuilds that machinery inside each worker so \"we control the curve.\" That control is already available through the library's backoff callback, and the rebuilt version has to re-solve persistence, visibility and crash safety on its own.\nStakes if we pick wrong: an in-process retry timer dies with the worker, so a crash or deploy mid-backoff silently drops the job; retry counts and dead-letter state vanish from the library's dashboards and tooling.\nRecommendation: A because the library's hook gives the same curve control with persistence and tooling for free [Layer 1]; rebuilding it is accidental complexity in 5 places.\nCompleteness: A=9/10, B=4/10, C=n/a (bounded investigation, decides nothing)\nPros / cons:\nA) Library retry hooks + custom backoff callback (recommended)\n  ✅ Retry state (attempt count, next-run time, dead-letter) persists in the queue store and survives worker crashes and deploys\n  ✅ Existing library tooling (dashboards, admin retry, metrics) keeps working; one backoff function instead of five schedulers (human: ~1 day / CC: ~20 min)\n  ❌ Curve is bounded by the hook's inputs (often attempt number only), so error-specific delays like Retry-After need a small wrapper\nB) Custom inline scheduler in each worker (plan as written)\n  ✅ Unlimited control over delay math and per-error behavior without touching library config\n  ✅ No dependency on the library's backoff API shape or version\n  ❌ Retries live in worker memory unless you also build persistence; a crash during backoff loses the job silently and bypasses the library's retry visibility (human: ~1 week / CC: ~1 hr, plus 5 copies to maintain)\nC) Investigate first: bounded probe of the library's backoff hook\n  ✅ Confirms whether the installed library's hook supports the exact curve before committing either way\n  ✅ Cheap: read the library docs and one worker's current retry config (human: ~1 hr / CC: ~5 min)\n  ❌ Decides nothing; R1 stays pending and Sections 1–4 proceed against the plan as written\nNet: trading a bounded callback signature for crash-safe, observable retries you don't have to write five times.\nHeader: Retry mechanism\nOptions:\nA) Library hooks + custom curve (recommended)\nUse the job library's built-in retry hooks and supply one custom backoff callback for the curve. ✅ Retry state (attempt count, next-run time, dead-letter) persists in the queue store and survives worker crashes and deploys. ✅ Existing library tooling (dashboards, admin retry, metrics) keeps working; one backoff function instead of five schedulers (human: ~1 day / CC: ~20 min). ❌ Curve is bounded by the hook's inputs (often attempt number only), so error-specific delays like Retry-After need a small wrapper. Completeness 9/10. R2–R5 stay pending.\nB) Custom inline scheduler\nKeep the plan as written: a hand-rolled exponential-backoff scheduler inside each of the 5 workers. ✅ Unlimited control over delay math and per-error behavior without touching library config. ✅ No dependency on the library's backoff API shape or version. ❌ Retries live in worker memory unless you also build persistence; a crash during backoff loses the job silently and bypasses the library's retry visibility (human: ~1 week / CC: ~1 hr, plus 5 copies to maintain). Completeness 4/10. R2–R5 stay pending.\nC) Investigate library hook first\nBounded probe only: read the installed library's backoff hook docs and one worker's current retry config, then return to this question. ✅ Confirms whether the hook supports the exact curve before committing either way. ✅ Cheap (human: ~1 hr / CC: ~5 min). ❌ Decides nothing; R1 stays pending and Sections 1–4 proceed against the plan as written. No completeness score (investigation, not coverage). R2–R5 stay pending.\n\nState: pending\nActual answer: unanswered\nAccepted scope: none\nHistory: none\n"
   },
   {
    "at": "2026-10-04T09:56:52.825Z",
    "old": "State: pending\nActual answer: unanswered\nAccepted scope: none\nHistory: none\n",
    "new": "State: approved\nActual answer: A) Library hooks + custom curve (D1 answer, AskUserQuestion)\nAccepted scope: Replace the inline per-worker exponential-backoff scheduler with the job library's built-in retry hooks plus one custom backoff callback that implements the desired curve; retry state (attempt count, next-run time, dead-letter) is persisted by the queue store. Includes the callback's unit tests and the plan's Architecture section rewrite. R2–R5 remain pending.\nHistory: none\n\nScope Challenge result: scope accepted as-is (R1 changes the mechanism, not the feature scope; B skipped).\n"
   },
   {
    "at": "2026-10-04T09:58:39.713Z",
    "old": "Scope Challenge result: scope accepted as-is (R1 changes the mechanism, not the feature scope; B skipped).\n",
    "new": "Scope Challenge result: scope accepted as-is (R1 changes the mechanism, not the feature scope; B skipped).\n\n## Section 1: Architecture review — findings\n\n1. [P1] (confidence: 8/10) PLAN.md:17-19 — retrying `processWebhookJob()` converts at-most-once delivery into at-least-once; a POST that lands but whose response times out is retried and the receiver gets a duplicate. No idempotency key or delivered marker planned. → R5\n2. [P2] (confidence: 7/10) PLAN.md:7-9 — no retry bounds: no max attempts, delay cap or jitter; lockstep retry storms after an outage and unbounded delay growth. → R6 (jitter), R7 (max attempts), R8 (delay cap)\n3. [P2] (confidence: 7/10) PLAN.md:6-9 — no retry state diagram; factual addition, see Diagrams. No decision.\n4. Worker crash during in-memory backoff loses the retry — resolved by D1 (library persists retry state). Accepted via D1.\n\n### R5: processWebhookJob delivery semantics and regression contract\nFinding: #1 (Architecture), P1, confidence 8/10, PLAN.md:17-19 (\"The existing `processWebhookJob()` flow gets rewritten as part of this change. No regression test for the prior at-most-once delivery guarantee is planned.\"), reviewer plan-eng-review (claude)\nPlan baseline: original proposal — rewrite the flow under the retry framework with no stated semantics and no regression test; nothing approved\nRuntime evidence: unknown — processWebhookJob source not in this repo; the plan itself asserts the current guarantee is at-most-once\nComparison grid:\n\n| Choice | Current (plan) | A) Idempotent retried delivery | B) Explicit at-least-once | C) Exclude webhooks from retry |\n|---|---|---|---|---|\n| R5 behavior preserved | implicit, unstated | receiver never gets the same event twice on a successful path (dedup via stable key + delivered marker) | none; duplicates allowed | exact at-most-once: a failed POST is never re-sent |\n| R5 intentional change | implicit, unstated | failed POST (connect error, 5xx, timeout) is retried via library hooks | failed POST retried; duplicates possible on ambiguous outcomes | none for webhooks; other 4 workers still get retries |\n| R5 acceptance assertions (regression contract) | none planned | (1) 2xx on attempt 1 → exactly one POST, no retry scheduled; (2) 5xx then 2xx → two POSTs with identical idempotency-key header; (3) send succeeds, response times out → retry carries the same key; (4) delivered marker set but ack lost → no second POST | (1) 5xx → retry scheduled; (2) key header absent, duplicate on ambiguous outcome documented in changelog | (1) 5xx → job lands in failed state once, no retry; (2) unchanged request shape |\n| R1 retry mechanism | approved A (D1) | approved A, unchanged | approved A, unchanged | approved A, unchanged (webhook opts out) |\n| R2, R4, R6, R7, R8, R9 | pending | pending | pending | pending |\n\nQuestion D2:\nD2 — What delivery guarantee does the retried processWebhookJob keep, and what regression test proves it?\nProject/branch/task: main — reviewing PLAN.md \"Add background job retry framework\"; the webhook job is rewritten under the new retry path and currently guarantees at-most-once delivery.\nELI10: Today a webhook is sent once; if it fails, it is gone. Adding retries means the same event can be sent again. Sometimes the first send actually arrived but the response got lost, so the retry delivers a duplicate. Receivers that bill, email or create records on each webhook will double-act unless we give them a way to recognise a repeat.\nStakes if we pick wrong: downstream systems process duplicate events (double charges, double notifications) with no test telling us the guarantee changed, or webhook failures stay unrecovered forever.\nRecommendation: A because it recovers failed sends and keeps receivers safe from duplicates, and the four assertions make the guarantee executable rather than implied.\nCompleteness: A=9/10, B=5/10, C=6/10\nPros / cons:\nA) Idempotent retried delivery (recommended)\n  ✅ Failed webhooks are retried, and a stable per-job idempotency-key header plus a persisted delivered marker let receivers and the worker dedup repeats\n  ✅ Four concrete assertions cover first-try success, 5xx-then-2xx, lost response and lost ack, so the regression test fails on any semantic slip (human: ~2 days / CC: ~30 min)\n  ❌ Receivers must honor the idempotency header to be fully safe; the marker adds one persisted field per job\nB) Explicit at-least-once\n  ✅ Simplest code: library retry with no key or marker; one changelog note documents the new semantics\n  ✅ Still recovers failed webhooks that were previously dropped\n  ❌ Duplicates reach receivers on every ambiguous outcome, and the only test is \"a 5xx schedules a retry\"\nC) Exclude webhooks from retry\n  ✅ Preserves the exact current at-most-once guarantee with a one-assertion regression test\n  ✅ Zero risk of duplicate side effects downstream\n  ❌ Webhook failures stay unrecovered, which is the problem this plan set out to fix; the webhook rewrite then has no purpose\nNet: trading one header and one persisted flag for retries that cannot double-act on receivers.\nHeader: Webhook semantics\nOptions:\nA) Idempotent retried delivery (recommended)\nRetry failed webhook POSTs via the library hooks (D1), send a stable per-job idempotency-key header on every attempt, and persist a delivered marker on 2xx that is checked before each attempt. Regression contract: (1) 2xx on attempt 1 → exactly one POST, no retry; (2) 5xx then 2xx → two POSTs with identical key; (3) send succeeds, response times out → retry carries the same key; (4) marker set but ack lost → no second POST. ✅ Recovers failed sends and dedups repeats. ✅ Guarantee is executable, not implied (human: ~2 days / CC: ~30 min). ❌ Receivers must honor the header; one persisted field per job. Completeness 9/10. R2, R4, R6–R9 stay pending.\nB) Explicit at-least-once\nRetry failed webhook POSTs with no key or marker; document at-least-once in the changelog. Regression contract: (1) 5xx → retry scheduled; (2) duplicates on ambiguous outcomes documented. ✅ Simplest code. ✅ Recovers failed webhooks. ❌ Duplicates reach receivers on every ambiguous outcome. Completeness 5/10. R2, R4, R6–R9 stay pending.\nC) Exclude webhooks from retry\nprocessWebhookJob opts out of the retry hooks and keeps exact at-most-once. Regression contract: (1) 5xx → job lands in failed state once, no retry; (2) request shape unchanged. ✅ Exact current guarantee preserved. ✅ Zero duplicate risk. ❌ Webhook failures stay unrecovered and the rewrite loses its purpose. Completeness 6/10. R2, R4, R6–R9 stay pending.\n\nState: pending\nActual answer: unanswered\nAccepted scope: none\nHistory: none\n"
   },
   {
    "at": "2026-10-04T09:59:40.286Z",
    "old": "Completeness 6/10. R2, R4, R6–R9 stay pending.\n\nState: pending\nActual answer: unanswered\nAccepted scope: none\nHistory: none\n",
    "new": "Completeness 6/10. R2, R4, R6–R9 stay pending.\n\nState: approved\nActual answer: A) Idempotent retried delivery (D2 answer, AskUserQuestion)\nAccepted scope: processWebhookJob retries failed POSTs (connect error, 5xx, timeout) via the library hooks (D1); every attempt sends a stable per-job idempotency-key header; a delivered marker is persisted on 2xx and checked before each attempt. Regression contract (CRITICAL test, carried into Test review as approved): (1) 2xx on attempt 1 → exactly one POST, no retry scheduled; (2) 5xx then 2xx → two POSTs with identical idempotency key; (3) send succeeds, response times out → retry carries the same key; (4) marker set but ack lost → no second POST. Changelog note documenting the new header. R2, R4, R6–R9 remain pending.\nHistory: none\n\n### R6: Backoff jitter\nFinding: #2 (Architecture), P2, confidence 7/10, PLAN.md:7-9 (\"custom exponential-backoff scheduler ... full control over the curve\"), reviewer plan-eng-review (claude). The curve names exponential growth but no jitter.\nPlan baseline: original proposal — exponential curve, jitter unspecified; nothing approved\nRuntime evidence: unknown — no scheduler source in this repo. External: BullMQ built-in exponential accepts a 0–1 jitter factor (https://docs.bullmq.io/guide/retrying-failing-jobs); AWS Architecture Blog \"Exponential Backoff and Jitter\" shows full jitter minimizes contention and total work (in-distribution knowledge)\nComparison grid:\n\n| Choice | Current (plan) | A) Full jitter | B) Equal jitter | C) No jitter |\n|---|---|---|---|---|\n| R6 jitter | unspecified, pending | delay = random(0, base × 2^attempt) | delay = half of base × 2^attempt + random(0, that half) | delay = base × 2^attempt exactly |\n| R6 proof (unit test, seeded RNG) | none | delay ∈ [0, base × 2^attempt]; two jobs with same attempt get different delays | delay ∈ [half, full]; two jobs differ | delay equals formula exactly |\n| R1 retry mechanism | approved A (D1) | unchanged | unchanged | unchanged |\n| R5 webhook semantics | approved A (D2) | unchanged | unchanged | unchanged |\n| R7 max attempts, R8 delay cap | pending | pending (cap applies to the pre-jitter value when decided) | pending | pending |\n| R2, R4, R9 | pending | pending | pending | pending |\n\nQuestion D3:\nD3 — Should retry delays be randomized (jitter), and how?\nProject/branch/task: main — reviewing PLAN.md \"Add background job retry framework\"; the backoff callback approved in D1 needs its curve defined, starting with jitter.\nELI10: When a downstream service goes down, every job that failed at the same moment computes the same retry delay and comes back at the same moment, so the recovering service gets hit by a wave and falls over again. Jitter adds randomness to each delay so retries spread out. Full jitter picks any delay from zero up to the computed value; equal jitter keeps half the delay fixed and randomizes the other half.\nStakes if we pick wrong: synchronized retry storms after every outage, or (with equal jitter) a longer mandatory floor than needed.\nRecommendation: A because full jitter spreads load best for the same code size [Layer 1]; the only cost is that a retry can occasionally fire almost immediately.\nCompleteness: A=9/10, B=8/10, C=4/10\nPros / cons:\nA) Full jitter (recommended)\n  ✅ Spreads retries across the whole window, so a recovering service sees a trickle instead of a wave (human: ~2 hr / CC: ~5 min incl. seeded test)\n  ✅ Same one-line callback as the plain curve; well documented standard practice\n  ❌ A retry may fire almost immediately after failure, which wastes one attempt when the outage is still ongoing\nB) Equal jitter\n  ✅ Guarantees a minimum wait of half the computed delay, so no near-instant retry\n  ✅ Still breaks synchronization across jobs\n  ❌ Slightly more contention than full jitter and a larger mandatory floor at high attempt counts\nC) No jitter\n  ✅ Fully deterministic delays are easy to reason about and test exactly\n  ✅ Zero extra code\n  ❌ Every job that failed together retries together; the thundering-herd failure mode is left open\nNet: trading exact predictability of one delay for a recovering dependency that is not re-flattened by our own retries.\nHeader: Backoff jitter\nOptions:\nA) Full jitter (recommended)\nBackoff callback returns random(0, base × 2^attempt). Unit test with seeded RNG: delay within [0, formula]; two jobs at the same attempt get different delays. ✅ Spreads retries across the whole window (human: ~2 hr / CC: ~5 min). ✅ One-line callback, standard practice. ❌ A retry may fire almost immediately. Completeness 9/10. R7, R8 pending (cap applies pre-jitter when decided); R2, R4, R9 pending.\nB) Equal jitter\nCallback returns half the formula plus random(0, half). Unit test: delay within [half, full]; two jobs differ. ✅ Guaranteed minimum wait. ✅ Still desynchronizes. ❌ More contention than full jitter and a larger floor at high attempts. Completeness 8/10. R7, R8, R2, R4, R9 pending.\nC) No jitter\nCallback returns base × 2^attempt exactly. Unit test: exact values per attempt. ✅ Deterministic and exact. ✅ Zero extra code. ❌ Thundering herd after outages stays open. Completeness 4/10. R7, R8, R2, R4, R9 pending.\n\nState: pending\nActual answer: unanswered\nAccepted scope: none\nHistory: none\n"
   }
  ]
 }
}