feat: overlay runtime cache configuration on defaults#68
Open
lan17 wants to merge 3 commits into
Open
Conversation
This was referenced Jul 19, 2026
lan17
marked this pull request as ready for review
July 19, 2026 17:56
The library has no consumers yet, and this error class was defined and exported but never thrown anywhere. Missing policy now resolves to the disabled baseline, so the class has no future use either. Packed consumer tests assert the export is gone from the type declarations and from the ESM and CommonJS runtime entries. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Combines runtime config overlays with the fallback deadline and coalescing state work from #69. Both cached() registration validations (defaultConfig snapshot and fallbackTimeoutMs) run before the use case name is registered. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 20, 2026
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.
Summary
Runtime cache configuration now overlays each cached definition's optional
defaultConfigfield by field. This makes a provider useful as a sparse operational control instead of forcing it to repeat the complete policy on every response.Missing policy is now an intentional disabled baseline: request-local caching defaults off, and process-local or Redis caching remains off until that layer has an effective TTL. A configured TTL with no ramp defaults to 100%.
Closes #23.
Resolution model
nullor defensiveundefinedundefinedrequestLocal: falseramp[layer]: 0policy_disabled100config_errorThe provider is still resolved once per enabled invocation, and the resulting effective configuration is used across request-local, process-local, and Redis lookup work.
Registration and mutation safety
cached()validates static defaults when the definition is registered. Static TTLs must be positive safe integers, ramps must be finite percentages from 0 through 100, layer maps must be objects, andrequestLocalmust be boolean when present.Registration captures and freezes an internal snapshot, so later mutation of the caller's
defaultConfigobject or maps cannot change a live use case. Dynamic overlays remain intentionally fail-open because they may come from runtime configuration systems.Public API and migration
No constructor option or policy object was added, and
defaultConfigremains optional. Existing TTL/ramp map shapes are unchanged.Observable changes:
DialCacheKeyConfig.requestLocalremainsundefineduntil config resolution; its effective default is stillfalse.{}or omission as a kill switch must use explicitrequestLocal: falseand/or per-layer ramp0.DisabledReasonreplacesmissing_configwithpolicy_disabled; dashboards and alerts must migrate that label value.MissingKeyConfigErroris removed from the public API. It was exported but never thrown, and missing policy no longer throws, so it is deleted rather than deprecated.cached()registration.There is no cache-key, Redis-key, Lua frame, serializer, adapter ownership, or client lifecycle change.
Runtime cost
The provider call count remains one per enabled invocation. The
null/undefinedprovider path reuses the immutable registration snapshot without a merge allocation. A non-null overlay creates one small normalized config and two bounded two-layer maps.Validation