Sangeetha-Grantha

Metadata Value
Status Completed
Version 1.0.0
Last Updated 2026-03-20
Author Sangeetha Grantha Team

Track: Handle Per-Script “Variations” as Intra-Variant Metadata

ID: TRACK-104 Status: Not Started Owner: Sangita Grantha Architect Created: 2026-03-20 Updated: 2026-03-20 Parent: TRACK-093 (Trinity Krithi Import)

Goal

Handle the Dikshitar blog’s repeated “variations” blocks (one after each script section) as intra-variant metadata boundaries rather than document-level boundaries. Once TRACK-100 enables multi-pass parsing, these per-script “variations” blocks must be excluded from lyric content within each language block.

Context

Analysis

Verified Code Path

  1. _find_metadata_boundaries() (line 862) uses METADATA_BOUNDARY_PATTERNS which includes VARIATIONS (line 247)
  2. Test evidence shows 3 VARIATIONS boundaries in Dikshitar content: pos 368, 756(MEANING), 1135
  3. After TRACK-100 fix, per-language-block parsing via _build_blocks() will encounter VARIATIONS as a header
  4. _detect_language_header() (line 388) already has ("variations", "VARIATIONS") in candidates
  5. _extract_language_header_variants() (line 665) already has if block.label in METADATA_LABELS: flush(); break at line 688-689
  6. This means the existing code already handles this correctly — when a VARIATIONS block is encountered within a language block, _extract_language_header_variants() flushes the current variant and stops processing that block

Re-Assessment

After tracing the code, the existing _extract_language_header_variants() method at lines 687-689 already breaks on METADATA_LABELS (which includes VARIATIONS). Once TRACK-100 provides full-document text to per-block parsing, the per-script variations blocks will be naturally excluded.

However, there’s a subtle issue: if _build_blocks() processes a full language block that contains a “variations” section followed by more lyric content (e.g., a “Word Division” sub-block after “variations”), the break at line 689 would prematurely stop variant collection. This needs verification against actual Dikshitar page structure.

Dikshitar Page Structure Per Language Block

[Language Header: Devanagari]
  pallavi (lyrics)
  anupallavi (lyrics)
  charanam (lyrics)
  variations (metadata)        ← break here is correct
[Language Header: Tamil]       ← next language block starts fresh

The break is correct per-block because each language section is self-contained with its own variations footer. No lyric content follows variations within the same language block.

Implementation Plan

Phase 1: Verification

Phase 2: Fix (if needed)

Phase 3: Testing & Validation

Design Considerations

The existing code may already handle this correctly once TRACK-100 provides full text. This track is primarily a verification and safety-net track. If integration testing after TRACK-100 shows no issues, this track can be marked as “Verified — No Changes Needed.”

Acceptance Criteria

Dependencies

Files to Modify