test: cover riskiest untested production paths (PII filter, pruner, judge, conversation builder, ingestion pipeline, preference formatter) - #37
Merged
Conversation
…n pipeline, preference formatter Adds 94 focused unit tests for the least-covered production paths (0-31% before, 94-98% after) and fixes a latent import-time crash in the PII filter: the BEARER_TOKEN pattern embedded the inline (?i) flag mid-pattern, which Python's re rejects, so PIIFilter (and the scan_pii ingestion path) could never be imported. Co-authored-by: Omar <omr.omr163@gmail.com>
Runs ruff format (0.9.10, matching the CI-pinned version) on the four new test files and adds an [Unreleased] CHANGELOG section covering the new tests and the PII filter import fix, satisfying the changelog-enforcer. Co-authored-by: Omar <omr.omr163@gmail.com>
Contributor
Author
|
Fix pass for the three failing checks:
|
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 94 focused unit tests for the six least-covered, highest-risk production modules (all below 32% coverage before; 94–98% after). These paths gate security (PII/secret redaction), training-data quality (pruning), and user-visible output correctness (conversation generation, DPO export), so their behavior is now pinned down.
core/pii_filter.pysynthesis/pruner.pysynthesis/conversation_builder.pyingestion/pipeline.pysynthesis/judge.pyexporter/formatters/preference.pyProduction bug found and fixed
distill_align.core.pii_filtercrashed on import: theBEARER_TOKENregex embedded the inline(?i)global flag mid-pattern ((?:(?i)...), which Python'srerejects withre.error. Sinceingestion/auto.pylazily importsPIIFilterwhenscan_piiis enabled, the entire PII-scanning feature was dead on arrival. The flag was moved to the start of the pattern; semantics unchanged. This was the first thing the new PII filter tests caught.Two existing behaviors are documented in tests rather than silently changed: consecutive-digit credit-card numbers are classified as
phone_us(pattern ordering shadowscredit_card— noted intest_plain_card_number_shadowed_by_phone), and the quality gate does not reject conversations for short content or invalid structure alone (scores 0.7/0.6 respectively, still above the 0.5 threshold).Verification
pytest --covruff checkclean on all changed files