Skip to content

feat(LLMsDocsCli): auto no-cache when not found component - #1273

Merged
ArgoZhang merged 2 commits into
masterfrom
dev-cli
Oct 30, 2026
Merged

ArgoZhang merged 2 commits into
masterfrom
dev-cli

Conversation

@ArgoZhang

@ArgoZhang ArgoZhang commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Link issues

fixes #1272

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Automatically retry component lookups against a refreshed index when cached index data is stale.

New Features:

  • Automatically refresh the remote component index once when a requested component is missing from a fresh cached index.

Enhancements:

  • Preserve normal document caching while avoiding redundant index refreshes for explicit refreshes, uncached requests, and local directories.

Build:

  • Update the LLMs Docs CLI project configuration.

Documentation:

  • Document the automatic index refresh behavior and its caching conditions.

@sourcery-ai

sourcery-ai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The CLI now recovers from stale remote index caches by forcing one index refresh when a requested component is not found, while preserving existing cache, local-source, and explicit refresh semantics; documentation and project configuration were updated accordingly.

Sequence diagram for automatic index refresh on missing component

sequenceDiagram
    participant CLI as LLMsDocsClient
    participant Cache as IndexCache
    participant Remote as RemoteDocs

    CLI->>Cache: TryReadFreshCache(llms.txt)
    Cache-->>CLI: Cached index
    CLI->>CLI: ParseIndex(index)
    alt Component found
        CLI-->>CLI: Return component document
    else Component missing from cached index
        CLI->>Remote: FetchAsync(llms.txt, ct, refresh: true)
        Remote-->>CLI: Refreshed index
        CLI->>CLI: ParseIndex(refreshed index)
        alt Component found after refresh
            CLI-->>CLI: Return component document
        else Component still missing
            CLI-->>CLI: throw FileNotFoundException
        end
    end
Loading

Flow diagram for component lookup cache behavior

flowchart TD
    A[GetComponentAsync] --> B{Remote source using cache?}
    B -->|No| C[GetIndexAsync]
    B -->|Yes| D[TryReadFreshCache]
    D --> E{Component in index?}
    E -->|Yes| F[Fetch component document]
    E -->|No| G[FetchAsync with refresh: true]
    G --> H{Component in refreshed index?}
    H -->|Yes| F
    H -->|No| I[FileNotFoundException]
    C --> J{Component in index?}
    J -->|Yes| F
    J -->|No| I
Loading

File-Level Changes

Change Details Files
Automatically refresh the remote index once when a component is absent from a fresh cached index.
  • Read and track whether the initial index came from a usable cache entry.
  • On a cache miss for the requested component, bypass the cache, fetch the latest index, and retry lookup.
  • Preserve existing not-found errors when the refreshed index also lacks the component.
  • Avoid the fallback for local sources, explicit refresh/no-cache flows, and already refreshed indexes.
tools/BootstrapBlazor.LLMsDocs.Cli/Services/LlmsDocsClient.cs
Document the new automatic index refresh behavior and its caching boundaries.
  • Explain the one-time fallback refresh when a cached index lacks a component.
  • Clarify interactions with explicit refresh/no-cache options, local directories, and document-content caching.
  • Note that the behavior requires a CLI version containing the feature.
tools/BootstrapBlazor.LLMsDocs.Cli/README.md
Update the CLI project configuration.
  • Apply the project-file change associated with the feature release/build configuration.
tools/BootstrapBlazor.LLMsDocs.Cli/BootstrapBlazor.LLMsDocs.Cli.csproj

Assessment against linked issues

Issue Objective Addressed Explanation
#1272 When get cannot find a component in a cached index, refresh the remote index once and retry before reporting that the component is missing. ✅
#1272 Avoid redundant automatic refreshes when the index was already fetched fresh, caching is disabled, a manual refresh was requested, or the source is local. ✅

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto Bot added the enhancement New feature or request label Oct 30, 2026
@bb-auto bb-auto Bot added this to the v10.0.0 milestone Oct 30, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

@ArgoZhang
ArgoZhang merged commit 35e1b2f into master Oct 30, 2026
3 checks passed
@ArgoZhang
ArgoZhang deleted the dev-cli branch October 30, 2026 06:53

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tools/BootstrapBlazor.LLMsDocs.Cli/Services/LlmsDocsClient.cs" line_range="84" />
<code_context>
             .FirstOrDefault(e => string.Equals(e.Name, name, StringComparison.OrdinalIgnoreCase));
