| Metadata | Value |
|---|---|
| Status | Completed |
| Version | 1.2.1 |
| Last Updated | 2026-02-19 |
| Author | Sangita Grantha Architect |
Harden the Krithi import pipeline by implementing multi-source structural voting and authoritative source prioritization.
ImportService with ComposerSourcePriority map.StructuralVotingEngine to compare multi-source extractions.KrithiStructureParser for technical headers (Madhyama Kala, Chittaswaram).extraction CLI command to sangita-cli.ImportReview UI (TierBadge + AuthorityWarning — TRACK-044/052).ExtractionQueueRepository and ExtractionQueueService (TRACK-045).ExtractionResultProcessor for reading Python extraction results.| Artifact | Path | Description |
|---|---|---|
| Strategy document | application_documentation/01-requirements/krithi-data-sourcing/quality-strategy.md |
Comprehensive strategy covering all sourcing & quality work |
| Implementation checklist | application_documentation/01-requirements/krithi-data-sourcing/implementation-checklist.md |
Phase-by-phase task breakdown with acceptance criteria |
| StructuralVotingEngine | modules/backend/api/.../services/scraping/StructuralVotingEngine.kt |
Multi-source section structure voting |
| ImportService (enhanced) | modules/backend/api/.../services/ImportService.kt |
ComposerSourcePriority, structural voting integration |
| KrithiStructureParser (enhanced) | modules/backend/api/.../services/scraping/KrithiStructureParser.kt |
Multi-script detection, Madhyama Kala, Tamil subscripts |
| CanonicalExtractionDto | modules/shared/domain/.../import/CanonicalExtractionDto.kt |
Universal extraction format (Kotlin) |
| Canonical schema (Python) | tools/krithi-extract-enrich-worker/src/schema.py |
Pydantic model matching Kotlin DTO |
| Canonical JSON schema | shared/domain/model/import/canonical-extraction-schema.json |
JSON Schema for validation |
| Migration 23 | database/migrations/23__source_authority_enhancement.sql |
Source authority model |
| Migration 24 | database/migrations/24__krithi_source_evidence.sql |
Source evidence tracking |
| Migration 25 | database/migrations/25__structural_vote_log.sql |
Structural vote audit trail |
| Migration 26 | database/migrations/26__import_task_format_tracking.sql |
Format tracking |
| Migration 27 | database/migrations/27__extraction_queue.sql |
Kotlin ↔ Python extraction queue |
| Source registry seed | database/seed_data/04_import_sources_authority.sql |
Import sources with tier rankings |
| PDF extraction service | tools/krithi-extract-enrich-worker/ |
Python service (PyMuPDF, OCR, transliteration) |
| Dockerfile | tools/krithi-extract-enrich-worker/Dockerfile |
Container image with Tesseract + Indic packs |
| Docker Compose | compose.yaml |
Extended with krithi-extract-enrich-worker service |
| CLI extraction command | tools/sangita-cli/src/commands/extraction.rs |
sangita-cli extraction start/stop/status/logs |
| Sourcing UI/UX Plan | application_documentation/01-requirements/krithi-data-sourcing/ui-ux-plan.md |
UI/UX requirements for sourcing & extraction monitoring screens |
| ExtractionResultProcessor | modules/backend/api/.../services/ExtractionResultProcessor.kt |
Processes DONE extraction queue items → source evidence + structural voting |
| Migration 28 | database/migrations/28__extraction_ingested_status.sql |
Adds INGESTED status to extraction_status enum |
ImportService (ComposerSourcePriority map), plus parser upgrades for Madhyama Kala shorthand and Tamil subscript normalization in KrithiStructureParser. Created initial StructuralVotingEngine service.database/seed_data/04_import_sources_authority.sql.source_tier, supported_formats, composer_affinity columns on import_sources.krithi_source_evidence table — links each Krithi to all contributing sources with per-field provenance.structural_vote_log table — audit trail for cross-source structural voting decisions.source_format and page_range columns on import_task_run.extraction_queue table — database-backed work queue for Kotlin ↔ Python integration using SELECT ... FOR UPDATE SKIP LOCKED.CanonicalExtractionDto.kt) and Python (schema.py). This is the universal contract between all source adapters and the resolution pipeline.tools/krithi-extract-enrich-worker/ with:
extractor.py — PyMuPDF text extraction with font-size and position data.page_segmenter.py — Krithi boundary detection in anthology PDFs.structure_parser.py — Section label detection (P/A/C/SC/Chittaswaram).metadata_parser.py — Header field extraction (title, raga, tala, deity).ocr_fallback.py — Tesseract integration with Indic language packs.transliterator.py — indic-transliteration wrapper for script conversion.worker.py — Database-queue polling worker (production entry point).db.py — PostgreSQL operations for extraction_queue.cli.py — CLI for local development and testing.compose.yaml extended with krithi-extract-enrich-worker service (profile-gated, depends on postgres health).extraction command to sangita-cli with build, start, stop, logs, status, and restart subcommands.application_documentation/ across 12+ files:
04-database/schema.md — New tables §10.3–10.6, migration summary §1402-architecture/backend-system-design.md — Enhanced §5.4, new §5.8 (containerised extraction)06-backend/README.md — New services and extraction architecture08-operations/README.md — PDF extraction service operations01-requirements/README.md, 01-requirements/features/README.md — Links to krithi-data-sourcing07-quality/README.md, 07-quality/reports/README.md — Sourcing strategy and audit resultsREADME.md — Comprehensive link updates across all sectionsresult_payload as List<CanonicalExtractionDto>, matches each to existing Krithis (via normalised title), creates krithi_source_evidence records, and runs structural voting for Krithis with multiple sources. Marks processed items as INGESTED.INGESTED status to extraction_status DB enum to track Kotlin-processed items.markIngested() to ExtractionQueueRepository, createEvidence() to SourceEvidenceRepository, createVotingRecord() to StructuralVotingRepository.INGESTED to ExtractionStatus enum.POST /v1/admin/quality/extraction/process triggers batch processing.