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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Make the redaction seam obey the cloud_context_privacy dial (increment 2)
rcourtman3e3c601317f7
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.mdindex 3c962e6e16..b5bed9afab 100644--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md@@ -107,31 +107,38 @@ deriving an older display status from `workflowStatusHistory`.`GetCloudContextPrivacy` / `NormalizeCloudContextPrivacy`) with three levels:`full` (default), `redacted`, and `local_only`. It supersedes the legacyboolean `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 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 `Cloud model privacy` setting, rather than silently- degrading the answer.+ (`ShouldShareOperationalContextWithCloud`), which is retained only for API+ back-compat and is no longer read by the redaction seam. `/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 reads the dial directly at `internal/ai/chat/service.go`,+ resolving `cloudPrivacyLevel` once per turn (failing closed to `redacted` when+ no config snapshot is available) and threading it into both the proactive+ prefetch and the model-boundary sanitizer:+ - `full`: the model-bound resource-policy sanitizer is invoked with+ `modelboundary.RedactLocalOnlyResourcesOnly()`, so real identifiers (hostname,+ IP, alias, name) for ordinary (Internal) and Sensitive (local-first) resources+ reach the cloud model, while resources the policy engine routes+ `ResourceRoutingScopeLocalOnly` (Restricted) stay redacted as a HARD FLOOR a+ blanket dial must never override. Prompt-secret sanitation (credentials) always+ runs — credentials never cross the boundary at any level.+ - `redacted`: the sanitizer redacts every policied resource's identifiers as+ before, and `internal/ai/chat/context_prefetch.go` surfaces the PII-free+ operational context from `servicediscovery.FormatCloudSafeContext` (service+ identity, access command, config/data/log paths, ports) for governed+ resources, allow-listed through `modelboundary.AllowResourcePolicyText` so it+ is not re-stripped. Identifying fields stay redacted.+ - `local_only`: `context_prefetch.go` injects NO proactive infrastructure+ context for the cloud turn (only a transparency directive telling the+ Assistant to disclose the withholding and point at the `Cloud model privacy`+ setting / a local model), and the sanitizer still redacts identifiers as a+ backstop for any context arriving via tool results, handoff text, or user text.+ Local (Ollama) routing is unaffected and always receives full context+ (`RequestSanitizerForModel` returns nil for local models).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 thediff --git a/internal/ai/chat/context_prefetch.go b/internal/ai/chat/context_prefetch.goindex 363a0d9651..984329bebf 100644--- a/internal/ai/chat/context_prefetch.go+++ b/internal/ai/chat/context_prefetch.go@@ -7,28 +7,46 @@ import ("strings""github.com/rcourtman/pulse-go-rewrite/internal/ai/tools"+ "github.com/rcourtman/pulse-go-rewrite/internal/config""github.com/rcourtman/pulse-go-rewrite/internal/servicediscovery""github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources""github.com/rs/zerolog/log")-// CloudContextPolicy controls whether governed resource context may be shared-// with a cloud-routed model as PII-free operational context. Both fields must-// be true for the cloud-safe operational context to be injected; the zero value-// preserves the historical terse-redaction behavior for governed resources.+// CloudContextPolicy governs how much governed-resource context reaches a+// cloud-routed model for this turn, driven by the AIConfig.CloudContextPrivacy+// dial. The zero value (no cloud routing) preserves the local-model behavior of+// injecting full context.type CloudContextPolicy struct {- // CloudRouting reports that this turn routes to an external (cloud) provider,- // where governed resource identity is otherwise redacted to a terse summary.+ // CloudRouting reports that this turn routes to an external (cloud) provider.CloudRouting bool- // ShareOperationalContext reports that the operator opted in via- // AIConfig.ShareOperationalContextWithCloud.- ShareOperationalContext bool+ // Level is the persisted cloud_context_privacy dial value (full | redacted |+ // local_only). An empty or unknown value fails closed to redacted.+ Level string+}++// level normalizes the dial, failing closed to "redacted" for empty/unknown+// values so a missing setting never widens what reaches a cloud model.+func (p CloudContextPolicy) level() string {+ switch p.Level {+ case config.CloudContextPrivacyFull, config.CloudContextPrivacyRedacted, config.CloudContextPrivacyLocalOnly:+ return p.Level+ default:+ return config.CloudContextPrivacyRedacted+ }}// sharesCloudOperationalContext reports whether governed resources should have-// their PII-free operational context injected for this turn.+// their PII-free operational context injected for this cloud turn. True for the+// full and redacted levels; local_only sends no infrastructure context at all.func (p CloudContextPolicy) sharesCloudOperationalContext() bool {- return p.CloudRouting && p.ShareOperationalContext+ return p.CloudRouting && p.level() != config.CloudContextPrivacyLocalOnly+}++// suppressesCloudContext reports whether ALL proactive infrastructure context+// must be withheld from this cloud turn (the local_only level).+func (p CloudContextPolicy) suppressesCloudContext() bool {+ return p.CloudRouting && p.level() == config.CloudContextPrivacyLocalOnly}// ResourceMention represents a detected resource mention in a user message@@ -172,6 +190,17 @@ func (p *ContextPrefetcher) PrefetchWithCloudPolicy(ctx context.Context, messageInt("mentions_found", len(mentions)).Msg("[ContextPrefetch] Found resource mentions in message")+ // local_only: send NO infrastructure context to the cloud model. Resolve the+ // mentions (so routing validation still recognizes them) but inject only a+ // transparency directive instead of any resource detail, and skip discovery.+ if cloudPolicy.suppressesCloudContext() {+ log.Info().Int("mentions", len(mentions)).Msg("[ContextPrefetch] Cloud privacy=local_only; withholding all infra context")+ return &PrefetchedContext{+ Mentions: mentions,+ Summary: localOnlyCloudContextDirective(),+ }+ }+// Gather discovery data for each mentionvar discoveries []*tools.ResourceDiscoveryInfoif p.discoveryProvider != nil {@@ -730,13 +759,10 @@ func (p *ContextPrefetcher) formatContextSummaryWithPolicy(mentions []ResourceMecontinue}}+ // full / redacted without discovery data falls back to the terse+ // governed summary. local_only never reaches here — it is withheld+ // entirely upstream in PrefetchWithCloudPolicy.sb.WriteString(unifiedresources.FormatResourcePolicyGovernedSummary(mention.AISafeSummary, mention.Policy))- // Transparency: when context was withheld because this turn routes to- // a cloud model and sharing is off, instruct the Assistant to say so- // and point at the opt-in.- if cloudPolicy.CloudRouting && !cloudPolicy.ShareOperationalContext {- sb.WriteString(cloudRedactionTransparencyDirective())- }continue}@@ -954,16 +980,16 @@ func formatCloudSafeGovernedBlock(cloudSafe string) string {return sb.String()}-// cloudRedactionTransparencyDirective instructs the Assistant to disclose, in-// its reply, that resource-specific operational context was withheld because the-// turn routes to a cloud model with sharing disabled, and to point at the-// opt-in. Pulse's privacy posture is only trustworthy if the redaction is-// visible to the user rather than silently degrading the answer.-func cloudRedactionTransparencyDirective() string {+// localOnlyCloudContextDirective is injected in place of all resource detail when+// the operator set Cloud model privacy to "local_only": no infrastructure context+// is sent to the cloud model. It instructs the Assistant to disclose this rather+// than silently giving a generic answer, and to point at the remedy. Pulse's+// privacy posture is only trustworthy when the withholding is visible to the user.+func localOnlyCloudContextDirective() string {return strings.Join([]string{- "[Cloud routing transparency]",- "This resource's operational details (access commands, config/data/log paths, ports) were withheld because this chat routes to a cloud model and operational-context sharing with cloud models is off.",- "In your reply, tell the user you cannot give resource-specific steps for this reason, and that they can enable \"Share operational context with cloud models\" in Settings → AI (or use a local Ollama model) to get specific guidance. Do not fabricate the withheld details.",+ "=== PULSE CLOUD PRIVACY: LOCAL ONLY ===",+ "No infrastructure context for the mentioned resources was sent to this cloud model because Cloud model privacy is set to \"Local only\".",+ "In your reply, tell the user you cannot give resource-specific steps for this reason, and that they can either switch the Assistant to a local (Ollama) model or change Cloud model privacy in Settings → Assistant & Patrol to \"Full\" or \"Redacted\". Do not fabricate the withheld details.","","",}, "\n")diff --git a/internal/ai/chat/context_prefetch_cloud_context_test.go b/internal/ai/chat/context_prefetch_cloud_context_test.goindex d4f26bd29b..e8bf8d8ed4 100644--- a/internal/ai/chat/context_prefetch_cloud_context_test.go+++ b/internal/ai/chat/context_prefetch_cloud_context_test.go@@ -7,6 +7,7 @@ import ("github.com/rcourtman/pulse-go-rewrite/internal/ai/modelboundary""github.com/rcourtman/pulse-go-rewrite/internal/ai/providers""github.com/rcourtman/pulse-go-rewrite/internal/ai/tools"+ "github.com/rcourtman/pulse-go-rewrite/internal/config""github.com/rcourtman/pulse-go-rewrite/internal/models""github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources")@@ -58,13 +59,16 @@ func homeAssistantDiscovery() *tools.ResourceDiscoveryInfo {}}-func TestPrefetcherCloudContext_OptInSharesAccessPathWithoutPII(t *testing.T) {+func TestPrefetcherCloudContext_RedactedSharesAccessPathWithoutPII(t *testing.T) {prefetcher := NewContextPrefetcher(newTestReadState(models.StateSnapshot{}), nil)+ // The "redacted" level shares the PII-free operational context for governed+ // resources: useful commands/paths/ports reach the model, identifying+ // hostnames/IPs do not.summary, spans := prefetcher.formatContextSummaryWithPolicy([]ResourceMention{governedHomeAssistantMention()},[]*tools.ResourceDiscoveryInfo{homeAssistantDiscovery()},- CloudContextPolicy{CloudRouting: true, ShareOperationalContext: true},+ CloudContextPolicy{CloudRouting: true, Level: config.CloudContextPrivacyRedacted},)// The operational access path reaches the model.@@ -103,50 +107,65 @@ func TestPrefetcherCloudContext_OptInSharesAccessPathWithoutPII(t *testing.T) {}}-func TestPrefetcherCloudContext_OptOutKeepsRedaction(t *testing.T) {+func TestPrefetcherCloudContext_FullKeepsGovernedPIIFreeInPrefetch(t *testing.T) {prefetcher := NewContextPrefetcher(newTestReadState(models.StateSnapshot{}), nil)+ // Even at "full", the proactive prefetch keeps genuinely-governed resources+ // PII-free (the model-boundary sanitizer is where full opens identifiers up).+ // So a governed resource still surfaces only the cloud-safe operational span.summary, spans := prefetcher.formatContextSummaryWithPolicy([]ResourceMention{governedHomeAssistantMention()},[]*tools.ResourceDiscoveryInfo{homeAssistantDiscovery()},- CloudContextPolicy{CloudRouting: true, ShareOperationalContext: false},+ CloudContextPolicy{CloudRouting: true, Level: config.CloudContextPrivacyFull},)- // Current redaction holds: no access path, no paths.- if strings.Contains(summary, "pct exec") {- t.Fatalf("opt-out cloud summary must withhold the access path, got:\n%s", summary)+ if !strings.Contains(summary, "pct exec 101 -- docker exec homeassistant") {+ t.Fatalf("full prefetch must include the access path, got:\n%s", summary)}- if strings.Contains(summary, "/config/automations.yaml") {- t.Fatalf("opt-out cloud summary must withhold config paths, got:\n%s", summary)+ if strings.Contains(summary, "delly-ha-host") || strings.Contains(summary, "192.168.0.101") {+ t.Fatalf("full prefetch must not leak governed PII, got:\n%s", summary)}- if !strings.Contains(summary, unifiedresources.ResourcePolicyGovernedSummaryFooter()) {- t.Fatalf("opt-out cloud summary must keep the governed redaction, got:\n%s", summary)+ if len(spans) != 1 {+ t.Fatalf("expected one cloud-safe span at full, got %d: %#v", len(spans), spans)}+}- // Transparency: the Assistant is told to disclose the redaction + opt-in.- if !strings.Contains(summary, "Share operational context with cloud models") {- t.Fatalf("opt-out cloud summary must disclose the opt-in setting, got:\n%s", summary)- }+func TestPrefetcherCloudContext_RedactedWithoutDiscoveryKeepsGovernedSummary(t *testing.T) {+ prefetcher := NewContextPrefetcher(newTestReadState(models.StateSnapshot{}), nil)++ // Redacted with no discovery data falls back to the terse governed summary —+ // and never emits the obsolete opt-in transparency string.+ summary, spans := prefetcher.formatContextSummaryWithPolicy(+ []ResourceMention{governedHomeAssistantMention()},+ nil,+ CloudContextPolicy{CloudRouting: true, Level: config.CloudContextPrivacyRedacted},+ )+ if strings.Contains(summary, "pct exec") {+ t.Fatalf("redacted-without-discovery must withhold the access path, got:\n%s", summary)+ }+ if !strings.Contains(summary, unifiedresources.ResourcePolicyGovernedSummaryFooter()) {+ t.Fatalf("redacted-without-discovery must keep the governed redaction, got:\n%s", summary)+ }+ if strings.Contains(summary, "Share operational context with cloud models") {+ t.Fatalf("obsolete opt-in transparency string must not appear, got:\n%s", summary)+ }if len(spans) != 0 {- t.Fatalf("opt-out must not return cloud-safe spans, got %#v", spans)+ t.Fatalf("redacted-without-discovery must not return cloud-safe spans, got %#v", spans)}}func TestPrefetcherCloudContext_LocalRoutingUnaffected(t *testing.T) {prefetcher := NewContextPrefetcher(newTestReadState(models.StateSnapshot{}), nil)- // Local routing (Ollama): not a cloud turn, so no transparency directive and- // no cloud-safe injection — behavior matches the historical governed path.+ // Local routing (Ollama): not a cloud turn, so no cloud-safe injection —+ // behavior matches the historical governed path.summary, spans := prefetcher.formatContextSummaryWithPolicy([]ResourceMention{governedHomeAssistantMention()},[]*tools.ResourceDiscoveryInfo{homeAssistantDiscovery()},- CloudContextPolicy{CloudRouting: false, ShareOperationalContext: true},+ CloudContextPolicy{CloudRouting: false, Level: config.CloudContextPrivacyFull},)- if strings.Contains(summary, "Share operational context with cloud models") {- t.Fatalf("local routing must not emit the cloud transparency directive, got:\n%s", summary)- }if !strings.Contains(summary, unifiedresources.ResourcePolicyGovernedSummaryFooter()) {t.Fatalf("local routing must keep the governed prefetch redaction, got:\n%s", summary)}@@ -155,6 +174,33 @@ func TestPrefetcherCloudContext_LocalRoutingUnaffected(t *testing.T) {}}+func TestCloudContextPolicy_LevelSemantics(t *testing.T) {+ cases := []struct {+ name string+ policy CloudContextPolicy+ wantShares bool+ wantSuppresses bool+ }{+ {"full cloud", CloudContextPolicy{CloudRouting: true, Level: config.CloudContextPrivacyFull}, true, false},+ {"redacted cloud", CloudContextPolicy{CloudRouting: true, Level: config.CloudContextPrivacyRedacted}, true, false},+ {"local_only cloud", CloudContextPolicy{CloudRouting: true, Level: config.CloudContextPrivacyLocalOnly}, false, true},+ {"empty level fails closed to redacted", CloudContextPolicy{CloudRouting: true, Level: ""}, true, false},+ {"unknown level fails closed to redacted", CloudContextPolicy{CloudRouting: true, Level: "bogus"}, true, false},+ {"full but local routing shares nothing extra", CloudContextPolicy{CloudRouting: false, Level: config.CloudContextPrivacyFull}, false, false},+ {"local_only but local routing never suppresses", CloudContextPolicy{CloudRouting: false, Level: config.CloudContextPrivacyLocalOnly}, false, false},+ }+ for _, tc := range cases {+ t.Run(tc.name, func(t *testing.T) {+ if got := tc.policy.sharesCloudOperationalContext(); got != tc.wantShares {+ t.Fatalf("sharesCloudOperationalContext() = %v, want %v", got, tc.wantShares)+ }+ if got := tc.policy.suppressesCloudContext(); got != tc.wantSuppresses {+ t.Fatalf("suppressesCloudContext() = %v, want %v", got, tc.wantSuppresses)+ }+ })+ }+}+// policiedResourceProvider is a minimal modelboundary.UnifiedResourceProvider// returning one sensitive system container so the resource-policy sanitizer has// real PII candidates to redact.diff --git a/internal/ai/chat/service.go b/internal/ai/chat/service.goindex 5854edd5ad..f5a760b5f2 100644--- a/internal/ai/chat/service.go+++ b/internal/ai/chat/service.go@@ -676,12 +676,21 @@ func (s *Service) ExecuteStream(ctx context.Context, req ExecuteRequest, callbacStr("prompt", req.Prompt[:min(50, len(req.Prompt))]).Msg("[ChatService] Checking prefetcher")+ // Resolve the cloud_context_privacy dial once for this turn. It governs both+ // the proactive context prefetch and the model-boundary sanitizer below.+ // Fail closed to "redacted" when no config snapshot is available so a missing+ // setting never widens what reaches a cloud model.+ cloudPrivacyLevel := config.CloudContextPrivacyRedacted+ if cfgSnapshot != nil {+ cloudPrivacyLevel = cfgSnapshot.GetCloudContextPrivacy()+ }+mentionsFound := falsevar modelBoundaryAllowedCloudContext []stringif prefetcher != nil {cloudContextPolicy := CloudContextPolicy{- CloudRouting: modelboundary.ModelUsesExternalProvider(selectedModel),- ShareOperationalContext: cfgSnapshot.ShouldShareOperationalContextWithCloud(),+ CloudRouting: modelboundary.ModelUsesExternalProvider(selectedModel),+ Level: cloudPrivacyLevel,}prefetchCtx := prefetcher.PrefetchWithCloudPolicy(ctx, req.Prompt, req.Mentions, cloudContextPolicy)if prefetchCtx != nil {@@ -860,6 +869,15 @@ func (s *Service) ExecuteStream(ctx context.Context, req ExecuteRequest, callbacif len(modelBoundaryAllowedCloudContext) > 0 {sanitizerOptions = append(sanitizerOptions, modelboundary.AllowResourcePolicyText(modelBoundaryAllowedCloudContext...))}+ // Cloud model privacy = "full": the operator chose to share real resource+ // identifiers, so the model-boundary identifier redaction narrows to the+ // local-only floor (Restricted resources that must never leave local stay+ // redacted even at full). Prompt-secret sanitation (credentials) still runs+ // unconditionally. Local models never reach this sanitizer+ // (RequestSanitizerForModel returns nil).+ if cloudPrivacyLevel == config.CloudContextPrivacyFull {+ sanitizerOptions = append(sanitizerOptions, modelboundary.RedactLocalOnlyResourcesOnly())+ }loop.SetRequestSanitizer(modelboundary.RequestSanitizerForModel(attempt.Model, unifiedResourceProvider, sanitizerOptions...))loop.SetSuppressProviderErrorEvents(true)loop.SetSessionFSM(sessionFSM)diff --git a/internal/ai/chat/service_execute_additional_test.go b/internal/ai/chat/service_execute_additional_test.goindex 771aa3f541..b956bf3db1 100644--- a/internal/ai/chat/service_execute_additional_test.go+++ b/internal/ai/chat/service_execute_additional_test.go@@ -2597,7 +2597,12 @@ func TestService_ExecuteStream_HandoffResourceRelationshipContextIsModelOnly(t *loop := NewAgenticLoop(provider, executor, "system")svc := &Service{- cfg: &config.AIConfig{ChatModel: "openai:test"},+ // Redacted cloud privacy: governed identities must be stripped at the+ // external-provider boundary (the behavior this test pins). With the dial+ // at "full" the local-only floor would still protect Restricted resources,+ // but Sensitive ones would flow — that path is covered by the modelboundary+ // sanitizer tests.+ cfg: &config.AIConfig{ChatModel: "openai:test", CloudContextPrivacy: config.CloudContextPrivacyRedacted},sessions: store,executor: executor,agenticLoop: loop,diff --git a/internal/ai/modelboundary/resource_policy_sanitizer.go b/internal/ai/modelboundary/resource_policy_sanitizer.goindex 2dc0955dc5..3b557859dd 100644--- a/internal/ai/modelboundary/resource_policy_sanitizer.go+++ b/internal/ai/modelboundary/resource_policy_sanitizer.go@@ -23,6 +23,7 @@ type allUnifiedResourceProvider interface {type requestSanitizerOptions struct {resourcePolicyAllowedText []string+ localOnlyFloorOnly bool}// RequestSanitizerOption scopes model-bound sanitizer behavior for@@ -43,6 +44,23 @@ func AllowResourcePolicyText(values ...string) RequestSanitizerOption {}}+// RedactLocalOnlyResourcesOnly narrows the resource-identifier redaction pass to+// the hard floor: resources the policy engine routes local-only (Restricted+// sensitivity / "never leaves the local trust boundary"). Identifiers for all+// other resources — ordinary (Internal) and Sensitive (local-first) — may then+// reach a cloud model. It is the model-boundary half of the "full"+// cloud_context_privacy level: the operator chose to share real infrastructure+// detail, but an explicit local-only classification still must not be overridden+// by a blanket dial. Prompt-secret sanitation (API keys, passwords, tokens) ALWAYS+// still runs — credentials never cross the model boundary regardless of this+// option. Callers must only set this from the persisted privacy dial, never from+// raw user text.+func RedactLocalOnlyResourcesOnly() RequestSanitizerOption {+ return func(opts *requestSanitizerOptions) {+ opts.localOnlyFloorOnly = true+ }+}+// RequestSanitizerForModel returns a sanitizer for non-local model traffic.// It is intentionally applied at the final provider transport boundary so// operator-entered prompts, handoff text, tool-result turns, and provider-bound@@ -57,7 +75,14 @@ func RequestSanitizerForModel(model string, provider UnifiedResourceProvider, opopt(&options)}}+ // At the "full" dial the operator opted into sharing real resource identifiers,+ // so the redaction pass narrows to the local-only floor (resources that must+ // never leave the local trust boundary); everything else flows. Otherwise the+ // pass covers every policied resource. Prompt-secret sanitation below always runs.resources := resourcePolicySanitizerResources(provider)+ if options.localOnlyFloorOnly {+ resources = localOnlyRoutedResources(resources)+ }return func(req providers.ChatRequest) providers.ChatRequest {req = sanitizeProviderRequestForPromptSecrets(req)if len(resources) == 0 {@@ -130,6 +155,22 @@ func resourcesWithPolicy(resources []unifiedresources.Resource) []unifiedresourcreturn filtered}+// localOnlyRoutedResources keeps only resources the policy engine routes+// local-only — the "never leaves the local trust boundary" floor that the "full"+// cloud_context_privacy dial must not override.+func localOnlyRoutedResources(resources []unifiedresources.Resource) []unifiedresources.Resource {+ filtered := make([]unifiedresources.Resource, 0, len(resources))+ for _, resource := range resources {+ if resource.Policy == nil {+ continue+ }+ if resource.Policy.Routing.Scope == unifiedresources.ResourceRoutingScopeLocalOnly {+ filtered = append(filtered, resource)+ }+ }+ return filtered+}+func sanitizeProviderRequestForResources(req providers.ChatRequest, resources []unifiedresources.Resource, allowedText []string) providers.ChatRequest {if len(resources) == 0 {return reqdiff --git a/internal/ai/modelboundary/resource_policy_sanitizer_test.go b/internal/ai/modelboundary/resource_policy_sanitizer_test.goindex 4da5faddd1..c121e30eae 100644--- a/internal/ai/modelboundary/resource_policy_sanitizer_test.go+++ b/internal/ai/modelboundary/resource_policy_sanitizer_test.go@@ -149,6 +149,64 @@ func TestRequestSanitizerForModelAllowsPulseGeneratedInventoryExportOnly(t *test}}+func TestRequestSanitizerForModel_RedactLocalOnlyResourcesOnlyKeepsFloorAndSecrets(t *testing.T) {+ // The "full" cloud_context_privacy level. A Sensitive (local-first) resource's+ // identifiers may reach the cloud model, but a Restricted (local-only) resource+ // stays redacted as a hard floor, and credentials are always stripped.+ sensitiveVM := unifiedresources.Resource{+ ID: "vm-200",+ Type: unifiedresources.ResourceTypeVM,+ Name: "finance-vm",+ Tags: []string{"sensitive"}, // -> Sensitive -> local-first (flows at full)+ Identity: unifiedresources.ResourceIdentity{+ Hostnames: []string{"finance-vm.lan"},+ IPAddresses: []string{"10.0.0.7"},+ },+ Proxmox: &unifiedresources.ProxmoxData{VMID: 200, NodeName: "node1"},+ }+ restrictedAgent := unifiedresources.Resource{+ ID: "agent/vault",+ Type: unifiedresources.ResourceTypeAgent,+ Name: "vault",+ Tags: []string{"secret"}, // -> Restricted -> local-only (hard floor)+ Identity: unifiedresources.ResourceIdentity{+ Hostnames: []string{"vault.lan"},+ IPAddresses: []string{"10.0.0.9"},+ },+ }+ provider := policySanitizerProvider{resources: []unifiedresources.Resource{sensitiveVM, restrictedAgent}}++ req := providers.ChatRequest{+ System: "finance-vm.lan is 10.0.0.7; vault.lan is 10.0.0.9. Authorization: Bearer sk-leaked-secret-token",+ }++ // Default (redacted): BOTH resources' identifiers are stripped.+ redacted := RequestSanitizerForModel("openai:gpt-4o", provider)(req)+ for _, identifier := range []string{"finance-vm.lan", "10.0.0.7", "vault.lan", "10.0.0.9"} {+ if strings.Contains(redacted.System, identifier) {+ t.Fatalf("default sanitizer must redact identifier %q, got: %s", identifier, redacted.System)+ }+ }++ // Full (local-only floor): the Sensitive resource's identifiers flow...+ full := RequestSanitizerForModel("openai:gpt-4o", provider, RedactLocalOnlyResourcesOnly())(req)+ for _, identifier := range []string{"finance-vm.lan", "10.0.0.7"} {+ if !strings.Contains(full.System, identifier) {+ t.Fatalf("full sanitizer must preserve sensitive (non-local-only) identifier %q, got: %s", identifier, full.System)+ }+ }+ // ...but the Restricted (local-only) resource stays redacted as the hard floor...+ for _, identifier := range []string{"vault.lan", "10.0.0.9"} {+ if strings.Contains(full.System, identifier) {+ t.Fatalf("full sanitizer must keep the local-only floor for %q, got: %s", identifier, full.System)+ }+ }+ // ...and the credential is STILL redacted, even at full.+ if strings.Contains(full.System, "sk-leaked-secret-token") {+ t.Fatalf("full sanitizer must still redact the bearer token, got: %s", full.System)+ }+}+func TestRequestSanitizerForModelSkipsLocalModel(t *testing.T) {resource := unifiedresources.Resource{ID: "agent/pve-secret",