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

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
@@ -2995,16 +2995,32 @@ var loadRAGRetrievalComparisonHistory = async ({
2995
2995
  suiteId,
2996
2996
  label,
2997
2997
  winnerId,
2998
+ corpusGroupKey,
2998
2999
  groupKey,
2999
3000
  tag
3000
- }) => normalizeRetrievalComparisonRuns(await Promise.resolve(store.listRuns({ groupKey, label, limit, suiteId, tag, winnerId })));
3001
+ }) => normalizeRetrievalComparisonRuns(await Promise.resolve(store.listRuns({
3002
+ corpusGroupKey,
3003
+ groupKey,
3004
+ label,
3005
+ limit,
3006
+ suiteId,
3007
+ tag,
3008
+ winnerId
3009
+ })));
3001
3010
  var loadRAGRetrievalBaselines = async ({
3002
3011
  store,
3012
+ corpusGroupKey,
3003
3013
  groupKey,
3004
3014
  tag,
3005
3015
  limit,
3006
3016
  status
3007
- }) => normalizeRetrievalBaselineRecords(await Promise.resolve(store.listBaselines({ groupKey, limit, status, tag })));
3017
+ }) => normalizeRetrievalBaselineRecords(await Promise.resolve(store.listBaselines({
3018
+ corpusGroupKey,
3019
+ groupKey,
3020
+ limit,
3021
+ status,
3022
+ tag
3023
+ })));
3008
3024
  var persistRAGRetrievalBaseline = async ({
3009
3025
  store,
3010
3026
  record
@@ -3014,18 +3030,21 @@ var persistRAGRetrievalBaseline = async ({
3014
3030
  };
3015
3031
  var loadRAGRetrievalReleaseDecisions = async ({
3016
3032
  store,
3033
+ corpusGroupKey,
3017
3034
  groupKey,
3018
3035
  limit,
3019
3036
  kind
3020
- }) => normalizeRetrievalReleaseDecisionRecords(await Promise.resolve(store.listDecisions({ groupKey, kind, limit })));
3037
+ }) => normalizeRetrievalReleaseDecisionRecords(await Promise.resolve(store.listDecisions({ corpusGroupKey, groupKey, kind, limit })));
3021
3038
  var loadRAGRetrievalLaneHandoffDecisions = async ({
3022
3039
  store,
3040
+ corpusGroupKey,
3023
3041
  groupKey,
3024
3042
  limit,
3025
3043
  kind,
3026
3044
  sourceRolloutLabel,
3027
3045
  targetRolloutLabel
3028
3046
  }) => normalizeRetrievalLaneHandoffDecisionRecords(await Promise.resolve(store.listDecisions({
3047
+ corpusGroupKey,
3029
3048
  groupKey,
3030
3049
  kind,
3031
3050
  limit,
@@ -3048,12 +3067,14 @@ var loadRAGRetrievalReleaseIncidents = async ({
3048
3067
  })));
3049
3068
  var loadRAGRetrievalLaneHandoffIncidents = async ({
3050
3069
  store,
3070
+ corpusGroupKey,
3051
3071
  groupKey,
3052
3072
  limit,
3053
3073
  targetRolloutLabel,
3054
3074
  status,
3055
3075
  severity
3056
3076
  }) => normalizeRetrievalReleaseIncidentRecords(await Promise.resolve(store.listIncidents({
3077
+ corpusGroupKey,
3057
3078
  groupKey,
3058
3079
  limit,
3059
3080
  severity,
@@ -3062,12 +3083,14 @@ var loadRAGRetrievalLaneHandoffIncidents = async ({
3062
3083
  })));
3063
3084
  var loadRAGRetrievalLaneHandoffIncidentHistory = async ({
3064
3085
  store,
3086
+ corpusGroupKey,
3065
3087
  action,
3066
3088
  groupKey,
3067
3089
  incidentId,
3068
3090
  limit,
3069
3091
  targetRolloutLabel
3070
3092
  }) => await Promise.resolve(store.listRecords({
3093
+ corpusGroupKey,
3071
3094
  action,
3072
3095
  groupKey,
3073
3096
  incidentId,
@@ -3112,21 +3135,25 @@ var loadRAGRetrievalIncidentRemediationExecutionHistory = async ({
3112
3135
  })));
3113
3136
  var loadRAGRetrievalLaneHandoffAutoCompletePolicyHistory = async ({
3114
3137
  store,
3138
+ corpusGroupKey,
3115
3139
  groupKey,
3116
3140
  limit,
3117
3141
  targetRolloutLabel
3118
3142
  }) => await Promise.resolve(store.listRecords({
3143
+ corpusGroupKey,
3119
3144
  groupKey,
3120
3145
  limit,
3121
3146
  targetRolloutLabel
3122
3147
  }));
3123
3148
  var loadRAGRetrievalReleaseLanePolicyHistory = async ({
3124
3149
  store,
3150
+ corpusGroupKey,
3125
3151
  groupKey,
3126
3152
  limit,
3127
3153
  rolloutLabel,
3128
3154
  scope
3129
3155
  }) => await Promise.resolve(store.listRecords({
3156
+ corpusGroupKey,
3130
3157
  groupKey,
3131
3158
  limit,
3132
3159
  rolloutLabel,
@@ -3134,11 +3161,13 @@ var loadRAGRetrievalReleaseLanePolicyHistory = async ({
3134
3161
  }));
3135
3162
  var loadRAGRetrievalBaselineGatePolicyHistory = async ({
3136
3163
  store,
3164
+ corpusGroupKey,
3137
3165
  groupKey,
3138
3166
  limit,
3139
3167
  rolloutLabel,
3140
3168
  scope
3141
3169
  }) => await Promise.resolve(store.listRecords({
3170
+ corpusGroupKey,
3142
3171
  groupKey,
3143
3172
  limit,
3144
3173
  rolloutLabel,
@@ -3146,6 +3175,7 @@ var loadRAGRetrievalBaselineGatePolicyHistory = async ({
3146
3175
  }));
3147
3176
  var loadRAGRetrievalReleaseLaneEscalationPolicyHistory = async ({
3148
3177
  store,
3178
+ corpusGroupKey,
3149
3179
  groupKey,
3150
3180
  limit,
3151
3181
  targetRolloutLabel
@@ -12208,6 +12238,7 @@ var ragChat = (config) => {
12208
12238
  const requiredMetadata = scope.requiredMetadata && Object.keys(scope.requiredMetadata).length > 0 ? scope.requiredMetadata : undefined;
12209
12239
  return {
12210
12240
  allowedComparisonGroupKeys: normalizeStringArray3(scope.allowedComparisonGroupKeys),
12241
+ allowedCorpusGroupKeys: normalizeStringArray3(scope.allowedCorpusGroupKeys),
12211
12242
  allowedCorpusKeys: normalizeStringArray3(scope.allowedCorpusKeys),
12212
12243
  allowedDocumentIds: normalizeStringArray3(scope.allowedDocumentIds),
12213
12244
  allowedSourcePrefixes: normalizeStringArray3(scope.allowedSourcePrefixes),
@@ -12243,8 +12274,26 @@ var ragChat = (config) => {
12243
12274
  return matchesRequiredMetadata(scope.requiredMetadata, input.metadata);
12244
12275
  };
12245
12276
  const matchesSyncSourceScope = (scope, source) => !scope?.allowedSyncSourceIds?.length || scope.allowedSyncSourceIds.includes(source.id);
12277
+ const deriveCorpusGroupKey = (input) => {
12278
+ const explicitCorpusGroupKey = input.corpusGroupKey?.trim();
12279
+ if (explicitCorpusGroupKey) {
12280
+ return explicitCorpusGroupKey;
12281
+ }
12282
+ const normalizedCorpusKeys = [
12283
+ ...new Set((input.corpusKeys ?? []).map((value) => value.trim()).filter((value) => value.length > 0))
12284
+ ].sort((left, right) => left.localeCompare(right));
12285
+ if (normalizedCorpusKeys.length === 0) {
12286
+ return;
12287
+ }
12288
+ if (normalizedCorpusKeys.length === 1) {
12289
+ return normalizedCorpusKeys[0];
12290
+ }
12291
+ return normalizedCorpusKeys.join("+");
12292
+ };
12293
+ const isAllowedCorpusGroupKey = (scope, corpusGroupKey) => !scope?.allowedCorpusGroupKeys?.length || typeof corpusGroupKey === "string" && scope.allowedCorpusGroupKeys.includes(corpusGroupKey);
12246
12294
  const isAllowedComparisonGroupKey = (scope, groupKey) => !scope?.allowedComparisonGroupKeys?.length || typeof groupKey === "string" && scope.allowedComparisonGroupKeys.includes(groupKey);
12247
12295
  const filterByComparisonGroupKey = (scope, records) => scope?.allowedComparisonGroupKeys?.length ? records.filter((record) => isAllowedComparisonGroupKey(scope, record.groupKey)) : records;
12296
+ const filterByCorpusGroupKey = (scope, records) => scope?.allowedCorpusGroupKeys?.length ? records.filter((record) => isAllowedCorpusGroupKey(scope, record.corpusGroupKey)) : records;
12248
12297
  const persistJobStateIfConfigured = async () => {
12249
12298
  if (!jobStateStore) {
12250
12299
  return;
@@ -12755,6 +12804,7 @@ var ragChat = (config) => {
12755
12804
  ...input,
12756
12805
  baselineRetrievalId: getStringProperty(body, "baselineRetrievalId"),
12757
12806
  candidateRetrievalId: getStringProperty(body, "candidateRetrievalId"),
12807
+ corpusGroupKey: getStringProperty(body, "corpusGroupKey"),
12758
12808
  groupKey: getStringProperty(body, "groupKey"),
12759
12809
  label: getStringProperty(body, "label"),
12760
12810
  persistRun: getBooleanProperty(body, "persistRun") === true,
@@ -12772,6 +12822,7 @@ var ragChat = (config) => {
12772
12822
  return null;
12773
12823
  }
12774
12824
  return {
12825
+ corpusGroupKey: getStringProperty(body, "corpusGroupKey"),
12775
12826
  groupKey,
12776
12827
  approvedAt: getIntegerLikeProperty(body, "approvedAt"),
12777
12828
  approvedBy: getStringProperty(body, "approvedBy"),
@@ -12800,6 +12851,7 @@ var ragChat = (config) => {
12800
12851
  return null;
12801
12852
  }
12802
12853
  return {
12854
+ corpusGroupKey: getStringProperty(body, "corpusGroupKey"),
12803
12855
  groupKey,
12804
12856
  overrideGate: getBooleanProperty(body, "overrideGate") === true,
12805
12857
  overrideReason: getStringProperty(body, "overrideReason"),
@@ -12830,6 +12882,7 @@ var ragChat = (config) => {
12830
12882
  return null;
12831
12883
  }
12832
12884
  return {
12885
+ corpusGroupKey: getStringProperty(body, "corpusGroupKey"),
12833
12886
  groupKey,
12834
12887
  approvedAt: getIntegerLikeProperty(body, "approvedAt"),
12835
12888
  approvedBy: getStringProperty(body, "approvedBy"),
@@ -12876,6 +12929,7 @@ var ragChat = (config) => {
12876
12929
  }
12877
12930
  return {
12878
12931
  candidateRetrievalId: getStringProperty(body, "candidateRetrievalId"),
12932
+ corpusGroupKey: getStringProperty(body, "corpusGroupKey"),
12879
12933
  decidedAt: getIntegerLikeProperty(body, "decidedAt"),
12880
12934
  decidedBy: getStringProperty(body, "decidedBy"),
12881
12935
  executePromotion: getBooleanProperty(body, "executePromotion") === true,
@@ -13230,6 +13284,12 @@ var ragChat = (config) => {
13230
13284
  ok: false
13231
13285
  };
13232
13286
  }
13287
+ if (!isAllowedCorpusGroupKey(accessScope, input.corpusGroupKey)) {
13288
+ return {
13289
+ error: "Retrieval comparison corpus group is outside the allowed RAG access scope",
13290
+ ok: false
13291
+ };
13292
+ }
13233
13293
  for (const evaluationCase of input.cases) {
13234
13294
  if (evaluationCase.corpusKey && !matchesAccessScope(accessScope, {
13235
13295
  corpusKey: evaluationCase.corpusKey
@@ -13275,6 +13335,19 @@ var ragChat = (config) => {
13275
13335
  label: suiteLabel
13276
13336
  }
13277
13337
  });
13338
+ const corpusGroupKey = deriveCorpusGroupKey({
13339
+ corpusGroupKey: input.corpusGroupKey,
13340
+ corpusKeys: comparison.corpusKeys
13341
+ });
13342
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
13343
+ return {
13344
+ error: "Retrieval comparison corpus group is outside the allowed RAG access scope",
13345
+ ok: false
13346
+ };
13347
+ }
13348
+ if (corpusGroupKey) {
13349
+ comparison.corpusGroupKey = corpusGroupKey;
13350
+ }
13278
13351
  if (input.persistRun && retrievalComparisonHistoryStore) {
13279
13352
  const finishedAt = Date.now();
13280
13353
  const decisionSummary = buildRAGRetrievalComparisonDecisionSummary({
@@ -13286,6 +13359,7 @@ var ragChat = (config) => {
13286
13359
  await persistRAGRetrievalComparisonRun({
13287
13360
  run: {
13288
13361
  comparison,
13362
+ corpusGroupKey,
13289
13363
  corpusKeys: comparison.corpusKeys,
13290
13364
  decisionSummary,
13291
13365
  elapsedMs: finishedAt - startedAt,
@@ -13319,13 +13393,21 @@ var ragChat = (config) => {
13319
13393
  }
13320
13394
  const accessScope = await loadAccessScope(request);
13321
13395
  const groupKey = getStringProperty(queryInput, "groupKey");
13396
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
13322
13397
  if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
13323
13398
  return {
13324
13399
  error: "Retrieval comparison group is outside the allowed RAG access scope",
13325
13400
  ok: false
13326
13401
  };
13327
13402
  }
13403
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
13404
+ return {
13405
+ error: "Retrieval comparison corpus group is outside the allowed RAG access scope",
13406
+ ok: false
13407
+ };
13408
+ }
13328
13409
  const runs = await loadRAGRetrievalComparisonHistory({
13410
+ corpusGroupKey,
13329
13411
  groupKey,
13330
13412
  label: getStringProperty(queryInput, "label"),
13331
13413
  limit: getIntegerLikeProperty(queryInput, "limit"),
@@ -13336,7 +13418,7 @@ var ragChat = (config) => {
13336
13418
  });
13337
13419
  return {
13338
13420
  ok: true,
13339
- runs: filterByComparisonGroupKey(accessScope, runs)
13421
+ runs: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, runs))
13340
13422
  };
13341
13423
  };
13342
13424
  const handleRetrievalBaselineList = async (queryInput, request) => {
@@ -13348,13 +13430,21 @@ var ragChat = (config) => {
13348
13430
  }
13349
13431
  const accessScope = await loadAccessScope(request);
13350
13432
  const groupKey = getStringProperty(queryInput, "groupKey");
13433
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
13351
13434
  if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
13352
13435
  return {
13353
13436
  error: "Retrieval baseline group is outside the allowed RAG access scope",
13354
13437
  ok: false
13355
13438
  };
13356
13439
  }
13440
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
13441
+ return {
13442
+ error: "Retrieval baseline corpus group is outside the allowed RAG access scope",
13443
+ ok: false
13444
+ };
13445
+ }
13357
13446
  const baselines = await loadRAGRetrievalBaselines({
13447
+ corpusGroupKey,
13358
13448
  groupKey,
13359
13449
  limit: getIntegerLikeProperty(queryInput, "limit"),
13360
13450
  status: getStringProperty(queryInput, "status") === "active" || getStringProperty(queryInput, "status") === "superseded" ? getStringProperty(queryInput, "status") : undefined,
@@ -13362,7 +13452,7 @@ var ragChat = (config) => {
13362
13452
  tag: getStringProperty(queryInput, "tag")
13363
13453
  });
13364
13454
  return {
13365
- baselines: filterByComparisonGroupKey(accessScope, baselines),
13455
+ baselines: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, baselines)),
13366
13456
  ok: true
13367
13457
  };
13368
13458
  };
@@ -13373,6 +13463,7 @@ var ragChat = (config) => {
13373
13463
  await persistRAGRetrievalReleaseDecision({
13374
13464
  record: {
13375
13465
  baselineId: input.baseline?.id,
13466
+ corpusGroupKey: input.baseline?.corpusGroupKey ?? input.corpusGroupKey,
13376
13467
  decidedAt: input.baseline?.promotedAt ?? input.decidedAt ?? Date.now(),
13377
13468
  decidedBy: input.decidedBy,
13378
13469
  groupKey: input.baseline?.groupKey ?? input.groupKey,
@@ -13489,6 +13580,7 @@ var ragChat = (config) => {
13489
13580
  await persistRAGRetrievalLaneHandoffIncidentHistory({
13490
13581
  record: {
13491
13582
  action: input.action,
13583
+ corpusGroupKey: input.incident.corpusGroupKey,
13492
13584
  groupKey: input.incident.groupKey,
13493
13585
  id: generateId(),
13494
13586
  incidentId: input.incident.id,
@@ -13511,6 +13603,7 @@ var ragChat = (config) => {
13511
13603
  await persistRAGRetrievalLaneHandoffAutoCompletePolicyHistory({
13512
13604
  record: {
13513
13605
  changeKind: input.changeKind,
13606
+ corpusGroupKey: input.corpusGroupKey,
13514
13607
  enabled: input.enabled,
13515
13608
  groupKey: input.groupKey,
13516
13609
  id: generateId(),
@@ -13531,6 +13624,7 @@ var ragChat = (config) => {
13531
13624
  record: {
13532
13625
  approvalMaxAgeMs: input.approvalMaxAgeMs,
13533
13626
  changeKind: input.changeKind,
13627
+ corpusGroupKey: input.corpusGroupKey,
13534
13628
  groupKey: input.groupKey,
13535
13629
  id: generateId(),
13536
13630
  previousApprovalMaxAgeMs: input.previousApprovalMaxAgeMs,
@@ -13550,6 +13644,7 @@ var ragChat = (config) => {
13550
13644
  await persistRAGRetrievalBaselineGatePolicyHistory({
13551
13645
  record: {
13552
13646
  changeKind: input.changeKind,
13647
+ corpusGroupKey: input.corpusGroupKey,
13553
13648
  groupKey: input.groupKey,
13554
13649
  id: generateId(),
13555
13650
  policy: input.policy,
@@ -13569,6 +13664,7 @@ var ragChat = (config) => {
13569
13664
  record: {
13570
13665
  approvalExpiredSeverity: input.approvalExpiredSeverity,
13571
13666
  changeKind: input.changeKind,
13667
+ corpusGroupKey: input.corpusGroupKey,
13572
13668
  gateFailureSeverity: input.gateFailureSeverity,
13573
13669
  groupKey: input.groupKey,
13574
13670
  id: generateId(),
@@ -13657,6 +13753,7 @@ var ragChat = (config) => {
13657
13753
  const matchingHandoff = (input.handoffs ?? []).find((entry) => entry.groupKey === incident.groupKey && entry.targetRolloutLabel === incident.targetRolloutLabel);
13658
13754
  const laneIncident = {
13659
13755
  ...incident,
13756
+ corpusGroupKey: matchingHandoff?.corpusGroupKey,
13660
13757
  kind: "handoff_stale",
13661
13758
  sourceRolloutLabel: matchingHandoff?.sourceRolloutLabel
13662
13759
  };
@@ -14056,6 +14153,7 @@ var ragChat = (config) => {
14056
14153
  approvedAt: input.approvedAt,
14057
14154
  approvedBy: input.approvedBy,
14058
14155
  approvalNotes: input.approvalNotes,
14156
+ corpusGroupKey: input.corpusGroupKey,
14059
14157
  groupKey: input.groupKey,
14060
14158
  id: generateId(),
14061
14159
  label: input.label ?? input.retrievalId,
@@ -14089,6 +14187,19 @@ var ragChat = (config) => {
14089
14187
  ok: false
14090
14188
  };
14091
14189
  }
14190
+ const accessScope = await loadAccessScope(request);
14191
+ if (!isAllowedComparisonGroupKey(accessScope, input.groupKey)) {
14192
+ return {
14193
+ error: "Retrieval baseline group is outside the allowed RAG access scope",
14194
+ ok: false
14195
+ };
14196
+ }
14197
+ if (!isAllowedCorpusGroupKey(accessScope, input.corpusGroupKey)) {
14198
+ return {
14199
+ error: "Retrieval baseline corpus group is outside the allowed RAG access scope",
14200
+ ok: false
14201
+ };
14202
+ }
14092
14203
  const job = createAdminJob("promote_retrieval_baseline", input.groupKey);
14093
14204
  const action = createAdminAction("promote_retrieval_baseline", undefined, input.groupKey);
14094
14205
  try {
@@ -14131,6 +14242,7 @@ var ragChat = (config) => {
14131
14242
  approvedAt: input.approvedAt,
14132
14243
  approvedBy: input.approvedBy,
14133
14244
  approvalNotes: input.approvalNotes,
14245
+ corpusGroupKey: input.corpusGroupKey,
14134
14246
  groupKey: input.groupKey,
14135
14247
  label: input.label,
14136
14248
  metadata: input.metadata,
@@ -14144,6 +14256,7 @@ var ragChat = (config) => {
14144
14256
  });
14145
14257
  await persistRetrievalReleaseDecisionIfConfigured({
14146
14258
  baseline,
14259
+ corpusGroupKey: baseline.corpusGroupKey,
14147
14260
  decidedBy: input.approvedBy,
14148
14261
  kind: "promote",
14149
14262
  notes: input.approvalNotes,
@@ -14186,6 +14299,19 @@ var ragChat = (config) => {
14186
14299
  ok: false
14187
14300
  };
14188
14301
  }
14302
+ const accessScope = await loadAccessScope(request);
14303
+ if (!isAllowedComparisonGroupKey(accessScope, input.groupKey)) {
14304
+ return {
14305
+ error: "Retrieval baseline group is outside the allowed RAG access scope",
14306
+ ok: false
14307
+ };
14308
+ }
14309
+ if (!isAllowedCorpusGroupKey(accessScope, input.corpusGroupKey)) {
14310
+ return {
14311
+ error: "Retrieval baseline corpus group is outside the allowed RAG access scope",
14312
+ ok: false
14313
+ };
14314
+ }
14189
14315
  const job = createAdminJob("promote_retrieval_baseline", input.groupKey);
14190
14316
  const action = createAdminAction("promote_retrieval_baseline", undefined, input.groupKey);
14191
14317
  try {
@@ -14197,6 +14323,13 @@ var ragChat = (config) => {
14197
14323
  if (!sourceRun) {
14198
14324
  throw new Error("Retrieval comparison run was not found");
14199
14325
  }
14326
+ const corpusGroupKey = deriveCorpusGroupKey({
14327
+ corpusGroupKey: input.corpusGroupKey ?? sourceRun.corpusGroupKey ?? sourceRun.comparison.corpusGroupKey,
14328
+ corpusKeys: sourceRun.corpusKeys ?? sourceRun.comparison.corpusKeys
14329
+ });
14330
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14331
+ throw new Error("Retrieval baseline corpus group is outside the allowed RAG access scope");
14332
+ }
14200
14333
  const retrievalId = input.retrievalId ?? sourceRun.decisionSummary?.candidateRetrievalId ?? sourceRun.comparison.summary.bestByPassingRate ?? sourceRun.comparison.entries[0]?.retrievalId;
14201
14334
  if (!retrievalId) {
14202
14335
  throw new Error("Unable to resolve retrieval candidate from comparison run");
@@ -14228,6 +14361,7 @@ var ragChat = (config) => {
14228
14361
  approvedAt: input.approvedAt,
14229
14362
  approvedBy: input.approvedBy,
14230
14363
  approvalNotes: input.approvalNotes,
14364
+ corpusGroupKey,
14231
14365
  groupKey: input.groupKey,
14232
14366
  label: entry?.label ?? retrievalId,
14233
14367
  metadata: input.metadata,
@@ -14241,6 +14375,7 @@ var ragChat = (config) => {
14241
14375
  });
14242
14376
  await persistRetrievalReleaseDecisionIfConfigured({
14243
14377
  baseline,
14378
+ corpusGroupKey,
14244
14379
  decidedBy: input.approvedBy,
14245
14380
  gateStatus: gate?.status,
14246
14381
  kind: "promote",
@@ -14286,6 +14421,19 @@ var ragChat = (config) => {
14286
14421
  ok: false
14287
14422
  };
14288
14423
  }
14424
+ const accessScope = await loadAccessScope(request);
14425
+ if (!isAllowedComparisonGroupKey(accessScope, input.groupKey)) {
14426
+ return {
14427
+ error: "Retrieval baseline group is outside the allowed RAG access scope",
14428
+ ok: false
14429
+ };
14430
+ }
14431
+ if (!isAllowedCorpusGroupKey(accessScope, input.corpusGroupKey)) {
14432
+ return {
14433
+ error: "Retrieval baseline corpus group is outside the allowed RAG access scope",
14434
+ ok: false
14435
+ };
14436
+ }
14289
14437
  const job = createAdminJob("revert_retrieval_baseline", input.groupKey);
14290
14438
  const action = createAdminAction("revert_retrieval_baseline", undefined, input.groupKey);
14291
14439
  try {
@@ -14297,10 +14445,14 @@ var ragChat = (config) => {
14297
14445
  if (!targetBaseline) {
14298
14446
  throw new Error("Retrieval baseline version was not found");
14299
14447
  }
14448
+ if (!isAllowedCorpusGroupKey(accessScope, targetBaseline.corpusGroupKey)) {
14449
+ throw new Error("Retrieval baseline corpus group is outside the allowed RAG access scope");
14450
+ }
14300
14451
  const baseline = await promoteRetrievalBaselineRecord({
14301
14452
  approvedAt: input.approvedAt,
14302
14453
  approvedBy: input.approvedBy,
14303
14454
  approvalNotes: input.approvalNotes,
14455
+ corpusGroupKey: targetBaseline.corpusGroupKey,
14304
14456
  groupKey: input.groupKey,
14305
14457
  label: targetBaseline.label,
14306
14458
  metadata: {
@@ -14317,6 +14469,7 @@ var ragChat = (config) => {
14317
14469
  });
14318
14470
  await persistRetrievalReleaseDecisionIfConfigured({
14319
14471
  baseline,
14472
+ corpusGroupKey: baseline.corpusGroupKey,
14320
14473
  decidedBy: input.approvedBy,
14321
14474
  kind: "revert",
14322
14475
  notes: input.approvalNotes,
@@ -14356,23 +14509,31 @@ var ragChat = (config) => {
14356
14509
  }
14357
14510
  const accessScope = await loadAccessScope(request);
14358
14511
  const groupKey = getStringProperty(queryInput, "groupKey");
14512
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14359
14513
  if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14360
14514
  return {
14361
14515
  error: "Retrieval release decision group is outside the allowed RAG access scope",
14362
14516
  ok: false
14363
14517
  };
14364
14518
  }
14519
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14520
+ return {
14521
+ error: "Retrieval release decision corpus group is outside the allowed RAG access scope",
14522
+ ok: false
14523
+ };
14524
+ }
14365
14525
  const kind = getStringProperty(queryInput, "kind");
14366
14526
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14367
14527
  const freshnessStatusFilter = getStringProperty(queryInput, "freshnessStatus");
14368
14528
  const decisions = await loadRAGRetrievalReleaseDecisions({
14529
+ corpusGroupKey,
14369
14530
  groupKey,
14370
14531
  kind: kind === "approve" || kind === "promote" || kind === "reject" || kind === "revert" ? kind : undefined,
14371
14532
  limit: getIntegerLikeProperty(queryInput, "limit"),
14372
14533
  store: config.retrievalReleaseDecisionStore
14373
14534
  });
14374
14535
  return {
14375
- decisions: filterByComparisonGroupKey(accessScope, decisions).map((decision) => ({
14536
+ decisions: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, decisions)).map((decision) => ({
14376
14537
  ...decision,
14377
14538
  ...getDecisionFreshness({ record: decision })
14378
14539
  })).filter((decision) => {
@@ -14404,6 +14565,13 @@ var ragChat = (config) => {
14404
14565
  ok: false
14405
14566
  };
14406
14567
  }
14568
+ const accessScope = await loadAccessScope(request);
14569
+ if (!isAllowedComparisonGroupKey(accessScope, input.groupKey)) {
14570
+ return {
14571
+ error: "Retrieval release decision group is outside the allowed RAG access scope",
14572
+ ok: false
14573
+ };
14574
+ }
14407
14575
  const runs = await loadRAGRetrievalComparisonHistory({
14408
14576
  groupKey: input.groupKey,
14409
14577
  store: retrievalComparisonHistoryStore
@@ -14415,6 +14583,16 @@ var ragChat = (config) => {
14415
14583
  ok: false
14416
14584
  };
14417
14585
  }
14586
+ const corpusGroupKey = deriveCorpusGroupKey({
14587
+ corpusGroupKey: sourceRun.corpusGroupKey ?? sourceRun.comparison.corpusGroupKey,
14588
+ corpusKeys: sourceRun.corpusKeys ?? sourceRun.comparison.corpusKeys
14589
+ });
14590
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14591
+ return {
14592
+ error: "Retrieval release decision corpus group is outside the allowed RAG access scope",
14593
+ ok: false
14594
+ };
14595
+ }
14418
14596
  const retrievalId = input.retrievalId ?? sourceRun.decisionSummary?.candidateRetrievalId ?? sourceRun.comparison.summary.bestByPassingRate ?? sourceRun.comparison.entries[0]?.retrievalId;
14419
14597
  if (!retrievalId) {
14420
14598
  return {
@@ -14444,6 +14622,7 @@ var ragChat = (config) => {
14444
14622
  const decidedAt = Date.now();
14445
14623
  await persistRetrievalReleaseDecisionIfConfigured({
14446
14624
  baseline: undefined,
14625
+ corpusGroupKey,
14447
14626
  decidedAt: input.decidedAt,
14448
14627
  decidedBy: input.decidedBy,
14449
14628
  gateStatus: gate?.status,
@@ -14457,17 +14636,19 @@ var ragChat = (config) => {
14457
14636
  targetRolloutLabel: input.targetRolloutLabel
14458
14637
  });
14459
14638
  const decisions = await loadRAGRetrievalReleaseDecisions({
14639
+ corpusGroupKey,
14460
14640
  groupKey: input.groupKey,
14461
14641
  limit: 10,
14462
14642
  store: config.retrievalReleaseDecisionStore
14463
14643
  });
14464
14644
  return {
14465
- decisions,
14645
+ decisions: filterByCorpusGroupKey(accessScope, decisions),
14466
14646
  ok: true
14467
14647
  };
14468
14648
  };
14469
- const handleRetrievalReleaseGroupHistory = async (queryInput) => {
14649
+ const handleRetrievalReleaseGroupHistory = async (queryInput, request) => {
14470
14650
  const groupKey = getStringProperty(queryInput, "groupKey");
14651
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14471
14652
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14472
14653
  if (!groupKey) {
14473
14654
  return {
@@ -14475,7 +14656,21 @@ var ragChat = (config) => {
14475
14656
  ok: false
14476
14657
  };
14477
14658
  }
14659
+ const accessScope = await loadAccessScope(request);
14660
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14661
+ return {
14662
+ error: "Retrieval release decision group is outside the allowed RAG access scope",
14663
+ ok: false
14664
+ };
14665
+ }
14666
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14667
+ return {
14668
+ error: "Retrieval release corpus group is outside the allowed RAG access scope",
14669
+ ok: false
14670
+ };
14671
+ }
14478
14672
  const decisions = config.retrievalReleaseDecisionStore ? (await loadRAGRetrievalReleaseDecisions({
14673
+ corpusGroupKey,
14479
14674
  groupKey,
14480
14675
  limit: getIntegerLikeProperty(queryInput, "decisionLimit") ?? 20,
14481
14676
  store: config.retrievalReleaseDecisionStore
@@ -14484,11 +14679,13 @@ var ragChat = (config) => {
14484
14679
  ...getDecisionFreshness({ record: decision })
14485
14680
  })).filter((decision) => targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? decision.targetRolloutLabel === targetRolloutLabel : true) : undefined;
14486
14681
  const baselines = retrievalBaselineStore ? await loadRAGRetrievalBaselines({
14682
+ corpusGroupKey,
14487
14683
  groupKey,
14488
14684
  limit: getIntegerLikeProperty(queryInput, "baselineLimit") ?? 20,
14489
14685
  store: retrievalBaselineStore
14490
14686
  }).then((entries) => targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? entries.filter((entry) => entry.rolloutLabel === targetRolloutLabel) : entries) : undefined;
14491
14687
  const runs = retrievalComparisonHistoryStore ? await loadRAGRetrievalComparisonHistory({
14688
+ corpusGroupKey,
14492
14689
  groupKey,
14493
14690
  limit: getIntegerLikeProperty(queryInput, "runLimit") ?? 20,
14494
14691
  store: retrievalComparisonHistoryStore
@@ -14496,11 +14693,13 @@ var ragChat = (config) => {
14496
14693
  const latest = decisions?.[0];
14497
14694
  return {
14498
14695
  baselines,
14696
+ corpusGroupKey: corpusGroupKey ?? decisions?.[0]?.corpusGroupKey ?? baselines?.[0]?.corpusGroupKey ?? runs?.[0]?.corpusGroupKey,
14499
14697
  decisions,
14500
14698
  groupKey,
14501
14699
  ok: true,
14502
14700
  runs,
14503
14701
  timeline: {
14702
+ corpusGroupKey: corpusGroupKey ?? decisions?.[0]?.corpusGroupKey ?? baselines?.[0]?.corpusGroupKey ?? runs?.[0]?.corpusGroupKey,
14504
14703
  groupKey,
14505
14704
  lastApprovedAt: decisions?.find((entry) => entry.kind === "approve")?.decidedAt,
14506
14705
  lastPromotedAt: decisions?.find((entry) => entry.kind === "promote")?.decidedAt,
@@ -14512,29 +14711,53 @@ var ragChat = (config) => {
14512
14711
  }
14513
14712
  };
14514
14713
  };
14515
- const handleRetrievalLaneHandoffList = async (queryInput) => {
14714
+ const handleRetrievalLaneHandoffList = async (queryInput, request) => {
14516
14715
  const result = await buildOperationsPayload();
14716
+ const accessScope = await loadAccessScope(request);
14717
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14718
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14719
+ return {
14720
+ error: "Retrieval lane handoff corpus group is outside the allowed RAG access scope",
14721
+ ok: false
14722
+ };
14723
+ }
14517
14724
  const sourceRolloutLabel = getStringProperty(queryInput, "sourceRolloutLabel");
14518
14725
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14519
14726
  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));
14727
+ 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
14728
  return {
14522
14729
  handoffs: typeof limit === "number" ? handoffs.slice(0, limit) : handoffs,
14523
14730
  ok: true
14524
14731
  };
14525
14732
  };
14526
- const handleRetrievalLaneHandoffDecisionList = async (queryInput) => {
14733
+ const handleRetrievalLaneHandoffDecisionList = async (queryInput, request) => {
14527
14734
  if (!config.retrievalLaneHandoffDecisionStore) {
14528
14735
  return {
14529
14736
  error: "RAG retrieval lane handoff decision store is not configured",
14530
14737
  ok: false
14531
14738
  };
14532
14739
  }
14740
+ const accessScope = await loadAccessScope(request);
14741
+ const groupKey = getStringProperty(queryInput, "groupKey");
14742
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14743
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14744
+ return {
14745
+ error: "Retrieval lane handoff decision group is outside the allowed RAG access scope",
14746
+ ok: false
14747
+ };
14748
+ }
14749
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14750
+ return {
14751
+ error: "Retrieval lane handoff decision corpus group is outside the allowed RAG access scope",
14752
+ ok: false
14753
+ };
14754
+ }
14533
14755
  const sourceRolloutLabel = getStringProperty(queryInput, "sourceRolloutLabel");
14534
14756
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14535
14757
  const kind = getStringProperty(queryInput, "kind");
14536
14758
  const decisions = await loadRAGRetrievalLaneHandoffDecisions({
14537
- groupKey: getStringProperty(queryInput, "groupKey"),
14759
+ corpusGroupKey,
14760
+ groupKey,
14538
14761
  kind: kind === "approve" || kind === "reject" || kind === "complete" ? kind : undefined,
14539
14762
  limit: getIntegerLikeProperty(queryInput, "limit"),
14540
14763
  sourceRolloutLabel: sourceRolloutLabel === "canary" || sourceRolloutLabel === "stable" || sourceRolloutLabel === "rollback_target" ? sourceRolloutLabel : undefined,
@@ -14542,116 +14765,230 @@ var ragChat = (config) => {
14542
14765
  targetRolloutLabel: targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? targetRolloutLabel : undefined
14543
14766
  });
14544
14767
  return {
14545
- decisions,
14768
+ decisions: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, decisions)),
14546
14769
  ok: true
14547
14770
  };
14548
14771
  };
14549
- const handleRetrievalLaneHandoffIncidentList = async (queryInput) => {
14772
+ const handleRetrievalLaneHandoffIncidentList = async (queryInput, request) => {
14550
14773
  if (!config.retrievalLaneHandoffIncidentStore) {
14551
14774
  return {
14552
14775
  error: "RAG retrieval lane handoff incident store is not configured",
14553
14776
  ok: false
14554
14777
  };
14555
14778
  }
14779
+ const accessScope = await loadAccessScope(request);
14780
+ const groupKey = getStringProperty(queryInput, "groupKey");
14781
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14782
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14783
+ return {
14784
+ error: "Retrieval lane handoff incident group is outside the allowed RAG access scope",
14785
+ ok: false
14786
+ };
14787
+ }
14788
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14789
+ return {
14790
+ error: "Retrieval lane handoff incident corpus group is outside the allowed RAG access scope",
14791
+ ok: false
14792
+ };
14793
+ }
14556
14794
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14557
14795
  const status = getStringProperty(queryInput, "status");
14558
14796
  const severity = getStringProperty(queryInput, "severity");
14559
14797
  const incidents = await loadRAGRetrievalLaneHandoffIncidents({
14560
- groupKey: getStringProperty(queryInput, "groupKey"),
14798
+ corpusGroupKey,
14799
+ groupKey,
14561
14800
  limit: getIntegerLikeProperty(queryInput, "limit"),
14562
14801
  severity: severity === "warning" || severity === "critical" ? severity : undefined,
14563
14802
  status: status === "open" || status === "resolved" ? status : undefined,
14564
14803
  store: config.retrievalLaneHandoffIncidentStore,
14565
14804
  targetRolloutLabel: targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? targetRolloutLabel : undefined
14566
14805
  });
14567
- return { incidents, ok: true };
14806
+ return {
14807
+ incidents: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, incidents)),
14808
+ ok: true
14809
+ };
14568
14810
  };
14569
- const handleRetrievalLaneHandoffIncidentHistoryList = async (queryInput) => {
14811
+ const handleRetrievalLaneHandoffIncidentHistoryList = async (queryInput, request) => {
14570
14812
  if (!config.retrievalLaneHandoffIncidentHistoryStore) {
14571
14813
  return {
14572
14814
  error: "RAG retrieval lane handoff incident history store is not configured",
14573
14815
  ok: false
14574
14816
  };
14575
14817
  }
14818
+ const accessScope = await loadAccessScope(request);
14819
+ const groupKey = getStringProperty(queryInput, "groupKey");
14820
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14821
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14822
+ return {
14823
+ error: "Retrieval lane handoff incident history group is outside the allowed RAG access scope",
14824
+ ok: false
14825
+ };
14826
+ }
14827
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14828
+ return {
14829
+ error: "Retrieval lane handoff incident history corpus group is outside the allowed RAG access scope",
14830
+ ok: false
14831
+ };
14832
+ }
14576
14833
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14577
14834
  const action = getStringProperty(queryInput, "action");
14578
14835
  const records = await loadRAGRetrievalLaneHandoffIncidentHistory({
14836
+ corpusGroupKey,
14579
14837
  action: action === "opened" || action === "acknowledged" || action === "unacknowledged" || action === "resolved" ? action : undefined,
14580
- groupKey: getStringProperty(queryInput, "groupKey"),
14838
+ groupKey,
14581
14839
  incidentId: getStringProperty(queryInput, "incidentId"),
14582
14840
  limit: getIntegerLikeProperty(queryInput, "limit"),
14583
14841
  store: config.retrievalLaneHandoffIncidentHistoryStore,
14584
14842
  targetRolloutLabel: targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? targetRolloutLabel : undefined
14585
14843
  });
14586
- return { ok: true, records };
14844
+ return {
14845
+ ok: true,
14846
+ records: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, records))
14847
+ };
14587
14848
  };
14588
- const handleRetrievalLaneHandoffAutoCompletePolicyHistoryList = async (queryInput) => {
14849
+ const handleRetrievalLaneHandoffAutoCompletePolicyHistoryList = async (queryInput, request) => {
14589
14850
  if (!config.retrievalLaneHandoffAutoCompletePolicyHistoryStore) {
14590
14851
  return {
14591
14852
  error: "RAG retrieval lane handoff auto-complete policy history store is not configured",
14592
14853
  ok: false
14593
14854
  };
14594
14855
  }
14856
+ const accessScope = await loadAccessScope(request);
14857
+ const groupKey = getStringProperty(queryInput, "groupKey");
14858
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14859
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14860
+ return {
14861
+ error: "Retrieval lane handoff auto-complete policy group is outside the allowed RAG access scope",
14862
+ ok: false
14863
+ };
14864
+ }
14865
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14866
+ return {
14867
+ error: "Retrieval lane handoff auto-complete policy corpus group is outside the allowed RAG access scope",
14868
+ ok: false
14869
+ };
14870
+ }
14595
14871
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14596
14872
  const records = await loadRAGRetrievalLaneHandoffAutoCompletePolicyHistory({
14597
- groupKey: getStringProperty(queryInput, "groupKey"),
14873
+ corpusGroupKey,
14874
+ groupKey,
14598
14875
  limit: getIntegerLikeProperty(queryInput, "limit"),
14599
14876
  store: config.retrievalLaneHandoffAutoCompletePolicyHistoryStore,
14600
14877
  targetRolloutLabel: targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? targetRolloutLabel : undefined
14601
14878
  });
14602
- return { ok: true, records };
14879
+ return {
14880
+ ok: true,
14881
+ records: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, records))
14882
+ };
14603
14883
  };
14604
- const handleRetrievalReleaseLanePolicyHistoryList = async (queryInput) => {
14884
+ const handleRetrievalReleaseLanePolicyHistoryList = async (queryInput, request) => {
14605
14885
  if (!config.retrievalReleaseLanePolicyHistoryStore) {
14606
14886
  return {
14607
14887
  error: "RAG retrieval release lane policy history store is not configured",
14608
14888
  ok: false
14609
14889
  };
14610
14890
  }
14891
+ const accessScope = await loadAccessScope(request);
14892
+ const groupKey = getStringProperty(queryInput, "groupKey");
14893
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14894
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14895
+ return {
14896
+ error: "Retrieval release lane policy group is outside the allowed RAG access scope",
14897
+ ok: false
14898
+ };
14899
+ }
14900
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14901
+ return {
14902
+ error: "Retrieval release lane policy corpus group is outside the allowed RAG access scope",
14903
+ ok: false
14904
+ };
14905
+ }
14611
14906
  const rolloutLabel = getStringProperty(queryInput, "rolloutLabel");
14612
14907
  const scope = getStringProperty(queryInput, "scope");
14613
14908
  const records = await loadRAGRetrievalReleaseLanePolicyHistory({
14614
- groupKey: getStringProperty(queryInput, "groupKey"),
14909
+ corpusGroupKey,
14910
+ groupKey,
14615
14911
  limit: getIntegerLikeProperty(queryInput, "limit"),
14616
14912
  rolloutLabel: rolloutLabel === "canary" || rolloutLabel === "stable" || rolloutLabel === "rollback_target" ? rolloutLabel : undefined,
14617
14913
  scope: scope === "rollout_label" || scope === "group_rollout_label" ? scope : undefined,
14618
14914
  store: config.retrievalReleaseLanePolicyHistoryStore
14619
14915
  });
14620
- return { ok: true, records };
14916
+ return {
14917
+ ok: true,
14918
+ records: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, records))
14919
+ };
14621
14920
  };
14622
- const handleRetrievalBaselineGatePolicyHistoryList = async (queryInput) => {
14921
+ const handleRetrievalBaselineGatePolicyHistoryList = async (queryInput, request) => {
14623
14922
  if (!config.retrievalBaselineGatePolicyHistoryStore) {
14624
14923
  return {
14625
14924
  error: "RAG retrieval baseline gate policy history store is not configured",
14626
14925
  ok: false
14627
14926
  };
14628
14927
  }
14928
+ const accessScope = await loadAccessScope(request);
14929
+ const groupKey = getStringProperty(queryInput, "groupKey");
14930
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14931
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14932
+ return {
14933
+ error: "Retrieval baseline gate policy group is outside the allowed RAG access scope",
14934
+ ok: false
14935
+ };
14936
+ }
14937
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14938
+ return {
14939
+ error: "Retrieval baseline gate policy corpus group is outside the allowed RAG access scope",
14940
+ ok: false
14941
+ };
14942
+ }
14629
14943
  const rolloutLabel = getStringProperty(queryInput, "rolloutLabel");
14630
14944
  const scope = getStringProperty(queryInput, "scope");
14631
14945
  const records = await loadRAGRetrievalBaselineGatePolicyHistory({
14632
- groupKey: getStringProperty(queryInput, "groupKey"),
14946
+ corpusGroupKey,
14947
+ groupKey,
14633
14948
  limit: getIntegerLikeProperty(queryInput, "limit"),
14634
14949
  rolloutLabel: rolloutLabel === "canary" || rolloutLabel === "stable" || rolloutLabel === "rollback_target" ? rolloutLabel : undefined,
14635
14950
  scope: scope === "rollout_label" || scope === "group_rollout_label" ? scope : undefined,
14636
14951
  store: config.retrievalBaselineGatePolicyHistoryStore
14637
14952
  });
14638
- return { ok: true, records };
14953
+ return {
14954
+ ok: true,
14955
+ records: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, records))
14956
+ };
14639
14957
  };
14640
- const handleRetrievalReleaseLaneEscalationPolicyHistoryList = async (queryInput) => {
14958
+ const handleRetrievalReleaseLaneEscalationPolicyHistoryList = async (queryInput, request) => {
14641
14959
  if (!config.retrievalReleaseLaneEscalationPolicyHistoryStore) {
14642
14960
  return {
14643
14961
  error: "RAG retrieval release lane escalation policy history store is not configured",
14644
14962
  ok: false
14645
14963
  };
14646
14964
  }
14965
+ const accessScope = await loadAccessScope(request);
14966
+ const groupKey = getStringProperty(queryInput, "groupKey");
14967
+ const corpusGroupKey = getStringProperty(queryInput, "corpusGroupKey");
14968
+ if (!isAllowedComparisonGroupKey(accessScope, groupKey)) {
14969
+ return {
14970
+ error: "Retrieval release lane escalation policy group is outside the allowed RAG access scope",
14971
+ ok: false
14972
+ };
14973
+ }
14974
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
14975
+ return {
14976
+ error: "Retrieval release lane escalation policy corpus group is outside the allowed RAG access scope",
14977
+ ok: false
14978
+ };
14979
+ }
14647
14980
  const targetRolloutLabel = getStringProperty(queryInput, "targetRolloutLabel");
14648
14981
  const records = await loadRAGRetrievalReleaseLaneEscalationPolicyHistory({
14649
- groupKey: getStringProperty(queryInput, "groupKey"),
14982
+ corpusGroupKey,
14983
+ groupKey,
14650
14984
  limit: getIntegerLikeProperty(queryInput, "limit"),
14651
14985
  store: config.retrievalReleaseLaneEscalationPolicyHistoryStore,
14652
14986
  targetRolloutLabel: targetRolloutLabel === "canary" || targetRolloutLabel === "stable" || targetRolloutLabel === "rollback_target" ? targetRolloutLabel : undefined
14653
14987
  });
14654
- return { ok: true, records };
14988
+ return {
14989
+ ok: true,
14990
+ records: filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, records))
14991
+ };
14655
14992
  };
14656
14993
  const handleRetrievalLaneHandoffDecision = async (body) => {
14657
14994
  if (!config.retrievalLaneHandoffDecisionStore) {
@@ -14667,6 +15004,19 @@ var ragChat = (config) => {
14667
15004
  ok: false
14668
15005
  };
14669
15006
  }
15007
+ const accessScope = await loadAccessScope();
15008
+ if (!isAllowedComparisonGroupKey(accessScope, input.groupKey)) {
15009
+ return {
15010
+ error: "Retrieval lane handoff group is outside the allowed RAG access scope",
15011
+ ok: false
15012
+ };
15013
+ }
15014
+ if (!isAllowedCorpusGroupKey(accessScope, input.corpusGroupKey)) {
15015
+ return {
15016
+ error: "Retrieval lane handoff corpus group is outside the allowed RAG access scope",
15017
+ ok: false
15018
+ };
15019
+ }
14670
15020
  const ops = await buildOperationsPayload();
14671
15021
  const handoff = ops.retrievalComparisons?.releaseLaneHandoffs?.find((entry) => entry.groupKey === input.groupKey && entry.sourceRolloutLabel === input.sourceRolloutLabel && entry.targetRolloutLabel === input.targetRolloutLabel);
14672
15022
  if (!handoff) {
@@ -14675,6 +15025,13 @@ var ragChat = (config) => {
14675
15025
  ok: false
14676
15026
  };
14677
15027
  }
15028
+ const corpusGroupKey = input.corpusGroupKey ?? handoff.corpusGroupKey;
15029
+ if (!isAllowedCorpusGroupKey(accessScope, corpusGroupKey)) {
15030
+ return {
15031
+ error: "Retrieval lane handoff corpus group is outside the allowed RAG access scope",
15032
+ ok: false
15033
+ };
15034
+ }
14678
15035
  if (input.kind === "approve" && handoff.readyForHandoff !== true) {
14679
15036
  return {
14680
15037
  error: `handoff is not ready: ${handoff.reasons.join("; ")}`,
@@ -14699,6 +15056,7 @@ var ragChat = (config) => {
14699
15056
  approvalNotes: input.notes,
14700
15057
  approvedAt: input.decidedAt,
14701
15058
  approvedBy: input.decidedBy,
15059
+ corpusGroupKey,
14702
15060
  groupKey: input.groupKey,
14703
15061
  retrievalId: input.candidateRetrievalId ?? handoff.candidateRetrievalId,
14704
15062
  rolloutLabel: input.targetRolloutLabel,
@@ -14714,6 +15072,7 @@ var ragChat = (config) => {
14714
15072
  const decision = await persistRAGRetrievalLaneHandoffDecision({
14715
15073
  record: {
14716
15074
  candidateRetrievalId: input.candidateRetrievalId ?? handoff.candidateRetrievalId,
15075
+ corpusGroupKey,
14717
15076
  decidedAt: input.decidedAt ?? Date.now(),
14718
15077
  decidedBy: input.decidedBy,
14719
15078
  groupKey: input.groupKey,
@@ -14741,6 +15100,7 @@ var ragChat = (config) => {
14741
15100
  approvalNotes: input.notes,
14742
15101
  approvedAt,
14743
15102
  approvedBy: input.decidedBy,
15103
+ corpusGroupKey,
14744
15104
  groupKey: input.groupKey,
14745
15105
  retrievalId: input.candidateRetrievalId ?? handoff.candidateRetrievalId,
14746
15106
  rolloutLabel: input.targetRolloutLabel,
@@ -14755,6 +15115,7 @@ var ragChat = (config) => {
14755
15115
  await persistRAGRetrievalLaneHandoffDecision({
14756
15116
  record: {
14757
15117
  candidateRetrievalId: input.candidateRetrievalId ?? handoff.candidateRetrievalId,
15118
+ corpusGroupKey,
14758
15119
  decidedAt: Date.now(),
14759
15120
  decidedBy: input.decidedBy,
14760
15121
  groupKey: input.groupKey,
@@ -16166,6 +16527,7 @@ var ragChat = (config) => {
16166
16527
  });
16167
16528
  const buildOperationsPayload = async (request) => {
16168
16529
  const accessScope = await loadAccessScope(request);
16530
+ const filterScopedGovernanceEntries = (entries) => entries ? filterByCorpusGroupKey(accessScope, filterByComparisonGroupKey(accessScope, entries)) : undefined;
16169
16531
  const collection = config.collection ?? (ragStore ? createRAGCollection({
16170
16532
  defaultModel: config.embeddingModel,
16171
16533
  defaultTopK: topK,
@@ -16185,51 +16547,51 @@ var ragChat = (config) => {
16185
16547
  limit: 5,
16186
16548
  store: searchTracePruneHistoryStore
16187
16549
  }) : undefined;
16188
- const recentRetrievalComparisonRuns = retrievalComparisonHistoryStore ? await loadRAGRetrievalComparisonHistory({
16550
+ const recentRetrievalComparisonRuns = filterScopedGovernanceEntries(retrievalComparisonHistoryStore ? await loadRAGRetrievalComparisonHistory({
16189
16551
  limit: 5,
16190
16552
  store: retrievalComparisonHistoryStore
16191
- }) : undefined;
16192
- const activeRetrievalBaselines = retrievalBaselineStore ? await loadRAGRetrievalBaselines({
16553
+ }) : undefined);
16554
+ const activeRetrievalBaselines = filterScopedGovernanceEntries(retrievalBaselineStore ? await loadRAGRetrievalBaselines({
16193
16555
  limit: 5,
16194
16556
  status: "active",
16195
16557
  store: retrievalBaselineStore
16196
- }) : undefined;
16197
- const retrievalBaselineHistory = retrievalBaselineStore ? await loadRAGRetrievalBaselines({
16558
+ }) : undefined);
16559
+ const retrievalBaselineHistory = filterScopedGovernanceEntries(retrievalBaselineStore ? await loadRAGRetrievalBaselines({
16198
16560
  limit: 10,
16199
16561
  store: retrievalBaselineStore
16200
- }) : undefined;
16201
- const recentRetrievalReleaseDecisions = config.retrievalReleaseDecisionStore ? await loadRAGRetrievalReleaseDecisions({
16562
+ }) : undefined);
16563
+ const recentRetrievalReleaseDecisions = filterScopedGovernanceEntries(config.retrievalReleaseDecisionStore ? await loadRAGRetrievalReleaseDecisions({
16202
16564
  limit: 10,
16203
16565
  store: config.retrievalReleaseDecisionStore
16204
- }) : undefined;
16205
- const recentRetrievalLaneHandoffDecisions = config.retrievalLaneHandoffDecisionStore ? await loadRAGRetrievalLaneHandoffDecisions({
16566
+ }) : undefined);
16567
+ const recentRetrievalLaneHandoffDecisions = filterScopedGovernanceEntries(config.retrievalLaneHandoffDecisionStore ? await loadRAGRetrievalLaneHandoffDecisions({
16206
16568
  limit: 10,
16207
16569
  store: config.retrievalLaneHandoffDecisionStore
16208
- }) : undefined;
16209
- const recentRetrievalLaneHandoffIncidents = config.retrievalLaneHandoffIncidentStore ? await loadRAGRetrievalLaneHandoffIncidents({
16570
+ }) : undefined);
16571
+ const recentRetrievalLaneHandoffIncidents = filterScopedGovernanceEntries(config.retrievalLaneHandoffIncidentStore ? await loadRAGRetrievalLaneHandoffIncidents({
16210
16572
  limit: 10,
16211
16573
  store: config.retrievalLaneHandoffIncidentStore
16212
- }) : undefined;
16213
- const recentRetrievalLaneHandoffIncidentHistory = config.retrievalLaneHandoffIncidentHistoryStore ? await loadRAGRetrievalLaneHandoffIncidentHistory({
16574
+ }) : undefined);
16575
+ const recentRetrievalLaneHandoffIncidentHistory = filterScopedGovernanceEntries(config.retrievalLaneHandoffIncidentHistoryStore ? await loadRAGRetrievalLaneHandoffIncidentHistory({
16214
16576
  limit: 10,
16215
16577
  store: config.retrievalLaneHandoffIncidentHistoryStore
16216
- }) : undefined;
16217
- const recentHandoffAutoCompletePolicyHistory = config.retrievalLaneHandoffAutoCompletePolicyHistoryStore ? await loadRAGRetrievalLaneHandoffAutoCompletePolicyHistory({
16578
+ }) : undefined);
16579
+ const recentHandoffAutoCompletePolicyHistory = filterScopedGovernanceEntries(config.retrievalLaneHandoffAutoCompletePolicyHistoryStore ? await loadRAGRetrievalLaneHandoffAutoCompletePolicyHistory({
16218
16580
  limit: 10,
16219
16581
  store: config.retrievalLaneHandoffAutoCompletePolicyHistoryStore
16220
- }) : undefined;
16221
- const recentReleaseLanePolicyHistory = config.retrievalReleaseLanePolicyHistoryStore ? await loadRAGRetrievalReleaseLanePolicyHistory({
16582
+ }) : undefined);
16583
+ const recentReleaseLanePolicyHistory = filterScopedGovernanceEntries(config.retrievalReleaseLanePolicyHistoryStore ? await loadRAGRetrievalReleaseLanePolicyHistory({
16222
16584
  limit: 10,
16223
16585
  store: config.retrievalReleaseLanePolicyHistoryStore
16224
- }) : undefined;
16225
- const recentBaselineGatePolicyHistory = config.retrievalBaselineGatePolicyHistoryStore ? await loadRAGRetrievalBaselineGatePolicyHistory({
16586
+ }) : undefined);
16587
+ const recentBaselineGatePolicyHistory = filterScopedGovernanceEntries(config.retrievalBaselineGatePolicyHistoryStore ? await loadRAGRetrievalBaselineGatePolicyHistory({
16226
16588
  limit: 10,
16227
16589
  store: config.retrievalBaselineGatePolicyHistoryStore
16228
- }) : undefined;
16229
- const recentReleaseLaneEscalationPolicyHistory = config.retrievalReleaseLaneEscalationPolicyHistoryStore ? await loadRAGRetrievalReleaseLaneEscalationPolicyHistory({
16590
+ }) : undefined);
16591
+ const recentReleaseLaneEscalationPolicyHistory = filterScopedGovernanceEntries(config.retrievalReleaseLaneEscalationPolicyHistoryStore ? await loadRAGRetrievalReleaseLaneEscalationPolicyHistory({
16230
16592
  limit: 10,
16231
16593
  store: config.retrievalReleaseLaneEscalationPolicyHistoryStore
16232
- }) : undefined;
16594
+ }) : undefined);
16233
16595
  const recentIncidentRemediationDecisions = config.retrievalIncidentRemediationDecisionStore ? await loadRAGRetrievalIncidentRemediationDecisions({
16234
16596
  limit: 10,
16235
16597
  store: config.retrievalIncidentRemediationDecisionStore
@@ -16294,6 +16656,12 @@ var ragChat = (config) => {
16294
16656
  targetRolloutLabel
16295
16657
  };
16296
16658
  }) : undefined;
16659
+ const getComparisonCorpusGroupKey = (groupKey) => {
16660
+ if (!groupKey) {
16661
+ return;
16662
+ }
16663
+ 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;
16664
+ };
16297
16665
  const baseReleaseGroups = (() => {
16298
16666
  const groups = new Set;
16299
16667
  for (const run of recentRetrievalComparisonRuns ?? []) {
@@ -16355,6 +16723,7 @@ var ragChat = (config) => {
16355
16723
  approvalMaxAgeMs: getRetrievalReleasePolicy(groupKey).approvalMaxAgeMs,
16356
16724
  approvalRequired: getRetrievalReleasePolicy(groupKey).requireApprovalBeforePromotion === true,
16357
16725
  blockedReasons,
16726
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16358
16727
  escalationSeverity,
16359
16728
  groupKey,
16360
16729
  latestDecisionAt: latestDecision?.decidedAt,
@@ -16404,6 +16773,7 @@ var ragChat = (config) => {
16404
16773
  const groupDecisions = (enrichedRecentRetrievalReleaseDecisions ?? []).filter((entry) => entry.groupKey === groupKey);
16405
16774
  const latest = groupDecisions[0];
16406
16775
  return {
16776
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16407
16777
  groupKey,
16408
16778
  lastApprovedAt: groupDecisions.find((entry) => entry.kind === "approve")?.decidedAt,
16409
16779
  lastPromotedAt: groupDecisions.find((entry) => entry.kind === "promote")?.decidedAt,
@@ -16435,6 +16805,7 @@ var ragChat = (config) => {
16435
16805
  const laneDecisions = (enrichedRecentRetrievalReleaseDecisions ?? []).filter((entry) => entry.groupKey === groupKey && (entry.targetRolloutLabel ?? undefined) === targetRolloutLabel);
16436
16806
  const latest = laneDecisions[0];
16437
16807
  summaries.push({
16808
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16438
16809
  groupKey,
16439
16810
  lastApprovedAt: laneDecisions.find((entry) => entry.kind === "approve")?.decidedAt,
16440
16811
  lastPromotedAt: laneDecisions.find((entry) => entry.kind === "promote")?.decidedAt,
@@ -16470,6 +16841,7 @@ var ragChat = (config) => {
16470
16841
  const latest = laneDecisions[0];
16471
16842
  summaries.push({
16472
16843
  approvalCount: laneDecisions.filter((entry) => entry.kind === "approve").length,
16844
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16473
16845
  decisionCount: laneDecisions.length,
16474
16846
  groupKey,
16475
16847
  latestDecisionAt: latest?.decidedAt,
@@ -16763,6 +17135,7 @@ var ragChat = (config) => {
16763
17135
  if (!latest) {
16764
17136
  await persistLaneHandoffAutoCompletePolicyHistoryRecord({
16765
17137
  changeKind: "snapshot",
17138
+ corpusGroupKey: getComparisonCorpusGroupKey(policy.groupKey),
16766
17139
  enabled: policy.enabled,
16767
17140
  groupKey: policy.groupKey,
16768
17141
  maxApprovedDecisionAgeMs: policy.maxApprovedDecisionAgeMs,
@@ -16773,6 +17146,7 @@ var ragChat = (config) => {
16773
17146
  if (latest.enabled !== policy.enabled || latest.maxApprovedDecisionAgeMs !== policy.maxApprovedDecisionAgeMs) {
16774
17147
  await persistLaneHandoffAutoCompletePolicyHistoryRecord({
16775
17148
  changeKind: "changed",
17149
+ corpusGroupKey: getComparisonCorpusGroupKey(policy.groupKey),
16776
17150
  enabled: policy.enabled,
16777
17151
  groupKey: policy.groupKey,
16778
17152
  maxApprovedDecisionAgeMs: policy.maxApprovedDecisionAgeMs,
@@ -16810,6 +17184,7 @@ var ragChat = (config) => {
16810
17184
  const latest = laneIncidents[0];
16811
17185
  summaries.push({
16812
17186
  acknowledgedOpenCount,
17187
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16813
17188
  groupKey,
16814
17189
  highestSeverity: laneIncidents.some((entry) => entry.severity === "critical") ? "critical" : laneIncidents.some((entry) => entry.severity === "warning") ? "warning" : undefined,
16815
17190
  latestKind: latest?.kind,
@@ -16865,6 +17240,7 @@ var ragChat = (config) => {
16865
17240
  await persistReleaseLanePolicyHistoryRecord({
16866
17241
  approvalMaxAgeMs: policy.approvalMaxAgeMs,
16867
17242
  changeKind: "snapshot",
17243
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16868
17244
  groupKey,
16869
17245
  requireApprovalBeforePromotion: policy.requireApprovalBeforePromotion,
16870
17246
  rolloutLabel: policy.rolloutLabel,
@@ -16876,6 +17252,7 @@ var ragChat = (config) => {
16876
17252
  await persistReleaseLanePolicyHistoryRecord({
16877
17253
  approvalMaxAgeMs: policy.approvalMaxAgeMs,
16878
17254
  changeKind: "changed",
17255
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16879
17256
  groupKey,
16880
17257
  previousApprovalMaxAgeMs: latest.approvalMaxAgeMs,
16881
17258
  previousRequireApprovalBeforePromotion: latest.requireApprovalBeforePromotion,
@@ -16895,6 +17272,7 @@ var ragChat = (config) => {
16895
17272
  if (!latest) {
16896
17273
  await persistBaselineGatePolicyHistoryRecord({
16897
17274
  changeKind: "snapshot",
17275
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16898
17276
  groupKey,
16899
17277
  policy: policy.policy,
16900
17278
  rolloutLabel: policy.rolloutLabel,
@@ -16905,6 +17283,7 @@ var ragChat = (config) => {
16905
17283
  if (previousPolicy !== currentPolicy) {
16906
17284
  await persistBaselineGatePolicyHistoryRecord({
16907
17285
  changeKind: "changed",
17286
+ corpusGroupKey: getComparisonCorpusGroupKey(groupKey),
16908
17287
  groupKey,
16909
17288
  policy: policy.policy,
16910
17289
  previousPolicy: latest.policy,
@@ -16959,6 +17338,7 @@ var ragChat = (config) => {
16959
17338
  await persistReleaseLaneEscalationPolicyHistoryRecord({
16960
17339
  approvalExpiredSeverity: policy.approvalExpiredSeverity,
16961
17340
  changeKind: "snapshot",
17341
+ corpusGroupKey: getComparisonCorpusGroupKey(policy.groupKey),
16962
17342
  gateFailureSeverity: policy.gateFailureSeverity,
16963
17343
  groupKey: policy.groupKey,
16964
17344
  openIncidentSeverity: policy.openIncidentSeverity,
@@ -16971,6 +17351,7 @@ var ragChat = (config) => {
16971
17351
  await persistReleaseLaneEscalationPolicyHistoryRecord({
16972
17352
  approvalExpiredSeverity: policy.approvalExpiredSeverity,
16973
17353
  changeKind: "changed",
17354
+ corpusGroupKey: getComparisonCorpusGroupKey(policy.groupKey),
16974
17355
  gateFailureSeverity: policy.gateFailureSeverity,
16975
17356
  groupKey: policy.groupKey,
16976
17357
  openIncidentSeverity: policy.openIncidentSeverity,
@@ -17025,6 +17406,7 @@ var ragChat = (config) => {
17025
17406
  const latestWinner = latestRetrievalComparisonRun.comparison.summary.bestByPassingRate;
17026
17407
  if (latestWinner && stableWinnerByPassingRate?.retrievalId && stableWinnerByPassingRate.retrievalId !== latestWinner) {
17027
17408
  alerts.push({
17409
+ corpusGroupKey: latestRetrievalComparisonRun.corpusGroupKey,
17028
17410
  groupKey: latestRetrievalComparisonRun.groupKey,
17029
17411
  kind: "stable_winner_changed",
17030
17412
  latestRunId: latestRetrievalComparisonRun.id,
@@ -17041,6 +17423,7 @@ var ragChat = (config) => {
17041
17423
  baselineRetrievalId: latestRetrievalComparisonRun.decisionSummary?.baselineRetrievalId,
17042
17424
  candidateRetrievalId: latestRetrievalComparisonRun.decisionSummary?.candidateRetrievalId,
17043
17425
  delta,
17426
+ corpusGroupKey: latestRetrievalComparisonRun.corpusGroupKey,
17044
17427
  groupKey: latestRetrievalComparisonRun.groupKey,
17045
17428
  kind: "baseline_regression",
17046
17429
  latestRunId: latestRetrievalComparisonRun.id,
@@ -17055,6 +17438,7 @@ var ragChat = (config) => {
17055
17438
  candidateRetrievalId: latestRetrievalComparisonRun.decisionSummary?.candidateRetrievalId,
17056
17439
  delta,
17057
17440
  gate,
17441
+ corpusGroupKey: latestRetrievalComparisonRun.corpusGroupKey,
17058
17442
  groupKey: latestRetrievalComparisonRun.groupKey,
17059
17443
  kind: "baseline_gate_failed",
17060
17444
  latestRunId: latestRetrievalComparisonRun.id,
@@ -17072,6 +17456,7 @@ var ragChat = (config) => {
17072
17456
  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
17457
  alerts.push({
17074
17458
  candidateRetrievalId: entry.candidateRetrievalId,
17459
+ corpusGroupKey: getComparisonCorpusGroupKey(entry.groupKey),
17075
17460
  groupKey: entry.groupKey,
17076
17461
  kind,
17077
17462
  latestRunId: entry.sourceRunId ?? latestRetrievalComparisonRun.id,
@@ -17182,6 +17567,7 @@ var ragChat = (config) => {
17182
17567
  latest: latestRetrievalComparisonRun ? {
17183
17568
  bestByAverageF1: latestRetrievalComparisonRun.comparison.summary.bestByAverageF1,
17184
17569
  bestByPassingRate: latestRetrievalComparisonRun.comparison.summary.bestByPassingRate,
17570
+ corpusGroupKey: latestRetrievalComparisonRun.corpusGroupKey,
17185
17571
  elapsedMs: latestRetrievalComparisonRun.elapsedMs,
17186
17572
  fastest: latestRetrievalComparisonRun.comparison.summary.fastest,
17187
17573
  finishedAt: latestRetrievalComparisonRun.finishedAt,
@@ -18053,7 +18439,7 @@ var ragChat = (config) => {
18053
18439
  }
18054
18440
  return result;
18055
18441
  }).get(`${path}/compare/retrieval/release-history`, async ({ query, request, set }) => {
18056
- const result = await handleRetrievalReleaseGroupHistory(query);
18442
+ const result = await handleRetrievalReleaseGroupHistory(query, request);
18057
18443
  if (!result.ok) {
18058
18444
  set.status = HTTP_STATUS_BAD_REQUEST;
18059
18445
  }
@@ -18068,7 +18454,7 @@ var ragChat = (config) => {
18068
18454
  }
18069
18455
  return result;
18070
18456
  }).get(`${path}/compare/retrieval/handoffs`, async ({ query, request, set }) => {
18071
- const result = await handleRetrievalLaneHandoffList(query);
18457
+ const result = await handleRetrievalLaneHandoffList(query, request);
18072
18458
  if (!result.ok) {
18073
18459
  set.status = HTTP_STATUS_BAD_REQUEST;
18074
18460
  }
@@ -18083,7 +18469,7 @@ var ragChat = (config) => {
18083
18469
  }
18084
18470
  return result;
18085
18471
  }).get(`${path}/compare/retrieval/handoffs/decisions`, async ({ query, request, set }) => {
18086
- const result = await handleRetrievalLaneHandoffDecisionList(query);
18472
+ const result = await handleRetrievalLaneHandoffDecisionList(query, request);
18087
18473
  if (!result.ok) {
18088
18474
  set.status = HTTP_STATUS_BAD_REQUEST;
18089
18475
  }
@@ -18098,7 +18484,7 @@ var ragChat = (config) => {
18098
18484
  }
18099
18485
  return result;
18100
18486
  }).get(`${path}/compare/retrieval/handoffs/incidents`, async ({ query, request, set }) => {
18101
- const result = await handleRetrievalLaneHandoffIncidentList(query);
18487
+ const result = await handleRetrievalLaneHandoffIncidentList(query, request);
18102
18488
  if (!result.ok) {
18103
18489
  set.status = HTTP_STATUS_BAD_REQUEST;
18104
18490
  }
@@ -18113,7 +18499,7 @@ var ragChat = (config) => {
18113
18499
  }
18114
18500
  return result;
18115
18501
  }).get(`${path}/compare/retrieval/handoffs/incidents/history`, async ({ query, request, set }) => {
18116
- const result = await handleRetrievalLaneHandoffIncidentHistoryList(query);
18502
+ const result = await handleRetrievalLaneHandoffIncidentHistoryList(query, request);
18117
18503
  if (!result.ok) {
18118
18504
  set.status = HTTP_STATUS_BAD_REQUEST;
18119
18505
  }
@@ -18650,7 +19036,7 @@ var ragChat = (config) => {
18650
19036
  }
18651
19037
  return result;
18652
19038
  }).get(`${path}/compare/retrieval/escalation-policies/history`, async ({ query, request, set }) => {
18653
- const result = await handleRetrievalReleaseLaneEscalationPolicyHistoryList(query);
19039
+ const result = await handleRetrievalReleaseLaneEscalationPolicyHistoryList(query, request);
18654
19040
  if (!result.ok) {
18655
19041
  set.status = HTTP_STATUS_BAD_REQUEST;
18656
19042
  }
@@ -18665,7 +19051,7 @@ var ragChat = (config) => {
18665
19051
  }
18666
19052
  return result;
18667
19053
  }).get(`${path}/compare/retrieval/incident-policies/history`, async ({ query, request, set }) => {
18668
- const result = await handleRetrievalReleaseLaneEscalationPolicyHistoryList(query);
19054
+ const result = await handleRetrievalReleaseLaneEscalationPolicyHistoryList(query, request);
18669
19055
  if (!result.ok) {
18670
19056
  set.status = HTTP_STATUS_BAD_REQUEST;
18671
19057
  }
@@ -23474,5 +23860,5 @@ export {
23474
23860
  aiChat
23475
23861
  };
23476
23862
 
23477
- //# debugId=01B4F90C8AC5AD4364756E2164756E21
23863
+ //# debugId=98118EA892F30E7564756E2164756E21
23478
23864
  //# sourceMappingURL=index.js.map