from __future__ import annotations from app.modules.rag.contracts import EvidenceLink, EvidenceType, RagDocument, RagLayer, RagSource, RagSpan from app.modules.rag.indexing.code.entrypoints.registry import Entrypoint class EntrypointDocumentBuilder: def build(self, source: RagSource, entrypoint: Entrypoint) -> RagDocument: return RagDocument( layer=RagLayer.CODE_ENTRYPOINTS, lang="python", source=source, title=entrypoint.route_or_command, text=f"{entrypoint.framework} {entrypoint.entry_type} {entrypoint.route_or_command}", span=RagSpan(entrypoint.start_line, entrypoint.end_line), metadata={ "entry_id": entrypoint.entry_id, "entry_type": entrypoint.entry_type, "framework": entrypoint.framework, "route_or_command": entrypoint.route_or_command, "handler_symbol_id": entrypoint.handler_symbol_id, "lang_payload": entrypoint.metadata, "artifact_type": "CODE", }, links=[EvidenceLink(type=EvidenceType.CODE_SPAN, target_id=entrypoint.entry_id, path=source.path, start_line=entrypoint.start_line, end_line=entrypoint.end_line)], )