@absolutejs/absolute 0.19.0-beta.612 → 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;
@@ -4704,6 +4714,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4704
4714
  const strongestBestHit = diagnostics.reduce((highest, section) => Math.max(highest, section.bestScore), 0);
4705
4715
  const parentLabelByKey = new Map(diagnostics.map((section) => [section.key, section.parentLabel]));
4706
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 ?? []]));
4707
4718
  return diagnostics.map((section) => {
4708
4719
  const siblingPool = diagnostics.filter((entry) => entry.parentLabel === section.parentLabel);
4709
4720
  const siblings = siblingPool.filter((entry) => entry.key !== section.key);
@@ -4725,16 +4736,30 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4725
4736
  stage: step.stage
4726
4737
  })).filter((entry) => entry.count > 0) ?? [];
4727
4738
  const stageWeights = stageCounts.map((entry) => {
4739
+ const previousStageEntry = stageCounts[stageCounts.findIndex((candidate) => candidate.stage === entry.stage) - 1];
4728
4740
  const stageEntries = stageSectionCounts.get(entry.stage)?.filter((candidate) => candidate.count > 0) ?? [];
4741
+ const stageScoreEntries = stageSectionScores.get(entry.stage)?.filter((candidate) => candidate.totalScore > 0) ?? [];
4729
4742
  const stageTotal = stageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
4743
+ const stageScoreTotal = stageScoreEntries.reduce((sum, candidate) => sum + candidate.totalScore, 0);
4730
4744
  const siblingStageEntries = stageEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
4731
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);
4732
4748
  const strongestStageSibling = siblingStageEntries.slice().sort((left, right) => right.count - left.count)[0];
4733
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);
4734
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;
4735
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;
4736
4759
  const stageShareGap = stageTotal > 0 && strongestStageSibling ? entry.count / stageTotal - strongestStageSibling.count / stageTotal : undefined;
4737
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;
4738
4763
  const reasons2 = [];
4739
4764
  if (entry.stage === "rerank" && stageShare > 0.5 && (typeof stageShareGap !== "number" || stageShareGap > 0)) {
4740
4765
  reasons2.push("rerank_preserved_lead");
@@ -4748,20 +4773,65 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4748
4773
  if (strongestStageSibling && (typeof stageShareGap === "number" && stageShareGap <= 0.1 || typeof parentStageShareGap === "number" && parentStageShareGap <= 0.1)) {
4749
4774
  reasons2.push("stage_runner_up_pressure");
4750
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
+ }
4751
4785
  return {
4752
4786
  count: entry.count,
4787
+ countDelta,
4788
+ parentStageScoreShare,
4753
4789
  parentStageShare,
4754
4790
  parentStageShareGap,
4791
+ previousCount: previousStageEntry?.count,
4792
+ previousStage: previousStageEntry?.stage,
4755
4793
  reasons: reasons2,
4794
+ retentionRate,
4756
4795
  stage: entry.stage,
4796
+ stageScoreShare,
4797
+ stageScoreShareGap,
4757
4798
  stageShare,
4758
4799
  stageShareGap,
4800
+ totalScore: activeStageScore,
4759
4801
  strongestSiblingCount: strongestStageSibling?.count,
4760
4802
  strongestSiblingLabel: strongestStageSibling ? diagnostics.find((candidate) => candidate.key === strongestStageSibling.key)?.label ?? strongestStageSibling.key : undefined
4761
4803
  };
4762
4804
  });
4763
4805
  const firstSeenStage = stageCounts[0]?.stage;
4764
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
+ }
4765
4835
  if (section.bestScore >= strongestBestHit) {
4766
4836
  reasons.push("best_hit");
4767
4837
  }
@@ -4795,7 +4865,19 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4795
4865
  parentShareGap: typeof parentShare === "number" && strongestSibling && parentTotal > 0 ? parentShare - strongestSibling.totalScore / parentTotal : undefined,
4796
4866
  path: section.path,
4797
4867
  firstSeenStage,
4868
+ finalCount,
4869
+ finalRetentionRate,
4798
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
+ },
4799
4881
  retrievalMode: trace?.mode,
4800
4882
  reasons,
4801
4883
  rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
@@ -10567,12 +10649,13 @@ var applyRAGMMRDiversity = (results, queryVector, lambda) => {
10567
10649
  return [...selected, ...tail];
10568
10650
  };
10569
10651
  var weightQueryResults = (results, queryIndex) => {
10570
- if (queryIndex === 0) {
10571
- return results;
10572
- }
10573
- const weight = Math.pow(VARIANT_RESULT_WEIGHT, queryIndex);
10652
+ const weight = queryIndex === 0 ? 1 : Math.pow(VARIANT_RESULT_WEIGHT, queryIndex);
10574
10653
  return results.map((result) => ({
10575
10654
  ...result,
10655
+ metadata: {
10656
+ ...result.metadata ?? {},
10657
+ retrievalQueryIndex: queryIndex
10658
+ },
10576
10659
  score: result.score * weight
10577
10660
  }));
10578
10661
  };
@@ -10622,6 +10705,43 @@ var buildTraceSectionCounts = (results) => {
10622
10705
  return left.key.localeCompare(right.key);
10623
10706
  });
10624
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
+ };
10625
10745
  var shouldRunVectorRetrieval = (mode) => mode === "vector" || mode === "hybrid";
10626
10746
  var shouldRunLexicalRetrieval = (mode, store) => mode === "lexical" || mode === "hybrid" && Boolean(store.queryLexical);
10627
10747
  var createRAGCollection = (options) => {
@@ -10722,8 +10842,20 @@ var createRAGCollection = (options) => {
10722
10842
  }) ?? Promise.resolve([]) : Promise.resolve([])
10723
10843
  ]);
10724
10844
  return {
10725
- lexicalResults: weightQueryResults(lexicalResults2, queryIndex),
10726
- 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
+ })
10727
10859
  };
10728
10860
  }));
10729
10861
  const vectorResults = mergeQueryResults(resultGroups.flatMap((group) => group.vectorResults));
@@ -10736,6 +10868,7 @@ var createRAGCollection = (options) => {
10736
10868
  topK: candidateTopK
10737
10869
  },
10738
10870
  sectionCounts: buildTraceSectionCounts(vectorResults),
10871
+ sectionScores: buildTraceSectionScores(vectorResults),
10739
10872
  stage: "vector_search"
10740
10873
  });
10741
10874
  }
@@ -10749,6 +10882,7 @@ var createRAGCollection = (options) => {
10749
10882
  topK: lexicalTopK
10750
10883
  },
10751
10884
  sectionCounts: buildTraceSectionCounts(lexicalResults),
10885
+ sectionScores: buildTraceSectionScores(lexicalResults),
10752
10886
  stage: "lexical_search"
10753
10887
  });
10754
10888
  }
@@ -10767,6 +10901,7 @@ var createRAGCollection = (options) => {
10767
10901
  mode: retrieval.mode
10768
10902
  },
10769
10903
  sectionCounts: buildTraceSectionCounts(results),
10904
+ sectionScores: buildTraceSectionScores(results),
10770
10905
  stage: "fusion"
10771
10906
  });
10772
10907
  const rerankInput = {
@@ -10790,6 +10925,7 @@ var createRAGCollection = (options) => {
10790
10925
  applied: hasReranker
10791
10926
  },
10792
10927
  sectionCounts: buildTraceSectionCounts(reranked),
10928
+ sectionScores: buildTraceSectionScores(reranked),
10793
10929
  stage: "rerank"
10794
10930
  });
10795
10931
  const diversityAdjusted = retrieval.diversityStrategy === "mmr" ? applyRAGMMRDiversity(reranked, queryVector, retrieval.mmrLambda) : reranked;
@@ -10802,6 +10938,7 @@ var createRAGCollection = (options) => {
10802
10938
  mmrLambda: retrieval.mmrLambda
10803
10939
  },
10804
10940
  sectionCounts: buildTraceSectionCounts(diversityAdjusted),
10941
+ sectionScores: buildTraceSectionScores(diversityAdjusted),
10805
10942
  stage: "diversity"
10806
10943
  });
10807
10944
  }
@@ -10815,6 +10952,7 @@ var createRAGCollection = (options) => {
10815
10952
  strategy: retrieval.sourceBalanceStrategy
10816
10953
  },
10817
10954
  sectionCounts: buildTraceSectionCounts(diversified),
10955
+ sectionScores: buildTraceSectionScores(diversified),
10818
10956
  stage: "source_balance"
10819
10957
  });
10820
10958
  }
@@ -10831,6 +10969,7 @@ var createRAGCollection = (options) => {
10831
10969
  appliedScoreThreshold: false
10832
10970
  },
10833
10971
  sectionCounts: buildTraceSectionCounts(limited),
10972
+ sectionScores: buildTraceSectionScores(limited),
10834
10973
  stage: "finalize"
10835
10974
  });
10836
10975
  return {
@@ -10869,6 +11008,7 @@ var createRAGCollection = (options) => {
10869
11008
  scoreThreshold
10870
11009
  },
10871
11010
  sectionCounts: buildTraceSectionCounts(filtered),
11011
+ sectionScores: buildTraceSectionScores(filtered),
10872
11012
  stage: "score_filter"
10873
11013
  });
10874
11014
  steps.push({
@@ -10878,6 +11018,7 @@ var createRAGCollection = (options) => {
10878
11018
  appliedScoreThreshold: true
10879
11019
  },
10880
11020
  sectionCounts: buildTraceSectionCounts(filtered),
11021
+ sectionScores: buildTraceSectionScores(filtered),
10881
11022
  stage: "finalize"
10882
11023
  });
10883
11024
  return {
@@ -10996,7 +11137,7 @@ var renderSectionDiagnostics = (diagnostics) => {
10996
11137
  if (diagnostics.length === 0) {
10997
11138
  return "";
10998
11139
  }
10999
- 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.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.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>`;
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>`;
11000
11141
  };
11001
11142
  var renderEmptyState = (kind) => {
11002
11143
  switch (kind) {
@@ -22291,5 +22432,5 @@ export {
22291
22432
  aiChat
22292
22433
  };
22293
22434
 
22294
- //# debugId=1ADA1065B50387AC64756E2164756E21
22435
+ //# debugId=13C12436C949ED5964756E2164756E21
22295
22436
  //# sourceMappingURL=index.js.map