@absolutejs/absolute 0.19.0-beta.611 → 0.19.0-beta.613

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ai/index.js CHANGED
@@ -4668,6 +4668,10 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4668
4668
  const vectorHits = channels.includes("vector") ? 1 : 0;
4669
4669
  const lexicalHits = channels.includes("lexical") ? 1 : 0;
4670
4670
  const hybridHits = isHybrid ? 1 : 0;
4671
+ const queryOrigin = source.metadata?.retrievalQueryOrigin;
4672
+ const primaryHits = queryOrigin === "primary" ? 1 : 0;
4673
+ const transformedHits = queryOrigin === "transformed" ? 1 : 0;
4674
+ const variantHits = queryOrigin === "variant" ? 1 : 0;
4671
4675
  if (!existing) {
4672
4676
  sections.set(key, {
4673
4677
  bestScore: source.score,
@@ -4678,10 +4682,13 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4678
4682
  lexicalHits,
4679
4683
  parentLabel,
4680
4684
  path,
4685
+ primaryHits,
4681
4686
  sourceSet: new Set(source.source ? [source.source] : []),
4682
4687
  topChunkId: source.chunkId,
4683
4688
  topSource: source.source,
4684
4689
  totalScore: source.score,
4690
+ transformedHits,
4691
+ variantHits,
4685
4692
  vectorHits
4686
4693
  });
4687
4694
  continue;
@@ -4694,6 +4701,9 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4694
4701
  existing.vectorHits += vectorHits;
4695
4702
  existing.lexicalHits += lexicalHits;
4696
4703
  existing.hybridHits += hybridHits;
4704
+ existing.primaryHits += primaryHits;
4705
+ existing.transformedHits += transformedHits;
4706
+ existing.variantHits += variantHits;
4697
4707
  if (source.score > existing.bestScore) {
4698
4708
  existing.bestScore = source.score;
4699
4709
  existing.topChunkId = source.chunkId;
@@ -4702,6 +4712,9 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4702
4712
  }
4703
4713
  const diagnostics = [...sections.values()];
4704
4714
  const strongestBestHit = diagnostics.reduce((highest, section) => Math.max(highest, section.bestScore), 0);
4715
+ const parentLabelByKey = new Map(diagnostics.map((section) => [section.key, section.parentLabel]));
4716
+ const stageSectionCounts = new Map((trace?.steps ?? []).filter((step) => Array.isArray(step.sectionCounts) && step.sectionCounts.length > 0).map((step) => [step.stage, step.sectionCounts ?? []]));
4717
+ const stageSectionScores = new Map((trace?.steps ?? []).filter((step) => Array.isArray(step.sectionScores) && step.sectionScores.length > 0).map((step) => [step.stage, step.sectionScores ?? []]));
4705
4718
  return diagnostics.map((section) => {
4706
4719
  const siblingPool = diagnostics.filter((entry) => entry.parentLabel === section.parentLabel);
4707
4720
  const siblings = siblingPool.filter((entry) => entry.key !== section.key);
@@ -4722,8 +4735,103 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4722
4735
  count: step.sectionCounts?.find((entry) => entry.key === section.key)?.count ?? 0,
4723
4736
  stage: step.stage
4724
4737
  })).filter((entry) => entry.count > 0) ?? [];
