Repository navigation
Return 410 for session-store calls after a stopped turn - #1155
Merged
Merged
Conversation
Pressing stop revokes the turn capability while the chat still exists, so the worker's next transcript write got 403 and raised the critical session_store_forbidden alert (2026-11-23 10:11). A rejected session-store capability now returns 410 when the token's own capability for that chat, turn and scope was revoked, alongside the existing 404 for a deleted chat. Every other rejection stays 403, and the worker already treats 410 as a non-retryable 4xx. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Chat change: needs explicit authorization to merge and deploy.
The critical
session_store_forbiddenalert fired again at 10:11 UTC on 2026-11-23, after #1137. A user stopped a new chat at 10:10:55, which revokes the turn's capability while the chat still exists. The worker's next transcript write at 10:10:58 got 403. #1137 only covered deleted chats, which return 404.Change
ChatCapabilityService.revoked(token, scope, chat_session_id, turn_id)returns true only when that token's own capability matches the chat, turn and scope and was revoked._scope, a rejectedsession_storecall now returns 410 "Chat turn has ended" for a revoked capability and 404 for a deleted chat. Everything else, including other scopes and expired or mismatched tokens, stays 403.403 Forbiddenon the session-store route, so a stopped turn no longer raises it.docs/autonomous-operations.mdis updated.Verification
revoked()stays false for another turn, chat or scope.chat_gateway,test_provider_contractsandtest_operational_alerts: 272 passed. 24 failed, and origin/main fails the same 24 here: the stale-fence path writes a qualification event, and the conftest guard refuses the live database.🤖 Generated with Claude Code
Note
Low Risk
Narrow HTTP semantics change on session-store rejection paths; workers already treat 410 as non-retryable 4xx per the PR description.
Overview
Stopped turns no longer surface as generic capability failures on session-store writes. When
validaterejects asession_storecall, the gateway now uses_session_store_rejectionto return 404 if the chat was deleted, 410 (Chat turn has ended) if the token’s capability for that session/turn was revoked, and 403 otherwise. Other scopes still get 403 only.ChatCapabilityService.revoked()was added to detect a matching revoked capability (same token hash, session, turn, and scope) without going through validation.Tests cover the status matrix and
revoked()scoping; autonomous-operations docs note that only true 403s count towardsession_store_forbidden.Reviewed by Cursor Bugbot for commit 541e3c8. Bugbot is set up for automated code reviews on this repo. Configure here.