Skip to content

fix: score lyrics language by aliases and tokens, not prefixes - #139

Merged
IAnMove merged 1 commit into
mainfrom
feat/lyrics-language-alias-tokens
Sep 5, 2026
Merged

fix: score lyrics language by aliases and tokens, not prefixes#139
IAnMove merged 1 commit into
mainfrom
feat/lyrics-language-alias-tokens

Conversation

@IAnMove

@IAnMove IAnMove commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Resumen ejecutivo

Esta primera sección está pensada para project managers y revisores no
técnicos. Mantén el detalle técnico completo más abajo.

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 de
más de dos letras.

Para qué sirve

En #137, English se clasificaba como español (english empieza por es)
y en español como inglés. Story Lab usa nombres como Españ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

  • Bajo
  • Medio
  • Alto

Estado

  • En desarrollo
  • Listo para revisión
  • Bloqueado por CI o revisión
  • Requiere migración o acción manual

Summary

Follow-up to merged #137. Replace prefix matching in
canonical_lyrics_language / canonicalLyricsLanguage with:

  1. exact folded aliases (es, espanol, spanish, en, english);
  2. BCP-47 prefixes via the token before - (es-MX, en-US);
  3. tokens longer than two letters so Español de España and en español
    are Spanish, while en and English stay English.

Does not wire the guard into write-song/generate. Does not touch
_launch_runtime.py, useStore.ts or agentActions.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 missing
LANGUAGE_ALIASES map 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 resolver
  • ui/src/lib/lyricsLanguageGuard.ts — UI/Wizard mirror
  • tests/test_lyrics_language.py, ui/tests/lyricsLanguageGuard.test.ts
  • docs/development/LYRICS_LANGUAGE.md
  • Untouched: launch, store, agentActions, write-song, generate

Validation

  • python scripts/verify_clean_repo.py (via validate_local.sh)
  • Focused Python tests: pytest tests/test_lyrics_language.py — 10 passed
  • UI tests: tsx ... tests/lyricsLanguageGuard.test.ts — 8 passed
  • bash scripts/validate_local.sh — Python contracts, UI tests/lint/build, simulated E2E 7 passed
  • bash scripts/check_code_health_pr_base.sh — ratchet passed
  • git diff --check
  • E2E/smoke real media: N/A (no GPU, no provider)

Code quality

  • Score: 49.6/100
  • Change vs PR base: +0.0
  • Production LOC: +17
  • Test LOC: +29
  • Functions ≥ 15: +0
  • Ratchet: passed (warning: +17 production LOC)

CI and review

  • CI: pending
  • Cursor/Bugbot: pending
  • Human review: pending

Do not merge while required CI or Cursor is running.

Coste de la tarea

  • Tests simulados: 0 tokens externos
  • Tests reales: N/A
  • Llamadas LLM externas: 0
  • Tokens de prompt: N/A (Grok no expone recuento fiable de esta sesión)
  • Tokens de respuesta: N/A
  • Tokens totales: N/A
  • Generaciones de imágenes/audio/vídeo: 0
  • Tiempo transcurrido: ~15 min de este bloque
  • Proveedores/modelos: N/A

Notes and limitations

The guard is still library-only. Wiring into Story generate and
/api/v1/llm/write-song remains a follow-up.

Follow-up work

  • Wire the guard into write-song/generate after durable song identity owns
    those call sites, or in a PR that does not overlap launch.
  • Durable Story song identity (pending candidate before generate; recover
    after client close).

Checklist

  • The executive summary is understandable without reading the code.
  • The detailed Summary/Overview has not been removed or shortened.
  • Tests and their actual results are recorded.
  • Generated assets, secrets and local-only files are not committed.
  • Required CI and Cursor/Bugbot review are complete, or the PR is clearly
    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 in canonical_lyrics_language and canonicalLyricsLanguage.

Resolution now follows exact folded aliases, BCP-47 prefixes (e.g. en-US), then word tokens longer than two letters so names like Español de España and phrases like en español map to Spanish while English and bare en stay English. The TypeScript guard gains the same LANGUAGE_ALIASES table 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.

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.
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

PR Review — Loreframe Studio

Risk: low
Scope: 5 file(s); +70/-13; React UI, backend services, docs

Automated review from scripts/analyze_pr.py. This is a heuristic pass (no LLM) so humans still own the merge decision.

Findings

  • low — UI changed — rebuild before merge
    Run cd ui && npm run build (CI already does this). Pinokio Update rebuilds for end users; keep ui/dist untracked.

Changed files

  • modified: app/services/lyrics_language.py, docs/development/LYRICS_LANGUAGE.md, tests/test_lyrics_language.py, ui/src/lib/lyricsLanguageGuard.ts, ui/tests/lyricsLanguageGuard.test.ts

CONTRIBUTING checklist

  • python scripts/verify_clean_repo.py
  • python -m compileall -q app/services app/launch.py scripts
  • cd ui && npm run build if the UI changed
  • No weights, CivitAI sidecars, or generated guides
  • Stays local-first (no required accounts / telemetry)

Posted by the repo PR review workflow. Re-runs on each push to the PR.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Code health

Quality score: 49.6/100

Higher is better. The score is a trend dashboard; the independent ratchet below remains the CI gate.

Component Weight Current Change
Cyclomatic health 45% 52.6 +0.0
File concentration 25% 55.0 +0.0
Oversized-file debt 20% 30.1 +0.0
Modularity 10% 62.1 +0.0

Change vs PR base: +0.0 points.

Metric Value
Production LOC 243,784
Production files 537
Test LOC 71,056
Functions measured 15,247
Functions complexity ≥ 15 786
Maximum complexity 667

Markdown, JSON catalogs and tests are out of this table. Only app/ runtime + ui/src TS/JS count.

Most complex functions

Complexity Where
667 app/wgp.py:7164 generate_video
374 ui/src/stores/useStore.ts:4024 Async method 'startGeneration'
355 app/_launch_runtime.py:23508 _run_generation
308 app/wgp.py:12281 generate_video_tab
271 ui/src/components/Sidebar/SceneAnimatorPanel.tsx:474 Function 'SceneAnimatorPanel'
266 ui/src/stores/useStore.ts:8566 Async method 'loadSettingsFromOutput'
258 app/services/director/planners/short_film.py:3433 ShortFilmPlanner._plan_story_driven
248 app/services/director_pipeline.py:13735 _run_video_generation
245 app/services/director_pipeline.py:7860 _run_pipeline
243 ui/src/features/agent/agentActions.ts:1128 Function 'parseAction'
226 app/services/director_pipeline.py:6689 update_comic_preview
225 ui/src/features/agent/agentActions.ts:2796 Async function 'executeAgentActions'

Trend vs baseline

Metric Δ
Production LOC +17
Test LOC +29
Functions ≥ 15 +0
Maximum complexity +0

Warnings

  • production LOC increased by +17

Ratchet passed.

@IAnMove
IAnMove merged commit bce3a6a into main Sep 5, 2026
5 checks passed
@IAnMove
IAnMove deleted the feat/lyrics-language-alias-tokens branch September 5, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant