spring-projects / spring-projects/spring-ai
Data Minimization: deterministic redaction for ETL, RAG, and ChatClient (no extra LLM calls)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 5
Description
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 —
DocumentPostProcessorfor 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— 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):
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();
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the DocumentTransformer, DocumentPostProcessor, CallAdvisor/StreamAdvisor, Prompt, and ChatClient entry points named in the issue. Done means a dependency-free, pluggable policy supports deterministic redaction at ETL, retrieval, and final chat-prompt stages without extra LLM calls, including the stated v1 replacement modes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- ai, backend-api-design, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100