@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.
@@ -5299,6 +5299,8 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
5299
5299
  }
5300
5300
  const diagnostics = [...sections.values()];
5301
5301
  const strongestBestHit = diagnostics.reduce((highest, section) => Math.max(highest, section.bestScore), 0);
5302
+ const parentLabelByKey = new Map(diagnostics.map((section) => [section.key, section.parentLabel]));
5303
+ const stageSectionCounts = new Map((trace?.steps ?? []).filter((step) => Array.isArray(step.sectionCounts) && step.sectionCounts.length > 0).map((step) => [step.stage, step.sectionCounts ?? []]));
5302
5304
  return diagnostics.map((section) => {
5303
5305
  const siblingPool = diagnostics.filter((entry) => entry.parentLabel === section.parentLabel);
5304
5306
  const siblings = siblingPool.filter((entry) => entry.key !== section.key);
@@ -5315,6 +5317,48 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
5315
5317
  totalScore: entry.totalScore
5316
5318
  })).sort((left, right) => right.totalScore - left.totalScore) : [];
5317
5319
  const reasons = [];
5320
+ const stageCounts = trace?.steps.map((step) => ({
5321
+ count: step.sectionCounts?.find((entry) => entry.key === section.key)?.count ?? 0,
5322
+ stage: step.stage
5323
+ })).filter((entry) => entry.count > 0) ?? [];
5324
+ const stageWeights = stageCounts.map((entry) => {
5325
+ const stageEntries = stageSectionCounts.get(entry.stage)?.filter((candidate) => candidate.count > 0) ?? [];
5326
+ const stageTotal = stageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
5327
+ const siblingStageEntries = stageEntries.filter((candidate) => candidate.key !== section.key && parentLabelByKey.get(candidate.key) === section.parentLabel);
5328
+ const parentStageEntries = stageEntries.filter((candidate) => parentLabelByKey.get(candidate.key) === section.parentLabel);
5329
+ const strongestStageSibling = siblingStageEntries.slice().sort((left, right) => right.count - left.count)[0];
5330
+ const parentStageTotal = parentStageEntries.reduce((sum, candidate) => sum + candidate.count, 0);
5331
+ const stageShare = stageTotal > 0 ? entry.count / stageTotal : 0;
5332
+ const parentStageShare = parentStageTotal > 0 ? entry.count / parentStageTotal : undefined;
5333
+ const stageShareGap = stageTotal > 0 && strongestStageSibling ? entry.count / stageTotal - strongestStageSibling.count / stageTotal : undefined;
5334
+ const parentStageShareGap = parentStageTotal > 0 && strongestStageSibling ? entry.count / parentStageTotal - strongestStageSibling.count / parentStageTotal : undefined;
5335
+ const reasons2 = [];
5336
+ if (entry.stage === "rerank" && stageShare > 0.5 && (typeof stageShareGap !== "number" || stageShareGap > 0)) {
5337
+ reasons2.push("rerank_preserved_lead");
5338
+ }
5339
+ if (entry.stage === "finalize" && stageShare >= 0.5) {
5340
+ reasons2.push("final_stage_concentration");
5341
+ }
5342
+ if (entry.stage === "finalize" && typeof parentStageShare === "number" && parentStageShare >= 0.6 && (typeof parentStageShareGap !== "number" || parentStageShareGap > 0)) {
5343
+ reasons2.push("final_stage_dominant_within_parent");
5344
+ }
5345
+ if (strongestStageSibling && (typeof stageShareGap === "number" && stageShareGap <= 0.1 || typeof parentStageShareGap === "number" && parentStageShareGap <= 0.1)) {
5346
+ reasons2.push("stage_runner_up_pressure");
5347
+ }
5348
+ return {
5349
+ count: entry.count,
5350
+ parentStageShare,
5351
+ parentStageShareGap,
5352
+ reasons: reasons2,
5353
+ stage: entry.stage,
5354
+ stageShare,
5355
+ stageShareGap,
5356
+ strongestSiblingCount: strongestStageSibling?.count,
5357
+ strongestSiblingLabel: strongestStageSibling ? diagnostics.find((candidate) => candidate.key === strongestStageSibling.key)?.label ?? strongestStageSibling.key : undefined
5358
+ };
5359
+ });
5360
+ const firstSeenStage = stageCounts[0]?.stage;
5361
+ const lastSeenStage = stageCounts.at(-1)?.stage;
5318
5362
  if (section.bestScore >= strongestBestHit) {
5319
5363
  reasons.push("best_hit");
5320
5364
  }
@@ -5347,11 +5391,15 @@ var buildRAGSectionRetrievalDiagnostics = (sources, trace) => {
5347
5391
  parentShare,
5348
5392
  parentShareGap: typeof parentShare === "number" && strongestSibling && parentTotal > 0 ? parentShare - strongestSibling.totalScore / parentTotal : undefined,
5349
5393
  path: section.path,
5394
+ firstSeenStage,
5395
+ lastSeenStage,
5350
5396
  retrievalMode: trace?.mode,
5351
5397
  reasons,
5352
5398
  rerankApplied: trace?.steps.some((step) => step.stage === "rerank" && step.metadata?.applied === true),
5353
5399
  scoreShare,
5354
5400
  scoreThresholdApplied: trace?.steps.some((step) => step.stage === "score_filter"),
5401
+ stageCounts,
5402
+ stageWeights,
5355
5403
  siblingCount: siblings.length,
5356
5404
  siblingScoreGap: strongestSibling ? section.totalScore - strongestSibling.totalScore : undefined,
5357
5405
  sourceCount: section.sourceSet.size,
@@ -7306,5 +7354,5 @@ export {
7306
7354
  buildRAGEvaluationLeaderboard
7307
7355
  };
7308
7356
 
7309
- //# debugId=3709E5ECFB9CD0AA64756E2164756E21
7357
+ //# debugId=6DDF41CB2B08D94664756E2164756E21
7310
7358
  //# sourceMappingURL=index.js.map