feat: enhance repair#137
Conversation
Greptile SummaryThis PR enhances the privacy repair pipeline in two ways: it enriches the reanswer step by adding an Confidence Score: 5/5Safe 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 src/anonymizer/engine/schemas/rewrite.py — missing per-item and list-size constraints on the new Important Files Changed
Sequence DiagramsequenceDiagram
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
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") |
There was a problem hiding this comment.
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.
| 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!
Changes include: