Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Add cloud_context_privacy dial (privacy redesign increment 1)

rcourtman7cb45489e85e
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 8876fada77..cc6dcfda50 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -1662,10 +1662,11 @@ Visible `stream_idle` workflow progress on that same legacy Assistant SSE
route, and on `/api/ai/execute/stream`, is likewise Assistant/API transport
liveness only. It must not be reused as agent heartbeat, enrollment progress,
installer status, command websocket liveness, or fleet freshness evidence.
-The `/api/settings/ai` `share_operational_context_with_cloud` opt-in is an
-Assistant privacy/runtime setting governing whether PII-free operational
-context reaches cloud models; it is not agent enrollment config, installer
-readiness, command reachability, or any fleet-control capability signal.
+The `/api/settings/ai` `cloud_context_privacy` dial (and the legacy
+`share_operational_context_with_cloud` boolean it supersedes) is an Assistant
+privacy/runtime setting governing how much infrastructure context reaches cloud
+models; it is not agent enrollment config, installer readiness, command
+reachability, or any fleet-control capability signal.
Patrol finding chat handoffs follow the same ownership split: when
`/api/ai/chat` resolves a `finding_id` into model-only Patrol briefing,
resource, or action context, the backend-enforced `autonomous_mode:false`
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 31ab154486..3c962e6e16 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -101,43 +101,56 @@ deriving an older display status from `workflowStatusHistory`.
and `internal/ai/providers/ollama.go` is the only layer that turns it into
the Ollama `keep_alive` request field. An empty configured value means
Pulse omits `keep_alive` so the Ollama server default applies.
- Cloud operational-context sharing is a runtime privacy option owned by this
- path: `internal/config/ai.go` stores
- `AIConfig.ShareOperationalContextWithCloud` (default false, surfaced through
- `ShouldShareOperationalContextWithCloud`). The default keeps governed
- resources reduced to the terse policy redaction on cloud-routed turns, which
- is correct for privacy but leaves the Assistant unable to give
- resource-specific guidance on cloud models. When the operator opts in AND the
- turn routes to an external provider, governed-resource context built in
- `internal/ai/chat/context_prefetch.go` must carry the PII-free operational
- context from `servicediscovery.FormatCloudSafeContext` (service identity,
- access command, config/data/log paths, port numbers) in place of the terse
- governed summary, and the model-bound resource-policy sanitizer in
+ Cloud context privacy is a runtime privacy option owned by this path. The
+ canonical operator control is the `cloud_context_privacy` dial in
+ `internal/config/ai.go` (`AIConfig.CloudContextPrivacy`, normalized through
+ `GetCloudContextPrivacy` / `NormalizeCloudContextPrivacy`) with three levels:
+ `full` (default), `redacted`, and `local_only`. It supersedes the legacy
+ boolean `AIConfig.ShareOperationalContextWithCloud`
+ (`ShouldShareOperationalContextWithCloud`), which is retained only as the
+ field the redaction seam still reads until the dial is wired into the seam
+ directly (privacy-redesign increment 2). `/api/settings/ai` keeps the legacy
+ boolean in sync with the dial (`full` → true, `redacted`/`local_only` →
+ false), and `internal/config` config load migrates the dial out of the legacy
+ boolean for pre-dial configs (legacy on → `full`, off/absent → `redacted`)
+ without mutating the boolean, so existing installs keep their current cloud
+ behavior. A fresh install defaults to `full` so a self-hosted Pulse answers
+ with real resource detail out of the box.
+ The redaction seam behavior is unchanged by the dial's introduction. When
+ sharing is on AND the turn routes to an external provider, governed-resource
+ context built in `internal/ai/chat/context_prefetch.go` must carry the PII-free
+ operational context from `servicediscovery.FormatCloudSafeContext` (service
+ identity, access command, config/data/log paths, port numbers) in place of the
+ terse governed summary, and the model-bound resource-policy sanitizer in
`internal/ai/chat/service.go` must allow-list those exact spans via
`modelboundary.AllowResourcePolicyText` so they are not re-stripped at the
provider boundary. Genuinely identifying fields — hostname, IP, bind address,
alias, and platform ID — must never be emitted by that cloud-safe path and
- stay redacted regardless of the opt-in. Local (Ollama) routing is unaffected
- and always receives full context. Transparency is mandatory: when governed
- operational context is withheld because a cloud turn has sharing off,
+ stay redacted regardless of the dial. Local (Ollama) routing is unaffected and
+ always receives full context. Transparency is mandatory: when governed
+ operational context is withheld because a cloud turn is not on `full`,
`context_prefetch.go` must instruct the Assistant to disclose the redaction in
- its reply and point at the `Share operational context with cloud models`
- setting, rather than silently degrading the answer.
- The opt-in must be operator-reachable, not config-file-only. `/api/settings/ai`
- round-trips `share_operational_context_with_cloud` field-by-field exactly like
+ its reply and point at the `Cloud model privacy` setting, rather than silently
+ degrading the answer.
+ The dial must be operator-reachable, not config-file-only. `/api/settings/ai`
+ round-trips `cloud_context_privacy` field-by-field exactly like
`discovery_enabled`: `internal/api/ai_handlers.go` always serializes the
- current value on the settings response from
- `settings.ShouldShareOperationalContextWithCloud()` (no `omitempty`, so a
- toggle can bind to the concrete boolean) and applies the optional request
- `*bool` on update, leaving the persisted opt-in untouched when the field is
- omitted. The operator surface is the `Share operational context with cloud
- models` toggle in the Assistant runtime controls
+ current value on the settings response from `settings.GetCloudContextPrivacy()`
+ (no `omitempty`, so a 3-option control can bind to the concrete value),
+ validates the optional request `*string` against
+ `config.NormalizeCloudContextPrivacy` (rejecting unknown values with 400),
+ leaves the persisted dial untouched when the field is omitted, and syncs the
+ legacy boolean from the chosen level. The operator surface is the `Cloud model
+ privacy` 3-option control in the Assistant runtime controls
(`frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx`),
- bound to the canonical `useAISettingsState` form and the
- `frontend-modern/src/api/ai.ts` `AISettings` / `AISettingsUpdateRequest`
- payload contract. The toggle defaults off, carries the PII-free scope and
- Ollama-always-full-context caveats in its help copy
- (`getAISettingsCloudContextSharingHelpContent` in
+ bound to the canonical `useAISettingsState` form and the `AISettings` /
+ `AISettingsUpdateRequest` payload contract in
+ `frontend-modern/src/types/ai.ts` (consumed by
+ `frontend-modern/src/api/ai.ts`). The dial defaults to `full`, carries the
+ privacy-level and Ollama-always-full-context caveats in its help and per-option
+ copy (`getAISettingsCloudContextPrivacyHelpContent` /
+ `getAISettingsCloudContextPrivacyOptions` /
+ `getAISettingsCloudContextPrivacySummary` in
`frontend-modern/src/utils/aiSettingsPresentation.ts`), and must not be
reimplemented as a local-only browser flag or a bespoke fetch outside the
canonical settings payload.
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 42fa032cf8..9529abf9f5 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -664,12 +664,16 @@ payload shape change when the portal presents compact client rows.
then pacing the first backend `workflow_state` long enough for browser proof
to verify immediate visible activity without opening a provider request.
34. `internal/api/ai_handlers.go` shared with `ai-runtime`: AI settings and remediation handlers are both an AI runtime control surface and a canonical API payload contract boundary.
- The AI settings payload on `/api/settings/ai` round-trips
- `share_operational_context_with_cloud` field-by-field alongside
- `discovery_enabled`: the settings response always serializes the boolean
- (no `omitempty`) so the operator UI can bind a toggle to its concrete
- value, the update request carries it as an optional `*bool`, and an omitted
- field leaves the persisted opt-in unchanged rather than resetting it.
+ The AI settings payload on `/api/settings/ai` round-trips the
+ `cloud_context_privacy` dial field-by-field alongside `discovery_enabled`:
+ the settings response always serializes the string (no `omitempty`) so the
+ operator UI can bind a 3-option control to its concrete value, the update
+ request carries it as an optional `*string` validated against the
+ `full`/`redacted`/`local_only` set (unknown values are rejected with 400),
+ and an omitted field leaves the persisted dial unchanged rather than
+ resetting it. The dial supersedes the legacy
+ `share_operational_context_with_cloud` boolean, which the handler keeps in
+ sync (`full` → true, otherwise false) and still serializes for back-compat.
Legacy Assistant SSE routes in this handler that still use the older
execute envelope, including `/api/ai/execute/stream` and
`/api/ai/investigate-alert`, must preserve their existing top-level
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 6464e14353..cb2ca9c18a 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -518,16 +518,17 @@ not a replacement status card, CTA band, or page-local nested card.
apply controlled `value` props after options are mounted so settings panels
such as workload discovery show the persisted option instead of falling back
to the first option while the collapsed summary shows a different value.
- The Assistant runtime-control toggles in
- `frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx` —
- workload discovery and the `Share operational context with cloud models`
- cloud operational-context opt-in — are settings-shell chrome bound to the
- canonical `useAISettingsState` form and `/api/settings/ai` payload, not
- local browser state. Each must bind its shared `Toggle` to a
- `state.form.*` field, round-trip through the field-by-field settings payload
- (the cloud opt-in's `share_operational_context_with_cloud` mirrors
- `discovery_enabled` and defaults off), and source its label, help, and
- summary copy from
+ The Assistant runtime controls in
+ `frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx` — the
+ workload discovery `Toggle` and the `Cloud model privacy` 3-option dial — are
+ settings-shell chrome bound to the canonical `useAISettingsState` form and
+ `/api/settings/ai` payload, not local browser state. Each must bind to a
+ `state.form.*` field and round-trip through the field-by-field settings
+ payload: discovery via its `Toggle`, and cloud model privacy via the shared
+ `FormSelect` primitive bound to `state.form.cloudContextPrivacy` and the
+ `cloud_context_privacy` payload field (which mirrors `discovery_enabled`'s
+ field-by-field round-trip and defaults to `full`). Both must source their
+ label, help, option, and summary copy from
`frontend-modern/src/utils/aiSettingsPresentation.ts` rather than inlining
strings or reaching for a bespoke fetch outside the canonical payload.
3. Add feature-specific presentation only when no shared primitive should own it.
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index cd66cfdd7e..056c55a61f 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -582,11 +582,11 @@ recovery scope, or a storage/recovery-owned secret source.
investigation streams, is likewise Assistant/API transport liveness only,
not recovery acquisition progress, backup task freshness, restore readiness,
provider health, or storage/recovery job status.
- The `/api/settings/ai` `share_operational_context_with_cloud` opt-in on that
- same handler governs only whether PII-free Assistant operational context
- (access commands, config/data/log paths, ports) reaches cloud models; it is
- not a storage/recovery restore approval, backup freshness, recovery-scope,
- or restore-command signal.
+ The `/api/settings/ai` `cloud_context_privacy` dial on that same handler
+ (and the legacy `share_operational_context_with_cloud` boolean it supersedes)
+ governs only how much Assistant infrastructure context reaches cloud models;
+ it is not a storage/recovery restore approval, backup freshness,
+ recovery-scope, or restore-command signal.
Patrol finding chat handoff execution controls in `internal/api/ai_handler.go`
follow the same boundary: backend-forced `autonomous_mode:false` for
`finding_id` handoffs with model-only Patrol briefing, resource, or action
diff --git a/frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx b/frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx
index f06da181dc..482fc550a1 100644
--- a/frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx
+++ b/frontend-modern/src/components/Settings/AIRuntimeControlsSection.tsx
@@ -1,5 +1,6 @@
-import { Component, Show } from 'solid-js';
+import { Component, For, Show } from 'solid-js';
import RefreshCwIcon from 'lucide-solid/icons/refresh-cw';
+import type { CloudContextPrivacy } from '@/types/ai';
import type { AIControlLevel } from '@/utils/aiControlLevelPresentation';
import type { AISettingsState } from '@/components/Settings/useAISettingsState';
import { HelpIcon } from '@/components/shared/HelpIcon';
@@ -14,9 +15,10 @@ import {
} from '@/utils/aiControlLevelPresentation';
import {
AI_SETTINGS_ASSISTANT_PERMISSIONS_TITLE,
- AI_SETTINGS_CLOUD_CONTEXT_SHARING_LABEL,
- getAISettingsCloudContextSharingHelpContent,
- getAISettingsCloudContextSharingSummary,
+ AI_SETTINGS_CLOUD_CONTEXT_PRIVACY_LABEL,
+ getAISettingsCloudContextPrivacyHelpContent,
+ getAISettingsCloudContextPrivacyOptions,
+ getAISettingsCloudContextPrivacySummary,
getAISettingsWorkloadDiscoveryHelpContent,
getAISettingsWorkloadDiscoverySummary,
} from '@/utils/aiSettingsPresentation';
@@ -157,20 +159,30 @@ export const AIRuntimeControlsSection: Component<AIRuntimeControlsSectionProps>
</div>
<div class="space-y-2 p-3 rounded-md border border-border bg-surface-alt">
- <div class="flex items-center justify-between gap-2">
- <label class="text-xs font-medium text-base-content flex items-center gap-1.5">
- {AI_SETTINGS_CLOUD_CONTEXT_SHARING_LABEL}
- <HelpIcon inline={getAISettingsCloudContextSharingHelpContent()} size="xs" />
- </label>
- <Toggle
- checked={state.form.shareOperationalContextWithCloud}
- onChange={(event) =>
- state.setForm('shareOperationalContextWithCloud', event.currentTarget.checked)
- }
- disabled={state.saving()}
- />
- </div>
- <p class="text-[10px] text-muted">{getAISettingsCloudContextSharingSummary().text}</p>
+ <FormSelect
+ id="ai-cloud-context-privacy-select"
+ label={
+ <span class="flex items-center gap-1.5">
+ {AI_SETTINGS_CLOUD_CONTEXT_PRIVACY_LABEL}
+ <HelpIcon inline={getAISettingsCloudContextPrivacyHelpContent()} size="xs" />
+ </span>
+ }
+ value={state.form.cloudContextPrivacy}
+ onChange={(e) =>
+ state.setForm('cloudContextPrivacy', e.currentTarget.value as CloudContextPrivacy)
+ }
+ disabled={state.saving()}
+ fieldBaseClass="flex flex-col gap-1.5"
+ labelClass="text-xs font-medium text-base-content"
+ selectBaseClass="min-h-10 sm:min-h-9 px-2 py-2 text-sm border border-border rounded bg-surface"
+ >
+ <For each={getAISettingsCloudContextPrivacyOptions()}>
+ {(option) => <option value={option.value}>{option.label}</option>}
+ </For>
+ </FormSelect>
+ <p class="text-[10px] text-muted">
+ {getAISettingsCloudContextPrivacySummary(state.form.cloudContextPrivacy).text}
+ </p>
</div>
<div class="flex items-center gap-3 p-3 rounded-md border border-border bg-surface-alt">
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index e941382d92..a04663ab26 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -379,22 +379,23 @@ describe('settings architecture guardrails', () => {
expect(aiRuntimeControlsSectionSource).not.toContain("fetch('/api/discovery/run");
});
- it('keeps the cloud operational-context opt-in wired through the canonical settings state', () => {
- // The "Share operational context with cloud models" toggle must bind to the
- // canonical AI settings form/store and round-trip the API field rather than
+ it('keeps the cloud model privacy dial wired through the canonical settings state', () => {
+ // The "Cloud model privacy" dial must bind to the canonical AI settings
+ // form/store and round-trip the cloud_context_privacy API field rather than
// reaching for a bespoke fetch or local-only flag.
- expect(aiRuntimeControlsSectionSource).toContain('AI_SETTINGS_CLOUD_CONTEXT_SHARING_LABEL');
- expect(aiRuntimeControlsSectionSource).toContain('getAISettingsCloudContextSharingHelpContent');
- expect(aiRuntimeControlsSectionSource).toContain('state.form.shareOperationalContextWithCloud');
+ expect(aiRuntimeControlsSectionSource).toContain('AI_SETTINGS_CLOUD_CONTEXT_PRIVACY_LABEL');
+ expect(aiRuntimeControlsSectionSource).toContain('getAISettingsCloudContextPrivacyHelpContent');
+ expect(aiRuntimeControlsSectionSource).toContain('getAISettingsCloudContextPrivacyOptions');
+ expect(aiRuntimeControlsSectionSource).toContain('state.form.cloudContextPrivacy');
expect(aiRuntimeControlsSectionSource).toContain(
- "state.setForm('shareOperationalContextWithCloud', event.currentTarget.checked)",
+ "state.setForm('cloudContextPrivacy', e.currentTarget.value as CloudContextPrivacy)",
);
- expect(aiSettingsStateSource).toContain('shareOperationalContextWithCloud');
+ expect(aiSettingsStateSource).toContain('cloudContextPrivacy');
expect(aiSettingsStateSource).toContain(
- 'payload.share_operational_context_with_cloud = form.shareOperationalContextWithCloud;',
+ 'payload.cloud_context_privacy = form.cloudContextPrivacy;',
);
expect(aiSettingsStateSource).toContain(
- 'shareOperationalContextWithCloud: data.share_operational_context_with_cloud ?? false,',
+ "cloudContextPrivacy: data.cloud_context_privacy ?? 'full',",
);
});
diff --git a/frontend-modern/src/components/Settings/useAISettingsState.ts b/frontend-modern/src/components/Settings/useAISettingsState.ts
index b1effefdb0..6265701aa8 100644
--- a/frontend-modern/src/components/Settings/useAISettingsState.ts
+++ b/frontend-modern/src/components/Settings/useAISettingsState.ts
@@ -23,7 +23,13 @@ import { hasFeature, loadRuntimeCapabilities } from '@/stores/license';
import { getUpgradeActionDestination } from '@/stores/licenseCommercial';
import { presentationPolicyHidesUpgradePrompts } from '@/stores/sessionPresentationPolicy';
import { notificationStore } from '@/stores/notifications';
-import type { AISettings as AISettingsType, AIProvider, AuthMethod, ModelInfo } from '@/types/ai';
+import type {
+ AISettings as AISettingsType,
+ AIProvider,
+ AuthMethod,
+ CloudContextPrivacy,
+ ModelInfo,
+} from '@/types/ai';
import { normalizeAIControlLevel, type AIControlLevel } from '@/utils/aiControlLevelPresentation';
import { getAIProviderDisplayName, getProviderFromModelId } from '@/utils/aiProviderPresentation';
import {
@@ -303,7 +309,7 @@ export const useAISettingsState = () => {
protectedGuests: '' as string,
discoveryEnabled: false,
discoveryIntervalHours: 0,
- shareOperationalContextWithCloud: false,
+ cloudContextPrivacy: 'full' as CloudContextPrivacy,
});
const showUpgradePrompts = () => !presentationPolicyHidesUpgradePrompts();
@@ -379,7 +385,7 @@ export const useAISettingsState = () => {
protectedGuests: '',
discoveryEnabled: false,
discoveryIntervalHours: 0,
- shareOperationalContextWithCloud: false,
+ cloudContextPrivacy: 'full' as CloudContextPrivacy,
});
return;
}
@@ -412,7 +418,7 @@ export const useAISettingsState = () => {
protectedGuests: Array.isArray(data.protected_guests) ? data.protected_guests.join(', ') : '',
discoveryEnabled: data.discovery_enabled ?? false,
discoveryIntervalHours: data.discovery_interval_hours ?? 0,
- shareOperationalContextWithCloud: data.share_operational_context_with_cloud ?? false,
+ cloudContextPrivacy: data.cloud_context_privacy ?? 'full',
});
const configured = new Set<AIProvider>();
@@ -884,7 +890,7 @@ export const useAISettingsState = () => {
payload.discovery_enabled = form.discoveryEnabled;
payload.discovery_interval_hours = form.discoveryIntervalHours;
- payload.share_operational_context_with_cloud = form.shareOperationalContextWithCloud;
+ payload.cloud_context_privacy = form.cloudContextPrivacy;
const updated = await AIAPI.updateSettings(payload);
setSettings(updated);
diff --git a/frontend-modern/src/types/ai.ts b/frontend-modern/src/types/ai.ts
index 019c9b8a7b..c2afc89504 100644
--- a/frontend-modern/src/types/ai.ts
+++ b/frontend-modern/src/types/ai.ts
@@ -2,6 +2,8 @@
export type AIProvider = 'anthropic' | 'openai' | 'openrouter' | 'ollama' | 'deepseek' | 'gemini';
export type AuthMethod = 'api_key' | 'oauth';
+// Cloud context privacy dial - what infrastructure context cloud models may see.
+export type CloudContextPrivacy = 'full' | 'redacted' | 'local_only';
export type PatrolReadinessStatus = 'ready' | 'warning' | 'not_ready';
export interface PatrolReadinessCheck {
@@ -82,10 +84,14 @@ export interface AISettings {
discovery_enabled?: boolean;
discovery_interval_hours?: number;
- // Cloud operational-context sharing - when true, PII-free operational
- // context for governed resources is shared with cloud models.
+ // Cloud operational-context sharing - legacy boolean superseded by
+ // cloud_context_privacy; the backend keeps it in sync for back-compat.
share_operational_context_with_cloud?: boolean;
+ // Cloud context privacy dial - canonical control for what infrastructure
+ // context cloud models may see. Always serialized by the backend.
+ cloud_context_privacy?: CloudContextPrivacy;
+
// Current Pulse Patrol runtime readiness for this settings snapshot
patrol_readiness?: PatrolReadiness;
// Most recent Patrol tool-call preflight result, recorded by Pulse so
@@ -160,9 +166,12 @@ export interface AISettingsUpdateRequest {
discovery_enabled?: boolean;
discovery_interval_hours?: number;
- // Cloud operational-context sharing - opt in to share PII-free operational
- // context for governed resources with cloud models.
+ // Cloud operational-context sharing - legacy boolean superseded by
+ // cloud_context_privacy; kept for back-compat with older API clients.
share_operational_context_with_cloud?: boolean;
+
+ // Cloud context privacy dial - canonical control for cloud model context.
+ cloud_context_privacy?: CloudContextPrivacy;
}
export interface AITestResult {
diff --git a/frontend-modern/src/utils/__tests__/aiSettingsPresentation.test.ts b/frontend-modern/src/utils/__tests__/aiSettingsPresentation.test.ts
index 49a91ff3b7..fd80dc835e 100644
--- a/frontend-modern/src/utils/__tests__/aiSettingsPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/aiSettingsPresentation.test.ts
@@ -2,13 +2,14 @@ import { describe, expect, it } from 'vitest';
import {
AI_SETTINGS_ASSISTANT_PERMISSIONS_TITLE,
AI_SETTINGS_ASSISTANT_SESSIONS_TITLE,
- AI_SETTINGS_CLOUD_CONTEXT_SHARING_LABEL,
+ AI_SETTINGS_CLOUD_CONTEXT_PRIVACY_LABEL,
AI_SETTINGS_MODEL_OVERRIDES_TITLE,
AI_SETTINGS_PANEL_DESCRIPTION,
AI_SETTINGS_PANEL_TITLE,
getAICredentialsClearErrorMessage,
- getAISettingsCloudContextSharingHelpContent,
- getAISettingsCloudContextSharingSummary,
+ getAISettingsCloudContextPrivacyHelpContent,
+ getAISettingsCloudContextPrivacyOptions,
+ getAISettingsCloudContextPrivacySummary,
getAIOAuthErrorMessage,
getAIChatSessionsEmptyState,
getAIChatSessionsLoadErrorMessage,
@@ -44,16 +45,40 @@ describe('aiSettingsPresentation', () => {
expect(getAISettingsWorkloadDiscoverySummary()).toEqual({
text: 'Workload discovery stores concrete service context for Assistant chat and Patrol verification, so responses and findings can reference real services and commands instead of generic advice.',
});
- expect(AI_SETTINGS_CLOUD_CONTEXT_SHARING_LABEL).toBe(
- 'Share operational context with cloud models',
- );
- expect(getAISettingsCloudContextSharingHelpContent()).toEqual({
- title: 'Sharing operational context with cloud models',
+ expect(AI_SETTINGS_CLOUD_CONTEXT_PRIVACY_LABEL).toBe('Cloud model privacy');
+ expect(getAISettingsCloudContextPrivacyHelpContent()).toEqual({
+ title: 'What cloud models can see',
description:
- 'When on, Pulse shares PII-free operational context — access commands, config/data/log paths, and port numbers for discovered services — with cloud models (Anthropic, OpenAI, etc.) so the Assistant can give resource-specific guidance instead of generic advice. Identifying fields (hostnames, IP addresses, aliases, platform IDs) always stay redacted. Default off. Local Ollama models always receive full context regardless of this setting.',
+ 'When the Assistant runs on a cloud model (Anthropic, OpenAI, OpenRouter, and similar), this dial controls how much of your real infrastructure it includes in the request. Local models (Ollama) always receive full context regardless of this setting. Most self-hosted setups keep this on Full so the Assistant can answer with real detail; raise the privacy level if you would rather limit what leaves your network.',
+ });
+ expect(getAISettingsCloudContextPrivacyOptions()).toEqual([
+ {
+ value: 'full',
+ label: 'Full — answer with real detail',
+ description:
+ 'Cloud models receive your infrastructure context so the Assistant gives resource-specific answers instead of generic advice. Best for a private, self-hosted Pulse.',
+ },
+ {
+ value: 'redacted',
+ label: 'Redacted — hide identifying detail',
+ description:
+ 'Cloud models receive operational context like service commands, paths, and ports, but identifying details such as hostnames, IP addresses, and aliases are removed before the request leaves Pulse.',
+ },
+ {
+ value: 'local_only',
+ label: 'Local only — send nothing to cloud',
+ description:
+ 'Cloud models receive no infrastructure context. Switch the Assistant to a local model to get resource-specific answers.',
+ },
+ ]);
+ expect(getAISettingsCloudContextPrivacySummary('full')).toEqual({
+ text: 'Cloud models receive your infrastructure context so answers stay specific. Choose Redacted or Local only to limit what leaves Pulse.',
+ });
+ expect(getAISettingsCloudContextPrivacySummary('redacted')).toEqual({
+ text: 'Cloud models get cloud-safe operational details (commands, paths, ports); hostnames, IP addresses, and aliases are redacted.',
});
- expect(getAISettingsCloudContextSharingSummary()).toEqual({
- text: 'Off by default: cloud models receive a terse redacted summary, so Assistant answers stay generic on cloud routes. Turning this on shares cloud-safe operational details (commands, paths, ports) while hostnames, IPs, and aliases remain redacted.',
+ expect(getAISettingsCloudContextPrivacySummary('local_only')).toEqual({
+ text: 'No infrastructure context is sent to cloud models. Use a local model for resource-specific answers.',
});
expect(getAISettingsSetupDialogPresentation()).toEqual({
ariaLabel: 'Set up Assistant and Patrol',
diff --git a/frontend-modern/src/utils/aiSettingsPresentation.ts b/frontend-modern/src/utils/aiSettingsPresentation.ts
index a7b79da50d..ea7c36c95b 100644
--- a/frontend-modern/src/utils/aiSettingsPresentation.ts
+++ b/frontend-modern/src/utils/aiSettingsPresentation.ts
@@ -1,3 +1,5 @@
+import type { CloudContextPrivacy } from '@/types/ai';
+
export interface AISettingsReadinessPresentation {
containerClassName: string;
dotClassName: string;
@@ -54,21 +56,61 @@ export function getAISettingsWorkloadDiscoverySummary() {
} as const;
}
-export const AI_SETTINGS_CLOUD_CONTEXT_SHARING_LABEL =
- 'Share operational context with cloud models';
+export const AI_SETTINGS_CLOUD_CONTEXT_PRIVACY_LABEL = 'Cloud model privacy';
-export function getAISettingsCloudContextSharingHelpContent() {
+export function getAISettingsCloudContextPrivacyHelpContent() {
return {
- title: 'Sharing operational context with cloud models',
+ title: 'What cloud models can see',
description:
- 'When on, Pulse shares PII-free operational context — access commands, config/data/log paths, and port numbers for discovered services — with cloud models (Anthropic, OpenAI, etc.) so the Assistant can give resource-specific guidance instead of generic advice. Identifying fields (hostnames, IP addresses, aliases, platform IDs) always stay redacted. Default off. Local Ollama models always receive full context regardless of this setting.',
+ 'When the Assistant runs on a cloud model (Anthropic, OpenAI, OpenRouter, and similar), this dial controls how much of your real infrastructure it includes in the request. Local models (Ollama) always receive full context regardless of this setting. Most self-hosted setups keep this on Full so the Assistant can answer with real detail; raise the privacy level if you would rather limit what leaves your network.',
} as const;
}
-export function getAISettingsCloudContextSharingSummary() {
- return {
- text: 'Off by default: cloud models receive a terse redacted summary, so Assistant answers stay generic on cloud routes. Turning this on shares cloud-safe operational details (commands, paths, ports) while hostnames, IPs, and aliases remain redacted.',
- } as const;
+export interface AISettingsCloudContextPrivacyOption {
+ value: CloudContextPrivacy;
+ label: string;
+ description: string;
+}
+
+export function getAISettingsCloudContextPrivacyOptions(): readonly AISettingsCloudContextPrivacyOption[] {
+ return [
+ {
+ value: 'full',
+ label: 'Full — answer with real detail',
+ description:
+ 'Cloud models receive your infrastructure context so the Assistant gives resource-specific answers instead of generic advice. Best for a private, self-hosted Pulse.',
+ },
+ {
+ value: 'redacted',
+ label: 'Redacted — hide identifying detail',
+ description:
+ 'Cloud models receive operational context like service commands, paths, and ports, but identifying details such as hostnames, IP addresses, and aliases are removed before the request leaves Pulse.',
+ },
+ {
+ value: 'local_only',
+ label: 'Local only — send nothing to cloud',
+ description:
+ 'Cloud models receive no infrastructure context. Switch the Assistant to a local model to get resource-specific answers.',
+ },
+ ] as const;
+}
+
+export function getAISettingsCloudContextPrivacySummary(value: CloudContextPrivacy) {
+ switch (value) {
+ case 'redacted':
+ return {
+ text: 'Cloud models get cloud-safe operational details (commands, paths, ports); hostnames, IP addresses, and aliases are redacted.',
+ } as const;
+ case 'local_only':
+ return {
+ text: 'No infrastructure context is sent to cloud models. Use a local model for resource-specific answers.',
+ } as const;
+ case 'full':
+ default:
+ return {
+ text: 'Cloud models receive your infrastructure context so answers stay specific. Choose Redacted or Local only to limit what leaves Pulse.',
+ } as const;
+ }
}
export function getAISettingsSetupDialogPresentation(): AISettingsSetupDialogPresentation {
diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.go
index 33a7db7894..ddaa9360ed 100644
--- a/internal/api/ai_handlers.go
+++ b/internal/api/ai_handlers.go
@@ -2308,6 +2308,11 @@ type AISettingsResponse struct {
// resource-specific guidance. Identifying fields stay redacted; local
// (Ollama) models always receive full context regardless of this flag.
ShareOperationalContextWithCloud bool `json:"share_operational_context_with_cloud"`
+ // Cloud context privacy dial - the canonical control for what infrastructure
+ // context cloud models may see: "full" (default), "redacted", or "local_only".
+ // Always serialized so the operator UI binds a 3-option control to the
+ // concrete value. Local (Ollama) models always receive full context.
+ CloudContextPrivacy string `json:"cloud_context_privacy"`
// Current Patrol runtime readiness after this settings snapshot is applied.
PatrolReadiness *PatrolReadinessResponse `json:"patrol_readiness,omitempty"`
// Most recent Patrol tool-call preflight outcome, surfaced so the UI
@@ -2407,6 +2412,11 @@ type AISettingsUpdateRequest struct {
// Cloud operational-context sharing - opt in to share PII-free operational
// context for governed resources with cloud models (nil = don't update).
ShareOperationalContextWithCloud *bool `json:"share_operational_context_with_cloud,omitempty"`
+ // Cloud context privacy dial - canonical control for cloud model context
+ // ("full" | "redacted" | "local_only"; nil = don't update). When provided it
+ // supersedes share_operational_context_with_cloud and the handler keeps that
+ // legacy flag in sync (full -> true, redacted/local_only -> false).
+ CloudContextPrivacy *string `json:"cloud_context_privacy,omitempty"`
}
// AssistantEnabled reports whether the Pulse Assistant affordance should be
@@ -2535,6 +2545,7 @@ func (h *AISettingsHandler) HandleGetAISettings(w http.ResponseWriter, r *http.R
DiscoveryEnabled: settings.IsDiscoveryEnabled(),
DiscoveryIntervalHours: settings.DiscoveryIntervalHours,
ShareOperationalContextWithCloud: settings.ShouldShareOperationalContextWithCloud(),
+ CloudContextPrivacy: settings.GetCloudContextPrivacy(),
PatrolPreflight: cachedPatrolPreflightSnapshot(aiService),
PatrolReadiness: ptrToPatrolReadiness(h.buildPatrolReadiness(ctx, aiService, h.getPatrolService(ctx) != nil)),
}.NormalizeCollections()
@@ -2865,6 +2876,23 @@ func (h *AISettingsHandler) HandleUpdateAISettings(w http.ResponseWriter, r *htt
settings.ShareOperationalContextWithCloud = *req.ShareOperationalContextWithCloud
}
+ // Handle the cloud context privacy dial (nil = don't update). When provided it
+ // is the canonical control and supersedes share_operational_context_with_cloud:
+ // the handler keeps the legacy flag (still read by the redaction seam until the
+ // dial is wired into the seam directly) in sync so behavior tracks the dial's
+ // full/redacted axis. The dial's deeper semantics (real identifiers on "full",
+ // dropping all infra context on "local_only") land in privacy-redesign
+ // increment 2; here local_only conservatively maps to the redacted seam state.
+ if req.CloudContextPrivacy != nil {
+ normalized, valid := config.NormalizeCloudContextPrivacy(*req.CloudContextPrivacy)
+ if !valid {
+ http.Error(w, "invalid cloud_context_privacy: must be full, redacted, or local_only", http.StatusBadRequest)
+ return
+ }
+ settings.CloudContextPrivacy = normalized
+ settings.ShareOperationalContextWithCloud = normalized == config.CloudContextPrivacyFull
+ }
+
if aiSettingsRequireModelResolution(settings) {
resolvedModel, resolveErr := ai.ResolveConfiguredModel(r.Context(), settings)
if resolveErr != nil {
@@ -2993,6 +3021,7 @@ func (h *AISettingsHandler) HandleUpdateAISettings(w http.ResponseWriter, r *htt
DiscoveryEnabled: settings.DiscoveryEnabled,
DiscoveryIntervalHours: settings.DiscoveryIntervalHours,
ShareOperationalContextWithCloud: settings.ShouldShareOperationalContextWithCloud(),
+ CloudContextPrivacy: settings.GetCloudContextPrivacy(),
PatrolReadiness: ptrToPatrolReadiness(patrolReadiness),
PatrolPreflight: cachedPatrolPreflightSnapshot(aiService),
}.NormalizeCollections()
diff --git a/internal/api/ai_handlers_test.go b/internal/api/ai_handlers_test.go
index 146ff0dcab..29ea3bbe2c 100644
--- a/internal/api/ai_handlers_test.go
+++ b/internal/api/ai_handlers_test.go
@@ -577,6 +577,110 @@ func TestAISettingsHandler_ShareOperationalContextWithCloud_RoundTrip(t *testing
}
}
+func TestAISettingsHandler_CloudContextPrivacy_RoundTrip(t *testing.T) {
+ t.Parallel()
+
+ tmp := t.TempDir()
+ cfg := &config.Config{DataPath: tmp}
+ persistence := config.NewConfigPersistence(tmp)
+
+ handler := newTestAISettingsHandler(cfg, persistence, nil)
+
+ getSettings := func(t *testing.T) AISettingsResponse {
+ t.Helper()
+ req := newLoopbackRequest(http.MethodGet, "/api/settings/ai", nil)
+ rec := httptest.NewRecorder()
+ handler.HandleGetAISettings(rec, req)
+ if rec.Code != http.StatusOK {
+ t.Fatalf("GET status = %d, body=%s", rec.Code, rec.Body.String())
+ }
+ // The dial is always serialized (no omitempty) so the operator UI can bind
+ // a 3-option control to its concrete value.
+ if !strings.Contains(rec.Body.String(), `"cloud_context_privacy":`) {
+ t.Fatalf("expected cloud_context_privacy in GET body, got %s", rec.Body.String())
+ }
+ var resp AISettingsResponse
+ if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
+ t.Fatalf("decode: %v", err)
+ }
+ return resp
+ }
+
+ updateSettings := func(t *testing.T, req AISettingsUpdateRequest) (AISettingsResponse, int) {
+ t.Helper()
+ body, _ := json.Marshal(req)
+ httpReq := newLoopbackRequest(http.MethodPut, "/api/settings/ai", bytes.NewReader(body))
+ rec := httptest.NewRecorder()
+ handler.HandleUpdateAISettings(rec, httpReq)
+ var resp AISettingsResponse
+ if rec.Code == http.StatusOK {
+ if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
+ t.Fatalf("decode: %v", err)
+ }
+ }
+ return resp, rec.Code
+ }
+
+ // A fresh install defaults to the "full" posture.
+ if got := getSettings(t).CloudContextPrivacy; got != config.CloudContextPrivacyFull {
+ t.Fatalf("expected default cloud_context_privacy=full, got %q", got)
+ }
+
+ // Selecting "redacted" persists and syncs the legacy share flag off (the
+ // redaction seam still reads it until the dial is wired into the seam directly).
+ resp, code := updateSettings(t, AISettingsUpdateRequest{
+ Enabled: ptr(true),
+ Model: ptr("ollama:llama3"),
+ OllamaBaseURL: ptr("http://localhost:11434"),
+ CloudContextPrivacy: ptr(config.CloudContextPrivacyRedacted),
+ })
+ if code != http.StatusOK {
+ t.Fatalf("PUT redacted status = %d", code)
+ }
+ if resp.CloudContextPrivacy != config.CloudContextPrivacyRedacted {
+ t.Fatalf("expected response cloud_context_privacy=redacted, got %q", resp.CloudContextPrivacy)
+ }
+ if resp.ShareOperationalContextWithCloud {
+ t.Fatalf("expected redacted to sync legacy share flag off")
+ }
+ if got := getSettings(t); got.CloudContextPrivacy != config.CloudContextPrivacyRedacted || got.ShareOperationalContextWithCloud {
+ t.Fatalf("expected persisted redacted + share off, got %+v", got)
+ }
+
+ // "full" persists and syncs the legacy share flag on.
+ resp, code = updateSettings(t, AISettingsUpdateRequest{CloudContextPrivacy: ptr(config.CloudContextPrivacyFull)})
+ if code != http.StatusOK {
+ t.Fatalf("PUT full status = %d", code)
+ }
+ if resp.CloudContextPrivacy != config.CloudContextPrivacyFull || !resp.ShareOperationalContextWithCloud {
+ t.Fatalf("expected full + share on, got %+v", resp)
+ }
+
+ // "local_only" persists and (until increment 2) maps the legacy seam to off.
+ resp, code = updateSettings(t, AISettingsUpdateRequest{CloudContextPrivacy: ptr(config.CloudContextPrivacyLocalOnly)})
+ if code != http.StatusOK {
+ t.Fatalf("PUT local_only status = %d", code)
+ }
+ if resp.CloudContextPrivacy != config.CloudContextPrivacyLocalOnly || resp.ShareOperationalContextWithCloud {
+ t.Fatalf("expected local_only + share off, got %+v", resp)
+ }
+
+ // Omitting the field leaves the persisted dial untouched.
+ resp, code = updateSettings(t, AISettingsUpdateRequest{Model: ptr("ollama:llama3")})
+ if code != http.StatusOK {
+ t.Fatalf("PUT omitted status = %d", code)
+ }
+ if resp.CloudContextPrivacy != config.CloudContextPrivacyLocalOnly {
+ t.Fatalf("expected omitted field to preserve local_only, got %q", resp.CloudContextPrivacy)
+ }
+
+ // An unrecognized value is rejected rather than silently coerced.
+ _, code = updateSettings(t, AISettingsUpdateRequest{CloudContextPrivacy: ptr("bogus")})
+ if code != http.StatusBadRequest {
+ t.Fatalf("expected 400 for invalid cloud_context_privacy, got %d", code)
+ }
+}
+
func TestAISettingsHandler_GetSettingsClampsPaidControlsToEntitlements(t *testing.T) {
t.Parallel()
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index 6e95df6d42..d22324f6a8 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -1336,6 +1336,7 @@ func TestContract_AISettingsUpdateProviderResolutionJSONSnapshot(t *testing.T) {
"protected_guests":[],
"discovery_enabled":false,
"share_operational_context_with_cloud":false,
+ "cloud_context_privacy":"full",
"patrol_readiness":{
"status":"warning",
"ready":true,
@@ -1481,6 +1482,7 @@ func TestContract_AISettingsBYOKOverrideDoesNotExposeQuickstartInventoryJSONSnap
"protected_guests":[],
"discovery_enabled":false,
"share_operational_context_with_cloud":false,
+ "cloud_context_privacy":"full",
"patrol_readiness":{"status":"not_ready","ready":false,"cause":"service_unavailable","summary":"Pulse Patrol service is not available.","checks":[{"id":"service","status":"not_ready","cause":"service_unavailable","label":"Patrol service","message":"Pulse Patrol service is not available.","action":"restart_service"}]}
}`
@@ -3487,6 +3489,7 @@ func TestContract_HostedAISettingsDoesNotAutoBootstrapQuickstartJSONSnapshot(t *
"protected_guests":[],
"discovery_enabled":false,
"share_operational_context_with_cloud":false,
+ "cloud_context_privacy":"full",
"patrol_readiness":{"status":"not_ready","ready":false,"cause":"service_unavailable","summary":"Pulse Patrol service is not available.","checks":[{"id":"service","status":"not_ready","cause":"service_unavailable","label":"Patrol service","message":"Pulse Patrol service is not available.","action":"restart_service"}]}
}`
@@ -3551,6 +3554,7 @@ func TestContract_AISettingsRetiredQuickstartAliasJSONSnapshot(t *testing.T) {
"protected_guests":[],
"discovery_enabled":false,
"share_operational_context_with_cloud":false,
+ "cloud_context_privacy":"full",
"patrol_readiness":{"status":"not_ready","ready":false,"cause":"service_unavailable","summary":"Pulse Patrol service is not available.","checks":[{"id":"service","status":"not_ready","cause":"service_unavailable","label":"Patrol service","message":"Pulse Patrol service is not available.","action":"restart_service"}]}
}`
@@ -3620,6 +3624,7 @@ func TestContract_AISettingsOllamaAuthJSONSnapshot(t *testing.T) {
"protected_guests":[],
"discovery_enabled":false,
"share_operational_context_with_cloud":false,
+ "cloud_context_privacy":"full",
"patrol_readiness":{"status":"not_ready","ready":false,"cause":"service_unavailable","summary":"Pulse Patrol service is not available.","checks":[{"id":"service","status":"not_ready","cause":"service_unavailable","label":"Patrol service","message":"Pulse Patrol service is not available.","action":"restart_service"}]}
}`
@@ -4182,6 +4187,7 @@ func TestContract_HostedTenantAISettingsDoesNotAutoBootstrapQuickstartJSONSnapsh
"protected_guests":[],
"discovery_enabled":false,
"share_operational_context_with_cloud":false,
+ "cloud_context_privacy":"full",
"patrol_readiness":{"status":"not_ready","ready":false,"cause":"service_unavailable","summary":"Pulse Patrol service is not available.","checks":[{"id":"service","status":"not_ready","cause":"service_unavailable","label":"Patrol service","message":"Pulse Patrol service is not available.","action":"restart_service"}]}
}`
diff --git a/internal/config/ai.go b/internal/config/ai.go
index 269698354f..fda44c9752 100644
--- a/internal/config/ai.go
+++ b/internal/config/ai.go
@@ -112,7 +112,28 @@ type AIConfig struct {
// Opting in shares the cloud-safe operational context while genuinely
// identifying fields (hostname, IP, alias, platform ID) stay redacted. Local
// (Ollama) models always receive full context and are unaffected by this flag.
+ //
+ // Deprecated: superseded by CloudContextPrivacy. Retained as the load-bearing
+ // behavior field the redaction seam still reads until the dial is wired into
+ // the seam directly (privacy-redesign increment 2). CloudContextPrivacy is the
+ // canonical operator control; the settings handler keeps this field in sync
+ // (full -> true, redacted/local_only -> false) and config load migrates the
+ // dial out of it for pre-dial configs.
ShareOperationalContextWithCloud bool `json:"share_operational_context_with_cloud,omitempty"`
+
+ // CloudContextPrivacy is the single privacy dial governing what infrastructure
+ // context cloud models may see. It supersedes the boolean
+ // ShareOperationalContextWithCloud with three explicit levels:
+ // - "full" (default) cloud models get the same operational context as
+ // local models so the Assistant can answer with real detail.
+ // - "redacted" cloud models get the PII-free operational context only
+ // (today's opt-in behavior): commands/paths/ports yes,
+ // identifying hostnames/IPs/aliases stripped.
+ // - "local_only" no infrastructure context is sent to cloud models at all;
+ // use a local (Ollama) model for resource-specific answers.
+ // Local (Ollama) models always receive full context regardless of this dial.
+ // Empty normalizes to "full" via GetCloudContextPrivacy.
+ CloudContextPrivacy string `json:"cloud_context_privacy,omitempty"`
}
// AIProvider constants
@@ -126,6 +147,21 @@ const (
AIProviderQuickstart = "quickstart" // Retired Pulse-hosted proxy marker retained only for legacy config migration.
)
+// Cloud context privacy dial constants. These are the canonical values for
+// AIConfig.CloudContextPrivacy — the single dial controlling what infrastructure
+// context cloud models may see. Local (Ollama) models always receive full context.
+const (
+ // CloudContextPrivacyFull - cloud models receive the same operational context
+ // as local models so the Assistant answers with real, resource-specific detail.
+ CloudContextPrivacyFull = "full"
+ // CloudContextPrivacyRedacted - cloud models receive only PII-free operational
+ // context (commands/paths/ports); identifying hostnames/IPs/aliases are stripped.
+ CloudContextPrivacyRedacted = "redacted"
+ // CloudContextPrivacyLocalOnly - no infrastructure context is sent to cloud
+ // models; resource-specific answers require a local model.
+ CloudContextPrivacyLocalOnly = "local_only"
+)
+
// AI Control Level constants
const (
// ControlLevelReadOnly - AI can only query infrastructure, no control tools available
@@ -231,6 +267,10 @@ func NewDefaultAIConfig() *AIConfig {
// Default to critical-only so alert-triggered investigations stay
// token-conservative out of the box. Operators can opt warnings in.
PatrolAlertTriggerMinSeverity: AlertTriggerSeverityCritical,
+ // Cloud context privacy defaults to "full": a self-hosted Pulse should
+ // answer with real resource detail on cloud models out of the box.
+ // Operators who want redaction or a local-only posture pick it explicitly.
+ CloudContextPrivacy: CloudContextPrivacyFull,
}
}
@@ -920,3 +960,33 @@ func (c *AIConfig) ShouldShareOperationalContextWithCloud() bool {
}
return c.ShareOperationalContextWithCloud
}
+
+// NormalizeCloudContextPrivacy validates and canonicalizes a cloud context
+// privacy value. It returns the normalized value and whether the input was a
+// recognized level. Empty input is treated as the default ("full") and reported
+// as valid; any other unrecognized value reports invalid (so the settings API
+// can reject hand-crafted payloads) while still returning the safe default.
+func NormalizeCloudContextPrivacy(value string) (string, bool) {
+ switch strings.ToLower(strings.TrimSpace(value)) {
+ case "":
+ return CloudContextPrivacyFull, true
+ case CloudContextPrivacyFull:
+ return CloudContextPrivacyFull, true
+ case CloudContextPrivacyRedacted:
+ return CloudContextPrivacyRedacted, true
+ case CloudContextPrivacyLocalOnly:
+ return CloudContextPrivacyLocalOnly, true
+ default:
+ return CloudContextPrivacyFull, false
+ }
+}
+
+// GetCloudContextPrivacy returns the canonical cloud context privacy level,
+// normalizing empty/unknown values to the default ("full"). Nil-safe.
+func (c *AIConfig) GetCloudContextPrivacy() string {
+ if c == nil {
+ return CloudContextPrivacyFull
+ }
+ normalized, _ := NormalizeCloudContextPrivacy(c.CloudContextPrivacy)
+ return normalized
+}
diff --git a/internal/config/ai_config_test.go b/internal/config/ai_config_test.go
index 0a87f6c3d9..c415ee9690 100644
--- a/internal/config/ai_config_test.go
+++ b/internal/config/ai_config_test.go
@@ -46,6 +46,59 @@ func TestAIConfig_ShouldShareOperationalContextWithCloud(t *testing.T) {
}
}
+func TestAIConfig_GetCloudContextPrivacy(t *testing.T) {
+ // Nil-safe and defaults to the homelab-friendly "full" posture.
+ if got := (*AIConfig)(nil).GetCloudContextPrivacy(); got != CloudContextPrivacyFull {
+ t.Fatalf("nil config cloud privacy = %q, want %q", got, CloudContextPrivacyFull)
+ }
+ // A fresh config opts into full context so the Assistant answers with detail.
+ if got := NewDefaultAIConfig().GetCloudContextPrivacy(); got != CloudContextPrivacyFull {
+ t.Fatalf("default config cloud privacy = %q, want %q", got, CloudContextPrivacyFull)
+ }
+ // Empty/unset normalizes to full.
+ if got := (&AIConfig{}).GetCloudContextPrivacy(); got != CloudContextPrivacyFull {
+ t.Fatalf("zero-value cloud privacy = %q, want %q", got, CloudContextPrivacyFull)
+ }
+
+ cases := []struct {
+ in string
+ want string
+ }{
+ {CloudContextPrivacyFull, CloudContextPrivacyFull},
+ {CloudContextPrivacyRedacted, CloudContextPrivacyRedacted},
+ {CloudContextPrivacyLocalOnly, CloudContextPrivacyLocalOnly},
+ {" Redacted ", CloudContextPrivacyRedacted}, // trimmed + lowercased
+ {"LOCAL_ONLY", CloudContextPrivacyLocalOnly},
+ {"bogus", CloudContextPrivacyFull}, // unknown values fall back to the safe default
+ }
+ for _, tc := range cases {
+ if got := (&AIConfig{CloudContextPrivacy: tc.in}).GetCloudContextPrivacy(); got != tc.want {
+ t.Fatalf("GetCloudContextPrivacy(%q) = %q, want %q", tc.in, got, tc.want)
+ }
+ }
+}
+
+func TestNormalizeCloudContextPrivacy(t *testing.T) {
+ cases := []struct {
+ in string
+ want string
+ wantValid bool
+ }{
+ {"", CloudContextPrivacyFull, true},
+ {"full", CloudContextPrivacyFull, true},
+ {"redacted", CloudContextPrivacyRedacted, true},
+ {"local_only", CloudContextPrivacyLocalOnly, true},
+ {" FULL ", CloudContextPrivacyFull, true},
+ {"nonsense", CloudContextPrivacyFull, false},
+ }
+ for _, tc := range cases {
+ got, valid := NormalizeCloudContextPrivacy(tc.in)
+ if got != tc.want || valid != tc.wantValid {
+ t.Fatalf("NormalizeCloudContextPrivacy(%q) = (%q, %v), want (%q, %v)", tc.in, got, valid, tc.want, tc.wantValid)
+ }
+ }
+}
+
func TestEffectiveControlLevelForEntitlement(t *testing.T) {
tests := []struct {
name string
@@ -951,6 +1004,9 @@ func TestNewDefaultAIConfig(t *testing.T) {
if !config.PatrolAnomalyTriggersEnabled {
t.Error("Default anomaly-triggered patrols should be enabled")
}
+ if config.CloudContextPrivacy != CloudContextPrivacyFull {
+ t.Errorf("Default cloud context privacy should be %q, got %q", CloudContextPrivacyFull, config.CloudContextPrivacy)
+ }
}
func TestAIConfig_PatrolEventTriggerSettings(t *testing.T) {
diff --git a/internal/config/persistence.go b/internal/config/persistence.go
index e7eb5c7b97..bdd469541f 100644
--- a/internal/config/persistence.go
+++ b/internal/config/persistence.go
@@ -2130,7 +2130,25 @@ func (c *ConfigPersistence) LoadAIConfig() (*AIConfig, error) {
}
migratedQuickstartAliases := settings.NormalizeQuickstartModelAliases()
- if migratedPlaintext || migratedLegacyFields || migratedControlLevel || migratedPatrolTriggerFields || migratedQuickstartAliases {
+ // Migration: derive the cloud_context_privacy dial from the legacy
+ // share_operational_context_with_cloud toggle for configs persisted before
+ // the dial existed. This preserves each existing install's current cloud
+ // behavior (legacy on -> "full", legacy off/absent -> "redacted") instead of
+ // silently adopting the fresh-install default ("full"). The legacy boolean is
+ // left untouched so the redaction seam that still reads it behaves identically
+ // until the dial is wired into the seam directly (privacy-redesign increment 2).
+ migratedCloudContextPrivacy := false
+ if _, cloudPrivacyPresent := legacyRaw["cloud_context_privacy"]; !cloudPrivacyPresent {
+ legacyShare, _ := decodeOptionalJSONBool(legacyRaw["share_operational_context_with_cloud"])
+ if legacyShare {
+ settings.CloudContextPrivacy = CloudContextPrivacyFull
+ } else {
+ settings.CloudContextPrivacy = CloudContextPrivacyRedacted
+ }
+ migratedCloudContextPrivacy = true
+ }
+
+ if migratedPlaintext || migratedLegacyFields || migratedControlLevel || migratedPatrolTriggerFields || migratedQuickstartAliases || migratedCloudContextPrivacy {
jsonData, err := json.Marshal(*settings)
if err != nil {
return nil, fmt.Errorf("marshal ai config migration rewrite: %w", err)
@@ -2143,6 +2161,8 @@ func (c *ConfigPersistence) LoadAIConfig() (*AIConfig, error) {
Bool("legacy_fields_migrated", migratedLegacyFields).
Bool("patrol_trigger_fields_migrated", migratedPatrolTriggerFields).
Bool("quickstart_aliases_migrated", migratedQuickstartAliases).
+ Bool("cloud_context_privacy_migrated", migratedCloudContextPrivacy).
+ Str("cloud_context_privacy", settings.CloudContextPrivacy).
Bool("plaintext_migrated", migratedPlaintext).
Msg("Migrated AI configuration")
}
diff --git a/internal/config/persistence_ai_test.go b/internal/config/persistence_ai_test.go
index 2421d71664..b64e6dabed 100644
--- a/internal/config/persistence_ai_test.go
+++ b/internal/config/persistence_ai_test.go
@@ -309,6 +309,82 @@ func TestPersistence_AIConfig_MigratesLegacyPatrolEventTriggerToggle(t *testing.
assert.False(t, loaded.PatrolEventTriggersEnabled)
}
+func TestPersistence_AIConfig_MigratesCloudContextPrivacyFromLegacyShareToggle(t *testing.T) {
+ writeLegacy := func(t *testing.T, p *ConfigPersistence, dir string, legacy map[string]interface{}) {
+ t.Helper()
+ data, err := json.Marshal(legacy)
+ require.NoError(t, err)
+ if p.crypto != nil {
+ data, err = p.crypto.Encrypt(data)
+ require.NoError(t, err)
+ }
+ require.NoError(t, os.WriteFile(filepath.Join(dir, "ai.enc"), data, 0o600))
+ }
+
+ t.Run("legacy share on derives full and leaves the legacy flag untouched", func(t *testing.T) {
+ tempDir := t.TempDir()
+ p := NewConfigPersistence(tempDir)
+ writeLegacy(t, p, tempDir, map[string]interface{}{
+ "enabled": true,
+ "share_operational_context_with_cloud": true,
+ })
+
+ loaded, err := p.LoadAIConfig()
+ require.NoError(t, err)
+ assert.Equal(t, CloudContextPrivacyFull, loaded.CloudContextPrivacy)
+ // The redaction seam still reads the legacy boolean until increment 2, so
+ // migration must preserve it byte-for-byte.
+ assert.True(t, loaded.ShareOperationalContextWithCloud)
+ })
+
+ t.Run("legacy share absent derives redacted preserving current behavior", func(t *testing.T) {
+ tempDir := t.TempDir()
+ p := NewConfigPersistence(tempDir)
+ writeLegacy(t, p, tempDir, map[string]interface{}{"enabled": true})
+
+ loaded, err := p.LoadAIConfig()
+ require.NoError(t, err)
+ assert.Equal(t, CloudContextPrivacyRedacted, loaded.CloudContextPrivacy)
+ assert.False(t, loaded.ShareOperationalContextWithCloud)
+ })
+
+ t.Run("legacy share explicit off derives redacted", func(t *testing.T) {
+ tempDir := t.TempDir()
+ p := NewConfigPersistence(tempDir)
+ writeLegacy(t, p, tempDir, map[string]interface{}{
+ "enabled": true,
+ "share_operational_context_with_cloud": false,
+ })
+
+ loaded, err := p.LoadAIConfig()
+ require.NoError(t, err)
+ assert.Equal(t, CloudContextPrivacyRedacted, loaded.CloudContextPrivacy)
+ })
+
+ t.Run("explicit dial value is preserved and not re-derived", func(t *testing.T) {
+ tempDir := t.TempDir()
+ p := NewConfigPersistence(tempDir)
+ writeLegacy(t, p, tempDir, map[string]interface{}{
+ "enabled": true,
+ "share_operational_context_with_cloud": true, // would imply "full" if re-derived
+ "cloud_context_privacy": CloudContextPrivacyLocalOnly,
+ })
+
+ loaded, err := p.LoadAIConfig()
+ require.NoError(t, err)
+ assert.Equal(t, CloudContextPrivacyLocalOnly, loaded.CloudContextPrivacy)
+ })
+
+ t.Run("fresh install with no config file defaults to full", func(t *testing.T) {
+ tempDir := t.TempDir()
+ p := NewConfigPersistence(tempDir)
+
+ loaded, err := p.LoadAIConfig()
+ require.NoError(t, err)
+ assert.Equal(t, CloudContextPrivacyFull, loaded.CloudContextPrivacy)
+ })
+}
+
func TestPersistence_AIConfig_NormalizesGranularPatrolTriggerSettingsOnSave(t *testing.T) {
tempDir := t.TempDir()
p := NewConfigPersistence(tempDir)