Related issues (searched; not duplicates)
I searched the issue tracker before opening this:
- #1081 / #1011 — broad behavioral guardrails; no shipped deterministic redaction SPI
- #1184 — Bedrock provider guardrails, not framework-agnostic minimization
- #5615 — guardrails for tool calls, not ingest/RAG prompt content
- #5671, #5903, #5776 —
DocumentPostProcessor for reorder/rerank, not PII/secret redaction
None of the above provide a built-in, dependency-free way to minimize sensitive/proprietary data before it reaches an LLM across ingest, retrieval, and chat.
Expected Behavior
Spring AI provides a small, optional Data Minimization building block (module or package) with:
- A pluggable
DataMinimizationPolicy (detectors + replacement strategy) that performs no LLM calls
SanitizingDocumentTransformer — implements DocumentTransformer for ETL (redact before embed/index)
SanitizingDocumentPostProcessor — implements DocumentPostProcessor (redact retrieved chunks before QueryAugmenter)
DataMinimizationAdvisor — implements CallAdvisor / StreamAdvisor (final gate on the assembled Prompt)
Built-in v1: RegexSensitiveDataDetector + ReplacementStyle (MASK, REMOVE). TOKENIZE (especially reversible tokenization) deferred to a follow-up. Optional fail-closed mode.
Example (same policy bean wired in all three places):
var policy = DataMinimizationPolicy.builder()
.detector(RegexSensitiveDataDetector.defaults())
.replacement(ReplacementStyle.MASK)
.build();
// ETL — before vector store
vectorStore.write(new SanitizingDocumentTransformer(policy).transform(reader.read()));
// RAG — after retrieval, before generation
var ragAdvisor = RetrievalAugmentationAdvisor.builder()
.documentRetriever(retriever)
.documentPostProcessors(new SanitizingDocumentPostProcessor(policy))
.build();
// Chat — non-RAG paths and final prompt gate
var client = ChatClient.builder(model)
.defaultAdvisors(DataMinimizationAdvisor.builder(policy).build())
.build();
Related issues (searched; not duplicates)
I searched the issue tracker before opening this:
DocumentPostProcessorfor reorder/rerank, not PII/secret redactionNone of the above provide a built-in, dependency-free way to minimize sensitive/proprietary data before it reaches an LLM across ingest, retrieval, and chat.
Expected Behavior
Spring AI provides a small, optional Data Minimization building block (module or package) with:
DataMinimizationPolicy(detectors + replacement strategy) that performs no LLM callsSanitizingDocumentTransformer— implementsDocumentTransformerfor ETL (redact before embed/index)SanitizingDocumentPostProcessor— implementsDocumentPostProcessor(redact retrieved chunks beforeQueryAugmenter)DataMinimizationAdvisor— implementsCallAdvisor/StreamAdvisor(final gate on the assembledPrompt)Built-in v1:
RegexSensitiveDataDetector+ReplacementStyle(MASK,REMOVE).TOKENIZE(especially reversible tokenization) deferred to a follow-up. Optional fail-closed mode.Example (same policy bean wired in all three places):