spring-projects / spring-projects/spring-ai

Data Minimization: deterministic redaction for ETL, RAG, and ChatClient (no extra LLM calls)

Open
#6,052 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
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, #5776DocumentPostProcessor 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:

  1. A pluggable DataMinimizationPolicy (detectors + replacement strategy) that performs no LLM calls
  2. SanitizingDocumentTransformer — implements DocumentTransformer for ETL (redact before embed/index)
  3. SanitizingDocumentPostProcessor — implements DocumentPostProcessor (redact retrieved chunks before QueryAugmenter)
  4. 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();

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.