You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b49119b
Browse filesBrowse the repository at this point in the historyBrowse files
## What Problem This Solves
A durable inbound message can capture one session ID and reach reply admission after a concurrent reset or owner rotation commits a replacement session. The stale attempt fails before user-visible work with `Session changed while starting work. Retry.` and can keep the same ingress lane occupied across retries.
Fixes#135149.
## Root Cause
The dispatch pipeline reused its first session snapshot after the session owner changed. A repeated conflict then stayed under the generic retry rule, which requires both eight attempts and 24 hours before a terminal failure. The delayed head kept later updates in the same lane blocked. Telegram and grammY also wrap the original error twice, so top-level classification cannot identify the conflict.
## Fix
- Visible pre-dispatch invalidation now carries a typed owner signal.
- Dispatch rebuilds its complete state once from the durable session store.
- Actual stale ownership conflicts use a dedicated code; generic storage invalidations keep their existing retry behavior.
- The ingress retry owner follows nested error causes and terminates only the dedicated conflict at its configured attempt budget.
- Archived, tombstoned, heartbeat, and queued-followup behavior does not change.
- Generic transport failures retain the existing attempt-and-age rule.
## Evidence
- Current-main red at `f1fb06eef9b46b55359f27451c10f0ba0996b534`: the final test bytes showed release at the attempt budget, missing conflict codes at each owner, generic deterministic diff-baseline conflicts, no Telegram dead letter, and a blocked same-lane follower.
- Exact-head green at `1d0e517f412de0c6940ce6cbd03444285d5c6fb6`: all 328 focused tests passed with a disk-backed temporary directory.
- The Telegram regression drives the durable queue, monitor, grammY middleware, shared drain, nested error graph, terminal failed row, and following same-lane update.
- Generic diff-baseline read and persistence failures remain `SESSION_WORK_START_INVALIDATED` and do not take the attempt-only terminal path.
- Exact-head continuous integration is the final platform gate.
## Live-proof limitation
A public Telegram reset cancels the admitted turn, and message hooks run after admission, so neither can create this exact stale-start interleave. Direct database replacement would bypass the lifecycle owner under test. The deterministic Telegram E2E therefore drives the real durable queue, monitor, grammY wrapper graph, shared drain, terminal failed row, and same-lane follower without adding a production-only pause.
A Test Server run confirmed this boundary with a source Gateway and public `sessions.reset`: three real DM inputs reached the provider, the reset completed, and no stale-start conflict was emitted because reset ran after admission and canceled the in-flight lifecycle instead. This negative trace is retained privately. The requested positive live trace is skipped because no supported external control exists before admission; adding a production pause or mutating the session database directly would invalidate the owner-boundary proof.
## ClawSweeper rank-up moves
- Applied: stale ownership conflicts now have a dedicated code; storage failures retain the generic retry policy.
- Applied: exact-head required checks completed successfully.
- Skipped with proof: a positive Test Server stale-start trace is not safely reachable through public controls; the real attempt exercised the distinct reset-cancellation path described above.
## Worked on by
- @brettdaman
- @obviyus
Co-authored-by: Ayaan Zaidi <[email protected]>
0 commit comments