feat: smart (semantic) diff for subtitle regression outputs
What this is
A semantic diff for regression-test outputs. Instead of a raw line diff, it classifies how two subtitle outputs differ, so a person — or an AI agent — gets an actionable verdict instead of a wall of changed lines.
Example: instead of "53 lines differ", it says "All 13 cues match but are 500 ms late."
Classification kinds
identical, timing_shift (constant offset), timing_drift (growing offset),
text_change, formatting_change (tags/entities only), whitespace_change
(CEA-608 padding only), encoding_change (non-ASCII/accents only), split_cues,
merged_cues, missing_cues, extra_cues, unsupported (no cues parsed), or
mixed. Each result also carries a per-cue changes list (which cue, what kind,
expected/actual snippet, timing offset).
Grounded in CCExtractor's own behaviour
- Mirrors
tests/extract_expected.py's normalization (strip styling tags, unescape entities, trim CEA-608 trailing padding) so cosmetic differences are separated from real text changes. - Handles the
-latin1charset case (accent folding →encoding_change). - Verified on real CCExtractor output (CEA-608 English + DVB Spanish with
<font>tags and accents), vendored as golden fixtures.
Where it lives
mod_test/smartdiff/— a Flask-decoupled core (SRT + WebVTT parsers, a format dispatcher, normalization, and the classifier). Fully unit-tested.TestResultFile.generate_smart_diff()+ a JSON endpointGET /diff/<test>/<regression>/<output>/smart— reusable by the web UI, a CLI, and agents.- A "Smart" option next to the existing "Fail" diff link on the result page (additive; the raw diff is unchanged).
Notes
- Independent of the REST API work — this is standalone in the platform.
- Tests: parsers, classifier, normalization, real golden fixtures, robustness (malformed/garbage input), and the model glue.
- Follow-up (not in this PR): a CLI
sp run diff --smartconsuming the same endpoint.
Quality Gate passed
Issues
2 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Quality Gate passed
Issues
2 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
@canihavesomecoffee Hi could you take a look at this PR? It just hasn't had eyes on it yet. Also, the SP CLI is live. Once this feature is merged I will wire it into that as well.
Please fix the two new sonarqube issues first.