[ML-858] docs: align docs with implementation#70
Merged
Conversation
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
There was a problem hiding this comment.
Pull request overview
Updates user-facing documentation to match the SDK’s actual cache eviction behavior and the current prompt management API surface, reducing docs-to-code drift for SDK consumers.
Changes:
- Corrects in-memory cache eviction description to reflect expiration-ordered bounded eviction (not LRU).
- Updates
ApiClient.newarchitecture example to the current keyword-argument constructor. - Extends the API reference to document
Client#create_promptandClient#update_prompt.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs/CACHING.md | Updates caching backend descriptions, especially in-memory eviction behavior. |
| docs/ARCHITECTURE.md | Aligns the ApiClient construction example and cache eviction wording with implementation. |
| docs/API_REFERENCE.md | Adds missing reference sections for prompt creation and label updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ment Folds in the drift fixes from #72 (ML-896) and #73 (ML-931) on top of #70: - SWR is gated on `cache_stale_ttl > 0`; `cache_stale_while_revalidate` is advisory only. Clarified in CONFIGURATION.md, CACHING.md, and the API_REFERENCE.md parameter table. - `get_prompt` `fallback` accepts `String` or `Array<Hash>`; documented in API_REFERENCE.md. - `cache_stale_ttl` accepts `:indefinite`; reflected in the parameter table. - Omitting `version` and `label` sends no selector — the Langfuse API decides. Corrected PROMPTS.md best practices, API_REFERENCE.md example comment, docs/CACHING.md cache-warming example, and the CacheWarmer YARD example. - CHANGELOG.md entry now reflects bounded expiration-ordered eviction (not LRU), matching the CACHING.md/ARCHITECTURE.md fix already in this PR.
This was referenced Apr 11, 2026
Copilot review correctly flagged the overview sentence as misleading — it implied the in-memory cache has no stampede protection, but PromptCache uses Monitor-based single-flight locks (prompt_cache.rb:82) and StaleWhileRevalidate#schedule_refresh gates background refresh on the same locks (stale_while_revalidate.rb:141). The distinction is distributed vs. intra-process, not "has it" vs. "doesn't."
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.
TL;DRConsolidated docs-alignment PR covering every known drift between
docs/(and YARD) and the current implementation. Supersedes #72 and #73.WhyThree separate Linear issues (ML-858, ML-896, ML-931) each flagged overlapping drift across the same doc files. Shipping one consolidated PR eliminates merge conflicts and keeps the history clean.
ChecklistSummary
Cache eviction (
docs/CACHING.md,docs/ARCHITECTURE.md,CHANGELOG.md)stale_untilwhenmax_sizeis reached (lib/langfuse/prompt_cache.rb:238-244).ApiClientconstructor (docs/ARCHITECTURE.md)public_key:,secret_key:,base_url:,timeout:,logger:,cache:(lib/langfuse/api_client.rb:52-59).Prompt API surface (
docs/API_REFERENCE.md)Client#create_promptandClient#update_promptsections with full signature, params, raises, and examples.get_promptfallbacktype toStringorArray<Hash>(chat fallback was always supported).# Latest versionto# API default selection (no version/label sent).cache_stale_while_revalidateparameter-table description to "advisory SWR intent flag".cache_stale_ttlparameter-table type toInteger or :indefinite.SWR activation (
docs/CONFIGURATION.md,docs/CACHING.md)cache_stale_while_revalidatedoes not gate SWR. SWR is active whencache_stale_ttl > 0(lib/langfuse/stale_while_revalidate.rb:102-104,lib/langfuse/config.rb).cache_stale_while_revalidatesection in CONFIGURATION.md to describe it as an advisory intent flag.cache_stale_ttl = 0(the actual off switch).Prompt selection semantics (
docs/PROMPTS.md,docs/API_REFERENCE.md,docs/CACHING.md,lib/langfuse/cache_warmer.rb)versionandlabelsends no selector to the API — the server decides which version to return (lib/langfuse/api_client.rb:738-740). The SDK does not auto-inject"production".label: "production"in production and frame implicit selection as API-defined.docs/CACHING.mdand theCacheWarmer#warm_allYARD example that previously claimed omitting the label fetched "latest versions".Fixes Addressed
ApiClientconstructor example used an outdated positional signature.create_prompt/update_promptand under-specifiedfallback/cache_stale_ttltypes.CacheWarmer#warm_all.Validation Checklist
bundle exec rspec— 1198 examples, 0 failures related to this change (2 pre-existing failures caused byLANGFUSE_HOSTenv var pointing to staging; docs-only changes don't affect them)bundle exec rubocop— cleanString-only fallback, positionalApiClient.new, missing prompt-mutation methods) — no further instances found