ワンクリックで
rag-knowledge
RAG domain knowledge — architecture, component routing, rules, and reference tables. Use when working on any file under rag/.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
RAG domain knowledge — architecture, component routing, rules, and reference tables. Use when working on any file under rag/.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
MAS domain knowledge — architecture, component routing, rules, recipes. Use when working on any file under multi-agent/.
Project overview and domain routing table for the UnifAI monorepo. Each domain has its own skill with `paths` scoping for auto-surfacing when editing relevant files.
Deep investigation techniques for architecture reviews — import chain tracing, constructor audits, error propagation, cross-reference validation, test hygiene. Load during pipeline reviews or detailed architectural analysis.
Domain knowledge for the Platform Backend service. Admin config, platform API, and core orchestration. Use when working on files under backend/.
Domain knowledge for the Celery worker service. Async task execution for RAG pipeline processing. Shares codebase with rag/ — see RAG domain for core logic.
Domain knowledge for the global_utils shared Python library. Provides cross-service utilities: config, Redis, ports, helpers, embedding, Flask, and Celery app setup. Use when working on files under global_utils/.
| name | rag-knowledge |
| description | RAG domain knowledge — architecture, component routing, rules, and reference tables. Use when working on any file under rag/. |
| paths | rag/** |
Document ingestion and retrieval engine: data sources → processing pipeline → vector storage → semantic retrieval.
┌──────────┐
│ BOOTSTRAP│ wires ~40 singletons via @lru_cache
└────┬─────┘
│
┌─────────┼──────────────┐
▼ ▼ ▼
┌────────┐ ┌────────────┐ ┌──────────────┐
│PIPELINE│→│DATA-SOURCES│→│VECTOR-RETRIEVAL│ CORE (rag/core/ ~104 files)
└───┬────┘ └─────┬──────┘ └──────┬───────┘
│ │ │
▼ ▼ ▼
┌──────────────────────────────────────┐
│ INFRASTRUCTURE │ OUTER RING (~59 files)
│ flask (8 bps), mongo (7 colls), │
│ qdrant (2 colls), celery (3 queues)│
│ source connectors, embeddings │
└──────────────────────────────────────┘
| Path prefix | Component | Dev-guide section |
|---|---|---|
core/pipeline/ | Pipeline | rag.md → core_pipeline |
core/data_sources/, core/connector/, core/registration/ | Data Sources | rag.md → core_data_sources_registration |
core/vector/, core/retrieval/ | Vector Retrieval | rag.md → core_vector_retrieval |
core/monitoring/, core/health/ | Infrastructure | rag.md → core_monitoring_health |
infrastructure/ | Infrastructure | rag.md → architecture |
bootstrap/, config/ | Bootstrap | rag.md → bootstrap_factories |
For detailed component architecture and cross-component contracts:
| Component | Reference |
|---|---|
| Pipeline | references/pipeline.md — execution, dispatch, status tracking, Celery integration |
| Data Sources | references/data-sources.md — source types, plugin model, connectors, registration |
| Vector Retrieval | references/vector-retrieval.md — embeddings, chunking, Qdrant, semantic search |
| Infrastructure | references/infrastructure.md — Flask, Mongo, Qdrant, Celery, port-adapter wiring |
| Bootstrap | references/bootstrap.md — composition root, factories, config, local/remote switching |
| Working on... | Load |
|---|---|
| Pipeline execution, dispatch, Celery tasks | references/pipeline.md |
| Source types (document, Slack), connectors, registration | references/data-sources.md |
| Embeddings, chunking, Qdrant, semantic search | references/vector-retrieval.md |
| Flask endpoints, Mongo repos, Qdrant client, Celery | references/infrastructure.md |
| Wiring, config, factories, local/remote switching | references/bootstrap.md |
| Crossing component boundaries | Both relevant references/ files |
All document processing follows the strict pipeline pattern:
Registration → Dispatch (Celery) → Collect → Process → Chunk → Embed → Index → Status Update
Each stage is a discrete unit communicating via Pydantic models.
PipelineRecord tracks status: PENDING → PROCESSING → COMPLETED | FAILED.
Pipeline state is persisted for crash-recovery.
Each source type (document, Slack) provides its own set:
Connector, Processor, ChunkerStrategy, Validator(s), PipelineHandler, Registration, ConfigManager.
RegistrationFactory and get_pipeline_handler() select the correct set based on source type.
No if/elif chains for type resolution — factory pattern only.
All vector operations go through VectorRepository (ABC in core/vector/domain/repository.py).
The QdrantVectorRepository adapter implements this port.
Domain code never imports Qdrant client directly.
Two collections: document_data, slack_data.
Celery tasks in infrastructure/celery/workers/ are thin dispatchers:
PipelineExecutor or domain serviceBusiness logic never lives inside a Celery task function.
Three queues: document_queue, slack_queue, slack_events_queue.
Docling (document conversion) and embedding generation can run:
LocalDoclingAdapter, LocalEmbeddingAdapter)RemoteDoclingAdapter, RemoteEmbeddingAdapter)Controlled by config flags: use_remote_docling, use_remote_embedding.
Factories in bootstrap/factories.py select the adapter at startup.
21 port abstractions in RAG core. Every adapter implements exactly one port. Key port categories:
@lru_cache Singletonsapp_container.py wires ~40 singletons via @lru_cache property methods.
All dependency injection flows through this container.
Services receive dependencies as constructor parameters — no service locator.
These patterns are established and reviewers MUST NOT flag them as violations:
| Pattern | Where it exists | Why it's acceptable |
|---|---|---|
@lru_cache singleton container with parameterized caches | bootstrap/app_container.py (~640 lines, ~40 singletons) | Composition root — explicit function-call graphs, not string-keyed lookup; clear_all_caches() for tests |
Celery tasks importing directly from bootstrap.app_container | infrastructure/celery/workers/pipeline_tasks.py, slack_event_tasks.py | Tasks are driving adapters; 3-line delegate pattern (resolve → select handler → execute) |
Factory classes with if config.use_remote_* branching + lazy imports | bootstrap/factories.py, adapter __init__.py with PEP 562 __getattr__ | Encapsulated local/remote switching; prevents heavy deps (torch, docling) from loading in remote mode |
LangChain (langchain_text_splitters) in chunker implementations | infrastructure/sources/document/chunker.py, infrastructure/sources/slack/chunker.py | Chunkers are infrastructure adapters implementing ContentChunker port; core has ABC only |
AppConfig.get_instance() ambient singleton | Called from bootstrap/, infrastructure/http/, infrastructure/celery/app.py | Pydantic BaseSettings singleton — monorepo convention; bootstrap reads once, never from core |
get_pipeline_handler() registry dict in app_container | Maps "SLACK" / "DOCUMENT" → cached factory functions | Handler routing by source type; dictionary acts as a factory, not a service locator |
SourceFilterResolver injected without core port | core/retrieval/service.py accepts concrete SourceFilterResolver | Query helper for Qdrant filter composition; accepted typing shortcut — runtime injection is still via container |
Pipeline handlers in core/ importing concrete infrastructure types in type hints | DocumentPipelineHandler → DocumentConnector, PDFChunkerStrategy | Constructor injection is correct; the import-direction blur is typing only, not runtime coupling |
| Group | Count | Prefix | Key operations |
|---|---|---|---|
| Documents | 6 | /docs/ | upload, validate, query.match, list, tags |
| Slack | 7 | /slack/ | channels, search, events, stats, webhook |
| Data Sources | 4 | /data_sources/ | list, detail, update, delete |
| Pipelines/Vector | 2 | /pipelines/, /vector/ | embed trigger, chunk counts |
| Terms Approval | 2 | /terms_approval/ | approval status, record |
| Health/Settings | 5 | /health/, /settings/ | liveness, readiness, version, analytics |
| Celery Tasks | 2 | (RabbitMQ) | execute_pipeline, process_slack_events |
| Port | Adapter | Tech |
|---|---|---|
VectorRepository | QdrantVectorRepository | Qdrant |
PipelineRepository | MongoPipelineRepository | MongoDB |
DataSourceRepository | MongoDataSourceRepository | MongoDB |
MonitoringRepository | MongoMonitoringRepository | MongoDB |
SlackChannelRepository | MongoSlackChannelRepository | MongoDB |
TermsApprovalRepository | MongoTermsApprovalRepository | MongoDB |
EmbeddingPort | LocalEmbeddingAdapter / RemoteEmbeddingAdapter | sentence-transformers / HTTP |
DocumentConverterPort | LocalDoclingAdapter / RemoteDoclingAdapter | Docling / HTTP |
PipelineTaskDispatcher | CeleryPipelineDispatcher | RabbitMQ |
SlackEventDispatcher | CelerySlackEventDispatcher | RabbitMQ |
DataConnector | DocumentConnector / SlackConnector | Filesystem / Slack API |
ContentChunker | PDFChunkerStrategy / SlackChunkerStrategy | LangChain splitters |
| Store | Database | Collection | Adapter / Source Type |
|---|---|---|---|
| MongoDB | pipeline_monitoring | pipelines | MongoPipelineRepository |
| MongoDB | pipeline_monitoring | metrics, errors, logs | MongoMonitoringRepository |
| MongoDB | data_sources | sources | MongoDataSourceRepository |
| MongoDB | data_sources | slack_channels | MongoSlackChannelRepository |
| MongoDB | users | terms_user_approval | MongoTermsApprovalRepository |
| Qdrant | — | document_data | DOCUMENT source type |
| Qdrant | — | slack_data | SLACK source type |
For full endpoint signatures, class architecture, port catalogs, and call graphs beyond the tables above:
.cursor/unifai-dev-guide/docs/services/rag.md