# KnowledgeService

- File ID: file:27eki7:knowledgeservice-cs
- Path: NexusReader.Infrastructure/Services/KnowledgeService.cs
- Role: service
- Layer: infrastructure

## Purpose

Infrastructure implementation of IKnowledgeService: orchestrates retrieval/creation of structured knowledge from text using AI, caches results in Postgres, de-duplicates concurrent requests, stores/updates KnowledgeUnits and links, and provides RAG search/grounding via Qdrant + Neo4j.

## Key Details

Central service for converting raw text into structured KnowledgePacket via LLM, avoids duplicate concurrent AI requests using _activeRequests, caches JSON responses with a PromptVersion check, persists/upserts KnowledgeUnits and links, performs retrieval via Qdrant and graph expansion via Neo4j, and enforces strict JSON grounding in QA flow.

## Symbols

- KnowledgeService: Infrastructure implementation of IKnowledgeService: orchestrates retrieval/creation of structured knowledge from text using AI, caches results in Postgres, de-duplicates concurrent requests, stores/updates KnowledgeUnits and links, and provides RAG search/grounding via Qdrant + Neo4j.
- KnowledgeService(): Constructor wiring dependencies, configuring retry pipeline and tokenizer
- GetKnowledgeAsync(): Public entry that requests full knowledge extraction using internal routine
- GetGraphDataAsync(): Public entry that requests graph-structured extraction
- GetSummaryAndQuizAsync(): Public entry for summary + quiz extraction
- GetKnowledgeMapAsync(): Public entry for knowledge map extraction
- GetKnowledgeInternalAsync(): Core flow: validate input, check cache, deduplicate concurrent requests, and invoke AI + caching if needed
- ExecuteAiRequestAndCacheAsync(): Invokes AI via chat client with retries, repairs/deserializes JSON, caches the response in DB and processes KnowledgeUnits
- ProcessKnowledgeUnitsAsync(): Upserts KnowledgeUnit entities and KnowledgeUnitLink entities from parsed KnowledgePacket into the relational DB
- VerifyGroundednessAsync(): Asks AI to score whether an answer is grounded in given context and returns structured groundedness result
- GetRelevantContextAsync(): Generates embedding for query, searches Qdrant for top context points (tenant or global) and returns RelevantContext list
- SearchLibrarySemanticallyAsync(): Performs semantic search: embedding generation, Qdrant retrieval, optional Neo4j graph expansion, enrich with ebook titles from Postgres, and map to DTOs
- AskQuestionAsync(): RAG question-answering flow: embed question, retrieve top contexts from Qdrant, optionally expand via Neo4j, fetch ebook titles, build grounding prompt, call chat AI with strict JSON response expectations, and hydrate citation book titles
- ClearCacheAsync(): Deletes all entries from SemanticKnowledgeCache, KnowledgeUnits and KnowledgeUnitLinks tables
- EstimateTokenCount(): Estimates token count for a string using configured tokenizer

## Dependencies

- imports NexusReader.Infrastructure/Helpers/ContentHasher.cs
- imports NexusReader.Infrastructure/Helpers/JsonRepairHelper.cs

## Calls

- No resolved calls.

## Unresolved References

