@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
@@ -0,0 +1,123 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { groupsOf, project, tool } from "../evidenceFixtures";
3
+ import fixture from "./testdata/get-changes-created.json";
4
+ import { createdChanges } from "./changes";
5
+
6
+ // The fixture is written by the Go test TestCompactCreatesSharedFixture from
7
+ // the producer's own CompactCreates, so this checks both ends of the contract.
8
+ function cardChanges(result: unknown) {
9
+ const projection = project([tool("changes", "get_changes", result)]);
10
+ const group = groupsOf(projection.groups, "changes")[0];
11
+ const data = group?.latest.data;
12
+ return { projection, changes: data?.type === "changes" ? data.changes : [] };
13
+ }
14
+
15
+ describe("get_changes created runs", () => {
16
+ it("expand into the exact rows and order the producer replaced", () => {
17
+ const original = cardChanges(fixture.original);
18
+ const compacted = cardChanges(fixture.compacted);
19
+ expect(compacted.changes).toEqual(original.changes);
20
+ expect(compacted.changes).toHaveLength(fixture.original.changes.length);
21
+ expect(compacted.projection.limitations).toEqual(
22
+ original.projection.limitations,
23
+ );
24
+ });
25
+
26
+ it("rebuilds each timestamp in the zone of first", () => {
27
+ const rows = createdChanges([
28
+ {
29
+ namespace: "shop",
30
+ first: "2026-10-16T23:59:30+03:00",
31
+ count: 1,
32
+ objects: ["+41s Service/cart"],
33
+ },
34
+ ]);
35
+ expect(rows).toEqual([
36
+ {
37
+ changeType: "add",
38
+ summary: "add",
39
+ change_category: "lifecycle",
40
+ rank_reason: "resource create/delete for config or desired state",
41
+ kind: "Service",
42
+ namespace: "shop",
43
+ name: "cart",
44
+ timestamp: "2026-10-17T00:00:11+03:00",
45
+ },
46
+ ]);
47
+ });
48
+
49
+ it("expands an absent created field to no rows", () => {
50
+ expect(createdChanges(undefined)).toEqual([]);
51
+ });
52
+
53
+ it("rejects a malformed run instead of dropping its objects", () => {
54
+ for (const created of [
55
+ [
56
+ {
57
+ namespace: "shop",
58
+ first: "2026-10-16T04:43:24+03:00",
59
+ count: 1,
60
+ objects: ["Service/cart"],
61
+ },
62
+ ],
63
+ [
64
+ {
65
+ namespace: "shop",
66
+ first: "not a time",
67
+ count: 1,
68
+ objects: ["+0s Service/cart"],
69
+ },
70
+ ],
71
+ [
72
+ {
73
+ first: "2026-10-16T04:43:24+03:00",
74
+ count: 1,
75
+ objects: ["+0s Service/cart"],
76
+ },
77
+ ],
78
+ [
79
+ {
80
+ namespace: "shop",
81
+ first: "2026-10-16T04:43:24+03:00",
82
+ count: 1,
83
+ objects: ["+0s Service/cart"],
84
+ apiVersions: { Service: "" },
85
+ },
86
+ ],
87
+ [
88
+ {
89
+ namespace: "shop",
90
+ first: "2026-10-16T04:43:24+03:00",
91
+ count: 5,
92
+ objects: ["+0s Service/cart"],
93
+ },
94
+ ],
95
+ [
96
+ {
97
+ namespace: "shop",
98
+ first: "2026-02-30T04:43:24+03:00",
99
+ count: 1,
100
+ objects: ["+0s Service/cart"],
101
+ },
102
+ ],
103
+ [
104
+ {
105
+ namespace: "shop",
106
+ first: "2026-10-16T04:43:24+03:00",
107
+ count: 1,
108
+ objects: ["+99999999999999999999s Service/cart"],
109
+ },
110
+ ],
111
+ { namespace: "shop" },
112
+ ]) {
113
+ expect(createdChanges(created)).toBeUndefined();
114
+ const { projection } = cardChanges({ changes: [], created });
115
+ expect(groupsOf(projection.groups, "changes")).toHaveLength(0);
116
+ expect(projection.limitations).toEqual(
117
+ expect.arrayContaining([
118
+ expect.objectContaining({ source: "Recent changes" }),
119
+ ]),
120
+ );
121
+ }
122
+ });
123
+ });
@@ -8,7 +8,13 @@ import {
8
8
  scopeFromArgs,
9
9
  sourceArgsRelevance,
10
10
  } from "../observations";
