@absolutejs/absolute 0.19.0-beta.610 → 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);
@@ -1536,6 +1538,48 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
1536
1538
  totalScore: entry.totalScore
1537
1539
  })).sort((left, right) => right.totalScore - left.totalScore) : [];
1538
1540
  const reasons = [];
1541
+ const stageCounts = trace?.steps.map((step) => ({
1542
+ count: step.sectionCounts?.find((entry) => entry.key === section.key)?.count ?? 0,
1543
+ stage: step.stage
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
+ });
1581
+ const firstSeenStage = stageCounts[0]?.stage;
1582
+ const lastSeenStage = stageCounts.at(-1)?.stage;
1539
1583
  if (section.bestScore >= strongestBestHit) {
1540
1584
  reasons.push("best_hit");
1541
1585
  }
@@ -1568,11 +1612,15 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
1568
1612
  parentShare,
1569
1613
  parentShareGap: typeof parentShare === "number" && strongestSibling && parentTotal > 0 ? parentShare - strongestSibling.totalScore / parentTotal : undefined,
1570
1614
  path: section.path,
1615
+ firstSeenStage,
1616
+ lastSeenStage,
1571
1617
  retrievalMode: trace?.mode,
1572
1618
  reasons,
1573
1619
  rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
1574
1620
  scoreShare,
1575
1621
  scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
1622
+ stageCounts,
1623
+ stageWeights,
1576
1624
  siblingCount: siblings.length,
1577
1625
  siblingScoreGap: strongestSibling ? section.totalScore - strongestSibling.totalScore : undefined,
1578
1626
  sourceCount: section.sourceSet.size,
@@ -2393,5 +2441,5 @@ export {
2393
2441
  buildRAGAnswerWorkflowState
2394
2442
  };
2395
2443
 
2396
- //# debugId=931690819320093C64756E2164756E21
2444
+ //# debugId=3F9A363D61D0FB9F64756E2164756E21
2397
2445
  //# sourceMappingURL=ui.js.map