Repository navigation
Fix InMemoryMcpTaskStore TTL clocks, cancel CAS, and missing-task throws - #1965
Open
robertmclaws wants to merge 2 commits into
Open
robertmclaws wants to merge 2 commits into
robertmclaws wants to merge 2 commits into
Conversation
…ows (modelcontextprotocol#1963) Split work vs tracking windows, serve-and-drop terminal Gets, insert then sweep, honor CancellationToken, and treat missing mutations as no-ops.
This branch has not been deployed
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.
Fixes #1963.
InMemoryMcpTaskStoremixed work and tracking into oneCreatedAt + TTLclock, threw on missing mutations, could report a successful cancel that lost the CAS, swept the dictionary on the create thread before inserting, and ignoredCancellationToken.Changes
SetCancelledAsyncreturn value —transitionedis reset on the terminal/expired retry so a lost CAS against complete/fail no longer returnstrue.TryUpdatereturnsfalseinstead of throwing. Cancel returnsfalse; complete/fail/input are no-ops.IsActiveis the work window (CreatedAt + TTL). Never-terminal rows stay visible untilCreatedAt + 2×TTLso a late complete/fail/cancel can still be recorded. Terminal rows stay visible untilLastUpdatedAt + TTL.GetTaskAsyncserves a terminal snapshot and then drops the row. Null/non-positive TTL remains unlimited until a terminal get.GetTaskAsyncpulses the same throttled walk. Sweep removes onlyHasExpiredrows.TryUpdate, and during the sweep walk so a cancelled caller does not finish the dictionary scan or commit.Also adds a
TimeProviderconstructor (defaultTimeProvider.System) so TTL and sweep can be tested withFakeTimeProvider.Tests
xUnit coverage of
InMemoryMcpTaskStoreis 100% line and branch, including unhappy paths (missing keys, second-window work refused / settle allowed, serve-and-drop, cancelled tokens, CAS retry). Integration tests that polled a completed task and then got it again now expect the post-drop unknown-task error; cancel is still acknowledged and does not resurrect a row.