4738
+ const stageWeights = stageCounts.map((entry) => {
4739
+ const previousStageEntry = stageCounts[stageCounts.findIndex((candidate) => candidate.stage === entry.stage) - 1];
4740
+ const stageEntries = stageSectionCounts.get(entry.stage)?.filter((candidate) => candidate.count > 0) ?? [];
4741
+ const stageScoreEntries = stageSectionScores.get(entry.stage)?.filter((candidate) => candidate.totalScore > 0) ?? [];
4742
+ const stageTotal = stageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
4743
+ const stageScoreTotal = stageScoreEntries.reduce((sum, candidate) => sum + candidate.totalScore, 0);
4744
+ const siblingStageEntries = stageEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
4745
+ const parentStageEntries = stageEntries.filter((candidate) => parentLabelByKey.get(candidate.key) === section.parentLabel);
4746
+ const siblingStageScoreEntries = stageScoreEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
4747
+ const parentStageScoreEntries = stageScoreEntries.filter((candidate) => parentLabelByKey.get(candidate.key) === section.parentLabel);
4748
+ const strongestStageSibling = siblingStageEntries.slice().sort((left, right) => right.count - left.count)[0];
4749
+ const parentStageTotal = parentStageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
4750
+ const activeStageScore = stageScoreEntries.find((candidate) => candidate.key === section.key)?.totalScore;
4751
+ const strongestStageScoreSibling = siblingStageScoreEntries.slice().sort((left, right) => right.totalScore - left.totalScore)[0];
4752
+ const parentStageScoreTotal = parentStageScoreEntries.reduce((sum, candidate) => sum + candidate.totalScore, 0);
4753
+ const stageShare = stageTotal > 0 ? entry.count / stageTotal : 0;
4754
+ const retentionRate = typeof previousStageEntry?.count === "number" && previousStageEntry.count > 0 ? entry.count / previousStageEntry.count : undefined;
4755
+ const countDelta = typeof previousStageEntry?.count === "number" ? entry.count - previousStageEntry.count : undefined;
4756
+ const parentStageShare = parentStageTotal > 0 ? entry.count / parentStageTotal : undefined;
4757
+ const stageScoreShare = typeof activeStageScore === "number" && stageScoreTotal > 0 ? activeStageScore / stageScoreTotal : undefined;
4758
+ const parentStageScoreShare = typeof activeStageScore === "number" && parentStageScoreTotal > 0 ? activeStageScore / parentStageScoreTotal : undefined;
4759
+ const stageShareGap = stageTotal > 0 && strongestStageSibling ? entry.count / stageTotal - strongestStageSibling.count / stageTotal : undefined;
4760
+ const parentStageShareGap = parentStageTotal > 0 && strongestStageSibling ? entry.count / parentStageTotal - strongestStageSibling.count / parentStageTotal : undefined;
4761
+ const stageScoreShareGap = typeof activeStageScore === "number" && stageScoreTotal > 0 && strongestStageScoreSibling ? activeStageScore / stageScoreTotal - strongestStageScoreSibling.totalScore / stageScoreTotal : undefined;
4762
+ const parentStageScoreShareGap = typeof activeStageScore === "number" && parentStageScoreTotal > 0 && strongestStageScoreSibling ? activeStageScore / parentStageScoreTotal - strongestStageScoreSibling.totalScore / parentStageScoreTotal : undefined;
4763
+ const reasons2 = [];
4764
+ if (entry.stage === "rerank" && stageShare > 0.5 && (typeof stageShareGap !== "number" || stageShareGap > 0)) {
4765
+ reasons2.push("rerank_preserved_lead");
4766
+ }
4767
+ if (entry.stage === "finalize" && stageShare >= 0.5) {
4768
+ reasons2.push("final_stage_concentration");
4769
+ }
4770
+ if (entry.stage === "finalize" && typeof parentStageShare === "number" && parentStageShare >= 0.6 && (typeof parentStageShareGap !== "number" || parentStageShareGap > 0)) {
4771
+ reasons2.push("final_stage_dominant_within_parent");
4772
+ }
4773
+ if (strongestStageSibling && (typeof stageShareGap === "number" && stageShareGap <= 0.1 || typeof parentStageShareGap === "number" && parentStageShareGap <= 0.1)) {
4774
+ reasons2.push("stage_runner_up_pressure");
4775
+ }
4776
+ if (typeof countDelta === "number") {
4777
+ if (countDelta > 0) {
4778
+ reasons2.push("stage_expanded");
4779
+ } else if (countDelta < 0) {
4780
+ reasons2.push("stage_narrowed");
4781
+ } else {
4782
+ reasons2.push("stage_held");
4783
+ }
4784
+ }
4785
+ return {
4786
+ count: entry.count,
4787
+ countDelta,
4788
+ parentStageScoreShare,
4789
+ parentStageShare,
4790
+ parentStageShareGap,
4791
+ previousCount: previousStageEntry?.count,
4792
+ previousStage: previousStageEntry?.stage,
4793
+ reasons: reasons2,
4794
+ retentionRate,
4795
+ stage: entry.stage,
4796
+ stageScoreShare,
4797
+ stageScoreShareGap,
4798
+ stageShare,
4799
+ stageShareGap,
4800
+ totalScore: activeStageScore,
4801
+ strongestSiblingCount: strongestStageSibling?.count,
4802
+ strongestSiblingLabel: strongestStageSibling ? diagnostics.find((candidate) => candidate.key === strongestStageSibling.key)?.label ?? strongestStageSibling.key : undefined
4803
+ };
4804
+ });
4725
4805
  const firstSeenStage = stageCounts[0]?.stage;
