fix(anonymizer): include confidence score in OperatorResult#2179
Closed
kalra-mohit wants to merge 1 commit into
Closed
fix(anonymizer): include confidence score in OperatorResult#2179kalra-mohit wants to merge 1 commit into
kalra-mohit wants to merge 1 commit into
Conversation
…vacy-stack#2057) AnonymizerEngine currently drops the RecognizerResult.score during anonymization, making it impossible to recover per-entity confidence for audit/traceability without re-running the analyzer. Add an optional `score` field to OperatorResult, threaded through EngineBase._operate() from the originating entity (RecognizerResult during anonymize, or an already-scored OperatorResult during deanonymize). Defaults to None so existing callers, JSON shape consumers, and the deanonymize path are unaffected unless they opt in. - score is preserved through conflict resolution: the surviving entity keeps its own score, not a dropped entity's - score is included in to_dict()/to_json() and round-trips via OperatorResult.from_json() - unit + integration tests cover construction, equality, JSON (de)serialization, score propagation through anonymize, conflict resolution, and the anonymize -> deanonymize round trip Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
scorefield toOperatorResult, threaded through from the originatingRecognizerResultduringAnonymizerEngine.anonymize()and preserved throughDeanonymizeEngine.deanonymize().scoredefaults toNoneso existing callers are unaffectedanonymizer_engine.py, unmodified hereto_dict()/to_json()output and round-trips viafrom_json()Enables audit/traceability use cases where the confidence of an anonymized entity needs to be recoverable after anonymization.
Closes #2057
Test plan
OperatorResultscore default, equality,to_dict/from_jsonAnonymizerEngine(single, multiple, conflicting entities)scorefield in output