Skip to content

fix: switch augment prompt to plain text input, drop GLiNER seed entities - #267

Open
asteier2026 wants to merge 1 commit into
mainfrom
asteier2026/bugfix/augment-plain-text-drop-seed-entities
Open

asteier2026 wants to merge 1 commit into
mainfrom
asteier2026/bugfix/augment-plain-text-drop-seed-entities

Conversation

@asteier2026

@asteier2026 asteier2026 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Switches the entity augment prompt to use COL_TEXT (plain, untagged) instead of COL_INITIAL_TAGGED_TEXT, so the augment LLM sees a clean slate with no GLiNER annotations. Removes the seed entities line and the do-not-repeat rule; updates both strict and non-strict example blocks to match plain text input.
  • Because the augmenter now sees plain text, it commonly re-detects spans GLiNER already found and validated. resolve_overlaps() previously broke ties on identical spans purely alphabetically by label, so an unvalidated augmenter relabeling (e.g. Seattle -> address) could silently overwrite an already-validated detector span (Seattle -> city). Adds a provenance tiebreak so entities sourced from the augmenter always lose to any other source on identical spans, matching the invariant resolve_overlaps() already documented but didn't enforce.
  • NOTE: extensive tests were run and not showing augment the gliner entities and say avoid these, actually helps augment find more entities that gliner didn't find.

Test plan

  • python -m pytest tests/engine/test_detection_postprocess.py — 70 passed, including new regression tests covering the augmenter-vs-detector provenance tiebreak
  • make format-check

🤖 Generated with Claude Code

@asteier2026
asteier2026 requested a review from a team as a code owner September 14, 2026 16:25
@greptile-apps

greptile-apps Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The PR is not yet safe to merge because broader sensitive augmenter spans can still be discarded when they overlap narrower detector spans.

Findings

  1. P1 Security Broader sensitive spans discarded

Summary

  • Replaces tagged text and seed-entity prompt inputs with plain COL_TEXT.
  • Adds overlap filtering so augmenter spans cannot displace validated spans.
  • Adds regression coverage for prompt construction and augmenter provenance precedence.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Plain input text] --> B[Augmenter extraction]
    C[Validated detector entities] --> D[Overlap resolution]
    B --> D
    D -->|Overlapping augmenter span dropped| E[Resolved entities]
    D -->|Non-overlapping augmenter span retained| E
    E --> F[Validation and anonymization]
Loading

Reviews (3) · Last reviewed commit: "fix: switch augment prompt to plain text..."

Comment thread src/anonymizer/engine/detection/postprocess.py Outdated
Comment thread src/anonymizer/engine/detection/detection_workflow.py
@asteier2026
asteier2026 force-pushed the asteier2026/bugfix/augment-plain-text-drop-seed-entities branch from cbf4e98 to 36d76a3 Compare September 14, 2026 16:37
Comment on lines 256 to +258
"""
non_augmenter = [item for item in entities if item.source != "augmenter"]
augmenter = [item for item in entities if item.source == "augmenter"]

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.

P1 security Broader sensitive spans discarded

When the augmenter identifies a broader sensitive value that overlaps a narrower detector span, this filter discards the entire augmenter entity instead of preserving its non-overlapping sensitive portion. For example, if the augmenter finds a full street address containing a detector-identified city, only the city reaches validation and replacement. The rest of the address can remain unanonymized.

How this was verified: Only entities retained by resolve_overlaps() are passed into validation and replacement, and no later stage reconstructs the discarded span or its residual intervals.

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.

This is by design. If gliner finds Seattle and augment finds "near downtown Seattle", it's better to hold on to the validated gliner entity "Seattle" and throw out the rest. I think it's too messy to try and weed out parts of the augment span that should still be an entity. Augment is supposed to find minimal spans. If "Seattle, Washington" shows up, we want augment to tag "Seattle" and "Washington" individually.

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.

That makes sense. Given the augmenter’s minimal-span contract, dropping an overlapping augmenter result is intentional: the validated GLiNER span is preserved, while the augmenter is expected to emit separate minimal entities such as Seattle and Washington rather than a broader span containing Seattle. I’m withdrawing this concern.

…ties

Uses COL_TEXT (plain, untagged) instead of COL_INITIAL_TAGGED_TEXT so the
augment LLM sees a clean slate with no GLiNER annotations. Removes the
seed entities line and the do-not-repeat rule. Updates both strict and
non-strict example blocks to match plain text input.

Because the augmenter now sees plain text, it commonly re-detects spans
GLiNER already found and validated. resolve_overlaps() previously broke
ties on identical spans purely alphabetically by label, and let a longer
overlapping augmenter span win outright over a shorter validated span, so
an augmenter's unvalidated relabeling (e.g. "near downtown Seattle" ->
address) could silently swallow and displace an already-validated span
(Seattle -> city). Any augmenter-sourced entity that overlaps an entity
from any other provenance is now dropped before span length is even
considered, so it can never displace a validated span regardless of
length, matching the invariant resolve_overlaps() already documented but
didn't enforce.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: asteier2026 <asteier@nvidia.com>
@asteier2026
asteier2026 force-pushed the asteier2026/bugfix/augment-plain-text-drop-seed-entities branch from 36d76a3 to a6f683a Compare September 14, 2026 17:50
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