11
- import { nonEmptyString, parseJSON, recentChange, record } from "../parse";
11
+ import {
12
+ nonEmptyString,
13
+ parseJSON,
14
+ recentChange,
15
+ record,
16
+ stringArray,
17
+ } from "../parse";
12
18
  import { type InvestigationEvidenceSource } from "../types";
13
19
 
14
20
  export function adaptChanges(
@@ -23,13 +29,15 @@ export function adaptChanges(
23
29
  invalidPayload(builder, source, "Recent changes");
24
30
  return;
25
31
  }
26
- const changes = changesRaw
32
+ const rows = changesRaw
27
33
  .map(recentChange)
28
34
  .filter((item): item is IssueRecentChange => Boolean(item));
29
- if (changes.length !== changesRaw.length) {
35
+ const created = createdChanges(value.created);
36
+ if (rows.length !== changesRaw.length || !created) {
30
37
  invalidPayload(builder, source, "Recent changes");
31
38
  return;
32
39
  }
40
+ const changes = mergeCreated(rows, created);
33
41
  addNarrowHint(builder, source, value);
34
42
  let sourceErrors = 0;
35
43
  if (Array.isArray(value.sourcesErrored)) {
@@ -57,4 +65,185 @@ export function adaptChanges(
57
65
  changesSubjectFromArgs(source),
58
66
  nonEmptyString(args?.since) ? args.since : undefined,
59
67
  );
68
+ addClusterScopedChanges(builder, source, value.clusterScopedChanges);
69
+ }
70
+
71
+ const CLUSTER_SCOPED_LABEL = "Cluster-scoped admission changes";
72
+
73
+ // Admission configuration changes that apply, or may apply, to the queried
74
+ // namespace. Each row's summary carries why it is listed, because the
75
+ // applicability is the point: the row itself is a cluster-scoped object.
76
+ export function addClusterScopedChanges(
77
+ builder: ProjectionBuilder,
78
+ source: InvestigationEvidenceSource,
79
+ payload: unknown,
80
+ ): void {
81
+ if (payload === undefined) return;
82
+ const value = record(payload);
83
+ const rowsRaw = value?.changes === null ? [] : value?.changes;
84
+ if (!value || !Array.isArray(rowsRaw)) {
85
+ invalidPayload(builder, source, CLUSTER_SCOPED_LABEL);
86
+ return;
87
+ }
88
+ const changes: IssueRecentChange[] = [];
89
+ for (const raw of rowsRaw) {
90
+ const change = recentChange(raw);
91
+ const row = record(raw);
92
+ if (!change || !row || !nonEmptyString(row.applies_because)) {
93
+ invalidPayload(builder, source, CLUSTER_SCOPED_LABEL);
94
+ return;
95
+ }
96
+ const applicability =
97
+ row.applicability === "applies" ? "Applies" : "May apply";
98
+ changes.push({
99
+ ...change,
100
+ summary: [change.summary, `${applicability}: ${row.applies_because}`]
101
+ .filter(Boolean)
102
+ .join(" · "),
103
+ });
104
+ }
105
+ if (nonEmptyString(value.error)) {
106
+ builder.limit(source, CLUSTER_SCOPED_LABEL, value.error, "error");
107
+ }
108
+ if (nonEmptyString(value.incomplete)) {
109
+ builder.limit(source, CLUSTER_SCOPED_LABEL, value.incomplete, "unknown");
110
+ }
111
+ const notListed = stringArray(value.not_listed) ?? [];
112
+ if (notListed.length > 0 || value.truncated === true) {
113
+ builder.limit(
114
+ source,
115
+ CLUSTER_SCOPED_LABEL,
116
+ notListed.length > 0
117
+ ? `Also changed in this window: ${notListed.join(", ")}.`
118
+ : "More cluster-scoped admission changes occurred than were read.",
119
+ "truncated",
120
+ );
121
+ }
122
+ if (changes.length === 0) return;
123
+ addChanges(
124
+ builder,
125
+ source,
126
+ changes,
127
+ `changes:cluster-scoped:${scopeFromArgs(source)}`,
128
+ undefined,
129
+ value.truncated !== true,
130
+ );
131
+ }
132
+
133
+ // The constant fields of a plain create row, which the producer leaves out of
134
+ // `created` (issuesapi.CreatedObjects).
135
+ const PLAIN_CREATE = {
136
+ changeType: "add",
137
+ summary: "add",
138
+ change_category: "lifecycle",
139
+ rank_reason: "resource create/delete for config or desired state",
140
+ } as const;
141
+
142
+ const CREATED_LINE = /^\+(\d+)s ([^ /]+)\/([^ /]+)(?: \(used by (.+)\))?$/;
143
+ const RFC3339_SECONDS =
144
+ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|[+-]\d{2}:\d{2})$/;
145
+
146
+ /**
147
+ * Expands get_changes `created` runs back into the rows they replaced. Each
148
+ * line is "+<seconds after first>s Kind/name", with " (used by ...)" for a
149
+ * consumed ConfigMap; a member's timestamp is `first` plus the offset, written
150
+ * in `first`'s zone so it matches the row the producer would have sent.
151
+ * Returns [] when the field is absent and undefined when it is malformed.
152
+ */
153
+ export function createdChanges(
154
+ payload: unknown,
155
+ ): IssueRecentChange[] | undefined {
156
+ if (payload === undefined || payload === null) return [];
157
+ if (!Array.isArray(payload)) return undefined;
158
+ const out: IssueRecentChange[] = [];
159
+ for (const raw of payload) {
160
+ const entry = record(raw);
161
+ const objects = stringArray(entry?.objects);
162
+ const first = typeof entry?.first === "string" ? entry.first : "";
163
+ const versions = record(entry?.apiVersions);
164
+ if (
165
+ !entry ||
166
+ !nonEmptyString(entry.namespace) ||
167
+ !objects ||
168
+ entry.count !== objects.length ||
169
+ addSeconds(first, 0) !== first ||
170
+ (entry.apiVersions !== undefined && !versions)
171
+ ) {
172
+ return undefined;
173
+ }
174
+ for (const line of objects) {
175
+ const match = CREATED_LINE.exec(line);
176
+ if (!match) return undefined;
177
+ const [, offset, kind, name, consumers] = match;
178
+ const apiVersion = versions?.[kind];
179
+ const timestamp = addSeconds(first, Number(offset));
180
+ if (
181
+ (apiVersion !== undefined && !nonEmptyString(apiVersion)) ||
182
+ timestamp === undefined
183
+ )
184
+ return undefined;
185
+ out.push({
186
+ ...PLAIN_CREATE,
187
+ kind,
188
+ ...(apiVersion ? { apiVersion } : {}),
189
+ namespace: entry.namespace,
190
+ name,
191
+ timestamp,
192
+ ...(consumers ? { consumed_by: consumers.split(", ") } : {}),
193
+ });
194
+ }
195
+ }
196
+ return out;
197
+ }
198
+
199
+ // addSeconds adds whole seconds to an RFC3339 timestamp and keeps its zone
200
+ // designator, so "2026-10-16T04:43:24+03:00" + 41 is "2026-10-16T04:44:05+03:00".
201
+ // Returns undefined for a malformed timestamp or an out-of-range result; a
202
+ // calendar-invalid date (February 30) is caught by callers comparing
203
+ // addSeconds(t, 0) with t.
204
+ function addSeconds(timestamp: string, seconds: number): string | undefined {
205
+ const m = RFC3339_SECONDS.exec(timestamp);
206
+ if (!m || !Number.isSafeInteger(seconds)) return undefined;
207
+ const [, y, mo, d, h, mi, s, zone] = m;
208
+ const wall = new Date(
209
+ Date.UTC(+y, +mo - 1, +d, +h, +mi, +s) + seconds * 1000,
210
+ );
211
+ if (Number.isNaN(wall.getTime())) return undefined;
212
+ const pad = (n: number, width = 2) => String(n).padStart(width, "0");
213
+ return (
214
+ `${pad(wall.getUTCFullYear(), 4)}-${pad(wall.getUTCMonth() + 1)}-${pad(wall.getUTCDate())}` +
215
+ `T${pad(wall.getUTCHours())}:${pad(wall.getUTCMinutes())}:${pad(wall.getUTCSeconds())}${zone}`
216
+ );
217
+ }
218
+
219
+ /**
220
+ * Puts expanded creates back where get_changes ranked them: plain creates
221
+ * share the lifecycle rank, so they join the rows of that rank ordered newest
222
+ * first (ties by kind/namespace/name, as the producer breaks them), after
223
+ * every higher-ranked row and before status rows.
224
+ */
225
+ export function mergeCreated(
226
+ rows: IssueRecentChange[],
227
+ created: IssueRecentChange[],
228
+ ): IssueRecentChange[] {
229
+ if (created.length === 0) return rows;
230
+ const lifecycleBand = (c: IssueRecentChange) =>
231
+ c.change_category === "lifecycle" &&
232
+ !c.application_configuration_change &&
233
+ !c.not_linked_to_returned_issues;
234
+ const start = rows.findIndex(
235
+ (c) => lifecycleBand(c) || c.change_category === "runtime_status",
236
+ );
237
+ const bandStart = start === -1 ? rows.length : start;
238
+ let bandEnd = bandStart;
239
+ while (bandEnd < rows.length && lifecycleBand(rows[bandEnd])) bandEnd++;
240
+ const key = (c: IssueRecentChange) =>
241
+ `${c.kind}/${c.namespace ?? ""}/${c.name}/${c.changeType}`;
242
+ const band = [...rows.slice(bandStart, bandEnd), ...created].sort((a, b) => {
243
+ const at = Date.parse(a.timestamp);
244
+ const bt = Date.parse(b.timestamp);
245
+ if (at !== bt) return bt - at;
246
+ return key(a) < key(b) ? -1 : key(a) > key(b) ? 1 : 0;
247
+ });
248
+ return [...rows.slice(0, bandStart), ...band, ...rows.slice(bandEnd)];
60
249
  }
@@ -19,6 +19,7 @@ import {
19
19
  stringArray,
20
20
  } from "../parse";
21
21
  import { type InvestigationEvidenceSource } from "../types";
22
+ import { addClusterScopedChanges } from "./changes";
22
23
 
23
24
  export function adaptIssues(
24
25
  builder: ProjectionBuilder,
@@ -63,30 +64,8 @@ export function adaptIssues(
63
64
  "error",
64
65
  );
65
66
  }
66
- if (value.recent_changes_truncated === true) {
67
- builder.limit(
68
- source,
69
- "Issue-related changes",
70
- "The issue response omitted some recent changes.",
71
- "truncated",
72
- );
73
- }
74
- if (nonEmptyString(value.recent_changes_error)) {
75
- builder.limit(
76
- source,
77
- "Issue-related changes",
78
- value.recent_changes_error,
79
- "error",
80
- );
81
- }
82
- if (value.correlation_truncated === true) {
83
- builder.limit(
84
- source,
85
- "Issue change correlation",
86
- "Change correlation was not evaluated for every returned issue.",
87
- "truncated",
88
- );
89
- }
67
+ const historyIncomplete =
68
+ record(value.recent_changes_history_coverage)?.incomplete === true;
90
69
  const visibility = record(value.visibility);
91
70
  if (
92
71
  visibility &&
@@ -114,7 +93,7 @@ export function adaptIssues(
114
93
  changes,
115
94
  `changes:issues:${source.args ?? scopeFromArgs(source)}`,
116
95
  undefined,
117
- value.recent_changes_truncated !== true,
96
+ value.recent_changes_truncated !== true && !historyIncomplete,
118
97
  );
119
98
  } else {
120
99
  invalidPayload(builder, source, "Issue-related changes");
@@ -122,6 +101,7 @@ export function adaptIssues(
122
101
  } else if (issueChangesRaw !== undefined) {
123
102
  invalidPayload(builder, source, "Issue-related changes");
124
103
  }
104
+ addClusterScopedChanges(builder, source, value.cluster_scoped_changes);
125
105
  const clusterDNS = record(record(value.cluster_context)?.dns);
126
106
  if (clusterDNS) {
127
107
  const signals = stringArray(clusterDNS.signals) ?? [];
@@ -148,33 +128,75 @@ export function adaptIssues(
148
128
  }
149
129
  }
150
130
  if (issues.length === 0) {
151
- if (!source.confirmedSuccess || builder.limitedSources.has(source.id))
152
- return;
153
- const args = record(source.args ? parseJSON(source.args) : undefined);
154
- if (!nonEmptyString(args?.namespace)) {
155
- builder.limit(
156
- source,
157
- "Issues",
158
- "Radar found no matching issues, but the search covered only namespaces the current user can access.",
159
- "unknown",
160
- );
161
- return;
162
- }
163
- const scope = scopeFromArgs(source);
164
- const relevance = sourceArgsRelevance(builder, source);
165
- builder.observe(`issues:${source.args ?? scope}`, "receipt", source, {
166
- tier: evidenceTierForRelevance("checked", relevance),
167
- relevance,
168
- tone: "neutral",
169
- title: "No live issues matched this search",
170
- summary: scope,
171
- data: {
172
- type: "receipt",
173
- checked: "issues",
174
- scope,
175
- },
176
- });
131
+ addNoIssuesReceipt(builder, source);
177
132
  } else {
178
133
  for (const item of issues) addIssueObservation(builder, source, item);
179
134
  }
135
+ // Added last: these limit the change feed only, so they must not withhold
136
+ // the live-issue receipt above.
137
+ if (value.recent_changes_truncated === true) {
138
+ builder.limit(
139
+ source,
140
+ "Issue-related changes",
141
+ "The issue response omitted some recent changes.",
142
+ "truncated",
143
+ );
144
+ }
145
+ if (historyIncomplete) {
146
+ builder.limit(
147
+ source,
148
+ "Issue-related changes",
149
+ "Radar's change history is incomplete for part of the window, so earlier changes may be missing.",
150
+ "unknown",
151
+ );
152
+ }
153
+ if (nonEmptyString(value.recent_changes_error)) {
154
+ builder.limit(
155
+ source,
156
+ "Issue-related changes",
157
+ value.recent_changes_error,
158
+ "error",
159
+ );
160
+ }
161
+ if (value.correlation_truncated === true) {
162
+ builder.limit(
163
+ source,
164
+ "Issue change correlation",
165
+ "Change correlation was not evaluated for every returned issue.",
166
+ "truncated",
167
+ );
168
+ }
169
+ }
170
+
171
+ // The receipt for a scan that found nothing, unless the scan itself was
172
+ // limited or covered only the caller's namespaces.
173
+ function addNoIssuesReceipt(
174
+ builder: ProjectionBuilder,
175
+ source: InvestigationEvidenceSource,
176
+ ): void {
177
+ if (!source.confirmedSuccess || builder.limitedSources.has(source.id)) return;
178
+ const args = record(source.args ? parseJSON(source.args) : undefined);
179
+ if (!nonEmptyString(args?.namespace)) {
180
+ builder.limit(
181
+ source,
182
+ "Issues",
183
+ "Radar found no matching issues, but the search covered only namespaces the current user can access.",
184
+ "unknown",
185
+ );
186
+ return;
187
+ }
188
+ const scope = scopeFromArgs(source);
189
+ const relevance = sourceArgsRelevance(builder, source);
190
+ builder.observe(`issues:${source.args ?? scope}`, "receipt", source, {
191
+ tier: evidenceTierForRelevance("checked", relevance),
192
+ relevance,
193
+ tone: "neutral",
194
+ title: "No live issues matched this search",
195
+ summary: scope,
196
+ data: {
197
+ type: "receipt",
198
+ checked: "issues",
199
+ scope,
200
+ },
201
+ });
180
202
  }