@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.
@@ -1520,6 +1520,8 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
1520
1520
  }
1521
1521
  const diagnostics = [...sections.values()];
1522
1522
  const strongestBestHit = diagnostics.reduce((highest, section) => Math.max(highest, section.bestScore), 0);
1523
+ const parentLabelByKey = new Map(diagnostics.map((section) => [section.key, section.parentLabel]));
1524
+ const stageSectionCounts = new Map((trace?.steps ?? []).filter((step) => Array.isArray(step.sectionCounts) && step.sectionCounts.length > 0).map((step) => [step.stage, step.sectionCounts ?? []]));
1523
1525
  return diagnostics.map((section) => {
1524
1526
  const siblingPool = diagnostics.filter((entry) => entry.parentLabel === section.parentLabel);
1525
1527
  const siblings = siblingPool.filter((entry) => entry.key !== section.key);
@@ -1540,6 +1542,42 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
1540
1542
  count: step.sectionCounts?.find((entry) => entry.key === section.key)?.count ?? 0,
1541
1543
  stage: step.stage
1542
1544
  })).filter((entry) => entry.count > 0) ?? [];
1545
+ const stageWeights = stageCounts.map((entry) => {
1546
+ const stageEntries = stageSectionCounts.get(entry.stage)?.filter((candidate) => candidate.count > 0) ?? [];
1547
+ const stageTotal = stageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
1548
+ const siblingStageEntries = stageEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
1549
+ const parentStageEntries = stageEntries.filter((candidate) => parentLabelByKey.get(candidate.key) === section.parentLabel);
1550
+ const strongestStageSibling = siblingStageEntries.slice().sort((left, right) => right.count - left.count)[0];
1551
+ const parentStageTotal = parentStageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
1552
+ const stageShare = stageTotal > 0 ? entry.count / stageTotal : 0;
1553
+ const parentStageShare = parentStageTotal > 0 ? entry.count / parentStageTotal : undefined;
1554
+ const stageShareGap = stageTotal > 0 && strongestStageSibling ? entry.count / stageTotal - strongestStageSibling.count / stageTotal : undefined;
1555
+ const parentStageShareGap = parentStageTotal > 0 && strongestStageSibling ? entry.count / parentStageTotal - strongestStageSibling.count / parentStageTotal : undefined;
1556
+ const reasons2 = [];
1557
+ if (entry.stage === "rerank" && stageShare > 0.5 && (typeof stageShareGap !== "number" || stageShareGap > 0)) {
1558
+ reasons2.push("rerank_preserved_lead");
1559
+ }
1560
+ if (entry.stage === "finalize" && stageShare >= 0.5) {
1561
+ reasons2.push("final_stage_concentration");
1562
+ }
1563
+ if (entry.stage === "finalize" && typeof parentStageShare === "number" && parentStageShare >= 0.6 && (typeof parentStageShareGap !== "number" || parentStageShareGap > 0)) {
1564
+ reasons2.push("final_stage_dominant_within_parent");
1565
+ }
1566
+ if (strongestStageSibling && (typeof stageShareGap === "number" && stageShareGap <= 0.1 || typeof parentStageShareGap === "number" && parentStageShareGap <= 0.1)) {
1567
+ reasons2.push("stage_runner_up_pressure");
1568
+ }
1569
+ return {
1570
+ count: entry.count,
1571
+ parentStageShare,
1572
+ parentStageShareGap,
1573
+ reasons: reasons2,
1574
+ stage: entry.stage,
1575
+ stageShare,
1576
+ stageShareGap,
1577
+ strongestSiblingCount: strongestStageSibling?.count,
1578
+ strongestSiblingLabel: strongestStageSibling ? diagnostics.find((candidate) => candidate.key === strongestStageSibling.key)?.label ?? strongestStageSibling.key : undefined
1579
+ };
1580
+ });
1543
1581
  const firstSeenStage = stageCounts[0]?.stage;
1544
1582
  const lastSeenStage = stageCounts.at(-1)?.stage;
1545
1583
  if (section.bestScore >= strongestBestHit) {
@@ -1582,6 +1620,7 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
1582
1620
  scoreShare,
1583
1621
  scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
1584
1622
  stageCounts,
1623
+ stageWeights,
1585
1624
  siblingCount: siblings.length,
1586
1625
  siblingScoreGap: strongestSibling ? section.totalScore - strongestSibling.totalScore : undefined,
1587
1626
  sourceCount: section.sourceSet.size,
@@ -2402,5 +2441,5 @@ export {
2402
2441
  buildRAGAnswerWorkflowState
2403
2442
  };
2404
2443
 
2405
- //# debugId=99F4F5DE38F3934764756E2164756E21
2444
+ //# debugId=3F9A363D61D0FB9F64756E2164756E21
2406
2445
  //# sourceMappingURL=ui.js.map