@skyhook-io/radar-app 1.17.1 → 1.18.1

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 (146) hide show
  1. package/README.md +6 -0
  2. package/package.json +10 -11
  3. package/src/App.tsx +36 -36
  4. package/src/api/client.gitops-destination.test.tsx +55 -0
  5. package/src/api/client.gitopsPoll.test.ts +99 -0
  6. package/src/api/client.helmPreview.test.tsx +48 -0
  7. package/src/api/client.resource-list.test.ts +76 -0
  8. package/src/api/client.resourceAvailability.test.ts +24 -0
  9. package/src/api/client.ts +396 -105
  10. package/src/api/client.workloadRuns.test.ts +53 -0
  11. package/src/api/config.test.ts +23 -1
  12. package/src/api/config.ts +7 -3
  13. package/src/api/diagnose.ts +4 -1
  14. package/src/api/drain-plan.test.ts +70 -40
  15. package/src/api/policy.ts +5 -5
  16. package/src/api/quotas.ts +9 -20
  17. package/src/api/radarFeatures.ts +3 -0
  18. package/src/api/resourceLists.test.ts +84 -0
  19. package/src/api/resourceLists.ts +71 -0
  20. package/src/api/traffic.scope.render.test.tsx +60 -0
  21. package/src/api/traffic.ts +3 -1
  22. package/src/components/cnpg/CNPGSummaryHost.tsx +4 -3
  23. package/src/components/cnpg/CNPGView.tsx +1 -0
  24. package/src/components/compare/CompareResourcePicker.test.tsx +58 -0
  25. package/src/components/compare/CompareViewRoute.tsx +5 -1
  26. package/src/components/compare/useCompareCandidates.ts +1 -1
  27. package/src/components/compare/useCompareLauncher.tsx +4 -2
  28. package/src/components/diagnose/DiagnoseSurface.tsx +3 -3
  29. package/src/components/diagnose/InvestigationChangesEvidence.test.tsx +352 -0
  30. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +101 -0
  31. package/src/components/diagnose/InvestigationView.tsx +2 -1
  32. package/src/components/diagnose/StoryExcerpt.tsx +24 -5
  33. package/src/components/diagnose/investigationEvidence/adapters/changes.test.ts +123 -0
  34. package/src/components/diagnose/investigationEvidence/adapters/changes.ts +192 -3
  35. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +73 -51
  36. package/src/components/diagnose/investigationEvidence/adapters/listCoverage.test.ts +415 -0
  37. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +64 -2
  38. package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +37 -0
  39. package/src/components/diagnose/investigationEvidence/adapters/resource.ts +107 -8
  40. package/src/components/diagnose/investigationEvidence/adapters/testdata/get-changes-created.json +323 -0
  41. package/src/components/diagnose/investigationEvidence/bodies/inventory.tsx +66 -16
  42. package/src/components/diagnose/investigationEvidence/bodies/streams.tsx +144 -15
  43. package/src/components/diagnose/investigationEvidence/builder.ts +13 -1
  44. package/src/components/diagnose/investigationEvidence/excerpt.ts +2 -0
  45. package/src/components/diagnose/investigationEvidence/observations.ts +21 -0
  46. package/src/components/diagnose/investigationEvidence/parse.ts +57 -1
  47. package/src/components/diagnose/investigationEvidence/projection.test.ts +131 -1
  48. package/src/components/diagnose/investigationEvidence/types.ts +26 -0
  49. package/src/components/diagnose/investigationEvidencePresentation.test.ts +18 -0
  50. package/src/components/diagnose/investigationState.test.ts +36 -1
  51. package/src/components/diagnose/investigationState.ts +8 -0
  52. package/src/components/diagnose/launch.ts +2 -2
  53. package/src/components/diagnose/toolCallLabel.test.ts +9 -0
  54. package/src/components/diagnose/toolCallLabel.ts +2 -0
  55. package/src/components/dock/BottomDock.tsx +6 -3
  56. package/src/components/dock/WorkloadLogsTab.tsx +3 -0
  57. package/src/components/execution/BatchExecutionView.image-browse.test.tsx +46 -0
  58. package/src/components/execution/BatchExecutionView.render.test.tsx +29 -1
  59. package/src/components/execution/BatchExecutionView.tsx +28 -11
  60. package/src/components/execution/cluster-template-runs.render.test.tsx +42 -0
  61. package/src/components/gitops/GitOpsView.identity.test.tsx +113 -0
  62. package/src/components/gitops/GitOpsView.tsx +69 -40
  63. package/src/components/gitops/useDestinationCluster.ts +2 -1
  64. package/src/components/helm/ArtifactHubSourceSearch.test.tsx +124 -0
  65. package/src/components/helm/ArtifactHubSourceSearch.tsx +240 -0
  66. package/src/components/helm/ChartBrowser.tsx +5 -4
  67. package/src/components/helm/HelmReleaseDrawer.tsx +139 -55
  68. package/src/components/helm/HelmReleaseNotes.test.tsx +42 -0
  69. package/src/components/helm/HelmReleaseNotes.tsx +26 -0
  70. package/src/components/helm/OwnedResources.tsx +2 -2
  71. package/src/components/helm/TrackChartSourceDialog.render.test.tsx +295 -50
  72. package/src/components/helm/TrackChartSourceDialog.test.ts +3 -2
  73. package/src/components/helm/TrackChartSourceDialog.tsx +614 -85
  74. package/src/components/helm/ValuesDiffPreview.tsx +4 -1
  75. package/src/components/home/ClusterHealthCard.tsx +4 -4
  76. package/src/components/home/CostCard.test.tsx +100 -0
  77. package/src/components/home/CostCard.tsx +2 -2
  78. package/src/components/home/HelmSummary.tsx +2 -2
  79. package/src/components/home/HomeView.tsx +15 -6
  80. package/src/components/home/MCPSetupDialog.test.tsx +30 -0
  81. package/src/components/home/MCPSetupDialog.tsx +13 -6
  82. package/src/components/home/ProblemsPanel.test.tsx +1 -0
  83. package/src/components/home/mcpToolCatalog.ts +28 -2
  84. package/src/components/issues/IssuesPane.render.test.tsx +21 -0
  85. package/src/components/issues/IssuesPane.tsx +31 -7
  86. package/src/components/issues/UncheckedSourceHelp.test.tsx +42 -0
  87. package/src/components/issues/UncheckedSourceHelp.tsx +24 -0
  88. package/src/components/issues/uncheckedSources.test.ts +43 -0
  89. package/src/components/issues/uncheckedSources.ts +58 -5
  90. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +4 -2
  91. package/src/components/resource/PrometheusCharts.overlays.test.ts +45 -0
  92. package/src/components/resource/PrometheusCharts.tsx +2 -2
  93. package/src/components/resources/ImageFilesystemModal.test.tsx +68 -0
  94. package/src/components/resources/ImageFilesystemModal.tsx +11 -4
  95. package/src/components/resources/PodFilesystemModal.tsx +2 -2
  96. package/src/components/resources/ResourcesView.scope.render.test.tsx +58 -0
  97. package/src/components/resources/ResourcesView.tsx +46 -69
  98. package/src/components/resources/renderers/FluxHelmReleaseRenderer.test.tsx +111 -0
  99. package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +67 -0
  100. package/src/components/resources/renderers/KyvernoPolicyCoverage.scope.render.test.tsx +64 -0
  101. package/src/components/resources/renderers/KyvernoPolicyCoverage.tsx +6 -7
  102. package/src/components/resources/renderers/PodRenderer.tsx +4 -1
  103. package/src/components/settings/MyPermissionsDialog.tsx +12 -9
  104. package/src/components/settings/SettingsDialog.tsx +21 -15
  105. package/src/components/traffic/TrafficFilterSidebar.test.tsx +77 -0
  106. package/src/components/traffic/TrafficFilterSidebar.tsx +42 -31
  107. package/src/components/traffic/TrafficSourcePill.test.tsx +110 -0
  108. package/src/components/traffic/TrafficSourcePill.tsx +111 -0
  109. package/src/components/traffic/TrafficView.tsx +21 -67
  110. package/src/components/traffic/trafficFilters.test.ts +20 -1
  111. package/src/components/traffic/trafficFilters.ts +13 -0
  112. package/src/components/ui/DiagnosticsOverlay.test.ts +25 -0
  113. package/src/components/ui/DiagnosticsOverlay.tsx +2 -1
  114. package/src/components/ui/Omnibar.note.test.tsx +141 -0
  115. package/src/components/ui/Omnibar.tsx +89 -14
  116. package/src/components/ui/RadarOmnibar.test.tsx +183 -0
  117. package/src/components/ui/RadarOmnibar.tsx +38 -4
  118. package/src/components/ui/Toast.tsx +1 -1
  119. package/src/components/ui/UpdateNotification.manual.test.tsx +177 -0
  120. package/src/components/ui/UpdateNotification.test.tsx +2 -1
  121. package/src/components/ui/UpdateNotification.tsx +29 -5
  122. package/src/components/ui/omnibar-match.test.ts +37 -0
  123. package/src/components/ui/omnibar-match.ts +23 -0
  124. package/src/components/ui/searchCoverage.fixtures.ts +16 -0
  125. package/src/components/ui/searchCoverageNote.test.ts +245 -0
  126. package/src/components/ui/searchCoverageNote.ts +222 -0
  127. package/src/components/whats-new/WhatsNew.test.ts +10 -0
  128. package/src/components/whats-new/WhatsNew.tsx +5 -4
  129. package/src/components/whats-new/WhatsNewDialog.test.tsx +20 -0
  130. package/src/components/whats-new/releaseNotes.ts +57 -5
  131. package/src/components/workload/CronJobSchedulingEvidence.test.tsx +35 -0
  132. package/src/components/workload/CronJobSchedulingEvidence.tsx +37 -0
  133. package/src/components/workload/NodeDrainStatus.test.tsx +253 -0
  134. package/src/components/workload/NodeDrainStatus.tsx +55 -0
  135. package/src/components/workload/WorkloadView.tsx +43 -5
  136. package/src/context/ConnectionContext.test.ts +27 -1
  137. package/src/context/ConnectionContext.tsx +17 -7
  138. package/src/hooks/useResourceCounts.ts +2 -0
  139. package/src/index.css +2 -4
  140. package/src/index.ts +7 -0
  141. package/src/integrations/resourceHosts.test.tsx +1 -0
  142. package/src/integrations/resourceHosts.tsx +2 -0
  143. package/src/utils/artifacthub.test.ts +18 -0
  144. package/src/utils/artifacthub.ts +9 -0
  145. package/src/utils/navigation.ts +14 -0
  146. package/src/utils/wails-clipboard.ts +4 -2
@@ -1,13 +1,16 @@
1
1
  import { VISIBLE_LOG_EVIDENCE_LINES } from "../excerpt";
2
- import { useContext } from "react";
2
+ import { Fragment, useContext } from "react";
3
3
  import {
4
+ AlertBanner,
4
5
  Badge,
5
6
  DiffViewer,
6
7
  TerminalBlock,
7
8
  formatRelativeAgeTime,
9
+ pluralize,
8
10
  ResourceLink,
9
11
  stripAnsi,
10
12
  } from "@skyhook-io/k8s-ui";
13
+ import { builtinGroupForKind } from "@skyhook-io/k8s-ui/utils/api-resources";
11
14
  import { apiVersionToGroup } from "../../../../utils/navigation";
12
15
  import { Tooltip } from "../../../ui/Tooltip";
13
16
  import { EvidenceNavigationContext } from "../navigation";
@@ -133,6 +136,49 @@ export function EventsBody({ data }: { data: EvidenceDataOf<"events"> }) {
133
136
  );
134
137
  }
135
138
 
139
+ // The producer caps consumed_by and running_previous_value.workloads at five
140
+ // (maxConsumersPerEntry), so a full list may not be the whole set.
141
+ const REFERENCE_LIST_CAP = 5;
142
+
143
+ function ChangeReferences({
144
+ references,
145
+ namespace,
146
+ }: {
147
+ references: string[];
148
+ namespace?: string;
149
+ }) {
150
+ const { onOpenResource } = useContext(EvidenceNavigationContext);
151
+ return references.map((reference) => {
152
+ const slash = reference.indexOf("/");
153
+ const kind = reference.slice(0, slash);
154
+ const name = reference.slice(slash + 1);
155
+ // The producer names only Kind/name, so a link is safe only for kinds
156
+ // whose group is known and a row with a namespace; a CRD owner such as a
157
+ // CNPG Cluster stays text.
158
+ const group =
159
+ kind === "Rollout" ? "argoproj.io" : builtinGroupForKind(kind);
160
+ return (
161
+ <span
162
+ key={reference}
163
+ className="min-w-0 max-w-full font-mono [overflow-wrap:anywhere]"
164
+ >
165
+ {group === undefined || !namespace ? (
166
+ reference
167
+ ) : (
168
+ <ResourceLink
169
+ name={name}
170
+ kind={kind}
171
+ namespace={namespace}
172
+ group={group}
173
+ label={reference}
174
+ onNavigate={onOpenResource}
175
+ />
176
+ )}
177
+ </span>
178
+ );
179
+ });
180
+ }
181
+
136
182
  export function ChangesBody({ data }: { data: EvidenceDataOf<"changes"> }) {
137
183
  const { onOpenResource } = useContext(EvidenceNavigationContext);
138
184
  return (
@@ -145,13 +191,13 @@ export function ChangesBody({ data }: { data: EvidenceDataOf<"changes"> }) {
145
191
  {data.changes.map((change, index) => (
146
192
  <div
147
193
  key={`${change.kind}-${change.namespace ?? ""}-${change.name}-${change.timestamp}-${index}`}
148
- className="rounded-md border border-theme-border/70 bg-theme-base/30 p-2.5"
194
+ className="min-w-0 rounded-md border border-theme-border/70 bg-theme-base/30 p-2.5 [overflow-wrap:anywhere]"
149
195
  >
150
196
  <div className="flex flex-wrap items-center gap-1.5">
151
197
  <Badge tone="structural" size="sm">
152
198
  {change.kind}
153
199
  </Badge>
154
- <span className="font-mono text-xs">
200
+ <span className="min-w-0 max-w-full font-mono text-xs">
155
201
  <ResourceLink
156
202
  name={change.name}
157
203
  kind={change.kind}
@@ -172,25 +218,108 @@ export function ChangesBody({ data }: { data: EvidenceDataOf<"changes"> }) {
172
218
  <Badge tone="note" size="sm">
173
219
  {change.changeType.replaceAll("_", " ")}
174
220
  </Badge>
175
- <Tooltip
176
- content={new Date(change.timestamp).toLocaleString()}
177
- delay={150}
178
- position="left"
179
- wrapperClassName="ml-auto"
180
- >
181
- <time
182
- dateTime={change.timestamp}
183
- className="text-xs text-theme-text-tertiary"
221
+ <div className="ml-auto flex min-w-0 flex-wrap items-center gap-1.5">
222
+ {(change.updates_in_window ?? 0) > 1 ? (
223
+ <Badge
224
+ tone="structural"
225
+ size="sm"
226
+ className="max-w-full whitespace-normal"
227
+ >
228
+ {change.updates_in_window} updates
229
+ {change.first_update_at
230
+ ? `, first ${formatRelativeAgeTime(change.first_update_at)}`
231
+ : ""}
232
+ </Badge>
233
+ ) : null}
234
+ <Tooltip
235
+ content={new Date(change.timestamp).toLocaleString()}
236
+ delay={150}
237
+ position="left"
184
238
  >
185
- {formatRelativeAgeTime(change.timestamp)}
186
- </time>
187
- </Tooltip>
239
+ <time
240
+ dateTime={change.timestamp}
241
+ className="text-xs text-theme-text-tertiary"
242
+ >
243
+ {formatRelativeAgeTime(change.timestamp)}
244
+ </time>
245
+ </Tooltip>
246
+ </div>
188
247
  </div>
189
248
  {change.summary ? (
190
249
  <p className="mt-1.5 text-xs text-theme-text-secondary">
191
250
  {change.summary}
192
251
  </p>
193
252
  ) : null}
253
+ {change.running_previous_value ? (
254
+ <AlertBanner
255
+ variant="warning"
256
+ className="mt-2"
257
+ title={`${pluralize(change.running_previous_value.pods, "Pod")} likely still ${change.running_previous_value.pods === 1 ? "holds" : "hold"} the earlier value`}
258
+ >
259
+ <div className="mt-1 space-y-1.5 text-xs text-theme-text-secondary">
260
+ <p>
261
+ Changed keys read as env:{" "}
262
+ {change.running_previous_value.keys.map((key, keyIndex) => (
263
+ <Fragment key={key}>
264
+ {keyIndex > 0 ? ", " : null}
265
+ <Badge
266
+ tone="structural"
267
+ size="sm"
268
+ className="max-w-full whitespace-normal font-mono [overflow-wrap:anywhere]"
269
+ >
270
+ {key}
271
+ </Badge>
272
+ </Fragment>
273
+ ))}
274
+ </p>
275
+ {(change.running_previous_value.workloads ?? []).length > 0 ? (
276
+ <div className="flex min-w-0 flex-wrap gap-x-2 gap-y-1">
277
+ <span>In workloads you can view:</span>
278
+ <ChangeReferences
279
+ references={change.running_previous_value.workloads ?? []}
280
+ namespace={change.namespace}
281
+ />
282
+ {(change.running_previous_value.workloads ?? []).length >=
283
+ REFERENCE_LIST_CAP ? (
284
+ <span>(first {REFERENCE_LIST_CAP})</span>
285
+ ) : null}
286
+ {change.running_previous_value.withheld ? (
287
+ <span>
288
+ +{change.running_previous_value.withheld.count} more
289
+ you can&apos;t view
290
+ </span>
291
+ ) : null}
292
+ </div>
293
+ ) : (
294
+ <p>
295
+ {change.running_previous_value.withheld
296
+ ? `In ${pluralize(change.running_previous_value.withheld.count, "workload")} you can't view`
297
+ : "workload names hidden by your permissions"}
298
+ </p>
299
+ )}
300
+ <p>{change.running_previous_value.note}</p>
301
+ </div>
302
+ </AlertBanner>
303
+ ) : null}
304
+ {change.consumed_by?.length || change.consumed_by_withheld ? (
305
+ <div className="mt-1.5 flex min-w-0 flex-wrap gap-x-2 gap-y-1 text-xs text-theme-text-secondary">
306
+ <span>Referenced by</span>
307
+ <ChangeReferences
308
+ references={change.consumed_by ?? []}
309
+ namespace={change.namespace}
310
+ />
311
+ {(change.consumed_by?.length ?? 0) >= REFERENCE_LIST_CAP ? (
312
+ <span>(first {REFERENCE_LIST_CAP})</span>
313
+ ) : null}
314
+ {change.consumed_by_withheld ? (
315
+ <span>
316
+ {change.consumed_by?.length
317
+ ? `+${change.consumed_by_withheld.count} more you can't view`
318
+ : `${pluralize(change.consumed_by_withheld.count, "workload")} you can't view`}
319
+ </span>
320
+ ) : null}
321
+ </div>
322
+ ) : null}
194
323
  {change.fields?.length ? (
195
324
  <div className="mt-2">
196
325
  <DiffViewer
@@ -203,7 +203,7 @@ export function projectInvestigationEvidence(
203
203
  builder.limit(
204
204
  source,
205
205
  investigationResultLabel(source),
206
- item.result || "This investigation step failed.",
206
+ failedStepMessage(item.result) || "This investigation step failed.",
207
207
  "error",
208
208
  );
209
209
  continue;
@@ -440,3 +440,15 @@ export function projectInvestigationEvidence(
440
440
  },
441
441
  };
442
442
  }
443
+
444
+ // A resource read's failure arrives as its JSON body ({error, error_code,
445
+ // coverage?}); Findings shows the explanation, not the JSON.
446
+ export function failedStepMessage(
447
+ result: string | undefined,
448
+ ): string | undefined {
449
+ if (!result) return result;
450
+ const body = record(parseJSON(result));
451
+ return nonEmptyString(body?.error) && typeof body.error_code === "string"
452
+ ? body.error
453
+ : result;
454
+ }
@@ -71,6 +71,8 @@ export function storyExcerpt(
71
71
  data.resources as InvestigationResourceSummary[],
72
72
  items,
73
73
  options.scopeNamespace,
74
+ data.namespacesRead,
75
+ data.namespacesReadOmitted,
74
76
  );
75
77
  return entries.length > 0 ? { kind: "rows", entries } : undefined;
76
78
  }
@@ -182,6 +182,7 @@ const INVESTIGATION_RESULT_LABELS: Readonly<Record<string, string>> = {
182
182
  get_neighborhood: "Relationships",
183
183
  get_topology: "Topology",
184
184
  get_workload_logs: "Workload logs",
185
+ wait_for: "Wait",
185
186
  get_prometheus_rules: "Alert rules",
186
187
  get_helm_release: "Helm release",
187
188
  get_subject_permissions: "Permissions",
@@ -189,6 +190,7 @@ const INVESTIGATION_RESULT_LABELS: Readonly<Record<string, string>> = {
189
190
  top_resources: "Resource ranking",
190
191
  get_cluster_audit: "Posture findings",
191
192
  get_cluster_upgrade_readiness: "Upgrade readiness",
193
+ get_runtime_versions: "Runtime versions",
192
194
  list_helm_releases: "Helm releases",
193
195
  list_packages: "Installed packages",
194
196
  search: "Search results",
@@ -700,6 +702,11 @@ export function addResourceObservation(
700
702
  : warnings.length > 0
701
703
  ? "warning"
702
704
  : "neutral";
705
+ // A Pod/template difference is listed with the warnings but does not set
706
+ // the tone: admission defaults (LimitRange, injected sidecars) produce it on
707
+ // healthy Pods.
708
+ const divergence = templateDivergenceWarning(context);
709
+ if (divergence) warnings = [...warnings, divergence];
703
710
  const namespace = resource.metadata.namespace;
704
711
  const identity = `${resource.apiVersion}:${resource.kind}:${namespace ?? ""}:${resource.metadata.name}`;
705
712
  builder.observe(identity, "resource", source, {
@@ -724,6 +731,20 @@ export function addResourceObservation(
724
731
  });
725
732
  addResourceContextLimitations(builder, source, context);
726
733
  }
734
+ // The live Pod spec differing from its template is context, not a fault, so
735
+ // it reads as a line on the resource card rather than a finding of its own.
736
+ function templateDivergenceWarning(
737
+ context: InvestigationResourceContext | undefined,
738
+ ): string | undefined {
739
+ const divergence = context?.templateDivergence;
740
+ const first = divergence?.differences?.[0];
741
+ if (!divergence || !nonEmptyString(first)) return undefined;
742
+ const scope = divergence.examplePod
743
+ ? `${divergence.podsDiffering} of ${divergence.podsCompared} compared Pods${divergence.podsCapped ? " (the most recent)" : ""} differ from their template${divergence.podsNotCompared ? `, ${divergence.podsNotCompared} more not compared` : ""}`
744
+ : "Live Pod spec differs from its template";
745
+ const more = divergence.differences.length > 1 ? " (and more)" : "";
746
+ return `${scope}: ${first}${more}`;
747
+ }
727
748
  export function addIssueObservation(
728
749
  builder: ProjectionBuilder,
729
750
  source: InvestigationEvidenceSource,
@@ -2,6 +2,7 @@ import {
2
2
  type Issue,
3
3
  type IssueRecentChange,
4
4
  stripAnsi,
5
+ type IssueWithheld,
5
6
  } from "@skyhook-io/k8s-ui";
6
7
  import { type TimeSeries } from "@skyhook-io/k8s-ui/components/charts";
7
8
  import {
@@ -186,7 +187,62 @@ export function recentChange(value: unknown): IssueRecentChange | undefined {
186
187
  ) {
187
188
  return undefined;
188
189
  }
189
- return candidate as unknown as IssueRecentChange;
190
+ const {
191
+ running_previous_value,
192
+ updates_in_window,
193
+ first_update_at,
194
+ consumed_by,
195
+ consumed_by_withheld,
196
+ ...change
197
+ } = candidate;
198
+ const running = record(running_previous_value);
199
+ const workloads =
200
+ running?.workloads === null ? [] : stringArray(running?.workloads);
201
+ const keys = stringArray(running?.keys);
202
+ const consumers = stringArray(consumed_by);
203
+ const runningWithheld = withheld(running?.withheld);
204
+ const consumersWithheld = withheld(consumed_by_withheld);
205
+ return {
206
+ ...change,
207
+ ...(running &&
208
+ workloads &&
209
+ keys &&
210
+ nonNegativeInteger(running.pods) &&
211
+ typeof running.note === "string"
212
+ ? {
213
+ running_previous_value: {
214
+ workloads,
215
+ ...(runningWithheld ? { withheld: runningWithheld } : {}),
216
+ pods: running.pods,
217
+ keys,
218
+ note: running.note,
219
+ },
220
+ }
221
+ : {}),
222
+ ...(nonNegativeInteger(updates_in_window) && updates_in_window > 0
223
+ ? { updates_in_window }
224
+ : {}),
225
+ ...(typeof first_update_at === "string" &&
226
+ Number.isFinite(Date.parse(first_update_at))
227
+ ? { first_update_at }
228
+ : {}),
229
+ ...(consumers ? { consumed_by: consumers } : {}),
230
+ ...(consumersWithheld ? { consumed_by_withheld: consumersWithheld } : {}),
231
+ } as unknown as IssueRecentChange;
232
+ }
233
+
234
+ // withheld keeps a well-formed {count, reason} marker; anything else drops it.
235
+ function withheld(value: unknown): IssueWithheld | undefined {
236
+ const candidate = record(value);
237
+ if (
238
+ !candidate ||
239
+ !nonNegativeInteger(candidate.count) ||
240
+ candidate.count === 0 ||
241
+ !nonEmptyString(candidate.reason)
242
+ ) {
243
+ return undefined;
244
+ }
245
+ return { count: candidate.count, reason: candidate.reason };
190
246
  }
191
247
  export function diagnosisChangeContext(
192
248
  value: unknown,
@@ -1,5 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import { projectInvestigationEvidence } from "./index";
3
+ import { failedStepMessage } from "./builder";
3
4
  import {
4
5
  completeLogProof,
5
6
  criticalIssue,
@@ -263,6 +264,45 @@ describe("strict evidence adapters", () => {
263
264
  }),
264
265
  ]);
265
266
 
267
+ const evictedIssueFeed = project([
268
+ tool("issues-evicted", "issues", {
269
+ issues: [],
270
+ total: 0,
271
+ total_matched: 0,
272
+ recent_changes_history_coverage: {
273
+ incomplete: true,
274
+ reasons: ["events_evicted"],
275
+ },
276
+ }),
277
+ ]);
278
+ expect(evictedIssueFeed.limitations).toEqual([
279
+ expect.objectContaining({
280
+ source: "Issue-related changes",
281
+ kind: "unknown",
282
+ message: expect.stringContaining("incomplete for part of the window"),
283
+ }),
284
+ ]);
285
+ // Incomplete change history limits the change feed, not the live scan.
286
+ expect(groupsOf(evictedIssueFeed.groups, "receipt")).toHaveLength(1);
287
+
288
+ // So does a saturated change fetch whose rows were all discarded.
289
+ const saturatedIssueFeed = project([
290
+ tool("issues-saturated", "issues", {
291
+ issues: [],
292
+ total: 0,
293
+ total_matched: 0,
294
+ recent_changes_reason: "no_critical_issues",
295
+ recent_changes_truncated: true,
296
+ }),
297
+ ]);
298
+ expect(saturatedIssueFeed.limitations).toEqual([
299
+ expect.objectContaining({
300
+ source: "Issue-related changes",
301
+ kind: "truncated",
302
+ }),
303
+ ]);
304
+ expect(groupsOf(saturatedIssueFeed.groups, "receipt")).toHaveLength(1);
305
+
266
306
  const filtered = project([
267
307
  tool("filtered", "get_resource", {
268
308
  resource: deployment,
@@ -1988,6 +2028,74 @@ describe("honest zero and partial-result states", () => {
1988
2028
  });
1989
2029
  });
1990
2030
 
2031
+ it("shows cluster-scoped admission changes with why each one is listed", () => {
2032
+ const webhook = {
2033
+ kind: "MutatingWebhookConfiguration",
2034
+ apiVersion: "admissionregistration.k8s.io/v1",
2035
+ name: "gatekeeper-mutating-webhook-configuration",
2036
+ changeType: "add",
2037
+ timestamp: "2026-09-02T09:55:00Z",
2038
+ applicability: "applies",
2039
+ applies_because:
2040
+ "webhook mutation.gatekeeper.sh has a namespaceSelector matching namespace shop's labels and its rules cover namespaced resources",
2041
+ };
2042
+ const result = project([
2043
+ tool("changes", "get_changes", {
2044
+ changes: [],
2045
+ clusterScopedChanges: {
2046
+ kinds: ["MutatingWebhookConfiguration"],
2047
+ window_seconds: 3600,
2048
+ changes: [webhook],
2049
+ not_listed: [
2050
+ "ValidatingWebhookConfiguration policy (add at 2026-09-02T09:50:00Z)",
2051
+ ],
2052
+ incomplete: "Current webhook configurations are not cached.",
2053
+ },
2054
+ }),
2055
+ tool("issues", "issues", {
2056
+ issues: [],
2057
+ total: 0,
2058
+ total_matched: 0,
2059
+ cluster_scoped_changes: {
2060
+ changes: [{ ...webhook, applies_because: "" }],
2061
+ },
2062
+ }),
2063
+ ]);
2064
+ const rows = groupsOf(result.groups, "changes").map(
2065
+ (group) => group.latest.data,
2066
+ );
2067
+ expect(rows).toHaveLength(1);
2068
+ const data = rows[0];
2069
+ expect(data.type).toBe("changes");
2070
+ if (data.type === "changes") {
2071
+ expect(data.changes[0].summary).toBe(
2072
+ "Applies: webhook mutation.gatekeeper.sh has a namespaceSelector matching namespace shop's labels and its rules cover namespaced resources",
2073
+ );
2074
+ }
2075
+ expect(result.limitations).toEqual(
2076
+ expect.arrayContaining([
2077
+ expect.objectContaining({
2078
+ source: "Cluster-scoped admission changes",
2079
+ kind: "truncated",
2080
+ }),
2081
+ expect.objectContaining({
2082
+ source: "Cluster-scoped admission changes",
2083
+ kind: "unknown",
2084
+ }),
2085
+ ]),
2086
+ );
2087
+ // A row without its reason is malformed, not silently shown.
2088
+ expect(result.limitations).toEqual(
2089
+ expect.arrayContaining([
2090
+ expect.objectContaining({
2091
+ source: "Cluster-scoped admission changes",
2092
+ message:
2093
+ "Radar couldn't summarize this investigation step. Review it in Activity.",
2094
+ }),
2095
+ ]),
2096
+ );
2097
+ });
2098
+
1991
2099
  it("creates receipts only for confirmed complete zero-result reads", () => {
1992
2100
  const result = project([
1993
2101
  tool("diagnose", "diagnose", {
@@ -2158,7 +2266,7 @@ describe("honest zero and partial-result states", () => {
2158
2266
  truncated: true,
2159
2267
  narrowHint: "subgraph capped at 25 nodes",
2160
2268
  omitted: [
2161
- { field: "uses.secrets", reason: "rbac_denied" },
2269
+ { field: "uses.secrets", reason: "user_forbidden" },
2162
2270
  { field: "referencedBy", reason: "budget_exceeded" },
2163
2271
  ],
2164
2272
  }),
@@ -2750,3 +2858,25 @@ describe("namespace listings", () => {
2750
2858
  ).toEqual(["capi-system", "shop"]);
2751
2859
  });
2752
2860
  });
2861
+
2862
+ describe("failedStepMessage", () => {
2863
+ it("shows a coded read failure's explanation, not its JSON body", () => {
2864
+ const body = JSON.stringify({
2865
+ error:
2866
+ 'namespace "beta" is not among the namespaces you can see, or does not exist',
2867
+ error_code: "user_namespace_not_visible",
2868
+ coverage: { status: "partial", scope: { type: "namespaces" }, gaps: [] },
2869
+ });
2870
+ expect(failedStepMessage(body)).toBe(
2871
+ 'namespace "beta" is not among the namespaces you can see, or does not exist',
2872
+ );
2873
+ });
2874
+ it("keeps any other failure text as it came", () => {
2875
+ expect(failedStepMessage("user_forbidden: your role cannot list pods")).toBe(
2876
+ "user_forbidden: your role cannot list pods",
2877
+ );
2878
+ expect(failedStepMessage('{"error":"no code"}')).toBe(
2879
+ '{"error":"no code"}',
2880
+ );
2881
+ });
2882
+ });
@@ -111,6 +111,17 @@ export interface InvestigationResourceContext extends DiagnosisResourceContext {
111
111
  };
112
112
  policySummary?: unknown;
113
113
  podSummary?: unknown;
114
+ templateDivergence?: {
115
+ summary: string;
116
+ podsCompared: number;
117
+ podsDiffering: number;
118
+ podsCapped?: boolean;
119
+ podsNotCompared?: number;
120
+ examplePod?: string;
121
+ baseline?: string;
122
+ differences: string[];
123
+ sources?: string[];
124
+ };
114
125
  }
115
126
  export interface InvestigationGitOpsDiagnosis {
116
127
  tool: "argocd" | "flux";
@@ -448,6 +459,21 @@ export type InvestigationEvidenceData =
448
459
  type: "inventory";
449
460
  resources: InvestigationResourceSummary[];
450
461
  scope: string;
462
+ /**
463
+ * Set only when Radar's collector read the kind in just these
464
+ * namespaces: a name missing from the rows is unknown outside them.
465
+ */
466
+ namespacesRead?: string[];
467
+ /**
468
+ * Namespaces read that the listing doesn't name, because there were too
469
+ * many to list; they were read, so they are not a gap.
470
+ */
471
+ namespacesReadOmitted?: number;
472
+ /**
473
+ * Radar's own sentence for a partial or narrowed list: what it didn't
474
+ * read and why, shown with the rows so they never read as everything.
475
+ */
476
+ coverageNote?: string;
451
477
  }
452
478
  | {
453
479
  type: "ranking";
@@ -177,6 +177,24 @@ describe("evidence display significance (not record identity)", () => {
177
177
  evidenceDisplaySnapshot(different),
178
178
  );
179
179
  });
180
+ it("keeps a since-creation condition warning stable and distinct from a regression", () => {
181
+ const snapshot = (warning: string) =>
182
+ evidenceDisplaySnapshot(
183
+ observation({ type: "resource", resource, warnings: [warning] }),
184
+ );
185
+ const sinceCreation = (elapsed: string) =>
186
+ snapshot(
187
+ "Condition `Ready=False` for ~" +
188
+ elapsed +
189
+ " — since about when this resource was created (resource age: " +
190
+ elapsed +
191
+ ").",
192
+ );
193
+ expect(sinceCreation("20s")).toBe(sinceCreation("1m5s"));
194
+ expect(sinceCreation("20s")).not.toBe(
195
+ snapshot("Condition `Ready=False` for ~20s (resource age: 1h)."),
196
+ );
197
+ });
180
198
  it("tolerates unstructured conditions without deleting their contents", () => {
181
199
  const value = {
182
200
  ...resource,
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { DiagnoseError } from "../../api/diagnose";
2
+ import { DiagnoseError, type RunSummary } from "../../api/diagnose";
3
3
  import {
4
4
  canOfferInvestigationApply,
5
5
  initialInvestigationPane,
@@ -28,6 +28,7 @@ import {
28
28
  investigationHealthSignals,
29
29
  investigationSettledAnswerTurnIndexes,
30
30
  investigationIsAssessmentTurn,
31
+ readOnlyNotice,
31
32
  } from "./investigationState";
32
33
 
33
34
  describe("investigation terminal presentation", () => {
@@ -1355,3 +1356,37 @@ describe("investigationFailureShown", () => {
1355
1356
  });
1356
1357
  });
1357
1358
  });
1359
+
1360
+ describe("readOnlyNotice", () => {
1361
+ const base: RunSummary = {
1362
+ id: "r1",
1363
+ kind: "Deployment",
1364
+ group: "apps",
1365
+ namespace: "prod",
1366
+ name: "payments",
1367
+ context: "prod-cluster",
1368
+ status: "done",
1369
+ createdAt: "2026-01-01T00:00:00Z",
1370
+ updatedAt: "2026-01-01T00:00:00Z",
1371
+ canContinue: false,
1372
+ };
1373
+
1374
+ it("shows the host's reason a run can't take a follow-up", () => {
1375
+ expect(
1376
+ readOnlyNotice({
1377
+ ...base,
1378
+ continueBlockedReason:
1379
+ "This conversation can't be continued. Start a new investigation to ask more.",
1380
+ }),
1381
+ ).toBe(
1382
+ "This conversation can't be continued. Start a new investigation to ask more.",
1383
+ );
1384
+ });
1385
+
1386
+ it("falls back to the generic notice without one", () => {
1387
+ expect(readOnlyNotice(base)).toBe("This investigation is read-only.");
1388
+ expect(readOnlyNotice({ ...base, continueBlockedReason: " " })).toBe(
1389
+ "This investigation is read-only.",
1390
+ );
1391
+ });
1392
+ });
@@ -819,6 +819,14 @@ export function canContinueInvestigation(
819
819
  );
820
820
  }
821
821
 
822
+ // readOnlyNotice is what an interactive run that can't take a follow-up shows
823
+ // where the follow-up box would be: the host's reason when it gave one.
824
+ export function readOnlyNotice(run: RunSummary): string {
825
+ return (
826
+ run.continueBlockedReason?.trim() || "This investigation is read-only."
827
+ );
828
+ }
829
+
822
830
  export function canInvestigateFurther(run: RunSummary, gone = false): boolean {
823
831
  return (
824
832
  !gone &&
@@ -1,8 +1,8 @@
1
1
  // Builds the shell command that hands an investigation off to the user's own
2
2
  // interactive agent CLI, pointed at Radar's MCP. This is the "escape hatch" to the
3
3
  // full agent (their config, their other MCPs, interactive approvals) — distinct
4
- // from the contained in-panel engine. The launched agent gets the full /mcp mount
5
- // (read+write); its own per-tool approval prompts gate any changes.
4
+ // from the contained in-panel engine. The endpoint follows the server MCP mode.
5
+ // In full mode, the client approval prompts gate changes.
6
6
  import { type RunSummary } from "../../api/diagnose";
7
7
 
8
8
  // sq POSIX-single-quotes a string so it's a safe single shell argument regardless