Repository navigation
fix: preserve hook retries during first session creation - #167629
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesWebhook retries retain the database identity observed by the session read worker, avoiding false failures when the first session database is created before that read. Example: A webhook retry waits while an earlier request creates its destination database.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR remains useful: current main retains the failing capture behavior, and the narrow repair preserves the existing ownership checks. No actionable patch defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway webhooks submit work to ordinary session execution. Session capture reads the destination through a worker and retains its physical database identity so delayed work cannot move to replacement storage. flowchart TD
A[Webhook retry] --> B[Capture session destination]
B --> C[Worker reads session database]
C --> D[Retain observed database identity]
D --> E{Source and session still current?}
E -->|Yes| F[Accept ordinary session work]
E -->|No| G[Reject changed destination]
Technical reviewBest possible solution: Keep receipt propagation in the existing worker reader and event-capture owners while preserving their current source and lifecycle fences. Do we have a high-confidence way to reproduce the issue? Yes, the source establishes the race: capture retains an absent-path identity, the worker reads a newly created database, and the final identity check rejects it. The contributor reports a failing original-owner regression; this review did not execute tests. Is this the best way to solve the issue? Yes, preserving the worker's already-validated receipt fixes the stale capture at its owner without retries, another reader, or weakened replacement checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f02f2de69516. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +22, Tests +63, Docs +3. Total +88 across 6 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (5 earlier review cycles)
Reviewed October 9, 2026, 4:23 AM ET / 08:23 UTC (Revision 6). |
Carry the read worker source receipt into event capture instead of retaining stale pre-read absence. Preserve existing file and alias fences, including refusal of creation after an absent read. The regression fails on the original owner and passes after the repair; the HTTP hook retry also passes. No schema, permission, or update migration changes.
c8ce9d1 to
88395fb
Compare
…7629) * fix: preserve hook retries during first session creation Carry the read worker source receipt into event capture instead of retaining stale pre-read absence. Preserve existing file and alias fences, including refusal of creation after an absent read. The regression fails on the original owner and passes after the repair; the HTTP hook retry also passes. No schema, permission, or update migration changes. * refactor(sessions): reuse the worker source receipt type
What Problem This Solves
Fixes a webhook retry returning HTTP 502 when an earlier failed hook creates the event destination while the retry is waiting for a cold session read.
User Impact
A retry can capture the file actually read by the worker. A file created after an absent read, replaced after capture, or retargeted through an alias remains refused. Typed admission errors and retryable idempotency are preserved. No schema, configuration, or update migration is required.
Why This Change Was Made
The read worker already returns its admitted physical-source receipt. Preserve that receipt through the entry-result projection and bind the event target to it instead of retaining a stale pre-read absence identity.
Evidence
The original HTTP failure was bisected to #167515 and diagnosed as
Session event destination storage changed after capture. On Linux Testbox, the new before-read creation regression fails on the original owner (23/24 pass), then all 24 handoff cases pass with the repair; creation after an absent read remains rejected. The independent HTTP hook file passes 8/8, and four reader/permission/artifact sibling files pass.pnpm test src/auto-reply/reply/session-event-handoff.test.ts --maxWorkers=1validation cost: 26.67s before and 22.59s after including worker preparation (Vitest 11.74s and 7.77s). This is validation timing, not a performance claim. On main at50dd07c229e2, the original Gateway group still failed the conversation observer and hook retry (41/43 pass). Applying the remaining fixture corrections and this hook repair passed all 80 tests across the six original files and handoff suite in 178.86s. The independent recovery repair is already on main ina73ef559b23a, and the quarantine observer repair is on main in18cade08699b.P2 Codex reviews are clean for the runtime change and type-only follow-up. The rebase preserves all added/removed lines; only the documentation hunk moved. Core types, all 27 core test typecheck graphs, ordinary lint, boundary lint, schema and remaining static guards pass.
check-changedstops at four pre-existing dead exports:bindCliQuestionAnswerAuthority, theprepareSessionEventTargetForHostre-export, thereadSessionEntryCreationTransitionre-export, andRESTART_CONTINUATION_CONTEXT_PREFIX; their declarations are unchanged.This PR now contains only the hook source-receipt repair and its regression cases. It remains a draft with auto-merge disabled.