Repository navigation
Batch 6c — Release plumbing, telemetry contract, refresh and layering correctness - #24
Merged
Merged
Conversation
Two gaps that no green check covered. The release workflow started Redis alone and then ran the integration suite. That suite is parameterized over every backend — SQL Server on 1433 and Cosmos on 8081 as well — and nothing in it skips a backend that is absent, so every SQL Server and Cosmos case failed and no push to release/** could reach the publish job. It now starts the same compose file pr.yml uses. Both samples still referenced src/ActionCache.csproj, a path the per-backend package split moved to src/ActionCache/ several batches ago, and they now need ActionCache.Redis as well since that is where UseRedisCache lives. samples/Api additionally failed six CS8618 under the repo-wide TreatWarningsAsErrors; its model properties default to string.Empty rather than being left unset. Nothing caught either because samples/ is deliberately outside ActionCache.slnx, which is also why the stale reference survived so long: the library's worked examples were broken in the one place a new user looks first, with every check green. A samples job in pr.yml now builds each of them. Claude-Session: https://claude.ai/code/session_01VUPTqPh5w79mfa18fLnMLz
…truments Batch 6b moved the namespace dimension to the unresolved template and moved actioncache.requests off the resilience decorator. Two instruments were missed, both in the way that batch had already diagnosed elsewhere. actioncache.single_flight.coalesced tagged (string)@namespace — the resolved, route-bound form. For [ActionCache(Namespace = "Account:{id}")] that is ActionCache:Account:42, one metric time series per account. It also carried the ActionCache: assembly prefix the other instruments do not, so the namespace dimension could not be grouped against actioncache.requests even for a namespace with no template at all. Both single-flight implementations now tag Namespace.Value. actioncache.evictions was recorded on ResilientActionCache, which decorates each backend individually while ActionCacheHandler fans a namespace eviction out to every layer. One [ActionCacheEviction] request against a Memory + Redis + SQL chain published three evictions: a count of backend calls, not of evictions — exactly what the request counter was moved off that decorator to fix. The eviction filters record it once per request instead. The test asserting the decorator records an eviction encoded the old contract and is replaced by one that drives the filter over a layered chain. Also: the Requests counter described itself as tagged by "outcome" when it emits "status", and the README's instrument table documented neither the outcome tag nor which instruments are per-request rather than per-operation. Claude-Session: https://claude.ai/code/session_01VUPTqPh5w79mfa18fLnMLz
…sing it
Body capture matched the first argument assignable to
IAcceptsMetadata.RequestType. The type does not identify the argument: in
MapPost("/echo/{name}", (string name, [FromBody] string payload) => ...)
the request type is string and so is the route value, so the match picked name.
Refresh then replayed the route value as the payload and wrote the response
computed for that different input back under the original key — a cache entry
silently corrupted by the mechanism meant to keep it fresh.
The handler's MethodInfo is in the endpoint metadata and its parameters line up
positionally with EndpointFilterInvocationContext.Arguments, so the body
parameter can be found rather than guessed: an explicit [FromBody] settles it,
otherwise it is the parameter of the accepted type that nothing else claims —
not bound from route, query, header, form or services, and not named after a
route token.
Where it still cannot be identified — no method metadata, arity that does not
line up, or two equally plausible candidates — nothing is recorded. Refresh
then skips the entry and logs that it did. That is the safe direction: a wrong
body corrupts the entry, a missing one only leaves it stale.
Three of the new tests fail against the previous implementation.
Claude-Session: https://claude.ai/code/session_01VUPTqPh5w79mfa18fLnMLz
…ation CreateHandler built the chain by calling SetNext repeatedly on the head handler. SetNext assigns Next and returns it, so each iteration wrote over the previous one and the chain came out as first -> last however many caches went in. Every layer between them was unreachable: never read, never written, never evicted, never refreshed, and absent from the GetKeysAsync union that eviction and refresh drive off. Entries there were served by nothing and cleared by nothing. Three or more instances is the shape that breaks, which happens two ways: three backends for one namespace, or a comma-separated namespace with two backends, which produces four. Two instances — the common single-namespace, two-backend setup — is the one arrangement that behaved, and the existing handler tests all chain exactly two, which is why this held up this long. Each layer now gets its own handler. Wrapping the tail as well is a passthrough: every ActionCacheHandler method delegates to its own cache and then to Next, and NextIfExists is a no-op when Next is null. Both new tests fail against the previous implementation — the union test sees KeyFirst and KeyLast but not KeyMiddle, and the write test finds the middle layer empty. Claude-Session: https://claude.ai/code/session_01VUPTqPh5w79mfa18fLnMLz
Same behaviour, two methods instead of four. The parameters are walked once
against a single predicate: an explicit [FromBody] settles it, otherwise the
body is the parameter of the accepted type that nothing else claims — not
bound from route, query, header, form or services, and not named after a route
token.
Drops the second matching strategy, which fell back to a unique type match
over the arguments when the handler's MethodInfo was missing or its arity did
not line up. Every Minimal API endpoint carries that metadata, so the fallback
only fired for shapes where the positional mapping was already untrustworthy.
Those now record nothing and refresh skips the entry, which is the same safe
direction the ambiguous case takes.
Also fills two holes the tests did not cover:
- The canonical MapPost("/todos", (Payload payload) => ...) — one unattributed
complex parameter, no route token. This is the shape Minimal APIs are built
around and the reason body capture cannot key off [FromBody] alone, and
nothing pinned it.
- The non-body binding source branch. IsBodyParameter rejects [FromQuery],
[FromHeader], [FromForm] and [FromServices], and no test reached it — the
one [FromBody] case returns from the branch above.
Reducing IsBodyParameter to [FromBody] alone fails five of the eleven cases,
so the inference is now held in place by tests rather than by argument.
Claude-Session: https://claude.ai/code/session_01VUPTqPh5w79mfa18fLnMLz
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.
A final review pass over Batches 6a and 6b (#21, #22, #23). Everything here sits in a gap the existing checks did not cover: the release workflow, the samples, two telemetry instruments, and two correctness bugs that only appear in shapes no test exercised.
Release plumbing
release.ymlstarted Redis alone and then ran the integration suite. That suite is parameterized over every backend — SQL Server on 1433 and Cosmos on 8081 as well — and nothing in it skips a backend that is absent, so every SQL Server and Cosmos case failed and no push torelease/**could reach the publish job. It now starts the same compose filepr.ymluses.Both samples still referenced
src/ActionCache.csproj, a path the per-backend package split moved tosrc/ActionCache/, and they needActionCache.Redistoo since that is whereUseRedisCachelives.samples/Apiadditionally failed sixCS8618under the repo-wideTreatWarningsAsErrors. Nothing caught either, becausesamples/is deliberately outsideActionCache.slnx— the worked examples were broken in the first place a new user looks, with every check green. Asamplesjob inpr.ymlnow builds each one.Telemetry contract
Batch 6b moved the namespace dimension to the unresolved template and moved
actioncache.requestsoff the resilience decorator. Two instruments were missed, both in ways that batch had already diagnosed elsewhere.actioncache.single_flight.coalescedtagged the resolved, route-bound namespace —ActionCache:Account:42, one time series per account. It also carried theActionCache:prefix the other instruments do not, so the dimension could not be grouped againstactioncache.requestseven with no template involved.actioncache.evictionswas recorded onResilientActionCache, which decorates each backend whileActionCacheHandlerfans a namespace eviction out to every layer. One[ActionCacheEviction]request against a three-backend chain published three evictions: a count of backend calls, not of evictions. The eviction filters record it once per request instead. The test asserting the decorator's behaviour encoded the old contract and is replaced by one driving the filter over a layered chain.Refresh: the Minimal API body parameter
Body capture matched the first argument assignable to
IAcceptsMetadata.RequestType. The type does not identify the argument:The request type is
stringand so is the route value, so the match pickedname. Refresh replayed the route value as the payload and wrote the response computed for that different input back under the original key — an entry silently corrupted by the mechanism meant to keep it fresh.The handler's
MethodInfois in endpoint metadata and its parameters line up positionally withArguments, so the body parameter is found rather than guessed. Where it still cannot be identified unambiguously, nothing is recorded: refresh then skips and logs, which leaves an entry stale rather than wrong.Layering: middle layers were dropped
CreateHandlerbuilt the chain by callingSetNextrepeatedly on the head handler.SetNextassignsNextand returns it, so each iteration wrote over the previous one and the chain came out as first -> last however many caches went in. Every layer between them was unreachable — never read, written, evicted or refreshed, and absent from theGetKeysAsyncunion eviction and refresh drive off.Three or more instances is the shape that breaks: three backends for one namespace, or a comma-separated namespace with two backends, which produces four. Two instances is the one arrangement that behaved, and the existing handler tests all chain exactly two.
Verification
dotnet build ActionCache.slnxThe refresh and layering fixes each ship regression tests confirmed to fail against the previous implementation.
Not addressed
Two findings from the same review, left out deliberately:
CachedResponseFactory.CreateRequesthard-codes the recordedContentTypeto JSON, so refresh is a permanent no-op for a[Consumes("application/xml")]or vendor-media-type endpoint.https://claude.ai/code/session_01VUPTqPh5w79mfa18fLnMLz