@skyhook-io/radar-app 1.19.0 → 1.20.0

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.
Files changed (173) hide show
  1. package/README.md +1 -1
  2. package/package.json +5 -5
  3. package/src/App.tsx +31 -5
  4. package/src/api/application-evidence.ts +63 -0
  5. package/src/api/argoSync.test.ts +22 -0
  6. package/src/api/client.audit-gating.test.tsx +48 -0
  7. package/src/api/client.kueuePosition.test.ts +32 -0
  8. package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
  9. package/src/api/client.resource-identity.test.ts +3 -0
  10. package/src/api/client.resourceIssues.test.tsx +239 -0
  11. package/src/api/client.resourcePath.test.ts +3 -0
  12. package/src/api/client.ts +285 -55
  13. package/src/api/config.ts +21 -0
  14. package/src/api/diagnose.ts +4 -0
  15. package/src/api/radarFeatures.render.test.tsx +33 -1
  16. package/src/api/radarFeatures.test.ts +47 -0
  17. package/src/api/radarFeatures.ts +40 -1
  18. package/src/api/rbac.settled.test.tsx +42 -0
  19. package/src/api/rbac.test.ts +18 -0
  20. package/src/api/rbac.ts +37 -7
  21. package/src/api/traffic.ts +9 -4
  22. package/src/api/usage-data.fixtures.ts +3 -1
  23. package/src/api/usage-data.test.tsx +134 -0
  24. package/src/api/usage-data.ts +35 -7
  25. package/src/api/workloadPodsPolling.test.ts +26 -0
  26. package/src/components/CloudConnectFlow.test.tsx +86 -0
  27. package/src/components/CloudConnectFlow.tsx +65 -27
  28. package/src/components/CloudFunnelButton.test.tsx +140 -5
  29. package/src/components/CloudFunnelButton.tsx +50 -9
  30. package/src/components/ConnectionErrorView.test.tsx +34 -0
  31. package/src/components/ConnectionErrorView.tsx +35 -11
  32. package/src/components/ContextSwitcher.tsx +5 -2
  33. package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
  34. package/src/components/SwitchAwareConnectionError.tsx +85 -0
  35. package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
  36. package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
  37. package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
  38. package/src/components/capacity/CapacityDemand.tsx +3 -2
  39. package/src/components/capacity/demandSummary.test.ts +38 -0
  40. package/src/components/capacity/shared.tsx +12 -1
  41. package/src/components/cost/ApplicationCostTab.tsx +4 -0
  42. package/src/components/cost/CostTrendChart.tsx +2 -0
  43. package/src/components/cost/WorkloadCostTab.tsx +4 -0
  44. package/src/components/cost/source.test.ts +5 -0
  45. package/src/components/cost/source.ts +11 -0
  46. package/src/components/diagnose/AIMarkdown.tsx +3 -0
  47. package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
  48. package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
  49. package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
  50. package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
  51. package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
  52. package/src/components/diagnose/DiagnoseContext.question.test.tsx +1 -1
  53. package/src/components/diagnose/DiagnoseContext.tsx +68 -2
  54. package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
  55. package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
  56. package/src/components/diagnose/Home.test.tsx +26 -0
  57. package/src/components/diagnose/Home.tsx +20 -1
  58. package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
  59. package/src/components/diagnose/InvestigationView.tsx +94 -26
  60. package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
  61. package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
  62. package/src/components/diagnose/NextStepJump.test.tsx +92 -0
  63. package/src/components/diagnose/NextStepJump.tsx +75 -0
  64. package/src/components/diagnose/QuestionComposer.tsx +8 -0
  65. package/src/components/diagnose/exampleInvestigation.events.json +191 -0
  66. package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
  67. package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
  68. package/src/components/diagnose/exampleInvestigation.ts +121 -0
  69. package/src/components/diagnose/investigationCase.test.tsx +9 -1
  70. package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
  71. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
  72. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
  73. package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
  74. package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
  75. package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
  76. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  77. package/src/components/diagnose/investigationState.ts +28 -0
  78. package/src/components/diagnose/lastInvestigation.test.ts +95 -0
  79. package/src/components/diagnose/lastInvestigation.ts +58 -0
  80. package/src/components/diagnose/launch.test.ts +125 -1
  81. package/src/components/diagnose/launch.ts +57 -10
  82. package/src/components/diagnose/toolCallLabel.test.ts +10 -4
  83. package/src/components/execution/BatchExecutionView.tsx +24 -11
  84. package/src/components/execution/JobSetAdmission.test.tsx +42 -0
  85. package/src/components/execution/JobSetAdmission.tsx +18 -3
  86. package/src/components/execution/JobSetMemberComparison.tsx +2 -1
  87. package/src/components/execution/runState.test.ts +14 -0
  88. package/src/components/execution/runState.ts +8 -0
  89. package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
  90. package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
  91. package/src/components/gitops/GitOpsView.tsx +86 -17
  92. package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
  93. package/src/components/gitops/destination-toast.test.ts +1 -1
  94. package/src/components/gitops/destination-toast.ts +2 -2
  95. package/src/components/home/ClusterHealthCard.tsx +1 -1
  96. package/src/components/home/HomeAgentBlock.test.tsx +31 -3
  97. package/src/components/home/HomeAgentBlock.tsx +13 -4
  98. package/src/components/home/HomeDiagramCard.tsx +47 -0
  99. package/src/components/home/HomeView.tsx +81 -41
  100. package/src/components/home/MCPSetupDialog.test.tsx +95 -5
  101. package/src/components/home/MCPSetupDialog.tsx +30 -5
  102. package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
  103. package/src/components/home/ProblemsPanel.test.tsx +3 -1
  104. package/src/components/home/TopologyPreview.test.tsx +73 -0
  105. package/src/components/home/TopologyPreview.tsx +120 -233
  106. package/src/components/home/TrafficSummary.test.tsx +63 -0
  107. package/src/components/home/TrafficSummary.tsx +135 -138
  108. package/src/components/home/mcpToolCatalog.ts +23 -10
  109. package/src/components/issues/IssuesPane.test.ts +11 -0
  110. package/src/components/issues/IssuesPane.tsx +15 -5
  111. package/src/components/issues/uncheckedSources.test.ts +20 -1
  112. package/src/components/issues/uncheckedSources.ts +18 -0
  113. package/src/components/kueue/KueuePendingPosition.tsx +35 -0
  114. package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
  115. package/src/components/kueue/useRelatedReads.test.ts +56 -0
  116. package/src/components/kueue/useRelatedReads.ts +205 -0
  117. package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
  118. package/src/components/logs/MultiPodLogsTab.tsx +120 -0
  119. package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
  120. package/src/components/logs/PodLogsUnavailable.tsx +21 -0
  121. package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
  122. package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
  123. package/src/components/logs/RayClusterLogsTab.tsx +109 -0
  124. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
  125. package/src/components/logs/rayClusterPods.ts +32 -0
  126. package/src/components/outageSince.test.ts +21 -0
  127. package/src/components/outageSince.ts +10 -0
  128. package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
  129. package/src/components/resource/PrometheusCharts.tsx +3 -40
  130. package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
  131. package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
  132. package/src/components/resources/crd/host.tsx +14 -0
  133. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
  134. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
  135. package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
  136. package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
  137. package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
  138. package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
  139. package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
  140. package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
  141. package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
  142. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
  143. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
  144. package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
  145. package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
  146. package/src/components/traffic/TrafficView.tsx +3 -3
  147. package/src/components/ui/command-items-crd.test.tsx +23 -0
  148. package/src/components/ui/command-items.ts +2 -1
  149. package/src/components/useContextSwitchFlow.test.tsx +61 -0
  150. package/src/components/useContextSwitchFlow.tsx +21 -4
  151. package/src/components/whats-new/WhatsNew.test.ts +10 -3
  152. package/src/components/whats-new/WhatsNew.tsx +5 -1
  153. package/src/components/whats-new/WhatsNewDialog.test.tsx +17 -3
  154. package/src/components/whats-new/releaseNotes.ts +77 -4
  155. package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
  156. package/src/components/workload/RelatedFindingsSection.tsx +80 -0
  157. package/src/components/workload/WorkloadView.test.ts +10 -1
  158. package/src/components/workload/WorkloadView.tsx +85 -98
  159. package/src/components/workload/issueResourceOpener.test.ts +20 -0
  160. package/src/components/workload/issueResourceOpener.ts +17 -0
  161. package/src/context/ConnectionContext.tsx +133 -60
  162. package/src/context/ConnectionProvider.retry.test.tsx +176 -0
  163. package/src/context/ContextSwitchContext.tsx +14 -1
  164. package/src/context/DiagnoseCustomization.tsx +3 -0
  165. package/src/context/clusterConnected.ts +10 -0
  166. package/src/contexts/CapabilitiesContext.tsx +6 -4
  167. package/src/hooks/useElementSize.ts +30 -0
  168. package/src/integrations/resourceHost.test.tsx +1 -0
  169. package/src/integrations/resourceHost.ts +5 -1
  170. package/src/integrations/resourceHosts.test.tsx +21 -4
  171. package/src/integrations/resourceHosts.tsx +12 -0
  172. package/src/main.tsx +5 -0
  173. package/src/utils/related-findings.ts +46 -0
