@absolutejs/absolute 0.19.0-beta.616 → 0.19.0-beta.618

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
@@ -2054,6 +2054,7 @@ var createRAGFileRetrievalLaneHandoffDecisionStore = (path) => ({
2054
2054
  });
2055
2055
  var createRAGFileRetrievalReleaseIncidentStore = (path) => ({
2056
2056
  listIncidents: async ({
2057
+ corpusGroupKey,
2057
2058
  groupKey,
2058
2059
  limit,
2059
2060
  severity,
@@ -2070,7 +2071,7 @@ var createRAGFileRetrievalReleaseIncidentStore = (path) => ({
2070
2071
  throw error;
2071
2072
  }
2072
2073
  }
2073
- const filtered = parsed.filter((entry) => (!groupKey || entry.groupKey === groupKey) && (!targetRolloutLabel || entry.targetRolloutLabel === targetRolloutLabel) && (!severity || entry.severity === severity) && (!status || entry.status === status));
2074
+ const filtered = parsed.filter((entry) => (!corpusGroupKey || entry.corpusGroupKey === corpusGroupKey) && (!groupKey || entry.groupKey === groupKey) && (!targetRolloutLabel || entry.targetRolloutLabel === targetRolloutLabel) && (!severity || entry.severity === severity) && (!status || entry.status === status));
2074
2075
  const sorted = normalizeRetrievalReleaseIncidentRecords(filtered);
2075
2076
  return typeof limit === "number" ? sorted.slice(0, limit) : sorted;
2076
2077
  },
@@ -2995,16 +2996,32 @@ var loadRAGRetrievalComparisonHistory = async ({
2995
2996
  suiteId,
2996
2997
  label,
2997
2998
  winnerId,
2999
+ corpusGroupKey,
2998
3000
  groupKey,
2999
3001
  tag
3000
- }) => normalizeRetrievalComparisonRuns(await Promise.resolve(store.listRuns({ groupKey, label, limit, suiteId, tag, winnerId })));
3002
+ }) => normalizeRetrievalComparisonRuns(await Promise.resolve(store.listRuns({
3003
+ corpusGroupKey,
3004
+ groupKey,
3005
+ label,
3006
+ limit,
3007
+ suiteId,
3008
+ tag,
3009
+ winnerId
3010
+ })));
3001
3011
  var loadRAGRetrievalBaselines = async ({
3002
3012
  store,
3013
+ corpusGroupKey,
3003
3014
  groupKey,
3004
3015
  tag,
3005
3016
  limit,
3006
3017
  status
3007
- }) => normalizeRetrievalBaselineRecords(await Promise.resolve(store.listBaselines({ groupKey, limit, status, tag })));
3018
+ }) => normalizeRetrievalBaselineRecords(await Promise.resolve(store.listBaselines({
3019
+ corpusGroupKey,
3020
+ groupKey,
3021
+ limit,
3022
+ status,
3023
+ tag
3024
+ })));
3008
3025
  var persistRAGRetrievalBaseline = async ({
3009
3026
  store,
3010
3027
  record
@@ -3014,18 +3031,21 @@ var persistRAGRetrievalBaseline = async ({
3014
3031
  };
3015
3032
  var loadRAGRetrievalReleaseDecisions = async ({
3016
3033
  store,
3034
+ corpusGroupKey,
3017
3035
  groupKey,
3018
3036
  limit,
3019
3037
  kind
3020
- }) => normalizeRetrievalReleaseDecisionRecords(await Promise.resolve(store.listDecisions({ groupKey, kind, limit })));
3038
+ }) => normalizeRetrievalReleaseDecisionRecords(await Promise.resolve(store.listDecisions({ corpusGroupKey, groupKey, kind, limit })));
3021
3039
  var loadRAGRetrievalLaneHandoffDecisions = async ({
3022
3040
  store,
3041
+ corpusGroupKey,
3023
3042
  groupKey,
3024
3043
  limit,
3025
3044
  kind,
3026
3045
  sourceRolloutLabel,
3027
3046
  targetRolloutLabel
3028
3047
  }) => normalizeRetrievalLaneHandoffDecisionRecords(await Promise.resolve(store.listDecisions({
3048
+ corpusGroupKey,
3029
3049
  groupKey,
3030
3050
  kind,
3031
3051
  limit,
@@ -3034,12 +3054,14 @@ var loadRAGRetrievalLaneHandoffDecisions = async ({
3034
3054
  })));
3035
3055
  var loadRAGRetrievalReleaseIncidents = async ({
3036
3056
  store,
3057
+ corpusGroupKey,
3037
3058
  groupKey,
3038
3059
  limit,
3039
3060
  targetRolloutLabel,
3040
3061
  status,
3041
3062
  severity
3042
3063
  }) => normalizeRetrievalReleaseIncidentRecords(await Promise.resolve(store.listIncidents({
3064
+ corpusGroupKey,
3043
3065
  groupKey,
3044
3066
  limit,
3045
3067
  severity,
@@ -3048,12 +3070,14 @@ var loadRAGRetrievalReleaseIncidents = async ({
3048
3070
  })));
3049
3071
  var loadRAGRetrievalLaneHandoffIncidents = async ({
3050
3072
  store,
3073
+ corpusGroupKey,
3051
3074
  groupKey,
3052
3075
  limit,
3053
3076
  targetRolloutLabel,
3054
3077
  status,
3055
3078
  severity
3056
3079
  }) => normalizeRetrievalReleaseIncidentRecords(await Promise.resolve(store.listIncidents({
3080
+ corpusGroupKey,
3057
3081
  groupKey,
3058
3082
  limit,
3059
3083
  severity,
@@ -3062,12 +3086,14 @@ var loadRAGRetrievalLaneHandoffIncidents = async ({
3062
3086
  })));
3063
3087
  var loadRAGRetrievalLaneHandoffIncidentHistory = async ({
3064
3088
  store,
3089
+ corpusGroupKey,
3065
3090
  action,
3066
3091
  groupKey,
3067
3092
  incidentId,
3068
3093
  limit,
3069
3094
  targetRolloutLabel
3070
3095
  }) => await Promise.resolve(store.listRecords({
3096
+ corpusGroupKey,
3071
3097
  action,
3072
3098
  groupKey,
3073
3099
  incidentId,
@@ -3112,21 +3138,25 @@ var loadRAGRetrievalIncidentRemediationExecutionHistory = async ({
3112
3138
  })));
3113
3139
  var loadRAGRetrievalLaneHandoffAutoCompletePolicyHistory = async ({
3114
3140
  store,
3141
+ corpusGroupKey,
3115
3142
  groupKey,
3116
3143
  limit,
3117
3144
  targetRolloutLabel
3118
3145
  }) => await Promise.resolve(store.listRecords({
3146
+ corpusGroupKey,
3119
3147
  groupKey,
3120
3148
  limit,
3121
3149
  targetRolloutLabel
3122
3150
  }));
3123
3151
  var loadRAGRetrievalReleaseLanePolicyHistory = async ({
3124
3152
  store,
3153
+ corpusGroupKey,
3125
3154
  groupKey,
3126
3155
  limit,
3127
3156
  rolloutLabel,
3128
3157
  scope
3129
3158
  }) => await Promise.resolve(store.listRecords({
3159
+ corpusGroupKey,
3130
3160
  groupKey,
3131
3161
  limit,
3132
3162
  rolloutLabel,
@@ -3134,11 +3164,13 @@ var loadRAGRetrievalReleaseLanePolicyHistory = async ({
3134
3164
  }));
3135
3165
  var loadRAGRetrievalBaselineGatePolicyHistory = async ({
3136
3166
  store,
3167
+ corpusGroupKey,
3137
3168
  groupKey,
3138
3169
  limit,
3139
3170
  rolloutLabel,
3140
3171
  scope
3141
3172
  }) => await Promise.resolve(store.listRecords({
3173
+ corpusGroupKey,
3142
3174
  groupKey,
3143
3175
  limit,
3144
3176
  rolloutLabel,
@@ -3146,6 +3178,7 @@ var loadRAGRetrievalBaselineGatePolicyHistory = async ({
3146
3178
  }));
3147
3179
  var loadRAGRetrievalReleaseLaneEscalationPolicyHistory = async ({
3148
3180
  store,
3181
+ corpusGroupKey,
3149
3182
  groupKey,
3150
3183
  limit,
3151
3184
  targetRolloutLabel
@@ -12208,6 +12241,7 @@ var ragChat = (config) => {
12208
12241
  const requiredMetadata = scope.requiredMetadata && Object.keys(scope.requiredMetadata).length > 0 ? scope.requiredMetadata : undefined;
12209
12242
  return {
12210
12243
  allowedComparisonGroupKeys: normalizeStringArray3(scope.allowedComparisonGroupKeys),
12244
+ allowedCorpusGroupKeys: normalizeStringArray3(scope.allowedCorpusGroupKeys),
12211
12245
  allowedCorpusKeys: normalizeStringArray3(scope.allowedCorpusKeys),
12212
12246
  allowedDocumentIds: normalizeStringArray3(scope.allowedDocumentIds),
12213
12247
  allowedSourcePrefixes: normalizeStringArray3(scope.allowedSourcePrefixes),
@@ -12243,8 +12277,26 @@ var ragChat = (config) => {
12243
12277
  return matchesRequiredMetadata(scope.requiredMetadata, input.metadata);
12244
12278
  };
12245
12279
  const matchesSyncSourceScope = (scope, source) => !scope?.allowedSyncSourceIds?.length || scope.allowedSyncSourceIds.includes(source.id);
12280
+ const deriveCorpusGroupKey = (input) => {
12281
+ const explicitCorpusGroupKey = input.corpusGroupKey?.trim();
12282
+ if (explicitCorpusGroupKey) {
12283
+ return explicitCorpusGroupKey;
12284
+ }
12285
+ const normalizedCorpusKeys = [
12286
+ ...new Set((input.corpusKeys ?? []).map((value) => value.trim()).filter((value) => value.length > 0))
12287
+ ].sort((left, right) => left.localeCompare(right));
12288
+ if (normalizedCorpusKeys.length === 0) {
12289
+ return;
12290
+ }
12291
+ if (normalizedCorpusKeys.length === 1) {
12292
+ return normalizedCorpusKeys[0];
12293
+ }
12294
+ return normalizedCorpusKeys.join("+");
12295
+ };
12296
+ const isAllowedCorpusGroupKey = (scope, corpusGroupKey) => !scope?.allowedCorpusGroupKeys?.length || typeof corpusGroupKey === "string" && scope.allowedCorpusGroupKeys.includes(corpusGroupKey);
12246
12297
  const isAllowedComparisonGroupKey = (scope, groupKey) => !scope?.allowedComparisonGroupKeys?.length || typeof groupKey === "string" && scope.allowedComparisonGroupKeys.includes(groupKey);
12247
12298
  const filterByComparisonGroupKey = (scope, records) => scope?.allowedComparisonGroupKeys?.length ? records.filter((record) => isAllowedComparisonGroupKey(scope, record.groupKey)) : records;
12299
+ const filterByCorpusGroupKey = (scope, records) => scope?.allowedCorpusGroupKeys?.length ? records.filter((record) => isAllowedCorpusGroupKey(scope, record.corpusGroupKey)) : records;
12248
12300
  const persistJobStateIfConfigured = async () => {
12249
12301
  if (!jobStateStore) {
12250
12302
  return;
@@ -12755,6 +12807,7 @@ var ragChat = (config) => {
12755
12807
  ...input,
12756
12808
  baselineRetrievalId: getStringProperty(body, "baselineRetrievalId"),
12757
12809
  candidateRetrievalId: getStringProperty(body, "candidateRetrievalId"),
12810
+ corpusGroupKey: getStringProperty(body, "corpusGroupKey"),
12758
12811
  groupKey: getStringProperty(body, "groupKey"),
12759
12812
  label: getStringProperty(body, "label"),
12760
12813
  persistRun: getBooleanProperty(body, "persistRun") === true,
@@ -12772,6 +12825,7 @@ var ragChat = (config) => {
12772
12825
  return null;
12773
12826
  }
12774
12827
  return {
12828
+ corpusGroupKey: getStringProperty(body, "corpusGroupKey"),
12775
12829
  groupKey,
12776
12830
  approvedAt: getIntegerLikeProperty(body, "approvedAt"),
12777
12831
  approvedBy: getStringProperty(body, "approvedBy"),
@@ -12800,6 +12854,7 @@ var ragChat = (config) => {
12800
12854
  return null;
12801
12855
  }
12802
12856
  return {
12857
+ corpusGroupKey: getStringProperty(body, "corpusGroupKey"),
12803
12858
  groupKey,
12804
12859
  overrideGate: getBooleanProperty(body, "overrideGate") === true,
12805
12860
  overrideReason: getStringProperty(body, "overrideReason"),
@@ -12830,6 +12885,7 @@ var ragChat = (config) => {
12830
12885
  return null;
12831
12886
  }
12832
12887
  return {
12888
+ corpusGroupKey: getStringProperty(body, "corpusGroupKey"),
12833
12889
  groupKey,
12834
12890
  approvedAt: getIntegerLikeProperty(body, "approvedAt"),
12835
12891
  approvedBy: getStringProperty(body, "approvedBy"),
@@ -12876,6 +12932,7 @@ var ragChat = (config) => {
12876
12932
  }
12877
12933
  return {
12878
12934
  candidateRetrievalId: getStringProperty(body, "candidateRetrievalId"),
12935
+ corpusGroupKey: getStringProperty(body, "corpusGroupKey"),
12879
12936
  decidedAt: getIntegerLikeProperty(body, "decidedAt"),
12880
12937
  decidedBy: getStringProperty(body, "decidedBy"),
12881
12938
  executePromotion: getBooleanProperty(body, "executePromotion") === true,
@@ -13230,6 +13287,12 @@ var ragChat = (config) => {
13230
13287
  ok: false
13231
13288
  };
13232
13289
  }
13290
+ if (!isAllowedCorpusGroupKey(accessScope, input.corpusGroupKey)) {
13291
+ return {
13292
+ error: "Retrieval comparison corpus group is outside the allowed RAG access scope",
13293
+ ok: false
13294
+ };
13295
+ }
13233
13296
  for (const evaluationCase of input.cases) {
13234
13297
  if (evaluationCase.corpusKey && !matchesAccessScope(accessScope, {
13235
13298
  corpusKey: evaluationCase.corpusKey
@@ -13275,6 +13338,19 @@ var ragChat = (config) => {
13275
13338
  label: suiteLabel
13276
13339
  }
13277
13340
  });
13341
+ const corpusGroupKey = deriveCorpusGroupKey({
13342
+ corpusGroupKey: input.corpusGroupKey,
13343
+ corpusKeys: comparison.corpusKeys
13344
+ });
13345
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
13346
+ return {
13347
+ error: "Retrieval comparison corpus group is outside the allowed RAG access scope",
13348
+ ok: false
13349
+ };
13350
+ }
13351
+ if (corpusGroupKey) {
13352
+ comparison.corpusGroupKey = corpusGroupKey;
13353
+ }
13278
13354
  if (input.persistRun && retrievalComparisonHistoryStore) {
13279
13355
  const finishedAt = Date.now();
13280
13356
  const decisionSummary = buildRAGRetrievalComparisonDecisionSummary({
@@ -13286,6 +13362,7 @@ var ragChat = (config) => {
13286
13362
  await persistRAGRetrievalComparisonRun({
13287
13363
  run: {
13288
13364
  comparison,
13365
+ corpusGroupKey,
13289
13366
  corpusKeys: comparison.corpusKeys,
13290
13367
  decisionSummary,
13291
13368
  elapsedMs: finishedAt - startedAt,
@@ -13319,13 +13396,21 @@ var ragChat = (config) => {
13319
13396
  }
13320
13397
  const accessScope = await loadAccessScope(request);
13321
13398
  const groupKey = getStringProperty(queryInput, "groupKey");
13399
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
13322
13400
  if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
13323
13401
  return {
13324
13402
  error: "Retrieval comparison group is outside the allowed RAG access scope",
13325
13403
  ok: false
13326
13404
  };
13327
13405
  }
13406
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
13407
+ return {
13408
+ error: "Retrieval comparison corpus group is outside the allowed RAG access scope",
13409
+ ok: false
13410
+ };
13411
+ }
13328
13412
  const runs = await loadRAGRetrievalComparisonHistory({
13413
+ corpusGroupKey,
13329
13414
  groupKey,
13330
13415
  label: getStringProperty(queryInput, "label"),
13331
13416
  limit: getIntegerLikeProperty(queryInput, "limit"),
@@ -13336,7 +13421,7 @@ var ragChat = (config) => {
13336
13421
  });
13337
13422
  return {
13338
13423
  ok: true,
13339
- runs: filterByComparisonGroupKey(accessScope, runs)
13424
+ runs: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, runs))
13340
13425
  };
13341
13426
  };
13342
13427
  const handleRetrievalBaselineList = async (queryInput, request) => {
@@ -13348,13 +13433,21 @@ var ragChat = (config) => {
13348
13433
  }
13349
13434
  const accessScope = await loadAccessScope(request);
13350
13435
  const groupKey = getStringProperty(queryInput, "groupKey");
13436
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
13351
13437
  if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
13352
13438
  return {
13353
13439
  error: "Retrieval baseline group is outside the allowed RAG access scope",
13354
13440
  ok: false
13355
13441
  };
13356
13442
  }
13443
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
13444
+ return {
13445
+ error: "Retrieval baseline corpus group is outside the allowed RAG access scope",
13446
+ ok: false
13447
+ };
13448
+ }
13357
13449
  const baselines = await loadRAGRetrievalBaselines({
13450
+ corpusGroupKey,
13358
13451
  groupKey,
13359
13452
  limit: getIntegerLikeProperty(queryInput, "limit"),
13360
13453
  status: getStringProperty(queryInput, "status") === "active" || getStringProperty(queryInput, "status") === "superseded" ? getStringProperty(queryInput, "status") : undefined,
@@ -13362,7 +13455,7 @@ var ragChat = (config) => {
13362
13455
  tag: getStringProperty(queryInput, "tag")
13363
13456
  });
13364
13457
  return {
13365
- baselines: filterByComparisonGroupKey(accessScope, baselines),
13458
+ baselines: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, baselines)),
13366
13459
  ok: true
13367
13460
  };
13368
13461
  };
@@ -13373,6 +13466,7 @@ var ragChat = (config) => {
13373
13466
  await persistRAGRetrievalReleaseDecision({
13374
13467
  record: {
13375
13468
  baselineId: input.baseline?.id,
13469
+ corpusGroupKey: input.baseline?.corpusGroupKey ?? input.corpusGroupKey,
13376
13470
  decidedAt: input.baseline?.promotedAt ?? input.decidedAt ?? Date.now(),
13377
13471
  decidedBy: input.decidedBy,
13378
13472
  groupKey: input.baseline?.groupKey ?? input.groupKey,
@@ -13489,6 +13583,7 @@ var ragChat = (config) => {
13489
13583
  await persistRAGRetrievalLaneHandoffIncidentHistory({
13490
13584
  record: {
13491
13585
  action: input.action,
13586
+ corpusGroupKey: input.incident.corpusGroupKey,
13492
13587
  groupKey: input.incident.groupKey,
13493
13588
  id: generateId(),
13494
13589
  incidentId: input.incident.id,
@@ -13511,6 +13606,7 @@ var ragChat = (config) => {
13511
13606
  await persistRAGRetrievalLaneHandoffAutoCompletePolicyHistory({
13512
13607
  record: {
13513
13608
  changeKind: input.changeKind,
13609
+ corpusGroupKey: input.corpusGroupKey,
13514
13610
  enabled: input.enabled,
13515
13611
  groupKey: input.groupKey,
13516
13612
  id: generateId(),
@@ -13531,6 +13627,7 @@ var ragChat = (config) => {
13531
13627
  record: {
13532
13628
  approvalMaxAgeMs: input.approvalMaxAgeMs,
13533
13629
  changeKind: input.changeKind,
13630
+ corpusGroupKey: input.corpusGroupKey,
13534
13631
  groupKey: input.groupKey,
13535
13632
  id: generateId(),
13536
13633
  previousApprovalMaxAgeMs: input.previousApprovalMaxAgeMs,
@@ -13550,6 +13647,7 @@ var ragChat = (config) => {
13550
13647
  await persistRAGRetrievalBaselineGatePolicyHistory({
13551
13648
  record: {
13552
13649
  changeKind: input.changeKind,
13650
+ corpusGroupKey: input.corpusGroupKey,
13553
13651
  groupKey: input.groupKey,
13554
13652
  id: generateId(),
13555
13653
  policy: input.policy,
@@ -13569,6 +13667,7 @@ var ragChat = (config) => {
13569
13667
  record: {
13570
13668
  approvalExpiredSeverity: input.approvalExpiredSeverity,
13571
13669
  changeKind: input.changeKind,
13670
+ corpusGroupKey: input.corpusGroupKey,
13572
13671
  gateFailureSeverity: input.gateFailureSeverity,
13573
13672
  groupKey: input.groupKey,
13574
13673
  id: generateId(),
@@ -13592,6 +13691,24 @@ var ragChat = (config) => {
13592
13691
  limit: 100,
13593
13692
  store: config.retrievalReleaseIncidentStore
13594
13693
  });
13694
+ const baselineCorpusGroups = config.retrievalBaselineStore ? await loadRAGRetrievalBaselines({
13695
+ limit: 200,
13696
+ store: config.retrievalBaselineStore
13697
+ }) : [];
13698
+ const comparisonRunCorpusGroups = config.retrievalComparisonHistoryStore ? await loadRAGRetrievalComparisonHistory({
13699
+ limit: 200,
13700
+ store: config.retrievalComparisonHistoryStore
13701
+ }) : [];
13702
+ const releaseDecisionCorpusGroups = config.retrievalReleaseDecisionStore ? await loadRAGRetrievalReleaseDecisions({
13703
+ limit: 200,
13704
+ store: config.retrievalReleaseDecisionStore
13705
+ }) : [];
13706
+ const resolveIncidentCorpusGroupKey = (groupKey) => {
13707
+ if (!groupKey) {
13708
+ return;
13709
+ }
13710
+ return existing.find((entry) => entry.groupKey === groupKey && typeof entry.corpusGroupKey === "string")?.corpusGroupKey ?? comparisonRunCorpusGroups.find((entry) => entry.groupKey === groupKey && typeof entry.corpusGroupKey === "string")?.corpusGroupKey ?? baselineCorpusGroups.find((entry) => entry.groupKey === groupKey && typeof entry.corpusGroupKey === "string")?.corpusGroupKey ?? releaseDecisionCorpusGroups.find((entry) => entry.groupKey === groupKey && typeof entry.corpusGroupKey === "string")?.corpusGroupKey;
13711
+ };
13595
13712
  const nextByKey = new Map;
13596
13713
  for (const candidate of input.promotionCandidates) {
13597
13714
  if (!candidate.groupKey || !candidate.targetRolloutLabel) {
@@ -13605,6 +13722,7 @@ var ragChat = (config) => {
13605
13722
  nextByKey.set(key, {
13606
13723
  baselineRetrievalId: candidate.baselineRetrievalId,
13607
13724
  candidateRetrievalId: candidate.candidateRetrievalId,
13725
+ corpusGroupKey: resolveIncidentCorpusGroupKey(candidate.groupKey),
13608
13726
  groupKey: candidate.groupKey,
13609
13727
  id: key,
13610
13728
  kind,
@@ -13630,6 +13748,7 @@ var ragChat = (config) => {
13630
13748
  nextByKey.set(key, {
13631
13749
  baselineRetrievalId: handoff.targetBaselineRetrievalId,
13632
13750
  candidateRetrievalId: handoff.candidateRetrievalId,
13751
+ corpusGroupKey: handoff.corpusGroupKey,
13633
13752
  groupKey: handoff.groupKey,
13634
13753
  id: key,
13635
13754
  kind: "handoff_stale",
@@ -13642,7 +13761,7 @@ var ragChat = (config) => {
13642
13761
  });
13643
13762
  }
13644
13763
  for (const incident of nextByKey.values()) {
13645
- const matchingIncidents = existing.filter((entry) => entry.groupKey === incident.groupKey && entry.kind === incident.kind && (entry.targetRolloutLabel ?? undefined) === (incident.targetRolloutLabel ?? undefined)).sort((left, right) => right.triggeredAt - left.triggeredAt);
13764
+ const matchingIncidents = existing.filter((entry) => entry.corpusGroupKey === incident.corpusGroupKey && entry.groupKey === incident.groupKey && entry.kind === incident.kind && (entry.targetRolloutLabel ?? undefined) === (incident.targetRolloutLabel ?? undefined)).sort((left, right) => right.triggeredAt - left.triggeredAt);
13646
13765
  const openIncident = matchingIncidents.find((entry) => entry.status === "open");
13647
13766
  const latestMatchingIncident = matchingIncidents[0];
13648
13767
  if (!openIncident) {
@@ -13657,6 +13776,7 @@ var ragChat = (config) => {
13657
13776
  const matchingHandoff = (input.handoffs ?? []).find((entry) => entry.groupKey === incident.groupKey && entry.targetRolloutLabel === incident.targetRolloutLabel);
13658
13777
  const laneIncident = {
13659
13778
  ...incident,
13779
+ corpusGroupKey: matchingHandoff?.corpusGroupKey,
13660
13780
  kind: "handoff_stale",
13661
13781
  sourceRolloutLabel: matchingHandoff?.sourceRolloutLabel
13662
13782
  };
@@ -14056,6 +14176,7 @@ var ragChat = (config) => {
14056
14176
  approvedAt: input.approvedAt,
14057
14177
  approvedBy: input.approvedBy,
14058
14178
  approvalNotes: input.approvalNotes,
14179
+ corpusGroupKey: input.corpusGroupKey,
14059
14180
  groupKey: input.groupKey,
14060
14181
  id: generateId(),
14061
14182
  label: input.label ?? input.retrievalId,
@@ -14089,6 +14210,19 @@ var ragChat = (config) => {
14089
14210
  ok: false
14090
14211
  };
14091
14212
  }
14213
+ const accessScope = await loadAccessScope(request);
14214
+ if (!isAllowedComparisonGroupKey(accessScope, input.groupKey)) {
14215
+ return {
14216
+ error: "Retrieval baseline group is outside the allowed RAG access scope",
14217
+ ok: false
14218
+ };
14219
+ }
14220
+ if (!isAllowedCorpusGroupKey(accessScope, input.corpusGroupKey)) {
14221
+ return {
14222
+ error: "Retrieval baseline corpus group is outside the allowed RAG access scope",
14223
+ ok: false
14224
+ };
14225
+ }
14092
14226
  const job = createAdminJob("promote_retrieval_baseline", input.groupKey);
14093
14227
  const action = createAdminAction("promote_retrieval_baseline", undefined, input.groupKey);
14094
14228
  try {
@@ -14131,6 +14265,7 @@ var ragChat = (config) => {
14131
14265
  approvedAt: input.approvedAt,
14132
14266
  approvedBy: input.approvedBy,
14133
14267
  approvalNotes: input.approvalNotes,
14268
+ corpusGroupKey: input.corpusGroupKey,
14134
14269
  groupKey: input.groupKey,
14135
14270
  label: input.label,
14136
14271
  metadata: input.metadata,
@@ -14144,6 +14279,7 @@ var ragChat = (config) => {
14144
14279
  });
14145
14280
  await persistRetrievalReleaseDecisionIfConfigured({
14146
14281
  baseline,
14282
+ corpusGroupKey: baseline.corpusGroupKey,
14147
14283
  decidedBy: input.approvedBy,
14148
14284
  kind: "promote",
14149
14285
  notes: input.approvalNotes,
@@ -14186,6 +14322,19 @@ var ragChat = (config) => {
14186
14322
  ok: false
14187
14323
  };
14188
14324
  }
14325
+ const accessScope = await loadAccessScope(request);
14326
+ if (!isAllowedComparisonGroupKey(accessScope, input.groupKey)) {
14327
+ return {
14328
+ error: "Retrieval baseline group is outside the allowed RAG access scope",
14329
+ ok: false
14330
+ };
14331
+ }
14332
+ if (!isAllowedCorpusGroupKey(accessScope, input.corpusGroupKey)) {
14333
+ return {
14334
+ error: "Retrieval baseline corpus group is outside the allowed RAG access scope",
14335
+ ok: false
14336
+ };
14337
+ }
14189
14338
  const job = createAdminJob("promote_retrieval_baseline", input.groupKey);
14190
14339
  const action = createAdminAction("promote_retrieval_baseline", undefined, input.groupKey);
14191
14340
  try {
@@ -14197,6 +14346,13 @@ var ragChat = (config) => {
14197
14346
  if (!sourceRun) {
14198
14347
  throw new Error("Retrieval comparison run was not found");
14199
14348
  }
14349
+ const corpusGroupKey = deriveCorpusGroupKey({
14350
+ corpusGroupKey: input.corpusGroupKey ?? sourceRun.corpusGroupKey ?? sourceRun.comparison.corpusGroupKey,
14351
+ corpusKeys: sourceRun.corpusKeys ?? sourceRun.comparison.corpusKeys
14352
+ });
14353
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14354
+ throw new Error("Retrieval baseline corpus group is outside the allowed RAG access scope");
14355
+ }
14200
14356
  const retrievalId = input.retrievalId ?? sourceRun.decisionSummary?.candidateRetrievalId ?? sourceRun.comparison.summary.bestByPassingRate ?? sourceRun.comparison.entries[0]?.retrievalId;
14201
14357
  if (!retrievalId) {
14202
14358
  throw new Error("Unable to resolve retrieval candidate from comparison run");
@@ -14228,6 +14384,7 @@ var ragChat = (config) => {
14228
14384
  approvedAt: input.approvedAt,
14229
14385
  approvedBy: input.approvedBy,
14230
14386
  approvalNotes: input.approvalNotes,
14387
+ corpusGroupKey,
14231
14388
  groupKey: input.groupKey,
14232
14389
  label: entry?.label ?? retrievalId,
14233
14390
  metadata: input.metadata,
@@ -14241,6 +14398,7 @@ var ragChat = (config) => {
14241
14398
  });
14242
14399
  await persistRetrievalReleaseDecisionIfConfigured({
14243
14400
  baseline,
14401
+ corpusGroupKey,
14244
14402
  decidedBy: input.approvedBy,
14245
14403
  gateStatus: gate?.status,
14246
14404
  kind: "promote",
@@ -14286,6 +14444,19 @@ var ragChat = (config) => {
14286
14444
  ok: false
14287
14445
  };
14288
14446
  }
14447
+ const accessScope = await loadAccessScope(request);
14448
+ if (!isAllowedComparisonGroupKey(accessScope, input.groupKey)) {
14449
+ return {
14450
+ error: "Retrieval baseline group is outside the allowed RAG access scope",
14451
+ ok: false
14452
+ };
14453
+ }
14454
+ if (!isAllowedCorpusGroupKey(accessScope, input.corpusGroupKey)) {
14455
+ return {
14456
+ error: "Retrieval baseline corpus group is outside the allowed RAG access scope",
14457
+ ok: false
14458
+ };
14459
+ }
14289
14460
  const job = createAdminJob("revert_retrieval_baseline", input.groupKey);
14290
14461
  const action = createAdminAction("revert_retrieval_baseline", undefined, input.groupKey);
14291
14462
  try {
@@ -14297,10 +14468,14 @@ var ragChat = (config) => {
14297
14468
  if (!targetBaseline) {
14298
14469
  throw new Error("Retrieval baseline version was not found");
14299
14470
  }
14471
+ if (!isAllowedCorpusGroupKey(accessScope, targetBaseline.corpusGroupKey)) {
14472
+ throw new Error("Retrieval baseline corpus group is outside the allowed RAG access scope");
14473
+ }
14300
14474
  const baseline = await promoteRetrievalBaselineRecord({
14301
14475
  approvedAt: input.approvedAt,
14302
14476
  approvedBy: input.approvedBy,
14303
14477
  approvalNotes: input.approvalNotes,
14478
+ corpusGroupKey: targetBaseline.corpusGroupKey,
14304
14479
  groupKey: input.groupKey,
14305
14480
  label: targetBaseline.label,
14306
14481
  metadata: {
@@ -14317,6 +14492,7 @@ var ragChat = (config) => {
14317
14492
  });
14318
14493
  await persistRetrievalReleaseDecisionIfConfigured({
14319
14494
  baseline,
14495
+ corpusGroupKey: baseline.corpusGroupKey,
14320
14496
  decidedBy: input.approvedBy,
14321
14497
  kind: "revert",
14322
14498
  notes: input.approvalNotes,
@@ -14356,23 +14532,31 @@ var ragChat = (config) => {
14356
14532
  }
14357
14533
  const accessScope = await loadAccessScope(request);
14358
14534
  const groupKey = getStringProperty(queryInput, "groupKey");
14535
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14359
14536
  if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14360
14537
  return {
14361
14538
  error: "Retrieval release decision group is outside the allowed RAG access scope",
14362
14539
  ok: false
14363
14540
  };
14364
14541
  }
14542
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14543
+ return {
14544
+ error: "Retrieval release decision corpus group is outside the allowed RAG access scope",
14545
+ ok: false
14546
+ };
14547
+ }
14365
14548
  const kind = getStringProperty(queryInput, "kind");
14366
14549
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14367
14550
  const freshnessStatusFilter = getStringProperty(queryInput, "freshnessStatus");
14368
14551
  const decisions = await loadRAGRetrievalReleaseDecisions({
14552
+ corpusGroupKey,
14369
14553
  groupKey,
14370
14554
  kind: kind === "approve" || kind === "promote" || kind === "reject" || kind === "revert" ? kind : undefined,
14371
14555
  limit: getIntegerLikeProperty(queryInput, "limit"),
14372
14556
  store: config.retrievalReleaseDecisionStore
14373
14557
  });
14374
14558
  return {
14375
- decisions: filterByComparisonGroupKey(accessScope, decisions).map((decision) => ({
14559
+ decisions: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, decisions)).map((decision) => ({
14376
14560
  ...decision,
14377
14561
  ...getDecisionFreshness({ record: decision })
14378
14562
  })).filter((decision) => {
@@ -14404,6 +14588,13 @@ var ragChat = (config) => {
14404
14588
  ok: false
14405
14589
  };
14406
14590
  }
14591
+ const accessScope = await loadAccessScope(request);
14592
+ if (!isAllowedComparisonGroupKey(accessScope, input.groupKey)) {
14593
+ return {
14594
+ error: "Retrieval release decision group is outside the allowed RAG access scope",
14595
+ ok: false
14596
+ };
14597
+ }
14407
14598
  const runs = await loadRAGRetrievalComparisonHistory({
14408
14599
  groupKey: input.groupKey,
14409
14600
  store: retrievalComparisonHistoryStore
@@ -14415,6 +14606,16 @@ var ragChat = (config) => {
14415
14606
  ok: false
14416
14607
  };
14417
14608
  }
14609
+ const corpusGroupKey = deriveCorpusGroupKey({
14610
+ corpusGroupKey: sourceRun.corpusGroupKey ?? sourceRun.comparison.corpusGroupKey,
14611
+ corpusKeys: sourceRun.corpusKeys ?? sourceRun.comparison.corpusKeys
14612
+ });
14613
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14614
+ return {
14615
+ error: "Retrieval release decision corpus group is outside the allowed RAG access scope",
14616
+ ok: false
14617
+ };
14618
+ }
14418
14619
  const retrievalId = input.retrievalId ?? sourceRun.decisionSummary?.candidateRetrievalId ?? sourceRun.comparison.summary.bestByPassingRate ?? sourceRun.comparison.entries[0]?.retrievalId;
14419
14620
  if (!retrievalId) {
14420
14621
  return {
@@ -14444,6 +14645,7 @@ var ragChat = (config) => {
14444
14645
  const decidedAt = Date.now();
14445
14646
  await persistRetrievalReleaseDecisionIfConfigured({
14446
14647
  baseline: undefined,
14648
+ corpusGroupKey,
14447
14649
  decidedAt: input.decidedAt,
14448
14650
  decidedBy: input.decidedBy,
14449
14651
  gateStatus: gate?.status,
@@ -14457,17 +14659,19 @@ var ragChat = (config) => {
14457
14659
  targetRolloutLabel: input.targetRolloutLabel
14458
14660
  });
14459
14661
  const decisions = await loadRAGRetrievalReleaseDecisions({
14662
+ corpusGroupKey,
14460
14663
  groupKey: input.groupKey,
14461
14664
  limit: 10,
14462
14665
  store: config.retrievalReleaseDecisionStore
14463
14666
  });
14464
14667
  return {
14465
- decisions,
14668
+ decisions: filterByCorpusGroupKey(accessScope, decisions),
14466
14669
  ok: true
14467
14670
  };
14468
14671
  };
14469
- const handleRetrievalReleaseGroupHistory = async (queryInput) => {
14672
+ const handleRetrievalReleaseGroupHistory = async (queryInput, request) => {
14470
14673
  const groupKey = getStringProperty(queryInput, "groupKey");
14674
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14471
14675
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14472
14676
  if (!groupKey) {
14473
14677
  return {
@@ -14475,7 +14679,21 @@ var ragChat = (config) => {
14475
14679
  ok: false
14476
14680
  };
14477
14681
  }
14682
+ const accessScope = await loadAccessScope(request);
14683
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14684
+ return {
14685
+ error: "Retrieval release decision group is outside the allowed RAG access scope",
14686
+ ok: false
14687
+ };
14688
+ }
14689
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14690
+ return {
14691
+ error: "Retrieval release corpus group is outside the allowed RAG access scope",
14692
+ ok: false
14693
+ };
14694
+ }
14478
14695
  const decisions = config.retrievalReleaseDecisionStore ? (await loadRAGRetrievalReleaseDecisions({
14696
+ corpusGroupKey,
14479
14697
  groupKey,
14480
14698
  limit: getIntegerLikeProperty(queryInput, "decisionLimit") ?? 20,
14481
14699
  store: config.retrievalReleaseDecisionStore
@@ -14484,11 +14702,13 @@ var ragChat = (config) => {
14484
14702
  ...getDecisionFreshness({ record: decision })
14485
14703
  })).filter((decision) => targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? decision.targetRolloutLabel === targetRolloutLabel : true) : undefined;
14486
14704
  const baselines = retrievalBaselineStore ? await loadRAGRetrievalBaselines({
14705
+ corpusGroupKey,
14487
14706
  groupKey,
14488
14707
  limit: getIntegerLikeProperty(queryInput, "baselineLimit") ?? 20,
14489
14708
  store: retrievalBaselineStore
14490
14709
  }).then((entries) => targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? entries.filter((entry) => entry.rolloutLabel === targetRolloutLabel) : entries) : undefined;
14491
14710
  const runs = retrievalComparisonHistoryStore ? await loadRAGRetrievalComparisonHistory({
14711
+ corpusGroupKey,
14492
14712
  groupKey,
14493
14713
  limit: getIntegerLikeProperty(queryInput, "runLimit") ?? 20,
14494
14714
  store: retrievalComparisonHistoryStore
@@ -14496,11 +14716,13 @@ var ragChat = (config) => {
14496
14716
  const latest = decisions?.[0];
14497
14717
  return {
14498
14718
  baselines,
14719
+ corpusGroupKey: corpusGroupKey ?? decisions?.[0]?.corpusGroupKey ?? baselines?.[0]?.corpusGroupKey ?? runs?.[0]?.corpusGroupKey,
14499
14720
  decisions,
14500
14721
  groupKey,
14501
14722
  ok: true,
14502
14723
  runs,
14503
14724
  timeline: {
14725
+ corpusGroupKey: corpusGroupKey ?? decisions?.[0]?.corpusGroupKey ?? baselines?.[0]?.corpusGroupKey ?? runs?.[0]?.corpusGroupKey,
14504
14726
  groupKey,
14505
14727
  lastApprovedAt: decisions?.find((entry) => entry.kind === "approve")?.decidedAt,
14506
14728
  lastPromotedAt: decisions?.find((entry) => entry.kind === "promote")?.decidedAt,
@@ -14512,29 +14734,53 @@ var ragChat = (config) => {
14512
14734
  }
14513
14735
  };
14514
14736
  };
14515
- const handleRetrievalLaneHandoffList = async (queryInput) => {
14737
+ const handleRetrievalLaneHandoffList = async (queryInput, request) => {
14516
14738
  const result = await buildOperationsPayload();
14739
+ const accessScope = await loadAccessScope(request);
14740
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14741
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14742
+ return {
14743
+ error: "Retrieval lane handoff corpus group is outside the allowed RAG access scope",
14744
+ ok: false
14745
+ };
14746
+ }
14517
14747
  const sourceRolloutLabel = getStringProperty(queryInput, "sourceRolloutLabel");
14518
14748
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14519
14749
  const limit = getIntegerLikeProperty(queryInput, "limit");
14520
- const handoffs = (result.retrievalComparisons?.releaseLaneHandoffs ?? []).filter((entry) => (!getStringProperty(queryInput, "groupKey") || entry.groupKey === getStringProperty(queryInput, "groupKey")) && (sourceRolloutLabel !== "canary" && sourceRolloutLabel !== "stable" && sourceRolloutLabel !== "rollback_target" || entry.sourceRolloutLabel === sourceRolloutLabel) && (targetRolloutLabel !== "canary" && targetRolloutLabel !== "stable" && targetRolloutLabel !== "rollback_target" || entry.targetRolloutLabel === targetRolloutLabel));
14750
+ const handoffs = (result.retrievalComparisons?.releaseLaneHandoffs ?? []).filter((entry) => (!corpusGroupKey || entry.corpusGroupKey === corpusGroupKey) && (!getStringProperty(queryInput, "groupKey") || entry.groupKey === getStringProperty(queryInput, "groupKey")) && (sourceRolloutLabel !== "canary" && sourceRolloutLabel !== "stable" && sourceRolloutLabel !== "rollback_target" || entry.sourceRolloutLabel === sourceRolloutLabel) && (targetRolloutLabel !== "canary" && targetRolloutLabel !== "stable" && targetRolloutLabel !== "rollback_target" || entry.targetRolloutLabel === targetRolloutLabel));
14521
14751
  return {
14522
14752
  handoffs: typeof limit === "number" ? handoffs.slice(0, limit) : handoffs,
14523
14753
  ok: true
14524
14754
  };
14525
14755
  };
14526
- const handleRetrievalLaneHandoffDecisionList = async (queryInput) => {
14756
+ const handleRetrievalLaneHandoffDecisionList = async (queryInput, request) => {
14527
14757
  if (!config.retrievalLaneHandoffDecisionStore) {
14528
14758
  return {
14529
14759
  error: "RAG retrieval lane handoff decision store is not configured",
14530
14760
  ok: false
14531
14761
  };
14532
14762
  }
14763
+ const accessScope = await loadAccessScope(request);
14764
+ const groupKey = getStringProperty(queryInput, "groupKey");
14765
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14766
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14767
+ return {
14768
+ error: "Retrieval lane handoff decision group is outside the allowed RAG access scope",
14769
+ ok: false
14770
+ };
14771
+ }
14772
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14773
+ return {
14774
+ error: "Retrieval lane handoff decision corpus group is outside the allowed RAG access scope",
14775
+ ok: false
14776
+ };
14777
+ }
14533
14778
  const sourceRolloutLabel = getStringProperty(queryInput, "sourceRolloutLabel");
14534
14779
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14535
14780
  const kind = getStringProperty(queryInput, "kind");
14536
14781
  const decisions = await loadRAGRetrievalLaneHandoffDecisions({
14537
- groupKey: getStringProperty(queryInput, "groupKey"),
14782
+ corpusGroupKey,
14783
+ groupKey,
14538
14784
  kind: kind === "approve" || kind === "reject" || kind === "complete" ? kind : undefined,
14539
14785
  limit: getIntegerLikeProperty(queryInput, "limit"),
14540
14786
  sourceRolloutLabel: sourceRolloutLabel === "canary" || sourceRolloutLabel === "stable" || sourceRolloutLabel === "rollback_target" ? sourceRolloutLabel : undefined,
@@ -14542,116 +14788,230 @@ var ragChat = (config) => {
14542
14788
  targetRolloutLabel: targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? targetRolloutLabel : undefined
14543
14789
  });
14544
14790
  return {
14545
- decisions,
14791
+ decisions: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, decisions)),
14546
14792
  ok: true
14547
14793
  };
14548
14794
  };
14549
- const handleRetrievalLaneHandoffIncidentList = async (queryInput) => {
14795
+ const handleRetrievalLaneHandoffIncidentList = async (queryInput, request) => {
14550
14796
  if (!config.retrievalLaneHandoffIncidentStore) {
14551
14797
  return {
14552
14798
  error: "RAG retrieval lane handoff incident store is not configured",
14553
14799
  ok: false
14554
14800
  };
14555
14801
  }
14802
+ const accessScope = await loadAccessScope(request);
14803
+ const groupKey = getStringProperty(queryInput, "groupKey");
14804
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14805
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14806
+ return {
14807
+ error: "Retrieval lane handoff incident group is outside the allowed RAG access scope",
14808
+ ok: false
14809
+ };
14810
+ }
14811
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14812
+ return {
14813
+ error: "Retrieval lane handoff incident corpus group is outside the allowed RAG access scope",
14814
+ ok: false
14815
+ };
14816
+ }
14556
14817
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14557
14818
  const status = getStringProperty(queryInput, "status");
14558
14819
  const severity = getStringProperty(queryInput, "severity");
14559
14820
  const incidents = await loadRAGRetrievalLaneHandoffIncidents({
14560
- groupKey: getStringProperty(queryInput, "groupKey"),
14821
+ corpusGroupKey,
14822
+ groupKey,
14561
14823
  limit: getIntegerLikeProperty(queryInput, "limit"),
14562
14824
  severity: severity === "warning" || severity === "critical" ? severity : undefined,
14563
14825
  status: status === "open" || status === "resolved" ? status : undefined,
14564
14826
  store: config.retrievalLaneHandoffIncidentStore,
14565
14827
  targetRolloutLabel: targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? targetRolloutLabel : undefined
14566
14828
  });
14567
- return { incidents, ok: true };
14829
+ return {
14830
+ incidents: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, incidents)),
14831
+ ok: true
14832
+ };
14568
14833
  };
14569
- const handleRetrievalLaneHandoffIncidentHistoryList = async (queryInput) => {
14834
+ const handleRetrievalLaneHandoffIncidentHistoryList = async (queryInput, request) => {
14570
14835
  if (!config.retrievalLaneHandoffIncidentHistoryStore) {
14571
14836
  return {
14572
14837
  error: "RAG retrieval lane handoff incident history store is not configured",
14573
14838
  ok: false
14574
14839
  };
14575
14840
  }
14841
+ const accessScope = await loadAccessScope(request);
14842
+ const groupKey = getStringProperty(queryInput, "groupKey");
14843
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14844
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14845
+ return {
14846
+ error: "Retrieval lane handoff incident history group is outside the allowed RAG access scope",
14847
+ ok: false
14848
+ };
14849
+ }
14850
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14851
+ return {
14852
+ error: "Retrieval lane handoff incident history corpus group is outside the allowed RAG access scope",
14853
+ ok: false
14854
+ };
14855
+ }
14576
14856
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14577
14857
  const action = getStringProperty(queryInput, "action");
14578
14858
  const records = await loadRAGRetrievalLaneHandoffIncidentHistory({
14859
+ corpusGroupKey,
14579
14860
  action: action === "opened" || action === "acknowledged" || action === "unacknowledged" || action === "resolved" ? action : undefined,
14580
- groupKey: getStringProperty(queryInput, "groupKey"),
14861
+ groupKey,
14581
14862
  incidentId: getStringProperty(queryInput, "incidentId"),
14582
14863
  limit: getIntegerLikeProperty(queryInput, "limit"),
14583
14864
  store: config.retrievalLaneHandoffIncidentHistoryStore,
14584
14865
  targetRolloutLabel: targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? targetRolloutLabel : undefined
14585
14866
  });
14586
- return { ok: true, records };
14867
+ return {
14868
+ ok: true,
14869
+ records: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, records))
14870
+ };
14587
14871
  };
14588
- const handleRetrievalLaneHandoffAutoCompletePolicyHistoryList = async (queryInput) => {
14872
+ const handleRetrievalLaneHandoffAutoCompletePolicyHistoryList = async (queryInput, request) => {
14589
14873
  if (!config.retrievalLaneHandoffAutoCompletePolicyHistoryStore) {
14590
14874
  return {
14591
14875
  error: "RAG retrieval lane handoff auto-complete policy history store is not configured",
14592
14876
  ok: false
14593
14877
  };
14594
14878
  }
14879
+ const accessScope = await loadAccessScope(request);
14880
+ const groupKey = getStringProperty(queryInput, "groupKey");
14881
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14882
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14883
+ return {
14884
+ error: "Retrieval lane handoff auto-complete policy group is outside the allowed RAG access scope",
14885
+ ok: false
14886
+ };
14887
+ }
14888
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14889
+ return {
14890
+ error: "Retrieval lane handoff auto-complete policy corpus group is outside the allowed RAG access scope",
14891
+ ok: false
14892
+ };
14893
+ }
14595
14894
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14596
14895
  const records = await loadRAGRetrievalLaneHandoffAutoCompletePolicyHistory({
14597
- groupKey: getStringProperty(queryInput, "groupKey"),
14896
+ corpusGroupKey,
14897
+ groupKey,
14598
14898
  limit: getIntegerLikeProperty(queryInput, "limit"),
14599
14899
  store: config.retrievalLaneHandoffAutoCompletePolicyHistoryStore,
14600
14900
  targetRolloutLabel: targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? targetRolloutLabel : undefined
14601
14901
  });
14602
- return { ok: true, records };
14902
+ return {
14903
+ ok: true,
14904
+ records: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, records))
14905
+ };
14603
14906
  };
14604
- const handleRetrievalReleaseLanePolicyHistoryList = async (queryInput) => {
14907
+ const handleRetrievalReleaseLanePolicyHistoryList = async (queryInput, request) => {
14605
14908
  if (!config.retrievalReleaseLanePolicyHistoryStore) {
14606
14909
  return {
14607
14910
  error: "RAG retrieval release lane policy history store is not configured",
14608
14911
  ok: false
14609
14912
  };
14610
14913
  }
14914
+ const accessScope = await loadAccessScope(request);
14915
+ const groupKey = getStringProperty(queryInput, "groupKey");
14916
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14917
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14918
+ return {
14919
+ error: "Retrieval release lane policy group is outside the allowed RAG access scope",
14920
+ ok: false
14921
+ };
14922
+ }
14923
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14924
+ return {
14925
+ error: "Retrieval release lane policy corpus group is outside the allowed RAG access scope",
14926
+ ok: false
14927
+ };
14928
+ }
14611
14929
  const rolloutLabel = getStringProperty(queryInput, "rolloutLabel");
14612
14930
  const scope = getStringProperty(queryInput, "scope");
14613
14931
  const records = await loadRAGRetrievalReleaseLanePolicyHistory({
14614
- groupKey: getStringProperty(queryInput, "groupKey"),
14932
+ corpusGroupKey,
14933
+ groupKey,
14615
14934
  limit: getIntegerLikeProperty(queryInput, "limit"),
14616
14935
  rolloutLabel: rolloutLabel === "canary" || rolloutLabel === "stable" || rolloutLabel === "rollback_target" ? rolloutLabel : undefined,
14617
14936
  scope: scope === "rollout_label" || scope === "group_rollout_label" ? scope : undefined,
14618
14937
  store: config.retrievalReleaseLanePolicyHistoryStore
14619
14938
  });
14620
- return { ok: true, records };
14939
+ return {
14940
+ ok: true,
14941
+ records: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, records))
14942
+ };
14621
14943
  };
14622
- const handleRetrievalBaselineGatePolicyHistoryList = async (queryInput) => {
14944
+ const handleRetrievalBaselineGatePolicyHistoryList = async (queryInput, request) => {
14623
14945
  if (!config.retrievalBaselineGatePolicyHistoryStore) {
14624
14946
  return {
14625
14947
  error: "RAG retrieval baseline gate policy history store is not configured",
14626
14948
  ok: false
14627
14949
  };
14628
14950
  }
14951
+ const accessScope = await loadAccessScope(request);
14952
+ const groupKey = getStringProperty(queryInput, "groupKey");
14953
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14954
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14955
+ return {
14956
+ error: "Retrieval baseline gate policy group is outside the allowed RAG access scope",
14957
+ ok: false
14958
+ };
14959
+ }
14960
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14961
+ return {
14962
+ error: "Retrieval baseline gate policy corpus group is outside the allowed RAG access scope",
14963
+ ok: false
14964
+ };
14965
+ }
14629
14966
  const rolloutLabel = getStringProperty(queryInput, "rolloutLabel");
14630
14967
  const scope = getStringProperty(queryInput, "scope");
14631
14968
  const records = await loadRAGRetrievalBaselineGatePolicyHistory({
14632
- groupKey: getStringProperty(queryInput, "groupKey"),
14969
+ corpusGroupKey,
14970
+ groupKey,
14633
14971
  limit: getIntegerLikeProperty(queryInput, "limit"),
14634
14972
  rolloutLabel: rolloutLabel === "canary" || rolloutLabel === "stable" || rolloutLabel === "rollback_target" ? rolloutLabel : undefined,
14635
14973
  scope: scope === "rollout_label" || scope === "group_rollout_label" ? scope : undefined,
14636
14974
  store: config.retrievalBaselineGatePolicyHistoryStore
14637
14975
  });
14638
- return { ok: true, records };
14976
+ return {
14977
+ ok: true,
14978
+ records: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, records))
14979
+ };
14639
14980
  };
14640
- const handleRetrievalReleaseLaneEscalationPolicyHistoryList = async (queryInput) => {
14981
+ const handleRetrievalReleaseLaneEscalationPolicyHistoryList = async (queryInput, request) => {
14641
14982
  if (!config.retrievalReleaseLaneEscalationPolicyHistoryStore) {
14642
14983
  return {
14643
14984
  error: "RAG retrieval release lane escalation policy history store is not configured",
14644
14985
  ok: false
14645
14986
  };
14646
14987
  }
14988
+ const accessScope = await loadAccessScope(request);
14989
+ const groupKey = getStringProperty(queryInput, "groupKey");
14990
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14991
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14992
+ return {
14993
+ error: "Retrieval release lane escalation policy group is outside the allowed RAG access scope",
14994
+ ok: false
14995
+ };
14996
+ }
14997
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14998
+ return {
14999
+ error: "Retrieval release lane escalation policy corpus group is outside the allowed RAG access scope",
15000
+ ok: false
15001
+ };
15002
+ }
14647
15003
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14648
15004
  const records = await loadRAGRetrievalReleaseLaneEscalationPolicyHistory({
14649
- groupKey: getStringProperty(queryInput, "groupKey"),
15005
+ corpusGroupKey,
15006
+ groupKey,
14650
15007
  limit: getIntegerLikeProperty(queryInput, "limit"),
14651
15008
  store: config.retrievalReleaseLaneEscalationPolicyHistoryStore,
14652
15009
  targetRolloutLabel: targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? targetRolloutLabel : undefined
14653
15010
  });
14654
- return { ok: true, records };
15011
+ return {
15012
+ ok: true,
15013
+ records: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, records))
15014
+ };
14655
15015
  };
14656
15016
  const handleRetrievalLaneHandoffDecision = async (body) => {
14657
15017
  if (!config.retrievalLaneHandoffDecisionStore) {
@@ -14667,6 +15027,19 @@ var ragChat = (config) => {
14667
15027
  ok: false
14668
15028
  };
14669
15029
  }
15030
+ const accessScope = await loadAccessScope();
15031
+ if (!isAllowedComparisonGroupKey(accessScope, input.groupKey)) {
15032
+ return {
15033
+ error: "Retrieval lane handoff group is outside the allowed RAG access scope",
15034
+ ok: false
15035
+ };
15036
+ }
15037
+ if (!isAllowedCorpusGroupKey(accessScope, input.corpusGroupKey)) {
15038
+ return {
15039
+ error: "Retrieval lane handoff corpus group is outside the allowed RAG access scope",
15040
+ ok: false
15041
+ };
15042
+ }
14670
15043
  const ops = await buildOperationsPayload();
14671
15044
  const handoff = ops.retrievalComparisons?.releaseLaneHandoffs?.find((entry) => entry.groupKey === input.groupKey && entry.sourceRolloutLabel === input.sourceRolloutLabel && entry.targetRolloutLabel === input.targetRolloutLabel);
14672
15045
  if (!handoff) {
@@ -14675,6 +15048,13 @@ var ragChat = (config) => {
14675
15048
  ok: false
14676
15049
  };
14677
15050
  }
15051
+ const corpusGroupKey = input.corpusGroupKey ?? handoff.corpusGroupKey;
15052
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
15053
+ return {
15054
+ error: "Retrieval lane handoff corpus group is outside the allowed RAG access scope",
15055
+ ok: false
15056
+ };
15057
+ }
14678
15058
  if (input.kind === "approve" && handoff.readyForHandoff !== true) {
14679
15059
  return {
14680
15060
  error: `handoff is not ready: ${handoff.reasons.join("; ")}`,
@@ -14699,6 +15079,7 @@ var ragChat = (config) => {
14699
15079
  approvalNotes: input.notes,
14700
15080
  approvedAt: input.decidedAt,
14701
15081
  approvedBy: input.decidedBy,
15082
+ corpusGroupKey,
14702
15083
  groupKey: input.groupKey,
14703
15084
  retrievalId: input.candidateRetrievalId ?? handoff.candidateRetrievalId,
14704
15085
  rolloutLabel: input.targetRolloutLabel,
@@ -14714,6 +15095,7 @@ var ragChat = (config) => {
14714
15095
  const decision = await persistRAGRetrievalLaneHandoffDecision({
14715
15096
  record: {
14716
15097
  candidateRetrievalId: input.candidateRetrievalId ?? handoff.candidateRetrievalId,
15098
+ corpusGroupKey,
14717
15099
  decidedAt: input.decidedAt ?? Date.now(),
14718
15100
  decidedBy: input.decidedBy,
14719
15101
  groupKey: input.groupKey,
@@ -14741,6 +15123,7 @@ var ragChat = (config) => {
14741
15123
  approvalNotes: input.notes,
14742
15124
  approvedAt,
14743
15125
  approvedBy: input.decidedBy,
15126
+ corpusGroupKey,
14744
15127
  groupKey: input.groupKey,
14745
15128
  retrievalId: input.candidateRetrievalId ?? handoff.candidateRetrievalId,
14746
15129
  rolloutLabel: input.targetRolloutLabel,
@@ -14755,6 +15138,7 @@ var ragChat = (config) => {
14755
15138
  await persistRAGRetrievalLaneHandoffDecision({
14756
15139
  record: {
14757
15140
  candidateRetrievalId: input.candidateRetrievalId ?? handoff.candidateRetrievalId,
15141
+ corpusGroupKey,
14758
15142
  decidedAt: Date.now(),
14759
15143
  decidedBy: input.decidedBy,
14760
15144
  groupKey: input.groupKey,
@@ -14790,6 +15174,7 @@ var ragChat = (config) => {
14790
15174
  const acknowledged = getStringProperty(queryInput, "acknowledged");
14791
15175
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14792
15176
  const incidents = await loadRAGRetrievalReleaseIncidents({
15177
+ corpusGroupKey: getStringProperty(queryInput, "corpusGroupKey"),
14793
15178
  groupKey: getStringProperty(queryInput, "groupKey"),
14794
15179
  limit: getIntegerLikeProperty(queryInput, "limit"),
14795
15180
  severity: severity === "warning" || severity === "critical" ? severity : undefined,
@@ -15440,6 +15825,7 @@ var ragChat = (config) => {
15440
15825
  });
15441
15826
  return {
15442
15827
  incidents: await loadRAGRetrievalReleaseIncidents({
15828
+ corpusGroupKey: incident.corpusGroupKey,
15443
15829
  groupKey: incident.groupKey,
15444
15830
  limit: 20,
15445
15831
  store: config.retrievalReleaseIncidentStore
@@ -15483,6 +15869,7 @@ var ragChat = (config) => {
15483
15869
  });
15484
15870
  return {
15485
15871
  incidents: await loadRAGRetrievalReleaseIncidents({
15872
+ corpusGroupKey: incident.corpusGroupKey,
15486
15873
  groupKey: incident.groupKey,
15487
15874
  limit: 20,
15488
15875
  store: config.retrievalReleaseIncidentStore
@@ -15526,6 +15913,7 @@ var ragChat = (config) => {
15526
15913
  });
15527
15914
  return {
15528
15915
  incidents: await loadRAGRetrievalReleaseIncidents({
15916
+ corpusGroupKey: incident.corpusGroupKey,
15529
15917
  groupKey: incident.groupKey,
15530
15918
  limit: 20,
15531
15919
  store: config.retrievalReleaseIncidentStore
@@ -16166,6 +16554,7 @@ var ragChat = (config) => {
16166
16554
  });
16167
16555
  const buildOperationsPayload = async (request) => {
16168
16556
  const accessScope = await loadAccessScope(request);
16557
+ const filterScopedGovernanceEntries = (entries) => entries ? filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, entries)) : undefined;
16169
16558
  const collection = config.collection ?? (ragStore ? createRAGCollection({
16170
16559
  defaultModel: config.embeddingModel,
16171
16560
  defaultTopK: topK,
@@ -16185,51 +16574,51 @@ var ragChat = (config) => {
16185
16574
  limit: 5,
16186
16575
  store: searchTracePruneHistoryStore
16187
16576
  }) : undefined;
16188
- const recentRetrievalComparisonRuns = retrievalComparisonHistoryStore ? await loadRAGRetrievalComparisonHistory({
16577
+ const recentRetrievalComparisonRuns = filterScopedGovernanceEntries(retrievalComparisonHistoryStore ? await loadRAGRetrievalComparisonHistory({
16189
16578
  limit: 5,
16190
16579
  store: retrievalComparisonHistoryStore
16191
- }) : undefined;
16192
- const activeRetrievalBaselines = retrievalBaselineStore ? await loadRAGRetrievalBaselines({
16580
+ }) : undefined);
16581
+ const activeRetrievalBaselines = filterScopedGovernanceEntries(retrievalBaselineStore ? await loadRAGRetrievalBaselines({
16193
16582
  limit: 5,
16194
16583
  status: "active",
16195
16584
  store: retrievalBaselineStore
16196
- }) : undefined;
16197
- const retrievalBaselineHistory = retrievalBaselineStore ? await loadRAGRetrievalBaselines({
16585
+ }) : undefined);
16586
+ const retrievalBaselineHistory = filterScopedGovernanceEntries(retrievalBaselineStore ? await loadRAGRetrievalBaselines({
16198
16587
  limit: 10,
16199
16588
  store: retrievalBaselineStore
16200
- }) : undefined;
16201
- const recentRetrievalReleaseDecisions = config.retrievalReleaseDecisionStore ? await loadRAGRetrievalReleaseDecisions({
16589
+ }) : undefined);
16590
+ const recentRetrievalReleaseDecisions = filterScopedGovernanceEntries(config.retrievalReleaseDecisionStore ? await loadRAGRetrievalReleaseDecisions({
16202
16591
  limit: 10,
16203
16592
  store: config.retrievalReleaseDecisionStore
16204
- }) : undefined;
16205
- const recentRetrievalLaneHandoffDecisions = config.retrievalLaneHandoffDecisionStore ? await loadRAGRetrievalLaneHandoffDecisions({
16593
+ }) : undefined);
16594
+ const recentRetrievalLaneHandoffDecisions = filterScopedGovernanceEntries(config.retrievalLaneHandoffDecisionStore ? await loadRAGRetrievalLaneHandoffDecisions({
16206
16595
  limit: 10,
16207
16596
  store: config.retrievalLaneHandoffDecisionStore
16208
- }) : undefined;
16209
- const recentRetrievalLaneHandoffIncidents = config.retrievalLaneHandoffIncidentStore ? await loadRAGRetrievalLaneHandoffIncidents({
16597
+ }) : undefined);
16598
+ const recentRetrievalLaneHandoffIncidents = filterScopedGovernanceEntries(config.retrievalLaneHandoffIncidentStore ? await loadRAGRetrievalLaneHandoffIncidents({
16210
16599
  limit: 10,
16211
16600
  store: config.retrievalLaneHandoffIncidentStore
16212
- }) : undefined;
16213
- const recentRetrievalLaneHandoffIncidentHistory = config.retrievalLaneHandoffIncidentHistoryStore ? await loadRAGRetrievalLaneHandoffIncidentHistory({
16601
+ }) : undefined);
16602
+ const recentRetrievalLaneHandoffIncidentHistory = filterScopedGovernanceEntries(config.retrievalLaneHandoffIncidentHistoryStore ? await loadRAGRetrievalLaneHandoffIncidentHistory({
16214
16603
  limit: 10,
16215
16604
  store: config.retrievalLaneHandoffIncidentHistoryStore
16216
- }) : undefined;
16217
- const recentHandoffAutoCompletePolicyHistory = config.retrievalLaneHandoffAutoCompletePolicyHistoryStore ? await loadRAGRetrievalLaneHandoffAutoCompletePolicyHistory({
16605
+ }) : undefined);
16606
+ const recentHandoffAutoCompletePolicyHistory = filterScopedGovernanceEntries(config.retrievalLaneHandoffAutoCompletePolicyHistoryStore ? await loadRAGRetrievalLaneHandoffAutoCompletePolicyHistory({
16218
16607
  limit: 10,
16219
16608
  store: config.retrievalLaneHandoffAutoCompletePolicyHistoryStore
16220
- }) : undefined;
16221
- const recentReleaseLanePolicyHistory = config.retrievalReleaseLanePolicyHistoryStore ? await loadRAGRetrievalReleaseLanePolicyHistory({
16609
+ }) : undefined);
16610
+ const recentReleaseLanePolicyHistory = filterScopedGovernanceEntries(config.retrievalReleaseLanePolicyHistoryStore ? await loadRAGRetrievalReleaseLanePolicyHistory({
16222
16611
  limit: 10,
16223
16612
  store: config.retrievalReleaseLanePolicyHistoryStore
16224
- }) : undefined;
16225
- const recentBaselineGatePolicyHistory = config.retrievalBaselineGatePolicyHistoryStore ? await loadRAGRetrievalBaselineGatePolicyHistory({
16613
+ }) : undefined);
16614
+ const recentBaselineGatePolicyHistory = filterScopedGovernanceEntries(config.retrievalBaselineGatePolicyHistoryStore ? await loadRAGRetrievalBaselineGatePolicyHistory({
16226
16615
  limit: 10,
16227
16616
  store: config.retrievalBaselineGatePolicyHistoryStore
16228
- }) : undefined;
16229
- const recentReleaseLaneEscalationPolicyHistory = config.retrievalReleaseLaneEscalationPolicyHistoryStore ? await loadRAGRetrievalReleaseLaneEscalationPolicyHistory({
16617
+ }) : undefined);
16618
+ const recentReleaseLaneEscalationPolicyHistory = filterScopedGovernanceEntries(config.retrievalReleaseLaneEscalationPolicyHistoryStore ? await loadRAGRetrievalReleaseLaneEscalationPolicyHistory({
16230
16619
  limit: 10,
16231
16620
  store: config.retrievalReleaseLaneEscalationPolicyHistoryStore
16232
- }) : undefined;
16621
+ }) : undefined);
16233
16622
  const recentIncidentRemediationDecisions = config.retrievalIncidentRemediationDecisionStore ? await loadRAGRetrievalIncidentRemediationDecisions({
16234
16623
  limit: 10,
16235
16624
  store: config.retrievalIncidentRemediationDecisionStore
@@ -16294,6 +16683,12 @@ var ragChat = (config) => {
16294
16683
  targetRolloutLabel
16295
16684
  };
16296
16685
  }) : undefined;
16686
+ const getComparisonCorpusGroupKey = (groupKey) => {
16687
+ if (!groupKey) {
16688
+ return;
16689
+ }
16690
+ return (recentRetrievalComparisonRuns ?? []).find((entry) => entry.groupKey === groupKey && typeof entry.corpusGroupKey === "string")?.corpusGroupKey ?? (activeRetrievalBaselines ?? []).find((entry) => entry.groupKey === groupKey && typeof entry.corpusGroupKey === "string")?.corpusGroupKey ?? (recentRetrievalReleaseDecisions ?? []).find((entry) => entry.groupKey === groupKey && typeof entry.corpusGroupKey === "string")?.corpusGroupKey;
16691
+ };
16297
16692
  const baseReleaseGroups = (() => {
16298
16693
  const groups = new Set;
16299
16694
  for (const run of recentRetrievalComparisonRuns ?? []) {
@@ -16355,6 +16750,7 @@ var ragChat = (config) => {
16355
16750
  approvalMaxAgeMs: getRetrievalReleasePolicy(groupKey).approvalMaxAgeMs,
16356
16751
  approvalRequired: getRetrievalReleasePolicy(groupKey).requireApprovalBeforePromotion === true,
16357
16752
  blockedReasons,
16753
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16358
16754
  escalationSeverity,
16359
16755
  groupKey,
16360
16756
  latestDecisionAt: latestDecision?.decidedAt,
@@ -16404,6 +16800,7 @@ var ragChat = (config) => {
16404
16800
  const groupDecisions = (enrichedRecentRetrievalReleaseDecisions ?? []).filter((entry) => entry.groupKey === groupKey);
16405
16801
  const latest = groupDecisions[0];
16406
16802
  return {
16803
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16407
16804
  groupKey,
16408
16805
  lastApprovedAt: groupDecisions.find((entry) => entry.kind === "approve")?.decidedAt,
16409
16806
  lastPromotedAt: groupDecisions.find((entry) => entry.kind === "promote")?.decidedAt,
@@ -16435,6 +16832,7 @@ var ragChat = (config) => {
16435
16832
  const laneDecisions = (enrichedRecentRetrievalReleaseDecisions ?? []).filter((entry) => entry.groupKey === groupKey && (entry.targetRolloutLabel ?? undefined) === targetRolloutLabel);
16436
16833
  const latest = laneDecisions[0];
16437
16834
  summaries.push({
16835
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16438
16836
  groupKey,
16439
16837
  lastApprovedAt: laneDecisions.find((entry) => entry.kind === "approve")?.decidedAt,
16440
16838
  lastPromotedAt: laneDecisions.find((entry) => entry.kind === "promote")?.decidedAt,
@@ -16470,6 +16868,7 @@ var ragChat = (config) => {
16470
16868
  const latest = laneDecisions[0];
16471
16869
  summaries.push({
16472
16870
  approvalCount: laneDecisions.filter((entry) => entry.kind === "approve").length,
16871
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16473
16872
  decisionCount: laneDecisions.length,
16474
16873
  groupKey,
16475
16874
  latestDecisionAt: latest?.decidedAt,
@@ -16763,6 +17162,7 @@ var ragChat = (config) => {
16763
17162
  if (!latest) {
16764
17163
  await persistLaneHandoffAutoCompletePolicyHistoryRecord({
16765
17164
  changeKind: "snapshot",
17165
+ corpusGroupKey: getComparisonCorpusGroupKey(policy.groupKey),
16766
17166
  enabled: policy.enabled,
16767
17167
  groupKey: policy.groupKey,
16768
17168
  maxApprovedDecisionAgeMs: policy.maxApprovedDecisionAgeMs,
@@ -16773,6 +17173,7 @@ var ragChat = (config) => {
16773
17173
  if (latest.enabled !== policy.enabled || latest.maxApprovedDecisionAgeMs !== policy.maxApprovedDecisionAgeMs) {
16774
17174
  await persistLaneHandoffAutoCompletePolicyHistoryRecord({
16775
17175
  changeKind: "changed",
17176
+ corpusGroupKey: getComparisonCorpusGroupKey(policy.groupKey),
16776
17177
  enabled: policy.enabled,
16777
17178
  groupKey: policy.groupKey,
16778
17179
  maxApprovedDecisionAgeMs: policy.maxApprovedDecisionAgeMs,
@@ -16810,6 +17211,7 @@ var ragChat = (config) => {
16810
17211
  const latest = laneIncidents[0];
16811
17212
  summaries.push({
16812
17213
  acknowledgedOpenCount,
17214
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16813
17215
  groupKey,
16814
17216
  highestSeverity: laneIncidents.some((entry) => entry.severity === "critical") ? "critical" : laneIncidents.some((entry) => entry.severity === "warning") ? "warning" : undefined,
16815
17217
  latestKind: latest?.kind,
@@ -16865,6 +17267,7 @@ var ragChat = (config) => {
16865
17267
  await persistReleaseLanePolicyHistoryRecord({
16866
17268
  approvalMaxAgeMs: policy.approvalMaxAgeMs,
16867
17269
  changeKind: "snapshot",
17270
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16868
17271
  groupKey,
16869
17272
  requireApprovalBeforePromotion: policy.requireApprovalBeforePromotion,
16870
17273
  rolloutLabel: policy.rolloutLabel,
@@ -16876,6 +17279,7 @@ var ragChat = (config) => {
16876
17279
  await persistReleaseLanePolicyHistoryRecord({
16877
17280
  approvalMaxAgeMs: policy.approvalMaxAgeMs,
16878
17281
  changeKind: "changed",
17282
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16879
17283
  groupKey,
16880
17284
  previousApprovalMaxAgeMs: latest.approvalMaxAgeMs,
16881
17285
  previousRequireApprovalBeforePromotion: latest.requireApprovalBeforePromotion,
@@ -16895,6 +17299,7 @@ var ragChat = (config) => {
16895
17299
  if (!latest) {
16896
17300
  await persistBaselineGatePolicyHistoryRecord({
16897
17301
  changeKind: "snapshot",
17302
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16898
17303
  groupKey,
16899
17304
  policy: policy.policy,
16900
17305
  rolloutLabel: policy.rolloutLabel,
@@ -16905,6 +17310,7 @@ var ragChat = (config) => {
16905
17310
  if (previousPolicy !== currentPolicy) {
16906
17311
  await persistBaselineGatePolicyHistoryRecord({
16907
17312
  changeKind: "changed",
17313
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16908
17314
  groupKey,
16909
17315
  policy: policy.policy,
16910
17316
  previousPolicy: latest.policy,
@@ -16959,6 +17365,7 @@ var ragChat = (config) => {
16959
17365
  await persistReleaseLaneEscalationPolicyHistoryRecord({
16960
17366
  approvalExpiredSeverity: policy.approvalExpiredSeverity,
16961
17367
  changeKind: "snapshot",
17368
+ corpusGroupKey: getComparisonCorpusGroupKey(policy.groupKey),
16962
17369
  gateFailureSeverity: policy.gateFailureSeverity,
16963
17370
  groupKey: policy.groupKey,
16964
17371
  openIncidentSeverity: policy.openIncidentSeverity,
@@ -16971,6 +17378,7 @@ var ragChat = (config) => {
16971
17378
  await persistReleaseLaneEscalationPolicyHistoryRecord({
16972
17379
  approvalExpiredSeverity: policy.approvalExpiredSeverity,
16973
17380
  changeKind: "changed",
17381
+ corpusGroupKey: getComparisonCorpusGroupKey(policy.groupKey),
16974
17382
  gateFailureSeverity: policy.gateFailureSeverity,
16975
17383
  groupKey: policy.groupKey,
16976
17384
  openIncidentSeverity: policy.openIncidentSeverity,
@@ -17025,6 +17433,7 @@ var ragChat = (config) => {
17025
17433
  const latestWinner = latestRetrievalComparisonRun.comparison.summary.bestByPassingRate;
17026
17434
  if (latestWinner && stableWinnerByPassingRate?.retrievalId && stableWinnerByPassingRate.retrievalId !== latestWinner) {
17027
17435
  alerts.push({
17436
+ corpusGroupKey: latestRetrievalComparisonRun.corpusGroupKey,
17028
17437
  groupKey: latestRetrievalComparisonRun.groupKey,
17029
17438
  kind: "stable_winner_changed",
17030
17439
  latestRunId: latestRetrievalComparisonRun.id,
@@ -17041,6 +17450,7 @@ var ragChat = (config) => {
17041
17450
  baselineRetrievalId: latestRetrievalComparisonRun.decisionSummary?.baselineRetrievalId,
17042
17451
  candidateRetrievalId: latestRetrievalComparisonRun.decisionSummary?.candidateRetrievalId,
17043
17452
  delta,
17453
+ corpusGroupKey: latestRetrievalComparisonRun.corpusGroupKey,
17044
17454
  groupKey: latestRetrievalComparisonRun.groupKey,
17045
17455
  kind: "baseline_regression",
17046
17456
  latestRunId: latestRetrievalComparisonRun.id,
@@ -17055,6 +17465,7 @@ var ragChat = (config) => {
17055
17465
  candidateRetrievalId: latestRetrievalComparisonRun.decisionSummary?.candidateRetrievalId,
17056
17466
  delta,
17057
17467
  gate,
17468
+ corpusGroupKey: latestRetrievalComparisonRun.corpusGroupKey,
17058
17469
  groupKey: latestRetrievalComparisonRun.groupKey,
17059
17470
  kind: "baseline_gate_failed",
17060
17471
  latestRunId: latestRetrievalComparisonRun.id,
@@ -17072,6 +17483,7 @@ var ragChat = (config) => {
17072
17483
  const kind = reasonSet.has("no active canary baseline exists for this group") ? "handoff_auto_complete_source_lane_missing" : reasonSet.has("latest approved handoff decision is older than the auto-complete policy allows") ? "handoff_auto_complete_stale_approval" : reasonSet.has("approved handoff decision is required before auto-complete") ? "handoff_auto_complete_approval_missing" : reasonText.includes("gate") || reasonText.includes("passing rate delta") || reasonText.includes("average") || reasonText.includes("candidate does not match") ? "handoff_auto_complete_gate_blocked" : "handoff_auto_complete_policy_drift";
17073
17484
  alerts.push({
17074
17485
  candidateRetrievalId: entry.candidateRetrievalId,
17486
+ corpusGroupKey: getComparisonCorpusGroupKey(entry.groupKey),
17075
17487
  groupKey: entry.groupKey,
17076
17488
  kind,
17077
17489
  latestRunId: entry.sourceRunId ?? latestRetrievalComparisonRun.id,
@@ -17182,6 +17594,7 @@ var ragChat = (config) => {
17182
17594
  latest: latestRetrievalComparisonRun ? {
17183
17595
  bestByAverageF1: latestRetrievalComparisonRun.comparison.summary.bestByAverageF1,
17184
17596
  bestByPassingRate: latestRetrievalComparisonRun.comparison.summary.bestByPassingRate,
17597
+ corpusGroupKey: latestRetrievalComparisonRun.corpusGroupKey,
17185
17598
  elapsedMs: latestRetrievalComparisonRun.elapsedMs,
17186
17599
  fastest: latestRetrievalComparisonRun.comparison.summary.fastest,
17187
17600
  finishedAt: latestRetrievalComparisonRun.finishedAt,
@@ -18053,7 +18466,7 @@ var ragChat = (config) => {
18053
18466
  }
18054
18467
  return result;
18055
18468
  }).get(`${path}/compare/retrieval/release-history`, async ({ query, request, set }) => {
18056
- const result = await handleRetrievalReleaseGroupHistory(query);
18469
+ const result = await handleRetrievalReleaseGroupHistory(query, request);
18057
18470
  if (!result.ok) {
18058
18471
  set.status = HTTP_STATUS_BAD_REQUEST;
18059
18472
  }
@@ -18068,7 +18481,7 @@ var ragChat = (config) => {
18068
18481
  }
18069
18482
  return result;
18070
18483
  }).get(`${path}/compare/retrieval/handoffs`, async ({ query, request, set }) => {
18071
- const result = await handleRetrievalLaneHandoffList(query);
18484
+ const result = await handleRetrievalLaneHandoffList(query, request);
18072
18485
  if (!result.ok) {
18073
18486
  set.status = HTTP_STATUS_BAD_REQUEST;
18074
18487
  }
@@ -18083,7 +18496,7 @@ var ragChat = (config) => {
18083
18496
  }
18084
18497
  return result;
18085
18498
  }).get(`${path}/compare/retrieval/handoffs/decisions`, async ({ query, request, set }) => {
18086
- const result = await handleRetrievalLaneHandoffDecisionList(query);
18499
+ const result = await handleRetrievalLaneHandoffDecisionList(query, request);
18087
18500
  if (!result.ok) {
18088
18501
  set.status = HTTP_STATUS_BAD_REQUEST;
18089
18502
  }
@@ -18098,7 +18511,7 @@ var ragChat = (config) => {
18098
18511
  }
18099
18512
  return result;
18100
18513
  }).get(`${path}/compare/retrieval/handoffs/incidents`, async ({ query, request, set }) => {
18101
- const result = await handleRetrievalLaneHandoffIncidentList(query);
18514
+ const result = await handleRetrievalLaneHandoffIncidentList(query, request);
18102
18515
  if (!result.ok) {
18103
18516
  set.status = HTTP_STATUS_BAD_REQUEST;
18104
18517
  }
@@ -18113,7 +18526,7 @@ var ragChat = (config) => {
18113
18526
  }
18114
18527
  return result;
18115
18528
  }).get(`${path}/compare/retrieval/handoffs/incidents/history`, async ({ query, request, set }) => {
18116
- const result = await handleRetrievalLaneHandoffIncidentHistoryList(query);
18529
+ const result = await handleRetrievalLaneHandoffIncidentHistoryList(query, request);
18117
18530
  if (!result.ok) {
18118
18531
  set.status = HTTP_STATUS_BAD_REQUEST;
18119
18532
  }
@@ -18650,7 +19063,7 @@ var ragChat = (config) => {
18650
19063
  }
18651
19064
  return result;
18652
19065
  }).get(`${path}/compare/retrieval/escalation-policies/history`, async ({ query, request, set }) => {
18653
- const result = await handleRetrievalReleaseLaneEscalationPolicyHistoryList(query);
19066
+ const result = await handleRetrievalReleaseLaneEscalationPolicyHistoryList(query, request);
18654
19067
  if (!result.ok) {
18655
19068
  set.status = HTTP_STATUS_BAD_REQUEST;
18656
19069
  }
@@ -18665,7 +19078,7 @@ var ragChat = (config) => {
18665
19078
  }
18666
19079
  return result;
18667
19080
  }).get(`${path}/compare/retrieval/incident-policies/history`, async ({ query, request, set }) => {
18668
- const result = await handleRetrievalReleaseLaneEscalationPolicyHistoryList(query);
19081
+ const result = await handleRetrievalReleaseLaneEscalationPolicyHistoryList(query, request);
18669
19082
  if (!result.ok) {
18670
19083
  set.status = HTTP_STATUS_BAD_REQUEST;
18671
19084
  }
@@ -23474,5 +23887,5 @@ export {
23474
23887
  aiChat
23475
23888
  };
23476
23889
 
23477
- //# debugId=01B4F90C8AC5AD4364756E2164756E21
23890
+ //# debugId=3A168E4E2E133AED64756E2164756E21
23478
23891
  //# sourceMappingURL=index.js.map