4726
4806
  const lastSeenStage = stageCounts.at(-1)?.stage;
4807
+ const peakStageEntry = stageCounts.reduce((highest, entry) => !highest || entry.count > highest.count ? entry : highest, undefined);
4808
+ const finalStageEntry = stageCounts.at(-1);
4809
+ const peakCount = peakStageEntry?.count ?? section.count;
4810
+ const finalCount = finalStageEntry?.count;
4811
+ const finalRetentionRate = typeof finalCount === "number" && peakCount > 0 ? finalCount / peakCount : undefined;
4812
+ const dropFromPeak = typeof finalCount === "number" ? peakCount - finalCount : undefined;
4813
+ const queryAttributionReasons = [];
4814
+ const queryAttributionMode = section.primaryHits > 0 && section.transformedHits === 0 && section.variantHits === 0 ? "primary" : section.transformedHits > 0 && section.primaryHits === 0 && section.variantHits === 0 ? "transformed" : section.variantHits > 0 && section.primaryHits === 0 && section.transformedHits === 0 ? "variant" : "mixed";
4815
+ if (queryAttributionMode === "primary") {
4816
+ queryAttributionReasons.push("base_query_only");
4817
+ }
4818
+ if (queryAttributionMode === "transformed") {
4819
+ queryAttributionReasons.push("transformed_query_only");
4820
+ queryAttributionReasons.push("transform_introduced");
4821
+ }
4822
+ if (queryAttributionMode === "variant") {
4823
+ queryAttributionReasons.push("variant_only");
4824
+ queryAttributionReasons.push("variant_supported");
4825
+ }
4826
+ if (queryAttributionMode === "mixed") {
4827
+ queryAttributionReasons.push("mixed_query_sources");
4828
+ if (section.variantHits > 0) {
4829
+ queryAttributionReasons.push("variant_supported");
4830
+ }
4831
+ if (section.transformedHits > 0 && section.primaryHits === 0) {
4832
+ queryAttributionReasons.push("transform_introduced");
4833
+ }
4834
+ }
4727
4835
  if (section.bestScore >= strongestBestHit) {
4728
4836
  reasons.push("best_hit");
4729
4837
  }
@@ -4757,13 +4865,26 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4757
4865
  parentShareGap: typeof parentShare === "number" && strongestSibling && parentTotal > 0 ? parentShare - strongestSibling.totalScore / parentTotal : undefined,
4758
4866
  path: section.path,
4759
4867
  firstSeenStage,
4868
+ finalCount,
4869
+ finalRetentionRate,
4760
4870
  lastSeenStage,
4871
+ dropFromPeak,
4872
+ peakCount,
4873
+ peakStage: peakStageEntry?.stage,
4874
+ queryAttribution: {
4875
+ mode: queryAttributionMode,
4876
+ primaryHits: section.primaryHits,
4877
+ reasons: queryAttributionReasons,
4878
+ transformedHits: section.transformedHits,
4879
+ variantHits: section.variantHits
4880
+ },
4761
4881
  retrievalMode: trace?.mode,
4762
4882
  reasons,
4763
4883
  rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
4764
4884
  scoreShare,
4765
4885
  scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
4766
4886
  stageCounts,
4887
+ stageWeights,
4767
4888
  siblingCount: siblings.length,
4768
4889
  siblingScoreGap: strongestSibling ? section.totalScore - strongestSibling.totalScore : undefined,
4769
4890
  sourceCount: section.sourceSet.size,
@@ -10528,12 +10649,13 @@ var applyRAGMMRDiversity = (results, queryVector, lambda) => {
10528
10649
  return [...selected, ...tail];
10529
10650
  };
10530
10651
  var weightQueryResults = (results, queryIndex) => {
10531
- if (queryIndex === 0) {
10532
- return results;
10533
- }
10534
- const weight = Math.pow(VARIANT_RESULT_WEIGHT, queryIndex);
10652
+ const weight = queryIndex === 0 ? 1 : Math.pow(VARIANT_RESULT_WEIGHT, queryIndex);
10535
10653
  return results.map((result) => ({
10536
10654
  ...result,
10655
+ metadata: {
10656
+ ...result.metadata ?? {},
10657
+ retrievalQueryIndex: queryIndex
10658
+ },
10537
10659
  score: result.score * weight
10538
10660
  }));
10539
10661
  };
