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
41.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": "ded5316419aefeaf",
 "source": {
  "run": "37195203538",
  "sha": "41287009bd6b524244edced7770c87fc3103eb59",
  "lane": "periodic",
  "artifact": "paid-slice-1-a1",
  "path": "shards/skill-e2e-plan-eng-multi-finding-batching/pty-count/ci-37195203538-1-eval-slices-1/plan-eng-review-1791109541361-oBdGAF"
 },
 "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": "148ebb73-116f-48ed-a898-e9a1ec6c7a20",
    "toolUseId": "toolu_01JBahHE3xuK2uiL2acmpLvV",
    "answeredAt": "2026-10-04T10:28:26.210Z",
    "answer": "Library hook + custom backoff fn (recommended)",
    "question": {
     "question": "D1 — Use the job library's retry hooks or roll a custom inline scheduler?\nProject/branch/task: `main` of the retry-framework plan; the plan currently rolls its own scheduler inside each of 5 workers (PLAN.md:7-9).\nELI10: Your job library already knows how to retry a failed job: it counts attempts, waits, re-runs, and gives up after N tries. The plan rebuilds that waiting logic by hand inside every worker because the team wants to pick the exact wait curve. Most libraries let you plug in your own curve as a small function while they keep doing the counting and re-running. Rebuilding it means you also own attempt tracking, surviving a worker restart mid-wait, max-attempt cutoff and dead-lettering.\nStakes if we pick wrong: a hand-rolled scheduler that loses attempt state on restart retries forever or never, and the bug appears in five places at once, at 3am.\nRecommendation: A because the plan's only stated reason (\"full control over the curve\") is exactly what a backoff-strategy hook provides, and it is an already-installed dependency (reuse ladder rung 4).\nNote: options differ in kind, not coverage — no completeness score.\nPros / cons:\nA) Library hook + custom backoff function (recommended)\n  ✅ Attempt counting, persistence across restarts, max attempts and dead-lettering stay with proven library code\n  ✅ The curve lives in one function (exponential, cap, jitter) instead of five inline copies (human: ~0.5 day / CC: ~10 min)\n  ❌ Curve is constrained to whatever the hook's signature allows (usually a delay in ms from attempt number and error)\nB) Custom inline scheduler per worker, as planned\n  ✅ No dependency on the library's hook contract; any curve shape or side effect is possible\n  ✅ No need to learn or verify the hook API before starting (human: ~2 days / CC: ~30 min, plus ongoing maintenance)\n  ❌ Re-implements attempt state, restart recovery, cutoff and dead-letter handling, each a new 3am failure mode across 5 files\nC) Investigate the hook first, decide after\n  ✅ Bounded check (hook signature, custom curve, max attempts, jitter, cap) settles the unknown with evidence (human: ~1 hour / CC: ~5 min)\n  ✅ Nothing is built on an assumption; R1 stays pending, R2–R4 stay pending\n  ❌ Delays the architecture decision; if the hook obviously supports a custom curve this is wasted time\nNet: trading the library's proven retry lifecycle against total freedom over a curve the library almost certainly already lets you set.",
     "header": "Retry mechanism",
     "multiSelect": false,
     "options": [
      {
       "label": "Library hook + custom backoff fn (recommended)",
       "description": "Register one custom backoff function with the job library's built-in retry hook; the function owns the curve (exponential base, cap, jitter). The library keeps attempt counting, persistence across worker restarts, max-attempt cutoff and dead-lettering. Human: ~0.5 day / CC: ~10 min. Risk: curve limited to the hook's signature. R2–R4 remain pending."
      },
      {
       "label": "Custom inline scheduler",
       "description": "Keep the plan as written: a hand-rolled exponential-backoff scheduler inline in each worker, bypassing the library's retry hooks. Full curve freedom. Human: ~2 days / CC: ~30 min plus maintenance. Risk: re-implements attempt state, restart recovery, cutoff and dead-lettering in 5 places. R2–R4 remain pending."
      },
      {
       "label": "Investigate hook first",
       "description": "Bounded investigation only: read the library's retry hook signature and confirm it supports a custom curve, max attempts, jitter and a delay cap. No implementation approved; R1 returns to this question with evidence. Human: ~1 hour / CC: ~5 min. R2–R4 remain pending."
      }
     ]
    }
   },
   {
    "sessionId": "148ebb73-116f-48ed-a898-e9a1ec6c7a20",
    "toolUseId": "toolu_01RoMYnxxpq4VAbMfbGVddrp",
    "answeredAt": "2026-10-04T10:29:58.185Z",
    "answer": "At-least-once + idempotency id (recommended)",
    "question": {
     "question": "D2 — What delivery guarantee does the webhook job keep once it can retry?\nProject/branch/task: `main` of the retry-framework plan; `processWebhookJob()` is rewritten and loses its at-most-once guarantee (PLAN.md:17-19).\nELI10: Today a webhook is sent at most once: if it fails, it is gone, but the receiver never sees a duplicate. Adding retries flips that: the receiver might now get the same event twice, for example when the POST lands but the worker dies before marking it done. You can either tell receivers \"you may see duplicates, here is an id so you can ignore the second one,\" keep the old promise by never retrying once a send was attempted, or retry blindly and hope receivers cope.\nStakes if we pick wrong: receivers double-process events (double charges, double emails), or you keep at-most-once and the reliability win from retries never reaches the webhook path.\nRecommendation: A because at-least-once plus a stable delivery id is the standard webhook contract and receivers can dedupe cheaply, while B gives up most of the reliability you are building this for.\nCompleteness: A=9/10, B=7/10, C=3/10\nPros / cons:\nA) At-least-once with idempotency id (recommended)\n  ✅ Retries apply to the whole webhook path, including transient receiver 5xx and network timeouts\n  ✅ Stable delivery id on every attempt lets receivers dedupe; this is the documented contract most webhook consumers expect (human: ~1 day / CC: ~15 min)\n  ❌ Receivers that ignore the id will see duplicates; the contract change must be documented and announced\nB) Preserve at-most-once\n  ✅ No behavior change visible to receivers; no duplicate risk and no receiver-side work\n  ✅ Retries still cover pre-send failures such as payload fetch or serialization errors (human: ~0.5 day / CC: ~10 min)\n  ❌ A receiver 503 or a timeout after send is final: the event is dead-lettered, so the webhook path gains almost nothing from this project\nC) At-least-once, no dedupe id (plan as written)\n  ✅ Smallest change: just let the library retry the existing handler as-is\n  ✅ No contract documentation or header work (human: ~2 hours / CC: ~5 min)\n  ❌ Duplicates are undetectable by receivers; the first incident is a double side effect with no way to reconcile\nNet: trading a documented, dedupe-able duplicate against either silent duplicates or a webhook path that cannot be retried.",
     "header": "Webhook guarantee",
     "multiSelect": false,
     "options": [
      {
       "label": "At-least-once + idempotency id (recommended)",
       "description": "`processWebhookJob()` retries through the library hook (D1). Every attempt sends the same stable delivery id (header and body field) so receivers can dedupe; the contract change is documented for receivers. Completeness 9/10. Human: ~1 day / CC: ~15 min. Risk: receivers ignoring the id see duplicates. R2, R3, R4 remain pending."
      },
      {
       "label": "Preserve at-most-once",
       "description": "Retries cover only failures before the HTTP send is attempted (payload fetch, serialization, auth). Once a send is attempted, no retry; failure goes to dead-letter. Receivers see no behavior change. Completeness 7/10. Human: ~0.5 day / CC: ~10 min. Risk: post-send transient failures are final. R2, R3, R4 remain pending."
      },
      {
       "label": "At-least-once, no dedupe id",
       "description": "Let the library retry the existing handler unchanged. No delivery id, no contract documentation. Completeness 3/10. Human: ~2 hours / CC: ~5 min. Risk: undetectable duplicate side effects at receivers. R2, R3, R4 remain pending."
      }
     ]
    }
   },
   {
    "sessionId": "148ebb73-116f-48ed-a898-e9a1ec6c7a20",
    "toolUseId": "toolu_012wPP3MnH4ha91TjftEnYM8",
    "answeredAt": "2026-10-04T10:31:24.991Z",
    "answer": "Library event listener (recommended)",
    "question": {
     "question": "D3 — Where does retry-attempt logging live once the library drives retries?\nProject/branch/task: `main` of the retry-framework plan; the retry envelope is copy-pasted into 5 worker files and the plan leaves it duplicated (PLAN.md:12-14).\nELI10: After D1 the library computes the delay and re-dispatches, so two of the three copy-pasted pieces disappear on their own. The third piece, \"log this attempt\", still has to live somewhere. Most job libraries fire an event every time a job fails and is scheduled to retry; one listener on that event logs every worker's attempts with zero code in the workers. The alternatives are a tiny shared function each worker calls, or leaving five copies and promising to clean up later.\nStakes if we pick wrong: five copies drift, one worker logs attempts differently or not at all, and the 3am incident has a hole exactly where the failing worker is.\nRecommendation: A because it uses an already-installed dependency (reuse ladder rung 4), needs no change inside the workers, and cannot drift across them.\nCompleteness: A=10/10, B=8/10, C=3/10\nPros / cons:\nA) One library lifecycle-event listener (recommended)\n  ✅ Zero retry code left in any worker; every worker's attempts logged identically from one place (human: ~2 hours / CC: ~5 min)\n  ✅ Uses the library's own failed/retry event, so logging stays correct even when a new worker is added later\n  ❌ Depends on the library emitting a usable event with attempt number and next delay; verify at implementation time\nB) Shared `logRetryAttempt()` helper called per worker\n  ✅ Works even if the library emits no retry event; explicit call site in each worker (human: ~3 hours / CC: ~10 min)\n  ✅ Single implementation, so log format cannot drift between workers\n  ❌ Every worker still carries a call and a new worker can forget it; one more seam to test per caller\nC) Leave the 5 inline copies, refactor later\n  ✅ No change to the 5 workers beyond removing the inline scheduler already approved in D1\n  ✅ Nothing new to learn or test right now (human: ~0 / CC: ~0)\n  ❌ \"Later\" rarely arrives; five copies drift and the duplication finding stands unresolved in the ship review\nNet: trading a dependency on one library event against carrying retry code in five workers that already should have none.",
     "header": "Attempt logging",
     "multiSelect": false,
     "options": [
      {
       "label": "Library event listener (recommended)",
       "description": "Register one listener on the job library's failed/retry lifecycle event at worker boot. It logs job id, attempt number, next delay and error class for every worker. Delete the inline envelope from all 5 workers (compute-delay and dispatch already move to the library under D1). Completeness 10/10. Human: ~2 hours / CC: ~5 min. Risk: library must emit the event with attempt data; verify at implementation. R3, R4 remain pending."
      },
      {
       "label": "Shared logRetryAttempt() helper",
       "description": "Create one small helper that logs job id, attempt number, next delay and error class; each of the 5 workers calls it from its failure path. Delete the rest of the inline envelope. Completeness 8/10. Human: ~3 hours / CC: ~10 min. Risk: a new worker can forget the call; one caller-integration test per worker. R3, R4 remain pending."
      },
      {
       "label": "Leave duplication, refactor later",
       "description": "Keep the per-worker attempt logging in all 5 workers as planned (PLAN.md:13-14); only the inline scheduler approved in D1 is removed. Completeness 3/10. Human: ~0 / CC: ~0. Risk: copies drift; finding stays open. R3, R4 remain pending."
      }
     ]
    }
   }
  ],
  "planEvents": [
   {
    "at": "2026-10-04T10:26:42.581Z",
    "write": "# Eng Review Report — Plan: Add background job retry framework\n\nReview target (fixed): `PLAN.md` in `<fixture>` (branch `main`, commit `bf0c669`).\nReviewer: /plan-eng-review (gstack), session `692-1791109527-353559b7`, 2026-10-04.\nReport file: this file (user-requested destination).\n\n## Original plan (unchanged copy of PLAN.md)\n\n```markdown\nProceed directly to the requested engineering review; skip the optional /office-hours prerequisite.\nPlease review this plan thoroughly. As you go, write your plan-mode plan to <fixture> (use Edit/Write to that exact path).\n\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\n## Review evidence notes\n\n- The repository contains only `CLAUDE.md` and `PLAN.md`. None of the code the plan names (the 5 worker files, `processWebhookJob()`, the job library) is checked in here. All runtime evidence below is therefore **unknown**; findings are calibrated from the plan text alone and quote `PLAN.md:line`.\n- `git log -- PLAN.md CLAUDE.md`: one commit (`bf0c669 Seed review plan`); no reverts.\n- No `TODOS.md` in the repo.\n- No design doc found; user asked to skip `/office-hours`.\n"
   },
   {
    "at": "2026-10-04T10:28:04.398Z",
    "old": "- No design doc found; user asked to skip `/office-hours`.\n",
    "new": "- No design doc found; user asked to skip `/office-hours`.\n- Test framework detection: no runtime markers, no test config, `TESTFILES:0`. Framework unknown.\n- Outside Voice preflight: `CODEX_MODE: disabled` (`codex_reviews=disabled`); Codex CLI also not installed.\n- Web research (host WebSearch, Aside unavailable): library-level retry hooks are the norm. BullMQ exposes a custom `backoffStrategy` hook (return -1 = fail now, 0 = requeue immediately, N = delay ms); un-jittered exponential backoff is the worst-performing strategy in AWS's jitter experiments; delivery is at-least-once so handlers must be idempotent; always cap attempts. Sources: https://oneuptime.com/blog/post/2026-01-21-bullmq-retry-exponential-backoff/view , https://www.digitalapplied.com/blog/background-job-queue-patterns-2026-engineering-reference , https://knowledgelib.io/software/patterns/retry-exponential-backoff/2026 , https://github.com/autumn-foundation/autumn/issues/3054\n\n## Step 0: Scope Challenge\n\n### A. Assessment\n- **What already solves each sub-problem:** The plan itself names the solution: the existing job library's built-in retry hooks (`PLAN.md:8`). Reuse ladder rung 4 (already-installed dependency). The stated motivation, \"full control over the curve\" (`PLAN.md:9`), is what a backoff-strategy hook exists to provide. **[Layer 1]**: use the library's hook with a custom curve function.\n- **Minimum change:** one backoff function registered with the library, plus the handler changes for `processWebhookJob()`. The inline-per-worker scheduler and the duplicated envelope are accidental complexity, not essential.\n- **Complexity check:** 5 proposed changed worker files (`PLAN.md:13`), 0 new classes/services (the scheduler is inline). Below the 8-file / 2-class gate, so **B is skipped**.\n- **Search check:** done (see evidence notes). No departure from standard practice is justified by the plan text.\n- **TODOS cross-reference:** no `TODOS.md`.\n- **Completeness check:** the plan defers three things (refactor, regression test, graph cache) that each cost CC minutes. Reviewed in Sections 2–4.\n- **Distribution check:** no new artifact; not applicable.\n\n### C. Findings\n1. **[P1] (confidence: 8/10) PLAN.md:7-9 — Custom inline scheduler re-implements the job library's built-in retry hooks.** Motivating lines: \"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.\" Runtime evidence: library identity and hook signature unknown (no code in repo), hence 8 not 9. An inline scheduler must also re-implement attempt counting, persistence of attempt state across worker restarts, max-attempt cutoff and dead-lettering, all of which the library already owns. Remedy: R1 / D1 below.\n\n## Decision ledger\n\n### R1: Retry mechanism — library retry hook vs custom inline scheduler\nFinding: #1, P1, confidence 8/10, PLAN.md:7-9, reviewer: native (plan-eng-review)\nPlan baseline: original proposal — custom exponential-backoff scheduler inline in each of the 5 workers; library hooks bypassed (PLAN.md:7-9). Nothing approved yet.\nRuntime evidence: unknown. The job library, its hook signature, and the 5 worker files are not in this repository. Web research shows mainstream libraries accept a custom backoff function (BullMQ `backoffStrategy`), but this library is unverified.\nComparison grid:\n\n| Choice | Current | A | B | C |\n|---|---|---|---|---|\n| R1 retry mechanism | custom inline scheduler per worker (proposed, unapproved) | library built-in retry hook + one custom backoff function (curve, cap, jitter) | custom inline scheduler per worker, as planned | pending; bounded investigation of the library hook's signature (custom curve, max attempts, jitter, cap) before choosing |\n| R2 retry envelope duplication across 5 workers | duplicated (PLAN.md:12-14), pending | pending | pending | pending |\n| R3 regression coverage for at-most-once guarantee | none planned (PLAN.md:17-19), pending | pending | pending | pending |\n| R4 dependency-graph recompute per retry | recompute every retry (PLAN.md:22-24), pending | pending | pending | pending |\n\nQuestion D1:\nD1 — Use the job library's retry hooks or roll a custom inline scheduler?\nProject/branch/task: `main` of the retry-framework plan; the plan currently rolls its own scheduler inside each of 5 workers (PLAN.md:7-9).\nELI10: Your job library already knows how to retry a failed job: it counts attempts, waits, re-runs, and gives up after N tries. The plan rebuilds that waiting logic by hand inside every worker because the team wants to pick the exact wait curve. Most libraries let you plug in your own curve as a small function while they keep doing the counting and re-running. Rebuilding it means you also own attempt tracking, surviving a worker restart mid-wait, max-attempt cutoff and dead-lettering.\nStakes if we pick wrong: a hand-rolled scheduler that loses attempt state on restart retries forever or never, and the bug appears in five places at once, at 3am.\nRecommendation: A because the plan's only stated reason (\"full control over the curve\") is exactly what a backoff-strategy hook provides, and it is an already-installed dependency (reuse ladder rung 4).\nNote: options differ in kind, not coverage — no completeness score.\nPros / cons:\nA) Library hook + custom backoff function (recommended)\n  ✅ Attempt counting, persistence across restarts, max attempts and dead-lettering stay with proven library code\n  ✅ The curve lives in one function (exponential, cap, jitter) instead of five inline copies (human: ~0.5 day / CC: ~10 min)\n  ❌ Curve is constrained to whatever the hook's signature allows (usually a delay in ms from attempt number and error)\nB) Custom inline scheduler per worker, as planned\n  ✅ No dependency on the library's hook contract; any curve shape or side effect is possible\n  ✅ No need to learn or verify the hook API before starting (human: ~2 days / CC: ~30 min, plus ongoing maintenance)\n  ❌ Re-implements attempt state, restart recovery, cutoff and dead-letter handling, each a new 3am failure mode across 5 files\nC) Investigate the hook first, decide after\n  ✅ Bounded check (hook signature, custom curve, max attempts, jitter, cap) settles the unknown with evidence (human: ~1 hour / CC: ~5 min)\n  ✅ Nothing is built on an assumption; R1 stays pending, R2–R4 stay pending\n  ❌ Delays the architecture decision; if the hook obviously supports a custom curve this is wasted time\nNet: trading the library's proven retry lifecycle against total freedom over a curve the library almost certainly already lets you set.\nHeader: Retry mechanism\nOptions:\nA) Library hook + custom backoff fn (recommended)\nRegister one custom backoff function with the job library's built-in retry hook; the function owns the curve (exponential base, cap, jitter). The library keeps attempt counting, persistence across worker restarts, max-attempt cutoff and dead-lettering. Human: ~0.5 day / CC: ~10 min. Risk: curve limited to the hook's signature. R2–R4 remain pending.\nB) Custom inline scheduler\nKeep the plan as written: a hand-rolled exponential-backoff scheduler inline in each worker, bypassing the library's retry hooks. Full curve freedom. Human: ~2 days / CC: ~30 min plus maintenance. Risk: re-implements attempt state, restart recovery, cutoff and dead-lettering in 5 places. R2–R4 remain pending.\nC) Investigate hook first\nBounded investigation only: read the library's retry hook signature and confirm it supports a custom curve, max attempts, jitter and a delay cap. No implementation approved; R1 returns to this question with evidence. Human: ~1 hour / CC: ~5 min. R2–R4 remain pending.\n\nState: pending\nActual answer: unanswered\nAccepted scope: none\nHistory: none\n"
   },
   {
    "at": "2026-10-04T10:28:56.211Z",
    "old": "State: pending\nActual answer: unanswered\nAccepted scope: none\nHistory: none\n",
    "new": "State: approved\nActual answer: A) Library hook + custom backoff fn — D1 answer (AskUserQuestion, this session)\nAccepted scope: Replace the inline per-worker scheduler (PLAN.md:7-9) with one custom backoff function registered on the job library's built-in retry hook. The function owns the curve: exponential base, delay cap and jitter. The library keeps attempt counting, attempt-state persistence across worker restarts, max-attempt cutoff and dead-lettering. Includes the code, tests and docs for that one function. R2, R3, R4 remain pending.\nHistory: none\n"
   },
   {
    "at": "2026-10-04T10:28:59.270Z",
    "old": "### C. Findings\n1. **[P1] (confidence: 8/10) PLAN.md:7-9",
    "new": "### C. Findings\nDispositions: #1 accepted via D1 (A). Scope Challenge result: **scope accepted as-is** (B skipped; the D1 change is an arrangement change that preserves the feature set, not a scope reduction).\n\n1. **[P1] (confidence: 8/10) PLAN.md:7-9"
   },
   {
    "at": "2026-10-04T10:29:11.583Z",
    "old": "## Decision ledger\n\n### R1: Retry mechanism",
    "new": "## Section 1: Architecture review\n\nFlow under the approved D1 arrangement (proposed, not yet code):\n\n```\nenqueue(job) ──► library runner ──► worker handler (e.g. processWebhookJob)\n                      ▲                    │\n                      │ success            ├── ok ──► ack / complete\n                      │                    └── throw ──► library retry hook\n                      │                                     │\n                      │                        backoffFn(attempt, err)\n                      │                          ├── attempt < max ──► delay = min(cap, base·2^attempt) ± jitter ──► requeue\n                      │                          └── attempt ≥ max ──► dead-letter / failed\n                      └──────────────── requeue after delay ───────────┘\n```\n\nFindings:\n2. **[P1] (confidence: 8/10) PLAN.md:17-19 — Adding retries to `processWebhookJob()` silently converts at-most-once delivery into at-least-once; duplicate webhooks reach receivers.** Motivating lines: \"The existing `processWebhookJob()` flow gets rewritten as part of this / change. No regression test for the prior at-most-once delivery guarantee / is planned.\" Realistic production failure: the HTTP POST to the receiver succeeds but the worker crashes or times out before acking; the retry re-sends, and the receiver processes the same event twice (double charge, double notification). The plan names the old guarantee and drops it without naming the new one or how receivers dedupe. Runtime evidence: unknown (handler not in repo). Remedy: R5 / D2 below. Test coverage for whichever guarantee is chosen is R3 (Section 3).\n3. **[P2] (confidence: 7/10) PLAN.md:7-9 — Curve parameters (max attempts, delay cap, jitter) are not specified.** Motivating line: \"we want full control over the curve.\" Un-jittered, uncapped exponential backoff is the worst strategy in AWS's published experiments (see evidence notes). Disposition: covered by D1 (A): the accepted scope makes the backoff function own base, cap and jitter and the library own max attempts. Values are implementation detail of that approved behavior; no separate question. Implementation task will name defaults.\n\nDispositions: #2 pending (D2). #3 accepted via D1 (A), carried forward. Security: no new auth or data-access boundary is introduced; the retry path reuses the existing payload fetch (performance implications in Section 4). Distribution: no new artifact.\n\n## Decision ledger\n\n### R1: Retry mechanism"
   },
   {
    "at": "2026-10-04T10:29:37.837Z",
    "old": "Accepted scope: Replace the inline per-worker scheduler (PLAN.md:7-9) with one custom backoff function registered on the job library's built-in retry hook. The function owns the curve: exponential base, delay cap and jitter. The library keeps attempt counting, attempt-state persistence across worker restarts, max-attempt cutoff and dead-lettering. Includes the code, tests and docs for that one function. R2, R3, R4 remain pending.\nHistory: none\n",
    "new": "Accepted scope: Replace the inline per-worker scheduler (PLAN.md:7-9) with one custom backoff function registered on the job library's built-in retry hook. The function owns the curve: exponential base, delay cap and jitter. The library keeps attempt counting, attempt-state persistence across worker restarts, max-attempt cutoff and dead-lettering. Includes the code, tests and docs for that one function. R2, R3, R4 remain pending.\nHistory: none\n\n### R5: Webhook delivery guarantee under retry\nFinding: #2, P1, confidence 8/10, PLAN.md:17-19, reviewer: native (plan-eng-review)\nPlan baseline: original proposal — `processWebhookJob()` is rewritten to retry; the prior at-most-once guarantee is dropped with no replacement guarantee named (PLAN.md:17-19). Nothing approved for R5.\nRuntime evidence: unknown. Handler, HTTP client and receiver contracts are not in this repository. Industry practice (evidence notes): webhook delivery is at-least-once with a stable delivery id so receivers can dedupe.\nComparison grid:\n\n| Choice | Current | A | B | C |\n|---|---|---|---|---|\n| R5 webhook delivery guarantee | at-most-once today; plan drops it, replacement unspecified | at-least-once with a stable idempotency/delivery id sent on every attempt (header + body field), documented for receivers | at-most-once preserved: retry only failures that occur before the HTTP send is attempted; once a send is attempted, no retry (dead-letter instead) | at-least-once with no dedupe id, as the plan implies |\n| R1 retry mechanism | approved D1 (A) | unchanged | unchanged | unchanged |\n| R2 envelope duplication | pending | pending | pending | pending |\n| R3 regression coverage for the chosen guarantee | pending | pending (Section 3) | pending (Section 3) | pending (Section 3) |\n| R4 graph recompute | pending | pending | pending | pending |\n\nQuestion D2:\nD2 — What delivery guarantee does the webhook job keep once it can retry?\nProject/branch/task: `main` of the retry-framework plan; `processWebhookJob()` is rewritten and loses its at-most-once guarantee (PLAN.md:17-19).\nELI10: Today a webhook is sent at most once: if it fails, it is gone, but the receiver never sees a duplicate. Adding retries flips that: the receiver might now get the same event twice, for example when the POST lands but the worker dies before marking it done. You can either tell receivers \"you may see duplicates, here is an id so you can ignore the second one,\" keep the old promise by never retrying once a send was attempted, or retry blindly and hope receivers cope.\nStakes if we pick wrong: receivers double-process events (double charges, double emails), or you keep at-most-once and the reliability win from retries never reaches the webhook path.\nRecommendation: A because at-least-once plus a stable delivery id is the standard webhook contract and receivers can dedupe cheaply, while B gives up most of the reliability you are building this for.\nCompleteness: A=9/10, B=7/10, C=3/10\nPros / cons:\nA) At-least-once with idempotency id (recommended)\n  ✅ Retries apply to the whole webhook path, including transient receiver 5xx and network timeouts\n  ✅ Stable delivery id on every attempt lets receivers dedupe; this is the documented contract most webhook consumers expect (human: ~1 day / CC: ~15 min)\n  ❌ Receivers that ignore the id will see duplicates; the contract change must be documented and announced\nB) Preserve at-most-once\n  ✅ No behavior change visible to receivers; no duplicate risk and no receiver-side work\n  ✅ Retries still cover pre-send failures such as payload fetch or serialization errors (human: ~0.5 day / CC: ~10 min)\n  ❌ A receiver 503 or a timeout after send is final: the event is dead-lettered, so the webhook path gains almost nothing from this project\nC) At-least-once, no dedupe id (plan as written)\n  ✅ Smallest change: just let the library retry the existing handler as-is\n  ✅ No contract documentation or header work (human: ~2 hours / CC: ~5 min)\n  ❌ Duplicates are undetectable by receivers; the first incident is a double side effect with no way to reconcile\nNet: trading a documented, dedupe-able duplicate against either silent duplicates or a webhook path that cannot be retried.\nHeader: Webhook guarantee\nOptions:\nA) At-least-once + idempotency id (recommended)\n`processWebhookJob()` retries through the library hook (D1). Every attempt sends the same stable delivery id (header and body field) so receivers can dedupe; the contract change is documented for receivers. Completeness 9/10. Human: ~1 day / CC: ~15 min. Risk: receivers ignoring the id see duplicates. R2, R3, R4 remain pending.\nB) Preserve at-most-once\nRetries cover only failures before the HTTP send is attempted (payload fetch, serialization, auth). Once a send is attempted, no retry; failure goes to dead-letter. Receivers see no behavior change. Completeness 7/10. Human: ~0.5 day / CC: ~10 min. Risk: post-send transient failures are final. R2, R3, R4 remain pending.\nC) At-least-once, no dedupe id\nLet the library retry the existing handler unchanged. No delivery id, no contract documentation. Completeness 3/10. Human: ~2 hours / CC: ~5 min. Risk: undetectable duplicate side effects at receivers. R2, R3, R4 remain pending.\n\nState: pending\nActual answer: unanswered\nAccepted scope: none\nHistory: none\n"
   },
   {
    "at": "2026-10-04T10:30:44.867Z",
    "old": "Let the library retry the existing handler unchanged. No delivery id, no contract documentation. Completeness 3/10. Human: ~2 hours / CC: ~5 min. Risk: undetectable duplicate side effects at receivers. R2, R3, R4 remain pending.\n\nState: pending\nActual answer: unanswered\nAccepted scope: none\nHistory: none\n",
    "new": "Let the library retry the existing handler unchanged. No delivery id, no contract documentation. Completeness 3/10. Human: ~2 hours / CC: ~5 min. Risk: undetectable duplicate side effects at receivers. R2, R3, R4 remain pending.\n\nState: approved\nActual answer: A) At-least-once + idempotency id — D2 answer (AskUserQuestion, this session)\nAccepted scope: `processWebhookJob()` retries through the library hook (D1). Every attempt sends the same stable delivery id, as both a request header and a body field, generated once at enqueue time and stored with the job so it survives retries and restarts. The receiver-facing contract change (at-most-once to at-least-once with dedupe id) is documented. Includes the code, tests and docs for that behavior; the regression/acceptance assertions for this guarantee are settled in R3 (Section 3). R2, R3, R4 remain pending.\nHistory: none\n\n### R2: Retry envelope duplication across 5 workers\nFinding: #4, P2, confidence 7/10, PLAN.md:12-14, reviewer: native (plan-eng-review)\nPlan baseline: original proposal — the envelope (compute delay, log attempt, dispatch) is copy-pasted into 5 worker files and left duplicated (PLAN.md:12-14). D1 (A) already moves \"compute delay\" into one backoff function and \"dispatch\" into the library runner. What remains unassigned is \"log attempt\".\nRuntime evidence: unknown. The 5 worker files are not in this repository; \"5\" and the envelope contents come from the plan text. Line estimates below are labelled estimates.\nShared-code rubric:\n- Callers: 5 proposed worker files (PLAN.md:13), proposed callers labelled as plan assumptions, not verified source.\n- Reuse before extracting: the job library's failure/retry lifecycle events (rung 4) are the reuse target for attempt logging; no new helper is needed if the library emits them.\n- Helper size: one listener registered once at worker boot, logging job id, attempt number, next delay and error class.\n- Whole change (estimates): removes ~5 × 15–30 lines of inline envelope = ~75–150 lines; adds ~15–25 lines (backoff function, already approved in D1) + ~10–20 lines (listener). Net savings ~40–125 lines before tests. Tests may add ~40–80 lines total.\n- Blast radius of a shared failure: a broken listener loses retry logging for all workers but does not alter retry behavior, since the library still drives retries.\nComparison grid:\n\n| Choice | Current | A | B | C |\n|---|---|---|---|---|\n| R2 attempt-logging location | inline in each of 5 workers (duplicated, PLAN.md:12-14) | one listener on the library's failed/retry lifecycle event, registered once at worker boot; inline envelopes deleted from all 5 workers | a small shared `logRetryAttempt()` helper called from each of the 5 workers; inline envelopes deleted except the helper call | inline envelopes left duplicated in 5 workers, as planned (\"refactor later\") |\n| R1 retry mechanism | approved D1 (A) | unchanged | unchanged | unchanged |\n| R5 webhook guarantee | approved D2 (A) | unchanged | unchanged | unchanged |\n| R3 regression coverage | pending | pending | pending | pending |\n| R4 graph recompute | pending | pending | pending | pending |\n\nQuestion D3:\nD3 — Where does retry-attempt logging live once the library drives retries?\nProject/branch/task: `main` of the retry-framework plan; the retry envelope is copy-pasted into 5 worker files and the plan leaves it duplicated (PLAN.md:12-14).\nELI10: After D1 the library computes the delay and re-dispatches, so two of the three copy-pasted pieces disappear on their own. The third piece, \"log this attempt\", still has to live somewhere. Most job libraries fire an event every time a job fails and is scheduled to retry; one listener on that event logs every worker's attempts with zero code in the workers. The alternatives are a tiny shared function each worker calls, or leaving five copies and promising to clean up later.\nStakes if we pick wrong: five copies drift, one worker logs attempts differently or not at all, and the 3am incident has a hole exactly where the failing worker is.\nRecommendation: A because it uses an already-installed dependency (reuse ladder rung 4), needs no change inside the workers, and cannot drift across them.\nCompleteness: A=10/10, B=8/10, C=3/10\nPros / cons:\nA) One library lifecycle-event listener (recommended)\n  ✅ Zero retry code left in any worker; every worker's attempts logged identically from one place (human: ~2 hours / CC: ~5 min)\n  ✅ Uses the library's own failed/retry event, so logging stays correct even when a new worker is added later\n  ❌ Depends on the library emitting a usable event with attempt number and next delay; verify at implementation time\nB) Shared `logRetryAttempt()` helper called per worker\n  ✅ Works even if the library emits no retry event; explicit call site in each worker (human: ~3 hours / CC: ~10 min)\n  ✅ Single implementation, so log format cannot drift between workers\n  ❌ Every worker still carries a call and a new worker can forget it; one more seam to test per caller\nC) Leave the 5 inline copies, refactor later\n  ✅ No change to the 5 workers beyond removing the inline scheduler already approved in D1\n  ✅ Nothing new to learn or test right now (human: ~0 / CC: ~0)\n  ❌ \"Later\" rarely arrives; five copies drift and the duplication finding stands unresolved in the ship review\nNet: trading a dependency on one library event against carrying retry code in five workers that already should have none.\nHeader: Attempt logging\nOptions:\nA) Library event listener (recommended)\nRegister one listener on the job library's failed/retry lifecycle event at worker boot. It logs job id, attempt number, next delay and error class for every worker. Delete the inline envelope from all 5 workers (compute-delay and dispatch already move to the library under D1). Completeness 10/10. Human: ~2 hours / CC: ~5 min. Risk: library must emit the event with attempt data; verify at implementation. R3, R4 remain pending.\nB) Shared logRetryAttempt() helper\nCreate one small helper that logs job id, attempt number, next delay and error class; each of the 5 workers calls it from its failure path. Delete the rest of the inline envelope. Completeness 8/10. Human: ~3 hours / CC: ~10 min. Risk: a new worker can forget the call; one caller-integration test per worker. R3, R4 remain pending.\nC) Leave duplication, refactor later\nKeep the per-worker attempt logging in all 5 workers as planned (PLAN.md:13-14); only the inline scheduler approved in D1 is removed. Completeness 3/10. Human: ~0 / CC: ~0. Risk: copies drift; finding stays open. R3, R4 remain pending.\n\nState: pending\nActual answer: unanswered\nAccepted scope: none\nHistory: none\n"
   },
   {
    "at": "2026-10-04T10:31:04.953Z",
    "old": "## Decision ledger\n\n### R1: Retry mechanism",
    "new": "## Section 2: Code quality review\n\nFindings:\n4. **[P2] (confidence: 7/10) PLAN.md:12-14 — Retry envelope copy-pasted across 5 workers and deliberately left duplicated.** Motivating lines: \"The retry envelope (compute delay, log attempt, dispatch) is duplicated / across 5 worker files with copy-pasted bodies. We will leave the / duplication for now and refactor \\\"later.\\\"\" Under D1 (A), compute-delay and dispatch already leave the workers; only attempt logging remains unassigned. Shared-code rubric evidence is in the R2 ledger record. Runtime evidence unknown (worker files not in repo); 7 because the 5-caller claim is the plan's own statement. Remedy: R2 / D3 below.\n5. **[P2] (confidence: 7/10) PLAN.md:17-18 — Rewriting `processWebhookJob()` and changing its delivery semantics in one step mixes refactor with behavior change.** Motivating line: \"The existing `processWebhookJob()` flow gets rewritten as part of this / change.\" Make-change-easy-first (Beck): land the mechanical move onto the library hook (D1) as its own commit with the existing behavior preserved, then land the at-least-once + delivery-id change (D2) as a second commit with its own tests (R3). Disposition: sequencing guidance carried into Implementation Tasks; no new behavior choice, so no question.\n6. **[P2] (confidence: 7/10) PLAN.md:7-9 — Error classification missing: the plan retries every failure the same way.** Motivating line: \"custom exponential-backoff scheduler ... full control over the curve.\" A 4xx from a webhook receiver (bad URL, revoked secret) or a malformed payload will never succeed on retry; retrying it burns the whole attempt budget and delays dead-lettering. Under D1 (A) the backoff function receives the error and can return the library's fail-now value for permanent errors. Disposition: covered by D1 (A) accepted scope (\"the function owns the curve\"), with the permanent-vs-transient split named as a required branch in Section 3's diagram and Implementation Tasks. No separate question.\n\nEdge cases and error handling flagged for implementation (no decision needed, carried into tasks): attempt number missing or 0 on the first failure; error object without a status code; delay cap smaller than base delay (misconfiguration); jitter producing a negative delay; job payload deleted between attempts (see Section 4).\n\nDispositions: #4 pending (D3). #5 accepted as sequencing guidance (no behavior choice). #6 accepted via D1 (A), carried forward.\n\n## Decision ledger\n\n### R1: Retry mechanism"
   }
  ]
 }
}