| Metadata | Value |
|---|---|
| Status | Completed |
| Version | 1.5.0 |
| Last Updated | 2026-09-30 |
| Author | Sangeetha Grantha Team |
ID: TRACK-145
Status: Completed
Owner: Seshadri
Created: 2026-09-26
Updated: 2026-09-30
Implement Flyway schema evolution (V66 and V67), seed migration maintenance (R__seed_07 amendment, R__seed_09 canonical cycle seeding with historical tag purge), and Python worker embedding enrichment (Context Formatter 2.0) to capture musicological, architectural, and spatial metadata for the corpus of Muttusvāmi Dīkṣitar (~485 kritis across attested cycles, immediate anchor shrines, and documented gaps like Kanyakumari), eliminating sibling vector collision and establishing verified retrieval benchmarks.
/Users/seshadri/.cursor/projects/Users-seshadri-project-sangeetha-grantha/canvases/track-145-review.canvas.tsx./Users/seshadri/.cursor/projects/Users-seshadri-project-sangeetha-grantha/canvases/dikshitar-kshetra-embedding-readout.canvas.tsx.Status: Accepted
Accepted by: Seshadri
Accepted at: 2026-09-26
Muttusvāmi Dīkṣitar’s compositions are distinguished by intricate grammatical schemes (aṣṭa-vibhakti), esoteric Sri Vidya geometry (the 9 enclosures of the Sri Chakra), strict melodic and talic constraints (Gauḷānta ragas, Śūḷādi Sapta Tāḷas), and field epigraphy recording sacred tanks, trees, and river banks across his pilgrimage routes.
In our current indexing architecture:
[Thematic Group / Tags: Kamalamba Navavarnam]) and the same generic town label ([Kshetra: Tiruvarur]). Because the Sanskrit sahitya across these hymns shares high-register devotional vocabulary (Jagadamba, Sivakanta, Parasakti), vector embeddings in Gemini Embedding 2 collapse into an undifferentiated cluster, unable to separate the Dhyana, the 7th Avarana, or the Mangalam.V58__semantic_search_pgvector.sql, search_documents.krithi_id is NOT NULL. Consequently, cycle-level or temple-level overview documents (including negative evidence / recorded gaps like Kanyakumari) cannot be stored natively.CYCLE_OVERVIEW, KSHETRA_OVERVIEW) within the same migration transaction that added them. Attempting to add values to search_document_kind_enum and create chk_search_doc_anchor in a single migration causes an immediate DDL abort.krithi_tags: R__seed_07 contains heuristic ILIKE pattern inserts into krithi_tags (e.g. %kamalamba%). Merely deleting the INSERT statements from R__seed_07 leaves existing heuristic rows in krithi_tags on databases that already executed that migration. A subsequent make migrate would leave false tags intact beside reviewed memberships unless an explicit purge runs.search_documents while the Python worker’s macro generator also attempts to write it, the unique constraint uq_search_doc_identity will cause an insert conflict.V66 and V67):
V66__dikshitar_musicological_enrichment.sql:
parent_temple_id, place_kind with default 'LOCALITY', enum values 'LOCALITY', 'COMPLEX', 'SANNIDHI', 'MANDAPAM') and sthala features (mandalam, bhuta, sthala_vriksha, sthala_tirtha, nadi_tirtha, deity_posture) to temples. Keevalur is CHOLA (Kaveri delta); Tiruvannamalai is NADU (Pennai basin); KONGU stays in enum unassigned in this seed.vibhakti_case, vibhakti_stem, raga_mudra_kind, raga_mudra_phrase, yati_pattern, is_manipravala, occasion_note) to krithis. Derive structural sections (MADHYAMA_KALA, SAMASHTI_CHARANAM, CHITTASWARAM) from existing krithi_sections.krithi_cycle_memberships table storing sequence order, 5-role membership (CORE, DHYANA, MANGALAM, OPTIONAL, DISPUTED_CONJECTURE), and polymorphic axis attributes:
CORE rows (Avaranas 1..9). DHYANA (Kamalambike in Todi) and MANGALAM (Sri Kamalambike in Sri Raga) have axis_value = NULL (sitting outside the 9 enclosures).Achalesvara, Hatakesvara, etc.).'God Save the King', 'Castalian Dew', etc.).axis_value = NULL (whole raga and vibhakti_case already discriminate).temples.bhuta, graha stays on krithis.deity_id, and esoteric attributes live in discriminative_attributes JSONB.search_documents.krithi_id to nullable, add temple_id and tag_id anchors, update uq_search_doc_identity, and append enum values 'CYCLE_OVERVIEW' and 'KSHETRA_OVERVIEW' to search_document_kind_enum without referencing them in constraints.V67__search_document_anchor_constraints.sql:
chk_search_doc_anchor using a strict CASE statement referencing committed enum labels ('CYCLE_OVERVIEW', 'KSHETRA_OVERVIEW') so macro documents cannot cross-pollinate with composition, section, or variant anchors.KrithiSearchRepository.kt live search API join (JOIN krithis k ON d.krithi_id = k.id) remains untouched in this track; macro documents are evaluated directly in evaluate_retrieval.py against search_documents.context_formatter.py to emit crisp, discriminative micro-clauses for individual kritis under a single programmatic check: maximum 60 words for the metadata header (len(header.split()) <= 60).axis_value into the header: [Cycle: Nottusvara Sahitya; Tune: <axis_value>].CYCLE_OVERVIEW and KSHETRA_OVERVIEW documents (including the recorded gap temple at Kanyakumari).R__seed_07 Amendment & R__seed_09 Creation):
R__seed_07_canonical_cycle_tags.sql: Strip out the heuristic title-pattern inserts into krithi_tags for Dikshitar cycles, preventing unreviewed pattern overwrites on rerun.R__seed_09_dikshitar_cycle_memberships.sql:
DELETE FROM krithi_tags WHERE tag_id IN ('...0001', '...0002', '...0003', '...0005', '...0006') AND source = 'canonical_cycle';
ensuring existing databases running make migrate are cleanly sanitized.tags with category = 'STOTRA_STYLE': guruguha-vibhakti, tyagaraja-vibhakti, tiruvarur-panchalinga, shodasa-ganapati, and nottusvara-sahitya.place_kind = 'COMPLEX', mandalam = 'PANDYA') in temples only. The worker macro indexer exclusively owns generating and upserting the KSHETRA_OVERVIEW row in search_documents.batch_embed_catalogue.py.Sarvarakshakara, Yogini Nigarbha, Case Shashthi) disambiguated from both the 5th enclosure (Sri Kamalambayah, Bhairavi; Case Panchami) and the 7th enclosure (Sri Kamalambikayam, Sahana; Chakra Sarvarogahara, Yogini Rahasya, Case Saptami), tune matching (Santatam Pahi Mam via axis_value = 'God Save the King'), and patronymic probes in evaluate_retrieval.py. The 5th enclosure is sung Sri Kamalambayah param nahi re and is often filed as Sri Kamalambikayah; the guardrail keys off Bhairavi and Panchami, not the title stem alone.make migrate / make db-reset). Never modify historical migration files (V01–V65).@Serializable DTO boundary; wrap all DAL mutations in DatabaseFactory.dbQuery { } and write to AUDIT_LOG.len(header.split()) <= 60). Short section passages must never be rejected because of header ratio.DISPUTED_CONJECTURE for Rahu/Ketu per SSP; do not manufacture closed grids for Shodasa Ganapati (open set of ~27) or Nottusvara (39 tunes); Rama Vibhakti is out of scope until sourced with attested citations.Status: Accepted
Accepted by: Seshadri
Accepted at: 2026-09-26
V66__dikshitar_musicological_enrichment.sql:
mandalam_enum ('CHOLA', 'PANDYA', 'TONDAI', 'NADU', 'CHERA', 'KONGU', 'UTTARA'), place_kind_enum ('LOCALITY', 'COMPLEX', 'SANNIDHI', 'MANDAPAM'), cycle_member_role_enum ('CORE', 'DHYANA', 'MANGALAM', 'OPTIONAL', 'DISPUTED_CONJECTURE'), vibhakti_enum (8 cases + SARVA_VIBHAKTI), raga_mudra_enum, yati_pattern_enum, deity_posture_enum, bhuta_enum.temples table with parent_temple_id, place_kind (DEFAULT 'LOCALITY'), mandalam, bhuta, sthala_vriksha, sthala_tirtha, nadi_tirtha, and deity_posture. Keevalur is mapped to CHOLA, Tiruvannamalai to NADU; KONGU remains unassigned in this seed.krithis table with vibhakti_case, vibhakti_stem, raga_mudra_kind, raga_mudra_phrase, yati_pattern, is_manipravala, and occasion_note.krithi_cycle_memberships (id, krithi_id, tag_id, sequence_order, role, axis_value, discriminative_attributes JSONB).search_documents.krithi_id nullability, add temple_id and tag_id, and update uq_search_doc_identity.'CYCLE_OVERVIEW' and 'KSHETRA_OVERVIEW' to search_document_kind_enum via ALTER TYPE ... ADD VALUE IF NOT EXISTS. Do NOT reference these values in any constraints within V66.V67__search_document_anchor_constraints.sql:
chk_search_doc_anchor via CASE statement:
COMPOSITION_OVERVIEW, SECTION_PASSAGE, COMMENTARY_LAKSHANA, MANUSCRIPT_FACSIMILE: krithi_id IS NOT NULL AND temple_id IS NULL AND tag_id IS NULLCYCLE_OVERVIEW: tag_id IS NOT NULL AND krithi_id IS NULL AND temple_id IS NULL AND section_id IS NULL AND variant_id IS NULLKSHETRA_OVERVIEW: temple_id IS NOT NULL AND krithi_id IS NULL AND tag_id IS NULL AND section_id IS NULL AND variant_id IS NULLELSE FALSER__seed_07 Amendment & R__seed_09 Implementation):
R__seed_07_canonical_cycle_tags.sql: Remove heuristic INSERT INTO krithi_tags ... WHERE lower(k.title) LIKE ... for Dikshitar cycles. Retain non-Dikshitar links (Tyagaraja Pancharatnam, Syama Sastri) and tag catalog rows.R__seed_09_dikshitar_cycle_memberships.sql:
DELETE FROM krithi_tags WHERE tag_id IN ('01920000-0000-7000-8000-000000000001', '01920000-0000-7000-8000-000000000002', '01920000-0000-7000-8000-000000000003', '01920000-0000-7000-8000-000000000005', '01920000-0000-7000-8000-000000000006') AND source = 'canonical_cycle';category = 'STOTRA_STYLE': guruguha-vibhakti, tyagaraja-vibhakti, tiruvarur-panchalinga, shodasa-ganapati, and nottusvara-sahitya.DHYANA at 0, axis_value = NULL; 9 CORE Avaranas with axis_value = Chakra name and JSONB Yoginis; MANGALAM at 10, axis_value = NULL). Enclosure 6 is Kamalambikayastava (Punnagavarali, SHASHTHI, chakra Sarvarakshakara, yogini Nigarbha). Enclosure 5 is the Bhairavi kriti in PANCHAMI, sung Sri Kamalambayah and often filed Sri Kamalambikayah. Enclosure 7 is Sri Kamalambikayam (Sahana, SAPTAMI, chakra Sarvarogahara, yogini Rahasya). Geometric enclosure shapes are not stored.CORE members at Tiruttani (axis_value = NULL)CORE members at Tiruvarur (axis_value = NULL)CORE members with raga suffix “-gaula” (axis_value = NULL; discriminated by krithis.vibhakti_case)CORE members + 2 OPTIONAL (Sadashraye and Sri Abhayamba manipravala mangalam, axis_value = NULL)CORE members (Surya..Shani) + 2 DISPUTED_CONJECTURE members (Rahu, Ketu)CORE elemental lingams across 5 regional towns (axis_value = NULL)CORE local sannidhis within Tiruvarur complex (axis_value = local lingam name)axis_value = tune name, e.g. 'God Save the King')place_kind = 'COMPLEX', mandalam = 'PANDYA') in temples. Do NOT seed search_documents in SQL to preserve single-writer ownership.fetch_krithi_candidates() in embed_catalogue.py and batch_embed_catalogue.py to join krithi_cycle_memberships and the new temple/krithi columns, deriving section architecture from krithi_sections.format_composition_overview() 2.0 with discriminative micro-clauses under a strict programmatic check: len(header.split()) <= 60. Include [Cycle: Nottusvara Sahitya; Tune: <axis_value>] for Nottusvara compositions.CYCLE_OVERVIEW and KSHETRA_OVERVIEW search documents anchored to tags or temples (including the Kanyakumari gap temple).evaluate_retrieval.py testing:
Sarvarakshakara, Yogini: Nigarbha, Case: Shashthi) disambiguated from both 5th enclosure (Sri Kamalambayah, Bhairavi; Case: Panchami) and 7th enclosure (Sri Kamalambikayam, Sahana; Chakra: Sarvarogahara, Yogini: Rahasya, Case: Saptami). The 5th is sung Sri Kamalambayah param nahi re and is often filed as Sri Kamalambikayah; match that sibling by Bhairavi and Panchami, not by the title stem alone.axis_value = 'God Save the King')search_documents.Status: Accepted
Accepted by: Seshadri
Accepted at: 2026-09-26
V66, V67) & Reference Seeds (R__seed_07 amend, R__seed_09 author)
database/migrations/V66__dikshitar_musicological_enrichment.sql implementing temples, krithis, krithi_cycle_memberships, search_documents anchor relaxation, and enum value additions.database/migrations/V67__search_document_anchor_constraints.sql implementing strict CASE chk_search_doc_anchor.database/migrations/R__seed_07_canonical_cycle_tags.sql to strip out heuristic Dikshitar cycle linking.database/migrations/R__seed_09_dikshitar_cycle_memberships.sql purging historical heuristic links, inserting 5 tags with category = 'STOTRA_STYLE', seeding reviewed cycle memberships (with Kamalamba Dhyana/Mangalam axis_value = NULL, Nottusvara axis_value = tune name), and seeding anchor temples and the Kanyakumari gap temple (temple row only).make migrate and verify schema integrity on both fresh and existing databases.modules/backend/dal, modules/shared/domain)
KrithiDto and TempleDto with new musicological fields.KrithisTable and TemplesTable in Exposed DAL.KrithiCycleMembershipsTable and query functions in KrithiRepository.kt.tools/krithi-extract-enrich-worker/src/embeddings/context_formatter.py to emit micro-clauses with len(header.split()) <= 60, deriving section structure from krithi_sections and emitting tune names for Nottusvaras.embed_catalogue.py and batch_embed_catalogue.py.CYCLE_OVERVIEW and KSHETRA_OVERVIEW search documents (including the Kanyakumari gap overview).batch_embed_catalogue.py on the Dikshitar cohort (481/481 embedded, 0 failures, 7,145 embeddings generated).evaluate_retrieval.py against the discriminative test battery, testing both composition and macro search documents (verified 100% recall on Track 145 battery).conductor/tracks.md and feature catalog.