@@ -10583,6 +10705,43 @@ var buildTraceSectionCounts = (results) => {
10583
10705
  return left.key.localeCompare(right.key);
10584
10706
  });
10585
10707
  };
10708
+ var buildTraceSectionScores = (results) => {
10709
+ const sections = new Map;
10710
+ for (const result of results) {
10711
+ const path = Array.isArray(result.metadata?.sectionPath) ? result.metadata.sectionPath.filter((value) => typeof value === "string" && value.trim().length > 0) : [];
10712
+ if (path.length === 0) {
10713
+ continue;
10714
+ }
10715
+ const key = path.join(" > ");
10716
+ const existing = sections.get(key);
10717
+ if (existing) {
10718
+ existing.totalScore += result.score;
10719
+ continue;
10720
+ }
10721
+ sections.set(key, {
10722
+ key,
10723
+ label: path.at(-1) ?? key,
10724
+ totalScore: result.score
10725
+ });
10726
+ }
10727
+ return [...sections.values()].sort((left, right) => {
10728
+ if (right.totalScore !== left.totalScore) {
10729
+ return right.totalScore - left.totalScore;
10730
+ }
10731
+ return left.key.localeCompare(right.key);
10732
+ });
10733
+ };
10734
+ var annotateRetrievalQueryOrigin = (input) => {
10735
+ const origin = input.queryIndex === 0 ? input.query === input.inputQuery ? "primary" : "transformed" : "variant";
10736
+ return input.results.map((result) => ({
10737
+ ...result,
10738
+ metadata: {
10739
+ ...result.metadata ?? {},
10740
+ retrievalQuery: input.query,
10741
+ retrievalQueryOrigin: origin
10742
+ }
10743
+ }));
10744
+ };
10586
10745
  var shouldRunVectorRetrieval = (mode) => mode === "vector" || mode === "hybrid";
10587
10746
  var shouldRunLexicalRetrieval = (mode, store) => mode === "lexical" || mode === "hybrid" && Boolean(store.queryLexical);
10588
10747
  var createRAGCollection = (options) => {
@@ -10683,8 +10842,20 @@ var createRAGCollection = (options) => {
10683
10842
  }) ?? Promise.resolve([]) : Promise.resolve([])
10684
10843
  ]);
10685
10844
  return {
10686
- lexicalResults: weightQueryResults(lexicalResults2, queryIndex),
10687
- vectorResults: weightQueryResults(vectorResults2, queryIndex)
10845
+ lexicalResults: annotateRetrievalQueryOrigin({
10846
+ inputQuery: input.query,
10847
+ query,
10848
+ queryIndex,
10849
+ results: weightQueryResults(lexicalResults2, queryIndex),
10850
+ transformedQuery: transformed.query
10851
+ }),
10852
+ vectorResults: annotateRetrievalQueryOrigin({
10853
+ inputQuery: input.query,
10854
+ query,
10855
+ queryIndex,
10856
+ results: weightQueryResults(vectorResults2, queryIndex),
10857
+ transformedQuery: transformed.query
10858
+ })
10688
10859
  };
10689
10860
  }));
10690
10861
  const vectorResults = mergeQueryResults(resultGroups.flatMap((group) => group.vectorResults));
@@ -10697,6 +10868,7 @@ var createRAGCollection = (options) => {
10697
10868
  topK: candidateTopK
10698
10869
  },
10699
10870
  sectionCounts: buildTraceSectionCounts(vectorResults),
10871
+ sectionScores: buildTraceSectionScores(vectorResults),
10700
10872
  stage: "vector_search"
10701
10873
  });
10702
10874
  }
@@ -10710,6 +10882,7 @@ var createRAGCollection = (options) => {
10710
10882
  topK: lexicalTopK
10711
10883
  },
10712
10884
  sectionCounts: buildTraceSectionCounts(lexicalResults),
10885
+ sectionScores: buildTraceSectionScores(lexicalResults),
10713
10886
  stage: "lexical_search"
10714
10887
  });
10715
10888
  }
@@ -10728,6 +10901,7 @@ var createRAGCollection = (options) => {
10728
10901
  mode: retrieval.mode
10729
10902
  },
