Skip to content

fix: preserve hook retries during first session creation - #167629

Merged
steipete merged 3 commits into
mainfrom
ci/fix5-hook-capture-20261009
Oct 9, 2026
Merged

steipete merged 3 commits into
mainfrom
ci/fix5-hook-capture-20261009

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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=1 validation 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 at 50dd07c229e2, 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 in a73ef559b23a, and the quarantine observer repair is on main in 18cade08699b.

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-changed stops at four pre-existing dead exports: bindCliQuestionAnswerAuthority, the prepareSessionEventTargetForHost re-export, the readSessionEntryCreationTransition re-export, and RESTART_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.

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: S labels Oct 9, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Webhook 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.

  • Before: The retry can return HTTP 502 with “Session event destination storage changed after capture.”
  • After: The retry accepts the database read by the worker, while creation after an absent read remains rejected.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is narrow and coherent, with meaningful reported regression validation and harness-level behavior evidence.
Proof confidence 🦐 gold shrimp (3/6) The recorded maintainer association exempts this PR from the external-contributor proof gate. The reported Linux validation exercises the changed capture owner with native workers and paired creation timing, supplemented by HTTP retry coverage; no standalone Gateway trace was supplied. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A webhook retry can fail with HTTP 502 while an earlier failed request creates its session destination.
Reason: The repair restores retryable admission under the existing event identity contract. Prior merged history establishes the author's ownership of this area, and the change adds no product or configuration surface.

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
Reviewed head: eaa0f908f282ee3c0f2bba3e666aad54b4392202

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A standalone running-Gateway trace of the before-read creation race is not supplied; the available validation exercises native workers and Gateway HTTP behavior through test harnesses.
Agent review details

How this fits together

Gateway 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]
Loading

Technical review

Best 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

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Introduced repair: The pinned introduced diff carries the existing worker source receipt through the result projection and reader owner into event capture; it adds no alternate reader or admission owner. (src/auto-reply/reply/session-event-target.ts:159, eaa0f908f282)
  • Still necessary on current main: Current main still retains preparedSource.identity without the worker receipt. None of the six touched paths changed between the pinned base and fetched main, so subsequent main work does not supply this repair. (src/auto-reply/reply/session-event-target.ts:159, f02f2de69516)
  • Receipt validation: The existing history runtime checks the receipt's agent and path, retains its physical identity, and verifies that identity before returning results. Event capture and later preparation continue checking file identity, aliases, lifecycle, and caller authority. (src/config/sessions/session-transcript-worker-runtime.ts:318, eaa0f908f282)
  • Meaningful regression coverage: The new paired cases use the real read worker and native database, injecting creation before or after its read. They verify successful capture and subsequent preparation for before-read creation, and rejection for after-read creation. (src/auto-reply/reply/session-event-handoff.test.ts:217, eaa0f908f282)
  • Reported before-and-after validation: The fully inspected PR body reports the original owner failing the new regression, then all 24 handoff cases passing, alongside eight HTTP-hook cases and reader/permission/artifact siblings. These are contributor-reported harness results; no tests were executed during this read-only review. (eaa0f908f282)
  • Existing product contract and ownership: The merged refactor: run immediate notifications through ordinary session execution #167113 establishes ordinary event execution with retained physical identity, permission ceilings, and reset/replacement refusal. History connects the current capture path to that work and shows Peter Steinberger's extensive prior maintenance of the reader area. (src/auto-reply/reply/session-event-target.ts:158, 753a7a57be10)

Likely related people:

  • Peter Steinberger: Raw commit 753a7a5 adds src/auto-reply/reply/session-event-target.ts:158 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 753a7a57be10; files: src/auto-reply/reply/session-event-target.ts)

PR surface

Source +22, Tests +63, Docs +3. Total +88 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 30 8 +22
Tests 1 63 0 +63
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 96 8 +88

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +30/-8; tests +63/-0 The bounded production growth carries an existing receipt across projections, with regression coverage for both sides of the creation boundary.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The repair addresses a bounded webhook retry failure during first-session database creation.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Optionally record a redacted running-Gateway retry trace showing successful acceptance when destination creation finishes before the worker read.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (5 earlier review cycles)
  • reviewed 2026-10-09T05:30:09.721Z sha c8ce9d1 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T05:36:47.828Z sha c8ce9d1 :: needs changes before merge. :: none
  • reviewed 2026-10-09T05:58:25.212Z sha c8ce9d1 :: needs changes before merge. :: none
  • reviewed 2026-10-09T06:55:36.134Z sha 88395fb :: needs maintainer review before merge. :: none
  • reviewed 2026-10-09T08:09:25.788Z sha 88395fb :: needs maintainer review before merge. :: none

Reviewed October 9, 2026, 4:23 AM ET / 08:23 UTC (Revision 6).

@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
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.
@steipete
steipete force-pushed the ci/fix5-hook-capture-20261009 branch from c8ce9d1 to 88395fb Compare October 9, 2026 06:50
@openclaw-barnacle openclaw-barnacle Bot removed gateway Gateway runtime agents Agent runtime and tooling labels Oct 9, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 9, 2026
@steipete
steipete marked this pull request as ready for review October 9, 2026 08:05
@steipete
steipete enabled auto-merge (squash) October 9, 2026 08:05
@steipete
steipete merged commit c7b1f7a into main Oct 9, 2026
120 checks passed
@steipete
steipete deleted the ci/fix5-hook-capture-20261009 branch October 9, 2026 08:25
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant