Skip to content

feat: enhance repair#137

Open
asteier2026 wants to merge 3 commits intomainfrom
asteier2026/feature/repair-improvements
Open

feat: enhance repair#137
asteier2026 wants to merge 3 commits intomainfrom
asteier2026/feature/repair-improvements

Conversation

@asteier2026
Copy link
Copy Markdown
Contributor

Changes include:

  • Add evidence to privacy qa reanswer
  • Enhance privacy qa reanswer prompt
  • Enhance repair prompt

@asteier2026 asteier2026 requested a review from a team as a code owner April 27, 2026 15:27
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 27, 2026

Greptile Summary

This PR enhances the privacy repair pipeline in two ways: it enriches the reanswer step by adding an evidence field (verbatim quotes) to PrivacyAnswerItemSchema and updating the reanswer prompt to collect that evidence, then surfaces those quotes in the repair prompt; it also rewrites the repair prompt to focus on inference suppression (adding adversarial_goal, inference_rules, critical_warnings, and success_criteria sections) and removes the now-unused protection_decisions / replacement_map blocks along with their dead-code helpers.

Confidence Score: 5/5

Safe to merge — only a P2 schema-constraint suggestion, no logic defects introduced.

All changes are prompt and schema additions/removals; backward compatibility is preserved via default_factory=list; dead-code cleanup is complete and consistent. The single finding is a non-blocking missing length constraint on the new evidence list items.

src/anonymizer/engine/schemas/rewrite.py — missing per-item and list-size constraints on the new evidence field.

Important Files Changed

Filename Overview
src/anonymizer/engine/rewrite/evaluate.py Privacy QA reanswer prompt substantially expanded with evidence collection rules; evidence: [] added to skeleton and default fallback item — looks correct.
src/anonymizer/engine/rewrite/parsers.py Adds logging import and module-level logger; no logic changes.
src/anonymizer/engine/rewrite/repair.py Removes dead code paths (_format_protection_block, _replacement_map_is_empty, related constants) and rewrites the repair prompt to focus on inference suppression; evidence from the reanswer step is now surfaced in the leaked-items block.
src/anonymizer/engine/schemas/rewrite.py Adds evidence: list[str] field to PrivacyAnswerItemSchema; field has no per-item length or list-size constraint unlike the adjacent reason field.

Sequence Diagram

sequenceDiagram
    participant Row as Input Row
    participant Eval as evaluate.py<br/>_render_privacy_reanswer_prompt
    participant LLM1 as LLM (reanswer)
    participant Schema as PrivacyAnswerItemSchema
    participant Repair as repair.py<br/>_inject_leaked_items_column
    participant Prompt as _render_repair_prompt
    participant LLM2 as LLM (repair)

    Row->>Eval: COL_PRIVACY_QA
    Eval->>Eval: Build skeleton with evidence:[]
    Eval->>LLM1: Prompt (rules + skeleton)
    LLM1-->>Schema: JSON {answer, confidence, reason, evidence:[...]}
    Schema->>Schema: model_validate (+ coverage check)
    Schema->>Repair: PrivacyAnswersSchema
    Repair->>Repair: _leaked_items_text() append evidence quotes
    Repair->>Repair: COL_LEAKED_PRIVACY_ITEMS
    Repair->>Prompt: row with leaked items
    Prompt->>Prompt: Build repair prompt (adversarial_goal, inference_rules, success_criteria)
    Prompt->>LLM2: Repair prompt
    LLM2-->>Row: COL_REWRITTEN_TEXT_NEXT
Loading

Reviews (2): Last reviewed commit: "fix: address review feedback on repair" | Re-trigger Greptile


from pydantic import BaseModel, ValidationError

logger = logging.getLogger("anonymizer.rewrite.parsers")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Logger defined mid-import block

The logger assignment is placed between the third-party (pydantic) and local (anonymizer) imports. Every other module in this package (evaluate.py line 51, repair.py line 48) initialises the logger after all imports. Moving it below all from anonymizer... imports keeps the style consistent and avoids any risk of the logger being referenced before the local schemas are loaded.

Suggested change
logger = logging.getLogger("anonymizer.rewrite.parsers")
from anonymizer.engine.schemas.rewrite import (

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant