fix: coerce low combined_risk_level to medium instead of rejecting - #210
fix: coerce low combined_risk_level to medium instead of rejecting#210asteier2026 wants to merge 5 commits into
Conversation
Greptile SummaryThis PR changes how
Confidence Score: 5/5Safe to merge — the coercion replaces a silent entity-drop with an explicit risk-level promotion, the warning log is in place, and the tests cover all four protection methods. The change is narrowly scoped to one validator branch. The coercion is semantically sound, the warning gives operators an observable signal, and the parametrized test catches regressions across every relevant protection method. No downstream consumers of combined_risk_level are broken by the promotion from low to medium. Files Needing Attention: No files require special attention. Important Files Changed
|
…cting The LLM occasionally outputs combined_risk_level='low' with a non-leave_as_is protection_method_suggestion. Previously this caused a ValidationError that dropped the entire record. Now the protection_method_suggestion is silently coerced to leave_as_is, consistent with the semantics of low combined risk. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: asteier2026 <asteier@nvidia.com>
…protection When the LLM assigns combined_risk_level='low' alongside a non-leave_as_is protection method, trust the protection intent over the risk label. Promoting the risk level to medium preserves the model's decision to protect the entity rather than silently discarding it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: asteier2026 <asteier@nvidia.com>
…nsistency Silent coercion made it impossible to detect in production whether the inconsistency was a rare blip or a systematic regression from a prompt or model change. The warning names the entity and both conflicting field values so it is actionable in logs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: asteier2026 <asteier@nvidia.com>
…hods Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: asteier2026 <asteier@nvidia.com>
Replace entity_value with entity_label in the logger.warning call so raw PII strings are not written to log aggregators. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
0fb61f0 to
e5a4b05
Compare
lipikaramaswamy
left a comment
There was a problem hiding this comment.
One non-blocking serialization consistency suggestion.
| ) | ||
| # Trust the protection intent over the risk label; promote risk to medium | ||
| # rather than suppressing the protection. | ||
| self.combined_risk_level = CombinedRiskLevel.medium |
There was a problem hiding this comment.
Non-blocking: because model_config uses use_enum_values=True, normally validated combined_risk_level values are stored and returned by model_dump() as plain strings. This assignment happens after validation, so the coerced path instead stores a CombinedRiskLevel enum object (although it compares equal to "medium"). Could we assign CombinedRiskLevel.medium.value here and add a model_dump() assertion so coerced and non-coerced records preserve the same serialization contract?
There was a problem hiding this comment.
Made suggested changs.
|
Note that this branch has a different version of rewrite_generation.py than what is being updated in PR 208 - it doesn't have the prereplace logic. How do we handle that? |
Summary
protection_method_suggestion (e.g. suppress_inference, generalize)
caused the entire record to be skipped (UPDATE - sometimes the record isn't skipped, but the entity silently gets dropped from the sensitivity disposition)
rather than suppressing it. This is more appropriate for weaker models that apply protection methods
without fully accounting for contextual risk
combined_risk_level is promoted and the original protection_method_suggestion is retained
UPDATE - the sensitivity disposition prompt is overloaded and doesn't do as well on gpt-oss-120b. We will do another PR to fix that, but above is a quick fix for now