- dependency-target: NexusReader.Application.DTOs.AI (KnowledgePacket, GroundednessResult, RelevantContext, SemanticSearchResultDto, GroundedResponseDto, CitationDto)
- dependency-target: NexusReader.Data.Persistence/AppDbContext.cs
- dependency-target: NexusReader.Domain/Entities (KnowledgeUnit, KnowledgeUnitLink, SemanticKnowledgeCache, Ebook)
- call-target: self
- call-target: unknown
- call-target: self
- call-target: self
- call-target: self
- call-target: self
- call-target: NexusReader.Infrastructure/Helpers/ContentHasher.cs
- call-target: self
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: NexusReader.Infrastructure/Helpers/JsonRepairHelper.cs
- call-target: self
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: NexusReader.Infrastructure/Helpers/JsonRepairHelper.cs
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: self
- interaction-target: if (cached == null) dbContext.SemanticKnowledgeCache.Add(cacheEntry);
- interaction-target: .Where(u => allCandidateIds.Contains(u.Id))
- interaction-target: dbContext.KnowledgeUnits.Add(unit);
- interaction-target: dbContext.KnowledgeUnitLinks.Add(link);
- interaction-target: .Where(r => r.Payload.TryGetValue("ebookId", out var ev) && Guid.TryParse(ev.StringValue, out _))
- interaction-target: .Where(e => ebookIds.Contains(e.Id))
- interaction-target: Answer = "I cannot answer this based on the provided book context.",
- interaction-target: relatedContexts.Add($"[Source ID: {sourceId}] {sourceContent}");
- interaction-target: relatedContexts.Add($"[Related Context ({relation}) to {sourceId}] {targetContent}");
- interaction-target: relatedContexts.Add($"[Source ID: {sourceId}] {content}");
- interaction-target: .Where(r => r.Payload.TryGetValue("ebookId", out var ev) && Guid.TryParse(ev.StringValue, out _))
- interaction-target: .Where(e => ebookIds.Contains(e.Id))
- interaction-target: awaits Lazy.Value which invokes ExecuteAiRequestAndCacheAsync
- interaction-target: calls _embeddingGenerator.GenerateAsync via retry pipeline
- interaction-target: var filter = new Qdrant.Client.Grpc.Filter();
- interaction-target: filter.Should.Add(new Qdrant.Client.Grpc.Condition
- interaction-target: Field = new Qdrant.Client.Grpc.FieldCondition
- interaction-target: Match = new Qdrant.Client.Grpc.Match { Text = tenantId }
- interaction-target: filter.Should.Add(new Qdrant.Client.Grpc.Condition
- interaction-target: Field = new Qdrant.Client.Grpc.FieldCondition
- interaction-target: Match = new Qdrant.Client.Grpc.Match { Text = "global" }
- interaction-target: List<Qdrant.Client.Grpc.ScoredPoint> searchResult;
- interaction-target: calls _qdrantClient.SearchAsync and converts to list; falls back to empty list on exception
- interaction-target: searchResult = new List<Qdrant.Client.Grpc.ScoredPoint>();

## Coverage

- Symbols: 15
- Executable symbols: 14
- Executable symbols with control flow: 14
- Grounded edges: 17
- Unresolved references: 67
- Control-flow fragments: 14
- Unresolved jumps: 34
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 12

## Control Flow Fragments

- KnowledgeService: 6 nodes, 5 edges, 2 jumps, 0 unsupported constructs
- GetKnowledgeAsync: 6 nodes, 5 edges, 1 jumps, 0 unsupported constructs
- GetGraphDataAsync: 6 nodes, 5 edges, 1 jumps, 0 unsupported constructs
- GetSummaryAndQuizAsync: 6 nodes, 5 edges, 1 jumps, 0 unsupported constructs
- GetKnowledgeMapAsync: 6 nodes, 5 edges, 1 jumps, 0 unsupported constructs
- GetKnowledgeInternalAsync: 49 nodes, 55 edges, 3 jumps, 0 unsupported constructs
- ExecuteAiRequestAndCacheAsync: 56 nodes, 61 edges, 6 jumps, 0 unsupported constructs
- ProcessKnowledgeUnitsAsync: 39 nodes, 45 edges, 1 jumps, 0 unsupported constructs
- VerifyGroundednessAsync: 18 nodes, 18 edges, 3 jumps, 0 unsupported constructs
- GetRelevantContextAsync: 27 nodes, 26 edges, 2 jumps, 0 unsupported constructs
- SearchLibrarySemanticallyAsync: 92 nodes, 101 edges, 6 jumps, 0 unsupported constructs
- AskQuestionAsync: 124 nodes, 137 edges, 8 jumps, 0 unsupported constructs
- ClearCacheAsync: 15 nodes, 14 edges, 4 jumps, 0 unsupported constructs
- EstimateTokenCount: 13 nodes, 14 edges, 1 jumps, 0 unsupported constructs

## Diagrams

### KnowledgeService Neighborhood

_Warnings: diagram file_27eki7_knowledgeservice_cs_neighborhood_view exceeds preferred complexity thresholds (18 nodes, 2 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart LR
    class_1ybxixo_knowledgeservice("KnowledgeService")
    file_27eki7_knowledgeservice_cs("KnowledgeService")
    method_1025f5z_getsummaryandquizasync[["GetSummaryAndQuizAsync()"]]
    method_10r1sy2_clearcacheasync[["ClearCacheAsync()"]]
    method_1anyvp0_getknowledgemapasync[["GetKnowledgeMapAsync()"]]
    method_1egheyd_executeairequestandcacheasync[["ExecuteAiRequestAndCacheAsync()"]]
    method_1fgpnj9_getgraphdataasync[["GetGraphDataAsync()"]]
    method_1l8c2eg_estimatetokencount[["EstimateTokenCount()"]]
    method_1lrpkzo_getknowledgeasync[["GetKnowledgeAsync()"]]
    method_1sxv1a4_getrelevantcontextasync[["GetRelevantContextAsync()"]]
    method_4eprgx_knowledgeservice[["KnowledgeService()"]]
    method_6gn0zk_verifygroundednessasync[["VerifyGroundednessAsync()"]]
    method_965937_getknowledgeinternalasync[["GetKnowledgeInternalAsync()"]]
    method_io0xiq_askquestionasync[["AskQuestionAsync()"]]
    method_yif4p8_processknowledgeunitsasync[["ProcessKnowledgeUnitsAsync()"]]
    method_yy3thw_searchlibrarysemanticallyasync[["SearchLibrarySemanticallyAsync()"]]
    file_13kvr59_contenthasher_cs[/"ContentHasher"/]
    file_1dyqnkg_jsonrepairhelper_cs[/"JsonRepairHelper"/]
    file_27eki7_knowledgeservice_cs -->|ContentHasher| file_13kvr59_contenthasher_cs
    file_27eki7_knowledgeservice_cs -->|JsonRepairHelper| file_1dyqnkg_jsonrepairhelper_cs
```

### KnowledgeService Execution Overview

_Warnings: diagram file_27eki7_knowledgeservice_cs_execution_view exceeds preferred complexity thresholds (73 nodes, 78 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    class_1ybxixo_knowledgeservice("KnowledgeService")
    method_1025f5z_getsummaryandquizasync[["GetSummaryAndQuizAsync()"]]
    method_10r1sy2_clearcacheasync[["ClearCacheAsync()"]]
    method_1anyvp0_getknowledgemapasync[["GetKnowledgeMapAsync()"]]
    method_1egheyd_executeairequestandcacheasync[["ExecuteAiRequestAndCacheAsync()"]]
    method_1fgpnj9_getgraphdataasync[["GetGraphDataAsync()"]]
    method_1l8c2eg_estimatetokencount[["EstimateTokenCount()"]]
    method_1lrpkzo_getknowledgeasync[["GetKnowledgeAsync()"]]
    method_1sxv1a4_getrelevantcontextasync[["GetRelevantContextAsync()"]]
    method_4eprgx_knowledgeservice[["KnowledgeService()"]]
    method_6gn0zk_verifygroundednessasync[["VerifyGroundednessAsync()"]]
    method_965937_getknowledgeinternalasync[["GetKnowledgeInternalAsync()"]]
    method_io0xiq_askquestionasync[["AskQuestionAsync()"]]
    method_yif4p8_processknowledgeunitsasync[["ProcessKnowledgeUnitsAsync()"]]
    method_yy3thw_searchlibrarysemanticallyasync[["SearchLibrarySemanticallyAsync()"]]
    unresolved_unresolved_100rhko_call_target{"Unresolved: QdrantClient.SearchAsync"}
    unresolved_unresolved_10sonyq_call_target{"Unresolved: QdrantClient.SearchAsync"}
    unresolved_unresolved_10uf8wm_call_target{"Unresolved: IDbContextFactory.CreateDbContextAsync"}
    unresolved_unresolved_11kkh95_call_target{"Unresolved: IDbContextFactory.CreateDbContextAsync"}
    unresolved_unresolved_1258ih7_interaction_target{"Unresolved: calls _embeddingGenerator.GenerateAsync via retry pipeline"}
    unresolved_unresolved_164lber_call_target{"Unresolved: JsonRepairHelper.Repair"}
    unresolved_unresolved_16685tb_interaction_target{"Unresolved: Answer = \\"I cannot answer this based on the provided book context.\\","}
    unresolved_unresolved_16zt9ep_call_target{"Unresolved: IDbContextFactory.CreateDbContextAsync"}
    unresolved_unresolved_1c8zyv3_call_target{"Unresolved: ContentHasher.ComputeHash"}
    unresolved_unresolved_1gilyr5_interaction_target{"Unresolved: dbContext.KnowledgeUnitLinks.Add(link);"}
    unresolved_unresolved_1jj6suh_call_target{"Unresolved: QdrantClient.SearchAsync"}
    unresolved_unresolved_1jqovd_interaction_target{"Unresolved: .Where(r => r.Payload.TryGetValue(\\"ebookId\\", out var ev) && Guid.TryParse(ev.StringValue, out _))"}
    unresolved_unresolved_1m9ex1b_interaction_target{"Unresolved: Match = new Qdrant.Client.Grpc.Match { Text = \\"global\\" }"}
    unresolved_unresolved_1onktry_call_target{"Unresolved: JsonSerializer.Deserialize<GroundedResponseDto>"}
    unresolved_unresolved_1p8z85d_interaction_target{"Unresolved: calls _qdrantClient.SearchAsync and converts to list; falls back to empty list on exception"}
    unresolved_unresolved_1pio9ig_call_target{"Unresolved: IEmbeddingGenerator.GenerateAsync"}
    unresolved_unresolved_1pjcjv0_call_target{"Unresolved: GetKnowledgeInternalAsync"}
    unresolved_unresolved_1qp5h1x_call_target{"Unresolved: JsonSerializer.Deserialize<KnowledgePacket>"}
    unresolved_unresolved_1ty51dz_call_target{"Unresolved: IEmbeddingGenerator.GenerateAsync"}
    unresolved_unresolved_1w5muzt_call_target{"Unresolved: ResiliencePipeline.ExecuteAsync"}
    unresolved_unresolved_1w8q8su_call_target{"Unresolved: JsonSerializer.Deserialize<Dictionary<string, object>>"}
    unresolved_unresolved_1wsorul_call_target{"Unresolved: DbSet.ExecuteDeleteAsync"}
    unresolved_unresolved_47atqf_call_target{"Unresolved: ResiliencePipelineProvider.GetPipeline"}
    unresolved_unresolved_483118_call_target{"Unresolved: GetKnowledgeInternalAsync"}
    unresolved_unresolved_4nj3fr_interaction_target{"Unresolved: relatedContexts.Add($\\"[Source ID: {sourceId}] {content}\\");"}
    unresolved_unresolved_4pitit_call_target{"Unresolved: IChatClient.GetResponseAsync"}
    unresolved_unresolved_7l69tj_call_target{"Unresolved: TiktokenTokenizer.CreateForModel"}
    unresolved_unresolved_7ruse6_call_target{"Unresolved: session.ExecuteReadAsync"}
    unresolved_unresolved_8s0x1n_interaction_target{"Unresolved: searchResult = new List<Qdrant.Client.Grpc.ScoredPoint>();"}
    unresolved_unresolved_9tcptu_interaction_target{"Unresolved: .Where(e => ebookIds.Contains(e.Id))"}
    unresolved_unresolved_a2ye6s_call_target{"Unresolved: ResiliencePipeline.ExecuteAsync"}
    unresolved_unresolved_a5fihx_interaction_target{"Unresolved: awaits Lazy.Value which invokes ExecuteAiRequestAndCacheAsync"}
    unresolved_unresolved_amsncy_call_target{"Unresolved: IDriver.AsyncSession"}
    unresolved_unresolved_bimks8_call_target{"Unresolved: Tokenizer.CountTokens"}
    unresolved_unresolved_c6stju_call_target{"Unresolved: IDbContextFactory.CreateDbContextAsync"}
    unresolved_unresolved_dspfoz_interaction_target{"Unresolved: Match = new Qdrant.Client.Grpc.Match { Text = tenantId }"}
    unresolved_unresolved_e1t5nn_call_target{"Unresolved: IChatClient.GetResponseAsync"}
    unresolved_unresolved_gc1ktw_call_target{"Unresolved: ProcessKnowledgeUnitsAsync"}
    unresolved_unresolved_ggzp9w_call_target{"Unresolved: session.ExecuteReadAsync"}
    unresolved_unresolved_gi8gy3_interaction_target{"Unresolved: Field = new Qdrant.Client.Grpc.FieldCondition"}
    unresolved_unresolved_gl3zt0_interaction_target{"Unresolved: relatedContexts.Add($\\"[Source ID: {sourceId}] {sourceContent}\\");"}
    unresolved_unresolved_jue0lv_interaction_target{"Unresolved: var filter = new Qdrant.Client.Grpc.Filter();"}
    unresolved_unresolved_kllanj_interaction_target{"Unresolved: dbContext.KnowledgeUnits.Add(unit);"}
    unresolved_unresolved_kmloog_call_target{"Unresolved: IDriver.AsyncSession"}
    unresolved_unresolved_lov4bd_call_target{"Unresolved: JsonSerializer.Deserialize<GroundednessResult>"}
    unresolved_unresolved_lw9jkq_interaction_target{"Unresolved: relatedContexts.Add($\\"[Related Context ({relation}) to {sourceId}] {targetContent}\\");"}
    unresolved_unresolved_nso9wb_interaction_target{"Unresolved: List<Qdrant.Client.Grpc.ScoredPoint> searchResult;"}
    unresolved_unresolved_oqpmyu_call_target{"Unresolved: ResiliencePipeline.ExecuteAsync"}
    unresolved_unresolved_out96g_call_target{"Unresolved: GetKnowledgeInternalAsync"}
    unresolved_unresolved_q30n8k_interaction_target{"Unresolved: filter.Should.Add(new Qdrant.Client.Grpc.Condition"}
    unresolved_unresolved_qcqfwo_call_target{"Unresolved: GetKnowledgeInternalAsync"}
    unresolved_unresolved_s4gw6p_interaction_target{"Unresolved: if (cached == null) dbContext.SemanticKnowledgeCache.Add(cacheEntry);"}
    unresolved_unresolved_sbu1nc_call_target{"Unresolved: JsonRepairHelper.Repair"}
    unresolved_unresolved_sbx7fo_call_target{"Unresolved: IDbContextFactory.CreateDbContextAsync"}
    unresolved_unresolved_twfvwd_call_target{"Unresolved: IEmbeddingGenerator.GenerateAsync"}
    unresolved_unresolved_uepcqr_call_target{"Unresolved: ExecuteAiRequestAndCacheAsync"}
    unresolved_unresolved_wlmnoi_interaction_target{"Unresolved: .Where(u => allCandidateIds.Contains(u.Id))"}
    unresolved_unresolved_yaascp_call_target{"Unresolved: AppDbContext.KnowledgeUnits"}
    class_1ybxixo_knowledgeservice -->|contains| method_1025f5z_getsummaryandquizasync
    class_1ybxixo_knowledgeservice -->|contains| method_10r1sy2_clearcacheasync
    class_1ybxixo_knowledgeservice -->|contains| method_1anyvp0_getknowledgemapasync
    class_1ybxixo_knowledgeservice -->|contains| method_1egheyd_executeairequestandcacheasync
    class_1ybxixo_knowledgeservice -->|contains| method_1fgpnj9_getgraphdataasync
    class_1ybxixo_knowledgeservice -->|contains| method_1l8c2eg_estimatetokencount
    class_1ybxixo_knowledgeservice -->|contains| method_1lrpkzo_getknowledgeasync
    class_1ybxixo_knowledgeservice -->|contains| method_1sxv1a4_getrelevantcontextasync
    class_1ybxixo_knowledgeservice -->|contains| method_4eprgx_knowledgeservice
    class_1ybxixo_knowledgeservice -->|contains| method_6gn0zk_verifygroundednessasync
    class_1ybxixo_knowledgeservice -->|contains| method_965937_getknowledgeinternalasync
    class_1ybxixo_knowledgeservice -->|contains| method_io0xiq_askquestionasync
    class_1ybxixo_knowledgeservice -->|contains| method_yif4p8_processknowledgeunitsasync
    class_1ybxixo_knowledgeservice -->|contains| method_yy3thw_searchlibrarysemanticallyasync
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_1258ih7_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_16685tb_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_1gilyr5_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_1jqovd_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_1jqovd_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_1m9ex1b_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_1p8z85d_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_4nj3fr_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_8s0x1n_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_9tcptu_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_9tcptu_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_a5fihx_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_dspfoz_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_gi8gy3_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_gi8gy3_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_gl3zt0_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_jue0lv_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_kllanj_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_lw9jkq_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_nso9wb_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_q30n8k_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_q30n8k_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_s4gw6p_interaction_target
    class_1ybxixo_knowledgeservice -->|unresolved interaction| unresolved_unresolved_wlmnoi_interaction_target
    method_1025f5z_getsummaryandquizasync -->|unresolved call| unresolved_unresolved_483118_call_target
    method_10r1sy2_clearcacheasync -->|unresolved call| unresolved_unresolved_10uf8wm_call_target
    method_10r1sy2_clearcacheasync -->|unresolved call| unresolved_unresolved_1wsorul_call_target
    method_10r1sy2_clearcacheasync -->|unresolved call| unresolved_unresolved_1wsorul_call_target
    method_10r1sy2_clearcacheasync -->|unresolved call| unresolved_unresolved_1wsorul_call_target
    method_1anyvp0_getknowledgemapasync -->|unresolved call| unresolved_unresolved_qcqfwo_call_target
    method_1egheyd_executeairequestandcacheasync -->|unresolved call| unresolved_unresolved_11kkh95_call_target
    method_1egheyd_executeairequestandcacheasync -->|unresolved call| unresolved_unresolved_164lber_call_target
    method_1egheyd_executeairequestandcacheasync -->|unresolved call| unresolved_unresolved_1qp5h1x_call_target
    method_1egheyd_executeairequestandcacheasync -->|unresolved call| unresolved_unresolved_a2ye6s_call_target
    method_1egheyd_executeairequestandcacheasync -->|unresolved call| unresolved_unresolved_e1t5nn_call_target
    method_1egheyd_executeairequestandcacheasync -->|unresolved call| unresolved_unresolved_gc1ktw_call_target
    method_1fgpnj9_getgraphdataasync -->|unresolved call| unresolved_unresolved_out96g_call_target
    method_1l8c2eg_estimatetokencount -->|unresolved call| unresolved_unresolved_bimks8_call_target
    method_1lrpkzo_getknowledgeasync -->|unresolved call| unresolved_unresolved_1pjcjv0_call_target
    method_1sxv1a4_getrelevantcontextasync -->|unresolved call| unresolved_unresolved_1jj6suh_call_target
    method_1sxv1a4_getrelevantcontextasync -->|unresolved call| unresolved_unresolved_1pio9ig_call_target
    method_4eprgx_knowledgeservice -->|unresolved call| unresolved_unresolved_47atqf_call_target
    method_4eprgx_knowledgeservice -->|unresolved call| unresolved_unresolved_7l69tj_call_target
    method_6gn0zk_verifygroundednessasync -->|unresolved call| unresolved_unresolved_4pitit_call_target
    method_6gn0zk_verifygroundednessasync -->|unresolved call| unresolved_unresolved_lov4bd_call_target
    method_6gn0zk_verifygroundednessasync -->|unresolved call| unresolved_unresolved_oqpmyu_call_target
    method_965937_getknowledgeinternalasync -->|unresolved call| unresolved_unresolved_16zt9ep_call_target
    method_965937_getknowledgeinternalasync -->|unresolved call| unresolved_unresolved_1c8zyv3_call_target
    method_965937_getknowledgeinternalasync -->|unresolved call| unresolved_unresolved_uepcqr_call_target
    method_io0xiq_askquestionasync -->|unresolved call| unresolved_unresolved_10sonyq_call_target
    method_io0xiq_askquestionasync -->|unresolved call| unresolved_unresolved_1onktry_call_target
    method_io0xiq_askquestionasync -->|unresolved call| unresolved_unresolved_1w5muzt_call_target
    method_io0xiq_askquestionasync -->|unresolved call| unresolved_unresolved_7ruse6_call_target
    method_io0xiq_askquestionasync -->|unresolved call| unresolved_unresolved_c6stju_call_target
    method_io0xiq_askquestionasync -->|unresolved call| unresolved_unresolved_kmloog_call_target
    method_io0xiq_askquestionasync -->|unresolved call| unresolved_unresolved_sbu1nc_call_target
    method_io0xiq_askquestionasync -->|unresolved call| unresolved_unresolved_twfvwd_call_target
    method_yif4p8_processknowledgeunitsasync -->|unresolved call| unresolved_unresolved_yaascp_call_target
    method_yy3thw_searchlibrarysemanticallyasync -->|unresolved call| unresolved_unresolved_100rhko_call_target
    method_yy3thw_searchlibrarysemanticallyasync -->|unresolved call| unresolved_unresolved_1ty51dz_call_target
    method_yy3thw_searchlibrarysemanticallyasync -->|unresolved call| unresolved_unresolved_1w8q8su_call_target
    method_yy3thw_searchlibrarysemanticallyasync -->|unresolved call| unresolved_unresolved_amsncy_call_target
    method_yy3thw_searchlibrarysemanticallyasync -->|unresolved call| unresolved_unresolved_ggzp9w_call_target
    method_yy3thw_searchlibrarysemanticallyasync -->|unresolved call| unresolved_unresolved_sbx7fo_call_target
```

### KnowledgeService() Control Flow

```mermaid
flowchart TD
    method_4eprgx_knowledgeservice__call_51_ResiliencePipelineProvider_GetPipeline[["ResiliencePipelineProvider.GetPipeline"]]
    method_4eprgx_knowledgeservice__call_58_TiktokenTokenizer_CreateForModel[["TiktokenTokenizer.CreateForModel"]]
    method_4eprgx_knowledgeservice__action_48_assignment_48__linear("store dependencies")
    method_4eprgx_knowledgeservice__action_58_initialization_58__linear("init tokenizer")
    method_4eprgx_knowledgeservice__entry(["KnowledgeService entry"])
    method_4eprgx_knowledgeservice__implicit_return(["return"])
    method_4eprgx_knowledgeservice__action_48_assignment_48__linear -->|ai-retry pipeline name| method_4eprgx_knowledgeservice__call_51_ResiliencePipelineProvider_GetPipeline
    method_4eprgx_knowledgeservice__action_58_initialization_58__linear -->|gpt-4 model for token estimation| method_4eprgx_knowledgeservice__call_58_TiktokenTokenizer_CreateForModel
    method_4eprgx_knowledgeservice__call_51_ResiliencePipelineProvider_GetPipeline -->|next| method_4eprgx_knowledgeservice__action_58_initialization_58__linear
    method_4eprgx_knowledgeservice__call_58_TiktokenTokenizer_CreateForModel -->|return| method_4eprgx_knowledgeservice__implicit_return
    method_4eprgx_knowledgeservice__entry -->|next| method_4eprgx_knowledgeservice__action_48_assignment_48__linear
```

### GetKnowledgeInternalAsync() Control Flow

_Warnings: diagram method_965937_getknowledgeinternalasync__fragment_diagram exceeds preferred complexity thresholds (49 nodes, 55 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_965937_getknowledgeinternalasync__call_112_ExecuteAiRequestAndCacheAsync[["ExecuteAiRequestAndCacheAsync"]]
    method_965937_getknowledgeinternalasync__call_85_IDbContextFactory_CreateDbContextAsync[["IDbContextFactory.CreateDbContextAsync"]]
    method_965937_getknowledgeinternalasync__call_87_ContentHasher_ComputeHash[["ContentHasher.ComputeHash"]]
    method_965937_getknowledgeinternalasync__action_101_getknowledgeinternalasync_catch_101_7__catch("catch JsonException ex")
    method_965937_getknowledgeinternalasync__action_103_getknowledgeinternalasync_log_103_8__linear("Logs runtime state")
    method_965937_getknowledgeinternalasync__action_110_concurrency_dedup_110__linear("deduplicate concurrent identical requests")
    method_965937_getknowledgeinternalasync__action_116_getknowledgeinternalasync_try_116_9__try("Begins protected execution")
    method_965937_getknowledgeinternalasync__action_116_try_catch_finally_116__linear("ensure activeRequests cleanup")
    method_965937_getknowledgeinternalasync__action_118_getknowledgeinternalasync_await_118_10__await[["Waits for async work"]]
    method_965937_getknowledgeinternalasync__action_122_fallback_122__condition{"remove failed active request so future attempts can retry"}
    method_965937_getknowledgeinternalasync__action_122_fallback_122__false("false")
    method_965937_getknowledgeinternalasync__action_122_fallback_122__merge("merge")
    method_965937_getknowledgeinternalasync__action_122_fallback_122__true("true")
    method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__condition{"result.IsFailed"}
    method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__false("false")
    method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__merge("merge")
    method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__true("true")
    method_965937_getknowledgeinternalasync__action_129_getknowledgeinternalasync_catch_129_13__catch("catch Exception")
    method_965937_getknowledgeinternalasync__action_132_getknowledgeinternalasync_throw_132_14__throw{"Throws exception"}
    method_965937_getknowledgeinternalasync__action_134_getknowledgeinternalasync_finally_134_15__finally("Runs cleanup or finalization")
    method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__condition{"string.IsNullOrWhiteSpace(text)) return Result.Fail(\\"Input text is empty.\\""}
    method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__false("continue")
    method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__merge("merge")
    method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__true("exit")
    method_965937_getknowledgeinternalasync__action_83_guard_clause_83__condition{"string.IsNullOrWhiteSpace(text)"}
    method_965937_getknowledgeinternalasync__action_83_guard_clause_83__false("continue")
    method_965937_getknowledgeinternalasync__action_83_guard_clause_83__merge("merge")
    method_965937_getknowledgeinternalasync__action_83_guard_clause_83__true("fail")
    method_965937_getknowledgeinternalasync__action_85_getknowledgeinternalasync_await_85_1__await[["Waits for async work"]]
    method_965937_getknowledgeinternalasync__action_90_getknowledgeinternalasync_await_90_2__await[["Waits for async work"]]
    method_965937_getknowledgeinternalasync__action_90_persistence_read_90__linear("cache lookup")
    method_965937_getknowledgeinternalasync__action_93_branch_93__condition{"cache hit and valid prompt version"}
    method_965937_getknowledgeinternalasync__action_93_branch_93__false("false")
    method_965937_getknowledgeinternalasync__action_93_branch_93__merge("merge")
    method_965937_getknowledgeinternalasync__action_93_branch_93__true("true")
    method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__condition{"cached != null && cached.PromptVersion == PromptVersion"}
    method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__false("false")
    method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__merge("merge")
    method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__true("true")
    method_965937_getknowledgeinternalasync__action_95_getknowledgeinternalasync_log_95_4__linear("Logs runtime state")
    method_965937_getknowledgeinternalasync__action_96_getknowledgeinternalasync_try_96_5__try("Begins protected execution")
    method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__condition{"packet != null) return Result.Ok(packet"}
    method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__false("continue")
    method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__merge("merge")
    method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__true("exit")
    method_965937_getknowledgeinternalasync__entry(["GetKnowledgeInternalAsync entry"])
    method_965937_getknowledgeinternalasync__action_118_external_call_118__linear("await AI/cache execution")
    method_965937_getknowledgeinternalasync__action_127_getknowledgeinternalasync_return_127_12__return(["Returns result"])
    method_965937_getknowledgeinternalasync__implicit_return(["return"])
    method_965937_getknowledgeinternalasync__action_101_getknowledgeinternalasync_catch_101_7__catch -->|next| method_965937_getknowledgeinternalasync__action_103_getknowledgeinternalasync_log_103_8__linear
    method_965937_getknowledgeinternalasync__action_103_getknowledgeinternalasync_log_103_8__linear -->|next| method_965937_getknowledgeinternalasync__action_110_concurrency_dedup_110__linear
    method_965937_getknowledgeinternalasync__action_110_concurrency_dedup_110__linear -->|normalizedText, tenantId, systemPrompt, traceType, ebookId, hash| method_965937_getknowledgeinternalasync__call_112_ExecuteAiRequestAndCacheAsync
    method_965937_getknowledgeinternalasync__action_116_getknowledgeinternalasync_try_116_9__try -->|next| method_965937_getknowledgeinternalasync__action_118_getknowledgeinternalasync_await_118_10__await
    method_965937_getknowledgeinternalasync__action_116_try_catch_finally_116__linear -->|next| method_965937_getknowledgeinternalasync__action_116_getknowledgeinternalasync_try_116_9__try
    method_965937_getknowledgeinternalasync__action_118_external_call_118__linear -->|fallback| method_965937_getknowledgeinternalasync__action_122_fallback_122__condition
    method_965937_getknowledgeinternalasync__action_118_getknowledgeinternalasync_await_118_10__await -->|next| method_965937_getknowledgeinternalasync__action_118_external_call_118__linear
    method_965937_getknowledgeinternalasync__action_122_fallback_122__condition -->|false| method_965937_getknowledgeinternalasync__action_122_fallback_122__false
    method_965937_getknowledgeinternalasync__action_122_fallback_122__condition -->|true| method_965937_getknowledgeinternalasync__action_122_fallback_122__true
    method_965937_getknowledgeinternalasync__action_122_fallback_122__false -->|next| method_965937_getknowledgeinternalasync__action_122_fallback_122__merge
    method_965937_getknowledgeinternalasync__action_122_fallback_122__merge -->|next| method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__condition
    method_965937_getknowledgeinternalasync__action_122_fallback_122__true -->|next| method_965937_getknowledgeinternalasync__action_122_fallback_122__merge
    method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__condition -->|false| method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__false
    method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__condition -->|true| method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__true
    method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__false -->|next| method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__merge
    method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__merge -->|return| method_965937_getknowledgeinternalasync__action_127_getknowledgeinternalasync_return_127_12__return
    method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__true -->|next| method_965937_getknowledgeinternalasync__action_122_getknowledgeinternalasync_branch_122_11__merge
    method_965937_getknowledgeinternalasync__action_127_getknowledgeinternalasync_return_127_12__return -->|exception| method_965937_getknowledgeinternalasync__action_129_getknowledgeinternalasync_catch_129_13__catch
    method_965937_getknowledgeinternalasync__action_129_getknowledgeinternalasync_catch_129_13__catch -->|exception| method_965937_getknowledgeinternalasync__action_132_getknowledgeinternalasync_throw_132_14__throw
    method_965937_getknowledgeinternalasync__action_132_getknowledgeinternalasync_throw_132_14__throw -->|next| method_965937_getknowledgeinternalasync__action_134_getknowledgeinternalasync_finally_134_15__finally
    method_965937_getknowledgeinternalasync__action_134_getknowledgeinternalasync_finally_134_15__finally -->|return| method_965937_getknowledgeinternalasync__implicit_return
    method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__condition -->|continue| method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__false
    method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__condition -->|exit| method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__true
    method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__false -->|next| method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__merge
    method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__merge -->|next| method_965937_getknowledgeinternalasync__action_85_getknowledgeinternalasync_await_85_1__await
    method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__true -->|next| method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__merge
    method_965937_getknowledgeinternalasync__action_83_guard_clause_83__condition -->|continue| method_965937_getknowledgeinternalasync__action_83_guard_clause_83__false
    method_965937_getknowledgeinternalasync__action_83_guard_clause_83__condition -->|fail| method_965937_getknowledgeinternalasync__action_83_guard_clause_83__true
    method_965937_getknowledgeinternalasync__action_83_guard_clause_83__false -->|next| method_965937_getknowledgeinternalasync__action_83_guard_clause_83__merge
    method_965937_getknowledgeinternalasync__action_83_guard_clause_83__merge -->|next| method_965937_getknowledgeinternalasync__action_83_getknowledgeinternalasync_guard_clause_83_0__condition
    method_965937_getknowledgeinternalasync__action_83_guard_clause_83__true -->|next| method_965937_getknowledgeinternalasync__action_83_guard_clause_83__merge
    method_965937_getknowledgeinternalasync__action_85_getknowledgeinternalasync_await_85_1__await -->|cancellationToken| method_965937_getknowledgeinternalasync__call_85_IDbContextFactory_CreateDbContextAsync
    method_965937_getknowledgeinternalasync__action_90_getknowledgeinternalasync_await_90_2__await -->|next| method_965937_getknowledgeinternalasync__action_90_persistence_read_90__linear
    method_965937_getknowledgeinternalasync__action_90_persistence_read_90__linear -->|next| method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__condition
    method_965937_getknowledgeinternalasync__action_93_branch_93__condition -->|false| method_965937_getknowledgeinternalasync__action_93_branch_93__false
    method_965937_getknowledgeinternalasync__action_93_branch_93__condition -->|true| method_965937_getknowledgeinternalasync__action_93_branch_93__true
    method_965937_getknowledgeinternalasync__action_93_branch_93__false -->|next| method_965937_getknowledgeinternalasync__action_93_branch_93__merge
    method_965937_getknowledgeinternalasync__action_93_branch_93__merge -->|next| method_965937_getknowledgeinternalasync__action_95_getknowledgeinternalasync_log_95_4__linear
    method_965937_getknowledgeinternalasync__action_93_branch_93__true -->|next| method_965937_getknowledgeinternalasync__action_93_branch_93__merge
    method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__condition -->|false| method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__false
    method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__condition -->|true| method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__true
    method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__false -->|next| method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__merge
    method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__merge -->|next| method_965937_getknowledgeinternalasync__action_93_branch_93__condition
    method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__true -->|next| method_965937_getknowledgeinternalasync__action_93_getknowledgeinternalasync_branch_93_3__merge
    method_965937_getknowledgeinternalasync__action_95_getknowledgeinternalasync_log_95_4__linear -->|next| method_965937_getknowledgeinternalasync__action_96_getknowledgeinternalasync_try_96_5__try
    method_965937_getknowledgeinternalasync__action_96_getknowledgeinternalasync_try_96_5__try -->|next| method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__condition
    method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__condition -->|continue| method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__false
    method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__condition -->|exit| method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__true
    method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__false -->|next| method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__merge
    method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__merge -->|exception| method_965937_getknowledgeinternalasync__action_101_getknowledgeinternalasync_catch_101_7__catch
    method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__true -->|next| method_965937_getknowledgeinternalasync__action_99_getknowledgeinternalasync_guard_clause_99_6__merge
    method_965937_getknowledgeinternalasync__call_112_ExecuteAiRequestAndCacheAsync -->|next| method_965937_getknowledgeinternalasync__action_116_try_catch_finally_116__linear
    method_965937_getknowledgeinternalasync__call_85_IDbContextFactory_CreateDbContextAsync -->|normalizedText| method_965937_getknowledgeinternalasync__call_87_ContentHasher_ComputeHash
    method_965937_getknowledgeinternalasync__call_87_ContentHasher_ComputeHash -->|next| method_965937_getknowledgeinternalasync__action_90_getknowledgeinternalasync_await_90_2__await
    method_965937_getknowledgeinternalasync__entry -->|next| method_965937_getknowledgeinternalasync__action_83_guard_clause_83__condition
```

### ExecuteAiRequestAndCacheAsync() Control Flow

_Warnings: diagram method_1egheyd_executeairequestandcacheasync__fragment_diagram exceeds preferred complexity thresholds (56 nodes, 61 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_1egheyd_executeairequestandcacheasync__call_151_IDbContextFactory_CreateDbContextAsync[["IDbContextFactory.CreateDbContextAsync"]]
    method_1egheyd_executeairequestandcacheasync__call_159_ResiliencePipeline_ExecuteAsync[["ResiliencePipeline.ExecuteAsync"]]
    method_1egheyd_executeairequestandcacheasync__call_160_IChatClient_GetResponseAsync[["IChatClient.GetResponseAsync"]]
    method_1egheyd_executeairequestandcacheasync__call_171_JsonRepairHelper_Repair[["JsonRepairHelper.Repair"]]
    method_1egheyd_executeairequestandcacheasync__call_175_JsonSerializer_Deserialize_KnowledgePacket_[["JsonSerializer.Deserialize<KnowledgePacket>"]]
    method_1egheyd_executeairequestandcacheasync__call_202_ProcessKnowledgeUnitsAsync[["ProcessKnowledgeUnitsAsync"]]
    method_1egheyd_executeairequestandcacheasync__action_148_executeairequestandcacheasync_log_148_0__linear("Logs runtime state")
    method_1egheyd_executeairequestandcacheasync__action_148_log_148__linear("Logs cache miss")
    method_1egheyd_executeairequestandcacheasync__action_149_executeairequestandcacheasync_try_149_1__try("Begins protected execution")
    method_1egheyd_executeairequestandcacheasync__action_151_executeairequestandcacheasync_await_151_2__await[["Waits for async work"]]
    method_1egheyd_executeairequestandcacheasync__action_159_executeairequestandcacheasync_await_159_3__await[["Waits for async work"]]
    method_1egheyd_executeairequestandcacheasync__action_159_retry_159__loop_body[["uses _retryPipeline.ExecuteAsync to call _chatClient.GetResponseAsync"]]
    method_1egheyd_executeairequestandcacheasync__action_159_retry_159__loop_entry("AI request executed via resilience pipeline")
    method_1egheyd_executeairequestandcacheasync__action_159_retry_159__loop_exit("exit loop")
    method_1egheyd_executeairequestandcacheasync__action_160_executeairequestandcacheasync_await_160_4__await[["Waits for async work"]]
    method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__condition{"string.IsNullOrWhiteSpace(rawResponse)"}
    method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__false("otherwise")
    method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__merge("merge")
    method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__true("fail")
    method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__condition{"string.IsNullOrWhiteSpace(rawResponse)) return Result.Fail(\\"AI returned an empty response.\\""}
    method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__false("continue")
    method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__merge("merge")
    method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__true("exit")
    method_1egheyd_executeairequestandcacheasync__action_169_text_cleanup_169__linear("strip markdown and repair JSON")
    method_1egheyd_executeairequestandcacheasync__action_173_executeairequestandcacheasync_try_173_6__try("Begins protected execution")
    method_1egheyd_executeairequestandcacheasync__action_175_json_deserialize_175__linear("parse KnowledgePacket")
    method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__condition{"knowledgePacket == null) return Result.Fail(\\"Failed to deserialize AI response.\\""}
    method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__false("continue")
    method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__merge("merge")
    method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__true("exit")
    method_1egheyd_executeairequestandcacheasync__action_179_executeairequestandcacheasync_await_179_8__await[["Waits for async work"]]
    method_1egheyd_executeairequestandcacheasync__action_179_persistence_read_write_179__linear("create or update SemanticKnowledgeCache")
    method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__condition{"cached == null) dbContext.SemanticKnowledgeCache.Add(cacheEntry"}
    method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__false("false")
    method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__merge("merge")
    method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__true("true")
    method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__condition{"Falls back to alternate path"}
    method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__false("otherwise")
    method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__merge("merge")
    method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__true("fallback")
    method_1egheyd_executeairequestandcacheasync__action_202_executeairequestandcacheasync_await_202_12__await[["Waits for async work"]]
    method_1egheyd_executeairequestandcacheasync__action_202_orchestration_202__linear("process structured units")
    method_1egheyd_executeairequestandcacheasync__action_204_executeairequestandcacheasync_await_204_13__await[["Waits for async work"]]
    method_1egheyd_executeairequestandcacheasync__action_204_persistence_write_204__linear("save changes")
    method_1egheyd_executeairequestandcacheasync__action_207_executeairequestandcacheasync_catch_207_15__catch("catch JsonException ex")
    method_1egheyd_executeairequestandcacheasync__action_209_executeairequestandcacheasync_log_209_16__linear("Logs runtime state")
    method_1egheyd_executeairequestandcacheasync__action_213_error_handling_213__linear("wrap exceptions")
    method_1egheyd_executeairequestandcacheasync__action_213_executeairequestandcacheasync_catch_213_18__catch("catch Exception ex")
    method_1egheyd_executeairequestandcacheasync__action_217_executeairequestandcacheasync_finally_217_20__finally("Runs cleanup or finalization")
    method_1egheyd_executeairequestandcacheasync__action_219_cleanup_219__linear("remove active request entry")
    method_1egheyd_executeairequestandcacheasync__entry(["ExecuteAiRequestAndCacheAsync entry"])
    method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_repository_write_193_10__linear[("Writes repository or persistence state")]
    method_1egheyd_executeairequestandcacheasync__action_205_executeairequestandcacheasync_return_205_14__return(["Returns result"])
    method_1egheyd_executeairequestandcacheasync__action_210_executeairequestandcacheasync_return_210_17__return(["Returns result"])
    method_1egheyd_executeairequestandcacheasync__action_215_executeairequestandcacheasync_return_215_19__return(["Returns result"])
    method_1egheyd_executeairequestandcacheasync__implicit_return(["return"])
    method_1egheyd_executeairequestandcacheasync__action_148_executeairequestandcacheasync_log_148_0__linear -->|next| method_1egheyd_executeairequestandcacheasync__action_148_log_148__linear
    method_1egheyd_executeairequestandcacheasync__action_148_log_148__linear -->|next| method_1egheyd_executeairequestandcacheasync__action_149_executeairequestandcacheasync_try_149_1__try
    method_1egheyd_executeairequestandcacheasync__action_149_executeairequestandcacheasync_try_149_1__try -->|next| method_1egheyd_executeairequestandcacheasync__action_151_executeairequestandcacheasync_await_151_2__await
    method_1egheyd_executeairequestandcacheasync__action_151_executeairequestandcacheasync_await_151_2__await -->|no params| method_1egheyd_executeairequestandcacheasync__call_151_IDbContextFactory_CreateDbContextAsync
    method_1egheyd_executeairequestandcacheasync__action_159_executeairequestandcacheasync_await_159_3__await -->|next| method_1egheyd_executeairequestandcacheasync__action_159_retry_159__loop_entry
    method_1egheyd_executeairequestandcacheasync__action_159_retry_159__loop_body -->|retry| method_1egheyd_executeairequestandcacheasync__action_159_retry_159__loop_entry
    method_1egheyd_executeairequestandcacheasync__action_159_retry_159__loop_entry -->|iterate| method_1egheyd_executeairequestandcacheasync__action_159_retry_159__loop_body
    method_1egheyd_executeairequestandcacheasync__action_159_retry_159__loop_entry -->|exit| method_1egheyd_executeairequestandcacheasync__action_159_retry_159__loop_exit
    method_1egheyd_executeairequestandcacheasync__action_159_retry_159__loop_exit -->|invokes _chatClient.GetResponseAsync with system+user messages and ChatOptions| method_1egheyd_executeairequestandcacheasync__call_159_ResiliencePipeline_ExecuteAsync
    method_1egheyd_executeairequestandcacheasync__action_160_executeairequestandcacheasync_await_160_4__await -->|systemPrompt and normalizedText messages, ChatOptions| method_1egheyd_executeairequestandcacheasync__call_160_IChatClient_GetResponseAsync
    method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__condition -->|otherwise| method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__false
    method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__condition -->|fail| method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__true
    method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__false -->|next| method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__merge
    method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__merge -->|next| method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__condition
    method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__true -->|next| method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__merge
    method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__condition -->|continue| method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__false
    method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__condition -->|exit| method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__true
    method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__false -->|next| method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__merge
    method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__merge -->|next| method_1egheyd_executeairequestandcacheasync__action_169_text_cleanup_169__linear
    method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__true -->|next| method_1egheyd_executeairequestandcacheasync__action_167_executeairequestandcacheasync_guard_clause_167_5__merge
    method_1egheyd_executeairequestandcacheasync__action_169_text_cleanup_169__linear -->|jsonResponse string| method_1egheyd_executeairequestandcacheasync__call_171_JsonRepairHelper_Repair
    method_1egheyd_executeairequestandcacheasync__action_173_executeairequestandcacheasync_try_173_6__try -->|next| method_1egheyd_executeairequestandcacheasync__action_175_json_deserialize_175__linear
    method_1egheyd_executeairequestandcacheasync__action_175_json_deserialize_175__linear -->|jsonResponse| method_1egheyd_executeairequestandcacheasync__call_175_JsonSerializer_Deserialize_KnowledgePacket_
    method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__condition -->|continue| method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__false
    method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__condition -->|exit| method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__true
    method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__false -->|next| method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__merge
    method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__merge -->|next| method_1egheyd_executeairequestandcacheasync__action_179_executeairequestandcacheasync_await_179_8__await
    method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__true -->|next| method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__merge
    method_1egheyd_executeairequestandcacheasync__action_179_executeairequestandcacheasync_await_179_8__await -->|next| method_1egheyd_executeairequestandcacheasync__action_179_persistence_read_write_179__linear
    method_1egheyd_executeairequestandcacheasync__action_179_persistence_read_write_179__linear -->|next| method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_repository_write_193_10__linear
    method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__condition -->|false| method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__false
    method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__condition -->|true| method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__true
    method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__false -->|next| method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__merge
    method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__merge -->|fallback| method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__condition
    method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__true -->|next| method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__merge
    method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_repository_write_193_10__linear -->|next| method_1egheyd_executeairequestandcacheasync__action_193_executeairequestandcacheasync_branch_193_9__condition
    method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__condition -->|otherwise| method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__false
    method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__condition -->|fallback| method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__true
    method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__false -->|next| method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__merge
    method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__merge -->|next| method_1egheyd_executeairequestandcacheasync__action_202_executeairequestandcacheasync_await_202_12__await
    method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__true -->|next| method_1egheyd_executeairequestandcacheasync__action_194_executeairequestandcacheasync_fallback_194_11__merge
    method_1egheyd_executeairequestandcacheasync__action_202_executeairequestandcacheasync_await_202_12__await -->|next| method_1egheyd_executeairequestandcacheasync__action_202_orchestration_202__linear
    method_1egheyd_executeairequestandcacheasync__action_202_orchestration_202__linear -->|knowledgePacket, tenantId, ebookId, dbContext, default CancellationToken| method_1egheyd_executeairequestandcacheasync__call_202_ProcessKnowledgeUnitsAsync
    method_1egheyd_executeairequestandcacheasync__action_204_executeairequestandcacheasync_await_204_13__await -->|next| method_1egheyd_executeairequestandcacheasync__action_204_persistence_write_204__linear
    method_1egheyd_executeairequestandcacheasync__action_204_persistence_write_204__linear -->|return| method_1egheyd_executeairequestandcacheasync__action_205_executeairequestandcacheasync_return_205_14__return
    method_1egheyd_executeairequestandcacheasync__action_205_executeairequestandcacheasync_return_205_14__return -->|exception| method_1egheyd_executeairequestandcacheasync__action_207_executeairequestandcacheasync_catch_207_15__catch
    method_1egheyd_executeairequestandcacheasync__action_207_executeairequestandcacheasync_catch_207_15__catch -->|next| method_1egheyd_executeairequestandcacheasync__action_209_executeairequestandcacheasync_log_209_16__linear
    method_1egheyd_executeairequestandcacheasync__action_209_executeairequestandcacheasync_log_209_16__linear -->|return| method_1egheyd_executeairequestandcacheasync__action_210_executeairequestandcacheasync_return_210_17__return
    method_1egheyd_executeairequestandcacheasync__action_210_executeairequestandcacheasync_return_210_17__return -->|next| method_1egheyd_executeairequestandcacheasync__action_213_error_handling_213__linear
    method_1egheyd_executeairequestandcacheasync__action_213_error_handling_213__linear -->|exception| method_1egheyd_executeairequestandcacheasync__action_213_executeairequestandcacheasync_catch_213_18__catch
    method_1egheyd_executeairequestandcacheasync__action_213_executeairequestandcacheasync_catch_213_18__catch -->|return| method_1egheyd_executeairequestandcacheasync__action_215_executeairequestandcacheasync_return_215_19__return
    method_1egheyd_executeairequestandcacheasync__action_215_executeairequestandcacheasync_return_215_19__return -->|next| method_1egheyd_executeairequestandcacheasync__action_217_executeairequestandcacheasync_finally_217_20__finally
    method_1egheyd_executeairequestandcacheasync__action_217_executeairequestandcacheasync_finally_217_20__finally -->|next| method_1egheyd_executeairequestandcacheasync__action_219_cleanup_219__linear
    method_1egheyd_executeairequestandcacheasync__action_219_cleanup_219__linear -->|return| method_1egheyd_executeairequestandcacheasync__implicit_return
    method_1egheyd_executeairequestandcacheasync__call_151_IDbContextFactory_CreateDbContextAsync -->|next| method_1egheyd_executeairequestandcacheasync__action_159_executeairequestandcacheasync_await_159_3__await
    method_1egheyd_executeairequestandcacheasync__call_159_ResiliencePipeline_ExecuteAsync -->|next| method_1egheyd_executeairequestandcacheasync__action_160_executeairequestandcacheasync_await_160_4__await
    method_1egheyd_executeairequestandcacheasync__call_160_IChatClient_GetResponseAsync -->|next| method_1egheyd_executeairequestandcacheasync__action_166_guard_clause_166__condition
    method_1egheyd_executeairequestandcacheasync__call_171_JsonRepairHelper_Repair -->|next| method_1egheyd_executeairequestandcacheasync__action_173_executeairequestandcacheasync_try_173_6__try
    method_1egheyd_executeairequestandcacheasync__call_175_JsonSerializer_Deserialize_KnowledgePacket_ -->|next| method_1egheyd_executeairequestandcacheasync__action_176_executeairequestandcacheasync_guard_clause_176_7__condition
    method_1egheyd_executeairequestandcacheasync__call_202_ProcessKnowledgeUnitsAsync -->|next| method_1egheyd_executeairequestandcacheasync__action_204_executeairequestandcacheasync_await_204_13__await
    method_1egheyd_executeairequestandcacheasync__entry -->|next| method_1egheyd_executeairequestandcacheasync__action_148_executeairequestandcacheasync_log_148_0__linear
```

### ProcessKnowledgeUnitsAsync() Control Flow

_Warnings: diagram method_yif4p8_processknowledgeunitsasync__fragment_diagram exceeds preferred complexity thresholds (39 nodes, 45 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_yif4p8_processknowledgeunitsasync__call_234_AppDbContext_KnowledgeUnits[["AppDbContext.KnowledgeUnits"]]
    method_yif4p8_processknowledgeunitsasync__action_227_mapping_227__linear("collect ids")
    method_yif4p8_processknowledgeunitsasync__action_227_processknowledgeunitsasync_mapping_227_0__linear("Maps data or transforms shape")
    method_yif4p8_processknowledgeunitsasync__action_228_processknowledgeunitsasync_mapping_228_1__linear("Maps data or transforms shape")
    method_yif4p8_processknowledgeunitsasync__action_229_processknowledgeunitsasync_mapping_229_2__linear("Maps data or transforms shape")
    method_yif4p8_processknowledgeunitsasync__action_234_persistence_read_234__linear("fetch existing units in batch")
    method_yif4p8_processknowledgeunitsasync__action_234_processknowledgeunitsasync_await_234_3__await[["Waits for async work"]]
    method_yif4p8_processknowledgeunitsasync__action_240_loop_240__loop_body[["for each unitDto create new KnowledgeUnit or update fields, set EbookId and MetadataJson"]]
    method_yif4p8_processknowledgeunitsasync__action_240_loop_240__loop_entry("upsert each KnowledgeUnit")
    method_yif4p8_processknowledgeunitsasync__action_240_loop_240__loop_exit("exit loop")
    method_yif4p8_processknowledgeunitsasync__action_240_processknowledgeunitsasync_loop_240_5__loop_body[["foreach (var unitDto in packet.Units)"]]
    method_yif4p8_processknowledgeunitsasync__action_240_processknowledgeunitsasync_loop_240_5__loop_entry("var unitDto in packet.Units")
    method_yif4p8_processknowledgeunitsasync__action_240_processknowledgeunitsasync_loop_240_5__loop_exit("Leaves the loop when the condition no longer holds.")
    method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__condition{"unit == null"}
    method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__false("false")
    method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__merge("merge")
    method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__true("true")
    method_yif4p8_processknowledgeunitsasync__action_252_enum_parse_252__linear("parse unit type")
    method_yif4p8_processknowledgeunitsasync__action_266_loop_266__loop_body[["for each link, if both endpoints exist add KnowledgeUnitLink, else log warning"]]
    method_yif4p8_processknowledgeunitsasync__action_266_loop_266__loop_entry("create links")
    method_yif4p8_processknowledgeunitsasync__action_266_loop_266__loop_exit("exit loop")
    method_yif4p8_processknowledgeunitsasync__action_266_processknowledgeunitsasync_loop_266_8__loop_body[["foreach (var linkDto in packet.Links)"]]
    method_yif4p8_processknowledgeunitsasync__action_266_processknowledgeunitsasync_loop_266_8__loop_entry("var linkDto in packet.Links")
    method_yif4p8_processknowledgeunitsasync__action_266_processknowledgeunitsasync_loop_266_8__loop_exit("Leaves the loop when the condition no longer holds.")
    method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__condition{"sourceExists && targetExists"}
    method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__false("false")
    method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__merge("merge")
    method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__true("true")
    method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__condition{"Falls back to alternate path"}
    method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__false("otherwise")
    method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__merge("merge")
    method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__true("fallback")
    method_yif4p8_processknowledgeunitsasync__action_285_log_285__linear("logs skipped invalid link")
    method_yif4p8_processknowledgeunitsasync__action_285_processknowledgeunitsasync_log_285_12__linear("Logs runtime state")
    method_yif4p8_processknowledgeunitsasync__entry(["ProcessKnowledgeUnitsAsync entry"])
    method_yif4p8_processknowledgeunitsasync__action_235_processknowledgeunitsasync_repository_read_235_4__linear[("Reads repository or persistence state")]
    method_yif4p8_processknowledgeunitsasync__action_248_processknowledgeunitsasync_repository_write_248_7__linear[("Writes repository or persistence state")]
    method_yif4p8_processknowledgeunitsasync__action_281_processknowledgeunitsasync_repository_write_281_10__linear[("Writes repository or persistence state")]
    method_yif4p8_processknowledgeunitsasync__implicit_return(["return"])
    method_yif4p8_processknowledgeunitsasync__action_227_mapping_227__linear -->|next| method_yif4p8_processknowledgeunitsasync__action_228_processknowledgeunitsasync_mapping_228_1__linear
    method_yif4p8_processknowledgeunitsasync__action_227_processknowledgeunitsasync_mapping_227_0__linear -->|next| method_yif4p8_processknowledgeunitsasync__action_227_mapping_227__linear
    method_yif4p8_processknowledgeunitsasync__action_228_processknowledgeunitsasync_mapping_228_1__linear -->|next| method_yif4p8_processknowledgeunitsasync__action_229_processknowledgeunitsasync_mapping_229_2__linear
    method_yif4p8_processknowledgeunitsasync__action_229_processknowledgeunitsasync_mapping_229_2__linear -->|next| method_yif4p8_processknowledgeunitsasync__action_234_processknowledgeunitsasync_await_234_3__await
    method_yif4p8_processknowledgeunitsasync__action_234_persistence_read_234__linear -->|query for existing units by Ids| method_yif4p8_processknowledgeunitsasync__call_234_AppDbContext_KnowledgeUnits
    method_yif4p8_processknowledgeunitsasync__action_234_processknowledgeunitsasync_await_234_3__await -->|next| method_yif4p8_processknowledgeunitsasync__action_234_persistence_read_234__linear
    method_yif4p8_processknowledgeunitsasync__action_235_processknowledgeunitsasync_repository_read_235_4__linear -->|next| method_yif4p8_processknowledgeunitsasync__action_240_loop_240__loop_entry
    method_yif4p8_processknowledgeunitsasync__action_240_loop_240__loop_body -->|continue| method_yif4p8_processknowledgeunitsasync__action_240_loop_240__loop_entry
    method_yif4p8_processknowledgeunitsasync__action_240_loop_240__loop_entry -->|iterate| method_yif4p8_processknowledgeunitsasync__action_240_loop_240__loop_body
    method_yif4p8_processknowledgeunitsasync__action_240_loop_240__loop_entry -->|exit| method_yif4p8_processknowledgeunitsasync__action_240_loop_240__loop_exit
    method_yif4p8_processknowledgeunitsasync__action_240_loop_240__loop_exit -->|next| method_yif4p8_processknowledgeunitsasync__action_240_processknowledgeunitsasync_loop_240_5__loop_entry
    method_yif4p8_processknowledgeunitsasync__action_240_processknowledgeunitsasync_loop_240_5__loop_body -->|continue| method_yif4p8_processknowledgeunitsasync__action_240_processknowledgeunitsasync_loop_240_5__loop_entry
    method_yif4p8_processknowledgeunitsasync__action_240_processknowledgeunitsasync_loop_240_5__loop_entry -->|var unitDto in packet.Units| method_yif4p8_processknowledgeunitsasync__action_240_processknowledgeunitsasync_loop_240_5__loop_body
    method_yif4p8_processknowledgeunitsasync__action_240_processknowledgeunitsasync_loop_240_5__loop_entry -->|Leaves the loop when the condition no longer holds.| method_yif4p8_processknowledgeunitsasync__action_240_processknowledgeunitsasync_loop_240_5__loop_exit
    method_yif4p8_processknowledgeunitsasync__action_240_processknowledgeunitsasync_loop_240_5__loop_exit -->|next| method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__condition
    method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__condition -->|false| method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__false
    method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__condition -->|true| method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__true
    method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__false -->|next| method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__merge
    method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__merge -->|next| method_yif4p8_processknowledgeunitsasync__action_248_processknowledgeunitsasync_repository_write_248_7__linear
    method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__true -->|next| method_yif4p8_processknowledgeunitsasync__action_245_processknowledgeunitsasync_branch_245_6__merge
    method_yif4p8_processknowledgeunitsasync__action_248_processknowledgeunitsasync_repository_write_248_7__linear -->|next| method_yif4p8_processknowledgeunitsasync__action_252_enum_parse_252__linear
    method_yif4p8_processknowledgeunitsasync__action_252_enum_parse_252__linear -->|next| method_yif4p8_processknowledgeunitsasync__action_266_processknowledgeunitsasync_loop_266_8__loop_entry
    method_yif4p8_processknowledgeunitsasync__action_266_loop_266__loop_body -->|continue| method_yif4p8_processknowledgeunitsasync__action_266_loop_266__loop_entry
    method_yif4p8_processknowledgeunitsasync__action_266_loop_266__loop_entry -->|iterate| method_yif4p8_processknowledgeunitsasync__action_266_loop_266__loop_body
    method_yif4p8_processknowledgeunitsasync__action_266_loop_266__loop_entry -->|exit| method_yif4p8_processknowledgeunitsasync__action_266_loop_266__loop_exit
    method_yif4p8_processknowledgeunitsasync__action_266_loop_266__loop_exit -->|next| method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__condition
    method_yif4p8_processknowledgeunitsasync__action_266_processknowledgeunitsasync_loop_266_8__loop_body -->|continue| method_yif4p8_processknowledgeunitsasync__action_266_processknowledgeunitsasync_loop_266_8__loop_entry
    method_yif4p8_processknowledgeunitsasync__action_266_processknowledgeunitsasync_loop_266_8__loop_entry -->|var linkDto in packet.Links| method_yif4p8_processknowledgeunitsasync__action_266_processknowledgeunitsasync_loop_266_8__loop_body
    method_yif4p8_processknowledgeunitsasync__action_266_processknowledgeunitsasync_loop_266_8__loop_entry -->|Leaves the loop when the condition no longer holds.| method_yif4p8_processknowledgeunitsasync__action_266_processknowledgeunitsasync_loop_266_8__loop_exit
    method_yif4p8_processknowledgeunitsasync__action_266_processknowledgeunitsasync_loop_266_8__loop_exit -->|next| method_yif4p8_processknowledgeunitsasync__action_266_loop_266__loop_entry
    method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__condition -->|false| method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__false
    method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__condition -->|true| method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__true
    method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__false -->|next| method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__merge
    method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__merge -->|next| method_yif4p8_processknowledgeunitsasync__action_281_processknowledgeunitsasync_repository_write_281_10__linear
    method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__true -->|next| method_yif4p8_processknowledgeunitsasync__action_271_processknowledgeunitsasync_branch_271_9__merge
    method_yif4p8_processknowledgeunitsasync__action_281_processknowledgeunitsasync_repository_write_281_10__linear -->|fallback| method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__condition
    method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__condition -->|otherwise| method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__false
    method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__condition -->|fallback| method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__true
    method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__false -->|next| method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__merge
    method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__merge -->|next| method_yif4p8_processknowledgeunitsasync__action_285_log_285__linear
    method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__true -->|next| method_yif4p8_processknowledgeunitsasync__action_283_processknowledgeunitsasync_fallback_283_11__merge
    method_yif4p8_processknowledgeunitsasync__action_285_log_285__linear -->|next| method_yif4p8_processknowledgeunitsasync__action_285_processknowledgeunitsasync_log_285_12__linear
    method_yif4p8_processknowledgeunitsasync__action_285_processknowledgeunitsasync_log_285_12__linear -->|return| method_yif4p8_processknowledgeunitsasync__implicit_return
    method_yif4p8_processknowledgeunitsasync__call_234_AppDbContext_KnowledgeUnits -->|next| method_yif4p8_processknowledgeunitsasync__action_235_processknowledgeunitsasync_repository_read_235_4__linear
    method_yif4p8_processknowledgeunitsasync__entry -->|next| method_yif4p8_processknowledgeunitsasync__action_227_processknowledgeunitsasync_mapping_227_0__linear
```

### VerifyGroundednessAsync() Control Flow

```mermaid
flowchart TD
    method_6gn0zk_verifygroundednessasync__call_308_ResiliencePipeline_ExecuteAsync[["ResiliencePipeline.ExecuteAsync"]]
    method_6gn0zk_verifygroundednessasync__call_309_IChatClient_GetResponseAsync[["IChatClient.GetResponseAsync"]]
    method_6gn0zk_verifygroundednessasync__call_318_JsonSerializer_Deserialize_GroundednessResult_[["JsonSerializer.Deserialize<GroundednessResult>"]]
    method_6gn0zk_verifygroundednessasync__action_292_prompt_build_292__linear("compose system and user prompts for fact-checking")
    method_6gn0zk_verifygroundednessasync__action_300_verifygroundednessasync_try_300_1__try("Begins protected execution")
    method_6gn0zk_verifygroundednessasync__action_308_retry_308__loop_body[["uses _retryPipeline.ExecuteAsync"]]
    method_6gn0zk_verifygroundednessasync__action_308_retry_308__loop_entry("invoke chat client via retry pipeline")
    method_6gn0zk_verifygroundednessasync__action_308_retry_308__loop_exit("exit loop")
    method_6gn0zk_verifygroundednessasync__action_308_verifygroundednessasync_await_308_2__await[["Waits for async work"]]
    method_6gn0zk_verifygroundednessasync__action_309_verifygroundednessasync_await_309_3__await[["Waits for async work"]]
    method_6gn0zk_verifygroundednessasync__action_316_text_cleanup_316__linear("strip markdown")
    method_6gn0zk_verifygroundednessasync__action_318_json_deserialize_318__linear("parse groundedness result")
    method_6gn0zk_verifygroundednessasync__action_322_error_handling_322__linear("return failure on exception")
    method_6gn0zk_verifygroundednessasync__action_322_verifygroundednessasync_catch_322_5__catch("catch Exception ex")
    method_6gn0zk_verifygroundednessasync__entry(["VerifyGroundednessAsync entry"])
    method_6gn0zk_verifygroundednessasync__action_295_verifygroundednessasync_return_295_0__return(["Returns result"])
    method_6gn0zk_verifygroundednessasync__action_320_verifygroundednessasync_return_320_4__return(["Returns result"])
    method_6gn0zk_verifygroundednessasync__action_324_verifygroundednessasync_return_324_6__return(["Returns result"])
    method_6gn0zk_verifygroundednessasync__action_292_prompt_build_292__linear -->|return| method_6gn0zk_verifygroundednessasync__action_295_verifygroundednessasync_return_295_0__return
    method_6gn0zk_verifygroundednessasync__action_295_verifygroundednessasync_return_295_0__return -->|next| method_6gn0zk_verifygroundednessasync__action_300_verifygroundednessasync_try_300_1__try
    method_6gn0zk_verifygroundednessasync__action_300_verifygroundednessasync_try_300_1__try -->|next| method_6gn0zk_verifygroundednessasync__action_308_verifygroundednessasync_await_308_2__await
    method_6gn0zk_verifygroundednessasync__action_308_retry_308__loop_body -->|retry| method_6gn0zk_verifygroundednessasync__action_308_retry_308__loop_entry
    method_6gn0zk_verifygroundednessasync__action_308_retry_308__loop_entry -->|iterate| method_6gn0zk_verifygroundednessasync__action_308_retry_308__loop_body
    method_6gn0zk_verifygroundednessasync__action_308_retry_308__loop_entry -->|exit| method_6gn0zk_verifygroundednessasync__action_308_retry_308__loop_exit
    method_6gn0zk_verifygroundednessasync__action_308_retry_308__loop_exit -->|calls _chatClient.GetResponseAsync with system and user prompts| method_6gn0zk_verifygroundednessasync__call_308_ResiliencePipeline_ExecuteAsync
    method_6gn0zk_verifygroundednessasync__action_308_verifygroundednessasync_await_308_2__await -->|next| method_6gn0zk_verifygroundednessasync__action_308_retry_308__loop_entry
    method_6gn0zk_verifygroundednessasync__action_309_verifygroundednessasync_await_309_3__await -->|systemPrompt and userPrompt, ChatOptions| method_6gn0zk_verifygroundednessasync__call_309_IChatClient_GetResponseAsync
    method_6gn0zk_verifygroundednessasync__action_316_text_cleanup_316__linear -->|next| method_6gn0zk_verifygroundednessasync__action_318_json_deserialize_318__linear
    method_6gn0zk_verifygroundednessasync__action_318_json_deserialize_318__linear -->|rawJson| method_6gn0zk_verifygroundednessasync__call_318_JsonSerializer_Deserialize_GroundednessResult_
    method_6gn0zk_verifygroundednessasync__action_320_verifygroundednessasync_return_320_4__return -->|next| method_6gn0zk_verifygroundednessasync__action_322_error_handling_322__linear
    method_6gn0zk_verifygroundednessasync__action_322_error_handling_322__linear -->|exception| method_6gn0zk_verifygroundednessasync__action_322_verifygroundednessasync_catch_322_5__catch
    method_6gn0zk_verifygroundednessasync__action_322_verifygroundednessasync_catch_322_5__catch -->|return| method_6gn0zk_verifygroundednessasync__action_324_verifygroundednessasync_return_324_6__return
    method_6gn0zk_verifygroundednessasync__call_308_ResiliencePipeline_ExecuteAsync -->|next| method_6gn0zk_verifygroundednessasync__action_309_verifygroundednessasync_await_309_3__await
    method_6gn0zk_verifygroundednessasync__call_309_IChatClient_GetResponseAsync -->|next| method_6gn0zk_verifygroundednessasync__action_316_text_cleanup_316__linear
    method_6gn0zk_verifygroundednessasync__call_318_JsonSerializer_Deserialize_GroundednessResult_ -->|return| method_6gn0zk_verifygroundednessasync__action_320_verifygroundednessasync_return_320_4__return
    method_6gn0zk_verifygroundednessasync__entry -->|next| method_6gn0zk_verifygroundednessasync__action_292_prompt_build_292__linear
```

### GetRelevantContextAsync() Control Flow

_Warnings: diagram method_1sxv1a4_getrelevantcontextasync__fragment_diagram exceeds preferred complexity thresholds (27 nodes, 26 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_1sxv1a4_getrelevantcontextasync__call_332_IEmbeddingGenerator_GenerateAsync[["IEmbeddingGenerator.GenerateAsync"]]
    method_1sxv1a4_getrelevantcontextasync__call_357_QdrantClient_SearchAsync[["QdrantClient.SearchAsync"]]
    method_1sxv1a4_getrelevantcontextasync__action_330_getrelevantcontextasync_try_330_0__try("Begins protected execution")
    method_1sxv1a4_getrelevantcontextasync__action_332_getrelevantcontextasync_await_332_1__await[["Waits for async work"]]
    method_1sxv1a4_getrelevantcontextasync__action_333_getrelevantcontextasync_await_333_2__await[["Waits for async work"]]
    method_1sxv1a4_getrelevantcontextasync__action_336_build_filter_336__linear("build Qdrant filter for tenant/global")
    method_1sxv1a4_getrelevantcontextasync__action_355_getrelevantcontextasync_try_355_11__try("Begins protected execution")
    method_1sxv1a4_getrelevantcontextasync__action_357_getrelevantcontextasync_await_357_12__await[["Waits for async work"]]
    method_1sxv1a4_getrelevantcontextasync__action_366_getrelevantcontextasync_catch_366_13__catch("catch Exception")
    method_1sxv1a4_getrelevantcontextasync__action_371_getrelevantcontextasync_mapping_371_15__linear("Maps data or transforms shape")
    method_1sxv1a4_getrelevantcontextasync__action_371_mapping_371__linear("map scored points to RelevantContext")
    method_1sxv1a4_getrelevantcontextasync__action_379_error_handling_379__linear("wrap exceptions")
    method_1sxv1a4_getrelevantcontextasync__action_379_getrelevantcontextasync_catch_379_17__catch("catch Exception ex")
    method_1sxv1a4_getrelevantcontextasync__entry(["GetRelevantContextAsync entry"])
    method_1sxv1a4_getrelevantcontextasync__action_332_external_call_332__linear("generate embedding")
    method_1sxv1a4_getrelevantcontextasync__action_336_getrelevantcontextasync_external_call_336_3__linear("Calls external dependency")
    method_1sxv1a4_getrelevantcontextasync__action_337_getrelevantcontextasync_external_call_337_4__linear("Calls external dependency")
    method_1sxv1a4_getrelevantcontextasync__action_339_getrelevantcontextasync_external_call_339_5__linear("Calls external dependency")
    method_1sxv1a4_getrelevantcontextasync__action_342_getrelevantcontextasync_external_call_342_6__linear("Calls external dependency")
    method_1sxv1a4_getrelevantcontextasync__action_345_getrelevantcontextasync_external_call_345_7__linear("Calls external dependency")
    method_1sxv1a4_getrelevantcontextasync__action_347_getrelevantcontextasync_external_call_347_8__linear("Calls external dependency")
    method_1sxv1a4_getrelevantcontextasync__action_350_getrelevantcontextasync_external_call_350_9__linear("Calls external dependency")
    method_1sxv1a4_getrelevantcontextasync__action_354_getrelevantcontextasync_external_call_354_10__linear("Calls external dependency")
    method_1sxv1a4_getrelevantcontextasync__action_357_external_call_357__linear("search Qdrant")
    method_1sxv1a4_getrelevantcontextasync__action_368_getrelevantcontextasync_external_call_368_14__linear("Calls external dependency")
    method_1sxv1a4_getrelevantcontextasync__action_377_getrelevantcontextasync_return_377_16__return(["Returns result"])
    method_1sxv1a4_getrelevantcontextasync__action_381_getrelevantcontextasync_return_381_18__return(["Returns result"])
    method_1sxv1a4_getrelevantcontextasync__action_330_getrelevantcontextasync_try_330_0__try -->|next| method_1sxv1a4_getrelevantcontextasync__action_332_getrelevantcontextasync_await_332_1__await
    method_1sxv1a4_getrelevantcontextasync__action_332_external_call_332__linear -->|single query string, cancellation token| method_1sxv1a4_getrelevantcontextasync__call_332_IEmbeddingGenerator_GenerateAsync
    method_1sxv1a4_getrelevantcontextasync__action_332_getrelevantcontextasync_await_332_1__await -->|next| method_1sxv1a4_getrelevantcontextasync__action_332_external_call_332__linear
    method_1sxv1a4_getrelevantcontextasync__action_333_getrelevantcontextasync_await_333_2__await -->|next| method_1sxv1a4_getrelevantcontextasync__action_336_getrelevantcontextasync_external_call_336_3__linear
    method_1sxv1a4_getrelevantcontextasync__action_336_build_filter_336__linear -->|next| method_1sxv1a4_getrelevantcontextasync__action_337_getrelevantcontextasync_external_call_337_4__linear
    method_1sxv1a4_getrelevantcontextasync__action_336_getrelevantcontextasync_external_call_336_3__linear -->|next| method_1sxv1a4_getrelevantcontextasync__action_336_build_filter_336__linear
    method_1sxv1a4_getrelevantcontextasync__action_337_getrelevantcontextasync_external_call_337_4__linear -->|next| method_1sxv1a4_getrelevantcontextasync__action_339_getrelevantcontextasync_external_call_339_5__linear
    method_1sxv1a4_getrelevantcontextasync__action_339_getrelevantcontextasync_external_call_339_5__linear -->|next| method_1sxv1a4_getrelevantcontextasync__action_342_getrelevantcontextasync_external_call_342_6__linear
    method_1sxv1a4_getrelevantcontextasync__action_342_getrelevantcontextasync_external_call_342_6__linear -->|next| method_1sxv1a4_getrelevantcontextasync__action_345_getrelevantcontextasync_external_call_345_7__linear
    method_1sxv1a4_getrelevantcontextasync__action_345_getrelevantcontextasync_external_call_345_7__linear -->|next| method_1sxv1a4_getrelevantcontextasync__action_347_getrelevantcontextasync_external_call_347_8__linear
    method_1sxv1a4_getrelevantcontextasync__action_347_getrelevantcontextasync_external_call_347_8__linear -->|next| method_1sxv1a4_getrelevantcontextasync__action_350_getrelevantcontextasync_external_call_350_9__linear
    method_1sxv1a4_getrelevantcontextasync__action_350_getrelevantcontextasync_external_call_350_9__linear -->|next| method_1sxv1a4_getrelevantcontextasync__action_354_getrelevantcontextasync_external_call_354_10__linear
    method_1sxv1a4_getrelevantcontextasync__action_354_getrelevantcontextasync_external_call_354_10__linear -->|next| method_1sxv1a4_getrelevantcontextasync__action_355_getrelevantcontextasync_try_355_11__try
    method_1sxv1a4_getrelevantcontextasync__action_355_getrelevantcontextasync_try_355_11__try -->|next| method_1sxv1a4_getrelevantcontextasync__action_357_getrelevantcontextasync_await_357_12__await
    method_1sxv1a4_getrelevantcontextasync__action_357_external_call_357__linear -->|calls| method_1sxv1a4_getrelevantcontextasync__call_357_QdrantClient_SearchAsync
    method_1sxv1a4_getrelevantcontextasync__action_357_getrelevantcontextasync_await_357_12__await -->|next| method_1sxv1a4_getrelevantcontextasync__action_357_external_call_357__linear
    method_1sxv1a4_getrelevantcontextasync__action_366_getrelevantcontextasync_catch_366_13__catch -->|next| method_1sxv1a4_getrelevantcontextasync__action_368_getrelevantcontextasync_external_call_368_14__linear
    method_1sxv1a4_getrelevantcontextasync__action_368_getrelevantcontextasync_external_call_368_14__linear -->|next| method_1sxv1a4_getrelevantcontextasync__action_371_getrelevantcontextasync_mapping_371_15__linear
    method_1sxv1a4_getrelevantcontextasync__action_371_getrelevantcontextasync_mapping_371_15__linear -->|next| method_1sxv1a4_getrelevantcontextasync__action_371_mapping_371__linear
    method_1sxv1a4_getrelevantcontextasync__action_371_mapping_371__linear -->|return| method_1sxv1a4_getrelevantcontextasync__action_377_getrelevantcontextasync_return_377_16__return
    method_1sxv1a4_getrelevantcontextasync__action_377_getrelevantcontextasync_return_377_16__return -->|next| method_1sxv1a4_getrelevantcontextasync__action_379_error_handling_379__linear
    method_1sxv1a4_getrelevantcontextasync__action_379_error_handling_379__linear -->|exception| method_1sxv1a4_getrelevantcontextasync__action_379_getrelevantcontextasync_catch_379_17__catch
    method_1sxv1a4_getrelevantcontextasync__action_379_getrelevantcontextasync_catch_379_17__catch -->|return| method_1sxv1a4_getrelevantcontextasync__action_381_getrelevantcontextasync_return_381_18__return
    method_1sxv1a4_getrelevantcontextasync__call_332_IEmbeddingGenerator_GenerateAsync -->|next| method_1sxv1a4_getrelevantcontextasync__action_333_getrelevantcontextasync_await_333_2__await
    method_1sxv1a4_getrelevantcontextasync__call_357_QdrantClient_SearchAsync -->|exception| method_1sxv1a4_getrelevantcontextasync__action_366_getrelevantcontextasync_catch_366_13__catch
    method_1sxv1a4_getrelevantcontextasync__entry -->|next| method_1sxv1a4_getrelevantcontextasync__action_330_getrelevantcontextasync_try_330_0__try
```

### SearchLibrarySemanticallyAsync() Control Flow

_Warnings: diagram method_yy3thw_searchlibrarysemanticallyasync__fragment_diagram exceeds preferred complexity thresholds (92 nodes, 101 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_yy3thw_searchlibrarysemanticallyasync__call_390_IEmbeddingGenerator_GenerateAsync[["IEmbeddingGenerator.GenerateAsync"]]
    method_yy3thw_searchlibrarysemanticallyasync__call_420_QdrantClient_SearchAsync[["QdrantClient.SearchAsync"]]
    method_yy3thw_searchlibrarysemanticallyasync__call_448_IDriver_AsyncSession[["IDriver.AsyncSession"]]
    method_yy3thw_searchlibrarysemanticallyasync__call_454_session_ExecuteReadAsync[["session.ExecuteReadAsync"]]
    method_yy3thw_searchlibrarysemanticallyasync__call_487_IDbContextFactory_CreateDbContextAsync[["IDbContextFactory.CreateDbContextAsync"]]
    method_yy3thw_searchlibrarysemanticallyasync__call_517_JsonSerializer_Deserialize_Dictionary_string_object_[["JsonSerializer.Deserialize<Dictionary<string, object>>"]]
    method_yy3thw_searchlibrarysemanticallyasync__action_387_searchlibrarysemanticallyasync_try_387_0__try("Begins protected execution")
    method_yy3thw_searchlibrarysemanticallyasync__action_390_searchlibrarysemanticallyasync_await_390_1__await[["Waits for async work"]]
    method_yy3thw_searchlibrarysemanticallyasync__action_391_searchlibrarysemanticallyasync_await_391_2__await[["Waits for async work"]]
    method_yy3thw_searchlibrarysemanticallyasync__action_399_build_filter_399__linear("build Qdrant tenant/global filter")
    method_yy3thw_searchlibrarysemanticallyasync__action_418_searchlibrarysemanticallyasync_try_418_11__try("Begins protected execution")
    method_yy3thw_searchlibrarysemanticallyasync__action_420_searchlibrarysemanticallyasync_await_420_12__await[["Waits for async work"]]
    method_yy3thw_searchlibrarysemanticallyasync__action_429_searchlibrarysemanticallyasync_catch_429_13__catch("catch Exception ex")
    method_yy3thw_searchlibrarysemanticallyasync__action_431_searchlibrarysemanticallyasync_log_431_14__linear("Logs runtime state")
    method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__condition{"empty result fast path"}
    method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__false("false")
    method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__merge("merge")
    method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__true("true")
    method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__condition{"!searchResult.Any()"}
    method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__false("false")
    method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__merge("merge")
    method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__true("true")
    method_yy3thw_searchlibrarysemanticallyasync__action_441_searchlibrarysemanticallyasync_mapping_441_18__linear("Maps data or transforms shape")
    method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__condition{"candidateIds.Any()"}
    method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__false("false")
    method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__merge("merge")
    method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__true("true")
    method_yy3thw_searchlibrarysemanticallyasync__action_446_searchlibrarysemanticallyasync_try_446_20__try("Begins protected execution")
    method_yy3thw_searchlibrarysemanticallyasync__action_448_graph_query_448__linear("neo4j graph expansion")
    method_yy3thw_searchlibrarysemanticallyasync__action_448_searchlibrarysemanticallyasync_await_448_21__await[["Waits for async work"]]
    method_yy3thw_searchlibrarysemanticallyasync__action_454_searchlibrarysemanticallyasync_await_454_23__await[["Waits for async work"]]
    method_yy3thw_searchlibrarysemanticallyasync__action_456_searchlibrarysemanticallyasync_await_456_24__await[["Waits for async work"]]
    method_yy3thw_searchlibrarysemanticallyasync__action_457_searchlibrarysemanticallyasync_await_457_25__await[["Waits for async work"]]
    method_yy3thw_searchlibrarysemanticallyasync__action_460_searchlibrarysemanticallyasync_loop_460_27__loop_body[["foreach (var record in neoResult)"]]
    method_yy3thw_searchlibrarysemanticallyasync__action_460_searchlibrarysemanticallyasync_loop_460_27__loop_entry("var record in neoResult")
    method_yy3thw_searchlibrarysemanticallyasync__action_460_searchlibrarysemanticallyasync_loop_460_27__loop_exit("Leaves the loop when the condition no longer holds.")
    method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__condition{"!definitions.ContainsKey(sourceId)"}
    method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__false("false")
    method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__merge("merge")
    method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__true("true")
    method_yy3thw_searchlibrarysemanticallyasync__action_471_searchlibrarysemanticallyasync_catch_471_29__catch("catch Exception ex")
    method_yy3thw_searchlibrarysemanticallyasync__action_473_searchlibrarysemanticallyasync_log_473_30__linear("Logs runtime state")
    method_yy3thw_searchlibrarysemanticallyasync__action_480_searchlibrarysemanticallyasync_mapping_480_32__linear("Maps data or transforms shape")
    method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__condition{"ebookIds.Any()"}
    method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__false("false")
    method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__merge("merge")
    method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__true("true")
    method_yy3thw_searchlibrarysemanticallyasync__action_487_persistence_read_487__linear("retrieve ebook titles")
    method_yy3thw_searchlibrarysemanticallyasync__action_487_searchlibrarysemanticallyasync_await_487_34__await[["Waits for async work"]]
    method_yy3thw_searchlibrarysemanticallyasync__action_488_searchlibrarysemanticallyasync_await_488_35__await[["Waits for async work"]]
    method_yy3thw_searchlibrarysemanticallyasync__action_494_mapping_494__linear("map search points to DTOs")
    method_yy3thw_searchlibrarysemanticallyasync__action_494_searchlibrarysemanticallyasync_mapping_494_37__linear("Maps data or transforms shape")
    method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__condition{"Guid.TryParse(ebookIdStr, out var parsedId)"}
    method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__false("false")
    method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__merge("merge")
    method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__true("true")
    method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__condition{"ebookId.HasValue"}
    method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__false("false")
    method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__merge("merge")
    method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__true("true")
    method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__condition{"point.Payload.TryGetValue(\\"metadataJson\\", out var metaVal) && !string.IsNullOrEmpty(metaVal.StringValue)"}
    method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__false("false")
    method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__merge("merge")
    method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__true("true")
    method_yy3thw_searchlibrarysemanticallyasync__action_515_searchlibrarysemanticallyasync_try_515_41__try("Begins protected execution")
    method_yy3thw_searchlibrarysemanticallyasync__action_519_searchlibrarysemanticallyasync_catch_519_42__catch("Handles exception path")
    method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__condition{"definitions.TryGetValue(pointIdStr, out var pointDefs) && pointDefs.Any()"}
    method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__false("false")
    method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__merge("merge")
    method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__true("true")
    method_yy3thw_searchlibrarysemanticallyasync__action_543_error_handling_543__linear("wrap exceptions")
    method_yy3thw_searchlibrarysemanticallyasync__action_543_searchlibrarysemanticallyasync_catch_543_46__catch("catch Exception ex")
    method_yy3thw_searchlibrarysemanticallyasync__entry(["SearchLibrarySemanticallyAsync entry"])
    method_yy3thw_searchlibrarysemanticallyasync__action_390_external_call_390__linear("generate embedding via retry")
    method_yy3thw_searchlibrarysemanticallyasync__action_399_searchlibrarysemanticallyasync_external_call_399_3__linear("Calls external dependency")
    method_yy3thw_searchlibrarysemanticallyasync__action_400_searchlibrarysemanticallyasync_external_call_400_4__linear("Calls external dependency")
    method_yy3thw_searchlibrarysemanticallyasync__action_402_searchlibrarysemanticallyasync_external_call_402_5__linear("Calls external dependency")
    method_yy3thw_searchlibrarysemanticallyasync__action_405_searchlibrarysemanticallyasync_external_call_405_6__linear("Calls external dependency")
    method_yy3thw_searchlibrarysemanticallyasync__action_408_searchlibrarysemanticallyasync_external_call_408_7__linear("Calls external dependency")
    method_yy3thw_searchlibrarysemanticallyasync__action_410_searchlibrarysemanticallyasync_external_call_410_8__linear("Calls external dependency")
    method_yy3thw_searchlibrarysemanticallyasync__action_413_searchlibrarysemanticallyasync_external_call_413_9__linear("Calls external dependency")
    method_yy3thw_searchlibrarysemanticallyasync__action_417_searchlibrarysemanticallyasync_external_call_417_10__linear("Calls external dependency")
    method_yy3thw_searchlibrarysemanticallyasync__action_420_external_call_420__linear("search Qdrant")
    method_yy3thw_searchlibrarysemanticallyasync__action_432_searchlibrarysemanticallyasync_external_call_432_15__linear("Calls external dependency")
    method_yy3thw_searchlibrarysemanticallyasync__action_479_searchlibrarysemanticallyasync_repository_read_479_31__linear[("Reads repository or persistence state")]
    method_yy3thw_searchlibrarysemanticallyasync__action_489_searchlibrarysemanticallyasync_repository_read_489_36__linear[("Reads repository or persistence state")]
    method_yy3thw_searchlibrarysemanticallyasync__action_437_searchlibrarysemanticallyasync_return_437_17__return(["Returns result"])
    method_yy3thw_searchlibrarysemanticallyasync__action_452_searchlibrarysemanticallyasync_return_452_22__return(["Returns result"])
    method_yy3thw_searchlibrarysemanticallyasync__action_457_searchlibrarysemanticallyasync_return_457_26__return(["Returns result"])
    method_yy3thw_searchlibrarysemanticallyasync__action_538_searchlibrarysemanticallyasync_return_538_44__return(["Returns result"])
    method_yy3thw_searchlibrarysemanticallyasync__action_541_searchlibrarysemanticallyasync_return_541_45__return(["Returns result"])
    method_yy3thw_searchlibrarysemanticallyasync__action_545_searchlibrarysemanticallyasync_return_545_47__return(["Returns result"])
    method_yy3thw_searchlibrarysemanticallyasync__action_387_searchlibrarysemanticallyasync_try_387_0__try -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_390_searchlibrarysemanticallyasync_await_390_1__await
    method_yy3thw_searchlibrarysemanticallyasync__action_390_external_call_390__linear -->|queryText, Dimensions=768| method_yy3thw_searchlibrarysemanticallyasync__call_390_IEmbeddingGenerator_GenerateAsync
    method_yy3thw_searchlibrarysemanticallyasync__action_390_searchlibrarysemanticallyasync_await_390_1__await -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_390_external_call_390__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_391_searchlibrarysemanticallyasync_await_391_2__await -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_399_searchlibrarysemanticallyasync_external_call_399_3__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_399_build_filter_399__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_400_searchlibrarysemanticallyasync_external_call_400_4__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_399_searchlibrarysemanticallyasync_external_call_399_3__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_399_build_filter_399__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_400_searchlibrarysemanticallyasync_external_call_400_4__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_402_searchlibrarysemanticallyasync_external_call_402_5__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_402_searchlibrarysemanticallyasync_external_call_402_5__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_405_searchlibrarysemanticallyasync_external_call_405_6__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_405_searchlibrarysemanticallyasync_external_call_405_6__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_408_searchlibrarysemanticallyasync_external_call_408_7__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_408_searchlibrarysemanticallyasync_external_call_408_7__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_410_searchlibrarysemanticallyasync_external_call_410_8__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_410_searchlibrarysemanticallyasync_external_call_410_8__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_413_searchlibrarysemanticallyasync_external_call_413_9__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_413_searchlibrarysemanticallyasync_external_call_413_9__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_417_searchlibrarysemanticallyasync_external_call_417_10__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_417_searchlibrarysemanticallyasync_external_call_417_10__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_418_searchlibrarysemanticallyasync_try_418_11__try
    method_yy3thw_searchlibrarysemanticallyasync__action_418_searchlibrarysemanticallyasync_try_418_11__try -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_420_searchlibrarysemanticallyasync_await_420_12__await
    method_yy3thw_searchlibrarysemanticallyasync__action_420_external_call_420__linear -->|calls| method_yy3thw_searchlibrarysemanticallyasync__call_420_QdrantClient_SearchAsync
    method_yy3thw_searchlibrarysemanticallyasync__action_420_searchlibrarysemanticallyasync_await_420_12__await -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_420_external_call_420__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_429_searchlibrarysemanticallyasync_catch_429_13__catch -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_431_searchlibrarysemanticallyasync_log_431_14__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_431_searchlibrarysemanticallyasync_log_431_14__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_432_searchlibrarysemanticallyasync_external_call_432_15__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_432_searchlibrarysemanticallyasync_external_call_432_15__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__condition
    method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__condition -->|false| method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__false
    method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__condition -->|true| method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__true
    method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__false -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__merge -->|return| method_yy3thw_searchlibrarysemanticallyasync__action_437_searchlibrarysemanticallyasync_return_437_17__return
    method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__true -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__condition -->|false| method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__false
    method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__condition -->|true| method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__true
    method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__false -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__merge -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_435_branch_435__condition
    method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__true -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_435_searchlibrarysemanticallyasync_branch_435_16__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_437_searchlibrarysemanticallyasync_return_437_17__return -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_441_searchlibrarysemanticallyasync_mapping_441_18__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_441_searchlibrarysemanticallyasync_mapping_441_18__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__condition
    method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__condition -->|false| method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__false
    method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__condition -->|true| method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__true
    method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__false -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__merge -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_446_searchlibrarysemanticallyasync_try_446_20__try
    method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__true -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_444_searchlibrarysemanticallyasync_branch_444_19__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_446_searchlibrarysemanticallyasync_try_446_20__try -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_448_searchlibrarysemanticallyasync_await_448_21__await
    method_yy3thw_searchlibrarysemanticallyasync__action_448_graph_query_448__linear -->|create async Neo4j session| method_yy3thw_searchlibrarysemanticallyasync__call_448_IDriver_AsyncSession
    method_yy3thw_searchlibrarysemanticallyasync__action_448_searchlibrarysemanticallyasync_await_448_21__await -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_448_graph_query_448__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_452_searchlibrarysemanticallyasync_return_452_22__return -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_454_searchlibrarysemanticallyasync_await_454_23__await
    method_yy3thw_searchlibrarysemanticallyasync__action_454_searchlibrarysemanticallyasync_await_454_23__await -->|execute cypher to find DEFINES relationships| method_yy3thw_searchlibrarysemanticallyasync__call_454_session_ExecuteReadAsync
    method_yy3thw_searchlibrarysemanticallyasync__action_456_searchlibrarysemanticallyasync_await_456_24__await -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_457_searchlibrarysemanticallyasync_await_457_25__await
    method_yy3thw_searchlibrarysemanticallyasync__action_457_searchlibrarysemanticallyasync_await_457_25__await -->|return| method_yy3thw_searchlibrarysemanticallyasync__action_457_searchlibrarysemanticallyasync_return_457_26__return
    method_yy3thw_searchlibrarysemanticallyasync__action_457_searchlibrarysemanticallyasync_return_457_26__return -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_460_searchlibrarysemanticallyasync_loop_460_27__loop_entry
    method_yy3thw_searchlibrarysemanticallyasync__action_460_searchlibrarysemanticallyasync_loop_460_27__loop_body -->|continue| method_yy3thw_searchlibrarysemanticallyasync__action_460_searchlibrarysemanticallyasync_loop_460_27__loop_entry
    method_yy3thw_searchlibrarysemanticallyasync__action_460_searchlibrarysemanticallyasync_loop_460_27__loop_entry -->|var record in neoResult| method_yy3thw_searchlibrarysemanticallyasync__action_460_searchlibrarysemanticallyasync_loop_460_27__loop_body
    method_yy3thw_searchlibrarysemanticallyasync__action_460_searchlibrarysemanticallyasync_loop_460_27__loop_entry -->|Leaves the loop when the condition no longer holds.| method_yy3thw_searchlibrarysemanticallyasync__action_460_searchlibrarysemanticallyasync_loop_460_27__loop_exit
    method_yy3thw_searchlibrarysemanticallyasync__action_460_searchlibrarysemanticallyasync_loop_460_27__loop_exit -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__condition
    method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__condition -->|false| method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__false
    method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__condition -->|true| method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__true
    method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__false -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__merge -->|exception| method_yy3thw_searchlibrarysemanticallyasync__action_471_searchlibrarysemanticallyasync_catch_471_29__catch
    method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__true -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_464_searchlibrarysemanticallyasync_branch_464_28__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_471_searchlibrarysemanticallyasync_catch_471_29__catch -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_473_searchlibrarysemanticallyasync_log_473_30__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_473_searchlibrarysemanticallyasync_log_473_30__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_479_searchlibrarysemanticallyasync_repository_read_479_31__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_479_searchlibrarysemanticallyasync_repository_read_479_31__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_480_searchlibrarysemanticallyasync_mapping_480_32__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_480_searchlibrarysemanticallyasync_mapping_480_32__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__condition
    method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__condition -->|false| method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__false
    method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__condition -->|true| method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__true
    method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__false -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__merge -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_487_searchlibrarysemanticallyasync_await_487_34__await
    method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__true -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_485_searchlibrarysemanticallyasync_branch_485_33__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_487_persistence_read_487__linear -->|cancellationToken| method_yy3thw_searchlibrarysemanticallyasync__call_487_IDbContextFactory_CreateDbContextAsync
    method_yy3thw_searchlibrarysemanticallyasync__action_487_searchlibrarysemanticallyasync_await_487_34__await -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_487_persistence_read_487__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_488_searchlibrarysemanticallyasync_await_488_35__await -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_489_searchlibrarysemanticallyasync_repository_read_489_36__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_489_searchlibrarysemanticallyasync_repository_read_489_36__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_494_searchlibrarysemanticallyasync_mapping_494_37__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_494_mapping_494__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__condition
    method_yy3thw_searchlibrarysemanticallyasync__action_494_searchlibrarysemanticallyasync_mapping_494_37__linear -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_494_mapping_494__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__condition -->|false| method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__false
    method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__condition -->|true| method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__true
    method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__false -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__merge -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__condition
    method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__true -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_501_searchlibrarysemanticallyasync_branch_501_38__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__condition -->|false| method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__false
    method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__condition -->|true| method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__true
    method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__false -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__merge -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__condition
    method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__true -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_507_searchlibrarysemanticallyasync_branch_507_39__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__condition -->|false| method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__false
    method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__condition -->|true| method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__true
    method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__false -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__merge -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_515_searchlibrarysemanticallyasync_try_515_41__try
    method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__true -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_513_searchlibrarysemanticallyasync_branch_513_40__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_515_searchlibrarysemanticallyasync_try_515_41__try -->|metadataJson payload string| method_yy3thw_searchlibrarysemanticallyasync__call_517_JsonSerializer_Deserialize_Dictionary_string_object_
    method_yy3thw_searchlibrarysemanticallyasync__action_519_searchlibrarysemanticallyasync_catch_519_42__catch -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__condition
    method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__condition -->|false| method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__false
    method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__condition -->|true| method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__true
    method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__false -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__merge -->|return| method_yy3thw_searchlibrarysemanticallyasync__action_538_searchlibrarysemanticallyasync_return_538_44__return
    method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__true -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_533_searchlibrarysemanticallyasync_branch_533_43__merge
    method_yy3thw_searchlibrarysemanticallyasync__action_538_searchlibrarysemanticallyasync_return_538_44__return -->|return| method_yy3thw_searchlibrarysemanticallyasync__action_541_searchlibrarysemanticallyasync_return_541_45__return
    method_yy3thw_searchlibrarysemanticallyasync__action_541_searchlibrarysemanticallyasync_return_541_45__return -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_543_error_handling_543__linear
    method_yy3thw_searchlibrarysemanticallyasync__action_543_error_handling_543__linear -->|exception| method_yy3thw_searchlibrarysemanticallyasync__action_543_searchlibrarysemanticallyasync_catch_543_46__catch
    method_yy3thw_searchlibrarysemanticallyasync__action_543_searchlibrarysemanticallyasync_catch_543_46__catch -->|return| method_yy3thw_searchlibrarysemanticallyasync__action_545_searchlibrarysemanticallyasync_return_545_47__return
    method_yy3thw_searchlibrarysemanticallyasync__call_390_IEmbeddingGenerator_GenerateAsync -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_391_searchlibrarysemanticallyasync_await_391_2__await
    method_yy3thw_searchlibrarysemanticallyasync__call_420_QdrantClient_SearchAsync -->|exception| method_yy3thw_searchlibrarysemanticallyasync__action_429_searchlibrarysemanticallyasync_catch_429_13__catch
    method_yy3thw_searchlibrarysemanticallyasync__call_448_IDriver_AsyncSession -->|return| method_yy3thw_searchlibrarysemanticallyasync__action_452_searchlibrarysemanticallyasync_return_452_22__return
    method_yy3thw_searchlibrarysemanticallyasync__call_454_session_ExecuteReadAsync -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_456_searchlibrarysemanticallyasync_await_456_24__await
    method_yy3thw_searchlibrarysemanticallyasync__call_487_IDbContextFactory_CreateDbContextAsync -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_488_searchlibrarysemanticallyasync_await_488_35__await
    method_yy3thw_searchlibrarysemanticallyasync__call_517_JsonSerializer_Deserialize_Dictionary_string_object_ -->|exception| method_yy3thw_searchlibrarysemanticallyasync__action_519_searchlibrarysemanticallyasync_catch_519_42__catch
    method_yy3thw_searchlibrarysemanticallyasync__entry -->|next| method_yy3thw_searchlibrarysemanticallyasync__action_387_searchlibrarysemanticallyasync_try_387_0__try
```

### AskQuestionAsync() Control Flow

_Warnings: diagram method_io0xiq_askquestionasync__fragment_diagram exceeds preferred complexity thresholds (124 nodes, 137 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_io0xiq_askquestionasync__call_559_IEmbeddingGenerator_GenerateAsync[["IEmbeddingGenerator.GenerateAsync"]]
    method_io0xiq_askquestionasync__call_605_QdrantClient_SearchAsync[["QdrantClient.SearchAsync"]]
    method_io0xiq_askquestionasync__call_640_IDriver_AsyncSession[["IDriver.AsyncSession"]]
    method_io0xiq_askquestionasync__call_648_session_ExecuteReadAsync[["session.ExecuteReadAsync"]]
    method_io0xiq_askquestionasync__call_702_IDbContextFactory_CreateDbContextAsync[["IDbContextFactory.CreateDbContextAsync"]]
    method_io0xiq_askquestionasync__call_740_ResiliencePipeline_ExecuteAsync[["ResiliencePipeline.ExecuteAsync"]]
    method_io0xiq_askquestionasync__call_749_JsonRepairHelper_Repair[["JsonRepairHelper.Repair"]]
    method_io0xiq_askquestionasync__call_753_JsonSerializer_Deserialize_GroundedResponseDto_[["JsonSerializer.Deserialize<GroundedResponseDto>"]]
    method_io0xiq_askquestionasync__action_556_askquestionasync_try_556_0__try("Begins protected execution")
    method_io0xiq_askquestionasync__action_559_askquestionasync_await_559_1__await[["Waits for async work"]]
    method_io0xiq_askquestionasync__action_560_askquestionasync_await_560_2__await[["Waits for async work"]]
    method_io0xiq_askquestionasync__action_568_build_filter_568__linear("compose Qdrant filter for tenant and optional ebookId")
    method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__condition{"ebookId.HasValue"}
    method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__false("false")
    method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__merge("merge")
    method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__true("true")
    method_io0xiq_askquestionasync__action_603_askquestionasync_try_603_17__try("Begins protected execution")
    method_io0xiq_askquestionasync__action_605_askquestionasync_await_605_18__await[["Waits for async work"]]
    method_io0xiq_askquestionasync__action_614_askquestionasync_catch_614_19__catch("catch Exception ex")
    method_io0xiq_askquestionasync__action_616_askquestionasync_log_616_20__linear("Logs runtime state")
    method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__condition{"!searchResult.Any()"}
    method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__false("false")
    method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__merge("merge")
    method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__true("true")
    method_io0xiq_askquestionasync__action_620_guard_clause_620__condition{"no contexts fallback"}
    method_io0xiq_askquestionasync__action_620_guard_clause_620__false("false")
    method_io0xiq_askquestionasync__action_620_guard_clause_620__merge("merge")
    method_io0xiq_askquestionasync__action_620_guard_clause_620__true("true")
    method_io0xiq_askquestionasync__action_630_askquestionasync_mapping_630_25__linear("Maps data or transforms shape")
    method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__condition{"candidateIds.Any()"}
    method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__false("false")
    method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__merge("merge")
    method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__true("true")
    method_io0xiq_askquestionasync__action_638_askquestionasync_try_638_27__try("Begins protected execution")
    method_io0xiq_askquestionasync__action_640_askquestionasync_await_640_28__await[["Waits for async work"]]
    method_io0xiq_askquestionasync__action_640_graph_query_640__linear("neo4j optional expansion")
    method_io0xiq_askquestionasync__action_648_askquestionasync_await_648_30__await[["Waits for async work"]]
    method_io0xiq_askquestionasync__action_650_askquestionasync_await_650_31__await[["Waits for async work"]]
    method_io0xiq_askquestionasync__action_651_askquestionasync_await_651_32__await[["Waits for async work"]]
    method_io0xiq_askquestionasync__action_654_askquestionasync_loop_654_34__loop_body[["foreach (var record in neoResult)"]]
    method_io0xiq_askquestionasync__action_654_askquestionasync_loop_654_34__loop_entry("var record in neoResult")
    method_io0xiq_askquestionasync__action_654_askquestionasync_loop_654_34__loop_exit("Leaves the loop when the condition no longer holds.")
    method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__condition{"relations != null"}
    method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__false("false")
    method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__merge("merge")
    method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__true("true")
    method_io0xiq_askquestionasync__action_664_askquestionasync_loop_664_37__loop_body[["foreach (var relObj in relations)"]]
    method_io0xiq_askquestionasync__action_664_askquestionasync_loop_664_37__loop_entry("var relObj in relations")
    method_io0xiq_askquestionasync__action_664_askquestionasync_loop_664_37__loop_exit("Leaves the loop when the condition no longer holds.")
    method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__condition{"!string.IsNullOrEmpty(targetContent)"}
    method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__false("false")
    method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__merge("merge")
    method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__true("true")
    method_io0xiq_askquestionasync__action_680_askquestionasync_catch_680_40__catch("catch Exception ex")
    method_io0xiq_askquestionasync__action_682_askquestionasync_log_682_41__linear("Logs runtime state")
    method_io0xiq_askquestionasync__action_683_askquestionasync_loop_683_42__loop_body[["foreach (var point in searchResult)"]]
    method_io0xiq_askquestionasync__action_683_askquestionasync_loop_683_42__loop_entry("var point in searchResult")
    method_io0xiq_askquestionasync__action_683_askquestionasync_loop_683_42__loop_exit("Leaves the loop when the condition no longer holds.")
    method_io0xiq_askquestionasync__action_695_askquestionasync_mapping_695_45__linear("Maps data or transforms shape")
    method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__condition{"ebookIds.Any()"}
    method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__false("false")
    method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__merge("merge")
    method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__true("true")
    method_io0xiq_askquestionasync__action_702_askquestionasync_await_702_47__await[["Waits for async work"]]
    method_io0xiq_askquestionasync__action_702_persistence_read_702__linear("retrieve ebook titles for citations")
    method_io0xiq_askquestionasync__action_703_askquestionasync_await_703_48__await[["Waits for async work"]]
    method_io0xiq_askquestionasync__action_711_prompt_build_711__linear("compose strict grounding system prompt and user prompt")
    method_io0xiq_askquestionasync__action_740_askquestionasync_await_740_53__await[["Waits for async work"]]
    method_io0xiq_askquestionasync__action_740_retry_740__loop_body[["uses _retryPipeline.ExecuteAsync to get chat response in JSON format"]]
    method_io0xiq_askquestionasync__action_740_retry_740__loop_entry("invoke Chat client with JSON response format")
    method_io0xiq_askquestionasync__action_740_retry_740__loop_exit("exit loop")
    method_io0xiq_askquestionasync__action_741_askquestionasync_await_741_54__await[["Waits for async work"]]
    method_io0xiq_askquestionasync__action_749_text_cleanup_749__linear("repair JSON")
    method_io0xiq_askquestionasync__action_751_askquestionasync_try_751_55__try("Begins protected execution")
    method_io0xiq_askquestionasync__action_753_json_deserialize_753__linear("parse grounded response")
    method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__condition{"groundedResult == null || string.IsNullOrWhiteSpace(groundedResult.Answer)"}
    method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__false("false")
    method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__merge("merge")
    method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__true("true")
    method_io0xiq_askquestionasync__action_760_askquestionasync_loop_760_58__loop_body[["foreach (var citation in groundedResult.Citations)"]]
    method_io0xiq_askquestionasync__action_760_askquestionasync_loop_760_58__loop_entry("var citation in groundedResult.Citations")
    method_io0xiq_askquestionasync__action_760_askquestionasync_loop_760_58__loop_exit("Leaves the loop when the condition no longer holds.")
    method_io0xiq_askquestionasync__action_760_mapping_760__linear("hydrate citation book titles")
    method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__condition{"pointMap.TryGetValue(citation.CitationId, out var point"}
    method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__false("false")
    method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__merge("merge")
    method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__true("true")
    method_io0xiq_askquestionasync__action_773_askquestionasync_catch_773_61__catch("catch JsonException ex")
    method_io0xiq_askquestionasync__action_775_askquestionasync_log_775_62__linear("Logs runtime state")
    method_io0xiq_askquestionasync__action_779_askquestionasync_catch_779_64__catch("catch Exception ex")
    method_io0xiq_askquestionasync__action_779_error_handling_779__linear("wrap and return failures")
    method_io0xiq_askquestionasync__entry(["AskQuestionAsync entry"])
    method_io0xiq_askquestionasync__action_559_external_call_559__linear("generate embedding")
    method_io0xiq_askquestionasync__action_568_askquestionasync_external_call_568_3__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_571_askquestionasync_external_call_571_4__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_572_askquestionasync_external_call_572_5__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_574_askquestionasync_external_call_574_6__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_577_askquestionasync_external_call_577_7__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_580_askquestionasync_external_call_580_8__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_582_askquestionasync_external_call_582_9__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_585_askquestionasync_external_call_585_10__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_588_askquestionasync_external_call_588_11__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_592_askquestionasync_external_call_592_13__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_594_askquestionasync_external_call_594_14__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_597_askquestionasync_external_call_597_15__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_602_askquestionasync_external_call_602_16__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_605_external_call_605__linear("search Qdrant")
    method_io0xiq_askquestionasync__action_617_askquestionasync_external_call_617_21__linear("Calls external dependency")
    method_io0xiq_askquestionasync__action_624_askquestionasync_repository_read_624_24__linear[("Reads repository or persistence state")]
    method_io0xiq_askquestionasync__action_659_askquestionasync_repository_write_659_35__linear[("Writes repository or persistence state")]
    method_io0xiq_askquestionasync__action_673_askquestionasync_repository_write_673_39__linear[("Writes repository or persistence state")]
    method_io0xiq_askquestionasync__action_687_askquestionasync_repository_write_687_43__linear[("Writes repository or persistence state")]
    method_io0xiq_askquestionasync__action_694_askquestionasync_repository_read_694_44__linear[("Reads repository or persistence state")]
    method_io0xiq_askquestionasync__action_704_askquestionasync_repository_read_704_49__linear[("Reads repository or persistence state")]
    method_io0xiq_askquestionasync__action_715_askquestionasync_repository_read_715_50__linear[("Reads repository or persistence state")]
    method_io0xiq_askquestionasync__action_716_askquestionasync_repository_read_716_51__linear[("Reads repository or persistence state")]
    method_io0xiq_askquestionasync__action_717_askquestionasync_repository_read_717_52__linear[("Reads repository or persistence state")]
    method_io0xiq_askquestionasync__action_622_askquestionasync_return_622_23__return(["Returns result"])
    method_io0xiq_askquestionasync__action_645_askquestionasync_return_645_29__return(["Returns result"])
    method_io0xiq_askquestionasync__action_651_askquestionasync_return_651_33__return(["Returns result"])
    method_io0xiq_askquestionasync__action_756_askquestionasync_return_756_57__return(["Returns result"])
    method_io0xiq_askquestionasync__action_771_askquestionasync_return_771_60__return(["Returns result"])
    method_io0xiq_askquestionasync__action_776_askquestionasync_return_776_63__return(["Returns result"])
    method_io0xiq_askquestionasync__action_781_askquestionasync_return_781_65__return(["Returns result"])
    method_io0xiq_askquestionasync__action_556_askquestionasync_try_556_0__try -->|next| method_io0xiq_askquestionasync__action_559_askquestionasync_await_559_1__await
    method_io0xiq_askquestionasync__action_559_askquestionasync_await_559_1__await -->|next| method_io0xiq_askquestionasync__action_559_external_call_559__linear
    method_io0xiq_askquestionasync__action_559_external_call_559__linear -->|question, Dimensions=768| method_io0xiq_askquestionasync__call_559_IEmbeddingGenerator_GenerateAsync
    method_io0xiq_askquestionasync__action_560_askquestionasync_await_560_2__await -->|next| method_io0xiq_askquestionasync__action_568_build_filter_568__linear
    method_io0xiq_askquestionasync__action_568_askquestionasync_external_call_568_3__linear -->|next| method_io0xiq_askquestionasync__action_571_askquestionasync_external_call_571_4__linear
    method_io0xiq_askquestionasync__action_568_build_filter_568__linear -->|next| method_io0xiq_askquestionasync__action_568_askquestionasync_external_call_568_3__linear
    method_io0xiq_askquestionasync__action_571_askquestionasync_external_call_571_4__linear -->|next| method_io0xiq_askquestionasync__action_572_askquestionasync_external_call_572_5__linear
    method_io0xiq_askquestionasync__action_572_askquestionasync_external_call_572_5__linear -->|next| method_io0xiq_askquestionasync__action_574_askquestionasync_external_call_574_6__linear
    method_io0xiq_askquestionasync__action_574_askquestionasync_external_call_574_6__linear -->|next| method_io0xiq_askquestionasync__action_577_askquestionasync_external_call_577_7__linear
    method_io0xiq_askquestionasync__action_577_askquestionasync_external_call_577_7__linear -->|next| method_io0xiq_askquestionasync__action_580_askquestionasync_external_call_580_8__linear
    method_io0xiq_askquestionasync__action_580_askquestionasync_external_call_580_8__linear -->|next| method_io0xiq_askquestionasync__action_582_askquestionasync_external_call_582_9__linear
    method_io0xiq_askquestionasync__action_582_askquestionasync_external_call_582_9__linear -->|next| method_io0xiq_askquestionasync__action_585_askquestionasync_external_call_585_10__linear
    method_io0xiq_askquestionasync__action_585_askquestionasync_external_call_585_10__linear -->|next| method_io0xiq_askquestionasync__action_588_askquestionasync_external_call_588_11__linear
    method_io0xiq_askquestionasync__action_588_askquestionasync_external_call_588_11__linear -->|next| method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__condition
    method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__condition -->|false| method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__false
    method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__condition -->|true| method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__true
    method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__false -->|next| method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__merge
    method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__merge -->|next| method_io0xiq_askquestionasync__action_592_askquestionasync_external_call_592_13__linear
    method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__true -->|next| method_io0xiq_askquestionasync__action_590_askquestionasync_branch_590_12__merge
    method_io0xiq_askquestionasync__action_592_askquestionasync_external_call_592_13__linear -->|next| method_io0xiq_askquestionasync__action_594_askquestionasync_external_call_594_14__linear
    method_io0xiq_askquestionasync__action_594_askquestionasync_external_call_594_14__linear -->|next| method_io0xiq_askquestionasync__action_597_askquestionasync_external_call_597_15__linear
    method_io0xiq_askquestionasync__action_597_askquestionasync_external_call_597_15__linear -->|next| method_io0xiq_askquestionasync__action_602_askquestionasync_external_call_602_16__linear
    method_io0xiq_askquestionasync__action_602_askquestionasync_external_call_602_16__linear -->|next| method_io0xiq_askquestionasync__action_603_askquestionasync_try_603_17__try
    method_io0xiq_askquestionasync__action_603_askquestionasync_try_603_17__try -->|next| method_io0xiq_askquestionasync__action_605_askquestionasync_await_605_18__await
    method_io0xiq_askquestionasync__action_605_askquestionasync_await_605_18__await -->|next| method_io0xiq_askquestionasync__action_605_external_call_605__linear
    method_io0xiq_askquestionasync__action_605_external_call_605__linear -->|calls| method_io0xiq_askquestionasync__call_605_QdrantClient_SearchAsync
    method_io0xiq_askquestionasync__action_614_askquestionasync_catch_614_19__catch -->|next| method_io0xiq_askquestionasync__action_616_askquestionasync_log_616_20__linear
    method_io0xiq_askquestionasync__action_616_askquestionasync_log_616_20__linear -->|next| method_io0xiq_askquestionasync__action_617_askquestionasync_external_call_617_21__linear
    method_io0xiq_askquestionasync__action_617_askquestionasync_external_call_617_21__linear -->|next| method_io0xiq_askquestionasync__action_620_guard_clause_620__condition
    method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__condition -->|false| method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__false
    method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__condition -->|true| method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__true
    method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__false -->|next| method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__merge
    method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__merge -->|return| method_io0xiq_askquestionasync__action_622_askquestionasync_return_622_23__return
    method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__true -->|next| method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__merge
    method_io0xiq_askquestionasync__action_620_guard_clause_620__condition -->|false| method_io0xiq_askquestionasync__action_620_guard_clause_620__false
    method_io0xiq_askquestionasync__action_620_guard_clause_620__condition -->|true| method_io0xiq_askquestionasync__action_620_guard_clause_620__true
    method_io0xiq_askquestionasync__action_620_guard_clause_620__false -->|next| method_io0xiq_askquestionasync__action_620_guard_clause_620__merge
    method_io0xiq_askquestionasync__action_620_guard_clause_620__merge -->|next| method_io0xiq_askquestionasync__action_620_askquestionasync_branch_620_22__condition
    method_io0xiq_askquestionasync__action_620_guard_clause_620__true -->|next| method_io0xiq_askquestionasync__action_620_guard_clause_620__merge
    method_io0xiq_askquestionasync__action_622_askquestionasync_return_622_23__return -->|next| method_io0xiq_askquestionasync__action_624_askquestionasync_repository_read_624_24__linear
    method_io0xiq_askquestionasync__action_624_askquestionasync_repository_read_624_24__linear -->|next| method_io0xiq_askquestionasync__action_630_askquestionasync_mapping_630_25__linear
    method_io0xiq_askquestionasync__action_630_askquestionasync_mapping_630_25__linear -->|next| method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__condition
    method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__condition -->|false| method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__false
    method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__condition -->|true| method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__true
    method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__false -->|next| method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__merge
    method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__merge -->|next| method_io0xiq_askquestionasync__action_638_askquestionasync_try_638_27__try
    method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__true -->|next| method_io0xiq_askquestionasync__action_636_askquestionasync_branch_636_26__merge
    method_io0xiq_askquestionasync__action_638_askquestionasync_try_638_27__try -->|next| method_io0xiq_askquestionasync__action_640_askquestionasync_await_640_28__await
    method_io0xiq_askquestionasync__action_640_askquestionasync_await_640_28__await -->|next| method_io0xiq_askquestionasync__action_640_graph_query_640__linear
    method_io0xiq_askquestionasync__action_640_graph_query_640__linear -->|open async Neo4j session for optional graph expansion| method_io0xiq_askquestionasync__call_640_IDriver_AsyncSession
    method_io0xiq_askquestionasync__action_645_askquestionasync_return_645_29__return -->|next| method_io0xiq_askquestionasync__action_648_askquestionasync_await_648_30__await
    method_io0xiq_askquestionasync__action_648_askquestionasync_await_648_30__await -->|execute cypher to collect relations| method_io0xiq_askquestionasync__call_648_session_ExecuteReadAsync
    method_io0xiq_askquestionasync__action_650_askquestionasync_await_650_31__await -->|next| method_io0xiq_askquestionasync__action_651_askquestionasync_await_651_32__await
    method_io0xiq_askquestionasync__action_651_askquestionasync_await_651_32__await -->|return| method_io0xiq_askquestionasync__action_651_askquestionasync_return_651_33__return
    method_io0xiq_askquestionasync__action_651_askquestionasync_return_651_33__return -->|next| method_io0xiq_askquestionasync__action_654_askquestionasync_loop_654_34__loop_entry
    method_io0xiq_askquestionasync__action_654_askquestionasync_loop_654_34__loop_body -->|continue| method_io0xiq_askquestionasync__action_654_askquestionasync_loop_654_34__loop_entry
    method_io0xiq_askquestionasync__action_654_askquestionasync_loop_654_34__loop_entry -->|var record in neoResult| method_io0xiq_askquestionasync__action_654_askquestionasync_loop_654_34__loop_body
    method_io0xiq_askquestionasync__action_654_askquestionasync_loop_654_34__loop_entry -->|Leaves the loop when the condition no longer holds.| method_io0xiq_askquestionasync__action_654_askquestionasync_loop_654_34__loop_exit
    method_io0xiq_askquestionasync__action_654_askquestionasync_loop_654_34__loop_exit -->|next| method_io0xiq_askquestionasync__action_659_askquestionasync_repository_write_659_35__linear
    method_io0xiq_askquestionasync__action_659_askquestionasync_repository_write_659_35__linear -->|next| method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__condition
    method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__condition -->|false| method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__false
    method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__condition -->|true| method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__true
    method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__false -->|next| method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__merge
    method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__merge -->|next| method_io0xiq_askquestionasync__action_664_askquestionasync_loop_664_37__loop_entry
    method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__true -->|next| method_io0xiq_askquestionasync__action_662_askquestionasync_branch_662_36__merge
    method_io0xiq_askquestionasync__action_664_askquestionasync_loop_664_37__loop_body -->|continue| method_io0xiq_askquestionasync__action_664_askquestionasync_loop_664_37__loop_entry
    method_io0xiq_askquestionasync__action_664_askquestionasync_loop_664_37__loop_entry -->|var relObj in relations| method_io0xiq_askquestionasync__action_664_askquestionasync_loop_664_37__loop_body
    method_io0xiq_askquestionasync__action_664_askquestionasync_loop_664_37__loop_entry -->|Leaves the loop when the condition no longer holds.| method_io0xiq_askquestionasync__action_664_askquestionasync_loop_664_37__loop_exit
    method_io0xiq_askquestionasync__action_664_askquestionasync_loop_664_37__loop_exit -->|next| method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__condition
    method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__condition -->|false| method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__false
    method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__condition -->|true| method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__true
    method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__false -->|next| method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__merge
    method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__merge -->|next| method_io0xiq_askquestionasync__action_673_askquestionasync_repository_write_673_39__linear
    method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__true -->|next| method_io0xiq_askquestionasync__action_671_askquestionasync_branch_671_38__merge
    method_io0xiq_askquestionasync__action_673_askquestionasync_repository_write_673_39__linear -->|exception| method_io0xiq_askquestionasync__action_680_askquestionasync_catch_680_40__catch
    method_io0xiq_askquestionasync__action_680_askquestionasync_catch_680_40__catch -->|next| method_io0xiq_askquestionasync__action_682_askquestionasync_log_682_41__linear
    method_io0xiq_askquestionasync__action_682_askquestionasync_log_682_41__linear -->|next| method_io0xiq_askquestionasync__action_683_askquestionasync_loop_683_42__loop_entry
    method_io0xiq_askquestionasync__action_683_askquestionasync_loop_683_42__loop_body -->|continue| method_io0xiq_askquestionasync__action_683_askquestionasync_loop_683_42__loop_entry
    method_io0xiq_askquestionasync__action_683_askquestionasync_loop_683_42__loop_entry -->|var point in searchResult| method_io0xiq_askquestionasync__action_683_askquestionasync_loop_683_42__loop_body
    method_io0xiq_askquestionasync__action_683_askquestionasync_loop_683_42__loop_entry -->|Leaves the loop when the condition no longer holds.| method_io0xiq_askquestionasync__action_683_askquestionasync_loop_683_42__loop_exit
    method_io0xiq_askquestionasync__action_683_askquestionasync_loop_683_42__loop_exit -->|next| method_io0xiq_askquestionasync__action_687_askquestionasync_repository_write_687_43__linear
    method_io0xiq_askquestionasync__action_687_askquestionasync_repository_write_687_43__linear -->|next| method_io0xiq_askquestionasync__action_694_askquestionasync_repository_read_694_44__linear
    method_io0xiq_askquestionasync__action_694_askquestionasync_repository_read_694_44__linear -->|next| method_io0xiq_askquestionasync__action_695_askquestionasync_mapping_695_45__linear
    method_io0xiq_askquestionasync__action_695_askquestionasync_mapping_695_45__linear -->|next| method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__condition
    method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__condition -->|false| method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__false
    method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__condition -->|true| method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__true
    method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__false -->|next| method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__merge
    method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__merge -->|next| method_io0xiq_askquestionasync__action_702_askquestionasync_await_702_47__await
    method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__true -->|next| method_io0xiq_askquestionasync__action_700_askquestionasync_branch_700_46__merge
    method_io0xiq_askquestionasync__action_702_askquestionasync_await_702_47__await -->|next| method_io0xiq_askquestionasync__action_702_persistence_read_702__linear
    method_io0xiq_askquestionasync__action_702_persistence_read_702__linear -->|cancellationToken| method_io0xiq_askquestionasync__call_702_IDbContextFactory_CreateDbContextAsync
    method_io0xiq_askquestionasync__action_703_askquestionasync_await_703_48__await -->|next| method_io0xiq_askquestionasync__action_704_askquestionasync_repository_read_704_49__linear
    method_io0xiq_askquestionasync__action_704_askquestionasync_repository_read_704_49__linear -->|next| method_io0xiq_askquestionasync__action_711_prompt_build_711__linear
    method_io0xiq_askquestionasync__action_711_prompt_build_711__linear -->|next| method_io0xiq_askquestionasync__action_715_askquestionasync_repository_read_715_50__linear
    method_io0xiq_askquestionasync__action_715_askquestionasync_repository_read_715_50__linear -->|next| method_io0xiq_askquestionasync__action_716_askquestionasync_repository_read_716_51__linear
    method_io0xiq_askquestionasync__action_716_askquestionasync_repository_read_716_51__linear -->|next| method_io0xiq_askquestionasync__action_717_askquestionasync_repository_read_717_52__linear
    method_io0xiq_askquestionasync__action_717_askquestionasync_repository_read_717_52__linear -->|next| method_io0xiq_askquestionasync__action_740_askquestionasync_await_740_53__await
    method_io0xiq_askquestionasync__action_740_askquestionasync_await_740_53__await -->|next| method_io0xiq_askquestionasync__action_740_retry_740__loop_entry
    method_io0xiq_askquestionasync__action_740_retry_740__loop_body -->|retry| method_io0xiq_askquestionasync__action_740_retry_740__loop_entry
    method_io0xiq_askquestionasync__action_740_retry_740__loop_entry -->|iterate| method_io0xiq_askquestionasync__action_740_retry_740__loop_body
    method_io0xiq_askquestionasync__action_740_retry_740__loop_entry -->|exit| method_io0xiq_askquestionasync__action_740_retry_740__loop_exit
    method_io0xiq_askquestionasync__action_740_retry_740__loop_exit -->|calls _chatClient.GetResponseAsync with system and user prompts and ChatOptions ResponseFormat.Json| method_io0xiq_askquestionasync__call_740_ResiliencePipeline_ExecuteAsync
    method_io0xiq_askquestionasync__action_741_askquestionasync_await_741_54__await -->|next| method_io0xiq_askquestionasync__action_749_text_cleanup_749__linear
    method_io0xiq_askquestionasync__action_749_text_cleanup_749__linear -->|rawJson| method_io0xiq_askquestionasync__call_749_JsonRepairHelper_Repair
    method_io0xiq_askquestionasync__action_751_askquestionasync_try_751_55__try -->|next| method_io0xiq_askquestionasync__action_753_json_deserialize_753__linear
    method_io0xiq_askquestionasync__action_753_json_deserialize_753__linear -->|rawJson| method_io0xiq_askquestionasync__call_753_JsonSerializer_Deserialize_GroundedResponseDto_
    method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__condition -->|false| method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__false
    method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__condition -->|true| method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__true
    method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__false -->|next| method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__merge
    method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__merge -->|return| method_io0xiq_askquestionasync__action_756_askquestionasync_return_756_57__return
    method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__true -->|next| method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__merge
    method_io0xiq_askquestionasync__action_756_askquestionasync_return_756_57__return -->|next| method_io0xiq_askquestionasync__action_760_askquestionasync_loop_760_58__loop_entry
    method_io0xiq_askquestionasync__action_760_askquestionasync_loop_760_58__loop_body -->|continue| method_io0xiq_askquestionasync__action_760_askquestionasync_loop_760_58__loop_entry
    method_io0xiq_askquestionasync__action_760_askquestionasync_loop_760_58__loop_entry -->|var citation in groundedResult.Citations| method_io0xiq_askquestionasync__action_760_askquestionasync_loop_760_58__loop_body
    method_io0xiq_askquestionasync__action_760_askquestionasync_loop_760_58__loop_entry -->|Leaves the loop when the condition no longer holds.| method_io0xiq_askquestionasync__action_760_askquestionasync_loop_760_58__loop_exit
    method_io0xiq_askquestionasync__action_760_askquestionasync_loop_760_58__loop_exit -->|next| method_io0xiq_askquestionasync__action_760_mapping_760__linear
    method_io0xiq_askquestionasync__action_760_mapping_760__linear -->|next| method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__condition
    method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__condition -->|false| method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__false
    method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__condition -->|true| method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__true
    method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__false -->|next| method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__merge
    method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__merge -->|return| method_io0xiq_askquestionasync__action_771_askquestionasync_return_771_60__return
    method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__true -->|next| method_io0xiq_askquestionasync__action_762_askquestionasync_branch_762_59__merge
    method_io0xiq_askquestionasync__action_771_askquestionasync_return_771_60__return -->|exception| method_io0xiq_askquestionasync__action_773_askquestionasync_catch_773_61__catch
    method_io0xiq_askquestionasync__action_773_askquestionasync_catch_773_61__catch -->|next| method_io0xiq_askquestionasync__action_775_askquestionasync_log_775_62__linear
    method_io0xiq_askquestionasync__action_775_askquestionasync_log_775_62__linear -->|return| method_io0xiq_askquestionasync__action_776_askquestionasync_return_776_63__return
    method_io0xiq_askquestionasync__action_776_askquestionasync_return_776_63__return -->|next| method_io0xiq_askquestionasync__action_779_error_handling_779__linear
    method_io0xiq_askquestionasync__action_779_askquestionasync_catch_779_64__catch -->|return| method_io0xiq_askquestionasync__action_781_askquestionasync_return_781_65__return
    method_io0xiq_askquestionasync__action_779_error_handling_779__linear -->|exception| method_io0xiq_askquestionasync__action_779_askquestionasync_catch_779_64__catch
    method_io0xiq_askquestionasync__call_559_IEmbeddingGenerator_GenerateAsync -->|next| method_io0xiq_askquestionasync__action_560_askquestionasync_await_560_2__await
    method_io0xiq_askquestionasync__call_605_QdrantClient_SearchAsync -->|exception| method_io0xiq_askquestionasync__action_614_askquestionasync_catch_614_19__catch
    method_io0xiq_askquestionasync__call_640_IDriver_AsyncSession -->|return| method_io0xiq_askquestionasync__action_645_askquestionasync_return_645_29__return
    method_io0xiq_askquestionasync__call_648_session_ExecuteReadAsync -->|next| method_io0xiq_askquestionasync__action_650_askquestionasync_await_650_31__await
    method_io0xiq_askquestionasync__call_702_IDbContextFactory_CreateDbContextAsync -->|next| method_io0xiq_askquestionasync__action_703_askquestionasync_await_703_48__await
    method_io0xiq_askquestionasync__call_740_ResiliencePipeline_ExecuteAsync -->|next| method_io0xiq_askquestionasync__action_741_askquestionasync_await_741_54__await
    method_io0xiq_askquestionasync__call_749_JsonRepairHelper_Repair -->|next| method_io0xiq_askquestionasync__action_751_askquestionasync_try_751_55__try
    method_io0xiq_askquestionasync__call_753_JsonSerializer_Deserialize_GroundedResponseDto_ -->|next| method_io0xiq_askquestionasync__action_754_askquestionasync_branch_754_56__condition
    method_io0xiq_askquestionasync__entry -->|next| method_io0xiq_askquestionasync__action_556_askquestionasync_try_556_0__try
```

### ClearCacheAsync() Control Flow

```mermaid
flowchart TD
    method_10r1sy2_clearcacheasync__call_787_IDbContextFactory_CreateDbContextAsync[["IDbContextFactory.CreateDbContextAsync"]]
    method_10r1sy2_clearcacheasync__call_790_DbSet_ExecuteDeleteAsync[["DbSet.ExecuteDeleteAsync"]]
    method_10r1sy2_clearcacheasync__call_791_DbSet_ExecuteDeleteAsync[["DbSet.ExecuteDeleteAsync"]]
    method_10r1sy2_clearcacheasync__call_792_DbSet_ExecuteDeleteAsync[["DbSet.ExecuteDeleteAsync"]]
    method_10r1sy2_clearcacheasync__action_787_clearcacheasync_await_787_0__await[["Waits for async work"]]
    method_10r1sy2_clearcacheasync__action_788_clearcacheasync_try_788_1__try("Begins protected execution")
    method_10r1sy2_clearcacheasync__action_790_clearcacheasync_await_790_2__await[["Waits for async work"]]
    method_10r1sy2_clearcacheasync__action_790_persistence_delete_790__linear("clear cache tables")
    method_10r1sy2_clearcacheasync__action_791_clearcacheasync_await_791_3__await[["Waits for async work"]]
    method_10r1sy2_clearcacheasync__action_792_clearcacheasync_await_792_4__await[["Waits for async work"]]
    method_10r1sy2_clearcacheasync__action_795_clearcacheasync_catch_795_6__catch("catch Exception ex")
    method_10r1sy2_clearcacheasync__action_795_error_handling_795__linear("wrap exceptions")
    method_10r1sy2_clearcacheasync__entry(["ClearCacheAsync entry"])
    method_10r1sy2_clearcacheasync__action_793_clearcacheasync_return_793_5__return(["Returns result"])
    method_10r1sy2_clearcacheasync__action_797_clearcacheasync_return_797_7__return(["Returns result"])
    method_10r1sy2_clearcacheasync__action_787_clearcacheasync_await_787_0__await -->|cancellationToken| method_10r1sy2_clearcacheasync__call_787_IDbContextFactory_CreateDbContextAsync
    method_10r1sy2_clearcacheasync__action_788_clearcacheasync_try_788_1__try -->|next| method_10r1sy2_clearcacheasync__action_790_clearcacheasync_await_790_2__await
    method_10r1sy2_clearcacheasync__action_790_clearcacheasync_await_790_2__await -->|next| method_10r1sy2_clearcacheasync__action_790_persistence_delete_790__linear
    method_10r1sy2_clearcacheasync__action_790_persistence_delete_790__linear -->|deletes SemanticKnowledgeCache| method_10r1sy2_clearcacheasync__call_790_DbSet_ExecuteDeleteAsync
    method_10r1sy2_clearcacheasync__action_791_clearcacheasync_await_791_3__await -->|deletes KnowledgeUnits| method_10r1sy2_clearcacheasync__call_791_DbSet_ExecuteDeleteAsync
    method_10r1sy2_clearcacheasync__action_792_clearcacheasync_await_792_4__await -->|deletes KnowledgeUnitLinks| method_10r1sy2_clearcacheasync__call_792_DbSet_ExecuteDeleteAsync
    method_10r1sy2_clearcacheasync__action_793_clearcacheasync_return_793_5__return -->|next| method_10r1sy2_clearcacheasync__action_795_error_handling_795__linear
    method_10r1sy2_clearcacheasync__action_795_clearcacheasync_catch_795_6__catch -->|return| method_10r1sy2_clearcacheasync__action_797_clearcacheasync_return_797_7__return
    method_10r1sy2_clearcacheasync__action_795_error_handling_795__linear -->|exception| method_10r1sy2_clearcacheasync__action_795_clearcacheasync_catch_795_6__catch
    method_10r1sy2_clearcacheasync__call_787_IDbContextFactory_CreateDbContextAsync -->|next| method_10r1sy2_clearcacheasync__action_788_clearcacheasync_try_788_1__try
    method_10r1sy2_clearcacheasync__call_790_DbSet_ExecuteDeleteAsync -->|next| method_10r1sy2_clearcacheasync__action_791_clearcacheasync_await_791_3__await
    method_10r1sy2_clearcacheasync__call_791_DbSet_ExecuteDeleteAsync -->|next| method_10r1sy2_clearcacheasync__action_792_clearcacheasync_await_792_4__await
    method_10r1sy2_clearcacheasync__call_792_DbSet_ExecuteDeleteAsync -->|return| method_10r1sy2_clearcacheasync__action_793_clearcacheasync_return_793_5__return
    method_10r1sy2_clearcacheasync__entry -->|next| method_10r1sy2_clearcacheasync__action_787_clearcacheasync_await_787_0__await
```

### EstimateTokenCount() Control Flow

```mermaid
flowchart TD
    method_1l8c2eg_estimatetokencount__call_804_Tokenizer_CountTokens[["Tokenizer.CountTokens"]]
    method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__condition{"string.IsNullOrEmpty(text)"}
    method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__false("continue")
    method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__merge("merge")
    method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__true("exit")
    method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__condition{"string.IsNullOrEmpty(text)"}
    method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__false("otherwise")
    method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__merge("merge")
    method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__true("0")
    method_1l8c2eg_estimatetokencount__action_804_compute_804__linear("count tokens")
    method_1l8c2eg_estimatetokencount__entry(["EstimateTokenCount entry"])
    method_1l8c2eg_estimatetokencount__action_804_estimatetokencount_return_804_1__return(["Returns result"])
    method_1l8c2eg_estimatetokencount__implicit_return(["return"])
    method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__condition -->|continue| method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__false
    method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__condition -->|exit| method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__true
    method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__false -->|next| method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__merge
    method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__merge -->|next| method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__condition
    method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__true -->|next| method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__merge
    method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__condition -->|otherwise| method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__false
    method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__condition -->|0| method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__true
    method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__false -->|next| method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__merge
    method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__merge -->|return| method_1l8c2eg_estimatetokencount__action_804_estimatetokencount_return_804_1__return
    method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__true -->|next| method_1l8c2eg_estimatetokencount__action_803_guard_clause_803__merge
    method_1l8c2eg_estimatetokencount__action_804_compute_804__linear -->|text| method_1l8c2eg_estimatetokencount__call_804_Tokenizer_CountTokens
    method_1l8c2eg_estimatetokencount__action_804_estimatetokencount_return_804_1__return -->|next| method_1l8c2eg_estimatetokencount__action_804_compute_804__linear
    method_1l8c2eg_estimatetokencount__call_804_Tokenizer_CountTokens -->|return| method_1l8c2eg_estimatetokencount__implicit_return
    method_1l8c2eg_estimatetokencount__entry -->|next| method_1l8c2eg_estimatetokencount__action_803_estimatetokencount_guard_clause_803_0__condition
```

## Diagram Validation

- Status: warn
- Warning: Control-flow extraction left 34 unresolved jumps.
- Warning: neighborhood-view: diagram file_27eki7_knowledgeservice_cs_neighborhood_view exceeds preferred complexity thresholds (18 nodes, 2 edges).
- Warning: execution-overview: diagram file_27eki7_knowledgeservice_cs_execution_view exceeds preferred complexity thresholds (73 nodes, 78 edges).
- Warning: control-flow: diagram method_965937_getknowledgeinternalasync__fragment_diagram exceeds preferred complexity thresholds (49 nodes, 55 edges).
- Warning: control-flow: diagram method_1egheyd_executeairequestandcacheasync__fragment_diagram exceeds preferred complexity thresholds (56 nodes, 61 edges).
- Warning: control-flow: diagram method_yif4p8_processknowledgeunitsasync__fragment_diagram exceeds preferred complexity thresholds (39 nodes, 45 edges).
- Warning: control-flow: diagram method_1sxv1a4_getrelevantcontextasync__fragment_diagram exceeds preferred complexity thresholds (27 nodes, 26 edges).
- Warning: control-flow: diagram method_yy3thw_searchlibrarysemanticallyasync__fragment_diagram exceeds preferred complexity thresholds (92 nodes, 101 edges).
- Warning: control-flow: diagram method_io0xiq_askquestionasync__fragment_diagram exceeds preferred complexity thresholds (124 nodes, 137 edges).
