Skip to content

Return 410 for session-store calls after a stopped turn - #1155

Merged
NielsRogge merged 1 commit into
mainfrom
claude/session-store-revoked-410
Nov 23, 2026
Merged

NielsRogge merged 1 commit into
mainfrom
claude/session-store-revoked-410

Conversation

@NielsRogge

@NielsRogge NielsRogge commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Chat change: needs explicit authorization to merge and deploy.

The critical session_store_forbidden alert 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.
  • In _scope, a rejected session_store call 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.
  • The journal alert counts only 403 Forbidden on the session-store route, so a stopped turn no longer raises it.
  • Both worker clients already treat 410 as a non-retryable 4xx; only 408, 429 and 5xx are retried.
  • docs/autonomous-operations.md is updated.

Verification

  • New tests:
    • the gateway status matrix: deleted → 404, revoked → 410, otherwise 403, other scopes 403;
    • revoked() stays false for another turn, chat or scope.
  • chat_gateway, test_provider_contracts and test_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.
  • ruff, ruff-format and the comment ratchet pass.

🤖 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 validate rejects a session_store call, the gateway now uses _session_store_rejection to 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 toward session_store_forbidden.

Reviewed by Cursor Bugbot for commit 541e3c8. Bugbot is set up for automated code reviews on this repo. Configure here.

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>
@NielsRogge
NielsRogge merged commit 7ad43b8 into main Nov 23, 2026
6 checks passed
@NielsRogge
NielsRogge deleted the claude/session-store-revoked-410 branch November 23, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant