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

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.
@@ -4702,6 +4702,8 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4702
4702
  }
4703
4703
  const diagnostics = [...sections.values()];
4704
4704
  const strongestBestHit = diagnostics.reduce((highest, section) => Math.max(highest, section.bestScore), 0);
4705
+ const parentLabelByKey = new Map(diagnostics.map((section) => [section.key, section.parentLabel]));
4706
+ const stageSectionCounts = new Map((trace?.steps ?? []).filter((step) => Array.isArray(step.sectionCounts) && step.sectionCounts.length > 0).map((step) => [step.stage, step.sectionCounts ?? []]));
4705
4707
  return diagnostics.map((section) => {
4706
4708
  const siblingPool = diagnostics.filter((entry) => entry.parentLabel === section.parentLabel);
4707
4709
  const siblings = siblingPool.filter((entry) => entry.key !== section.key);
@@ -4722,6 +4724,42 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4722
4724
  count: step.sectionCounts?.find((entry) => entry.key === section.key)?.count ?? 0,
4723
4725
  stage: step.stage
4724
4726
  })).filter((entry) => entry.count > 0) ?? [];
4727
+ const stageWeights = stageCounts.map((entry) => {
4728
+ const stageEntries = stageSectionCounts.get(entry.stage)?.filter((candidate) => candidate.count > 0) ?? [];
4729
+ const stageTotal = stageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
4730
+ const siblingStageEntries = stageEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
4731
+ const parentStageEntries = stageEntries.filter((candidate) => parentLabelByKey.get(candidate.key) === section.parentLabel);
4732
+ const strongestStageSibling = siblingStageEntries.slice().sort((left, right) => right.count - left.count)[0];
4733
+ const parentStageTotal = parentStageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
4734
+ const stageShare = stageTotal > 0 ? entry.count / stageTotal : 0;
4735
+ const parentStageShare = parentStageTotal > 0 ? entry.count / parentStageTotal : undefined;
4736
+ const stageShareGap = stageTotal > 0 && strongestStageSibling ? entry.count / stageTotal - strongestStageSibling.count / stageTotal : undefined;
4737
+ const parentStageShareGap = parentStageTotal > 0 && strongestStageSibling ? entry.count / parentStageTotal - strongestStageSibling.count / parentStageTotal : undefined;
4738
+ const reasons2 = [];
4739
+ if (entry.stage === "rerank" && stageShare > 0.5 && (typeof stageShareGap !== "number" || stageShareGap > 0)) {
4740
+ reasons2.push("rerank_preserved_lead");
4741
+ }
4742
+ if (entry.stage === "finalize" && stageShare >= 0.5) {
4743
+ reasons2.push("final_stage_concentration");
4744
+ }
4745
+ if (entry.stage === "finalize" && typeof parentStageShare === "number" && parentStageShare >= 0.6 && (typeof parentStageShareGap !== "number" || parentStageShareGap > 0)) {
4746
+ reasons2.push("final_stage_dominant_within_parent");
4747
+ }
4748
+ if (strongestStageSibling && (typeof stageShareGap === "number" && stageShareGap <= 0.1 || typeof parentStageShareGap === "number" && parentStageShareGap <= 0.1)) {
4749
+ reasons2.push("stage_runner_up_pressure");
4750
+ }
4751
+ return {
4752
+ count: entry.count,
4753
+ parentStageShare,
4754
+ parentStageShareGap,
4755
+ reasons: reasons2,
4756
+ stage: entry.stage,
4757
+ stageShare,
4758
+ stageShareGap,
4759
+ strongestSiblingCount: strongestStageSibling?.count,
4760
+ strongestSiblingLabel: strongestStageSibling ? diagnostics.find((candidate) => candidate.key === strongestStageSibling.key)?.label ?? strongestStageSibling.key : undefined
4761
+ };
4762
+ });
4725
4763
  const firstSeenStage = stageCounts[0]?.stage;
4726
4764
  const lastSeenStage = stageCounts.at(-1)?.stage;
4727
4765
  if (section.bestScore >= strongestBestHit) {
@@ -4764,6 +4802,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
4764
4802
  scoreShare,
4765
4803
  scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
4766
4804
  stageCounts,
4805
+ stageWeights,
4767
4806
  siblingCount: siblings.length,
4768
4807
  siblingScoreGap: strongestSibling ? section.totalScore - strongestSibling.totalScore : undefined,
4769
4808
  sourceCount: section.sourceSet.size,
@@ -8099,5 +8138,5 @@ export {
8099
8138
  createAIStream
8100
8139
  };
8101
8140
 
8102
- //# debugId=2E85D191A5FE00B864756E2164756E21
8141
+ //# debugId=F26E4DDE93B27DEF64756E2164756E21
8103
8142
  //# sourceMappingURL=index.js.map