+        if (entry is null && usedCachedIndex)
+        {
+            entry = ParseIndex(await FetchAsync("llms.txt", ct, refresh: true))
+                .FirstOrDefault(e => string.Equals(e.Name, name, StringComparison.OrdinalIgnoreCase));
+        }
</code_context>
<issue_to_address>
**Stale indexes stay fresh**

When concurrent refreshes fetch different index revisions, `WriteContent` can overwrite a newer `llms.txt` body or pair an older body with newer metadata; a later 304 then treats that stale body as fresh for 24 hours, so `get` misses newly published components.

Serialize refreshes for each shared index and commit its body and metadata together, so concurrent responses cannot overwrite or mix revisions.
</issue_to_address>

### Comment 2
<location path="tools/BootstrapBlazor.LLMsDocs.Cli/Services/LlmsDocsClient.cs" line_range="74-77" />
<code_context>

-        var entry = ParseIndex(await GetIndexAsync(ct))
+        var index = "";
+        var usedCachedIndex = _useCache && !_refresh && TryReadFreshCache("llms.txt", out index);
+        if (!usedCachedIndex)
+        {
+            index = await GetIndexAsync(ct);
+        }
+
</code_context>
<issue_to_address>
**Concurrent cache update skips retry**

When another process writes a fresh index containing no requested component between the initial cache check and `GetIndexAsync`'s cache check, `GetIndexAsync` can read a newly written cache after the initial check misses, while `usedCachedIndex` remains false; if that index lacks the requested name, `GetComponentAsync` skips the automatic refresh and reports the component as not found.

Use the cache result and its provenance from a single lookup, or ensure that a miss on the initial lookup forces the subsequent index fetch to bypass cache.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

.FirstOrDefault(e => string.Equals(e.Name, name, StringComparison.OrdinalIgnoreCase));
if (entry is null && usedCachedIndex)
{
entry = ParseIndex(await FetchAsync("llms.txt", ct, refresh: true))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Stale indexes stay fresh

When concurrent refreshes fetch different index revisions, WriteContent can overwrite a newer llms.txt body or pair an older body with newer metadata; a later 304 then treats that stale body as fresh for 24 hours, so get misses newly published components.

Serialize refreshes for each shared index and commit its body and metadata together, so concurrent responses cannot overwrite or mix revisions.

Prompt for AI agents
In `tools/BootstrapBlazor.LLMsDocs.Cli/Services/LlmsDocsClient.cs` at line 84:

**Stale indexes stay fresh**

When concurrent refreshes fetch different index revisions, `WriteContent` can overwrite a newer `llms.txt` body or pair an older body with newer metadata; a later 304 then treats that stale body as fresh for 24 hours, so `get` misses newly published components.

Serialize refreshes for each shared index and commit its body and metadata together, so concurrent responses cannot overwrite or mix revisions.

Comment on lines +74 to +77
var usedCachedIndex = _useCache && !_refresh && TryReadFreshCache("llms.txt", out index);
if (!usedCachedIndex)
{
index = await GetIndexAsync(ct);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Concurrent cache update skips retry

When another process writes a fresh index containing no requested component between the initial cache check and GetIndexAsync's cache check, GetIndexAsync can read a newly written cache after the initial check misses, while usedCachedIndex remains false; if that index lacks the requested name, GetComponentAsync skips the automatic refresh and reports the component as not found.

Use the cache result and its provenance from a single lookup, or ensure that a miss on the initial lookup forces the subsequent index fetch to bypass cache.

Prompt for AI agents
In `tools/BootstrapBlazor.LLMsDocs.Cli/Services/LlmsDocsClient.cs` at lines 74-77:

**Concurrent cache update skips retry**

When another process writes a fresh index containing no requested component between the initial cache check and `GetIndexAsync`'s cache check, `GetIndexAsync` can read a newly written cache after the initial check misses, while `usedCachedIndex` remains false; if that index lacks the requested name, `GetComponentAsync` skips the automatic refresh and reports the component as not found.

Use the cache result and its provenance from a single lookup, or ensure that a miss on the initial lookup forces the subsequent index fetch to bypass cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(LLMsDocsCli): auto no-cache when not found component

1 participant