fix: score lyrics language by aliases and tokens, not prefixes - #139
Merged
Conversation
startswith("es") treated English as Spanish; startswith("en") treated
"en español" as English. Resolve exact aliases, then BCP-47 prefixes,
then tokens longer than two letters so Story Lab names stay Spanish.
PR Review — Loreframe StudioRisk: low Automated review from Findings
Changed files
CONTRIBUTING checklist
Posted by the repo PR review workflow. Re-runs on each push to the PR. |
Code healthQuality score: 49.6/100Higher is better. The score is a trend dashboard; the independent ratchet below remains the CI gate.
Change vs PR base: +0.0 points.
Markdown, JSON catalogs and tests are out of this table. Only Most complex functions
Trend vs baseline
Warnings
Ratchet passed. |
3 tasks
3 tasks
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.
Resumen ejecutivo
Qué cambia
El validador de idioma de letras ya no usa prefijos (
startswith("es")/startswith("en")). Resuelve alias exactos, códigos BCP-47 y palabras demás de dos letras.
Para qué sirve
En #137,
Englishse clasificaba como español (englishempieza pores)y
en españolcomo inglés. Story Lab usa nombres comoEspañol de España.Sin este arreglo, una letra española no se valida y una inglesa sí.
Impacto para el usuario
Ningún cambio visible de UI. Las letras se puntúan con el idioma pedido.
Riesgo
Estado
Summary
Follow-up to merged #137. Replace prefix matching in
canonical_lyrics_language/canonicalLyricsLanguagewith:es,espanol,spanish,en,english);-(es-MX,en-US);Español de Españaanden españolare Spanish, while
enandEnglishstay English.Does not wire the guard into write-song/generate. Does not touch
_launch_runtime.py,useStore.tsoragentActions.ts.Overview
Story Lab spoken-language names and short prepositional phrases must not
flip the lyrics language. Prefix traps are documented in
docs/development/LYRICS_LANGUAGE.md.Detailed changes
Backend
app/services/lyrics_language.py: token scan after exact aliases.UI and Wizard
ui/src/lib/lyricsLanguageGuard.ts: same rules, including the missingLANGUAGE_ALIASESmap that #137 never added on the TypeScript side.Data, provenance and compatibility
No schema change. Unknown language names still return an empty code and
skip Spanish-specific scoring.
Files and ownership
app/services/lyrics_language.py— canonical resolverui/src/lib/lyricsLanguageGuard.ts— UI/Wizard mirrortests/test_lyrics_language.py,ui/tests/lyricsLanguageGuard.test.tsdocs/development/LYRICS_LANGUAGE.mdValidation
python scripts/verify_clean_repo.py(viavalidate_local.sh)pytest tests/test_lyrics_language.py— 10 passedtsx ... tests/lyricsLanguageGuard.test.ts— 8 passedbash scripts/validate_local.sh— Python contracts, UI tests/lint/build, simulated E2E 7 passedbash scripts/check_code_health_pr_base.sh— ratchet passedgit diff --checkCode quality
CI and review
Do not merge while required CI or Cursor is running.
Coste de la tarea
Notes and limitations
The guard is still library-only. Wiring into Story generate and
/api/v1/llm/write-songremains a follow-up.Follow-up work
those call sites, or in a PR that does not overlap launch.
after client close).
Checklist
marked as waiting for them.
Note
Low Risk
Library-only resolver change with mirrored Python/TS tests; no API, auth, or generation pipeline wiring.
Overview
Fixes misclassification of Story Lab language labels in the lyrics guard by replacing
startswith("es")/startswith("en")logic incanonical_lyrics_languageandcanonicalLyricsLanguage.Resolution now follows exact folded aliases, BCP-47 prefixes (e.g.
en-US), then word tokens longer than two letters so names likeEspañol de Españaand phrases likeen españolmap to Spanish whileEnglishand bareenstay English. The TypeScript guard gains the sameLANGUAGE_ALIASEStable and matching algorithm.Tests cover the canonical resolver and validation with
Español de España; docs document the prefix traps and note the guard remains library-only (no write-song/generate wiring in this PR).Reviewed by Cursor Bugbot for commit a6b7b0f. Configure here.