Skip to content

[TAN-7987] Remove regex PII detection and use LLM call#14210

Open
amanda-anderson wants to merge 4 commits into
TAN-7987-uk-planning-export-2from
TAN-7987-uk-planning-export-replace-regex
Open

[TAN-7987] Remove regex PII detection and use LLM call#14210
amanda-anderson wants to merge 4 commits into
TAN-7987-uk-planning-export-2from
TAN-7987-uk-planning-export-replace-regex

Conversation

@amanda-anderson

@amanda-anderson amanda-anderson commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Replace regex PII detection with an LLM classification

Description:
Replaces the hardcoded English-only regex PII detection in the PDF responses export with a single LLM call (field_pii_detection use case, Claude Haiku by default): all export fields — form questions and user/registration fields — are classified by title, description and options, so detection is language-independent and user fields are no longer auto-flagged. If the LLM is unavailable, we fall back to flagging the structurally-known personal fields (registration fields), and the admin always makes the final call in the review UI. The detector moved to Export::PiiDetector (it's format-agnostic) and the FE shows a spinner while fields load.

@notion-workspace

Copy link
Copy Markdown

@cl-dev-bot

cl-dev-bot commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator
Warnings
⚠️

The changelog is empty. What should I put in the changelog?

Messages
📖 Notion issue: TAN-7987
📖

Run the e2e tests

📖 Check translation progress

Generated by 🚫 dangerJS against d012dcc

@@ -91,14 +91,15 @@ def survey_results
# registration/personal-data fields so the UI can pre-select them for

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(Flagging use of Claude code to help implement).

@amanda-anderson amanda-anderson requested a review from kogre July 2, 2026 07:15

@kogre kogre 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.

Looks good to me :)

end

def structural_pii?(field)
field.resource_type == 'User' || field.key.start_with?('u_')

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.

field.key.start_with?('u_') maybe there is already a helper available on the model class to detect these embedded fields? If not would probably be better if it lived om the model.

end

def llm
@llm ||= LLMSelector.new.llm_class_for_use_case(USE_CASE).new

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.

👍 Great that you used this!

<title><%= field[:title] %></title>
<% if field[:description].present? %><description><%= field[:description] %></description><% end %>
<type><%= field[:input_type] %></type>
<% if field[:options].present? %><options><%= field[:options].join(', ') %></options><% end %>

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.

👍 to including the options

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.

3 participants