To ensure complete legal compliance, data provenance, and user trust in law enforcement and operational workflows, every factual answer returned by the assistant must provide transparent, standardized source citations.
[Vector DB / RAG] ---> (Document Name, Page, File Type, URI) ----+
[Catalyst DataStore] ---> (Table Name, Filter Scope, Record ID) ----+---> [Response Aggregator & Formatter] ---> [Unified Payload] ---> [Chat UI & Audit Layer]
[Agentic Tools (Groq)] ---> (Tool Type, Source URL / OCR Target) ----+
{
"response_id": "resp_987421_a4b9",
"badge_id": "OFFICER_4482",
"text": "According to SOP Section 3.2 and FIR #4029 records, the vehicle was impounded at 14:30 hrs...",
"sources": [
{
"source_id": "src_01",
"source_type": "rag_document",
"display_name": "SOP_Arrest_and_Impound_v3.pdf",
"location": "Page 12, Paragraph 4",
"uri": "catalyst://filestore/sops/SOP_Arrest_and_Impound_v3.pdf",
"mime_type": "application/pdf"
},
{
"source_id": "src_02",
"source_type": "database_record",
"display_name": "FIR_Records",
"identifier": "FIR #4029",
"scope": "Catalyst DataStore (ZCQL Read-Only)",
"filter_applied": "fir_id = 4029 AND precinct_code = 'BLR_CENTRAL'"
},
{
"source_id": "src_03",
"source_type": "external_web",
"display_name": "Ministry of Transport Official Guidelines",
"uri": "https://mha.gov.in/guidelines/vehicle-seizure-protocol",
"domain": "mha.gov.in"
},
{
"source_id": "src_04",
"source_type": "vision_extraction",
"display_name": "Zia Vision OCR",
"identifier": "Vehicle_Plate_Scan_img01.jpg",
"extracted_field": "KA01AB1234"
}
],
"metrics": {
"pipeline_route": "HYBRID_RAG_ZCQL",
"latency_ms": 780
}
}
[FEATURE TICKET] Implement Unified Source Citation & Attribution Pipeline
1. Overview & Business Context
1.1 Problem Statement
To ensure complete legal compliance, data provenance, and user trust in law enforcement and operational workflows, every factual answer returned by the assistant must provide transparent, standardized source citations.
Currently, responses stream raw text without unified references back to:
1.2 Objective
Build an attribution parsing and normalization pipeline inside the Response Aggregator & Formatter that maps source metadata into a unified JSON contract and renders interactive citations in the Chat UI Client.
2. Technical Architecture & Data Flow
3. Detailed Component Specifications
3.1 RAG Pipeline (Unstructured Documents)
document_name: Filename (e.g.,SOP_Arrest_Procedures_v2.pdf,IPC_Section_Reference.txt).file_type: Format identifier (pdf|txt|docx).location: Specific pointer (e.g.,Page 14, Section 3.2or chunk index).document_uri: Catalyst FileStore URI or authenticated preview link.badge_idlacks clearance.3.2 Text2ZCQL Pipeline (Structured DataStore)
table_name: Target Catalyst DataStore table (e.g.,FIR_Records,Vehicle_Registry).query_filter_summary: Evaluated filter parameters (e.g.,FIR_ID = 4029).matched_record_ids: List of primary keys returned by the read-only execution role.execution_type: Hardcoded toCatalyst_DataStore_ZCQL_ReadOnly.3.3 Agentic Fallback Engine (ReAct Agent / Groq LLM)
page_title, externalurl, and targetdomain.image_filename, model name (Zia_OCR|Qwen2.5-VL), andextracted_field(e.g.,License Plate: KA01AB1234).screen_id,active_module, and metadata filters.4. API Contract & Response Schema
4.1 JSON Response Payload
The
Response Aggregator & Formattermust attach the unifiedsourcesarray to the API response:5. Frontend & UI Implementation Requirements
5.1 Citation Chips
[1],[2]inline with the generated text.5.2 Interactive Behaviors
rag_document): Clicking the chip triggers an in-app viewer modal jumping to the exact page and section.database_record): Clicking triggers a slide-out drawer displaying sanitized record details.external_web): Opens the verified external URL in a secure new tab (rel="noopener noreferrer").6. Security, Compliance & Audit Requirements
Immutable, Append-Only Audit & Logging Layermust log the completesourcesarray along with thebadge_id, route, and execution timestamps.7. Definition of Done & Acceptance Criteria
sourceslist.rag_document,database_record,external_web,vision_extraction) render correctly in the chat UI with functional interactive triggers.