10730
10903
  sectionCounts: buildTraceSectionCounts(results),
10904
+ sectionScores: buildTraceSectionScores(results),
10731
10905
  stage: "fusion"
10732
10906
  });
10733
10907
  const rerankInput = {
@@ -10751,6 +10925,7 @@ var createRAGCollection = (options) => {
10751
10925
  applied: hasReranker
10752
10926
  },
10753
10927
  sectionCounts: buildTraceSectionCounts(reranked),
10928
+ sectionScores: buildTraceSectionScores(reranked),
10754
10929
  stage: "rerank"
10755
10930
  });
10756
10931
  const diversityAdjusted = retrieval.diversityStrategy === "mmr" ? applyRAGMMRDiversity(reranked, queryVector, retrieval.mmrLambda) : reranked;
@@ -10763,6 +10938,7 @@ var createRAGCollection = (options) => {
10763
10938
  mmrLambda: retrieval.mmrLambda
10764
10939
  },
10765
10940
  sectionCounts: buildTraceSectionCounts(diversityAdjusted),
10941
+ sectionScores: buildTraceSectionScores(diversityAdjusted),
10766
10942
  stage: "diversity"
10767
10943
  });
10768
10944
  }
@@ -10776,6 +10952,7 @@ var createRAGCollection = (options) => {
10776
10952
  strategy: retrieval.sourceBalanceStrategy
10777
10953
  },
10778
10954
  sectionCounts: buildTraceSectionCounts(diversified),
10955
+ sectionScores: buildTraceSectionScores(diversified),
10779
10956
  stage: "source_balance"
10780
10957
  });
10781
10958
  }
@@ -10792,6 +10969,7 @@ var createRAGCollection = (options) => {
10792
10969
  appliedScoreThreshold: false
10793
10970
  },
10794
10971
  sectionCounts: buildTraceSectionCounts(limited),
10972
+ sectionScores: buildTraceSectionScores(limited),
10795
10973
  stage: "finalize"
10796
10974
  });
10797
10975
  return {
@@ -10830,6 +11008,7 @@ var createRAGCollection = (options) => {
10830
11008
  scoreThreshold
10831
11009
  },
10832
11010
  sectionCounts: buildTraceSectionCounts(filtered),
11011
+ sectionScores: buildTraceSectionScores(filtered),
10833
11012
  stage: "score_filter"
10834
11013
  });
10835
11014
  steps.push({
@@ -10839,6 +11018,7 @@ var createRAGCollection = (options) => {
10839
11018
  appliedScoreThreshold: true
10840
11019
  },
10841
11020
  sectionCounts: buildTraceSectionCounts(filtered),
11021
+ sectionScores: buildTraceSectionScores(filtered),
10842
11022
  stage: "finalize"
10843
11023
  });