@@ -251,6 +251,15 @@ export function adaptDiagnose(
251
251
  : "producer-related";
252
252
  };
253
253
  addNarrowHint(builder, source, value);
254
+ const resourceOnly = nonEmptyString(value.coverage);
255
+ if (resourceOnly) {
256
+ builder.limit(
257
+ source,
258
+ "Diagnosis coverage",
259
+ value.coverage as string,
260
+ "unknown",
261
+ );
262
+ }
254
263
 
255
264
  const relatedRaw = value.relatedIssues;
256
265
  const related = Array.isArray(relatedRaw)
@@ -330,6 +339,9 @@ export function adaptDiagnose(
330
339
  source.confirmedSuccess &&
331
340
  related.length === 0 &&
332
341
  relatedValid &&
342
+ (context?.relatedFindings === undefined ||
343
+ (Array.isArray(context.relatedFindings) &&
344
+ context.relatedFindings.length === 0)) &&
333
345
  isDiagnosableWorkloadKind(resource.kind)
334
346
  ) {
335
347
  const scope = scopeFromArgs(source);
@@ -358,6 +370,42 @@ export function adaptDiagnose(
358
370
  bundleRelevance,
359
371
  );
360
372
 
373
+ if (
374
+ apiVersionToGroup(resource.apiVersion) === "kafka.strimzi.io" &&
375
+ (resource.kind === "KafkaConnector" || resource.kind === "KafkaConnect")
376
+ ) {
377
+ const snapshot = record(value.operatorSnapshot);
378
+ if (
379
+ !snapshot ||
380
+ !["observed", "failing", "recovered", "unknown"].includes(
381
+ String(snapshot.state),
382
+ ) ||
383
+ typeof snapshot.generationCurrent !== "boolean"
384
+ ) {
385
+ invalidPayload(builder, source, "Operator snapshot");
386
+ } else if (snapshot.state === "unknown") {
387
+ builder.limit(
388
+ source,
389
+ "Operator snapshot",
390
+ `Operator status is unverifiable: ${nonEmptyString(snapshot.reason) ? snapshot.reason : "unknown"}. Missing findings do not establish application health.`,
391
+ "unknown",
392
+ );
393
+ } else if (
394
+ resource.kind === "KafkaConnector" &&
395
+ source.confirmedSuccess &&
396
+ snapshot.state === "recovered" &&
397
+ snapshot.generationCurrent === true
398
+ ) {
399
+ builder.connectorRecoveryBySource.set(source.id, {
400
+ group: "kafka.strimzi.io",
401
+ kind: "KafkaConnector",
402
+ namespace: resource.metadata.namespace,
403
+ name: resource.metadata.name,
404
+ });
405
+ }
406
+ return;
407
+ }
408
+
361
409
  if (Array.isArray(blockersRaw)) {
362
410
  for (const { blocker, pods, foldedInto } of blockerGroups) {
363
411
  if (foldedInto) continue;
@@ -643,7 +691,7 @@ export function adaptDiagnose(
643
691
  `events:diagnose:${scopeFromArgs(source)}`,
644
692
  typeof value.eventsTotalGroups !== "number" ||
645
693
  value.eventsTotalGroups <= events.length,
646
- true,
694
+ !resourceOnly,
647
695
  relatedRelevance,
648
696
  );
649
697
  } else {
@@ -660,7 +708,7 @@ export function adaptDiagnose(
660
708
  [],
661
709
  `events:diagnose:${scopeFromArgs(source)}`,
662
710
  true,
663
- true,
711
+ !resourceOnly,
664
712
  relatedRelevance,
665
713
  );
666
714
  } else if (eventsRaw !== undefined) {
@@ -1,10 +1,12 @@
1
1
  import { type Issue, type IssueRecentChange } from "@skyhook-io/k8s-ui";
2
+ import { type UncheckedSource } from "../../../../api/client";
2
3
  import { type DiagnosisDNSContext } from "../../diagnoseEvidenceTypes";
3
4
  import {
4
5
  ProjectionBuilder,
5
6
  addChanges,
6
7
  addIssueObservation,
7
8
  addNarrowHint,
9
+ addUncheckedIssueLimitations,
8
10
  evidenceTierForRelevance,
9
11
  invalidPayload,
10
12
  scopeFromArgs,
@@ -43,6 +45,13 @@ export function adaptIssues(
43
45
  return;
44
46
  }
45
47
  addNarrowHint(builder, source, value);
48
+ if (Array.isArray(value.unchecked_sources)) {
49
+ addUncheckedIssueLimitations(
50
+ builder,
51
+ source,
52
+ value.unchecked_sources as UncheckedSource[],
53
+ );
54
+ }
46
55
  if (
47
56
  value.total_matched > issues.length &&
48
57
  !nonEmptyString(value.narrowHint)
@@ -1,3 +1,4 @@
1
+ import { resourceKey } from "@skyhook-io/k8s-ui";
1
2
  import {
2
3
  apiVersionToGroup,
3
4
  knownKindForPluralWithGroup,
@@ -307,12 +308,32 @@ export function projectInvestigationEvidence(
307
308
  source: InvestigationEvidenceSource,
308
309
  podContainer: string,
309
310
  ) => `previous-log:${source.tool}:${scopeFromArgs(source)}:${podContainer}`;
311
+ const connectorCoverageKey = (ref: {
312
+ group?: string;
313
+ kind: string;
314
+ namespace?: string;
315
+ name: string;
316
+ }) =>
317
+ `connector:${resourceKey(ref.group ?? "", ref.kind, ref.namespace ?? "", ref.name)}`;
310
318
  const retirementKey = (
311
319
  group: InvestigationEvidenceGroup,
312
320
  observation: InvestigationEvidenceObservation,
313
321
  ): string | undefined => {
314
322
  switch (group.kind) {
315
323
  case "issue":
324
+ if (
325
+ observation.data.type === "issue" &&
326
+ observation.data.issue.group === "kafka.strimzi.io" &&
327
+ observation.data.issue.kind === "KafkaConnector"
328
+ )
329
+ return connectorCoverageKey(observation.data.issue);
330
+ // A clean parent diagnosis cannot prove an associated resource recovered.
331
+ if (
332
+ observation.data.type === "issue" &&
333
+ observation.data.associatedVia
334
+ )
335
+ return undefined;
336
+ return semanticCoverageKey(group.kind);
316
337
  case "startup":
317
338
  case "crash":
318
339
  case "dns":
@@ -344,6 +365,15 @@ export function projectInvestigationEvidence(
344
365
  turns.forEach((turn, turnIndex) => {
345
366
  if (!turn.verify || turn.status !== "done") return;
346
367
  const keys = new Set<string>();
368
+ for (const source of builder.sources) {
369
+ const recovered = builder.connectorRecoveryBySource.get(source.id);
370
+ if (
371
+ source.turnIndex === turnIndex &&
372
+ source.confirmedSuccess &&
373
+ recovered
374
+ )
375
+ keys.add(connectorCoverageKey(recovered));
376
+ }
347
377
  for (const group of builder.groups) {
348
378
  for (const observation of group.observations) {
349
379
  if (
@@ -1,6 +1,10 @@
1
+ import { relatedFindingLimitations } from "../../../utils/related-findings";
2
+ import { uncheckedSourceLines } from "../../issues/uncheckedSources";
3
+ import { type UncheckedSource } from "../../../api/client";
1
4
  import {
2
5
  type HPADiagnosisState,
3
6
  type Issue,
7
+ type RelatedFindingsGroup,
4
8
  type IssueRecentChange,
5
9
  type Topology,
6
10
  defaultConditionTone,
@@ -13,6 +17,7 @@ import {
13
17
  type DiagnosisChangeContext,
14
18
  type DiagnosisEvidenceLimitationBase,
15
19
  type DiagnosisPodLogEntry,
20
+ type DiagnosisResourceRef,
16
21
  diagnosisSeverityTone,
17
22
  } from "../diagnoseEvidenceTypes";
18
23
  import { getCrossplaneConditionTone } from "@skyhook-io/k8s-ui/components/resources/resource-utils-crossplane";
@@ -20,7 +25,15 @@ import { investigationResourceEvidenceSummary } from "../investigationResourceEv
20
25
  import { kindToPluralWithGroup } from "../../../utils/navigation";
21
26
  import { pluralToKind } from "@skyhook-io/k8s-ui";
22
27
  import { stableHash } from "./identity";
23
- import { nonEmptyString, parseJSON, record, stringArray } from "./parse";
28
+ import {
29
+ issue,
30
+ nonEmptyString,
31
+ nonNegativeInteger,
32
+ parseJSON,
33
+ record,
34
+ resourceRef,
35
+ stringArray,
36
+ } from "./parse";
24
37
  import {
25
38
  type InvestigationEventEvidence,
26
39
  type InvestigationEvidenceGroup,
@@ -287,6 +300,8 @@ export class ProjectionBuilder {
287
300
  readonly projectedSources = new Set<string>();
288
301
  readonly checkedSources = new Set<string>();
289
302
  readonly limitedSources = new Set<string>();
303
+ readonly connectorRecoveryBySource = new Map<string, DiagnosisResourceRef>();
304
+
290
305
  readonly semanticCoverageBySource = new Map<
291
306
  string,
292
307
  Set<InvestigationSemanticDomain>
@@ -513,6 +528,14 @@ export function addNarrowHint(
513
528
  source: InvestigationEvidenceSource,
514
529
  value: Record<string, unknown>,
515
530
  ): void {
531
+ if (value.relatedIssuesTruncated === true) {
532
+ builder.limit(
533
+ source,
534
+ "Related Issues",
535
+ "Radar returned part of the related Issues; more findings may exist.",
536
+ "truncated",
537
+ );
538
+ }
516
539
  if (nonEmptyString(value.narrowHint)) {
517
540
  const label = investigationResultLabel(source);
518
541
  builder.limit(
@@ -524,12 +547,26 @@ export function addNarrowHint(
524
547
  );
525
548
  }
526
549
  }
550
+ export function addUncheckedIssueLimitations(
551
+ builder: ProjectionBuilder,
552
+ source: InvestigationEvidenceSource,
553
+ gaps: UncheckedSource[] | undefined,
554
+ ): void {
555
+ for (const line of uncheckedSourceLines(gaps)) {
556
+ builder.limit(source, "Issue scan", line, "unknown");
557
+ }
558
+ }
527
559
  function addResourceContextLimitations(
528
560
  builder: ProjectionBuilder,
529
561
  source: InvestigationEvidenceSource,
530
562
  context: InvestigationResourceContext | undefined,
531
563
  ): void {
532
564
  if (!context) return;
565
+ addUncheckedIssueLimitations(
566
+ builder,
567
+ source,
568
+ context.issueSummary?.unchecked,
569
+ );
533
570
  for (const value of Array.isArray(context.omitted) ? context.omitted : []) {
534
571
  const omitted = record(value);
535
572
  if (
@@ -673,7 +710,9 @@ export function addResourceObservation(
673
710
  (available !== undefined && available < desired) ||
674
711
  (replicas?.unavailable ?? 0) > 0);
675
712
  const adverseCondition = (context?.statusSummary?.conditions ?? []).some(
676
- (condition) => (getCrossplaneConditionTone(resource, condition) ?? defaultConditionTone(condition)) === "fail",
713
+ (condition) =>
714
+ (getCrossplaneConditionTone(resource, condition) ??
715
+ defaultConditionTone(condition)) === "fail",
677
716
  );
678
717
  const gitOpsAdverse = Boolean(
679
718
  gitOpsDiagnosis &&
@@ -734,6 +773,7 @@ export function addResourceObservation(
734
773
  },
735
774
  });
736
775
  addResourceContextLimitations(builder, source, context);
776
+ addRelatedFindings(builder, source, context, relevance);
737
777
  }
738
778
  // The live Pod spec differing from its template is context, not a fault, so
739
779
  // it reads as a line on the resource card rather than a finding of its own.
@@ -755,6 +795,7 @@ export function addIssueObservation(
755
795
  value: Issue,
756
796
  producerRelevance: InvestigationEvidenceRelevance = "broader",
757
797
  pods?: string[],
798
+ associatedVia?: DiagnosisResourceRef,
758
799
  ): void {
759
800
  const matchesTarget = resourceMatchesTarget(builder.target, {
760
801
  kind: value.kind,
@@ -777,6 +818,7 @@ export function addIssueObservation(
777
818
  data: {
778
819
  type: "issue",
779
820
  issue: value,
821
+ ...(associatedVia ? { associatedVia } : {}),
780
822
  relevance,
781
823
  ...(pods && pods.length > 0 ? { pods } : {}),
782
824
  },
@@ -1017,3 +1059,80 @@ export function invalidPayload(
1017
1059
  "unknown",
1018
1060
  );
1019
1061
  }
1062
+
1063
+ function addRelatedFindings(
1064
+ builder: ProjectionBuilder,
1065
+ source: InvestigationEvidenceSource,
1066
+ context: InvestigationResourceContext | undefined,
1067
+ relevance: InvestigationEvidenceRelevance,
1068
+ ): void {
1069
+ const raw = context?.relatedFindings;
1070
+ if (raw === undefined) return;
1071
+ if (!Array.isArray(raw)) {
1072
+ invalidPayload(builder, source, "Related findings");
1073
+ return;
1074
+ }
1075
+ for (const entry of raw) {
1076
+ const value = record(entry);
1077
+ const associatedVia = resourceRef(value?.associatedVia);
1078
+ const kinds = record(value?.kinds);
1079
+ const findingsRaw = value?.findings;
1080
+ const findings = Array.isArray(findingsRaw)
1081
+ ? findingsRaw.map(issue).filter((item): item is Issue => Boolean(item))
1082
+ : [];
1083
+ if (
1084
+ !value ||
1085
+ !associatedVia ||
1086
+ !kinds ||
1087
+ !nonNegativeInteger(kinds.count) ||
1088
+ kinds.count === 0 ||
1089
+ kinds.extent !== undefined ||
1090
+ (kinds.names !== undefined &&
1091
+ (!Array.isArray(kinds.names) ||
1092
+ kinds.names.length !== kinds.count ||
1093
+ !kinds.names.every((item) => {
1094
+ const ref = record(item);
1095
+ return (
1096
+ ref &&
1097
+ nonEmptyString(ref.kind) &&
1098
+ (ref.group === undefined || typeof ref.group === "string")
1099
+ );
1100
+ }))) ||
1101
+ !Array.isArray(value.gaps) ||
1102
+ !value.gaps.every((gap) => nonEmptyString(record(gap)?.code)) ||
1103
+ !nonNegativeInteger(value.checked) ||
1104
+ !nonNegativeInteger(value.unknown) ||
1105
+ value.unknown > value.checked ||
1106
+ (value.truncated !== undefined && typeof value.truncated !== "boolean") ||
1107
+ (findingsRaw !== undefined &&
1108
+ (!Array.isArray(findingsRaw) || findings.length !== findingsRaw.length))
1109
+ ) {
1110
+ invalidPayload(builder, source, "Related findings group");
1111
+ continue;
1112
+ }
1113
+ for (const finding of findings) {
1114
+ addIssueObservation(
1115
+ builder,
1116
+ source,
1117
+ finding,
1118
+ relevance === "target" ? "producer-related" : "broader",
1119
+ undefined,
1120
+ associatedVia,
1121
+ );
1122
+ }
1123
+ const group = {
1124
+ ...value,
1125
+ associatedVia,
1126
+ findings,
1127
+ } as unknown as RelatedFindingsGroup;
1128
+ const anchor = `${associatedVia.kind} ${associatedVia.namespace ? associatedVia.namespace + "/" : ""}${associatedVia.name}${associatedVia.group ? " (" + associatedVia.group + ")" : ""}`;
1129
+ for (const limit of relatedFindingLimitations(group)) {
1130
+ builder.limit(
1131
+ source,
1132
+ `Related findings via ${anchor}`,
1133
+ limit.message,
1134
+ limit.kind,
1135
+ );
1136
+ }
1137
+ }
1138
+ }
@@ -2926,11 +2926,93 @@ describe("failedStepMessage", () => {
2926
2926
  );
2927
2927
  });
2928
2928
  it("keeps any other failure text as it came", () => {
2929
- expect(failedStepMessage("user_forbidden: your role cannot list pods")).toBe(
2930
- "user_forbidden: your role cannot list pods",
2931
- );
2929
+ expect(
2930
+ failedStepMessage("user_forbidden: your role cannot list pods"),
2931
+ ).toBe("user_forbidden: your role cannot list pods");
2932
2932
  expect(failedStepMessage('{"error":"no code"}')).toBe(
2933
2933
  '{"error":"no code"}',
2934
2934
  );
2935
2935
  });
2936
2936
  });
2937
+
2938
+ describe("Kueue diagnosis evidence boundaries", () => {
2939
+ it.each(["get_resource", "diagnose"])(
2940
+ "preserves unchecked Issues in %s",
2941
+ (name) => {
2942
+ const resource = {
2943
+ apiVersion: "kueue.x-k8s.io/v1beta2",
2944
+ kind: "Workload",
2945
+ metadata: { namespace: "shop", name: "run" },
2946
+ };
2947
+ const result = project([
2948
+ tool("batch", name, {
2949
+ resource,
2950
+ resourceContext: {
2951
+ tier: "diagnostic",
2952
+ issueSummary: {
2953
+ count: 0,
2954
+ unchecked: [
2955
+ {
2956
+ source: "kueue",
2957
+ reason: "caller_access_denied",
2958
+ kinds: [{ group: "kueue.x-k8s.io", kind: "ClusterQueue" }],
2959
+ },
2960
+ ],
2961
+ },
2962
+ },
2963
+ relatedIssues: [],
2964
+ ...(name === "diagnose"
2965
+ ? {
2966
+ coverage:
2967
+ "Cached resource only. Pods, runtime logs and metrics were not collected.",
2968
+ }
2969
+ : {}),
2970
+ }),
2971
+ ]);
2972
+ expect(
2973
+ result.limitations.some(
2974
+ (limit) =>
2975
+ limit.source === "Issue scan" &&
2976
+ limit.message.includes("can't read ClusterQueues"),
2977
+ ),
2978
+ ).toBe(true);
2979
+ if (name === "diagnose") {
2980
+ expect(
2981
+ result.limitations.some(
2982
+ (limit) =>
2983
+ limit.source === "Diagnosis coverage" &&
2984
+ limit.message.includes(
2985
+ "runtime logs and metrics were not collected",
2986
+ ),
2987
+ ),
2988
+ ).toBe(true);
2989
+ expect(
2990
+ groupsOf(result.groups, "receipt").some(
2991
+ (group) => group.latest.title === "No warning events",
2992
+ ),
2993
+ ).toBe(false);
2994
+ }
2995
+ },
2996
+ );
2997
+ });
2998
+
2999
+ it("does not turn unchecked Kueue scans into no-issue receipts", () => {
3000
+ const result = project([
3001
+ tool("partial", "issues", {
3002
+ issues: [],
3003
+ total: 0,
3004
+ total_matched: 0,
3005
+ unchecked_sources: [
3006
+ {
3007
+ source: "kueue",
3008
+ reason: "kind_sync_pending",
3009
+ kinds: [{ kind: "Workload", group: "kueue.x-k8s.io" }],
3010
+ },
3011
+ ],
3012
+ }),
3013
+ ]);
3014
+ expect(
3015
+ result.limitations.some((limit) => limit.source === "Issue scan"),
3016
+ ).toBe(true);
3017
+ expect(groupsOf(result.groups, "receipt")).toHaveLength(0);
3018
+ });
@@ -1,4 +1,5 @@
1
1
  import { type Issue, type IssueRecentChange } from "@skyhook-io/k8s-ui";
2
+ import { type UncheckedSource } from "../../../api/client";
2
3
  import { type TimeSeries } from "@skyhook-io/k8s-ui/components/charts";
3
4
  import {
4
5
  type DiagnosisChangeContext,
@@ -103,12 +104,14 @@ export interface InvestigationResourceContext extends DiagnosisResourceContext {
103
104
  highestSeverity?: string;
104
105
  topReason?: string;
105
106
  bySource?: Record<string, number>;
107
+ unchecked?: UncheckedSource[];
106
108
  };
107
109
  auditSummary?: {
108
110
  count: number;
109
111
  highestSeverity?: string;
110
112
  topFinding?: string;
111
113
  };
114
+ relatedFindings?: unknown;
112
115
  policySummary?: unknown;
113
116
  podSummary?: unknown;
114
117
  templateDivergence?: {
@@ -381,6 +384,8 @@ export type InvestigationEvidenceData =
381
384
  | {
382
385
  type: "issue";
383
386
  issue: Issue;
387
+ /** Association anchor; parent verification cannot establish recovery of this issue. */
388
+ associatedVia?: DiagnosisResourceRef;
384
389
  /**
385
390
  * A broad `issues` query can return failures from other resources. Keep
386
391
  * those factual observations, but do not let agent selection alone imply
@@ -800,6 +800,34 @@ export function canStopInvestigation(
800
800
  );
801
801
  }
802
802
 
803
+ // The hand-off resumes the agent's own session, so it waits until no turn is
804
+ // writing to that session. A finished transcript outranks a run summary that
805
+ // still says running, as for Stop; stopping does not, because Stop writes its
806
+ // terminal frame before the agent process has exited.
807
+ export function canContinueInOwnAgent(input: {
808
+ run: RunSummary;
809
+ busy: boolean;
810
+ requestPending: boolean;
811
+ gone: boolean;
812
+ streamReady: boolean;
813
+ verificationPending: boolean;
814
+ latestTurnStatus?: Turn["status"];
815
+ }): boolean {
816
+ const { run, latestTurnStatus } = input;
817
+ const transcriptTerminal =
818
+ latestTurnStatus === "done" || latestTurnStatus === "error";
819
+ return (
820
+ input.streamReady &&
821
+ !input.busy &&
822
+ !input.requestPending &&
823
+ !input.verificationPending &&
824
+ !input.gone &&
825
+ run.status !== "stopping" &&
826
+ latestTurnStatus !== "running" &&
827
+ (transcriptTerminal || run.status !== "running")
828
+ );
829
+ }
830
+
803
831
  export function canContinueInvestigation(
804
832
  run: RunSummary,
805
833
  latestTurnStatus?: Turn["status"],
@@ -0,0 +1,95 @@
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import type { RunSummary } from "../../api/diagnose";
4
+ import {
5
+ LAST_INVESTIGATION_MAX_AGE_MS,
6
+ lastInvestigations,
7
+ sameObject,
8
+ } from "./lastInvestigation";
9
+ import { runTargetKey } from "./target";
10
+
11
+ const now = Date.parse("2026-11-02T12:00:00Z");
12
+ const hoursAgo = (h: number) => new Date(now - h * 3600_000).toISOString();
13
+ const key = runTargetKey("Deployment", "shop", "cart", "apps");
14
+
15
+ function run(over: Partial<RunSummary>): RunSummary {
16
+ return {
17
+ id: "r1",
18
+ kind: "Deployment",
19
+ group: "apps",
20
+ namespace: "shop",
21
+ name: "cart",
22
+ context: "cluster-a",
23
+ status: "done",
24
+ preview: "Pods crash on a bad flag",
25
+ assessedAt: hoursAgo(2),
26
+ createdAt: hoursAgo(3),
27
+ updatedAt: hoursAgo(1),
28
+ ...over,
29
+ };
30
+ }
31
+
32
+ describe("lastInvestigations", () => {
33
+ it("picks the newest assessment of the resource on the cluster in use", () => {
34
+ const got = lastInvestigations(
35
+ [
36
+ run({ id: "old", assessedAt: hoursAgo(30) }),
37
+ run({ id: "new", assessedAt: hoursAgo(2), preview: "Healthy" }),
38
+ run({
39
+ id: "other-cluster",
40
+ context: "cluster-b",
41
+ assessedAt: hoursAgo(1),
42
+ }),
43
+ ],
44
+ "cluster-a",
45
+ now,
46
+ );
47
+ expect(got.get(key)).toMatchObject({ id: "new", preview: "Healthy" });
48
+ });
49
+
50
+ it("counts a run made stale by a cluster switch", () => {
51
+ const got = lastInvestigations(
52
+ [run({ status: "stale" })],
53
+ "cluster-a",
54
+ now,
55
+ );
56
+ expect(got.get(key)?.id).toBe("r1");
57
+ });
58
+
59
+ it.each([
60
+ ["a live run", { status: "running" as const }],
61
+ [
62
+ "a question about no resource",
63
+ { name: "", question: "why is checkout slow?" },
64
+ ],
65
+ ["a run with no dated assessment", { assessedAt: undefined }],
66
+ [
67
+ "an assessment past the cutoff",
68
+ {
69
+ assessedAt: new Date(
70
+ now - LAST_INVESTIGATION_MAX_AGE_MS - 1,
71
+ ).toISOString(),
72
+ },
73
+ ],
74
+ ])("skips %s", (_, over) => {
75
+ expect(lastInvestigations([run(over)], "cluster-a", now).size).toBe(0);
76
+ });
77
+
78
+ it("matches nothing until the cluster in use is known", () => {
79
+ expect(lastInvestigations([run({})], undefined, now).size).toBe(0);
80
+ });
81
+ });
82
+
83
+ describe("sameObject", () => {
84
+ const last = { id: "r1", preview: "x", assessedAt: hoursAgo(2) };
85
+ it("rejects an object created after the assessment", () => {
86
+ expect(sameObject(last, hoursAgo(1))).toBe(false);
87
+ });
88
+ it("accepts an object recreated mid-run that the assessment saw", () => {
89
+ expect(sameObject(last, hoursAgo(2.5))).toBe(true);
90
+ });
91
+ it("accepts an older object, or one whose creation time is unknown", () => {
92
+ expect(sameObject(last, hoursAgo(48))).toBe(true);
93
+ expect(sameObject(last, undefined)).toBe(true);
94
+ });
95
+ });
@@ -0,0 +1,58 @@
1
+ import type { RunSummary } from "../../api/diagnose";
2
+ import { isQuestionOnly, runTargetKey } from "./target";
3
+
4
+ // Past this age a verdict describes the cluster as it was, not as it is, so the
5
+ // resource stops pointing at it. History still lists it.
6
+ export const LAST_INVESTIGATION_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
7
+
8
+ export interface LastInvestigation {
9
+ id: string;
10
+ preview: string;
11
+ assessedAt: string;
12
+ }
13
+
14
+ // The newest assessment of each resource on the cluster in use. Only runs the
15
+ // server dated with assessedAt qualify: their preview is the assessment
16
+ // Findings shows, not a later answer. Stale runs count, since switching
17
+ // clusters marks every run stale.
18
+ export function lastInvestigations(
19
+ runs: readonly RunSummary[],
20
+ context: string | undefined,
21
+ now: number,
22
+ ): Map<string, LastInvestigation> {
23
+ const out = new Map<string, LastInvestigation>();
24
+ if (!context) return out;
25
+ for (const r of runs) {
26
+ if (
27
+ isQuestionOnly(r) ||
28
+ r.status === "running" ||
29
+ r.status === "stopping" ||
30
+ r.context !== context ||
31
+ !r.assessedAt ||
32
+ !r.preview
33
+ )
34
+ continue;
35
+ const assessed = Date.parse(r.assessedAt);
36
+ if (!(now - assessed <= LAST_INVESTIGATION_MAX_AGE_MS)) continue;
37
+ const key = runTargetKey(r.kind, r.namespace, r.name, r.group);
38
+ const prev = out.get(key);
39
+ if (prev && Date.parse(prev.assessedAt) >= assessed) continue;
40
+ out.set(key, {
41
+ id: r.id,
42
+ preview: r.preview,
43
+ assessedAt: r.assessedAt,
44
+ });
45
+ }
46
+ return out;
47
+ }
48
+
49
+ // Whether the object on screen is the one the assessment describes. Without a
50
+ // UID the creation time is the only tell: an object created after the
51
+ // assessment was recreated since. Unknown creation time can't rule it out.
52
+ export function sameObject(
53
+ last: LastInvestigation,
54
+ objectCreatedAt: string | undefined,
55
+ ): boolean {
56
+ if (!objectCreatedAt) return true;
57
+ return !(Date.parse(objectCreatedAt) > Date.parse(last.assessedAt));
58
+ }