Skip to content

[Multi-Agent Privacy] Integrate privacy into the RAG pipeline#339

Open
JCHAVEROT wants to merge 20 commits into
feat/adversarial-agentfrom
feat/privacy-mode
Open

[Multi-Agent Privacy] Integrate privacy into the RAG pipeline#339
JCHAVEROT wants to merge 20 commits into
feat/adversarial-agentfrom
feat/privacy-mode

Conversation

@JCHAVEROT

@JCHAVEROT JCHAVEROT commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Related issue: #295
Subsequent to: #338

The privacy pipeline stopped at the gate, never producing the answer, checking it, or recording it. This PR adds the post-cloud half: after the gate approves, the answer model answers from the sanitized context alone, a verifier agent checks for residual leakage and unfaithful claims, and every request ends with a short PII-free record.

The chain is now:

... -> HITL -> answer -> verifier -> report

Changes

  • AnswerModel (answer.py): answers from the sanitized context only, never the raw chunks; records the backend and model used
  • AdvisoryVerifierAgent (agents/verifier.py): reads the full context plus the answer, runs the configured leakage and faithfulness checks, warns when confidence clears the threshold; never re-runs detection or cleaning
  • Added a report record (report.py) and builder (report_builder.py) to give context to the user
  • Wired the graph (pipeline.py): added answer, verifier, and report nodes, routing the proceed, reject, and abort paths through the report
  • Integrated into RAG (rag/pipeline.py, run_rag.py): the privacy graph replaces the answer step and surfaces the report and warning summary alongside the answer
  • Also integrated into RAG CLI
  • Config (config.py): added VerifierCheck enum, VerifierConfig, and CloudLLMConfig
  • JSON adapter (dspy_llm.py): tolerant parsing for small local models that have trouble with formats
  • Tests: full E2E tests now that we have full pipeline (TBD soon in another PR)

Demo with RAG CLI

Note that adversarial agent is turned off here, but it works also fine with (just a bit longer)

CleanShot.2026-07-17.at.16.11.15-compressed.mp4

@JCHAVEROT JCHAVEROT self-assigned this Jun 29, 2026
@JCHAVEROT JCHAVEROT added documentation Improvements or additions to documentation enhancement New feature or request labels Jun 29, 2026
@JCHAVEROT JCHAVEROT changed the title feat: add the data layer for post cloud verification [Multi-Agent Privacy] Integrate privacy into the RAG pipeline Jun 29, 2026
@fabnemEPFL
fabnemEPFL requested a review from Copilot June 30, 2026 15:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the “post-cloud” half of the multi-agent privacy pipeline and integrates it into the RAG flow, so that (when enabled) retrieval outputs are sanitized/gated before an answer is generated, then the answer is advisorially verified and a PII-free report record is returned alongside the final response.

Changes:

  • Extends the privacy graph beyond the HITL gate with new answer, verifier, and report stages (and wires the new routing).
  • Integrates the privacy graph into the RAG pipeline as an optional replacement for the normal answer step, surfacing privacy_report and privacy_warnings in outputs.
  • Adds supporting config/schema, reporting utilities, and DSPy JSON parsing tolerance improvements.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/mmore/run_rag.py Adds --privacy flag support, builds/loads privacy graph, and exposes privacy fields in JSON/API output.
src/mmore/rag/pipeline.py Adds optional privacy_graph path that replaces the answer step and surfaces privacy report/warnings.
src/mmore/privacy/verification.py Introduces verifier verdict/warning dataclasses + summary helpers.
src/mmore/privacy/runner.py Adds config validation and a single-query runner that drives the compiled privacy graph.
src/mmore/privacy/report.py Defines the PII-free ReportRecord schema and related enums.
src/mmore/privacy/report_builder.py Builds/serializes the final report record from final graph state.
src/mmore/privacy/pipeline.py Wires answer/verifier/report nodes into the LangGraph pipeline and updates routing.
src/mmore/privacy/escalation.py Ensures detection-engine switching also resets per-engine default params.
src/mmore/privacy/dspy_llm.py Adds a tolerant JSON adapter for small/local model formatting issues.
src/mmore/privacy/config.py Adds verifier/answer config types and new enums; adjusts leakage adversary defaults.
src/mmore/privacy/answer.py Adds post-gate answer model that uses sanitized context only and records model identity.
src/mmore/privacy/agents/verifier.py Adds post-cloud advisory verifier agent (residual leakage + faithfulness checks).
src/mmore/privacy/agents/state.py Extends shared privacy graph state to include answer/verifier/report metadata.
src/mmore/privacy/agents/analyzer.py Switches DSPy adapter usage to the new tolerant JSON adapter.
src/mmore/privacy/agents/adversary.py Tweaks adversary probe instructions wording.
src/mmore/privacy/agents/init.py Exports the new verifier agent.
src/mmore/cli.py Adds --privacy option to the mmore rag CLI command.
examples/rag/privacy.yaml Adds an example privacy config including answer + verifier sections.
docs/source/index.md Adds privacy mode doc page to the docs index.
docs/source/core_features/privacy_mode.md Documents privacy mode pipeline, configuration, and report schema.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/mmore/privacy/answer.py Outdated
Comment thread src/mmore/privacy/agents/adversary.py Outdated
Comment thread src/mmore/privacy/runner.py
Comment thread src/mmore/privacy/runner.py Outdated
Comment thread src/mmore/privacy/dspy_llm.py
Comment thread src/mmore/privacy/agents/verifier.py
Comment thread docs/source/core_features/privacy_mode.md Outdated
Comment thread docs/source/core_features/privacy_mode.md
@JCHAVEROT
JCHAVEROT force-pushed the feat/adversarial-agent branch from c742d63 to 107ec76 Compare June 30, 2026 17:15
@JCHAVEROT JCHAVEROT linked an issue Jul 2, 2026 that may be closed by this pull request
@JCHAVEROT
JCHAVEROT force-pushed the feat/privacy-mode branch 2 times, most recently from ba0acc3 to b303356 Compare July 3, 2026 14:30
@JCHAVEROT
JCHAVEROT force-pushed the feat/adversarial-agent branch from a872863 to 9d83368 Compare July 8, 2026 08:35
@JCHAVEROT
JCHAVEROT force-pushed the feat/privacy-mode branch from 15d3722 to 0b72c20 Compare July 8, 2026 08:37
@fabnemEPFL
fabnemEPFL requested a review from Copilot July 8, 2026 09:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 4 comments.

Comment thread src/mmore/privacy/report_builder.py Outdated
Comment thread src/mmore/privacy/report_builder.py Outdated
Comment thread src/mmore/run_rag.py Outdated
Comment thread src/mmore/rag/pipeline.py
@JCHAVEROT
JCHAVEROT force-pushed the feat/privacy-mode branch 3 times, most recently from 3e2f842 to d969b64 Compare July 8, 2026 15:16
@JCHAVEROT
JCHAVEROT force-pushed the feat/adversarial-agent branch 2 times, most recently from 201382c to 4d7562a Compare July 13, 2026 09:52
@JCHAVEROT
JCHAVEROT force-pushed the feat/privacy-mode branch from 273be6f to 24c240a Compare July 13, 2026 10:38
@fabnemEPFL
fabnemEPFL requested a review from Copilot July 13, 2026 15:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated 3 comments.

Comment thread src/mmore/privacy/runner.py
Comment thread src/mmore/privacy/agents/detector.py Outdated
Comment thread src/mmore/privacy/sanitization/synthetic_rewrite_strategy.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 42 changed files in this pull request and generated 1 comment.

Comment thread docs/source/core_features/privacy_mode.md Outdated
@JCHAVEROT
JCHAVEROT force-pushed the feat/adversarial-agent branch from fe55399 to c5fa763 Compare July 21, 2026 16:46
@JCHAVEROT
JCHAVEROT force-pushed the feat/privacy-mode branch from e11c54a to aef505f Compare July 21, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integration of the system into RAG pipeline

3 participants