10844
11024
  return {
@@ -10957,7 +11137,7 @@ var renderSectionDiagnostics = (diagnostics) => {
10957
11137
  if (diagnostics.length === 0) {
10958
11138
  return "";
10959
11139
  }
10960
- return `<section class="rag-search-results"><h3>Section diagnostics</h3>` + diagnostics.map((diagnostic) => `<article class="rag-search-result" id="rag-section-diagnostic-${escapeHtml2(diagnostic.key)}">` + `<h4>${escapeHtml2(diagnostic.path?.join(" > ") ?? diagnostic.label)}</h4>` + `<p class="rag-search-source">${escapeHtml2(diagnostic.summary)}</p>` + `<ul class="rag-source-labels">` + `<li><strong>Top hit</strong> ${diagnostic.bestScore.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES)}</li>` + `<li><strong>Average</strong> ${diagnostic.averageScore.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES)}</li>` + `<li><strong>Sources</strong> ${diagnostic.sourceCount}</li>` + `<li><strong>Channels</strong> vector ${diagnostic.vectorHits} \xB7 lexical ${diagnostic.lexicalHits} \xB7 hybrid ${diagnostic.hybridHits}</li>` + `${diagnostic.stageCounts.length > 0 ? `<li><strong>Stage flow</strong> ${escapeHtml2(diagnostic.stageCounts.map((entry) => `${entry.stage} ${entry.count}`).join(" \u2192 "))}</li>` : ""}` + `${diagnostic.firstSeenStage ? `<li><strong>First seen</strong> ${escapeHtml2(diagnostic.firstSeenStage)}</li>` : ""}` + `${diagnostic.lastSeenStage ? `<li><strong>Last seen</strong> ${escapeHtml2(diagnostic.lastSeenStage)}</li>` : ""}` + `${diagnostic.retrievalMode ? `<li><strong>Trace mode</strong> ${escapeHtml2(diagnostic.retrievalMode)}</li>` : ""}` + `${diagnostic.rerankApplied !== undefined ? `<li><strong>Rerank</strong> ${diagnostic.rerankApplied ? "applied" : "skipped"}</li>` : ""}` + `${diagnostic.sourceBalanceApplied ? `<li><strong>Source balance</strong> applied</li>` : ""}` + `${diagnostic.scoreThresholdApplied ? `<li><strong>Score threshold</strong> applied</li>` : ""}` + `<li><strong>Reasons</strong> ${escapeHtml2(diagnostic.reasons.join(", ") || "none")}</li>` + `${diagnostic.strongestSiblingLabel ? `<li><strong>Strongest sibling</strong> ${escapeHtml2(diagnostic.strongestSiblingLabel)} (${diagnostic.strongestSiblingScore?.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES) ?? "n/a"})</li>` : ""}` + `${typeof diagnostic.parentShareGap === "number" ? `<li><strong>Parent share gap</strong> ${(diagnostic.parentShareGap * 100).toFixed(0)}%</li>` : ""}` + `</ul>` + `${diagnostic.parentDistribution.length > 0 ? `<ul class="rag-source-labels">${diagnostic.parentDistribution.map((entry) => `<li><strong>${entry.isActive ? "Active section" : "Peer section"}</strong> ${escapeHtml2(entry.label)} \xB7 ${(entry.parentShare * 100).toFixed(0)}% \xB7 ${entry.count} hit${entry.count === 1 ? "" : "s"}</li>`).join("")}</ul>` : ""}` + `</article>`).join("") + `</section>`;
11140
+ return `<section class="rag-search-results"><h3>Section diagnostics</h3>` + diagnostics.map((diagnostic) => `<article class="rag-search-result" id="rag-section-diagnostic-${escapeHtml2(diagnostic.key)}">` + `<h4>${escapeHtml2(diagnostic.path?.join(" > ") ?? diagnostic.label)}</h4>` + `<p class="rag-search-source">${escapeHtml2(diagnostic.summary)}</p>` + `<ul class="rag-source-labels">` + `<li><strong>Top hit</strong> ${diagnostic.bestScore.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES)}</li>` + `<li><strong>Average</strong> ${diagnostic.averageScore.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES)}</li>` + `<li><strong>Sources</strong> ${diagnostic.sourceCount}</li>` + `<li><strong>Channels</strong> vector ${diagnostic.vectorHits} \xB7 lexical ${diagnostic.lexicalHits} \xB7 hybrid ${diagnostic.hybridHits}</li>` + `${diagnostic.stageCounts.length > 0 ? `<li><strong>Stage flow</strong> ${escapeHtml2(diagnostic.stageCounts.map((entry) => `${entry.stage} ${entry.count}`).join(" \u2192 "))}</li>` : ""}` + `${diagnostic.firstSeenStage ? `<li><strong>First seen</strong> ${escapeHtml2(diagnostic.firstSeenStage)}</li>` : ""}` + `${diagnostic.lastSeenStage ? `<li><strong>Last seen</strong> ${escapeHtml2(diagnostic.lastSeenStage)}</li>` : ""}` + `<li><strong>Query attribution</strong> ${escapeHtml2(`${diagnostic.queryAttribution.mode} \xB7 primary ${diagnostic.queryAttribution.primaryHits} \xB7 transformed ${diagnostic.queryAttribution.transformedHits} \xB7 variant ${diagnostic.queryAttribution.variantHits}`)}</li>` + `${diagnostic.queryAttribution.reasons.length > 0 ? `<li><strong>Query attribution reasons</strong> ${escapeHtml2(diagnostic.queryAttribution.reasons.join(", "))}</li>` : ""}` + `${diagnostic.peakStage ? `<li><strong>Peak stage</strong> ${escapeHtml2(diagnostic.peakStage)} (${diagnostic.peakCount})</li>` : ""}` + `${typeof diagnostic.finalRetentionRate === "number" ? `<li><strong>Final retention</strong> ${(diagnostic.finalRetentionRate * 100).toFixed(0)}%</li>` : ""}` + `${typeof diagnostic.dropFromPeak === "number" ? `<li><strong>Drop from peak</strong> ${diagnostic.dropFromPeak}</li>` : ""}` + `${diagnostic.retrievalMode ? `<li><strong>Trace mode</strong> ${escapeHtml2(diagnostic.retrievalMode)}</li>` : ""}` + `${diagnostic.rerankApplied !== undefined ? `<li><strong>Rerank</strong> ${diagnostic.rerankApplied ? "applied" : "skipped"}</li>` : ""}` + `${diagnostic.sourceBalanceApplied ? `<li><strong>Source balance</strong> applied</li>` : ""}` + `${diagnostic.scoreThresholdApplied ? `<li><strong>Score threshold</strong> applied</li>` : ""}` + `<li><strong>Reasons</strong> ${escapeHtml2(diagnostic.reasons.join(", ") || "none")}</li>` + `${diagnostic.strongestSiblingLabel ? `<li><strong>Strongest sibling</strong> ${escapeHtml2(diagnostic.strongestSiblingLabel)} (${diagnostic.strongestSiblingScore?.toFixed(RAG_SEARCH_SCORE_DECIMAL_PLACES) ?? "n/a"})</li>` : ""}` + `${typeof diagnostic.parentShareGap === "number" ? `<li><strong>Parent share gap</strong> ${(diagnostic.parentShareGap * 100).toFixed(0)}%</li>` : ""}` + `</ul>` + `${diagnostic.stageWeights.length > 0 ? `<ul class="rag-source-labels">${diagnostic.stageWeights.map((entry) => `<li><strong>${escapeHtml2(entry.stage)}</strong> ${(entry.stageShare * 100).toFixed(0)}% of stage` + `${typeof entry.retentionRate === "number" ? ` \xB7 ${(entry.retentionRate * 100).toFixed(0)}% retained from ${escapeHtml2(entry.previousStage ?? "previous")}` : ""}` + `${typeof entry.countDelta === "number" ? ` \xB7 delta ${entry.countDelta >= 0 ? "+" : ""}${entry.countDelta}` : ""}` + `${typeof entry.stageScoreShare === "number" ? ` \xB7 ${(entry.stageScoreShare * 100).toFixed(0)}% of stage score` : ""}` + `${typeof entry.parentStageScoreShare === "number" ? ` \xB7 ${(entry.parentStageScoreShare * 100).toFixed(0)}% of parent stage score` : ""}` + `${typeof entry.stageScoreShareGap === "number" ? ` \xB7 score gap ${(entry.stageScoreShareGap * 100).toFixed(0)}%` : ""}` + `${typeof entry.parentStageShare === "number" ? ` \xB7 ${(entry.parentStageShare * 100).toFixed(0)}% of parent stage` : ""}` + `${typeof entry.stageShareGap === "number" ? ` \xB7 gap ${(entry.stageShareGap * 100).toFixed(0)}%` : ""}` + `${entry.strongestSiblingLabel ? ` \xB7 runner-up ${escapeHtml2(entry.strongestSiblingLabel)}` : ""}` + `${entry.reasons.length > 0 ? ` \xB7 ${escapeHtml2(entry.reasons.join(", "))}` : ""}</li>`).join("")}</ul>` : ""}` + `${diagnostic.parentDistribution.length > 0 ? `<ul class="rag-source-labels">${diagnostic.parentDistribution.map((entry) => `<li><strong>${entry.isActive ? "Active section" : "Peer section"}</strong> ${escapeHtml2(entry.label)} \xB7 ${(entry.parentShare * 100).toFixed(0)}% \xB7 ${entry.count} hit${entry.count === 1 ? "" : "s"}</li>`).join("")}</ul>` : ""}` + `</article>`).join("") + `</section>`;
10961
11141
  };
10962
11142
  var renderEmptyState = (kind) => {
10963
11143
  switch (kind) {
@@ -22252,5 +22432,5 @@ export {
22252
22432
  aiChat
22253
22433
  };
22254
22434
 
22255
- //# debugId=405B1228CB22607264756E2164756E21
22435
+ //# debugId=13C12436C949ED5964756E2164756E21
22256
22436
  //# sourceMappingURL=index.js.map