Skip to content

Batch 6c — Release plumbing, telemetry contract, refresh and layering correctness - #24

Merged
jzills merged 5 commits into
developfrom
fix/batch-6c-review-followups
Aug 23, 2026
Merged

jzills merged 5 commits into
developfrom
fix/batch-6c-review-followups

Conversation

@jzills

@jzills jzills commented Aug 23, 2026

Copy link
Copy Markdown
Owner

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.yml 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/, and they need ActionCache.Redis too since that is where UseRedisCache lives. samples/Api additionally failed six CS8618 under the repo-wide TreatWarningsAsErrors. Nothing caught either, because samples/ is deliberately outside ActionCache.slnx — the worked examples were broken in the first place a new user looks, with every check green. A samples job in pr.yml now builds each one.

Telemetry contract

Batch 6b moved the namespace dimension to the unresolved template and moved actioncache.requests off the resilience decorator. Two instruments were missed, both in ways that batch had already diagnosed elsewhere.

actioncache.single_flight.coalesced tagged the resolved, route-bound namespace — ActionCache:Account:42, one time series per account. It also carried the ActionCache: prefix the other instruments do not, so the dimension could not be grouped against actioncache.requests even with no template involved.

actioncache.evictions was recorded on ResilientActionCache, which decorates each backend while ActionCacheHandler fans 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:

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 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 MethodInfo is in endpoint metadata and its parameters line up positionally with Arguments, 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

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, written, evicted or refreshed, and absent from the GetKeysAsync union 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

Check Result
dotnet build ActionCache.slnx Clean, 0 warnings
Samples build Both succeed (were broken)
Unit 513/513, net8.0 and net10.0
Integration net8.0 53/53
Integration net10.0 53/53

The 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.CreateRequest hard-codes the recorded ContentType to JSON, so refresh is a permanent no-op for a [Consumes("application/xml")] or vendor-media-type endpoint.
  • Request bodies for non-vary-by POSTs are stored verbatim in the cache, while the README's "Cache Keys" section still presents key hashing as closing that exposure. The observability table is updated here; that section is not.

https://claude.ai/code/session_01VUPTqPh5w79mfa18fLnMLz

jzills added 5 commits August 23, 2026 13:54
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
@jzills
jzills merged commit 1209ea6 into develop Aug 23, 2026
9 of 10 checks passed
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